From f1515193ca82c229a712f067f61f1c26e9b83400 Mon Sep 17 00:00:00 2001 From: Tannin Date: Wed, 27 Nov 2013 20:25:24 +0100 Subject: - plugins can now be localized too - fixes to the installer script - extended build scripts to fetch translations from pootle server automatically --- src/mainwindow.cpp | 63 +++++++++++++++++++++++++++++------------------------- 1 file changed, 34 insertions(+), 29 deletions(-) (limited to 'src/mainwindow.cpp') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 31ee1ae7..5c487e7a 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -144,8 +144,7 @@ MainWindow::MainWindow(const QString &exeName, QSettings &initSettings, QWidget m_DirectoryStructure(new DirectoryEntry(L"data", NULL, 0)), m_ModList(this), m_ModListGroupingProxy(NULL), m_ModListSortProxy(NULL), m_PluginList(this), m_OldExecutableIndex(-1), m_GamePath(ToQString(GameInfo::instance().getGameDirectory())), - m_DownloadManager(NexusInterface::instance(), this), - m_InstallationManager(this), m_Translator(NULL), m_TranslatorQt(NULL), + m_DownloadManager(NexusInterface::instance(), this), m_InstallationManager(this), m_Updater(NexusInterface::instance(), this), m_CategoryFactory(CategoryFactory::instance()), m_CurrentProfile(NULL), m_AskForNexusPW(false), m_LoginAttempted(false), m_ArchivesInit(false), m_ContextItem(NULL), m_ContextAction(NULL), m_CurrentSaveView(NULL), @@ -975,7 +974,7 @@ void MainWindow::registerPluginTool(IPluginTool *tool) } -bool MainWindow::registerPlugin(QObject *plugin) +bool MainWindow::registerPlugin(QObject *plugin, const QString &fileName) { { // generic treatment for all plugins IPlugin *pluginObj = qobject_cast(plugin); @@ -983,6 +982,7 @@ bool MainWindow::registerPlugin(QObject *plugin) qDebug("not an IPlugin"); return false; } + plugin->setProperty("filename", fileName); m_Settings.registerPlugin(pluginObj); } @@ -1017,7 +1017,7 @@ bool MainWindow::registerPlugin(QObject *plugin) try { QObject *proxiedPlugin = proxy->instantiate(pluginName); if (proxiedPlugin != NULL) { - if (registerPlugin(proxiedPlugin)) { + if (registerPlugin(proxiedPlugin, pluginName)) { qDebug("loaded plugin \"%s\"", QDir::toNativeSeparators(pluginName).toUtf8().constData()); } else { qWarning("plugin \"%s\" failed to load", pluginName.toUtf8().constData()); @@ -1052,7 +1052,7 @@ void MainWindow::loadPlugins() m_Settings.clearPlugins(); foreach (QObject *plugin, QPluginLoader::staticInstances()) { - registerPlugin(plugin); + registerPlugin(plugin, ""); } QFile loadCheck(QCoreApplication::applicationDirPath() + "/plugin_loadcheck.tmp"); @@ -1095,7 +1095,7 @@ void MainWindow::loadPlugins() qCritical("failed to load plugin %s: %s", pluginName.toUtf8().constData(), pluginLoader.errorString().toUtf8().constData()); } else { - if (registerPlugin(pluginLoader.instance())) { + if (registerPlugin(pluginLoader.instance(), pluginName)) { qDebug("loaded plugin \"%s\"", QDir::toNativeSeparators(pluginName).toUtf8().constData()); } else { m_UnloadedPlugins.push_back(pluginName); @@ -3998,35 +3998,40 @@ void MainWindow::downloadRequested(QNetworkReply *reply, int modID, const QStrin } -void MainWindow::languageChange(const QString &newLanguage) +QTranslator *MainWindow::installTranslator(const QString &name) { - if (m_Translator != NULL) { - QCoreApplication::removeTranslator(m_Translator); - delete m_Translator; - m_Translator = NULL; + QTranslator *translator = new QTranslator(this); + QString fileName = name + "_" + m_CurrentLanguage; + if (!translator->load(fileName, qApp->applicationDirPath() + "/translations")) { + qWarning("localization file %s not found", qPrintable(fileName)); } - if (m_TranslatorQt != NULL) { - QCoreApplication::removeTranslator(m_TranslatorQt); - delete m_TranslatorQt; - m_TranslatorQt = NULL; + qApp->installTranslator(translator); + return translator; +} + + +void MainWindow::languageChange(const QString &newLanguage) +{ + foreach (QTranslator *trans, m_Translators) { + qApp->removeTranslator(trans); } + m_Translators.clear(); - if (newLanguage != "en_US") { - // add our own translations - m_Translator = new QTranslator(this); - QString locFile = ToQString(AppConfig::translationPrefix()) + "_" + newLanguage; - if (!m_Translator->load(locFile, QCoreApplication::applicationDirPath() + "/translations")) { - qDebug("localization %s not found", locFile.toUtf8().constData()); - } - QCoreApplication::installTranslator(m_Translator); + m_CurrentLanguage = newLanguage; - // also add the translations for qt default strings - m_TranslatorQt = new QTranslator(this); - locFile = QString("qt_") + newLanguage; - if (!m_TranslatorQt->load(locFile, QCoreApplication::applicationDirPath() + "/translations")) { - qDebug("localization %s not found", locFile.toUtf8().constData()); + if (newLanguage != "en_US") { + installTranslator("qt"); + installTranslator(ToQString(AppConfig::translationPrefix())); + foreach(IPlugin *plugin, m_Settings.plugins()) { + QObject *pluginObj = dynamic_cast(plugin); + if (pluginObj != NULL) { + QVariant fileNameVariant = pluginObj->property("filename"); + if (fileNameVariant.isValid()) { + QString fileName = QFileInfo(fileNameVariant.toString()).baseName(); + m_Translators.push_back(installTranslator(fileName)); + } + } } - QCoreApplication::installTranslator(m_TranslatorQt); } ui->retranslateUi(this); ui->profileBox->setItemText(0, QObject::tr("")); -- cgit v1.3.1 From b32457a7d2af4aeb095308c7f358a7a398ad849e Mon Sep 17 00:00:00 2001 From: Tannin Date: Sat, 7 Dec 2013 16:07:28 +0100 Subject: - minor text fixes - versions without a subminor version are now displayed without it (1.1 instead of 1.1.0) - version compares now prefer the decimal comparison over the traditional --- src/mainwindow.cpp | 6 +++--- src/mainwindow.h | 2 +- src/mainwindow.ui | 57 ++++++------------------------------------------------ src/version.rc | 4 ++-- 4 files changed, 12 insertions(+), 57 deletions(-) (limited to 'src/mainwindow.cpp') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 5c487e7a..59666a20 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -3998,7 +3998,7 @@ void MainWindow::downloadRequested(QNetworkReply *reply, int modID, const QStrin } -QTranslator *MainWindow::installTranslator(const QString &name) +void MainWindow::installTranslator(const QString &name) { QTranslator *translator = new QTranslator(this); QString fileName = name + "_" + m_CurrentLanguage; @@ -4006,7 +4006,7 @@ QTranslator *MainWindow::installTranslator(const QString &name) qWarning("localization file %s not found", qPrintable(fileName)); } qApp->installTranslator(translator); - return translator; + m_Translators.push_back(translator); } @@ -4028,7 +4028,7 @@ void MainWindow::languageChange(const QString &newLanguage) QVariant fileNameVariant = pluginObj->property("filename"); if (fileNameVariant.isValid()) { QString fileName = QFileInfo(fileNameVariant.toString()).baseName(); - m_Translators.push_back(installTranslator(fileName)); + installTranslator(fileName); } } } diff --git a/src/mainwindow.h b/src/mainwindow.h index 5a8278f9..197ac73c 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -272,7 +272,7 @@ private: static void setupNetworkProxy(bool activate); void activateProxy(bool activate); - QTranslator *installTranslator(const QString &name); + void installTranslator(const QString &name); private: diff --git a/src/mainwindow.ui b/src/mainwindow.ui index bc7dc212..73ca868e 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -31,16 +31,7 @@ 4 - - 6 - - - 6 - - - 6 - - + 6 @@ -586,7 +577,7 @@ p, li { white-space: pre-wrap; } QTabWidget::Rounded - 0 + 1 @@ -730,16 +721,7 @@ p, li { white-space: pre-wrap; } Archives - - 6 - - - 6 - - - 6 - - + 6 @@ -819,16 +801,7 @@ BSAs checked here are loaded in such a way that your installation order is obeye Data - - 6 - - - 6 - - - 6 - - + 6 @@ -898,16 +871,7 @@ BSAs checked here are loaded in such a way that your installation order is obeye Saves - - 6 - - - 6 - - - 6 - - + 6 @@ -936,16 +900,7 @@ p, li { white-space: pre-wrap; } Downloads - - 2 - - - 2 - - - 2 - - + 2 diff --git a/src/version.rc b/src/version.rc index ab144909..b91dce85 100644 --- a/src/version.rc +++ b/src/version.rc @@ -1,7 +1,7 @@ #include "Winver.h" -#define VER_FILEVERSION 1,0,8,0 -#define VER_FILEVERSION_STR "1,0,8,0\0" +#define VER_FILEVERSION 1,0,10,0 +#define VER_FILEVERSION_STR "1,0,10,0\0" VS_VERSION_INFO VERSIONINFO FILEVERSION VER_FILEVERSION -- cgit v1.3.1 From e71c37df37dea1e4eb8b5e87027fc7f5f81bef56 Mon Sep 17 00:00:00 2001 From: Tannin Date: Sat, 7 Dec 2013 16:54:08 +0100 Subject: - bugfix: drag&drop on archive list didn't always work properly --- src/mainwindow.cpp | 6 ++++-- src/mainwindow.ui | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'src/mainwindow.cpp') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 59666a20..102c798e 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -207,6 +207,8 @@ MainWindow::MainWindow(const QString &exeName, QSettings &initSettings, QWidget } ui->espList->installEventFilter(&m_PluginList); + ui->bsaList->setLocalMoveOnly(true); + resizeLists(initSettings.contains("mod_list_state"), initSettings.contains("plugin_list_state")); QMenu *linkMenu = new QMenu(this); @@ -1790,8 +1792,8 @@ void MainWindow::refreshBSAList() QTreeWidgetItem *newItem = new QTreeWidgetItem(strings); newItem->setData(0, Qt::UserRole, index); newItem->setData(1, Qt::UserRole, origin); -// newItem->setFlags(newItem->flags() & ~Qt::ItemIsDropEnabled | Qt::ItemIsUserCheckable); - newItem->setFlags(newItem->flags() | Qt::ItemIsUserCheckable); + newItem->setFlags(newItem->flags() & ~Qt::ItemIsDropEnabled | Qt::ItemIsUserCheckable); +// newItem->setFlags(newItem->flags() | Qt::ItemIsUserCheckable); newItem->setCheckState(0, (index != -1) ? Qt::Checked : Qt::Unchecked); if (m_Settings.forceEnableCoreFiles() && m_DefaultArchives.contains(filename)) { newItem->setCheckState(0, Qt::Checked); diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 73ca868e..5c89a7e0 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -577,7 +577,7 @@ p, li { white-space: pre-wrap; } QTabWidget::Rounded - 1 + 0 -- cgit v1.3.1