From 569b192fe68014935a2dafea3c37703c010ca259 Mon Sep 17 00:00:00 2001 From: Rafael Date: Thu, 27 Oct 2016 10:35:20 +0200 Subject: [PATCH] Deselect All doesn't show always anymore when checkboxes are visible --- ProfileInterface.cpp | 9 +++++++-- ProfileInterface.h | 1 + SavegameWidget.cpp | 7 ++++++- SavegameWidget.h | 1 + SnapmaticWidget.cpp | 7 ++++++- SnapmaticWidget.h | 1 + 6 files changed, 22 insertions(+), 4 deletions(-) diff --git a/ProfileInterface.cpp b/ProfileInterface.cpp index e41a305..6dfc291 100755 --- a/ProfileInterface.cpp +++ b/ProfileInterface.cpp @@ -117,7 +117,7 @@ void ProfileInterface::savegameLoaded(SavegameData *savegame, QString savegamePa void ProfileInterface::savegameLoaded_f(SavegameData *savegame, QString savegamePath, bool inserted) { - SavegameWidget *sgdWidget = new SavegameWidget(); + SavegameWidget *sgdWidget = new SavegameWidget(this); sgdWidget->setSavegameData(savegame, savegamePath); sgdWidget->setContentMode(contentMode); widgets[sgdWidget] = "SGD" + QFileInfo(savegamePath).fileName(); @@ -138,7 +138,7 @@ void ProfileInterface::pictureLoaded(SnapmaticPicture *picture, QString pictureP void ProfileInterface::pictureLoaded_f(SnapmaticPicture *picture, QString picturePath, bool inserted) { - SnapmaticWidget *picWidget = new SnapmaticWidget(profileDB, crewDB, threadDB); + SnapmaticWidget *picWidget = new SnapmaticWidget(profileDB, crewDB, threadDB, this); picWidget->setSnapmaticPicture(picture, picturePath); picWidget->setContentMode(contentMode); widgets[picWidget] = "PIC" + picture->getPictureSortStr(); @@ -832,3 +832,8 @@ void ProfileInterface::settingsApplied(int _contentMode, QString language) } } } + +int ProfileInterface::selectedWidgets() +{ + return selectedWidgts; +} diff --git a/ProfileInterface.h b/ProfileInterface.h index a17e22d..9d9a9d1 100755 --- a/ProfileInterface.h +++ b/ProfileInterface.h @@ -47,6 +47,7 @@ public: void setProfileFolder(QString folder, QString profile); void settingsApplied(int contentMode, QString language); void setupProfileInterface(); + int selectedWidgets(); ~ProfileInterface(); public slots: diff --git a/SavegameWidget.cpp b/SavegameWidget.cpp index 98c52fa..ef58f21 100755 --- a/SavegameWidget.cpp +++ b/SavegameWidget.cpp @@ -56,6 +56,7 @@ SavegameWidget::SavegameWidget(QWidget *parent) : labelAutosaveStr = tr("AUTOSAVE - %1\n%2"); labelSaveStr = tr("SAVE %3 - %1\n%2"); + snwgt = parent; sgdPath = ""; sgdStr = ""; sgdata = 0; @@ -214,7 +215,11 @@ void SavegameWidget::contextMenuEvent(QContextMenuEvent *ev) if (!ui->cbSelected->isChecked()) { contextMenu.addAction(tr("&Select"), this, SLOT(savegameSelected())); } if (ui->cbSelected->isChecked()) { contextMenu.addAction(tr("&Deselect"), this, SLOT(savegameSelected())); } contextMenu.addAction(tr("Select &All"), this, SLOT(selectAllWidgets()), QKeySequence::fromString("Ctrl+A")); - contextMenu.addAction(tr("&Deselect All"), this, SLOT(deselectAllWidgets()), QKeySequence::fromString("Ctrl+D")); + ProfileInterface *profileInterface = (ProfileInterface*)snwgt; + if (profileInterface->selectedWidgets() != 0) + { + contextMenu.addAction(tr("&Deselect All"), this, SLOT(deselectAllWidgets()), QKeySequence::fromString("Ctrl+D")); + } } else { diff --git a/SavegameWidget.h b/SavegameWidget.h index fe0071e..85e8fb2 100755 --- a/SavegameWidget.h +++ b/SavegameWidget.h @@ -70,6 +70,7 @@ private: QString labelSaveStr; QString sgdPath; QString sgdStr; + QWidget *snwgt; signals: void savegameDeleted(); diff --git a/SnapmaticWidget.cpp b/SnapmaticWidget.cpp index a456325..725ea9f 100755 --- a/SnapmaticWidget.cpp +++ b/SnapmaticWidget.cpp @@ -47,6 +47,7 @@ SnapmaticWidget::SnapmaticWidget(ProfileDatabase *profileDB, CrewDatabase *crewD palette.setCurrentColorGroup(QPalette::Disabled); highlightHiddenColor = palette.text().color(); + snwgt = parent; picPath = ""; picStr = ""; smpic = 0; @@ -216,7 +217,11 @@ void SnapmaticWidget::contextMenuEvent(QContextMenuEvent *ev) if (!ui->cbSelected->isChecked()) { contextMenu.addAction(tr("&Select"), this, SLOT(pictureSelected())); } if (ui->cbSelected->isChecked()) { contextMenu.addAction(tr("&Deselect"), this, SLOT(pictureSelected())); } contextMenu.addAction(tr("Select &All"), this, SLOT(selectAllWidgets()), QKeySequence::fromString("Ctrl+A")); - contextMenu.addAction(tr("&Deselect All"), this, SLOT(deselectAllWidgets()), QKeySequence::fromString("Ctrl+D")); + ProfileInterface *profileInterface = (ProfileInterface*)snwgt; + if (profileInterface->selectedWidgets() != 0) + { + contextMenu.addAction(tr("&Deselect All"), this, SLOT(deselectAllWidgets()), QKeySequence::fromString("Ctrl+D")); + } } else { diff --git a/SnapmaticWidget.h b/SnapmaticWidget.h index 728ea13..00baf49 100755 --- a/SnapmaticWidget.h +++ b/SnapmaticWidget.h @@ -87,6 +87,7 @@ private: QString picPath; QString picTitl; QString picStr; + QWidget *snwgt; signals: void pictureDeleted();