From a9cec9e5e230dbd56d62ae6dd517ae10252125ae Mon Sep 17 00:00:00 2001 From: Tom Tanner Date: Fri, 20 Mar 2015 10:34:30 +0000 Subject: Fixed Scons build for existing bits. Changed pynedit.pro to fetch from 'standard' install location Changed saveas code to use organizer report rather than uibase - this way it's not dependant on the vagaries of the include path, and works the same as the rest of the organiser directory --- src/SConscript | 23 +++++++++++++---------- src/savetextasdialog.cpp | 4 ++-- src/shared/SConscript | 3 +++ 3 files changed, 18 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/SConscript b/src/SConscript index 2eeb869e..3dd5d450 100644 --- a/src/SConscript +++ b/src/SConscript @@ -13,20 +13,16 @@ modules = [ 'Sql', 'WebKit', 'Xml', - 'XmlPatterns' + 'XmlPatterns', + 'Declarative' ] if env['QT_MAJOR_VERSION'] > 4: modules += [ 'Widgets', 'Qml', - 'Quick', 'WebKitWidgets' ] -else: - modules += [ - 'Declarative' - ] env.EnableQtModules(*modules) @@ -34,6 +30,7 @@ env.Uic4(env.Glob('*.ui')) env.RequireLibraries('uibase', 'shared', 'bsatk', 'esptk') + env.AppendUnique(LIBS = [ 'shell32', 'user32', @@ -58,8 +55,10 @@ for file in env.Glob('*.rc'): # Doing appendunique seems to throw the moc code into a tizzy env['CPPPATH'] += [ '../archive', - '../boss_modified/boss-api', +# '../boss_modified/boss-api', + '../plugins/gamefeatures', '.', # Why is this necessary? + '${LOOTPATH}', '${BOOSTPATH}', ] @@ -69,9 +68,7 @@ env.AppendUnique(CPPDEFINES = [ '_SCL_SECURE_NO_WARNINGS', 'NOMINMAX', 'BOOST_DISABLE_ASSERTS', -# Although the .pro file says it adds this, the compile line doesn't seem to -# have it (unless it's in the annoying '@' file -# 'NDEBUG' + 'NDEBUG' ]) env.AppendUnique(CPPFLAGS = [ '-wd4100', '-wd4127', '-wd4512', '-wd4189' ]) @@ -93,6 +90,9 @@ hgid = subprocess.check_output(['hg', 'id', '-i']).rstrip() about_env.AppendUnique(CPPDEFINES = [ 'HGID=\\"%s\\"' % hgid ]) other_sources.append(about_env.StaticObject('aboutdialog.cpp')) +env.AppendUnique(LIBPATH = "${ZLIBPATH}/build") +env.AppendUnique(LIBS = 'zlibstatic') + prog = env.Program('ModOrganizer', cpp_files + env.Glob('*.qrc') + other_sources) @@ -104,6 +104,9 @@ for subdir in ('tutorials', 'stylesheets'): # FIXME Sort the translations. Except they don't exist on the 1.2 branch +res = env['QT_USED_MODULES'] +Return('res') + """ CONFIG(debug, debug|release) { } else { diff --git a/src/savetextasdialog.cpp b/src/savetextasdialog.cpp index 1f23356f..1a940094 100644 --- a/src/savetextasdialog.cpp +++ b/src/savetextasdialog.cpp @@ -1,6 +1,6 @@ #include "savetextasdialog.h" #include "ui_savetextasdialog.h" -#include +#include "report.h" #include #include @@ -37,7 +37,7 @@ void SaveTextAsDialog::on_saveAsBtn_clicked() if (!fileName.isEmpty()) { QFile file(fileName); if (!file.open(QIODevice::WriteOnly)) { - MOBase::reportError(tr("failed to open \"%1\" for writing").arg(fileName)); + reportError(tr("failed to open \"%1\" for writing").arg(fileName)); return; } diff --git a/src/shared/SConscript b/src/shared/SConscript index 35c65d73..69a95289 100644 --- a/src/shared/SConscript +++ b/src/shared/SConscript @@ -20,3 +20,6 @@ env.AppendUnique(CPPPATH = [ # Not sure if renaming this helps much as it's static env.StaticLibrary('mo_shared', env.Glob('*.cpp')) + +res = env['QT_USED_MODULES'] +Return('res') -- cgit v1.3.1 From ea520baf4e4a512744552a8528e3b41145796151 Mon Sep 17 00:00:00 2001 From: Tom Tanner Date: Sun, 22 Mar 2015 10:49:15 +0000 Subject: Fix a meory leak with modules that error during loading More Sconscript stuff --- src/SConscript | 4 ++-- src/plugincontainer.cpp | 4 ++-- src/savegamegamebyro.h | 3 +-- 3 files changed, 5 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/SConscript b/src/SConscript index 3dd5d450..1d69c1d6 100644 --- a/src/SConscript +++ b/src/SConscript @@ -66,9 +66,9 @@ env.AppendUnique(CPPDEFINES = [ '_UNICODE', '_CRT_SECURE_NO_WARNINGS', '_SCL_SECURE_NO_WARNINGS', - 'NOMINMAX', 'BOOST_DISABLE_ASSERTS', - 'NDEBUG' + 'NDEBUG', + 'QT_MESSAGELOGCONTEXT' ]) env.AppendUnique(CPPFLAGS = [ '-wd4100', '-wd4127', '-wd4512', '-wd4189' ]) diff --git a/src/plugincontainer.cpp b/src/plugincontainer.cpp index 6bc9d12b..e1d9d9f0 100644 --- a/src/plugincontainer.cpp +++ b/src/plugincontainer.cpp @@ -266,7 +266,7 @@ void PluginContainer::loadPlugins() loadCheck.flush(); QString pluginName = iter.filePath(); if (QLibrary::isLibrary(pluginName)) { - QPluginLoader *pluginLoader = new QPluginLoader(pluginName, this); + std::unique_ptr pluginLoader(new QPluginLoader(pluginName, this)); if (pluginLoader->instance() == nullptr) { m_FailedPlugins.push_back(pluginName); qCritical("failed to load plugin %s: %s", @@ -274,7 +274,7 @@ void PluginContainer::loadPlugins() } else { if (registerPlugin(pluginLoader->instance(), pluginName)) { qDebug("loaded plugin \"%s\"", qPrintable(pluginName)); - m_PluginLoaders.push_back(pluginLoader); + m_PluginLoaders.push_back(pluginLoader.release()); } else { m_FailedPlugins.push_back(pluginName); qWarning("plugin \"%s\" failed to load", qPrintable(pluginName)); diff --git a/src/savegamegamebyro.h b/src/savegamegamebyro.h index eedda6c2..e08e1044 100644 --- a/src/savegamegamebyro.h +++ b/src/savegamegamebyro.h @@ -22,10 +22,9 @@ along with Mod Organizer. If not, see . #include "savegame.h" -#include + #include #include -#include #include #include -- cgit v1.3.1 From db7c6e6006d8e2607f6bfe2c86fd1247bfe09349 Mon Sep 17 00:00:00 2001 From: Tom Tanner Date: Wed, 25 Mar 2015 22:35:53 +0000 Subject: Add in all the necessary stuff for scons --- src/SConscript | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/SConscript b/src/SConscript index 1d69c1d6..a904f25f 100644 --- a/src/SConscript +++ b/src/SConscript @@ -26,7 +26,7 @@ if env['QT_MAJOR_VERSION'] > 4: env.EnableQtModules(*modules) -env.Uic4(env.Glob('*.ui')) +env.Uic(env.Glob('*.ui')) env.RequireLibraries('uibase', 'shared', 'bsatk', 'esptk') @@ -47,6 +47,7 @@ env.AppendUnique(LIBS = [ other_sources = env.AddExtraMoc(env.Glob('*.h')) for file in env.Glob('*.rc'): + # version.rc is included in app_icon.rc. Not sure why it's a separate file. if file.name == 'version.rc': continue other_sources.append(env.RES(file)) -- cgit v1.3.1 From 04b6f2e47554357641038d79b5c23df5e0e5745c Mon Sep 17 00:00:00 2001 From: Tom Tanner Date: Sat, 28 Mar 2015 10:11:09 +0000 Subject: Added json file dependency into moc scanner --- src/SConscript | 175 ++++++++++++++++++--------------------------------------- 1 file changed, 54 insertions(+), 121 deletions(-) (limited to 'src') diff --git a/src/SConscript b/src/SConscript index a904f25f..6f6916bf 100644 --- a/src/SConscript +++ b/src/SConscript @@ -1,123 +1,56 @@ import os -import subprocess -Import('qt_env') - -env = qt_env.Clone() - -modules = [ - 'Core', - 'Gui', - 'Network', - 'Script', - 'Sql', - 'WebKit', - 'Xml', - 'XmlPatterns', - 'Declarative' -] - -if env['QT_MAJOR_VERSION'] > 4: - modules += [ - 'Widgets', - 'Qml', - 'WebKitWidgets' - ] - -env.EnableQtModules(*modules) - -env.Uic(env.Glob('*.ui')) - -env.RequireLibraries('uibase', 'shared', 'bsatk', 'esptk') - - -env.AppendUnique(LIBS = [ - 'shell32', - 'user32', - 'ole32', - 'advapi32', - 'gdi32', - 'shlwapi', - 'Psapi', - 'Version' -]) - -# We have to 'persuade' moc to generate certain other targets and inject them -# into the list of cpps -other_sources = env.AddExtraMoc(env.Glob('*.h')) - -for file in env.Glob('*.rc'): - # version.rc is included in app_icon.rc. Not sure why it's a separate file. - if file.name == 'version.rc': - continue - other_sources.append(env.RES(file)) - -# Note the order of this is important, or you can pick up the wrong report.h... -# Doing appendunique seems to throw the moc code into a tizzy -env['CPPPATH'] += [ - '../archive', -# '../boss_modified/boss-api', - '../plugins/gamefeatures', - '.', # Why is this necessary? - '${LOOTPATH}', - '${BOOSTPATH}', -] - -env.AppendUnique(CPPDEFINES = [ - '_UNICODE', - '_CRT_SECURE_NO_WARNINGS', - '_SCL_SECURE_NO_WARNINGS', - 'BOOST_DISABLE_ASSERTS', - 'NDEBUG', - 'QT_MESSAGELOGCONTEXT' -]) - -env.AppendUnique(CPPFLAGS = [ '-wd4100', '-wd4127', '-wd4512', '-wd4189' ]) - -env.AppendUnique(LINKFLAGS = [ - '/SUBSYSTEM:WINDOWS', - '${EXE_MANIFEST_DEPENDENCY}' -]) - -# modeltest is optional and it doesn't compile anyway... -cpp_files = [ - x for x in Glob('*.cpp') - if x.name != 'modeltest.cpp' and x.name != 'aboutdialog.cpp' -] - -about_env = env.Clone() -hgid = subprocess.check_output(['hg', 'id', '-i']).rstrip() -# FIXME: It'd be much easier to stringify this in the source code -about_env.AppendUnique(CPPDEFINES = [ 'HGID=\\"%s\\"' % hgid ]) -other_sources.append(about_env.StaticObject('aboutdialog.cpp')) - -env.AppendUnique(LIBPATH = "${ZLIBPATH}/build") -env.AppendUnique(LIBS = 'zlibstatic') - -prog = env.Program('ModOrganizer', - cpp_files + env.Glob('*.qrc') + other_sources) - -env.InstallModule(prog) - -for subdir in ('tutorials', 'stylesheets'): - env.Install(os.path.join(env['INSTALL_PATH'], subdir), - env.Glob(os.path.join(subdir, '*'))) - -# FIXME Sort the translations. Except they don't exist on the 1.2 branch - -res = env['QT_USED_MODULES'] -Return('res') - -""" -CONFIG(debug, debug|release) { -} else { - QMAKE_CXXFLAGS += /Zi /GL - QMAKE_LFLAGS += /DEBUG /LTCG /OPT:REF /OPT:ICF -} - -TRANSLATIONS = organizer_en.ts - - -QMAKE_POST_LINK += xcopy /y /s /I $$quote($$BASEDIR\\*.qm) $$quote($$DSTDIR)\\translations $$escape_expand(\\n) - -""" +Import('env qt_env') + +def InstallModule(self, arg, subdir = None): + install_dir = '${INSTALL_PATH}' + if subdir is not None: + install_dir = os.path.join(install_dir, subdir) + # Ensure we install this when built from here, not just from top level build + self.Pseudo('install') + self.Depends('install', + self.Install(install_dir, + filter(lambda x: x.suffix in ('.dll', '.pdb', '.exe'), + arg))) + +def RequireLibraries(self, *libraries): + # Cannot use env.AppendUnique because it confuses moc +# self['CPPPATH'] += [ + # os.path.join('..', '..', library) for library in libraries + # ] + self.AppendUnique(CPPPATH = [ + os.path.join('..', library) for library in libraries + ]) + + self.AppendUnique(LIBPATH = [ + os.path.join('..', library) for library in libraries + ]) + + libs = list(libraries) + try: + idx = libs.index('shared') + libs[idx] = 'mo_shared' + except: + pass + + self.AppendUnique(LIBS = [ library for library in libs ]) + +qt_env = qt_env.Clone() +qt_env.AddMethod(InstallModule) +qt_env.AddMethod(RequireLibraries) + +env = env.Clone() +env.AddMethod(InstallModule) +env.AddMethod(RequireLibraries) + +libs_to_install = env.SConscript(env.Glob('*/SConscript'), + exports = 'env qt_env') +dll_manifest = 'dlls.manifest' +if qt_env['CONFIG'] == 'debug': + dll_manifest += '.debug' +if qt_env['QT_MAJOR_VERSION'] > 4: + dll_manifest += '.qt%d' % qt_env['QT_MAJOR_VERSION'] +qt_env.InstallAs(os.path.join(qt_env['INSTALL_PATH'], 'DLLs', 'dlls.manifest'), + dll_manifest) + +Return('libs_to_install') -- cgit v1.3.1 From 0269fc36e637dbe772c7463e07fa1aa330d3382d Mon Sep 17 00:00:00 2001 From: Tom Tanner Date: Sun, 29 Mar 2015 18:01:56 +0100 Subject: If there are no Missing ESPs, say "None" rather than leaving an empty list. --- src/savegameinfowidgetgamebryo.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/savegameinfowidgetgamebryo.cpp b/src/savegameinfowidgetgamebryo.cpp index b87d3165..c97e5810 100644 --- a/src/savegameinfowidgetgamebryo.cpp +++ b/src/savegameinfowidgetgamebryo.cpp @@ -71,4 +71,10 @@ void SaveGameInfoWidgetGamebryo::setSave(const SaveGame *saveGame) dotDotLabel->setFont(contentFont); layout->addWidget(dotDotLabel); } + if (count == 0) { + QLabel *dotDotLabel = new QLabel(tr("None")); + dotDotLabel->setIndent(10); + dotDotLabel->setFont(contentFont); + layout->addWidget(dotDotLabel); + } } -- cgit v1.3.1 From 11e67d7a6cec002fccbcf5295445e54644a1618f Mon Sep 17 00:00:00 2001 From: Tom Tanner Date: Sun, 19 Apr 2015 21:10:03 +0100 Subject: More fixing up of scons. Give up entirely with debugging python proxy --- README.txt | 17 ++---- src/SConscript | 179 ++++++++++++++++++++++++++++++++++++++++----------------- 2 files changed, 131 insertions(+), 65 deletions(-) (limited to 'src') diff --git a/README.txt b/README.txt index c171d2b6..637d0910 100644 --- a/README.txt +++ b/README.txt @@ -227,17 +227,12 @@ Troubleshooting (thanks to Ross): Complains about 'qtwebkit4' missing. For some reason this seems to insist on living with modorganiser.exe -6) Setting up so that you can use python proxy from the debug version. This is - necessary as PYQT5 build doesn't supply debug- and non-debug versions and it - appears the debug- and non-debug versions of the QT5 dlls don't play nicely - together. - Firstly, go to your build and run configuration in QTCreator, and *remove* - the qt bin dir from your build environment's PATH. - Then, in the DLLs directory, copy QT5Cored.dll to QT5Core.dll. Similary for - QT5Guid.gll and QT5Widgetsd.dll. - If you don't do both of these, then the program will die silently (if double - clicked) or print an obscure message about complaining you called QPixmap before - calling QApplication. +6) Debugging the python proxy: I (TT) don't think this is possible unless you have a debug + build of PyQt. However, a debug build of PyQt requires a debug build of python. There doesn't + appear to be a half way house which is build wiht normal python but debug versions of QT libraries. + You can confuse pyqt by copying the debug QT DLLs to appropriate named files in the DLLs + directory, and removing QT from your project run path, which results in the python proxy + initialising succesfully, but causes mod organiser to crash in strange places. ------------------- Building with scons diff --git a/src/SConscript b/src/SConscript index 6f6916bf..6783fd8b 100644 --- a/src/SConscript +++ b/src/SConscript @@ -1,56 +1,127 @@ import os +import subprocess -Import('env qt_env') - -def InstallModule(self, arg, subdir = None): - install_dir = '${INSTALL_PATH}' - if subdir is not None: - install_dir = os.path.join(install_dir, subdir) - # Ensure we install this when built from here, not just from top level build - self.Pseudo('install') - self.Depends('install', - self.Install(install_dir, - filter(lambda x: x.suffix in ('.dll', '.pdb', '.exe'), - arg))) - -def RequireLibraries(self, *libraries): - # Cannot use env.AppendUnique because it confuses moc -# self['CPPPATH'] += [ - # os.path.join('..', '..', library) for library in libraries - # ] - self.AppendUnique(CPPPATH = [ - os.path.join('..', library) for library in libraries - ]) - - self.AppendUnique(LIBPATH = [ - os.path.join('..', library) for library in libraries - ]) - - libs = list(libraries) - try: - idx = libs.index('shared') - libs[idx] = 'mo_shared' - except: - pass - - self.AppendUnique(LIBS = [ library for library in libs ]) - -qt_env = qt_env.Clone() -qt_env.AddMethod(InstallModule) -qt_env.AddMethod(RequireLibraries) - -env = env.Clone() -env.AddMethod(InstallModule) -env.AddMethod(RequireLibraries) - -libs_to_install = env.SConscript(env.Glob('*/SConscript'), - exports = 'env qt_env') -dll_manifest = 'dlls.manifest' -if qt_env['CONFIG'] == 'debug': - dll_manifest += '.debug' -if qt_env['QT_MAJOR_VERSION'] > 4: - dll_manifest += '.qt%d' % qt_env['QT_MAJOR_VERSION'] -qt_env.InstallAs(os.path.join(qt_env['INSTALL_PATH'], 'DLLs', 'dlls.manifest'), - dll_manifest) - -Return('libs_to_install') +Import('qt_env') + +env = qt_env.Clone() + +modules = [ + 'Core', + 'Gui', + 'Network', + 'Script', + 'Sql', + 'WebKit', + 'Xml', + 'XmlPatterns', + 'Declarative' +] + +if env['QT_MAJOR_VERSION'] > 4: + modules += [ + 'Widgets', + 'Qml', + 'WebKitWidgets' + ] + +env.EnableQtModules(*modules) + +env.Uic(env.Glob('*.ui')) + +env.RequireLibraries('uibase', 'shared', 'bsatk', 'esptk') + + +env.AppendUnique(LIBS = [ + 'shell32', + 'user32', + 'ole32', + 'advapi32', + 'gdi32', + 'shlwapi', + 'Psapi', + 'Version' +]) + +# We have to 'persuade' moc to generate certain other targets and inject them +# into the list of cpps +other_sources = env.AddExtraMoc(env.Glob('*.h')) + +for file in env.Glob('*.rc'): + # version.rc is included in app_icon.rc. Not sure why it's a separate file. + if file.name == 'version.rc': + continue + other_sources.append(env.RES(file)) + +# Note the order of this is important, or you can pick up the wrong report.h... +# Doing appendunique seems to throw the moc code into a tizzy +env['CPPPATH'] += [ + '../archive', +# '../boss_modified/boss-api', + '../plugins/gamefeatures', + '.', # Why is this necessary? + '${LOOTPATH}', + '${BOOSTPATH}', +] + +env.AppendUnique(CPPDEFINES = [ + '_UNICODE', + '_CRT_SECURE_NO_WARNINGS', + '_SCL_SECURE_NO_WARNINGS', + 'BOOST_DISABLE_ASSERTS', + 'NDEBUG', + 'QT_MESSAGELOGCONTEXT' +]) + +env.AppendUnique(CPPFLAGS = [ '-wd4100', '-wd4127', '-wd4512', '-wd4189' ]) + +env.AppendUnique(LINKFLAGS = [ + '/SUBSYSTEM:WINDOWS', + '${EXE_MANIFEST_DEPENDENCY}' +]) + +# modeltest is optional and it doesn't compile anyway... +cpp_files = [ + x for x in Glob('*.cpp') + if x.name != 'modeltest.cpp' and x.name != 'aboutdialog.cpp' +] + +about_env = env.Clone() +try: + hgid = subprocess.check_output(['hg', 'id', '-i']).rstrip() +except: + hgid = 'Unknown version' + +# FIXME: It'd be much easier to stringify this in the source code +about_env.AppendUnique(CPPDEFINES = [ 'HGID=\\"%s\\"' % hgid ]) +other_sources.append(about_env.StaticObject('aboutdialog.cpp')) + +env.AppendUnique(LIBPATH = "${ZLIBPATH}/build") +env.AppendUnique(LIBS = 'zlibstatic') + +prog = env.Program('ModOrganizer', + cpp_files + env.Glob('*.qrc') + other_sources) + +env.InstallModule(prog) + +for subdir in ('tutorials', 'stylesheets'): + env.Install(os.path.join(env['INSTALL_PATH'], subdir), + env.Glob(os.path.join(subdir, '*'))) + +# FIXME Sort the translations. Except they don't exist on the 1.2 branch + +res = env['QT_USED_MODULES'] +Return('res') + +""" +CONFIG(debug, debug|release) { +} else { + QMAKE_CXXFLAGS += /Zi /GL + QMAKE_LFLAGS += /DEBUG /LTCG /OPT:REF /OPT:ICF +} + +TRANSLATIONS = organizer_en.ts + + +QMAKE_POST_LINK += xcopy /y /s /I $$quote($$BASEDIR\\*.qm) $$quote($$DSTDIR)\\translations $$escape_expand(\\n) + +""" -- cgit v1.3.1 From a44cb011a5bf7e5825ac2eca8f183ea7eed63763 Mon Sep 17 00:00:00 2001 From: Tom Tanner Date: Sun, 19 Apr 2015 21:10:32 +0100 Subject: Small fixup to passing of argc/argv. --- src/moapplication.cpp | 2 +- src/moapplication.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/moapplication.cpp b/src/moapplication.cpp index df0fdd09..806c3142 100644 --- a/src/moapplication.cpp +++ b/src/moapplication.cpp @@ -73,7 +73,7 @@ public: }; -MOApplication::MOApplication(int argc, char **argv) +MOApplication::MOApplication(int &argc, char **argv) : QApplication(argc, argv) { connect(&m_StyleWatcher, SIGNAL(fileChanged(QString)), SLOT(updateStyle(QString))); diff --git a/src/moapplication.h b/src/moapplication.h index cf6bc625..9db130af 100644 --- a/src/moapplication.h +++ b/src/moapplication.h @@ -28,7 +28,7 @@ class MOApplication : public QApplication { Q_OBJECT public: - MOApplication(int argc, char **argv); + MOApplication(int &argc, char **argv); virtual bool notify (QObject *receiver, QEvent *event); -- cgit v1.3.1 From 927504cbd947a0cd794ed4777933df12bd0cd7e8 Mon Sep 17 00:00:00 2001 From: Tom Tanner Date: Sat, 25 Apr 2015 13:04:14 +0100 Subject: 1) reintroduce the report error when unpacking archives to avoid the error message disappearing entirely 2) Allow very long filenames to be used when unpacking --- src/installationmanager.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/installationmanager.cpp b/src/installationmanager.cpp index 7d431f02..e5f03481 100644 --- a/src/installationmanager.cpp +++ b/src/installationmanager.cpp @@ -414,11 +414,7 @@ void InstallationManager::updateProgressFile(LPCWSTR fileName) void InstallationManager::report7ZipError(LPCWSTR errorMessage) { -#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) - m_InstallationProgress.setLabelText(QString::fromWCharArray(errorMessage)); -#else - reportError(QString::fromUtf16(errorMessage)); -#endif + reportError(QString::fromWCharArray(errorMessage)); m_CurrentArchive->cancel(); } @@ -545,7 +541,7 @@ bool InstallationManager::doInstall(GuessedValue &modName, int modID, m_InstallationProgress.setValue(0); m_InstallationProgress.setWindowModality(Qt::WindowModal); m_InstallationProgress.show(); - if (!m_CurrentArchive->extract(ToWString(QDir::toNativeSeparators(targetDirectory)).c_str(), + if (!m_CurrentArchive->extract(ToWString("\\\\?\\" + QDir::toNativeSeparators(targetDirectory)).c_str(), new MethodCallback(this, &InstallationManager::updateProgress), new MethodCallback(this, &InstallationManager::updateProgressFile), new MethodCallback(this, &InstallationManager::report7ZipError))) { -- cgit v1.3.1 From ce925bc73e077fea813e509af4e9ad19f4306960 Mon Sep 17 00:00:00 2001 From: Tom Tanner Date: Sun, 26 Apr 2015 09:44:57 +0100 Subject: Allows drag-and-drop into the download tab --- src/downloadmanager.h | 14 ++++++ src/mainwindow.cpp | 117 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/mainwindow.h | 2 + src/mainwindow.ui | 8 +++- 4 files changed, 140 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/downloadmanager.h b/src/downloadmanager.h index c077ae79..5d047766 100644 --- a/src/downloadmanager.h +++ b/src/downloadmanager.h @@ -426,8 +426,22 @@ private slots: private: void createMetaFile(DownloadInfo *info); + +public: + + /** Get a unique filename for a download. + * + * This allows you multiple versions of download files, useful if the file + * comes from a web site with no version control + * + * @param basename: Name of the file + * + * @return Unique(ish) name + */ QString getDownloadFileName(const QString &baseName) const; +private: + void startDownload(QNetworkReply *reply, DownloadInfo *newDownload, bool resume); void resumeDownloadInt(int index); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 1566bc8a..945b258c 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -110,6 +110,7 @@ along with Mod Organizer. If not, see . #include #include #include +#include #if QT_VERSION >= QT_VERSION_CHECK(5,0,0) #include #else @@ -4547,3 +4548,119 @@ void MainWindow::on_manageArchivesBox_toggled(bool) { m_OrganizerCore.refreshBSAList(); } + +void MainWindow::dragEnterEvent(QDragEnterEvent *event) +{ + //Accept copy or move drags to the download window. Link drags are not + //meaningful (Well, they are - we could drop a link in the download folder, + //but you need privileges to do that). + if (ui->downloadTab->isVisible() && + (event->proposedAction() == Qt::CopyAction || + event->proposedAction() == Qt::MoveAction) && + event->answerRect().intersects(ui->downloadTab->rect())) { + + //If I read the documentation right, this won't work under a motif windows + //manager and the check needs to be done at the drop. However, that means + //the user might be allowed to drop things which we can't sanely process + QMimeData const *data = event->mimeData(); + + if (data->hasUrls()) { + QStringList extensions = + m_OrganizerCore.installationManager()->getSupportedExtensions(); + + //This is probably OK - scan to see if these are moderately sane archive + //types + QList urls = data->urls(); + bool ok = true; + for (auto url : urls) { + if (url.isLocalFile()) { + QString local = url.toLocalFile(); + bool fok = false; + for (auto ext : extensions) { + if (local.endsWith(ext, Qt::CaseInsensitive)) { + fok = true; + break; + } + } + if (! fok) { + ok = false; + break; + } + } + //We should probably allow the user to drop urls here and remember the + //url for installing later. + } + if (ok) { + event->accept(); + } + } + } +} + +void MainWindow::dropEvent(QDropEvent *event) +{ + Qt::DropAction action = event->proposedAction(); + QString output_dir = m_OrganizerCore.downloadManager()->getOutputDirectory(); + if (action == Qt::MoveAction) { + //Tell windows I'm taking control and will delete the source of a move. + event->setDropAction(Qt::TargetMoveAction); + } + for (auto url : event->mimeData()->urls()) { + QFileInfo file(url.toLocalFile()); + QString target = output_dir + "/" + file.fileName(); + //FIXME: Check here if the file exists and offer a rename + if (QFile::exists(target)) { + //Make this box have 2 buttons: + //'overwrite' and 'rename' + //for copy it's ok to add a 'do nothing' button + QMessageBox box(QMessageBox::Question, + file.fileName(), + tr("A file with the same name has already been downloaded. " + "What would you like to do?")); + box.addButton(tr("Overwrite"), QMessageBox::ActionRole); + box.addButton(tr("Rename new file"), QMessageBox::YesRole); + box.addButton(tr("Ignore file"), QMessageBox::RejectRole); + + box.exec(); + QMessageBox::ButtonRole role = box.buttonRole(box.clickedButton()); + switch (role) + { + case QMessageBox::RejectRole: + continue; + + case QMessageBox::ActionRole: + break; + + default: + case QMessageBox::YesRole: + target = m_OrganizerCore.downloadManager()->getDownloadFileName(file.fileName()); + break; + + } + } + + //We should really show progress and add a cancel button for these in case + //the operation takes a long time. + if (action == Qt::MoveAction) { + if (MoveFileExW(file.absoluteFilePath().toStdWString().c_str(), + target.toStdWString().c_str(), + MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING) != 0) { + continue; + } + } + else { + if (CopyFileW(file.absoluteFilePath().toStdWString().c_str(), + target.toStdWString().c_str(), + FALSE) != 0) { + continue; + } + } + //Something has gone horribly wrong here + qDebug("error %d", GetLastError()); + if (action == Qt::MoveAction) { + //Don't let the original source get deleted on a move + event->setDropAction(Qt::TargetMoveAction); + } + } + event->accept(); +} diff --git a/src/mainwindow.h b/src/mainwindow.h index 88419594..ddea1010 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -157,6 +157,8 @@ protected: virtual void closeEvent(QCloseEvent *event); virtual bool eventFilter(QObject *obj, QEvent *event); virtual void resizeEvent(QResizeEvent *event); + virtual void dragEnterEvent(QDragEnterEvent *event); + virtual void dropEvent(QDropEvent *event); private: diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 4201babf..ca93ea54 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -10,6 +10,9 @@ 710 + + true + Mod Organizer @@ -1140,11 +1143,14 @@ p, li { white-space: pre-wrap; } Qt::PreventContextMenu + + true + - This is a list of mods you downloaded from Nexus. Double click one to install it. + This is a list of mods you downloaded from Nexus. Double click one to install it. You can also drag an archive into here. Qt::ScrollBarAlwaysOn -- cgit v1.3.1 From c909f8ce4fa8d800a9cf5c0aafb5d8a3f577fcf9 Mon Sep 17 00:00:00 2001 From: Tom Tanner Date: Wed, 29 Apr 2015 21:14:46 +0100 Subject: remove redundant comments/code from drag'n'drop stuff --- src/mainwindow.cpp | 7 ------- 1 file changed, 7 deletions(-) (limited to 'src') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 945b258c..cadd935c 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -4610,9 +4610,6 @@ void MainWindow::dropEvent(QDropEvent *event) QString target = output_dir + "/" + file.fileName(); //FIXME: Check here if the file exists and offer a rename if (QFile::exists(target)) { - //Make this box have 2 buttons: - //'overwrite' and 'rename' - //for copy it's ok to add a 'do nothing' button QMessageBox box(QMessageBox::Question, file.fileName(), tr("A file with the same name has already been downloaded. " @@ -4657,10 +4654,6 @@ void MainWindow::dropEvent(QDropEvent *event) } //Something has gone horribly wrong here qDebug("error %d", GetLastError()); - if (action == Qt::MoveAction) { - //Don't let the original source get deleted on a move - event->setDropAction(Qt::TargetMoveAction); - } } event->accept(); } -- cgit v1.3.1 From 5f399f6a39c24cac66e572f1f78aea5703130dea Mon Sep 17 00:00:00 2001 From: Tom Tanner Date: Wed, 29 Apr 2015 21:18:43 +0100 Subject: Another removal of redundant commentary --- src/mainwindow.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index cadd935c..755b5469 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -4608,7 +4608,6 @@ void MainWindow::dropEvent(QDropEvent *event) for (auto url : event->mimeData()->urls()) { QFileInfo file(url.toLocalFile()); QString target = output_dir + "/" + file.fileName(); - //FIXME: Check here if the file exists and offer a rename if (QFile::exists(target)) { QMessageBox box(QMessageBox::Question, file.fileName(), -- cgit v1.3.1 From 26368df7a6f718b86fa2d5b6a616980037968160 Mon Sep 17 00:00:00 2001 From: Tom Tanner Date: Sun, 3 May 2015 08:43:12 +0100 Subject: Retain 'backup' switch state on mod overwrite options --- src/installationmanager.cpp | 6 +++++- src/queryoverwritedialog.cpp | 3 ++- src/queryoverwritedialog.h | 7 ++++++- 3 files changed, 13 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/installationmanager.cpp b/src/installationmanager.cpp index e5f03481..b55d8d3a 100644 --- a/src/installationmanager.cpp +++ b/src/installationmanager.cpp @@ -439,8 +439,12 @@ bool InstallationManager::testOverwrite(GuessedValue &modName, bool *me { QString targetDirectory = QDir::fromNativeSeparators(m_ModsDirectory + "\\" + modName); while (QDir(targetDirectory).exists()) { - QueryOverwriteDialog overwriteDialog(m_ParentWidget); + Settings &settings(Settings::instance()); + bool backup = settings.directInterface().value("backup_install", false).toBool(); + QueryOverwriteDialog overwriteDialog(m_ParentWidget, + backup ? QueryOverwriteDialog::BACKUP_YES : QueryOverwriteDialog::BACKUP_NO); if (overwriteDialog.exec()) { + settings.directInterface().setValue("backup_install", overwriteDialog.backup()); if (overwriteDialog.backup()) { QString backupDirectory = generateBackupName(targetDirectory); if (!copyDir(targetDirectory, backupDirectory, false)) { diff --git a/src/queryoverwritedialog.cpp b/src/queryoverwritedialog.cpp index 1d7aea0a..932b2637 100644 --- a/src/queryoverwritedialog.cpp +++ b/src/queryoverwritedialog.cpp @@ -20,11 +20,12 @@ along with Mod Organizer. If not, see . #include "queryoverwritedialog.h" #include "ui_queryoverwritedialog.h" -QueryOverwriteDialog::QueryOverwriteDialog(QWidget *parent) +QueryOverwriteDialog::QueryOverwriteDialog(QWidget *parent, Backup b) : QDialog(parent), ui(new Ui::QueryOverwriteDialog), m_Action(ACT_NONE) { ui->setupUi(this); + ui->backupBox->setChecked(b == BACKUP_YES); QIcon icon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxQuestion); ui->iconLabel->setPixmap(icon.pixmap(128)); diff --git a/src/queryoverwritedialog.h b/src/queryoverwritedialog.h index 1a22a60e..3f7b3194 100644 --- a/src/queryoverwritedialog.h +++ b/src/queryoverwritedialog.h @@ -37,8 +37,13 @@ public: ACT_RENAME }; + enum Backup { + BACKUP_NO, + BACKUP_YES + }; + public: - explicit QueryOverwriteDialog(QWidget *parent = 0); + QueryOverwriteDialog(QWidget *parent, Backup b); ~QueryOverwriteDialog(); bool backup() const; Action action() const { return m_Action; } -- cgit v1.3.1 From 89eabf3c4df39f918fae9414d26a4cf5459f2047 Mon Sep 17 00:00:00 2001 From: Tom Tanner Date: Sun, 3 May 2015 09:51:01 +0100 Subject: added a 'yes to all' shellMove and made the drag-and-drop code use shellMove/shellCopy --- src/mainwindow.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 755b5469..578d4419 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -4635,19 +4635,13 @@ void MainWindow::dropEvent(QDropEvent *event) } } - //We should really show progress and add a cancel button for these in case - //the operation takes a long time. if (action == Qt::MoveAction) { - if (MoveFileExW(file.absoluteFilePath().toStdWString().c_str(), - target.toStdWString().c_str(), - MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING) != 0) { + if (shellMove(file.absoluteFilePath(), target, true, this)) { continue; } } else { - if (CopyFileW(file.absoluteFilePath().toStdWString().c_str(), - target.toStdWString().c_str(), - FALSE) != 0) { + if (shellCopy(file.absoluteFilePath(), target, true, this)) { continue; } } -- cgit v1.3.1 From 1403d51a82fa4c7548e21d7411486244881bc8d8 Mon Sep 17 00:00:00 2001 From: Tom Tanner Date: Sat, 9 May 2015 11:41:39 +0100 Subject: Fix mod organiser not picking up stuff from a blank profile --- src/executableslist.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/executableslist.cpp b/src/executableslist.cpp index 35bb30ae..c4766fa8 100644 --- a/src/executableslist.cpp +++ b/src/executableslist.cpp @@ -181,12 +181,16 @@ void ExecutablesList::addExecutable(const QString &title, const QString &executa auto existingExe = findExe(title); if (existingExe != m_Executables.end()) { + //A note: If this isn't customised, we want to leave + //the directory and so on WELL alone + if (custom) { + existingExe->m_BinaryInfo = file; + existingExe->m_Arguments = arguments; + existingExe->m_WorkingDirectory = workingDirectory; + existingExe->m_SteamAppID = steamAppID; + } existingExe->m_Title = title; existingExe->m_CloseMO = closeMO; - existingExe->m_BinaryInfo = file; - existingExe->m_Arguments = arguments; - existingExe->m_WorkingDirectory = workingDirectory; - existingExe->m_SteamAppID = steamAppID; existingExe->m_Custom = custom; existingExe->m_Toolbar = toolbar; if (pos >= 0) { -- cgit v1.3.1