diff --git a/qt/Application.cc b/qt/Application.cc index 685453e4f..64969216e 100644 --- a/qt/Application.cc +++ b/qt/Application.cc @@ -294,7 +294,6 @@ Application::Application(int& argc, char** argv) : myWatchDir = new WatchDir(*myModel); connect(myModel, &TorrentModel::torrentsAdded, this, &Application::onTorrentsAdded); - connect(myModel, &TorrentModel::torrentsChanged, myWindow, &MainWindow::refreshActionSensitivity); connect(myModel, &TorrentModel::torrentsCompleted, this, &Application::onTorrentsCompleted); connect(myModel, &TorrentModel::torrentsNeedInfo, this, &Application::onTorrentsNeedInfo); connect(myPrefs, &Prefs::changed, this, &Application::refreshPref); diff --git a/qt/MainWindow.cc b/qt/MainWindow.cc index 01a1f3113..bc01ba2c2 100644 --- a/qt/MainWindow.cc +++ b/qt/MainWindow.cc @@ -245,6 +245,7 @@ MainWindow::MainWindow(Session& session, Prefs& prefs, TorrentModel& model, bool auto refreshActionSensitivitySoon = [this]() { refreshSoon(REFRESH_ACTION_SENSITIVITY); }; connect(&myFilterModel, &TorrentFilter::rowsInserted, this, refreshActionSensitivitySoon); connect(&myFilterModel, &TorrentFilter::rowsRemoved, this, refreshActionSensitivitySoon); + connect(&myModel, &TorrentModel::torrentsChanged, this, refreshActionSensitivitySoon); // torrent view myFilterModel.setSourceModel(&myModel); @@ -851,6 +852,7 @@ void MainWindow::refreshActionSensitivity() int selectedWithMetadata(0); QAbstractItemModel const* model(ui.listView->model()); QItemSelectionModel const* selectionModel(ui.listView->selectionModel()); + bool const hasSelection = selectionModel->hasSelection(); int const rowCount(model->rowCount()); // count how many torrents are selected, paused, etc @@ -862,8 +864,8 @@ void MainWindow::refreshActionSensitivity() if (tor != nullptr) { - bool const isSelected(selectionModel->isSelected(modelIndex)); - bool const isPaused(tor->isPaused()); + bool const isSelected = hasSelection && selectionModel->isSelected(modelIndex); + bool const isPaused = tor->isPaused(); if (isPaused) { diff --git a/qt/MainWindow.h b/qt/MainWindow.h index 97ecbca1a..52802a3dc 100644 --- a/qt/MainWindow.h +++ b/qt/MainWindow.h @@ -79,7 +79,6 @@ public slots: void setFilterbarVisible(bool); void setStatusbarVisible(bool); void setCompactView(bool); - void refreshActionSensitivity(); void wrongAuthentication(); void openSession(); @@ -196,8 +195,9 @@ private: }; int myRefreshFields = 0; QTimer myRefreshTimer; - void refreshTitle(); - void refreshTrayIcon(TransferStats const&); + void refreshActionSensitivity(); void refreshStatusBar(TransferStats const&); + void refreshTitle(); void refreshTorrentViewHeader(); + void refreshTrayIcon(TransferStats const&); };