ram usage fix from gta5sync

This commit is contained in:
Rafael 2017-02-13 04:12:47 +01:00
parent 98de3f5560
commit 33a5faa7bf
8 changed files with 86 additions and 80 deletions

View file

@ -17,6 +17,7 @@
*****************************************************************************/ *****************************************************************************/
#include "SnapmaticPicture.h" #include "SnapmaticPicture.h"
#include "ProfileInterface.h"
#include "PictureExport.h" #include "PictureExport.h"
#include "ProfileWidget.h" #include "ProfileWidget.h"
#include "ExportThread.h" #include "ExportThread.h"

View file

@ -135,6 +135,7 @@ void ProfileInterface::savegameLoaded(SavegameData *savegame, QString savegamePa
QObject::connect(sgdWidget, SIGNAL(widgetDeselected()), this, SLOT(profileWidgetDeselected())); QObject::connect(sgdWidget, SIGNAL(widgetDeselected()), this, SLOT(profileWidgetDeselected()));
QObject::connect(sgdWidget, SIGNAL(allWidgetsSelected()), this, SLOT(selectAllWidgets())); QObject::connect(sgdWidget, SIGNAL(allWidgetsSelected()), this, SLOT(selectAllWidgets()));
QObject::connect(sgdWidget, SIGNAL(allWidgetsDeselected()), this, SLOT(deselectAllWidgets())); QObject::connect(sgdWidget, SIGNAL(allWidgetsDeselected()), this, SLOT(deselectAllWidgets()));
QObject::connect(sgdWidget, SIGNAL(contextMenuTriggered(QContextMenuEvent*)), this, SLOT(contextMenuTriggeredSGD(QContextMenuEvent*)));
if (inserted) { insertSavegameIPI(sgdWidget); } 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(allWidgetsDeselected()), this, SLOT(deselectAllWidgets()));
QObject::connect(picWidget, SIGNAL(nextPictureRequested(QWidget*)), this, SLOT(dialogNextPictureRequested(QWidget*))); QObject::connect(picWidget, SIGNAL(nextPictureRequested(QWidget*)), this, SLOT(dialogNextPictureRequested(QWidget*)));
QObject::connect(picWidget, SIGNAL(previousPictureRequested(QWidget*)), this, SLOT(dialogPreviousPictureRequested(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); } if (inserted) { insertSnapmaticIPI(picWidget); }
} }
@ -319,9 +321,8 @@ void ProfileInterface::savegameDeleted_event()
savegameDeleted((SavegameWidget*)sender()); savegameDeleted((SavegameWidget*)sender());
} }
void ProfileInterface::savegameDeleted(QWidget *sgdWidget_) void ProfileInterface::savegameDeleted(SavegameWidget *sgdWidget)
{ {
SavegameWidget *sgdWidget = (SavegameWidget*)sgdWidget_;
SavegameData *savegame = sgdWidget->getSavegame(); SavegameData *savegame = sgdWidget->getSavegame();
if (sgdWidget->isSelected()) { sgdWidget->setSelected(false); } if (sgdWidget->isSelected()) { sgdWidget->setSelected(false); }
widgets.remove(sgdWidget); widgets.remove(sgdWidget);
@ -336,9 +337,8 @@ void ProfileInterface::pictureDeleted_event()
pictureDeleted((SnapmaticWidget*)sender()); pictureDeleted((SnapmaticWidget*)sender());
} }
void ProfileInterface::pictureDeleted(QWidget *picWidget_) void ProfileInterface::pictureDeleted(SnapmaticWidget *picWidget)
{ {
SnapmaticWidget *picWidget = (SnapmaticWidget*)picWidget_;
SnapmaticPicture *picture = picWidget->getPicture(); SnapmaticPicture *picture = picWidget->getPicture();
if (picWidget->isSelected()) { picWidget->setSelected(false); } if (picWidget->isSelected()) { picWidget->setSelected(false); }
widgets.remove(picWidget); widgets.remove(picWidget);
@ -1057,3 +1057,71 @@ int ProfileInterface::selectedWidgets()
{ {
return selectedWidgts; 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 &GTA 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());
}

View file

@ -53,6 +53,8 @@ public:
~ProfileInterface(); ~ProfileInterface();
public slots: public slots:
void contextMenuTriggeredPIC(QContextMenuEvent* ev);
void contextMenuTriggeredSGD(QContextMenuEvent* ev);
void selectAllWidgets(); void selectAllWidgets();
void deselectAllWidgets(); void deselectAllWidgets();
void exportSelected(); void exportSelected();
@ -96,8 +98,8 @@ private:
bool importSavegameData(SavegameData *savegame, QString sgdPath, bool warn = true); bool importSavegameData(SavegameData *savegame, QString sgdPath, bool warn = true);
void pictureLoaded(SnapmaticPicture *picture, bool inserted); void pictureLoaded(SnapmaticPicture *picture, bool inserted);
void savegameLoaded(SavegameData *savegame, QString savegamePath, bool inserted); void savegameLoaded(SavegameData *savegame, QString savegamePath, bool inserted);
void savegameDeleted(QWidget *sgdWidget); void savegameDeleted(SavegameWidget *sgdWidget);
void pictureDeleted(QWidget *picWidget); void pictureDeleted(SnapmaticWidget *picWidget);
void insertSnapmaticIPI(QWidget *widget); void insertSnapmaticIPI(QWidget *widget);
void insertSavegameIPI(QWidget *widget); void insertSavegameIPI(QWidget *widget);
void sortingProfileInterface(); void sortingProfileInterface();

View file

@ -19,7 +19,6 @@
#include "SavegameWidget.h" #include "SavegameWidget.h"
#include "ui_SavegameWidget.h" #include "ui_SavegameWidget.h"
#include "SidebarGenerator.h" #include "SidebarGenerator.h"
#include "ProfileInterface.h"
#include "SavegameDialog.h" #include "SavegameDialog.h"
#include "StandardPaths.h" #include "StandardPaths.h"
#include "SavegameData.h" #include "SavegameData.h"
@ -205,31 +204,7 @@ void SavegameWidget::savegameSelected()
void SavegameWidget::contextMenuEvent(QContextMenuEvent *ev) void SavegameWidget::contextMenuEvent(QContextMenuEvent *ev)
{ {
QMenu contextMenu(this); emit contextMenuTriggered(ev);
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("");
} }
void SavegameWidget::on_cbSelected_stateChanged(int arg1) void SavegameWidget::on_cbSelected_stateChanged(int arg1)

View file

@ -18,8 +18,6 @@
#ifndef SAVEGAMEWIDGET_H #ifndef SAVEGAMEWIDGET_H
#define SAVEGAMEWIDGET_H #define SAVEGAMEWIDGET_H
#include "ProfileInterface.h"
#include "ProfileWidget.h" #include "ProfileWidget.h"
#include "SavegameData.h" #include "SavegameData.h"
#include <QContextMenuEvent> #include <QContextMenuEvent>
@ -78,6 +76,7 @@ signals:
void widgetDeselected(); void widgetDeselected();
void allWidgetsSelected(); void allWidgetsSelected();
void allWidgetsDeselected(); void allWidgetsDeselected();
void contextMenuTriggered(QContextMenuEvent *ev);
}; };
#endif // SAVEGAMEWIDGET_H #endif // SAVEGAMEWIDGET_H

