in selection mode view only with right click, menuBar Edit menu added

This commit is contained in:
Rafael 2016-04-03 08:39:31 +02:00
parent cee1d0f861
commit b53c27db9d
11 changed files with 175 additions and 40 deletions

View file

@ -94,7 +94,7 @@ void ProfileInterface::setupProfileInterface()
QObject::connect(profileLoader, SIGNAL(savegameLoaded(SavegameData*, QString)), this, SLOT(savegameLoaded(SavegameData*, QString))); QObject::connect(profileLoader, SIGNAL(savegameLoaded(SavegameData*, QString)), this, SLOT(savegameLoaded(SavegameData*, QString)));
QObject::connect(profileLoader, SIGNAL(pictureLoaded(SnapmaticPicture*, QString)), this, SLOT(pictureLoaded(SnapmaticPicture*, QString))); QObject::connect(profileLoader, SIGNAL(pictureLoaded(SnapmaticPicture*, QString)), this, SLOT(pictureLoaded(SnapmaticPicture*, QString)));
QObject::connect(profileLoader, SIGNAL(loadingProgress(int,int)), this, SLOT(loadingProgress(int,int))); QObject::connect(profileLoader, SIGNAL(loadingProgress(int,int)), this, SLOT(loadingProgress(int,int)));
QObject::connect(profileLoader, SIGNAL(finished()), this, SLOT(profileLoaded())); QObject::connect(profileLoader, SIGNAL(finished()), this, SLOT(profileLoaded_p()));
profileLoader->start(); profileLoader->start();
} }
@ -131,20 +131,21 @@ void ProfileInterface::loadingProgress(int value, int maximum)
ui->labProfileLoading->setText(loadingStr.arg(QString::number(value), QString::number(maximum))); ui->labProfileLoading->setText(loadingStr.arg(QString::number(value), QString::number(maximum)));
} }
void ProfileInterface::profileLoaded() void ProfileInterface::profileLoaded_p()
{ {
saSpacerItem = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); saSpacerItem = new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding);
ui->saProfileContent->layout()->addItem(saSpacerItem); ui->saProfileContent->layout()->addItem(saSpacerItem);
ui->swProfile->setCurrentWidget(ui->pageProfile); ui->swProfile->setCurrentWidget(ui->pageProfile);
ui->cmdCloseProfile->setEnabled(true); ui->cmdCloseProfile->setEnabled(true);
ui->cmdImport->setEnabled(true); ui->cmdImport->setEnabled(true);
emit profileLoaded();
} }
void ProfileInterface::savegameDeleted() void ProfileInterface::savegameDeleted()
{ {
SavegameWidget *sgdWidget = (SavegameWidget*)sender(); SavegameWidget *sgdWidget = (SavegameWidget*)sender();
SavegameData *savegame = sgdWidget->getSavegame(); SavegameData *savegame = sgdWidget->getSavegame();
if (sgdWidget->isSelected()) { sgdWidget->setChecked(false); } if (sgdWidget->isSelected()) { sgdWidget->setSelected(false); }
sgdWidget->close(); sgdWidget->close();
savegames.removeAll(savegame); savegames.removeAll(savegame);
delete savegame; delete savegame;
@ -154,7 +155,7 @@ void ProfileInterface::pictureDeleted()
{ {
SnapmaticWidget *picWidget = (SnapmaticWidget*)sender(); SnapmaticWidget *picWidget = (SnapmaticWidget*)sender();
SnapmaticPicture *picture = picWidget->getPicture(); SnapmaticPicture *picture = picWidget->getPicture();
if (picWidget->isSelected()) { picWidget->setChecked(false); } if (picWidget->isSelected()) { picWidget->setSelected(false); }
picWidget->close(); picWidget->close();
pictures.removeAll(picture); pictures.removeAll(picture);
delete picture; delete picture;
@ -363,3 +364,19 @@ void ProfileInterface::profileWidgetDeselected()
} }
selectedWidgts--; selectedWidgts--;
} }
void ProfileInterface::selectAllWidgets()
{
foreach(ProfileWidget *widget, widgets.keys())
{
widget->setSelected(true);
}
}
void ProfileInterface::deselectAllWidgets()
{
foreach(ProfileWidget *widget, widgets.keys())
{
widget->setSelected(false);
}
}

View file

@ -45,15 +45,19 @@ public:
void setupProfileInterface(); void setupProfileInterface();
~ProfileInterface(); ~ProfileInterface();
public slots:
void selectAllWidgets();
void deselectAllWidgets();
private slots: private slots:
void on_cmdCloseProfile_clicked(); void on_cmdCloseProfile_clicked();
void on_cmdImport_clicked(); void on_cmdImport_clicked();
void pictureLoaded(SnapmaticPicture *picture, QString picturePath); void pictureLoaded(SnapmaticPicture *picture, QString picturePath);
void savegameLoaded(SavegameData *savegame, QString savegamePath); void savegameLoaded(SavegameData *savegame, QString savegamePath);
void loadingProgress(int value, int maximum); void loadingProgress(int value, int maximum);
void savegameDeleted();
void pictureDeleted(); void pictureDeleted();
void profileLoaded(); void savegameDeleted();
void profileLoaded_p();
void profileWidgetSelected(); void profileWidgetSelected();
void profileWidgetDeselected(); void profileWidgetDeselected();
@ -77,6 +81,7 @@ private:
bool importSavegameData(SavegameData *savegame, QString sgdPath); bool importSavegameData(SavegameData *savegame, QString sgdPath);
signals: signals:
void profileLoaded();
void profileClosed(); void profileClosed();
}; };

View file

@ -30,11 +30,16 @@ ProfileWidget::~ProfileWidget()
bool ProfileWidget::isSelected() bool ProfileWidget::isSelected()
{ {
qDebug() << "ProfileWidget got used without overwrite"; qDebug() << "ProfileWidget::isSelected got used without overwrite";
return false; return false;
} }
void ProfileWidget::setSelected(bool isSelected)
{
qDebug() << "ProfileWidget::setSelected got used without overwrite, result" << isSelected;
}
void ProfileWidget::setSelectionMode(bool selectionMode) void ProfileWidget::setSelectionMode(bool selectionMode)
{ {
qDebug() << "ProfileWidget got used without overwrite, result:" << selectionMode; qDebug() << "ProfileWidget::setSelectionMode got used without overwrite, result:" << selectionMode;
} }

View file

@ -27,6 +27,7 @@ class ProfileWidget : public QWidget
public: public:
explicit ProfileWidget(QWidget *parent = 0); explicit ProfileWidget(QWidget *parent = 0);
virtual void setSelectionMode(bool selectionMode); virtual void setSelectionMode(bool selectionMode);
virtual void setSelected(bool isSelected);
virtual bool isSelected(); virtual bool isSelected();
~ProfileWidget(); ~ProfileWidget();

View file

