diff --git a/src/librssguard/gui/labelsmenu.cpp b/src/librssguard/gui/labelsmenu.cpp index df944bb9d..d5646c637 100644 --- a/src/librssguard/gui/labelsmenu.cpp +++ b/src/librssguard/gui/labelsmenu.cpp @@ -50,7 +50,7 @@ void LabelsMenu::keyPressEvent(QKeyEvent* event) { LabelAction* act = qobject_cast(activeAction()); if (act != nullptr && event->key() == Qt::Key::Key_Space) { - act->toggle(); + act->toggleCheckState(); } NonClosableMenu::keyPressEvent(event); @@ -60,10 +60,11 @@ void LabelsMenu::mousePressEvent(QMouseEvent* event) { LabelAction* act = qobject_cast(activeAction()); if (act != nullptr) { - act->toggle(); + act->toggleCheckState(); + } + else { + NonClosableMenu::mousePressEvent(event); } - - NonClosableMenu::mousePressEvent(event); } void LabelsMenu::changeLabelAssignment(Qt::CheckState state) { @@ -121,7 +122,7 @@ Label* LabelAction::label() const { return m_label; } -void LabelAction::toggle() { +void LabelAction::toggleCheckState() { if (m_checkState == Qt::CheckState::Unchecked) { setCheckState(Qt::CheckState::Checked); } diff --git a/src/librssguard/gui/labelsmenu.h b/src/librssguard/gui/labelsmenu.h index 27d545a46..a563cd46d 100644 --- a/src/librssguard/gui/labelsmenu.h +++ b/src/librssguard/gui/labelsmenu.h @@ -42,7 +42,7 @@ class LabelAction : public QAction { Label* label() const; public slots: - void toggle(); + void toggleCheckState(); signals: void checkStateChanged(Qt::CheckState state); diff --git a/src/librssguard/gui/nonclosablemenu.cpp b/src/librssguard/gui/nonclosablemenu.cpp index c15b883ee..b51bb25a8 100644 --- a/src/librssguard/gui/nonclosablemenu.cpp +++ b/src/librssguard/gui/nonclosablemenu.cpp @@ -15,7 +15,14 @@ void NonClosableMenu::keyPressEvent(QKeyEvent* event) { } void NonClosableMenu::mousePressEvent(QMouseEvent* event) { - Q_UNUSED(event) + auto* act = dynamic_cast(activeAction()); + + if (act != nullptr) { + act->toggle(); + } + else { + QMenu::mousePressEvent(event); + } } void NonClosableMenu::mouseReleaseEvent(QMouseEvent* event) { diff --git a/src/librssguard/gui/treeviewcolumnsmenu.cpp b/src/librssguard/gui/treeviewcolumnsmenu.cpp index ad2243b9f..a874ca36d 100644 --- a/src/librssguard/gui/treeviewcolumnsmenu.cpp +++ b/src/librssguard/gui/treeviewcolumnsmenu.cpp @@ -4,7 +4,7 @@ #include -TreeViewColumnsMenu::TreeViewColumnsMenu(QHeaderView* parent) : QMenu(parent) { +TreeViewColumnsMenu::TreeViewColumnsMenu(QHeaderView* parent) : NonClosableMenu(parent) { connect(this, &TreeViewColumnsMenu::aboutToShow, this, &TreeViewColumnsMenu::prepareMenu); } @@ -17,6 +17,7 @@ void TreeViewColumnsMenu::prepareMenu() { act->setData(i); act->setCheckable(true); act->setChecked(!header_view->isSectionHidden(i)); + connect(act, &QAction::toggled, this, &TreeViewColumnsMenu::actionTriggered); } } diff --git a/src/librssguard/gui/treeviewcolumnsmenu.h b/src/librssguard/gui/treeviewcolumnsmenu.h index 963b58621..2f74aa51c 100644 --- a/src/librssguard/gui/treeviewcolumnsmenu.h +++ b/src/librssguard/gui/treeviewcolumnsmenu.h @@ -3,11 +3,11 @@ #ifndef TREEVIEWCOLUMNSMENU_H #define TREEVIEWCOLUMNSMENU_H -#include +#include "gui/nonclosablemenu.h" class QHeaderView; -class TreeViewColumnsMenu : public QMenu { +class TreeViewColumnsMenu : public NonClosableMenu { public: explicit TreeViewColumnsMenu(QHeaderView* parent); diff --git a/src/librssguard/miscellaneous/databasequeries.cpp b/src/librssguard/miscellaneous/databasequeries.cpp index b00ca5ff7..3e8d23d0e 100755 --- a/src/librssguard/miscellaneous/databasequeries.cpp +++ b/src/librssguard/miscellaneous/databasequeries.cpp @@ -1130,13 +1130,13 @@ bool DatabaseQueries::deleteAccount(const QSqlDatabase& db, int account_id) { query.setForwardOnly(true); QStringList queries; - queries << QSL("DELETE FROM Messages WHERE account_id = :account_id;") + queries << QSL("DELETE FROM MessageFiltersInFeeds WHERE account_id = :account_id;") + << QSL("DELETE FROM LabelsInMessages WHERE account_id = :account_id;") + << QSL("DELETE FROM Messages WHERE account_id = :account_id;") << QSL("DELETE FROM Feeds WHERE account_id = :account_id;") << QSL("DELETE FROM Categories WHERE account_id = :account_id;") - << QSL("DELETE FROM MessageFiltersInFeeds WHERE account_id = :account_id;") - << QSL("DELETE FROM Accounts WHERE id = :account_id;") - << QSL("DELETE FROM LabelsInMessages WHERE account_id = :account_id;") - << QSL("DELETE FROM Labels WHERE account_id = :account_id;"); + << QSL("DELETE FROM Labels WHERE account_id = :account_id;") + << QSL("DELETE FROM Accounts WHERE id = :account_id;"); for (const QString& q : queries) { query.prepare(q);