diff --git a/CrewDatabase.cpp b/CrewDatabase.cpp
index ab4f2f9..5e3a92c 100755
--- a/CrewDatabase.cpp
+++ b/CrewDatabase.cpp
@@ -16,24 +16,15 @@
* along with this program. If not, see .
*****************************************************************************/
+#include "StandardPaths.h"
#include "CrewDatabase.h"
#include
#include
-#ifdef QT5_MODE
-#include
-#else
-#include
-#endif
-
CrewDatabase::CrewDatabase(QObject *parent) : QObject(parent)
{
QDir dir;
-#ifdef QT5_MODE
- dir.setPath(QStandardPaths::writableLocation(QStandardPaths::DataLocation));
-#else
- dir.setPath(QDesktopServices::storageLocation(QDesktopServices::DataLocation));
-#endif
+ dir.setPath(StandardPaths::writableLocation(StandardPaths::DataLocation));
dir.mkdir("../gta5sync");
QString dirPath = dir.absolutePath();
QString defaultConfPath = dirPath + "/crews.ini";
diff --git a/PictureDialog.cpp b/PictureDialog.cpp
index ba9dc5a..9a52eb9 100755
--- a/PictureDialog.cpp
+++ b/PictureDialog.cpp
@@ -19,6 +19,7 @@
#include "PictureDialog.h"
#include "ProfileDatabase.h"
#include "ui_PictureDialog.h"
+#include "StandardPaths.h"
#include
#include
@@ -31,12 +32,6 @@
#include
#include
-#if QT5_MODE
-#include
-#else
-#include
-#endif
-
PictureDialog::PictureDialog(ProfileDatabase *profileDB, QWidget *parent) :
QDialog(parent), profileDB(profileDB),
ui(new Ui::PictureDialog)
@@ -164,13 +159,8 @@ void PictureDialog::on_cmdExport_clicked()
QDir dir;
// Get Documents + Desktop Location
-#ifdef QT5_MODE
- QString documentsLocation = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
- QString desktopLocation = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
-#else
- QString documentsLocation = QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation);
- QString desktopLocation = QDesktopServices::storageLocation(QDesktopServices::DesktopLocation);
-#endif
+ QString documentsLocation = StandardPaths::writableLocation(StandardPaths::DocumentsLocation);
+ QString desktopLocation = StandardPaths::writableLocation(StandardPaths::DesktopLocation);
// Add Desktop Location to Sidebar
dir.setPath(desktopLocation);
diff --git a/ProfileDatabase.cpp b/ProfileDatabase.cpp
index 17829e2..31bf554 100755
--- a/ProfileDatabase.cpp
+++ b/ProfileDatabase.cpp
@@ -17,23 +17,14 @@
*****************************************************************************/
#include "ProfileDatabase.h"
+#include "StandardPaths.h"
#include
#include
-#ifdef QT5_MODE
-#include
-#else
-#include
-#endif
-
ProfileDatabase::ProfileDatabase(QObject *parent) : QObject(parent)
{
QDir dir;
-#ifdef QT5_MODE
- dir.setPath(QStandardPaths::writableLocation(QStandardPaths::DataLocation));
-#else
- dir.setPath(QDesktopServices::storageLocation(QDesktopServices::DataLocation));
-#endif
+ dir.setPath(StandardPaths::writableLocation(StandardPaths::DataLocation));
dir.mkdir("../gta5sync");
QString dirPath = dir.absolutePath();
QString defaultConfPath = dirPath + "/players.ini";
diff --git a/StandardPaths.cpp b/StandardPaths.cpp
new file mode 100755
index 0000000..7ad6266
--- /dev/null
+++ b/StandardPaths.cpp
@@ -0,0 +1,31 @@
+/*****************************************************************************
+* 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 "StandardPaths.h"
+
+StandardPaths::StandardPaths()
+{
+
+}
+
+#ifndef QT5_MODE
+QString StandardPaths::writableLocation(QDesktopServices::StandardLocation standardLocation)
+{
+ return QDesktopServices::storageLocation(standardLocation);
+}
+#endif
diff --git a/SyncFramework.h b/StandardPaths.h
similarity index 54%
rename from SyncFramework.h
rename to StandardPaths.h
index b654cb8..b185aeb 100755
--- a/SyncFramework.h
+++ b/StandardPaths.h
@@ -16,40 +16,28 @@
* along with this program. If not, see .
*****************************************************************************/
-// DONT USE THE SYNC FRAMEWORK NOW
-
-#ifndef QT5_MODE
-
-#ifndef SYNCFRAMEWORK_H
-#define SYNCFRAMEWORK_H
+#ifndef STANDARDPATHS_H
+#define STANDARDPATHS_H
+#if QT_VERSION >= 0x050000
+#include
#include
-#include
-class SyncFramework : public QObject
+class StandardPaths : public QStandardPaths
{
- Q_OBJECT
public:
- explicit SyncFramework(QObject *parent = 0);
- void setPort(int port);
- void setHost(QString hostname);
- void setUsername(QString username);
- void setPassword(QString password);
- void setSyncFolder(QString folder);
- void testServer();
-
-private:
- int serverPort;
- QString serverHostname;
- QString serverUsername;
- QString serverPassword;
- QString serverSyncFolder;
-
-private slots:
- void fileDownloaded(bool isDone);
- void fileUploaded(bool isDone);
-
+ StandardPaths();
};
+#else
+#include
+#include
+class StandardPaths : public QDesktopServices
+{
+public:
+ StandardPaths();
+ static QString writableLocation(QDesktopServices::StandardLocation standardLocation);
+};
#endif
-#endif // SYNCFRAMEWORK_H
+
+#endif // STANDARDPATHS_H
diff --git a/SyncFramework.cpp b/SyncFramework.cpp
deleted file mode 100755
index 2576f7a..0000000
--- a/SyncFramework.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
-/*****************************************************************************
-* 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 .
-*****************************************************************************/
-
-// DONT USE THE SYNC FRAMEWORK NOW
-
-#ifndef QT5_MODE
-
-#include "SyncFramework.h"
-#include
-#include
-
-SyncFramework::SyncFramework(QObject *parent) : QObject(parent)
-{
- // INIT DEFAULT
- serverPort = 21;
- serverHostname = "";
- serverUsername = "";
- serverPassword = "";
- serverSyncFolder = "gta5sync";
-}
-
-void SyncFramework::testServer()
-{
- QEventLoop ftpLoop;
- QFtp *ftpConnection = new QFtp();
- connect(ftpConnection, SIGNAL(done(bool)), &ftpLoop, SLOT(quit()));
- ftpConnection->connectToHost(serverHostname, serverPort);
- if (serverUsername != "")
- {
- ftpConnection->login(serverHostname, serverPassword);
- }
- else
- {
- ftpConnection->login();
- }
- ftpConnection->close();
- ftpLoop.exec();
-}
-
-void SyncFramework::setPort(int port)
-{
- serverPort = port;
-}
-
-void SyncFramework::setHost(QString hostname)
-{
- serverHostname = hostname;
-}
-
-void SyncFramework::setUsername(QString username)
-{
- serverUsername = username;
-}
-
-void SyncFramework::setPassword(QString password)
-{
- serverPassword = password;
-}
-
-void SyncFramework::setSyncFolder(QString folder)
-{
- serverSyncFolder = folder;
-}
-
-void SyncFramework::fileDownloaded(bool isDone)
-{
- Q_UNUSED(isDone)
-}
-
-void SyncFramework::fileUploaded(bool isDone)
-{
- Q_UNUSED(isDone)
-}
-
-#endif
diff --git a/UserInterface.cpp b/UserInterface.cpp
index e57250c..4ed1b8d 100755
--- a/UserInterface.cpp
+++ b/UserInterface.cpp
@@ -19,6 +19,7 @@
#include "UserInterface.h"
#include "ui_UserInterface.h"
#include "ProfileInterface.h"
+#include "StandardPaths.h"
#include "AboutDialog.h"
#include
#include
@@ -31,12 +32,6 @@
#include
#include
-#ifdef QT5_MODE
-#include
-#else
-#include
-#endif
-
UserInterface::UserInterface(ProfileDatabase *profileDB, CrewDatabase *crewDB, DatabaseThread *threadDB, QWidget *parent) :
QMainWindow(parent), profileDB(profileDB), crewDB(crewDB), threadDB(threadDB),
ui(new Ui::UserInterface)
@@ -52,11 +47,7 @@ UserInterface::UserInterface(ProfileDatabase *profileDB, CrewDatabase *crewDB, D
bool forceDir = SyncSettings.value("force", false).toBool();
// init folder
-#ifdef QT5_MODE
- QString GTAV_defaultFolder = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation) + "/Rockstar Games/GTA V";
-#else
- QString GTAV_defaultFolder = QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation) + "/Rockstar Games/GTA V";
-#endif
+ QString GTAV_defaultFolder = StandardPaths::writableLocation(StandardPaths::DocumentsLocation) + "/Rockstar Games/GTA V";
QDir GTAV_Dir;
if (forceDir)
{
diff --git a/gta5sync.pro b/gta5sync.pro
index 6ff64be..8014ccd 100755
--- a/gta5sync.pro
+++ b/gta5sync.pro
@@ -19,7 +19,6 @@
QT += core gui network
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
-isEqual(QT_MAJOR_VERSION, 5): DEFINES += QT5_MODE
TARGET = gta5sync
TEMPLATE = app
@@ -33,13 +32,13 @@ SOURCES += main.cpp \
CrewDatabase.cpp \
SavegameData.cpp \
SavegameDialog.cpp \
- SyncFramework.cpp \
UserInterface.cpp \
ProfileInterface.cpp \
SnapmaticWidget.cpp \
SavegameWidget.cpp \
ProfileLoader.cpp \
- AboutDialog.cpp
+ AboutDialog.cpp \
+ StandardPaths.cpp
HEADERS += \
SnapmaticPicture.h \
@@ -49,13 +48,13 @@ HEADERS += \
CrewDatabase.h \
SavegameData.h \
SavegameDialog.h \
- SyncFramework.h \
UserInterface.h \
ProfileInterface.h \
SnapmaticWidget.h \
SavegameWidget.h \
ProfileLoader.h \
- AboutDialog.h
+ AboutDialog.h \
+ StandardPaths.h
FORMS += \
PictureDialog.ui \