in selection mode view only with right click, menuBar Edit menu added
This commit is contained in:
		
							parent
							
								
									cee1d0f861
								
							
						
					
					
						commit
						b53c27db9d
					
				
					 11 changed files with 175 additions and 40 deletions
				
			
		|  | @ -94,7 +94,7 @@ void ProfileInterface::setupProfileInterface() | |||
|     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(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(); | ||||
| } | ||||
| 
 | ||||
|  | @ -131,20 +131,21 @@ void ProfileInterface::loadingProgress(int value, int 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); | ||||
|     ui->saProfileContent->layout()->addItem(saSpacerItem); | ||||
|     ui->swProfile->setCurrentWidget(ui->pageProfile); | ||||
|     ui->cmdCloseProfile->setEnabled(true); | ||||
|     ui->cmdImport->setEnabled(true); | ||||
|     emit profileLoaded(); | ||||
| } | ||||
| 
 | ||||
| void ProfileInterface::savegameDeleted() | ||||
| { | ||||
|     SavegameWidget *sgdWidget = (SavegameWidget*)sender(); | ||||
|     SavegameData *savegame = sgdWidget->getSavegame(); | ||||
|     if (sgdWidget->isSelected()) { sgdWidget->setChecked(false); } | ||||
|     if (sgdWidget->isSelected()) { sgdWidget->setSelected(false); } | ||||
|     sgdWidget->close(); | ||||
|     savegames.removeAll(savegame); | ||||
|     delete savegame; | ||||
|  | @ -154,7 +155,7 @@ void ProfileInterface::pictureDeleted() | |||
| { | ||||
|     SnapmaticWidget *picWidget = (SnapmaticWidget*)sender(); | ||||
|     SnapmaticPicture *picture = picWidget->getPicture(); | ||||
|     if (picWidget->isSelected()) { picWidget->setChecked(false); } | ||||
|     if (picWidget->isSelected()) { picWidget->setSelected(false); } | ||||
|     picWidget->close(); | ||||
|     pictures.removeAll(picture); | ||||
|     delete picture; | ||||
|  | @ -363,3 +364,19 @@ void ProfileInterface::profileWidgetDeselected() | |||
|     } | ||||
|     selectedWidgts--; | ||||
| } | ||||
| 
 | ||||
