From 2162bdc12520ad9207a8b090254890b236be8feb Mon Sep 17 00:00:00 2001 From: Rafael Date: Mon, 28 Mar 2016 13:18:39 +0200 Subject: [PATCH] changed StandardPaths class --- CrewDatabase.cpp | 2 +- PictureDialog.cpp | 4 ++-- ProfileDatabase.cpp | 2 +- StandardPaths.cpp | 55 +++++++++++++++++++++++++++++++++++++++++++++ StandardPaths4.cpp | 24 -------------------- StandardPaths4.h | 30 ------------------------- StandardPaths5.cpp | 24 -------------------- StandardPaths5.h | 30 ------------------------- UserInterface.cpp | 2 +- gta5sync.pro | 11 ++++----- 10 files changed, 66 insertions(+), 118 deletions(-) create mode 100755 StandardPaths.cpp delete mode 100755 StandardPaths4.cpp delete mode 100755 StandardPaths4.h delete mode 100755 StandardPaths5.cpp delete mode 100755 StandardPaths5.h diff --git a/CrewDatabase.cpp b/CrewDatabase.cpp index 5e3a92c..b675167 100755 --- a/CrewDatabase.cpp +++ b/CrewDatabase.cpp @@ -24,7 +24,7 @@ CrewDatabase::CrewDatabase(QObject *parent) : QObject(parent) { QDir dir; - dir.setPath(StandardPaths::writableLocation(StandardPaths::DataLocation)); + dir.setPath(StandardPaths::dataLocation()); dir.mkdir("../gta5sync"); QString dirPath = dir.absolutePath(); QString defaultConfPath = dirPath + "/crews.ini"; diff --git a/PictureDialog.cpp b/PictureDialog.cpp index 9a52eb9..b5641b3 100755 --- a/PictureDialog.cpp +++ b/PictureDialog.cpp @@ -159,8 +159,8 @@ void PictureDialog::on_cmdExport_clicked() QDir dir; // Get Documents + Desktop Location - QString documentsLocation = StandardPaths::writableLocation(StandardPaths::DocumentsLocation); - QString desktopLocation = StandardPaths::writableLocation(StandardPaths::DesktopLocation); + QString documentsLocation = StandardPaths::documentsLocation(); + QString desktopLocation = StandardPaths::desktopLocation(); // Add Desktop Location to Sidebar dir.setPath(desktopLocation); diff --git a/ProfileDatabase.cpp b/ProfileDatabase.cpp index 31bf554..3da6376 100755 --- a/ProfileDatabase.cpp +++ b/ProfileDatabase.cpp @@ -24,7 +24,7 @@ ProfileDatabase::ProfileDatabase(QObject *parent) : QObject(parent) { QDir dir; - dir.setPath(StandardPaths::writableLocation(StandardPaths::DataLocation)); + dir.setPath(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..3c03b6a --- /dev/null +++ b/StandardPaths.cpp @@ -0,0 +1,55 @@ +/***************************************************************************** +* 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" +#if QT_VERSION >= 0x050000 +#include +#else +#include +#endif + +StandardPaths::StandardPaths() +{ +} + +QString StandardPaths::dataLocation() +{ +#if QT_VERSION >= 0x050000 + return QStandardPaths::writableLocation(QStandardPaths::DataLocation); +#else + return QDesktopServices::storageLocation(QDesktopServices::DataLocation); +#endif +} + +QString StandardPaths::desktopLocation() +{ +#if QT_VERSION >= 0x050000 + return QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); +#else + return QDesktopServices::storageLocation(QDesktopServices::DesktopLocation); +#endif +} + +QString StandardPaths::documentsLocation() +{ +#if QT_VERSION >= 0x050000 + return QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation); +#else + return QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation); +#endif +} diff --git a/StandardPaths4.cpp b/StandardPaths4.cpp deleted file mode 100755 index 64acc44..0000000 --- a/StandardPaths4.cpp +++ /dev/null @@ -1,24 +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 . -*****************************************************************************/ - -#include "StandardPaths.h" - -QString StandardPaths::writableLocation(StandardLocation type) -{ - return QDesktopServices::storageLocation(type); -} diff --git a/StandardPaths4.h b/StandardPaths4.h deleted file mode 100755 index b1016ea..0000000 --- a/StandardPaths4.h +++ /dev/null @@ -1,30 +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 . -*****************************************************************************/ -#ifndef STANDARDPATHS4_H -#define STANDARDPATHS4_H - -#include -#include - -class StandardPaths : public QDesktopServices -{ -public: - static QString writableLocation(StandardLocation type); -}; - -#endif // STANDARDPATHS4_H diff --git a/StandardPaths5.cpp b/StandardPaths5.cpp deleted file mode 100755 index 826bbef..0000000 --- a/StandardPaths5.cpp +++ /dev/null @@ -1,24 +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 . -*****************************************************************************/ - -#include "StandardPaths.h" - -QString StandardPaths::writableLocation(StandardLocation type) -{ - return QStandardPaths::writableLocation(type); -} diff --git a/StandardPaths5.h b/StandardPaths5.h deleted file mode 100755 index db12a86..0000000 --- a/StandardPaths5.h +++ /dev/null @@ -1,30 +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 . -*****************************************************************************/ -#ifndef STANDARDPATHS5_H -#define STANDARDPATHS5_H - -#include -#include - -class StandardPaths : public QStandardPaths -{ -public: - static QString writableLocation(StandardLocation type); -}; - -#endif // STANDARDPATHS5_H diff --git a/UserInterface.cpp b/UserInterface.cpp index 4ed1b8d..80b80d2 100755 --- a/UserInterface.cpp +++ b/UserInterface.cpp @@ -47,7 +47,7 @@ UserInterface::UserInterface(ProfileDatabase *profileDB, CrewDatabase *crewDB, D bool forceDir = SyncSettings.value("force", false).toBool(); // init folder - QString GTAV_defaultFolder = StandardPaths::writableLocation(StandardPaths::DocumentsLocation) + "/Rockstar Games/GTA V"; + QString GTAV_defaultFolder = StandardPaths::documentsLocation() + "/Rockstar Games/GTA V"; QDir GTAV_Dir; if (forceDir) { diff --git a/gta5sync.pro b/gta5sync.pro index d74afd8..84b28dc 100755 --- a/gta5sync.pro +++ b/gta5sync.pro @@ -37,7 +37,8 @@ SOURCES += main.cpp \ SnapmaticWidget.cpp \ SavegameWidget.cpp \ ProfileLoader.cpp \ - AboutDialog.cpp + AboutDialog.cpp \ + StandardPaths.cpp HEADERS += \ SnapmaticPicture.h \ @@ -98,7 +99,7 @@ isEqual(QT_MAJOR_VERSION, 4): SOURCES += qjson4/QJsonArray.cpp \ # QT4/QT5 STANDARDPATHS CLASS -isEqual(QT_MAJOR_VERSION, 4): HEADERS += StandardPaths4.h -isEqual(QT_MAJOR_VERSION, 4): SOURCES += StandardPaths4.cpp -greaterThan(QT_MAJOR_VERSION, 4): HEADERS += StandardPaths5.h -greaterThan(QT_MAJOR_VERSION, 4): SOURCES += StandardPaths5.cpp +isEqual(QT_MAJOR_VERSION, 4): HEADERS += +isEqual(QT_MAJOR_VERSION, 4): SOURCES += +greaterThan(QT_MAJOR_VERSION, 4): HEADERS += +greaterThan(QT_MAJOR_VERSION, 4): SOURCES +=