changed StandardPaths class

This commit is contained in:
Rafael 2016-03-28 13:18:39 +02:00
parent c82e7cf8e6
commit 2162bdc125
10 changed files with 66 additions and 118 deletions

View file

@ -24,7 +24,7 @@
CrewDatabase::CrewDatabase(QObject *parent) : QObject(parent) CrewDatabase::CrewDatabase(QObject *parent) : QObject(parent)
{ {
QDir dir; QDir dir;
dir.setPath(StandardPaths::writableLocation(StandardPaths::DataLocation)); dir.setPath(StandardPaths::dataLocation());
dir.mkdir("../gta5sync"); dir.mkdir("../gta5sync");
QString dirPath = dir.absolutePath(); QString dirPath = dir.absolutePath();
QString defaultConfPath = dirPath + "/crews.ini"; QString defaultConfPath = dirPath + "/crews.ini";

View file

@ -159,8 +159,8 @@ void PictureDialog::on_cmdExport_clicked()
QDir dir; QDir dir;
// Get Documents + Desktop Location // Get Documents + Desktop Location
QString documentsLocation = StandardPaths::writableLocation(StandardPaths::DocumentsLocation); QString documentsLocation = StandardPaths::documentsLocation();
QString desktopLocation = StandardPaths::writableLocation(StandardPaths::DesktopLocation); QString desktopLocation = StandardPaths::desktopLocation();
// Add Desktop Location to Sidebar // Add Desktop Location to Sidebar
dir.setPath(desktopLocation); dir.setPath(desktopLocation);

View file

@ -24,7 +24,7 @@
ProfileDatabase::ProfileDatabase(QObject *parent) : QObject(parent) ProfileDatabase::ProfileDatabase(QObject *parent) : QObject(parent)
{ {
QDir dir; QDir dir;
dir.setPath(StandardPaths::writableLocation(StandardPaths::DataLocation)); dir.setPath(StandardPaths::dataLocation());
dir.mkdir("../gta5sync"); dir.mkdir("../gta5sync");
QString dirPath = dir.absolutePath(); QString dirPath = dir.absolutePath();
QString defaultConfPath = dirPath + "/players.ini"; QString defaultConfPath = dirPath + "/players.ini";

55
StandardPaths.cpp Executable file
View file

@ -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 <http://www.gnu.org/licenses/>.
*****************************************************************************/
#include "StandardPaths.h"
#if QT_VERSION >= 0x050000
#include <QStandardPaths>
#else
#include <QDesktopServices>
#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
}

View file

@ -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 <http://www.gnu.org/licenses/>.
*****************************************************************************/
#include "StandardPaths.h"
QString StandardPaths::writableLocation(StandardLocation type)
{
return QDesktopServices::storageLocation(type);
}

View file

@ -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 <http://www.gnu.org/licenses/>.
*****************************************************************************/
#ifndef STANDARDPATHS4_H
#define STANDARDPATHS4_H
#include <QDesktopServices>
#include <QString>
class StandardPaths : public QDesktopServices
{
public:
static QString writableLocation(StandardLocation type);
};
#endif // STANDARDPATHS4_H

View file

@ -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 <http://www.gnu.org/licenses/>.
*****************************************************************************/
#include "StandardPaths.h"
QString StandardPaths::writableLocation(StandardLocation type)
{
return QStandardPaths::writableLocation(type);
}

View file

@ -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 <http://www.gnu.org/licenses/>.
*****************************************************************************/
#ifndef STANDARDPATHS5_H
#define STANDARDPATHS5_H
#include <QStandardPaths>
#include <QString>
class StandardPaths : public QStandardPaths
{
public:
static QString writableLocation(StandardLocation type);
};
#endif // STANDARDPATHS5_H

View file

@ -47,7 +47,7 @@ UserInterface::UserInterface(ProfileDatabase *profileDB, CrewDatabase *crewDB, D
bool forceDir = SyncSettings.value("force", false).toBool(); bool forceDir = SyncSettings.value("force", false).toBool();
// init folder // 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; QDir GTAV_Dir;
if (forceDir) if (forceDir)
{ {

View file

@ -37,7 +37,8 @@ SOURCES += main.cpp \
SnapmaticWidget.cpp \ SnapmaticWidget.cpp \
SavegameWidget.cpp \ SavegameWidget.cpp \
ProfileLoader.cpp \ ProfileLoader.cpp \
AboutDialog.cpp AboutDialog.cpp \
StandardPaths.cpp
HEADERS += \ HEADERS += \
SnapmaticPicture.h \ SnapmaticPicture.h \
@ -98,7 +99,7 @@ isEqual(QT_MAJOR_VERSION, 4): SOURCES += qjson4/QJsonArray.cpp \
# QT4/QT5 STANDARDPATHS CLASS # QT4/QT5 STANDARDPATHS CLASS
isEqual(QT_MAJOR_VERSION, 4): HEADERS += StandardPaths4.h isEqual(QT_MAJOR_VERSION, 4): HEADERS +=
isEqual(QT_MAJOR_VERSION, 4): SOURCES += StandardPaths4.cpp isEqual(QT_MAJOR_VERSION, 4): SOURCES +=
greaterThan(QT_MAJOR_VERSION, 4): HEADERS += StandardPaths5.h greaterThan(QT_MAJOR_VERSION, 4): HEADERS +=
greaterThan(QT_MAJOR_VERSION, 4): SOURCES += StandardPaths5.cpp greaterThan(QT_MAJOR_VERSION, 4): SOURCES +=