diff --git a/ExportThread.cpp b/ExportThread.cpp index 669adac..a2437bd 100755 --- a/ExportThread.cpp +++ b/ExportThread.cpp @@ -17,6 +17,7 @@ *****************************************************************************/ #include "SnapmaticPicture.h" +#include "ProfileInterface.h" #include "PictureExport.h" #include "ProfileWidget.h" #include "ExportThread.h" diff --git a/ProfileInterface.cpp b/ProfileInterface.cpp index e65cb0b..021b5cf 100755 --- a/ProfileInterface.cpp +++ b/ProfileInterface.cpp @@ -135,6 +135,7 @@ void ProfileInterface::savegameLoaded(SavegameData *savegame, QString savegamePa QObject::connect(sgdWidget, SIGNAL(widgetDeselected()), this, SLOT(profileWidgetDeselected())); QObject::connect(sgdWidget, SIGNAL(allWidgetsSelected()), this, SLOT(selectAllWidgets())); QObject::connect(sgdWidget, SIGNAL(allWidgetsDeselected()), this, SLOT(deselectAllWidgets())); + QObject::connect(sgdWidget, SIGNAL(contextMenuTriggered(QContextMenuEvent*)), this, SLOT(contextMenuTriggeredSGD(QContextMenuEvent*))); if (inserted) { insertSavegameIPI(sgdWidget); } } @@ -158,6 +159,7 @@ void ProfileInterface::pictureLoaded(SnapmaticPicture *picture, bool inserted) QObject::connect(picWidget, SIGNAL(allWidgetsDeselected()), this, SLOT(deselectAllWidgets())); QObject::connect(picWidget, SIGNAL(nextPictureRequested(QWidget*)), this, SLOT(dialogNextPictureRequested(QWidget*))); QObject::connect(picWidget, SIGNAL(previousPictureRequested(QWidget*)), this, SLOT(dialogPreviousPictureRequested(QWidget*))); + QObject::connect(picWidget, SIGNAL(contextMenuTriggered(QContextMenuEvent*)), this, SLOT(contextMenuTriggeredPIC(QContextMenuEvent*))); if (inserted) { insertSnapmaticIPI(picWidget); } } @@ -319,9 +321,8 @@ void ProfileInterface::savegameDeleted_event() savegameDeleted((SavegameWidget*)sender()); } -void ProfileInterface::savegameDeleted(QWidget *sgdWidget_) +void ProfileInterface::savegameDeleted(SavegameWidget *sgdWidget) { - SavegameWidget *sgdWidget = (SavegameWidget*)sgdWidget_; SavegameData *savegame = sgdWidget->getSavegame(); if (sgdWidget->isSelected()) { sgdWidget->setSelected(false); } widgets.remove(sgdWidget); @@ -336,9 +337,8 @@ void ProfileInterface::pictureDeleted_event() pictureDeleted((SnapmaticWidget*)sender()); } -void ProfileInterface::pictureDeleted(QWidget *picWidget_) +void ProfileInterface::pictureDeleted(SnapmaticWidget *picWidget) { - SnapmaticWidget *picWidget = (SnapmaticWidget*)picWidget_; SnapmaticPicture *picture = picWidget->getPicture(); if (picWidget->isSelected()) { picWidget->setSelected(false); } widgets.remove(picWidget); @@ -1057,3 +1057,71 @@ int ProfileInterface::selectedWidgets() { return selectedWidgts; } + +void ProfileInterface::contextMenuTriggeredPIC(QContextMenuEvent *ev) +{ + SnapmaticWidget *picWidget = (SnapmaticWidget*)sender(); + QMenu contextMenu(picWidget); + QMenu editMenu(SnapmaticWidget::tr("Edi&t"), picWidget); + if (isHidden()) + { + editMenu.addAction(SnapmaticWidget::tr("Show &In-game"), picWidget, SLOT(makePictureVisibleSlot())); + } + else + { + editMenu.addAction(SnapmaticWidget::tr("Hide &In-game"), picWidget, SLOT(makePictureHiddenSlot())); + } + editMenu.addAction(SnapmaticWidget::tr("&Edit Properties..."), picWidget, SLOT(editSnapmaticProperties())); + QMenu exportMenu(SnapmaticWidget::tr("&Export"), this); + exportMenu.addAction(SnapmaticWidget::tr("Export as &JPG picture..."), picWidget, SLOT(on_cmdExport_clicked())); + exportMenu.addAction(SnapmaticWidget::tr("Export as >A Snapmatic..."), picWidget, SLOT(on_cmdCopy_clicked())); + contextMenu.addAction(SnapmaticWidget::tr("&View"), picWidget, SLOT(on_cmdView_clicked())); + contextMenu.addMenu(&editMenu); + contextMenu.addMenu(&exportMenu); + contextMenu.addAction(SnapmaticWidget::tr("&Remove"), picWidget, SLOT(on_cmdDelete_clicked())); + if (picWidget->isSelected()) + { + contextMenu.addSeparator(); + if (!picWidget->isSelected()) { contextMenu.addAction(SnapmaticWidget::tr("&Select"), picWidget, SLOT(pictureSelected())); } + if (picWidget->isSelected()) { contextMenu.addAction(SnapmaticWidget::tr("&Deselect"), picWidget, SLOT(pictureSelected())); } + contextMenu.addAction(SnapmaticWidget::tr("Select &All"), picWidget, SLOT(selectAllWidgets()), QKeySequence::fromString("Ctrl+A")); + if (selectedWidgets() != 0) + { + contextMenu.addAction(SnapmaticWidget::tr("&Deselect All"), picWidget, SLOT(deselectAllWidgets()), QKeySequence::fromString("Ctrl+D")); + } + } + else + { + contextMenu.addSeparator(); + contextMenu.addAction(SnapmaticWidget::tr("&Select"), picWidget, SLOT(pictureSelected())); + contextMenu.addAction(SnapmaticWidget::tr("Select &All"), picWidget, SLOT(selectAllWidgets()), QKeySequence::fromString("Ctrl+A")); + } + contextMenu.exec(ev->globalPos()); +} + +void ProfileInterface::contextMenuTriggeredSGD(QContextMenuEvent *ev) +{ + SavegameWidget *sgdWidget = (SavegameWidget*)sender(); + QMenu contextMenu(sgdWidget); + contextMenu.addAction(SavegameWidget::tr("&View"), sgdWidget, SLOT(on_cmdView_clicked())); + contextMenu.addAction(SavegameWidget::tr("&Export"), sgdWidget, SLOT(on_cmdCopy_clicked())); + contextMenu.addAction(SavegameWidget::tr("&Remove"), sgdWidget, SLOT(on_cmdDelete_clicked())); + if (sgdWidget->isSelected()) + { + contextMenu.addSeparator(); + if (!sgdWidget->isSelected()) { contextMenu.addAction(SavegameWidget::tr("&Select"), this, SLOT(savegameSelected())); } + if (sgdWidget->isSelected()) { contextMenu.addAction(SavegameWidget::tr("&Deselect"), this, SLOT(savegameSelected())); } + contextMenu.addAction(SavegameWidget::tr("Select &All"), sgdWidget, SLOT(selectAllWidgets()), QKeySequence::fromString("Ctrl+A")); + if (selectedWidgets() != 0) + { + contextMenu.addAction(SavegameWidget::tr("&Deselect All"), sgdWidget, SLOT(deselectAllWidgets()), QKeySequence::fromString("Ctrl+D")); + } + } + else + { + contextMenu.addSeparator(); + contextMenu.addAction(SavegameWidget::tr("&Select"), sgdWidget, SLOT(savegameSelected())); + contextMenu.addAction(SavegameWidget::tr("Select &All"), sgdWidget, SLOT(selectAllWidgets()), QKeySequence::fromString("Ctrl+A")); + } + contextMenu.exec(ev->globalPos()); +} diff --git a/ProfileInterface.h b/ProfileInterface.h index eff2843..8150d5c 100755 --- a/ProfileInterface.h +++ b/ProfileInterface.h @@ -53,6 +53,8 @@ public: ~ProfileInterface(); public slots: + void contextMenuTriggeredPIC(QContextMenuEvent* ev); + void contextMenuTriggeredSGD(QContextMenuEvent* ev); void selectAllWidgets(); void deselectAllWidgets(); void exportSelected(); @@ -96,8 +98,8 @@ private: bool importSavegameData(SavegameData *savegame, QString sgdPath, bool warn = true); void pictureLoaded(SnapmaticPicture *picture, bool inserted); void savegameLoaded(SavegameData *savegame, QString savegamePath, bool inserted); - void savegameDeleted(QWidget *sgdWidget); - void pictureDeleted(QWidget *picWidget); + void savegameDeleted(SavegameWidget *sgdWidget); + void pictureDeleted(SnapmaticWidget *picWidget); void insertSnapmaticIPI(QWidget *widget); void insertSavegameIPI(QWidget *widget); void sortingProfileInterface(); diff --git a/SavegameWidget.cpp b/SavegameWidget.cpp index dcee9bb..fece230 100755 --- a/SavegameWidget.cpp +++ b/SavegameWidget.cpp @@ -19,7 +19,6 @@ #include "SavegameWidget.h" #include "ui_SavegameWidget.h" #include "SidebarGenerator.h" -#include "ProfileInterface.h" #include "SavegameDialog.h" #include "StandardPaths.h" #include "SavegameData.h" @@ -205,31 +204,7 @@ void SavegameWidget::savegameSelected() void SavegameWidget::contextMenuEvent(QContextMenuEvent *ev) { - QMenu contextMenu(this); - contextMenu.addAction(tr("&View"), this, SLOT(on_cmdView_clicked())); - contextMenu.addAction(tr("&Export"), this, SLOT(on_cmdCopy_clicked())); - contextMenu.addAction(tr("&Remove"), this, SLOT(on_cmdDelete_clicked())); - if (ui->cbSelected->isVisible()) - { - 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("Ctrl+A")); - ProfileInterface *profileInterface = (ProfileInterface*)snwgt; - if (profileInterface->selectedWidgets() != 0) - { - contextMenu.addAction(tr("&Deselect All"), this, SLOT(deselectAllWidgets()), QKeySequence::fromString("Ctrl+D")); - } - } - else - { - contextMenu.addSeparator(); - contextMenu.addAction(tr("&Select"), this, SLOT(savegameSelected())); - contextMenu.addAction(tr("Select &All"), this, SLOT(selectAllWidgets()), QKeySequence::fromString("Ctrl+A")); - } - //ui->SavegameFrame->setStyleSheet(QString("QFrame#SavegameFrame{background-color: rgb(%1, %2, %3)}QLabel#labSavegameStr{color: rgb(%4, %5, %6)}").arg(QString::number(highlightBackColor.red()), QString::number(highlightBackColor.green()), QString::number(highlightBackColor.blue()), QString::number(highlightTextColor.red()), QString::number(highlightTextColor.green()), QString::number(highlightTextColor.blue()))); - contextMenu.exec(ev->globalPos()); - //ui->SavegameFrame->setStyleSheet(""); + emit contextMenuTriggered(ev); } void SavegameWidget::on_cbSelected_stateChanged(int arg1) diff --git a/SavegameWidget.h b/SavegameWidget.h index 66dcb67..f0f62c4 100755 --- a/SavegameWidget.h +++ b/SavegameWidget.h @@ -18,8 +18,6 @@ #ifndef SAVEGAMEWIDGET_H #define SAVEGAMEWIDGET_H - -#include "ProfileInterface.h" #include "ProfileWidget.h" #include "SavegameData.h" #include @@ -78,6 +76,7 @@ signals: void widgetDeselected(); void allWidgetsSelected(); void allWidgetsDeselected(); + void contextMenuTriggered(QContextMenuEvent *ev); }; #endif // SAVEGAMEWIDGET_H diff --git a/SnapmaticWidget.cpp b/SnapmaticWidget.cpp index 6b1b413..de1968b 100755 --- a/SnapmaticWidget.cpp +++ b/SnapmaticWidget.cpp @@ -48,7 +48,6 @@ SnapmaticWidget::SnapmaticWidget(ProfileDatabase *profileDB, CrewDatabase *crewD palette.setCurrentColorGroup(QPalette::Disabled); highlightHiddenColor = palette.text().color(); - snwgt = parent; picPath = ""; picStr = ""; smpic = 0; @@ -201,43 +200,7 @@ void SnapmaticWidget::pictureSelected() void SnapmaticWidget::contextMenuEvent(QContextMenuEvent *ev) { - QMenu contextMenu(this); - QMenu editMenu(tr("Edi&t"), this); - if (isHidden()) - { - editMenu.addAction(tr("Show &In-game"), this, SLOT(makePictureVisibleSlot())); - } - else - { - editMenu.addAction(tr("Hide &In-game"), this, SLOT(makePictureHiddenSlot())); - } - editMenu.addAction(tr("&Edit Properties..."), this, SLOT(editSnapmaticProperties())); - QMenu exportMenu(tr("&Export"), this); - exportMenu.addAction(tr("Export as &JPG picture..."), this, SLOT(on_cmdExport_clicked())); - exportMenu.addAction(tr("Export as >A Snapmatic..."), this, SLOT(on_cmdCopy_clicked())); - contextMenu.addAction(tr("&View"), this, SLOT(on_cmdView_clicked())); - contextMenu.addMenu(&editMenu); - contextMenu.addMenu(&exportMenu); - contextMenu.addAction(tr("&Remove"), this, SLOT(on_cmdDelete_clicked())); - if (ui->cbSelected->isVisible()) - { - 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("Ctrl+A")); - ProfileInterface *profileInterface = (ProfileInterface*)snwgt; - if (profileInterface->selectedWidgets() != 0) - { - contextMenu.addAction(tr("&Deselect All"), this, SLOT(deselectAllWidgets()), QKeySequence::fromString("Ctrl+D")); - } - } - else - { - contextMenu.addSeparator(); - contextMenu.addAction(tr("&Select"), this, SLOT(pictureSelected())); - contextMenu.addAction(tr("Select &All"), this, SLOT(selectAllWidgets()), QKeySequence::fromString("Ctrl+A")); - } - contextMenu.exec(ev->globalPos()); + emit contextMenuTriggered(ev); } void SnapmaticWidget::dialogNextPictureRequested() @@ -276,10 +239,9 @@ void SnapmaticWidget::adjustTextColor() bool SnapmaticWidget::makePictureHidden() { - SnapmaticPicture *picture = (SnapmaticPicture*)smpic; - if (picture->setPictureHidden()) + if (smpic->setPictureHidden()) { - picPath = picture->getPictureFilePath(); + picPath = smpic->getPictureFilePath(); adjustTextColor(); return true; } @@ -288,10 +250,9 @@ bool SnapmaticWidget::makePictureHidden() bool SnapmaticWidget::makePictureVisible() { - SnapmaticPicture *picture = (SnapmaticPicture*)smpic; - if (picture->setPictureVisible()) + if (smpic->setPictureVisible()) { - picPath = picture->getPictureFilePath(); + picPath = smpic->getPictureFilePath(); adjustTextColor(); return true; } diff --git a/SnapmaticWidget.h b/SnapmaticWidget.h index df7e3c1..2e45d37 100755 --- a/SnapmaticWidget.h +++ b/SnapmaticWidget.h @@ -20,7 +20,6 @@ #define SNAPMATICWIDGET_H #include "SnapmaticPicture.h" -#include "ProfileInterface.h" #include "ProfileDatabase.h" #include "DatabaseThread.h" #include "ProfileWidget.h" @@ -97,6 +96,7 @@ signals: void allWidgetsDeselected(); void nextPictureRequested(QWidget *dialog); void previousPictureRequested(QWidget *dialog); + void contextMenuTriggered(QContextMenuEvent *ev); }; #endif // SNAPMATICWIDGET_H diff --git a/config.h b/config.h index 4837e86..f805e93 100755 --- a/config.h +++ b/config.h @@ -50,7 +50,7 @@ #ifndef GTA5SYNC_APPVER #ifndef GTA5SYNC_DAILYB -#define GTA5SYNC_APPVER "1.3.0" +#define GTA5SYNC_APPVER "1.3.1" #else #define GTA5SYNC_APPVER QString("%1").arg(GTA5SYNC_DAILYB) #endif