export all selected content added
This commit is contained in:
parent
3d664ca4ef
commit
68868b1f6c
18 changed files with 167 additions and 39 deletions
|
@ -28,7 +28,7 @@ PictureCopy::PictureCopy()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PictureCopy::CopyPicture(QWidget *parent, QString picPath)
|
void PictureCopy::copyPicture(QWidget *parent, QString picPath)
|
||||||
{
|
{
|
||||||
QSettings settings("Syping", "gta5sync");
|
QSettings settings("Syping", "gta5sync");
|
||||||
settings.beginGroup("FileDialogs");
|
settings.beginGroup("FileDialogs");
|
||||||
|
|
|
@ -26,7 +26,7 @@ class PictureCopy
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PictureCopy();
|
PictureCopy();
|
||||||
static void CopyPicture(QWidget *parent, QString picPath);
|
static void copyPicture(QWidget *parent, QString picPath);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PICTURECOPY_H
|
#endif // PICTURECOPY_H
|
||||||
|
|
|
@ -163,12 +163,12 @@ void PictureDialog::on_cmdClose_clicked()
|
||||||
|
|
||||||
void PictureDialog::on_cmdExport_clicked()
|
void PictureDialog::on_cmdExport_clicked()
|
||||||
{
|
{
|
||||||
PictureExport::ExportPicture(this, smpic);
|
PictureExport::exportPicture(this, smpic);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PictureDialog::on_cmdCopy_clicked()
|
void PictureDialog::on_cmdCopy_clicked()
|
||||||
{
|
{
|
||||||
PictureCopy::CopyPicture(this, picPath);
|
PictureCopy::copyPicture(this, picPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PictureDialog::on_labPicture_mouseDoubleClicked()
|
void PictureDialog::on_labPicture_mouseDoubleClicked()
|
||||||
|
|
|
@ -28,7 +28,7 @@ PictureExport::PictureExport()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PictureExport::ExportPicture(QWidget *parent, SnapmaticPicture *picture)
|
void PictureExport::exportPicture(QWidget *parent, SnapmaticPicture *picture)
|
||||||
{
|
{
|
||||||
QSettings settings("Syping", "gta5sync");
|
QSettings settings("Syping", "gta5sync");
|
||||||
settings.beginGroup("FileDialogs");
|
settings.beginGroup("FileDialogs");
|
||||||
|
@ -56,33 +56,7 @@ fileDialogPreSave:
|
||||||
|
|
||||||
if (picture != 0)
|
if (picture != 0)
|
||||||
{
|
{
|
||||||
QString newPictureFileName;
|
QString newPictureFileName = getPictureFileName(picture);
|
||||||
QString pictureStr = picture->getPictureStr();
|
|
||||||
QStringList pictureStrList = pictureStr.split(" - ");
|
|
||||||
if (pictureStrList.length() <= 2)
|
|
||||||
{
|
|
||||||
QString dtStr = pictureStrList.at(1);
|
|
||||||
QStringList dtStrList = dtStr.split(" ");
|
|
||||||
if (dtStrList.length() <= 2)
|
|
||||||
{
|
|
||||||
QString dayStr;
|
|
||||||
QString yearStr;
|
|
||||||
QString monthStr;
|
|
||||||
QString dateStr = dtStrList.at(0);
|
|
||||||
QString timeStr = dtStrList.at(1);
|
|
||||||
timeStr.replace(":","");
|
|
||||||
QStringList dateStrList = dateStr.split("/");
|
|
||||||
if (dateStrList.length() <= 3)
|
|
||||||
{
|
|
||||||
dayStr = dateStrList.at(1);
|
|
||||||
yearStr = dateStrList.at(2);
|
|
||||||
monthStr = dateStrList.at(0);
|
|
||||||
}
|
|
||||||
QString cmpPicTitl = picture->getPictureTitl();
|
|
||||||
cmpPicTitl.replace(" ", "_");
|
|
||||||
newPictureFileName = yearStr + monthStr + dayStr + timeStr + "_" + cmpPicTitl + ".jpg";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fileDialog.selectFile(newPictureFileName);
|
fileDialog.selectFile(newPictureFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,3 +130,35 @@ fileDialogPreSave:
|
||||||
settings.setValue("ExportPicture", fileDialog.saveState());
|
settings.setValue("ExportPicture", fileDialog.saveState());
|
||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString PictureExport::getPictureFileName(SnapmaticPicture *picture)
|
||||||
|
{
|
||||||
|
QString newPictureFileName;
|
||||||
|
QString pictureStr = picture->getPictureStr();
|
||||||
|
QStringList pictureStrList = pictureStr.split(" - ");
|
||||||
|
if (pictureStrList.length() <= 2)
|
||||||
|
{
|
||||||
|
QString dtStr = pictureStrList.at(1);
|
||||||
|
QStringList dtStrList = dtStr.split(" ");
|
||||||
|
if (dtStrList.length() <= 2)
|
||||||
|
{
|
||||||
|
QString dayStr;
|
||||||
|
QString yearStr;
|
||||||
|
QString monthStr;
|
||||||
|
QString dateStr = dtStrList.at(0);
|
||||||
|
QString timeStr = dtStrList.at(1);
|
||||||
|
timeStr.replace(":","");
|
||||||
|
QStringList dateStrList = dateStr.split("/");
|
||||||
|
if (dateStrList.length() <= 3)
|
||||||
|
{
|
||||||
|
dayStr = dateStrList.at(1);
|
||||||
|
yearStr = dateStrList.at(2);
|
||||||
|
monthStr = dateStrList.at(0);
|
||||||
|
}
|
||||||
|
QString cmpPicTitl = picture->getPictureTitl();
|
||||||
|
cmpPicTitl.replace(" ", "_");
|
||||||
|
newPictureFileName = yearStr + monthStr + dayStr + timeStr + "_" + cmpPicTitl + ".jpg";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return newPictureFileName;
|
||||||
|
}
|
||||||
|
|
|
@ -27,7 +27,8 @@ class PictureExport
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PictureExport();
|
PictureExport();
|
||||||
static void ExportPicture(QWidget *parent, SnapmaticPicture *picture);
|
static void exportPicture(QWidget *parent, SnapmaticPicture *picture);
|
||||||
|
static QString getPictureFileName(SnapmaticPicture *picture);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PICTUREEXPORT_H
|
#endif // PICTUREEXPORT_H
|
||||||
|
|
|
@ -22,8 +22,10 @@
|
||||||
#include "SnapmaticWidget.h"
|
#include "SnapmaticWidget.h"
|
||||||
#include "DatabaseThread.h"
|
#include "DatabaseThread.h"
|
||||||
#include "SavegameWidget.h"
|
#include "SavegameWidget.h"
|
||||||
|
#include "PictureExport.h"
|
||||||
#include "StandardPaths.h"
|
#include "StandardPaths.h"
|
||||||
#include "ProfileLoader.h"
|
#include "ProfileLoader.h"
|
||||||
|
#include <QInputDialog>
|
||||||
#include <QSpacerItem>
|
#include <QSpacerItem>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
|
@ -384,3 +386,96 @@ void ProfileInterface::deselectAllWidgets()
|
||||||
widget->setSelected(false);
|
widget->setSelected(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ProfileInterface::exportSelected()
|
||||||
|
{
|
||||||
|
bool modeSet = false;
|
||||||
|
bool pictureCopyEnabled = false;
|
||||||
|
bool pictureExportEnabled = false;
|
||||||
|
|
||||||
|
QStringList failedSavegames;
|
||||||
|
QStringList failedCopyPictures;
|
||||||
|
QStringList failedExportPictures;
|
||||||
|
QString exportDirectory = QFileDialog::getExistingDirectory(this, tr("Export selected"), profileFolder);
|
||||||
|
if (exportDirectory != "")
|
||||||
|
{
|
||||||
|
foreach(ProfileWidget *widget, widgets.keys())
|
||||||
|
{
|
||||||
|
if (widgets[widget] == "SnapmaticWidget")
|
||||||
|
{
|
||||||
|
SnapmaticWidget *picWidget = (SnapmaticWidget*)widget;
|
||||||
|
SnapmaticPicture *picture = picWidget->getPicture();
|
||||||
|
if (!modeSet)
|
||||||
|
{
|
||||||
|
QInputDialog inputDialog;
|
||||||
|
QStringList inputDialogItems;
|
||||||
|
inputDialogItems << tr("Export and Copy pictures");
|
||||||
|
inputDialogItems << tr("Export pictures");
|
||||||
|
inputDialogItems << tr("Copy pictures");
|
||||||
|
|
||||||
|
bool itemSelected = false;
|
||||||
|
QString selectedItem = inputDialog.getItem(this, tr("Export selected"), tr("How should we deal with the Snapmatic pictures?"), inputDialogItems, 0, false, &itemSelected, inputDialog.windowFlags()^Qt::WindowContextHelpButtonHint);
|
||||||
|
if (itemSelected)
|
||||||
|
{
|
||||||
|
if (selectedItem == tr("Export and Copy pictures"))
|
||||||
|
{
|
||||||
|
pictureExportEnabled = true;
|
||||||
|
pictureCopyEnabled = true;
|
||||||
|
}
|
||||||
|
else if (selectedItem == tr("Export pictures"))
|
||||||
|
{
|
||||||
|
pictureExportEnabled = true;
|
||||||
|
}
|
||||||
|
else if (selectedItem == tr("Copy pictures"))
|
||||||
|
{
|
||||||
|
pictureCopyEnabled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pictureExportEnabled = true;
|
||||||
|
pictureCopyEnabled = true;
|
||||||
|
}
|
||||||
|
modeSet = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pictureExportEnabled)
|
||||||
|
{
|
||||||
|
QString exportFileName = PictureExport::getPictureFileName(picture);
|
||||||
|
if (!picture->getPicture().save(exportDirectory + "/" + exportFileName, "JPEG", 100))
|
||||||
|
{
|
||||||
|
failedExportPictures.append(exportFileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (pictureCopyEnabled)
|
||||||
|
{
|
||||||
|
QString originalFileName = picture->getPictureFileName();
|
||||||
|
QFileInfo originalFileInfo(originalFileName);
|
||||||
|
QString exportFileName = originalFileInfo.fileName();
|
||||||
|
if (QFile::copy(originalFileName, exportDirectory + "/" + exportFileName))
|
||||||
|
{
|
||||||
|
failedCopyPictures.append(exportFileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (widgets[widget] == "SavegameWidget")
|
||||||
|
{
|
||||||
|
SavegameWidget *sgdWidget = (SavegameWidget*)widget;
|
||||||
|
SavegameData *savegame = sgdWidget->getSavegame();
|
||||||
|
|
||||||
|
QString originalFileName = savegame->getSavegameFileName();
|
||||||
|
QFileInfo originalFileInfo(originalFileName);
|
||||||
|
QString exportFileName = originalFileInfo.fileName();
|
||||||
|
if (QFile::copy(originalFileName, exportDirectory + "/" + exportFileName))
|
||||||
|
{
|
||||||
|
failedSavegames.append(exportFileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProfileInterface::deleteSelected()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -48,6 +48,8 @@ public:
|
||||||
public slots:
|
public slots:
|
||||||
void selectAllWidgets();
|
void selectAllWidgets();
|
||||||
void deselectAllWidgets();
|
void deselectAllWidgets();
|
||||||
|
void exportSelected();
|
||||||
|
void deleteSelected();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_cmdCloseProfile_clicked();
|
void on_cmdCloseProfile_clicked();
|
||||||
|
|
|
@ -28,7 +28,7 @@ SavegameCopy::SavegameCopy()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SavegameCopy::CopySavegame(QWidget *parent, QString sgdPath)
|
void SavegameCopy::copySavegame(QWidget *parent, QString sgdPath)
|
||||||
{
|
{
|
||||||
QSettings settings("Syping", "gta5sync");
|
QSettings settings("Syping", "gta5sync");
|
||||||
settings.beginGroup("FileDialogs");
|
settings.beginGroup("FileDialogs");
|
||||||
|
|
|
@ -26,7 +26,7 @@ class SavegameCopy
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SavegameCopy();
|
SavegameCopy();
|
||||||
static void CopySavegame(QWidget *parent, QString sgdPath);
|
static void copySavegame(QWidget *parent, QString sgdPath);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SAVEGAMECOPY_H
|
#endif // SAVEGAMECOPY_H
|
||||||
|
|
|
@ -108,6 +108,11 @@ bool SavegameData::isSavegameOk()
|
||||||
return savegameOk;
|
return savegameOk;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString SavegameData::getSavegameFileName()
|
||||||
|
{
|
||||||
|
return savegameFileName;
|
||||||
|
}
|
||||||
|
|
||||||
QString SavegameData::getSavegameStr()
|
QString SavegameData::getSavegameStr()
|
||||||
{
|
{
|
||||||
return savegameStr;
|
return savegameStr;
|
||||||
|
|
|
@ -31,6 +31,7 @@ public:
|
||||||
bool isSavegameOk();
|
bool isSavegameOk();
|
||||||
QString getLastStep();
|
QString getLastStep();
|
||||||
QString getSavegameStr();
|
QString getSavegameStr();
|
||||||
|
QString getSavegameFileName();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString getSavegameDataString(QByteArray savegameHeader);
|
QString getSavegameDataString(QByteArray savegameHeader);
|
||||||
|
|
|
@ -35,5 +35,5 @@ void SavegameDialog::on_cmdClose_clicked()
|
||||||
|
|
||||||
void SavegameDialog::on_cmdCopy_clicked()
|
void SavegameDialog::on_cmdCopy_clicked()
|
||||||
{
|
{
|
||||||
SavegameCopy::CopySavegame(this, sgdPath);
|
SavegameCopy::copySavegame(this, sgdPath);
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,7 @@ void SavegameWidget::setSavegameData(SavegameData *savegame, QString savegamePat
|
||||||
|
|
||||||
void SavegameWidget::on_cmdCopy_clicked()
|
void SavegameWidget::on_cmdCopy_clicked()
|
||||||
{
|
{
|
||||||
SavegameCopy::CopySavegame(this, sgdPath);
|
SavegameCopy::copySavegame(this, sgdPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SavegameWidget::on_cmdDelete_clicked()
|
void SavegameWidget::on_cmdDelete_clicked()
|
||||||
|
|
|
@ -221,6 +221,11 @@ void SnapmaticPicture::setPicture(QImage picture)
|
||||||
cachePicture = picture;
|
cachePicture = picture;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString SnapmaticPicture::getPictureFileName()
|
||||||
|
{
|
||||||
|
return picFileName;
|
||||||
|
}
|
||||||
|
|
||||||
QString SnapmaticPicture::getPictureDesc()
|
QString SnapmaticPicture::getPictureDesc()
|
||||||
{
|
{
|
||||||
return descStr;
|
return descStr;
|
||||||
|
|
|
@ -39,6 +39,7 @@ public:
|
||||||
QString getPictureStr();
|
QString getPictureStr();
|
||||||
QString getPictureTitl();
|
QString getPictureTitl();
|
||||||
QString getPictureDesc();
|
QString getPictureDesc();
|
||||||
|
QString getPictureFileName();
|
||||||
|
|
||||||
// JSON
|
// JSON
|
||||||
bool isJsonOk();
|
bool isJsonOk();
|
||||||
|
|
|
@ -88,12 +88,12 @@ void SnapmaticWidget::on_cmdView_clicked()
|
||||||
|
|
||||||
void SnapmaticWidget::on_cmdCopy_clicked()
|
void SnapmaticWidget::on_cmdCopy_clicked()
|
||||||
{
|
{
|
||||||
PictureCopy::CopyPicture(this, picPath);
|
PictureCopy::copyPicture(this, picPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SnapmaticWidget::on_cmdExport_clicked()
|
void SnapmaticWidget::on_cmdExport_clicked()
|
||||||
{
|
{
|
||||||
PictureExport::ExportPicture(this, smpic);
|
PictureExport::exportPicture(this, smpic);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SnapmaticWidget::on_cmdDelete_clicked()
|
void SnapmaticWidget::on_cmdDelete_clicked()
|
||||||
|
|
|
@ -227,3 +227,13 @@ void UserInterface::on_actionDeselect_all_triggered()
|
||||||
{
|
{
|
||||||
profileUI->deselectAllWidgets();
|
profileUI->deselectAllWidgets();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UserInterface::on_actionExport_selected_triggered()
|
||||||
|
{
|
||||||
|
profileUI->exportSelected();
|
||||||
|
}
|
||||||
|
|
||||||
|
void UserInterface::on_actionDelete_selected_triggered()
|
||||||
|
{
|
||||||
|
profileUI->deleteSelected();
|
||||||
|
}
|
||||||
|
|
|
@ -48,6 +48,8 @@ private slots:
|
||||||
void on_actionAbout_gta5sync_triggered();
|
void on_actionAbout_gta5sync_triggered();
|
||||||
void on_actionSelect_all_triggered();
|
void on_actionSelect_all_triggered();
|
||||||
void on_actionDeselect_all_triggered();
|
void on_actionDeselect_all_triggered();
|
||||||
|
void on_actionExport_selected_triggered();
|
||||||
|
void on_actionDelete_selected_triggered();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ProfileDatabase *profileDB;
|
ProfileDatabase *profileDB;
|
||||||
|
|
Loading…
Reference in a new issue