diff --git a/PictureDialog.cpp b/PictureDialog.cpp index a00edad..a75aa78 100755 --- a/PictureDialog.cpp +++ b/PictureDialog.cpp @@ -150,11 +150,16 @@ void PictureDialog::on_cmdExport_clicked() fileDialog.setFileMode(QFileDialog::AnyFile); fileDialog.setViewMode(QFileDialog::Detail); fileDialog.setAcceptMode(QFileDialog::AcceptSave); + fileDialog.setOption(QFileDialog::DontUseNativeDialog, true); fileDialog.setDefaultSuffix("suffix"); - fileDialog.setNameFilter(tr("JPEG picture (*.jpg);;Portable Network Graphics (*.png)")); fileDialog.setWindowTitle(tr("Export picture")); fileDialog.setWindowFlags(fileDialog.windowFlags()^Qt::WindowContextHelpButtonHint); + QStringList filters; + filters << tr("JPEG picture (*.jpg)"); + filters << tr("Portable Network Graphics (*.png)"); + fileDialog.setNameFilters(filters); + QList<QUrl> sidebarUrls = fileDialog.sidebarUrls(); QDir dir; diff --git a/SavegameWidget.cpp b/SavegameWidget.cpp index 27edc09..ff42ed6 100755 --- a/SavegameWidget.cpp +++ b/SavegameWidget.cpp @@ -18,9 +18,13 @@ #include "SavegameWidget.h" #include "ui_SavegameWidget.h" +#include "StandardPaths.h" #include "SavegameData.h" +#include <QFileDialog> #include <QMessageBox> +#include <QFileInfo> #include <QFile> +#include <QUrl> SavegameWidget::SavegameWidget(QWidget *parent) : QWidget(parent), @@ -64,3 +68,71 @@ void SavegameWidget::on_cmdDelete_clicked() } } } + +void SavegameWidget::on_cmdCopy_clicked() +{ + QFileInfo fileInfo(sgdPath); + QFileDialog fileDialog(this); + fileDialog.setFileMode(QFileDialog::AnyFile); + fileDialog.setViewMode(QFileDialog::Detail); + fileDialog.setAcceptMode(QFileDialog::AcceptSave); + fileDialog.setOption(QFileDialog::DontUseNativeDialog, true); + fileDialog.setDefaultSuffix(""); + fileDialog.setWindowFlags(fileDialog.windowFlags()^Qt::WindowContextHelpButtonHint); + fileDialog.setWindowTitle(tr("Copy savegame")); + + QStringList filters; + filters << tr("Savegame files (SGTA*)"); + filters << tr("All files (**)"); + fileDialog.setNameFilters(filters); + + QList<QUrl> sidebarUrls = fileDialog.sidebarUrls(); + QDir dir; + + // Get Documents + Desktop Location + QString documentsLocation = StandardPaths::documentsLocation(); + QString desktopLocation = StandardPaths::desktopLocation(); + + // Add Desktop Location to Sidebar + dir.setPath(desktopLocation); + if (dir.exists()) + { + sidebarUrls.append(QUrl::fromLocalFile(dir.absolutePath())); + } + + // Add Documents + GTA V Location to Sidebar + dir.setPath(documentsLocation); + if (dir.exists()) + { + sidebarUrls.append(QUrl::fromLocalFile(dir.absolutePath())); + if (dir.cd("Rockstar Games/GTA V")) + { + sidebarUrls.append(QUrl::fromLocalFile(dir.absolutePath())); + } + } + + fileDialog.setSidebarUrls(sidebarUrls); + +fileDialogPreSave: + if (fileDialog.exec()) + { + QStringList selectedFiles = fileDialog.selectedFiles(); + if (selectedFiles.length() == 1) + { + QString selectedFile = selectedFiles.at(0); + + bool isCopied = QFile::copy(sgdPath, selectedFile); + + if (!isCopied) + { + QMessageBox::warning(this, tr("Copy savegame"), tr("Failed to copy the savegame")); + goto fileDialogPreSave; + } + } + else + { + QMessageBox::warning(this, tr("Copy savegame"), tr("No valid file is selected")); + goto fileDialogPreSave; + } + } +} diff --git a/SavegameWidget.h b/SavegameWidget.h index d1a537d..2a232e0 100755 --- a/SavegameWidget.h +++ b/SavegameWidget.h @@ -37,6 +37,7 @@ public: private slots: void on_cmdDelete_clicked(); + void on_cmdCopy_clicked(); private: Ui::SavegameWidget *ui; diff --git a/gta5sync_de.qm b/gta5sync_de.qm index 382bf06..e83ad13 100755 Binary files a/gta5sync_de.qm and b/gta5sync_de.qm differ diff --git a/gta5sync_de.ts b/gta5sync_de.ts index 2d02afb..b8012c3 100755 --- a/gta5sync_de.ts +++ b/gta5sync_de.ts @@ -8,7 +8,7 @@ <source>About gta5sync</source> <translation>Über gta5sync</translation> </message> - <message utf8="true"> + <message> <location filename="AboutDialog.ui" line="59"/> <source><span style=" font-weight:600;">gta5sync</span><br/><br/>A project for viewing and sync Grand Theft Auto 5 Snapmatic Pictures and Savegames<br/><br/>Project version: %1<br/>Compiled with Qt %2<br/>Running with Qt %3<br/><br/>Copyright © <a href="https://github.com/Syping/">Syping</a> 2016<br/>gta5sync is licensed under <a href="https://www.gnu.org/licenses/gpl-3.0.html#content">GNU GPLv3</a></source> <translation type="unfinished"></translation> @@ -66,14 +66,23 @@ <translation>Keine Crew</translation> </message> <message> - <location filename="PictureDialog.cpp" line="154"/> + <location filename="PictureDialog.cpp" line="159"/> + <source>JPEG picture (*.jpg)</source> + <translation>JPEG Bild (*.jpg)</translation> + </message> + <message> + <location filename="PictureDialog.cpp" line="160"/> + <source>Portable Network Graphics (*.png)</source> + <translation>Portable Network Graphics (*.png)</translation> + </message> + <message> <source>JPEG picture (*.jpg);;Portable Network Graphics (*.png)</source> <translation>JPEG Bild (*.jpg);;Portable Network Graphics (*.png)</translation> </message> <message> <location filename="PictureDialog.cpp" line="155"/> - <location filename="PictureDialog.cpp" line="226"/> - <location filename="PictureDialog.cpp" line="232"/> + <location filename="PictureDialog.cpp" line="231"/> + <location filename="PictureDialog.cpp" line="237"/> <source>Export picture</source> <translation>Bild exportieren</translation> </message> @@ -82,12 +91,12 @@ <translation type="obsolete">Snapmatic Bild Exporter</translation> </message> <message> - <location filename="PictureDialog.cpp" line="226"/> + <location filename="PictureDialog.cpp" line="231"/> <source>Failed to save the picture</source> - <translation>Fehlgeschlagen beim Speichern des Bildes</translation> + <translation>Beim Speichern des Bildes ist ein Fehler aufgetreten</translation> </message> <message> - <location filename="PictureDialog.cpp" line="232"/> + <location filename="PictureDialog.cpp" line="237"/> <source>No valid file is selected</source> <translation>Keine gültige Datei wurde ausgewählt</translation> </message> @@ -171,21 +180,48 @@ <translation>Löschen</translation> </message> <message> - <location filename="SavegameWidget.cpp" line="50"/> - <location filename="SavegameWidget.cpp" line="63"/> + <location filename="SavegameWidget.cpp" line="54"/> + <location filename="SavegameWidget.cpp" line="67"/> <source>Delete savegame</source> <translation>Savegame löschen</translation> </message> <message> - <location filename="SavegameWidget.cpp" line="50"/> + <location filename="SavegameWidget.cpp" line="54"/> <source>Are you sure to delete %1 from your savegames?</source> <translation>Bist du sicher %1 von deinen Spielständen zu löschen?</translation> </message> <message> - <location filename="SavegameWidget.cpp" line="63"/> + <location filename="SavegameWidget.cpp" line="67"/> <source>Failed at deleting %1 from your savegames</source> <translation>Fehlgeschlagen beim Löschen %1 von deinen Spielständen</translation> </message> + <message> + <location filename="SavegameWidget.cpp" line="82"/> + <location filename="SavegameWidget.cpp" line="128"/> + <location filename="SavegameWidget.cpp" line="134"/> + <source>Copy savegame</source> + <translation>Spielstand kopieren</translation> + </message> + <message> + <location filename="SavegameWidget.cpp" line="85"/> + <source>Savegame files (SGTA*)</source> + <translation>Spielstanddateien (SGTA*)</translation> + </message> + <message> + <location filename="SavegameWidget.cpp" line="86"/> + <source>All files (**)</source> + <translation>Alle Dateien (**)</translation> + </message> + <message> + <location filename="SavegameWidget.cpp" line="128"/> + <source>Failed to copy the savegame</source> + <translation>Beim Kopieren vom Spielstand ist ein Fehler aufgetreten</translation> + </message> + <message> + <location filename="SavegameWidget.cpp" line="134"/> + <source>No valid file is selected</source> + <translation>Keine gültige Datei wurde ausgewählt</translation> + </message> <message> <source>Are you sure to delete %1 from your Savegames?</source> <translation type="obsolete">Bist du sicher %1 von deinen Spielständen zu löschen?</translation>