| void ProfileInterface::selectAllWidgets() | ||||
| { | ||||
|     foreach(ProfileWidget *widget, widgets.keys()) | ||||
|     { | ||||
|         widget->setSelected(true); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void ProfileInterface::deselectAllWidgets() | ||||
| { | ||||
|     foreach(ProfileWidget *widget, widgets.keys()) | ||||
|     { | ||||
|         widget->setSelected(false); | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -45,15 +45,19 @@ public: | |||
|     void setupProfileInterface(); | ||||
|     ~ProfileInterface(); | ||||
| 
 | ||||
| public slots: | ||||
|     void selectAllWidgets(); | ||||
|     void deselectAllWidgets(); | ||||
| 
 | ||||
| private slots: | ||||
|     void on_cmdCloseProfile_clicked(); | ||||
|     void on_cmdImport_clicked(); | ||||
|     void pictureLoaded(SnapmaticPicture *picture, QString picturePath); | ||||
|     void savegameLoaded(SavegameData *savegame, QString savegamePath); | ||||
|     void loadingProgress(int value, int maximum); | ||||
|     void savegameDeleted(); | ||||
|     void pictureDeleted(); | ||||
|     void profileLoaded(); | ||||
|     void savegameDeleted(); | ||||
|     void profileLoaded_p(); | ||||
|     void profileWidgetSelected(); | ||||
|     void profileWidgetDeselected(); | ||||
| 
 | ||||
|  | @ -77,6 +81,7 @@ private: | |||
|     bool importSavegameData(SavegameData *savegame, QString sgdPath); | ||||
| 
 | ||||
| signals: | ||||
|     void profileLoaded(); | ||||
|     void profileClosed(); | ||||
| }; | ||||
| 
 | ||||
|  |  | |||
|  | @ -30,11 +30,16 @@ ProfileWidget::~ProfileWidget() | |||
| 
 | ||||
| bool ProfileWidget::isSelected() | ||||
| { | ||||
|     qDebug() << "ProfileWidget got used without overwrite"; | ||||
|     qDebug() << "ProfileWidget::isSelected got used without overwrite"; | ||||
|     return false; | ||||
| } | ||||
| 
 | ||||
| void ProfileWidget::setSelected(bool isSelected) | ||||
| { | ||||
|     qDebug() << "ProfileWidget::setSelected got used without overwrite, result" << isSelected; | ||||
| } | ||||
| 
 | ||||
| void ProfileWidget::setSelectionMode(bool selectionMode) | ||||
| { | ||||
|     qDebug() << "ProfileWidget got used without overwrite, result:" << selectionMode; | ||||
|     qDebug() << "ProfileWidget::setSelectionMode got used without overwrite, result:" << selectionMode; | ||||
| } | ||||
|  |  | |||
|  | @ -27,6 +27,7 @@ class ProfileWidget : public QWidget | |||
| public: | ||||
|     explicit ProfileWidget(QWidget *parent = 0); | ||||
|     virtual void setSelectionMode(bool selectionMode); | ||||
|     virtual void setSelected(bool isSelected); | ||||
|     virtual bool isSelected(); | ||||
|     ~ProfileWidget(); | ||||
| 
 | ||||
|  |  | |||
|  | @ -106,17 +106,6 @@ void SavegameWidget::on_cmdView_clicked() | |||
|     delete savegameDialog; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| void SavegameWidget::setChecked(bool isChecked) | ||||
| { | ||||
|     ui->cbSelected->setChecked(isChecked); | ||||
| } | ||||
| 
 | ||||
| void SavegameWidget::savegameSelected() | ||||
| { | ||||
|     setChecked(true); | ||||
| } | ||||
| 
 | ||||
| void SavegameWidget::mousePressEvent(QMouseEvent *ev) | ||||
| { | ||||
|     ProfileWidget::mouseReleaseEvent(ev); | ||||
|  | @ -131,7 +120,8 @@ void SavegameWidget::mouseReleaseEvent(QMouseEvent *ev) | |||
|         if (rect().contains(ev->pos()) && ev->button() == Qt::LeftButton) | ||||
|         { | ||||
|             clkIssued = false; | ||||
|             QTimer::singleShot(QApplication::doubleClickInterval(), this, SLOT(changeCheckedState())); | ||||
|             //QTimer::singleShot(QApplication::doubleClickInterval(), this, SLOT(changeCheckedState()));
 | ||||
|             ui->cbSelected->setChecked(!ui->cbSelected->isChecked()); | ||||
|         } | ||||
|     } | ||||
|     else | ||||
|  | @ -147,11 +137,11 @@ void SavegameWidget::mouseDoubleClickEvent(QMouseEvent *ev) | |||
| { | ||||
|     QWidget::mouseDoubleClickEvent(ev); | ||||
| 
 | ||||
|     if (ev->button() == Qt::LeftButton) | ||||
|     { | ||||
|         clkIssued = true; | ||||
|         on_cmdView_clicked(); | ||||
|     } | ||||
| //  if (ev->button() == Qt::LeftButton)
 | ||||
| //  {
 | ||||
| //      clkIssued = true;
 | ||||
| //      on_cmdView_clicked();
 | ||||
| //  }
 | ||||
| } | ||||
| 
 | ||||
| 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) | ||||
| { | ||||
|     QMenu contextMenu(this); | ||||
|     if (!ui->cbSelected->isChecked()) | ||||
|     if (!ui->cbSelected->isVisible()) | ||||
|     { | ||||
|         contextMenu.addAction(tr("Select"), this, SLOT(savegameSelected())); | ||||
|         contextMenu.addSeparator(); | ||||
|  |  | |||
|  | @ -37,7 +37,7 @@ public: | |||
|     SavegameWidget(QWidget *parent = 0); | ||||
|     void setSavegameData(SavegameData *savegame, QString savegamePath); | ||||
|     void setSelectionMode(bool selectionMode); | ||||
|     void setChecked(bool isChecked); | ||||
|     void setSelected(bool isSelected); | ||||
|     SavegameData* getSavegame(); | ||||
|     bool isSelected(); | ||||
|     ~SavegameWidget(); | ||||
|  |  | |||
|  | @ -129,7 +129,8 @@ void SnapmaticWidget::mouseReleaseEvent(QMouseEvent *ev) | |||
|         if (rect().contains(ev->pos()) && ev->button() == Qt::LeftButton) | ||||
|         { | ||||
|             clkIssued = false; | ||||
|             QTimer::singleShot(QApplication::doubleClickInterval(), this, SLOT(changeCheckedState())); | ||||
|             //QTimer::singleShot(QApplication::doubleClickInterval(), this, SLOT(changeCheckedState()));
 | ||||
|             ui->cbSelected->setChecked(!ui->cbSelected->isChecked()); | ||||
|         } | ||||
|     } | ||||
|     else | ||||
|  | @ -145,11 +146,11 @@ void SnapmaticWidget::mouseDoubleClickEvent(QMouseEvent *ev) | |||
| { | ||||
|     QWidget::mouseDoubleClickEvent(ev); | ||||
| 
 | ||||
|     if (ev->button() == Qt::LeftButton) | ||||
|     { | ||||
|         clkIssued = true; | ||||
|         on_cmdView_clicked(); | ||||
|     } | ||||
| //  if (ev->button() == Qt::LeftButton)
 | ||||
| //  {
 | ||||
| //      clkIssued = true;
 | ||||
| //      on_cmdView_clicked();
 | ||||
| //  }
 | ||||
| } | ||||
| 
 | ||||
| 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() | ||||
| { | ||||
|     setChecked(true); | ||||
|     setSelected(true); | ||||
| } | ||||
| 
 | ||||
| void SnapmaticWidget::contextMenuEvent(QContextMenuEvent *ev) | ||||
| { | ||||
|     QMenu contextMenu(this); | ||||
|     if (!ui->cbSelected->isChecked()) | ||||
|     if (!ui->cbSelected->isVisible()) | ||||
|     { | ||||
|         contextMenu.addAction(tr("Select"), this, SLOT(pictureSelected())); | ||||
|         contextMenu.addSeparator(); | ||||
|  |  | |||
|  | @ -39,7 +39,7 @@ public: | |||
|     SnapmaticWidget(ProfileDatabase *profileDB, DatabaseThread *threadDB, QWidget *parent = 0); | ||||
|     void setSnapmaticPicture(SnapmaticPicture *picture, QString picturePath); | ||||
|     void setSelectionMode(bool selectionMode); | ||||
|     void setChecked(bool isChecked); | ||||
|     void setSelected(bool isSelected); | ||||
|     bool isSelected(); | ||||
|     SnapmaticPicture *getPicture(); | ||||
|     ~SnapmaticWidget(); | ||||
|  |  | |||
|  | @ -27,6 +27,7 @@ | |||
| #include <QMessageBox> | ||||
| #include <QSettings> | ||||
| #include <QFileInfo> | ||||
| #include <QProcess> | ||||
| #include <QDebug> | ||||
| #include <QFile> | ||||
| #include <QDir> | ||||
|  | @ -39,6 +40,7 @@ UserInterface::UserInterface(ProfileDatabase *profileDB, CrewDatabase *crewDB, D | |||
|     ui->setupUi(this); | ||||
|     profileOpen = 0; | ||||
|     profileUI = 0; | ||||
|     ui->menuProfile->setEnabled(false); | ||||
|     defaultWindowTitle = this->windowTitle(); | ||||
| 
 | ||||
|     this->setWindowIcon(QIcon(":/img/5sync.png")); | ||||
|  | @ -67,7 +69,7 @@ UserInterface::UserInterface(ProfileDatabase *profileDB, CrewDatabase *crewDB, D | |||
|     } | ||||
|     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(); | ||||
| 
 | ||||
|  | @ -94,7 +96,16 @@ UserInterface::UserInterface(ProfileDatabase *profileDB, CrewDatabase *crewDB, D | |||
| 
 | ||||
| void UserInterface::setupProfileUi(QStringList GTAV_Profiles) | ||||
| { | ||||
|     foreach(const QString >AV_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 >AV_Profile, GTAV_Profiles) | ||||
|     { | ||||
|         QPushButton *profileBtn = new QPushButton(GTAV_Profile, ui->swSelection); | ||||
|         profileBtn->setObjectName(GTAV_Profile); | ||||
|  | @ -122,6 +133,22 @@ void UserInterface::setupProfileUi(QStringList GTAV_Profiles) | |||
|     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() | ||||
| { | ||||
|     QPushButton *profileBtn = (QPushButton*)sender(); | ||||
|  | @ -137,6 +164,7 @@ void UserInterface::openProfile(QString profileName) | |||
|     profileUI->setProfileFolder(GTAV_ProfilesFolder + "/" + profileName, profileName); | ||||
|     profileUI->setupProfileInterface(); | ||||
|     QObject::connect(profileUI, SIGNAL(profileClosed()), this, SLOT(closeProfile())); | ||||
|     QObject::connect(profileUI, SIGNAL(profileLoaded()), this, SLOT(profileLoaded())); | ||||
|     this->setWindowTitle(defaultWindowTitle.arg(profileName)); | ||||
| } | ||||
| 
 | ||||
|  | @ -183,3 +211,18 @@ void UserInterface::on_actionAbout_gta5sync_triggered() | |||
|     aboutDialog->deleteLater(); | ||||
|     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(); | ||||
| } | ||||
|  |  | |||
|  | @ -40,10 +40,14 @@ public: | |||
| 
 | ||||
| private slots: | ||||
|     void closeProfile(); | ||||
|     void profileLoaded(); | ||||
|     void profileButton_clicked(); | ||||
|     void reloadProfiles_clicked(); | ||||
|     void on_actionExit_triggered(); | ||||
|     void on_actionSelect_profile_triggered(); | ||||
|     void on_actionAbout_gta5sync_triggered(); | ||||
|     void on_actionSelect_all_triggered(); | ||||
|     void on_actionDeselect_all_triggered(); | ||||
| 
 | ||||
| private: | ||||
|     ProfileDatabase *profileDB; | ||||
|  |  | |||
|  | @ -94,7 +94,26 @@ | |||
|     </property> | ||||
|     <addaction name="actionAbout_gta5sync"/> | ||||
|    </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="menuEdit"/> | ||||
|    <addaction name="menuHelp"/> | ||||
|   </widget> | ||||
|   <action name="actionAbout_gta5sync"> | ||||
|  | @ -121,6 +140,46 @@ | |||
|     <string>Ctrl+P</string> | ||||
|    </property> | ||||
|   </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> | ||||
|  <resources/> | ||||
|  <connections/> | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue