diff --git a/PictureDialog.cpp b/PictureDialog.cpp index 4b78ef4..91faddf 100755 --- a/PictureDialog.cpp +++ b/PictureDialog.cpp @@ -19,6 +19,7 @@ #include "PictureDialog.h" #include "ProfileDatabase.h" #include "ui_PictureDialog.h" +#include "SidebarGenerator.h" #include "StandardPaths.h" #include @@ -168,30 +169,7 @@ fileDialogPreSave: filters << tr("Portable Network Graphics (*.png)"); fileDialog.setNameFilters(filters); - QList 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())); - } - } + QList sidebarUrls = SidebarGenerator::generateSidebarUrls(fileDialog.sidebarUrls()); fileDialog.setSidebarUrls(sidebarUrls); fileDialog.restoreState(settings.value("ExportPicture","").toByteArray()); @@ -220,7 +198,9 @@ fileDialogPreSave: yearStr = dateStrList.at(2); monthStr = dateStrList.at(0); } - newPictureFileName = yearStr + "-" + monthStr + "-" + dayStr + "_" + timeStr + ".jpg"; + QString cmpPicTitl = picTitl; + cmpPicTitl.replace(" ", ""); + newPictureFileName = yearStr + "-" + monthStr + "-" + dayStr + "_" + timeStr + "_" + cmpPicTitl + ".jpg"; } } fileDialog.selectFile(newPictureFileName); diff --git a/ProfileInterface.cpp b/ProfileInterface.cpp index 48eca49..1bc881d 100755 --- a/ProfileInterface.cpp +++ b/ProfileInterface.cpp @@ -18,6 +18,7 @@ #include "ProfileInterface.h" #include "ui_ProfileInterface.h" +#include "SidebarGenerator.h" #include "SnapmaticWidget.h" #include "DatabaseThread.h" #include "SavegameWidget.h" @@ -171,30 +172,7 @@ fileDialogPreOpen: filters << tr("All files (**)"); fileDialog.setNameFilters(filters); - QList 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())); - } - } + QList sidebarUrls = SidebarGenerator::generateSidebarUrls(fileDialog.sidebarUrls()); fileDialog.setSidebarUrls(sidebarUrls); fileDialog.restoreState(settings.value("ImportCopy","").toByteArray()); diff --git a/SavegameWidget.cpp b/SavegameWidget.cpp index ca1066f..7587cc5 100755 --- a/SavegameWidget.cpp +++ b/SavegameWidget.cpp @@ -18,6 +18,7 @@ #include "SavegameWidget.h" #include "ui_SavegameWidget.h" +#include "SidebarGenerator.h" #include "StandardPaths.h" #include "SavegameData.h" #include @@ -92,30 +93,7 @@ fileDialogPreSave: filters << tr("All files (**)"); fileDialog.setNameFilters(filters); - QList 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())); - } - } + QList sidebarUrls = SidebarGenerator::generateSidebarUrls(fileDialog.sidebarUrls()); fileDialog.setSidebarUrls(sidebarUrls); fileDialog.restoreState(settings.value("CopySavegame","").toByteArray()); diff --git a/SidebarGenerator.cpp b/SidebarGenerator.cpp new file mode 100755 index 0000000..c935ff0 --- /dev/null +++ b/SidebarGenerator.cpp @@ -0,0 +1,57 @@ +/***************************************************************************** +* gta5sync GRAND THEFT AUTO V SYNC +* Copyright (C) 2016 Syping +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*****************************************************************************/ + +#include "SidebarGenerator.h" +#include "StandardPaths.h" +#include +#include +#include + +SidebarGenerator::SidebarGenerator() +{ + +} + +QList SidebarGenerator::generateSidebarUrls(QList sidebarUrls) +{ + QDir dir; + + dir.setPath(StandardPaths::picturesLocation()); + if (dir.exists()) + { + sidebarUrls << QUrl::fromLocalFile(dir.absolutePath()); + } + + dir.setPath(StandardPaths::documentsLocation()); + if (dir.exists()) + { + sidebarUrls.append(QUrl::fromLocalFile(dir.absolutePath())); + if (dir.cd("Rockstar Games/GTA V")) + { + sidebarUrls << QUrl::fromLocalFile(dir.absolutePath()); + } + } + + dir.setPath(StandardPaths::desktopLocation()); + if (dir.exists()) + { + sidebarUrls << QUrl::fromLocalFile(dir.absolutePath()); + } + + return sidebarUrls; +} diff --git a/SidebarGenerator.h b/SidebarGenerator.h new file mode 100755 index 0000000..d01bba0 --- /dev/null +++ b/SidebarGenerator.h @@ -0,0 +1,32 @@ +/***************************************************************************** +* gta5sync GRAND THEFT AUTO V SYNC +* Copyright (C) 2016 Syping +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*****************************************************************************/ + +#ifndef SIDEBARGENERATOR_H +#define SIDEBARGENERATOR_H + +#include +#include + +class SidebarGenerator +{ +public: + SidebarGenerator(); + static QList generateSidebarUrls(QList sidebarUrls); +}; + +#endif // SIDEBARGENERATOR_H diff --git a/StandardPaths.cpp b/StandardPaths.cpp index 4942695..3e9f38a 100755 --- a/StandardPaths.cpp +++ b/StandardPaths.cpp @@ -82,6 +82,15 @@ QString StandardPaths::moviesLocation() #endif } +QString StandardPaths::picturesLocation() +{ +#if QT_VERSION >= 0x050000 + return QStandardPaths::writableLocation(QStandardPaths::PicturesLocation); +#else + return QDesktopServices::storageLocation(QDesktopServices::PicturesLocation); +#endif +} + QString StandardPaths::fontsLocation() { #if QT_VERSION >= 0x050000 diff --git a/StandardPaths.h b/StandardPaths.h index 92033e7..d78f25c 100755 --- a/StandardPaths.h +++ b/StandardPaths.h @@ -33,6 +33,7 @@ public: static QString fontsLocation(); static QString homeLocation(); static QString moviesLocation(); + static QString picturesLocation(); static QString musicLocation(); static QString tempLocation(); }; diff --git a/gta5sync.pro b/gta5sync.pro index 160bd72..1de32c8 100755 --- a/gta5sync.pro +++ b/gta5sync.pro @@ -35,6 +35,7 @@ SOURCES += main.cpp \ SavegameData.cpp \ SavegameDialog.cpp \ SavegameWidget.cpp \ + SidebarGenerator.cpp \ SnapmaticPicture.cpp \ SnapmaticWidget.cpp \ StandardPaths.cpp \ @@ -51,6 +52,7 @@ HEADERS += \ SavegameData.h \ SavegameDialog.h \ SavegameWidget.h \ + SidebarGenerator.h \ SnapmaticPicture.h \ SnapmaticWidget.h \ StandardPaths.h \