context menu adjusted and edit menu bug fix

This commit is contained in:
Rafael 2016-04-03 09:23:14 +02:00
parent b53c27db9d
commit 94ef862f83
6 changed files with 66 additions and 12 deletions

View File

@ -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)

View File

@ -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;

View File

@ -19,6 +19,7 @@
#ifndef SAVEGAMEWIDGET_H
#define SAVEGAMEWIDGET_H
#include "ProfileInterface.h"
#include "ProfileWidget.h"
#include "SavegameData.h"
#include <QContextMenuEvent>
@ -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

View File

@ -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;

View File

@ -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

View File

@ -173,6 +173,7 @@ void UserInterface::closeProfile()
if (profileOpen)
{
profileOpen = false;
ui->menuProfile->setEnabled(false);
ui->swProfile->removeWidget(profileUI);
profileUI->deleteLater();
delete profileUI;