From 69455a743a21b0c1f07f2e828c642b1a413fac72 Mon Sep 17 00:00:00 2001 From: Chris Xiong Date: Sat, 1 Oct 2022 02:38:45 -0400 Subject: Do not use a separate menu for sort tool button. --- qdeduper/mingui.cpp | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/qdeduper/mingui.cpp b/qdeduper/mingui.cpp index 5b05a72..5c320b8 100644 --- a/qdeduper/mingui.cpp +++ b/qdeduper/mingui.cpp @@ -361,12 +361,13 @@ void DeduperMainWindow::setup_menu() }); view->addSeparator(); - QMenu *sort = view->addMenu("Sort by"); - QMenu *tbsort = new QMenu(this); - QAction *sfsz = new QAction("File size"); - QAction *simd = new QAction("Image dimension"); - QAction *sfpt = new QAction("File path"); - QAction *snon = new QAction("Default"); + QAction *sort = view->addAction("Sort by"); + QMenu *sortm = new QMenu(this); + sort->setMenu(sortm); + QAction *sfsz = sortm->addAction("File size"); + QAction *simd = sortm->addAction("Image dimension"); + QAction *sfpt = sortm->addAction("File path"); + QAction *snon = sortm->addAction("Default"); QList skeya = {sfsz, simd, sfpt, snon}; QList skeyr = { ImageItem::ImageItemRoles::file_size_role, @@ -378,8 +379,7 @@ void DeduperMainWindow::setup_menu() for (int i = 0; i < skeya.size(); ++i) { auto a = skeya[i]; - sort->addAction(a); - tbsort->addAction(a); + sortm->addAction(a); skeyg->addAction(a); a->setCheckable(true); ImageItem::ImageItemRoles sr = skeyr[i]; @@ -389,10 +389,10 @@ void DeduperMainWindow::setup_menu() { case ViewMode::view_normal: this->show_group(this->curgroup); - break; + break; case ViewMode::view_searchresult: this->search_image(this->searched_image); - break; + break; case ViewMode::view_marked: this->show_marked(); } @@ -400,8 +400,7 @@ void DeduperMainWindow::setup_menu() } snon->setChecked(true); skeyg->setExclusionPolicy(QActionGroup::ExclusionPolicy::Exclusive); - sort->addSeparator(); - tbsort->addSeparator(); + sortm->addSeparator(); QAction *sasc = new QAction("Ascending"); QAction *sdec = new QAction("Descending"); QActionGroup *sordg = new QActionGroup(sort); @@ -410,8 +409,7 @@ void DeduperMainWindow::setup_menu() for (int i = 0; i < sorda.size(); ++i) { auto a = sorda[i]; - sort->addAction(a); - tbsort->addAction(a); + sortm->addAction(a); sordg->addAction(a); a->setCheckable(true); Qt::SortOrder so = sordv[i]; @@ -526,10 +524,9 @@ void DeduperMainWindow::setup_menu() tb->addAction(prvgrp); tb->addAction(nxtgrp); tb->addAction(skip); - QAction *tbsorta = tb->addAction("Sort by"); - QToolButton *tbsortb = qobject_cast(tb->widgetForAction(tbsorta)); + tb->addAction(sort); + QToolButton *tbsortb = qobject_cast(tb->widgetForAction(sort)); tbsortb->setPopupMode(QToolButton::ToolButtonPopupMode::InstantPopup); - tbsorta->setMenu(tbsort); tb->setToolButtonStyle(Qt::ToolButtonStyle::ToolButtonTextBesideIcon); for (auto &ap : menuact) -- cgit v1.2.3