StandardPaths class for Qt4, SyncFramework deleted for a future rewrite
This commit is contained in:
parent
b280ce1423
commit
bfa84a5e99
8 changed files with 61 additions and 170 deletions
|
@ -16,24 +16,15 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*****************************************************************************/
|
||||
|
||||
#include "StandardPaths.h"
|
||||
#include "CrewDatabase.h"
|
||||
#include <QFile>
|
||||
#include <QDir>
|
||||
|
||||
#ifdef QT5_MODE
|
||||
#include <QStandardPaths>
|
||||
#else
|
||||
#include <QDesktopServices>
|
||||
#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";
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "PictureDialog.h"
|
||||
#include "ProfileDatabase.h"
|
||||
#include "ui_PictureDialog.h"
|
||||
#include "StandardPaths.h"
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QFileDialog>
|
||||
|
@ -31,12 +32,6 @@
|
|||
#include <QUrl>
|
||||
#include <QDir>
|
||||
|
||||
#if QT5_MODE
|
||||
#include <QStandardPaths>
|
||||
#else
|
||||
#include <QDesktopServices>
|
||||
#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);
|
||||
|
|
|
@ -17,23 +17,14 @@
|
|||
*****************************************************************************/
|
||||
|
||||
#include "ProfileDatabase.h"
|
||||
#include "StandardPaths.h"
|
||||
#include <QFile>
|
||||
#include <QDir>
|
||||
|
||||
#ifdef QT5_MODE
|
||||
#include <QStandardPaths>
|
||||
#else
|
||||
#include <QDesktopServices>
|
||||
#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";
|
||||
|
|
31
StandardPaths.cpp
Executable file
31
StandardPaths.cpp
Executable file
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*****************************************************************************/
|
||||
|
||||
#include "StandardPaths.h"
|
||||
|
||||
StandardPaths::StandardPaths()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#ifndef QT5_MODE
|
||||
QString StandardPaths::writableLocation(QDesktopServices::StandardLocation standardLocation)
|
||||
{
|
||||
return QDesktopServices::storageLocation(standardLocation);
|
||||
}
|
||||
#endif
|
|
@ -16,40 +16,28 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*****************************************************************************/
|
||||
|
||||
// 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 <QStandardPaths>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
|
||||
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 <QDesktopServices>
|
||||
#include <QObject>
|
||||
|
||||
class StandardPaths : public QDesktopServices
|
||||
{
|
||||
public:
|
||||
StandardPaths();
|
||||
static QString writableLocation(QDesktopServices::StandardLocation standardLocation);
|
||||
};
|
||||
#endif
|
||||
#endif // SYNCFRAMEWORK_H
|
||||
|
||||
#endif // STANDARDPATHS_H
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*****************************************************************************/
|
||||
|
||||
// DONT USE THE SYNC FRAMEWORK NOW
|
||||
|
||||
#ifndef QT5_MODE
|
||||
|
||||
#include "SyncFramework.h"
|
||||
#include <QEventLoop>
|
||||
#include <QFtp>
|
||||
|
||||
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
|
|
@ -19,6 +19,7 @@
|
|||
#include "UserInterface.h"
|
||||
#include "ui_UserInterface.h"
|
||||
#include "ProfileInterface.h"
|
||||
#include "StandardPaths.h"
|
||||
#include "AboutDialog.h"
|
||||
#include <QHBoxLayout>
|
||||
#include <QSpacerItem>
|
||||
|
@ -31,12 +32,6 @@
|
|||
#include <QDir>
|
||||
#include <QMap>
|
||||
|
||||
#ifdef QT5_MODE
|
||||
#include <QStandardPaths>
|
||||
#else
|
||||
#include <QDesktopServices>
|
||||
#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)
|
||||
{
|
||||
|
|
|
@ -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 \
|
||||
|
|
Loading…
Reference in a new issue