From 115315df2809fb66eb5b18b85f089da457ccc19b Mon Sep 17 00:00:00 2001 From: Tannin Date: Sat, 10 Oct 2015 19:29:45 +0200 Subject: build fixes --- src/CMakeLists.txt | 2 +- src/app_icon.rc | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c2d0b42a..22b725de 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -228,7 +228,7 @@ SET(organizer_QRCS SET(organizer_RCS app_icon.rc - #version.rc + version.rc ) diff --git a/src/app_icon.rc b/src/app_icon.rc index 2550f49d..6e79ef7d 100644 --- a/src/app_icon.rc +++ b/src/app_icon.rc @@ -1,3 +1 @@ -#include "version.rc" - - IDI_ICON1 ICON DISCARDABLE "mo_icon.ico" +IDI_ICON1 ICON DISCARDABLE "mo_icon.ico" -- cgit v1.3.1 From 90d87a0cf75be44da34c3c3282f82e5b3a399168 Mon Sep 17 00:00:00 2001 From: Tannin Date: Sat, 10 Oct 2015 19:35:18 +0200 Subject: fixed progress dialogs appearing on startup Appears to be a new bug in qt or maybe incompatibility with Windows 10: All Progress dialogs were made visibly automatically a few seconds after application startup. This was "fixed" by creating the dialog dynamically on demand --- src/installationmanager.cpp | 83 +++++++++++++++++++++++++-------------------- src/installationmanager.h | 2 +- src/nxmaccessmanager.cpp | 18 ++++++---- src/nxmaccessmanager.h | 2 +- src/selfupdater.cpp | 40 ++++++++++++++-------- src/selfupdater.h | 8 +++-- 6 files changed, 90 insertions(+), 63 deletions(-) (limited to 'src') diff --git a/src/installationmanager.cpp b/src/installationmanager.cpp index 75abd750..a6af1a7f 100644 --- a/src/installationmanager.cpp +++ b/src/installationmanager.cpp @@ -34,6 +34,7 @@ along with Mod Organizer. If not, see . #include #include #include +#include #include #include #include @@ -71,7 +72,6 @@ static T resolveFunction(QLibrary &lib, const char *name) InstallationManager::InstallationManager() : m_ParentWidget(nullptr) - , m_InstallationProgress(nullptr) , m_SupportedExtensions({ "zip", "rar", "7z", "fomod", "001" }) { QLibrary archiveLib("dlls\\archive.dll"); @@ -85,8 +85,6 @@ InstallationManager::InstallationManager() if (!m_CurrentArchive->isValid()) { throw MyException(getErrorString(m_CurrentArchive->getLastError())); } - - m_InstallationProgress.setWindowFlags(m_InstallationProgress.windowFlags() & (~Qt::WindowContextHelpButtonHint)); } @@ -97,7 +95,6 @@ InstallationManager::~InstallationManager() void InstallationManager::setParentWidget(QWidget *widget) { - m_InstallationProgress.setParent(widget, Qt::Dialog); for (IPluginInstaller *installer : m_Installers) { installer->setParentWidget(widget); } @@ -171,19 +168,24 @@ bool InstallationManager::unpackSingleFile(const QString &fileName) return false; } - m_InstallationProgress.setWindowTitle(tr("Extracting files")); - m_InstallationProgress.setLabelText(QString()); - m_InstallationProgress.setValue(0); - m_InstallationProgress.setWindowModality(Qt::WindowModal); - m_InstallationProgress.show(); + m_InstallationProgress = new QProgressDialog(m_ParentWidget); + ON_BLOCK_EXIT([this] () { + m_InstallationProgress->hide(); + m_InstallationProgress->deleteLater(); + m_InstallationProgress = nullptr; + }); + m_InstallationProgress->setWindowFlags( + m_InstallationProgress->windowFlags() & ~Qt::WindowContextHelpButtonHint); + + m_InstallationProgress->setWindowTitle(tr("Extracting files")); + m_InstallationProgress->setWindowModality(Qt::WindowModal); + m_InstallationProgress->show(); bool res = m_CurrentArchive->extract(ToWString(QDir::toNativeSeparators(QDir::tempPath())).c_str(), new MethodCallback(this, &InstallationManager::updateProgress), new MethodCallback(this, &InstallationManager::dummyProgressFile), new MethodCallback(this, &InstallationManager::report7ZipError)); - m_InstallationProgress.hide(); - return res; } @@ -191,7 +193,7 @@ bool InstallationManager::unpackSingleFile(const QString &fileName) QString InstallationManager::extractFile(const QString &fileName) { if (unpackSingleFile(fileName)) { - return QDir::tempPath().append("/").append(QFileInfo(fileName).fileName()); + return QDir::tempPath() + "/" + QFileInfo(fileName).fileName(); } else { return QString(); } @@ -215,7 +217,7 @@ QStringList InstallationManager::extractFiles(const QStringList &filesOrig, bool { QStringList files; - foreach (const QString &file, filesOrig) { + for (const QString &file : filesOrig) { files.append(canonicalize(file)); } @@ -249,22 +251,26 @@ QStringList InstallationManager::extractFiles(const QStringList &filesOrig, bool } } - m_InstallationProgress.setWindowTitle(tr("Extracting files")); - m_InstallationProgress.setLabelText(QString()); - m_InstallationProgress.setValue(0); - m_InstallationProgress.setWindowModality(Qt::WindowModal); - m_InstallationProgress.show(); + m_InstallationProgress = new QProgressDialog(m_ParentWidget); + ON_BLOCK_EXIT([this] () { + m_InstallationProgress->hide(); + m_InstallationProgress->deleteLater(); + m_InstallationProgress = nullptr; + }); + m_InstallationProgress->setWindowFlags( + m_InstallationProgress->windowFlags() & (~Qt::WindowContextHelpButtonHint)); + m_InstallationProgress->setWindowTitle(tr("Extracting files")); + m_InstallationProgress->setWindowModality(Qt::WindowModal); + m_InstallationProgress->show(); // unpack only the files we need for the installer if (!m_CurrentArchive->extract(ToWString(QDir::toNativeSeparators(QDir::tempPath())).c_str(), new MethodCallback(this, &InstallationManager::updateProgress), new MethodCallback(this, &InstallationManager::dummyProgressFile), new MethodCallback(this, &InstallationManager::report7ZipError))) { - m_InstallationProgress.hide(); throw MyException(QString("extracting failed (%1)").arg(m_CurrentArchive->getLastError())); } - m_InstallationProgress.hide(); return result; } @@ -387,21 +393,21 @@ DirectoryTree::Node *InstallationManager::getSimpleArchiveBase(DirectoryTree *da void InstallationManager::updateProgress(float percentage) { - m_InstallationProgress.setValue(static_cast(percentage * 100.0)); - if (m_InstallationProgress.wasCanceled()) { - m_CurrentArchive->cancel(); - m_InstallationProgress.reset(); + if (m_InstallationProgress != nullptr) { + m_InstallationProgress->setValue(static_cast(percentage * 100.0)); + if (m_InstallationProgress->wasCanceled()) { + m_CurrentArchive->cancel(); + m_InstallationProgress->reset(); + } } } void InstallationManager::updateProgressFile(LPCWSTR fileName) { -#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) - m_InstallationProgress.setLabelText(QString::fromWCharArray(fileName)); -#else - m_InstallationProgress.setLabelText(QString::fromUtf16(fileName)); -#endif + if (m_InstallationProgress != nullptr) { + m_InstallationProgress->setLabelText(QString::fromWCharArray(fileName)); + } } @@ -533,16 +539,21 @@ bool InstallationManager::doInstall(GuessedValue &modName, int modID, qDebug("installing to \"%s\"", targetDirectoryNative.toUtf8().constData()); - m_InstallationProgress.setWindowTitle(tr("Extracting files")); - m_InstallationProgress.setLabelText(QString()); - m_InstallationProgress.setValue(0); - m_InstallationProgress.setWindowModality(Qt::WindowModal); - m_InstallationProgress.show(); + m_InstallationProgress = new QProgressDialog(m_ParentWidget); + ON_BLOCK_EXIT([this] () { + m_InstallationProgress->hide(); + m_InstallationProgress->deleteLater(); + m_InstallationProgress = nullptr; + }); + + m_InstallationProgress->setWindowFlags( + m_InstallationProgress->windowFlags() & (~Qt::WindowContextHelpButtonHint)); + m_InstallationProgress->setWindowModality(Qt::WindowModal); + m_InstallationProgress->show(); if (!m_CurrentArchive->extract(ToWString("\\\\?\\" + targetDirectoryNative).c_str(), new MethodCallback(this, &InstallationManager::updateProgress), new MethodCallback(this, &InstallationManager::updateProgressFile), new MethodCallback(this, &InstallationManager::report7ZipError))) { - m_InstallationProgress.hide(); if (m_CurrentArchive->getLastError() == Archive::ERROR_EXTRACT_CANCELLED) { return false; } else { @@ -550,8 +561,6 @@ bool InstallationManager::doInstall(GuessedValue &modName, int modID, } } - m_InstallationProgress.hide(); - QSettings settingsFile(targetDirectory + "/meta.ini", QSettings::IniFormat); // overwrite settings only if they are actually are available or haven't been set before diff --git a/src/installationmanager.h b/src/installationmanager.h index d4b4f7dc..111b41f5 100644 --- a/src/installationmanager.h +++ b/src/installationmanager.h @@ -208,7 +208,7 @@ private: Archive *m_CurrentArchive; QString m_CurrentFile; - QProgressDialog m_InstallationProgress; + QProgressDialog *m_InstallationProgress { nullptr }; std::set m_TempFilesToDelete; diff --git a/src/nxmaccessmanager.cpp b/src/nxmaccessmanager.cpp index 07a75910..0763bb71 100644 --- a/src/nxmaccessmanager.cpp +++ b/src/nxmaccessmanager.cpp @@ -52,7 +52,6 @@ const std::set NXMAccessManager::s_PremiumAccountStates { 4, 6, 13, 27, 31, NXMAccessManager::NXMAccessManager(QObject *parent, const QString &moVersion) : QNetworkAccessManager(parent) , m_LoginReply(nullptr) - , m_ProgressDialog() , m_MOVersion(moVersion) { m_LoginTimeout.setSingleShot(true); @@ -239,10 +238,11 @@ void NXMAccessManager::pageLogin() request.setRawHeader("User-Agent", userAgent().toUtf8()); - m_ProgressDialog.setLabelText(tr("Logging into Nexus")); - QList buttons = m_ProgressDialog.findChildren(); + m_ProgressDialog = new QProgressDialog(nullptr); + m_ProgressDialog->setLabelText(tr("Logging into Nexus")); + QList buttons = m_ProgressDialog->findChildren(); buttons.at(0)->setEnabled(false); - m_ProgressDialog.show(); + m_ProgressDialog->show(); QCoreApplication::processEvents(); // for some reason the whole app hangs during the login. This way the user has at least a little feedback m_LoginReply = post(request, postDataQuery); @@ -269,7 +269,10 @@ void NXMAccessManager::loginTimeout() void NXMAccessManager::loginError(QNetworkReply::NetworkError) { qDebug("login error"); - m_ProgressDialog.hide(); + if (m_ProgressDialog != nullptr) { + m_ProgressDialog->deleteLater(); + m_ProgressDialog = nullptr; + } m_Username.clear(); m_Password.clear(); m_LoginState = LOGIN_NOT_VALID; @@ -300,7 +303,10 @@ bool NXMAccessManager::hasLoginCookies() const void NXMAccessManager::loginFinished() { - m_ProgressDialog.hide(); + if (m_ProgressDialog != nullptr) { + m_ProgressDialog->deleteLater(); + m_ProgressDialog = nullptr; + } m_LoginReply->deleteLater(); m_LoginReply = nullptr; diff --git a/src/nxmaccessmanager.h b/src/nxmaccessmanager.h index 2b615cdc..a03dbe36 100644 --- a/src/nxmaccessmanager.h +++ b/src/nxmaccessmanager.h @@ -109,7 +109,7 @@ private: QTimer m_LoginTimeout; QNetworkReply *m_LoginReply; - QProgressDialog m_ProgressDialog; + QProgressDialog *m_ProgressDialog { nullptr }; QString m_MOVersion; QString m_NMMVersion; diff --git a/src/selfupdater.cpp b/src/selfupdater.cpp index ed34bfc2..bcf81cfd 100644 --- a/src/selfupdater.cpp +++ b/src/selfupdater.cpp @@ -61,11 +61,8 @@ SelfUpdater::SelfUpdater(NexusInterface *nexusInterface) , m_Interface(nexusInterface) , m_UpdateRequestID(-1) , m_Reply(nullptr) - , m_Progress(nullptr) , m_Attempts(3) { - m_Progress.setMaximum(100); - QLibrary archiveLib("dlls\\archive.dll"); if (!archiveLib.load()) { throw MyException(tr("archive.dll not loaded: \"%1\"").arg(archiveLib.errorString())); @@ -78,7 +75,7 @@ SelfUpdater::SelfUpdater(NexusInterface *nexusInterface) throw MyException(InstallationManager::getErrorString(m_CurrentArchive->getLastError())); } - connect(&m_Progress, SIGNAL(canceled()), this, SLOT(downloadCancel())); + connect(m_Progress, SIGNAL(canceled()), this, SLOT(downloadCancel())); VS_FIXEDFILEINFO version = GetFileVersion(ToWString(QApplication::applicationFilePath())); @@ -136,12 +133,23 @@ void SelfUpdater::startUpdate() void SelfUpdater::showProgress() { - m_Progress.setModal(true); - m_Progress.setParent(m_Parent, Qt::Dialog); - m_Progress.show(); - m_Progress.setValue(0); - m_Progress.setWindowTitle(tr("Update")); - m_Progress.setLabelText(tr("Download in progress")); + if (m_Progress == nullptr) { + m_Progress = new QProgressDialog(m_Parent, Qt::Dialog); + } + m_Progress->setModal(true); + m_Progress->show(); + m_Progress->setValue(0); + m_Progress->setWindowTitle(tr("Update")); + m_Progress->setLabelText(tr("Download in progress")); +} + +void SelfUpdater::closeProgress() +{ + if (m_Progress != nullptr) { + m_Progress->hide(); + m_Progress->deleteLater(); + m_Progress = nullptr; + } } void SelfUpdater::download(const QString &downloadLink, const QString &fileName) @@ -168,7 +176,9 @@ void SelfUpdater::downloadProgress(qint64 bytesReceived, qint64 bytesTotal) m_Reply->abort(); } else { if (bytesTotal != 0) { - m_Progress.setValue((bytesReceived * 100) / bytesTotal); + if (m_Progress != nullptr) { + m_Progress->setValue((bytesReceived * 100) / bytesTotal); + } } } } @@ -196,7 +206,8 @@ void SelfUpdater::downloadFinished() m_Canceled = true; } - m_Progress.hide(); + closeProgress(); + m_Reply->close(); m_Reply->deleteLater(); m_Reply = nullptr; @@ -439,7 +450,7 @@ void SelfUpdater::nxmFilesAvailable(int, QVariant userData, QVariant resultData, } else { qCritical("no file for update found"); MessageDialog::showMessage(tr("no file for update found. Please update manually."), m_Parent); - m_Progress.hide(); + closeProgress(); } } @@ -474,8 +485,7 @@ void SelfUpdater::nxmDownloadURLsAvailable(int, int, QVariant userData, QVariant download(dlServer["URI"].toString(), userData.toString()); } else { MessageDialog::showMessage(tr("No download server available. Please try again later."), m_Parent); - m_Progress.hide(); + closeProgress(); } } } - diff --git a/src/selfupdater.h b/src/selfupdater.h index b5bbc406..143b05cb 100644 --- a/src/selfupdater.h +++ b/src/selfupdater.h @@ -32,6 +32,7 @@ along with Mod Organizer. If not, see . class NexusInterface; + /** * @brief manages updates for Mod Organizer itself * This class is used to update the Mod Organizer @@ -39,7 +40,7 @@ class NexusInterface; * 1. call testForUpdate() to determine is available * 2. if the updateAvailable() signal is received, allow the user to start the update * 3. if the user start the update, call startUpdate() - * 4. startUpdate() will first query a list of files, try to determine if there is an + * 4. startUpdate() will first query a list of files, try to determine if there is an * incremental update. If not, the user will have to confirm the download of a full download. * Once the correct file is selected, it is downloaded. * 5. before the downloaded file is extracted, existing files that are going to be replaced are @@ -48,7 +49,7 @@ class NexusInterface; * 7. finally, a restart is requested via signal. * 8. at restart, Mod Organizer will remove the update_backup directory since none of the files * should now be open - * + * * @todo use NexusBridge **/ class SelfUpdater : public QObject @@ -121,6 +122,7 @@ private: void report7ZipError(LPCWSTR errorMessage); QString retrieveNews(const QString &description); void showProgress(); + void closeProgress(); private slots: @@ -138,7 +140,7 @@ private: QString m_NewestVersion; QFile m_UpdateFile; QNetworkReply *m_Reply; - QProgressDialog m_Progress; + QProgressDialog *m_Progress { nullptr }; bool m_Canceled; int m_Attempts; -- cgit v1.3.1 From 7d93a9a2003f31188e4da8cbcd7e5df0352bb900 Mon Sep 17 00:00:00 2001 From: Tannin Date: Sat, 10 Oct 2015 19:36:12 +0200 Subject: updated about dialog. Now contains a link to the source code --- src/aboutdialog.cpp | 2 +- src/aboutdialog.ui | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/aboutdialog.cpp b/src/aboutdialog.cpp index 7b311263..6fce2acb 100644 --- a/src/aboutdialog.cpp +++ b/src/aboutdialog.cpp @@ -37,7 +37,7 @@ AboutDialog::AboutDialog(const QString &version, QWidget *parent) m_LicenseFiles[LICENSE_ZLIB] = "zlib.txt"; m_LicenseFiles[LICENSE_APACHE2] = "apache-license-2.0.txt"; - addLicense("Qt 5.4", LICENSE_LGPL3); + addLicense("Qt", LICENSE_LGPL3); addLicense("Qt Json", LICENSE_GPL3); addLicense("Boost Library", LICENSE_BOOST); addLicense("7-zip", LICENSE_LGPL3); diff --git a/src/aboutdialog.ui b/src/aboutdialog.ui index 2806921f..ea5d2141 100644 --- a/src/aboutdialog.ui +++ b/src/aboutdialog.ui @@ -90,7 +90,7 @@ - <html><head/><body><p>This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.</p><p>See the GNU General Public License for more details.</p></body></html> + <html><head/><body><p>This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.</p><p>See the GNU General Public License for more details.</p><p>Source code can be found at <a href="https://github.com/TanninOne/modorganizer"><span style=" text-decoration: underline; color:#007af4;">GitHub</span></a>.</p></body></html> true -- cgit v1.3.1