summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mainwindow.cpp20
-rw-r--r--src/mainwindow.h18
2 files changed, 28 insertions, 10 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 477cbc70..c49b0bdd 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -266,6 +266,7 @@ MainWindow::MainWindow(Settings &settings
, m_LinkToolbar(nullptr)
, m_LinkDesktop(nullptr)
, m_LinkStartMenu(nullptr)
+ , m_NumberOfProblems(0)
{
// disables incredibly slow menu fade in effect that looks and feels like crap.
// this was only happening to users with the windows
@@ -473,7 +474,8 @@ MainWindow::MainWindow(Settings &settings
setFilterShortcuts(ui->downloadView, ui->downloadFilterEdit);
m_UpdateProblemsTimer.setSingleShot(true);
- connect(&m_UpdateProblemsTimer, SIGNAL(timeout()), this, SLOT(updateProblemsButton()));
+ connect(&m_UpdateProblemsTimer, SIGNAL(timeout()), this, SLOT(checkForProblemsAsync()));
+ connect(this, SIGNAL(checkForProblemsDone()), this, SLOT(updateProblemsButton()), Qt::ConnectionType::QueuedConnection);
m_SaveMetaTimer.setSingleShot(false);
connect(&m_SaveMetaTimer, SIGNAL(timeout()), this, SLOT(saveModMetas()));
@@ -1000,7 +1002,7 @@ void MainWindow::on_centralWidget_customContextMenuRequested(const QPoint &pos)
createPopupMenu()->exec(ui->centralWidget->mapToGlobal(pos));
}
-void MainWindow::scheduleUpdateButton()
+void MainWindow::scheduleCheckForProblems()
{
if (!m_UpdateProblemsTimer.isActive()) {
m_UpdateProblemsTimer.start(1000);
@@ -1014,7 +1016,7 @@ void MainWindow::updateProblemsButton()
// if the current stylesheet doesn't provide an icon, this is used instead
const char* DefaultIconName = ":/MO/gui/warning";
- const std::size_t numProblems = checkForProblems();
+ const std::size_t numProblems = m_NumberOfProblems;
// original icon without a count painted on it
const QIcon original = m_originalNotificationIcon.isNull() ?
@@ -1097,8 +1099,13 @@ bool MainWindow::errorReported(QString &logFile)
return false;
}
+void MainWindow::checkForProblemsAsync() {
+ QtConcurrent::run([this]() {
+ checkForProblems();
+ });
+}
-size_t MainWindow::checkForProblems()
+void MainWindow::checkForProblems()
{
size_t numProblems = 0;
for (QObject *pluginObj : m_PluginContainer.plugins<QObject>()) {
@@ -1109,7 +1116,8 @@ size_t MainWindow::checkForProblems()
numProblems += diagnose->activeProblems().size();
}
}
- return numProblems;
+ m_NumberOfProblems = numProblems;
+ emit checkForProblemsDone();
}
void MainWindow::about()
@@ -1353,7 +1361,7 @@ void MainWindow::showEvent(QShowEvent *event)
m_OrganizerCore.settings().nexus().registerAsNXMHandler(false);
m_WasVisible = true;
- updateProblemsButton();
+ updateProblemsButton();
}
}
diff --git a/src/mainwindow.h b/src/mainwindow.h
index 25d09584..1f66c860 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -178,6 +178,8 @@ signals:
void modListDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
+ void checkForProblemsDone();
+
protected:
virtual void showEvent(QShowEvent *event);
@@ -244,8 +246,9 @@ private:
void fixCategories();
bool extractProgress(QProgressDialog &extractProgress, int percentage, std::string fileName);
-
- size_t checkForProblems();
+
+ // Performs checks, sets the problemCount and singnals checkForProblemsDone().
+ void checkForProblems();
void setCategoryListVisible(bool visible);
@@ -267,8 +270,6 @@ private:
QMenu *openFolderMenu();
- void scheduleUpdateButton();
-
QDir currentSavesDir() const;
void startMonitorSaves();
@@ -358,6 +359,8 @@ private:
// when painting the count
QIcon m_originalNotificationIcon;
+ size_t m_NumberOfProblems;
+
Executable* getSelectedExecutable();
private slots:
@@ -523,8 +526,15 @@ private slots:
void checkBSAList();
+ // Only visually update the problems icon.
void updateProblemsButton();
+ // Queue a problem check to allow collapsing of multiple requests in short amount of time.
+ void scheduleCheckForProblems();
+
+ // Perform the actual problem check in another thread.
+ void checkForProblemsAsync();
+
void saveModMetas();
void updateStyle(const QString &style);