View file

@ -48,7 +48,6 @@ SnapmaticWidget::SnapmaticWidget(ProfileDatabase *profileDB, CrewDatabase *crewD
palette.setCurrentColorGroup(QPalette::Disabled); palette.setCurrentColorGroup(QPalette::Disabled);
highlightHiddenColor = palette.text().color(); highlightHiddenColor = palette.text().color();
snwgt = parent;
picPath = ""; picPath = "";
picStr = ""; picStr = "";
smpic = 0; smpic = 0;
@ -201,43 +200,7 @@ void SnapmaticWidget::pictureSelected()
void SnapmaticWidget::contextMenuEvent(QContextMenuEvent *ev) void SnapmaticWidget::contextMenuEvent(QContextMenuEvent *ev)
{ {
QMenu contextMenu(this); emit contextMenuTriggered(ev);
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 &GTA 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());
} }
void SnapmaticWidget::dialogNextPictureRequested() void SnapmaticWidget::dialogNextPictureRequested()
@ -276,10 +239,9 @@ void SnapmaticWidget::adjustTextColor()
bool SnapmaticWidget::makePictureHidden() bool SnapmaticWidget::makePictureHidden()
{ {
SnapmaticPicture *picture = (SnapmaticPicture*)smpic; if (smpic->setPictureHidden())
if (picture->setPictureHidden())
{ {
picPath = picture->getPictureFilePath(); picPath = smpic->getPictureFilePath();
adjustTextColor(); adjustTextColor();
return true; return true;
} }
@ -288,10 +250,9 @@ bool SnapmaticWidget::makePictureHidden()
bool SnapmaticWidget::makePictureVisible() bool SnapmaticWidget::makePictureVisible()
{ {
SnapmaticPicture *picture = (SnapmaticPicture*)smpic; if (smpic->setPictureVisible())
if (picture->setPictureVisible())
{ {
picPath = picture->getPictureFilePath(); picPath = smpic->getPictureFilePath();
adjustTextColor(); adjustTextColor();
return true; return true;
} }

View file

@ -20,7 +20,6 @@
#define SNAPMATICWIDGET_H #define SNAPMATICWIDGET_H
#include "SnapmaticPicture.h" #include "SnapmaticPicture.h"
#include "ProfileInterface.h"
#include "ProfileDatabase.h" #include "ProfileDatabase.h"
#include "DatabaseThread.h" #include "DatabaseThread.h"
#include "ProfileWidget.h" #include "ProfileWidget.h"
@ -97,6 +96,7 @@ signals:
void allWidgetsDeselected(); void allWidgetsDeselected();
void nextPictureRequested(QWidget *dialog); void nextPictureRequested(QWidget *dialog);
void previousPictureRequested(QWidget *dialog); void previousPictureRequested(QWidget *dialog);
void contextMenuTriggered(QContextMenuEvent *ev);
}; };
#endif // SNAPMATICWIDGET_H #endif // SNAPMATICWIDGET_H

View file

@ -50,7 +50,7 @@
#ifndef GTA5SYNC_APPVER #ifndef GTA5SYNC_APPVER
#ifndef GTA5SYNC_DAILYB #ifndef GTA5SYNC_DAILYB
#define GTA5SYNC_APPVER "1.3.0" #define GTA5SYNC_APPVER "1.3.1"
#else #else
#define GTA5SYNC_APPVER QString("%1").arg(GTA5SYNC_DAILYB) #define GTA5SYNC_APPVER QString("%1").arg(GTA5SYNC_DAILYB)
#endif #endif