@ -106,17 +106,6 @@ void SavegameWidget::on_cmdView_clicked()
delete savegameDialog; delete savegameDialog;
} }
void SavegameWidget::setChecked(bool isChecked)
{
ui->cbSelected->setChecked(isChecked);
}
void SavegameWidget::savegameSelected()
{
setChecked(true);
}
void SavegameWidget::mousePressEvent(QMouseEvent *ev) void SavegameWidget::mousePressEvent(QMouseEvent *ev)
{ {
ProfileWidget::mouseReleaseEvent(ev); ProfileWidget::mouseReleaseEvent(ev);
@ -131,7 +120,8 @@ void SavegameWidget::mouseReleaseEvent(QMouseEvent *ev)
if (rect().contains(ev->pos()) && ev->button() == Qt::LeftButton) if (rect().contains(ev->pos()) && ev->button() == Qt::LeftButton)
{ {
clkIssued = false; clkIssued = false;
QTimer::singleShot(QApplication::doubleClickInterval(), this, SLOT(changeCheckedState())); //QTimer::singleShot(QApplication::doubleClickInterval(), this, SLOT(changeCheckedState()));
ui->cbSelected->setChecked(!ui->cbSelected->isChecked());
} }
} }
else else
@ -147,11 +137,11 @@ void SavegameWidget::mouseDoubleClickEvent(QMouseEvent *ev)
{ {
QWidget::mouseDoubleClickEvent(ev); QWidget::mouseDoubleClickEvent(ev);
if (ev->button() == Qt::LeftButton) // if (ev->button() == Qt::LeftButton)
{ // {
clkIssued = true; // clkIssued = true;
on_cmdView_clicked(); // on_cmdView_clicked();
} // }
} }
void SavegameWidget::changeCheckedState() void SavegameWidget::changeCheckedState()
@ -162,10 +152,20 @@ void SavegameWidget::changeCheckedState()
} }
} }
void SavegameWidget::setSelected(bool isSelected)
{
ui->cbSelected->setChecked(isSelected);
}
void SavegameWidget::savegameSelected()
{
setSelected(true);
}
void SavegameWidget::contextMenuEvent(QContextMenuEvent *ev) void SavegameWidget::contextMenuEvent(QContextMenuEvent *ev)
{ {
QMenu contextMenu(this); QMenu contextMenu(this);
if (!ui->cbSelected->isChecked()) if (!ui->cbSelected->isVisible())
{ {
contextMenu.addAction(tr("Select"), this, SLOT(savegameSelected())); contextMenu.addAction(tr("Select"), this, SLOT(savegameSelected()));
contextMenu.addSeparator(); contextMenu.addSeparator();

View file

@ -37,7 +37,7 @@ public:
SavegameWidget(QWidget *parent = 0); SavegameWidget(QWidget *parent = 0);
void setSavegameData(SavegameData *savegame, QString savegamePath); void setSavegameData(SavegameData *savegame, QString savegamePath);
void setSelectionMode(bool selectionMode); void setSelectionMode(bool selectionMode);
void setChecked(bool isChecked); void setSelected(bool isSelected);
SavegameData* getSavegame(); SavegameData* getSavegame();
bool isSelected(); bool isSelected();
~SavegameWidget(); ~SavegameWidget();

View file

@ -129,7 +129,8 @@ void SnapmaticWidget::mouseReleaseEvent(QMouseEvent *ev)
if (rect().contains(ev->pos()) && ev->button() == Qt::LeftButton) if (rect().contains(ev->pos()) && ev->button() == Qt::LeftButton)
{ {
clkIssued = false; clkIssued = false;
QTimer::singleShot(QApplication::doubleClickInterval(), this, SLOT(changeCheckedState())); //QTimer::singleShot(QApplication::doubleClickInterval(), this, SLOT(changeCheckedState()));
ui->cbSelected->setChecked(!ui->cbSelected->isChecked());
} }
} }
else else
@ -145,11 +146,11 @@ void SnapmaticWidget::mouseDoubleClickEvent(QMouseEvent *ev)
{ {
QWidget::mouseDoubleClickEvent(ev); QWidget::mouseDoubleClickEvent(ev);
if (ev->button() == Qt::LeftButton) // if (ev->button() == Qt::LeftButton)
{ // {
clkIssued = true; // clkIssued = true;
on_cmdView_clicked(); // on_cmdView_clicked();
} // }
} }
void SnapmaticWidget::changeCheckedState() void SnapmaticWidget::changeCheckedState()
@ -160,20 +161,20 @@ void SnapmaticWidget::changeCheckedState()
} }
} }
void SnapmaticWidget::setChecked(bool isChecked) void SnapmaticWidget::setSelected(bool isSelected)
{ {
ui->cbSelected->setChecked(isChecked); ui->cbSelected->setChecked(isSelected);
} }
void SnapmaticWidget::pictureSelected() void SnapmaticWidget::pictureSelected()
{ {
setChecked(true); setSelected(true);
} }
void SnapmaticWidget::contextMenuEvent(QContextMenuEvent *ev) void SnapmaticWidget::contextMenuEvent(QContextMenuEvent *ev)
{ {
QMenu contextMenu(this); QMenu contextMenu(this);
if (!ui->cbSelected->isChecked()) if (!ui->cbSelected->isVisible())
{ {
contextMenu.addAction(tr("Select"), this, SLOT(pictureSelected())); contextMenu.addAction(tr("Select"), this, SLOT(pictureSelected()));
contextMenu.addSeparator(); contextMenu.addSeparator();

View file

@ -39,7 +39,7 @@ public:
SnapmaticWidget(ProfileDatabase *profileDB, DatabaseThread *threadDB, QWidget *parent = 0); SnapmaticWidget(ProfileDatabase *profileDB, DatabaseThread *threadDB, QWidget *parent = 0);
void setSnapmaticPicture(SnapmaticPicture *picture, QString picturePath); void setSnapmaticPicture(SnapmaticPicture *picture, QString picturePath);
void setSelectionMode(bool selectionMode); void setSelectionMode(bool selectionMode);
void setChecked(bool isChecked); void setSelected(bool isSelected);
bool isSelected(); bool isSelected();
SnapmaticPicture *getPicture(); SnapmaticPicture *getPicture();
~SnapmaticWidget(); ~SnapmaticWidget();

View file

@ -27,6 +27,7 @@
#include <QMessageBox> #include <QMessageBox>
#include <QSettings> #include <QSettings>
#include <QFileInfo> #include <QFileInfo>
#include <QProcess>
#include <QDebug> #include <QDebug>
#include <QFile> #include <QFile>
#include <QDir> #include <QDir>
@ -39,6 +40,7 @@ UserInterface::UserInterface(ProfileDatabase *profileDB, CrewDatabase *crewDB, D
ui->setupUi(this); ui->setupUi(this);
profileOpen = 0; profileOpen = 0;
profileUI = 0; profileUI = 0;
ui->menuProfile->setEnabled(false);
defaultWindowTitle = this->windowTitle(); defaultWindowTitle = this->windowTitle();
this->setWindowIcon(QIcon(":/img/5sync.png")); this->setWindowIcon(QIcon(":/img/5sync.png"));
@ -67,7 +69,7 @@ UserInterface::UserInterface(ProfileDatabase *profileDB, CrewDatabase *crewDB, D
} }
else else
{ {
QMessageBox::warning(this, tr("gta5sync"), tr("GTA V Folder not found!")); QMessageBox::warning(this, tr("gta5sync"), tr("Grand Theft Auto V Folder not found!"));
} }
SyncSettings.endGroup(); SyncSettings.endGroup();
@ -94,7 +96,16 @@ UserInterface::UserInterface(ProfileDatabase *profileDB, CrewDatabase *crewDB, D
void UserInterface::setupProfileUi(QStringList GTAV_Profiles) void UserInterface::setupProfileUi(QStringList GTAV_Profiles)
{ {
foreach(const QString &GTAV_Profile, GTAV_Profiles) if (GTAV_Profiles.length() == 0)
{
QPushButton *reloadBtn = new QPushButton(tr("Reload"), ui->swSelection);
reloadBtn->setObjectName("Reload");
reloadBtn->setAutoDefault(true);
ui->swSelection->layout()->addWidget(reloadBtn);
QObject::connect(reloadBtn, SIGNAL(clicked(bool)), this, SLOT(reloadProfiles_clicked()));
}
else foreach(const QString &GTAV_Profile, GTAV_Profiles)
{ {
QPushButton *profileBtn = new QPushButton(GTAV_Profile, ui->swSelection); QPushButton *profileBtn = new QPushButton(GTAV_Profile, ui->swSelection);
profileBtn->setObjectName(GTAV_Profile); profileBtn->setObjectName(GTAV_Profile);
@ -122,6 +133,22 @@ void UserInterface::setupProfileUi(QStringList GTAV_Profiles)
QObject::connect(cmdClose, SIGNAL(clicked(bool)), this, SLOT(close())); QObject::connect(cmdClose, SIGNAL(clicked(bool)), this, SLOT(close()));
} }
void UserInterface::reloadProfiles_clicked()
{
QStringList gta5sync_a = qApp->arguments();
if (gta5sync_a.length() >= 1)
{
QProcess gta5sync_p;
QString gta5sync_exe = gta5sync_a.at(0);
gta5sync_a.removeAt(0);
gta5sync_p.startDetached(gta5sync_exe, gta5sync_a);
}
else
{
QMessageBox::warning(this, tr("Reload profiles"), tr("Not able to reload profiles"));
}
}
void UserInterface::profileButton_clicked() void UserInterface::profileButton_clicked()
{ {
QPushButton *profileBtn = (QPushButton*)sender(); QPushButton *profileBtn = (QPushButton*)sender();
@ -137,6 +164,7 @@ void UserInterface::openProfile(QString profileName)
profileUI->setProfileFolder(GTAV_ProfilesFolder + "/" + profileName, profileName); profileUI->setProfileFolder(GTAV_ProfilesFolder + "/" + profileName, profileName);
profileUI->setupProfileInterface(); profileUI->setupProfileInterface();
QObject::connect(profileUI, SIGNAL(profileClosed()), this, SLOT(closeProfile())); QObject::connect(profileUI, SIGNAL(profileClosed()), this, SLOT(closeProfile()));
QObject::connect(profileUI, SIGNAL(profileLoaded()), this, SLOT(profileLoaded()));
this->setWindowTitle(defaultWindowTitle.arg(profileName)); this->setWindowTitle(defaultWindowTitle.arg(profileName));
} }
@ -183,3 +211,18 @@ void UserInterface::on_actionAbout_gta5sync_triggered()
aboutDialog->deleteLater(); aboutDialog->deleteLater();
delete aboutDialog; delete aboutDialog;
} }
void UserInterface::profileLoaded()
{
ui->menuProfile->setEnabled(true);
}
void UserInterface::on_actionSelect_all_triggered()
{
profileUI->selectAllWidgets();
}
void UserInterface::on_actionDeselect_all_triggered()
{
profileUI->deselectAllWidgets();
}

View file

@ -40,10 +40,14 @@ public:
private slots: private slots:
void closeProfile(); void closeProfile();
void profileLoaded();
void profileButton_clicked(); void profileButton_clicked();
void reloadProfiles_clicked();
void on_actionExit_triggered(); void on_actionExit_triggered();
void on_actionSelect_profile_triggered(); void on_actionSelect_profile_triggered();
void on_actionAbout_gta5sync_triggered(); void on_actionAbout_gta5sync_triggered();
void on_actionSelect_all_triggered();
void on_actionDeselect_all_triggered();
private: private:
ProfileDatabase *profileDB; ProfileDatabase *profileDB;

View file

@ -94,7 +94,26 @@
</property> </property>
<addaction name="actionAbout_gta5sync"/> <addaction name="actionAbout_gta5sync"/>
</widget> </widget>
<widget class="QMenu" name="menuEdit">
<property name="title">
<string>Edit</string>
</property>
<widget class="QMenu" name="menuProfile">
<property name="title">
<string>Profile</string>
</property>
<addaction name="actionSelect_all"/>
<addaction name="actionDeselect_all"/>
<addaction name="separator"/>
<addaction name="actionExport_selected"/>
<addaction name="actionDelete_selected"/>
</widget>
<addaction name="menuProfile"/>
<addaction name="separator"/>
<addaction name="actionOptions"/>
</widget>
<addaction name="menuFile"/> <addaction name="menuFile"/>
<addaction name="menuEdit"/>
<addaction name="menuHelp"/> <addaction name="menuHelp"/>
</widget> </widget>
<action name="actionAbout_gta5sync"> <action name="actionAbout_gta5sync">
@ -121,6 +140,46 @@
<string>Ctrl+P</string> <string>Ctrl+P</string>
</property> </property>
</action> </action>
<action name="actionOptions">
<property name="text">
<string>Options</string>
</property>
<property name="shortcut">
<string>Ctrl+O</string>
</property>
</action>
<action name="actionSelect_all">
<property name="text">
<string>Select all</string>
</property>
<property name="shortcut">
<string>Ctrl+S</string>
</property>
</action>
<action name="actionDeselect_all">
<property name="text">
<string>Deselect all</string>
</property>
<property name="shortcut">
<string>Shift+S</string>
</property>
</action>
<action name="actionExport_selected">
<property name="text">
<string>Export selected</string>
</property>
<property name="shortcut">
<string>Ctrl+E</string>
</property>
</action>
<action name="actionDelete_selected">
<property name="text">
<string>Delete selected</string>
</property>
<property name="shortcut">
<string>Ctrl+D</string>
</property>
</action>
</widget> </widget>
<resources/> <resources/>
<connections/> <connections/>