diff --git a/ProfileInterface.cpp b/ProfileInterface.cpp index 3d4a117..67f5c99 100755 --- a/ProfileInterface.cpp +++ b/ProfileInterface.cpp @@ -109,6 +109,8 @@ void ProfileInterface::savegameLoaded(SavegameData *savegame, QString savegamePa QObject::connect(sgdWidget, SIGNAL(savegameDeleted()), this, SLOT(savegameDeleted())); QObject::connect(sgdWidget, SIGNAL(widgetSelected()), this, SLOT(profileWidgetSelected())); QObject::connect(sgdWidget, SIGNAL(widgetDeselected()), this, SLOT(profileWidgetDeselected())); + QObject::connect(sgdWidget, SIGNAL(allWidgetsSelected()), this, SLOT(selectAllWidgets())); + QObject::connect(sgdWidget, SIGNAL(allWidgetsDeselected()), this, SLOT(deselectAllWidgets())); } void ProfileInterface::pictureLoaded(SnapmaticPicture *picture, QString picturePath) @@ -122,6 +124,8 @@ void ProfileInterface::pictureLoaded(SnapmaticPicture *picture, QString pictureP QObject::connect(picWidget, SIGNAL(pictureDeleted()), this, SLOT(pictureDeleted())); QObject::connect(picWidget, SIGNAL(widgetSelected()), this, SLOT(profileWidgetSelected())); QObject::connect(picWidget, SIGNAL(widgetDeselected()), this, SLOT(profileWidgetDeselected())); + QObject::connect(picWidget, SIGNAL(allWidgetsSelected()), this, SLOT(selectAllWidgets())); + QObject::connect(picWidget, SIGNAL(allWidgetsDeselected()), this, SLOT(deselectAllWidgets())); } void ProfileInterface::loadingProgress(int value, int maximum) diff --git a/SavegameWidget.cpp b/SavegameWidget.cpp index 9d89052..2bb40ef 100755 --- a/SavegameWidget.cpp +++ b/SavegameWidget.cpp @@ -19,6 +19,7 @@ #include "SavegameWidget.h" #include "ui_SavegameWidget.h" #include "SidebarGenerator.h" +#include "ProfileInterface.h" #include "SavegameDialog.h" #include "StandardPaths.h" #include "SavegameData.h" @@ -159,20 +160,30 @@ void SavegameWidget::setSelected(bool isSelected) void SavegameWidget::savegameSelected() { - setSelected(true); + setSelected(!ui->cbSelected->isChecked()); } void SavegameWidget::contextMenuEvent(QContextMenuEvent *ev) { QMenu contextMenu(this); if (!ui->cbSelected->isVisible()) + contextMenu.addAction(tr("View"), this, SLOT(on_cmdView_clicked())); + contextMenu.addAction(tr("Copy"), this, SLOT(on_cmdCopy_clicked())); + contextMenu.addAction(tr("Delete"), this, SLOT(on_cmdDelete_clicked())); + if (ui->cbSelected->isVisible()) { - contextMenu.addAction(tr("Select"), this, SLOT(savegameSelected())); contextMenu.addSeparator(); + 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(tr("Ctrl+S"))); + contextMenu.addAction(tr("Deselect all"), this, SLOT(deselectAllWidgets()), QKeySequence::fromString(tr("Shift+S"))); + } + else + { + contextMenu.addSeparator(); + contextMenu.addAction(tr("Select"), this, SLOT(savegameSelected())); + contextMenu.addAction(tr("Select all"), this, SLOT(selectAllWidgets()), QKeySequence::fromString(tr("Ctrl+S"))); } - contextMenu.addAction(tr("View savegame"), this, SLOT(on_cmdView_clicked())); - contextMenu.addAction(tr("Copy savegame"), this, SLOT(on_cmdCopy_clicked())); - contextMenu.addAction(tr("Delete savegame"), this, SLOT(on_cmdDelete_clicked())); contextMenu.exec(ev->globalPos()); setStyleSheet(styleSheet()); // fix multi highlight bug } @@ -199,6 +210,16 @@ void SavegameWidget::setSelectionMode(bool selectionMode) ui->cbSelected->setVisible(selectionMode); } +void SavegameWidget::selectAllWidgets() +{ + emit allWidgetsSelected(); +} + +void SavegameWidget::deselectAllWidgets() +{ + emit allWidgetsDeselected(); +} + SavegameData* SavegameWidget::getSavegame() { return sgdata; diff --git a/SavegameWidget.h b/SavegameWidget.h index 01c8b69..b3f38ed 100755 --- a/SavegameWidget.h +++ b/SavegameWidget.h @@ -19,6 +19,7 @@ #ifndef SAVEGAMEWIDGET_H #define SAVEGAMEWIDGET_H +#include "ProfileInterface.h" #include "ProfileWidget.h" #include "SavegameData.h" #include @@ -49,6 +50,8 @@ private slots: void on_cbSelected_stateChanged(int arg1); void changeCheckedState(); void savegameSelected(); + void selectAllWidgets(); + void deselectAllWidgets(); protected: void mouseDoubleClickEvent(QMouseEvent *ev); @@ -67,6 +70,8 @@ signals: void savegameDeleted(); void widgetSelected(); void widgetDeselected(); + void allWidgetsSelected(); + void allWidgetsDeselected(); }; #endif // SAVEGAMEWIDGET_H diff --git a/SnapmaticWidget.cpp b/SnapmaticWidget.cpp index 4e29abe..2666750 100755 --- a/SnapmaticWidget.cpp +++ b/SnapmaticWidget.cpp @@ -168,21 +168,29 @@ void SnapmaticWidget::setSelected(bool isSelected) void SnapmaticWidget::pictureSelected() { - setSelected(true); + setSelected(!ui->cbSelected->isChecked()); } void SnapmaticWidget::contextMenuEvent(QContextMenuEvent *ev) { QMenu contextMenu(this); - if (!ui->cbSelected->isVisible()) + contextMenu.addAction(tr("View"), this, SLOT(on_cmdView_clicked())); + contextMenu.addAction(tr("Copy"), this, SLOT(on_cmdCopy_clicked())); + contextMenu.addAction(tr("Delete"), this, SLOT(on_cmdDelete_clicked())); + if (ui->cbSelected->isVisible()) { - contextMenu.addAction(tr("Select"), this, SLOT(pictureSelected())); contextMenu.addSeparator(); + 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(tr("Ctrl+S"))); + contextMenu.addAction(tr("Deselect all"), this, SLOT(deselectAllWidgets()), QKeySequence::fromString(tr("Shift+S"))); + } + else + { + contextMenu.addSeparator(); + contextMenu.addAction(tr("Select"), this, SLOT(pictureSelected())); + contextMenu.addAction(tr("Select all"), this, SLOT(selectAllWidgets()), QKeySequence::fromString(tr("Ctrl+S"))); } - contextMenu.addAction(tr("View picture"), this, SLOT(on_cmdView_clicked())); - contextMenu.addAction(tr("Copy picture"), this, SLOT(on_cmdCopy_clicked())); - contextMenu.addAction(tr("Export picture"), this, SLOT(on_cmdExport_clicked())); - contextMenu.addAction(tr("Delete picture"), this, SLOT(on_cmdDelete_clicked())); contextMenu.exec(ev->globalPos()); setStyleSheet(styleSheet()); // fix multi highlight bug } @@ -209,6 +217,16 @@ void SnapmaticWidget::setSelectionMode(bool selectionMode) ui->cbSelected->setVisible(selectionMode); } +void SnapmaticWidget::selectAllWidgets() +{ + emit allWidgetsSelected(); +} + +void SnapmaticWidget::deselectAllWidgets() +{ + emit allWidgetsDeselected(); +} + SnapmaticPicture* SnapmaticWidget::getPicture() { return smpic; diff --git a/SnapmaticWidget.h b/SnapmaticWidget.h index 504e4df..dbec429 100755 --- a/SnapmaticWidget.h +++ b/SnapmaticWidget.h @@ -20,6 +20,7 @@ #define SNAPMATICWIDGET_H #include "SnapmaticPicture.h" +#include "ProfileInterface.h" #include "ProfileDatabase.h" #include "DatabaseThread.h" #include "ProfileWidget.h" @@ -52,6 +53,8 @@ private slots: void on_cbSelected_stateChanged(int arg1); void changeCheckedState(); void pictureSelected(); + void selectAllWidgets(); + void deselectAllWidgets(); protected: void mouseDoubleClickEvent(QMouseEvent *ev); @@ -73,6 +76,8 @@ signals: void pictureDeleted(); void widgetSelected(); void widgetDeselected(); + void allWidgetsSelected(); + void allWidgetsDeselected(); }; #endif // SNAPMATICWIDGET_H diff --git a/UserInterface.cpp b/UserInterface.cpp index 8bbb611..7eb113a 100755 --- a/UserInterface.cpp +++ b/UserInterface.cpp @@ -173,6 +173,7 @@ void UserInterface::closeProfile() if (profileOpen) { profileOpen = false; + ui->menuProfile->setEnabled(false); ui->swProfile->removeWidget(profileUI); profileUI->deleteLater(); delete profileUI;