diff --git a/PictureDialog.cpp b/PictureDialog.cpp index ef2ca3f..18fdf29 100755 --- a/PictureDialog.cpp +++ b/PictureDialog.cpp @@ -43,6 +43,7 @@ PictureDialog::PictureDialog(ProfileDatabase *profileDB, QWidget *parent) : ui->cmdExport->setEnabled(0); plyrsList = QStringList(); picTitl = ""; + picPath = ""; crewID = ""; locX = ""; locY = ""; @@ -55,9 +56,10 @@ PictureDialog::~PictureDialog() delete ui; } -void PictureDialog::setSnapmaticPicture(SnapmaticPicture *picture, bool readOk) +void PictureDialog::setSnapmaticPicture(SnapmaticPicture *picture, QString picturePath, bool readOk) { // Showing error if reading error + picPath = picturePath; smpic = picture; if (!readOk) { @@ -262,7 +264,7 @@ fileDialogPreSave: if (!isSaved) { - QMessageBox::warning(this, tr("Export picture"), tr("Failed to save current picture")); + QMessageBox::warning(this, tr("Export picture"), tr("Failed to export current Snapmatic picture")); goto fileDialogPreSave; } } @@ -276,3 +278,72 @@ fileDialogPreSave: settings.setValue("ExportPicture", fileDialog.saveState()); settings.endGroup(); } + +void PictureDialog::on_cmdCopy_clicked() +{ + QSettings settings("Syping", "gta5sync"); + settings.beginGroup("FileDialogs"); + +fileDialogPreSave: + QFileInfo sgdFileInfo(picPath); + QFileDialog fileDialog(this); + fileDialog.setFileMode(QFileDialog::AnyFile); + fileDialog.setViewMode(QFileDialog::Detail); + fileDialog.setAcceptMode(QFileDialog::AcceptSave); + fileDialog.setOption(QFileDialog::DontUseNativeDialog, true); + fileDialog.setOption(QFileDialog::DontConfirmOverwrite, true); + fileDialog.setDefaultSuffix(""); + fileDialog.setWindowFlags(fileDialog.windowFlags()^Qt::WindowContextHelpButtonHint); + fileDialog.setWindowTitle(tr("Copy picture")); + + QStringList filters; + filters << tr("Snapmatic pictures (PGTA*)"); + filters << tr("All files (**)"); + fileDialog.setNameFilters(filters); + + QList sidebarUrls = SidebarGenerator::generateSidebarUrls(fileDialog.sidebarUrls()); + + fileDialog.setSidebarUrls(sidebarUrls); + fileDialog.restoreState(settings.value("CopyPicture","").toByteArray()); + fileDialog.selectFile(sgdFileInfo.fileName()); + + if (fileDialog.exec()) + { + QStringList selectedFiles = fileDialog.selectedFiles(); + if (selectedFiles.length() == 1) + { + QString selectedFile = selectedFiles.at(0); + + if (QFile::exists(selectedFile)) + { + if (QMessageBox::Yes == QMessageBox::warning(this, tr("Copy picture"), tr("Overwrite %1 with current Snapmatic picture?").arg("\""+selectedFile+"\""), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes)) + { + if (!QFile::remove(selectedFile)) + { + QMessageBox::warning(this, tr("Copy picture"), tr("Failed to overwrite %1 with current Snapmatic picture").arg("\""+selectedFile+"\"")); + goto fileDialogPreSave; + } + } + else + { + goto fileDialogPreSave; + } + } + + bool isCopied = QFile::copy(picPath, selectedFile); + if (!isCopied) + { + QMessageBox::warning(this, tr("Copy picture"), tr("Failed to copy current Snapmatic picture")); + goto fileDialogPreSave; + } + } + else + { + QMessageBox::warning(this, tr("Copy picture"), tr("No valid file is selected")); + goto fileDialogPreSave; + } + } + + settings.setValue("CopyPicture", fileDialog.saveState()); + settings.endGroup(); +} diff --git a/PictureDialog.h b/PictureDialog.h index c280e71..4175080 100755 --- a/PictureDialog.h +++ b/PictureDialog.h @@ -32,7 +32,7 @@ class PictureDialog : public QDialog Q_OBJECT public: explicit PictureDialog(ProfileDatabase *profileDB, QWidget *parent = 0); - void setSnapmaticPicture(SnapmaticPicture *picture, bool readOk); + void setSnapmaticPicture(SnapmaticPicture *picture, QString picPath, bool readOk); ~PictureDialog(); public slots: @@ -41,6 +41,7 @@ public slots: private slots: void on_cmdClose_clicked(); void on_cmdExport_clicked(); + void on_cmdCopy_clicked(); private: ProfileDatabase *profileDB; @@ -50,6 +51,7 @@ private: QString windowTitleStr; QStringList plyrsList; QString picTitl; + QString picPath; QString crewID; QString locX; QString locY; diff --git a/PictureDialog.ui b/PictureDialog.ui index f885561..510b176 100755 --- a/PictureDialog.ui +++ b/PictureDialog.ui @@ -89,6 +89,13 @@ + + + + Copy + + + diff --git a/SavegameWidget.ui b/SavegameWidget.ui index 97f845c..0cbbd6c 100755 --- a/SavegameWidget.ui +++ b/SavegameWidget.ui @@ -20,7 +20,7 @@ - :/img/savegame.png + :/img/savegame.png @@ -63,7 +63,7 @@ - + diff --git a/SnapmaticWidget.cpp b/SnapmaticWidget.cpp index 9c8d65b..ee927ff 100755 --- a/SnapmaticWidget.cpp +++ b/SnapmaticWidget.cpp @@ -57,7 +57,7 @@ void SnapmaticWidget::on_cmdView_clicked() { PictureDialog *picDialog = new PictureDialog(profileDB, this); picDialog->setWindowFlags(picDialog->windowFlags()^Qt::WindowContextHelpButtonHint); - picDialog->setSnapmaticPicture(smpic, true); + picDialog->setSnapmaticPicture(smpic, picPath, true); picDialog->setModal(true); // be ready for playerName updated diff --git a/SnapmaticWidget.ui b/SnapmaticWidget.ui index 6a9cdec..572bc36 100755 --- a/SnapmaticWidget.ui +++ b/SnapmaticWidget.ui @@ -65,13 +65,6 @@ - - - - Copy - - - diff --git a/gta5sync.pro b/gta5sync.pro index 08ee038..f380140 100755 --- a/gta5sync.pro +++ b/gta5sync.pro @@ -71,7 +71,8 @@ FORMS += \ UserInterface.ui TRANSLATIONS += \ - res/gta5sync_de.ts + res/gta5sync_de.ts \ + res/gta5sync_ru.ts RESOURCES += \ res/app.qrc diff --git a/main.cpp b/main.cpp index 9089f9c..2ea06a9 100755 --- a/main.cpp +++ b/main.cpp @@ -245,7 +245,7 @@ int main(int argc, char *argv[]) bool readOk = picture.readingPictureFromFile(arg1); picDialog->setWindowFlags(picDialog->windowFlags()^Qt::WindowContextHelpButtonHint); picDialog->setWindowIcon(IconLoader::loadingAppIcon()); - picDialog->setSnapmaticPicture(&picture, readOk); + picDialog->setSnapmaticPicture(&picture, arg1, readOk); int crewID = picture.getCrewNumber(); if (crewID != 0) { crewDB->addCrew(crewID); } diff --git a/res/gta5sync_de.qm b/res/gta5sync_de.qm index ee250ff..db2baff 100755 Binary files a/res/gta5sync_de.qm and b/res/gta5sync_de.qm differ diff --git a/res/gta5sync_de.ts b/res/gta5sync_de.ts index 9354c95..9f56ab5 100755 --- a/res/gta5sync_de.ts +++ b/res/gta5sync_de.ts @@ -11,7 +11,7 @@ <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> - + <span style=" font-weight:600;">gta5sync</span><br/><br/>Ein Projekt zum ansehen und synchronisieren von Grand Theft Auto 5 Snapmatic Bilder und Spielständen<br/><br/>Projektversion: %1<br/>Gebaut mit Qt %2<br/>Läuft auf Qt %3<br/><br/>Copyright © <a href="https://github.com/Syping/">Syping</a> 2016<br/>gta5sync is lizenziert unter <a href="https://www.gnu.org/licenses/gpl-3.0.html#content">GNU GPLv3</a> @@ -58,58 +58,93 @@ - + Copy + Kopieren + + + + Close Schließen - - + + Snapmatic Picture Viewer Snapmatic Bildansicht - - + + Failed at %1 Fehlgeschlagen bei %1 - - + + No player Keine Spieler - - + + No crew Keine Crew - + JPEG picture (*.jpg) JPEG Bild (*.jpg) - + Portable Network Graphics (*.png) Portable Network Graphics (*.png) - + + Overwrite %1 with current Snapmatic picture? Überschreibe %1 mit aktuellen Snapmatic Bild? - + + Failed to overwrite %1 with current Snapmatic picture Fehlgeschlagen beim Überschreiben von %1 mit aktuellen Snapmatic Bild - + + Failed to export current Snapmatic picture + Fehlgeschlagen beim Exportieren vom aktuellen Snapmatic Bild + + + + + + + + Copy picture + Bild kopieren + + + + Snapmatic pictures (PGTA*) + Snapmatic Bilder (PGTA*) + + + + All files (**) + Alle Dateien (**) + + + + Failed to copy current Snapmatic picture + Fehlgeschlagen beim Kopieren vom Snapmatic Bild + + Failed to save current picture - Fehlgeschlagen beim Speichern vom aktuellen Bild + Fehlgeschlagen beim Speichern vom aktuellen Bild JPEG picture (*.jpg);;Portable Network Graphics (*.png) @@ -117,11 +152,11 @@ - + + + - - - + Export picture Bild exportieren @@ -134,7 +169,8 @@ Beim Speichern des Bildes ist ein Fehler aufgetreten - + + No valid file is selected Keine gültige Datei wurde ausgewählt @@ -154,16 +190,16 @@ - - - - - - - - - - + + + + + + + + + + Import copy Kopie importieren @@ -181,68 +217,68 @@ Profil schließen - + Loading... Lade... - + All profile files (SGTA* PGTA*) Alle Profildateien (SGTA* PGTA*) - + Savegames files (SGTA*) Spielstanddateien (SGTA*) - + Snapmatic pictures (PGTA*) Snapmatic Bilder (PGTA*) - + All files (**) Alle Dateien (**) - + Failed to read Snapmatic picture Fehler beim Lesen vom Snapmatic Bild - + Failed to read Savegame file Fehler beim Lesen von Spielstanddatei - + Can't import %1 because of not valid file format Kann %1 nicht importieren weil das Dateiformat nicht gültig ist - - + + No valid file is selected Keine gültige Datei wurde ausgewählt - + Failed to import copy of Snapmatic picture because the file not begin with PGTA Fehlgeschlagenen beim Import vom Snapmatic Bild weil die Datei nicht mit PGTA begint - + Failed to import copy of Snapmatic picture because the copy failed Fehlgeschlagenen beim Import vom Snapmatic Bild weil kopieren fehlgeschlagen ist - + Failed to import copy of Savegame file because the copy failed Fehlgeschlagenen beim Import vom Spielstand weil kopieren fehlgeschlagen ist - + Failed to import copy of Savegame file because no free Savegame slot left Fehlgeschlagenen beim Import vom Spielstand weil kein Spielstandslot mehr übrig ist @@ -294,52 +330,52 @@ Löschen - - + + Delete savegame Savegame löschen - + Are you sure to delete %1 from your savegames? Bist du sicher %1 von deinen Spielständen zu löschen? - + Failed at deleting %1 from your savegames Fehlgeschlagen beim Löschen %1 von deinen Spielständen - - - - - + + + + + Copy savegame Spielstand kopieren - + Savegame files (SGTA*) Spielstanddateien (SGTA*) - + All files (**) Alle Dateien (**) - + Overwrite %1 with current savegame? Überschreibe %1 mit aktuellen Spielstand? - + Failed to overwrite %1 with current savegame Fehlgeschlagen beim Überschreiben von %1 mit aktuellen Spielstand - + Failed to copy current savegame Fehlgeschlagen beim Kopieren vom Spielstand @@ -348,7 +384,7 @@ Beim Kopieren vom Spielstand ist ein Fehler aufgetreten - + No valid file is selected Keine gültige Datei wurde ausgewählt