From 9f0ec849a03e084d36ed4c509dd0405d5426fa6d Mon Sep 17 00:00:00 2001 From: Koncord Date: Sat, 27 May 2017 11:44:55 +0800 Subject: [PATCH] [Browser] Disable refresh button when action in progress --- apps/browser/MainWindow.cpp | 2 ++ apps/browser/QueryHelper.cpp | 2 ++ apps/browser/QueryHelper.hpp | 3 +++ 3 files changed, 7 insertions(+) diff --git a/apps/browser/MainWindow.cpp b/apps/browser/MainWindow.cpp index 4bc62fcf5..c698d51e0 100644 --- a/apps/browser/MainWindow.cpp +++ b/apps/browser/MainWindow.cpp @@ -36,6 +36,8 @@ MainWindow::MainWindow(QWidget *parent) PingHelper::Get().SetModel((ServerModel*)proxyModel->sourceModel()); queryHelper = new QueryHelper(proxyModel->sourceModel()); + connect(queryHelper, &QueryHelper::started, [this](){actionRefresh->setEnabled(false);}); + connect(queryHelper, &QueryHelper::finished, [this](){actionRefresh->setEnabled(true);}); connect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(tabSwitched(int))); connect(actionAdd, SIGNAL(triggered(bool)), this, SLOT(addServer())); diff --git a/apps/browser/QueryHelper.cpp b/apps/browser/QueryHelper.cpp index f686ca73a..2155fea6d 100644 --- a/apps/browser/QueryHelper.cpp +++ b/apps/browser/QueryHelper.cpp @@ -16,12 +16,14 @@ QueryHelper::QueryHelper(QAbstractItemModel *model) queryUpdate->_model = model; connect(queryThread, SIGNAL(started()), queryUpdate, SLOT(process())); connect(queryUpdate, SIGNAL(finished()), queryThread, SLOT(quit())); + connect(queryUpdate, &QueryUpdate::finished, [this](){emit finished();}); queryUpdate->moveToThread(queryThread); } void QueryHelper::refresh() { queryThread->start(); + emit started(); } void QueryHelper::terminate() diff --git a/apps/browser/QueryHelper.hpp b/apps/browser/QueryHelper.hpp index ee04de7fd..b7ac16cda 100644 --- a/apps/browser/QueryHelper.hpp +++ b/apps/browser/QueryHelper.hpp @@ -18,6 +18,9 @@ public: public slots: void refresh(); void terminate(); +signals: + void finished(); + void started(); private: QThread *queryThread; };