add SidebarGenerator, add Pictures path to Sidebar/StandardPaths
This commit is contained in:
parent
95968f5986
commit
e7ba721687
8 changed files with 110 additions and 73 deletions
|
@ -19,6 +19,7 @@
|
||||||
#include "PictureDialog.h"
|
#include "PictureDialog.h"
|
||||||
#include "ProfileDatabase.h"
|
#include "ProfileDatabase.h"
|
||||||
#include "ui_PictureDialog.h"
|
#include "ui_PictureDialog.h"
|
||||||
|
#include "SidebarGenerator.h"
|
||||||
#include "StandardPaths.h"
|
#include "StandardPaths.h"
|
||||||
|
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
|
@ -168,30 +169,7 @@ fileDialogPreSave:
|
||||||
filters << tr("Portable Network Graphics (*.png)");
|
filters << tr("Portable Network Graphics (*.png)");
|
||||||
fileDialog.setNameFilters(filters);
|
fileDialog.setNameFilters(filters);
|
||||||
|
|
||||||
QList<QUrl> sidebarUrls = fileDialog.sidebarUrls();
|
QList<QUrl> sidebarUrls = SidebarGenerator::generateSidebarUrls(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()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fileDialog.setSidebarUrls(sidebarUrls);
|
fileDialog.setSidebarUrls(sidebarUrls);
|
||||||
fileDialog.restoreState(settings.value("ExportPicture","").toByteArray());
|
fileDialog.restoreState(settings.value("ExportPicture","").toByteArray());
|
||||||
|
@ -220,7 +198,9 @@ fileDialogPreSave:
|
||||||
yearStr = dateStrList.at(2);
|
yearStr = dateStrList.at(2);
|
||||||
monthStr = dateStrList.at(0);
|
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);
|
fileDialog.selectFile(newPictureFileName);
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
#include "ProfileInterface.h"
|
#include "ProfileInterface.h"
|
||||||
#include "ui_ProfileInterface.h"
|
#include "ui_ProfileInterface.h"
|
||||||
|
#include "SidebarGenerator.h"
|
||||||
#include "SnapmaticWidget.h"
|
#include "SnapmaticWidget.h"
|
||||||
#include "DatabaseThread.h"
|
#include "DatabaseThread.h"
|
||||||
#include "SavegameWidget.h"
|
#include "SavegameWidget.h"
|
||||||
|
@ -171,30 +172,7 @@ fileDialogPreOpen:
|
||||||
filters << tr("All files (**)");
|
filters << tr("All files (**)");
|
||||||
fileDialog.setNameFilters(filters);
|
fileDialog.setNameFilters(filters);
|
||||||
|
|
||||||
QList<QUrl> sidebarUrls = fileDialog.sidebarUrls();
|
QList<QUrl> sidebarUrls = SidebarGenerator::generateSidebarUrls(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()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fileDialog.setSidebarUrls(sidebarUrls);
|
fileDialog.setSidebarUrls(sidebarUrls);
|
||||||
fileDialog.restoreState(settings.value("ImportCopy","").toByteArray());
|
fileDialog.restoreState(settings.value("ImportCopy","").toByteArray());
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
#include "SavegameWidget.h"
|
#include "SavegameWidget.h"
|
||||||
#include "ui_SavegameWidget.h"
|
#include "ui_SavegameWidget.h"
|
||||||
|
#include "SidebarGenerator.h"
|
||||||
#include "StandardPaths.h"
|
#include "StandardPaths.h"
|
||||||
#include "SavegameData.h"
|
#include "SavegameData.h"
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
|
@ -92,30 +93,7 @@ fileDialogPreSave:
|
||||||
filters << tr("All files (**)");
|
filters << tr("All files (**)");
|
||||||
fileDialog.setNameFilters(filters);
|
fileDialog.setNameFilters(filters);
|
||||||
|
|
||||||
QList<QUrl> sidebarUrls = fileDialog.sidebarUrls();
|
QList<QUrl> sidebarUrls = SidebarGenerator::generateSidebarUrls(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()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fileDialog.setSidebarUrls(sidebarUrls);
|
fileDialog.setSidebarUrls(sidebarUrls);
|
||||||
fileDialog.restoreState(settings.value("CopySavegame","").toByteArray());
|
fileDialog.restoreState(settings.value("CopySavegame","").toByteArray());
|
||||||
|
|
57
SidebarGenerator.cpp
Executable file
57
SidebarGenerator.cpp
Executable file
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include "SidebarGenerator.h"
|
||||||
|
#include "StandardPaths.h"
|
||||||
|
#include <QList>
|
||||||
|
#include <QUrl>
|
||||||
|
#include <QDir>
|
||||||
|
|
||||||
|
SidebarGenerator::SidebarGenerator()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<QUrl> SidebarGenerator::generateSidebarUrls(QList<QUrl> 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;
|
||||||
|
}
|
32
SidebarGenerator.h
Executable file
32
SidebarGenerator.h
Executable file
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef SIDEBARGENERATOR_H
|
||||||
|
#define SIDEBARGENERATOR_H
|
||||||
|
|
||||||
|
#include <QList>
|
||||||
|
#include <QUrl>
|
||||||
|
|
||||||
|
class SidebarGenerator
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SidebarGenerator();
|
||||||
|
static QList<QUrl> generateSidebarUrls(QList<QUrl> sidebarUrls);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // SIDEBARGENERATOR_H
|
|
@ -82,6 +82,15 @@ QString StandardPaths::moviesLocation()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString StandardPaths::picturesLocation()
|
||||||
|
{
|
||||||
|
#if QT_VERSION >= 0x050000
|
||||||
|
return QStandardPaths::writableLocation(QStandardPaths::PicturesLocation);
|
||||||
|
#else
|
||||||
|
return QDesktopServices::storageLocation(QDesktopServices::PicturesLocation);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
QString StandardPaths::fontsLocation()
|
QString StandardPaths::fontsLocation()
|
||||||
{
|
{
|
||||||
#if QT_VERSION >= 0x050000
|
#if QT_VERSION >= 0x050000
|
||||||
|
|
|
@ -33,6 +33,7 @@ public:
|
||||||
static QString fontsLocation();
|
static QString fontsLocation();
|
||||||
static QString homeLocation();
|
static QString homeLocation();
|
||||||
static QString moviesLocation();
|
static QString moviesLocation();
|
||||||
|
static QString picturesLocation();
|
||||||
static QString musicLocation();
|
static QString musicLocation();
|
||||||
static QString tempLocation();
|
static QString tempLocation();
|
||||||
};
|
};
|
||||||
|
|
|
@ -35,6 +35,7 @@ SOURCES += main.cpp \
|
||||||
SavegameData.cpp \
|
SavegameData.cpp \
|
||||||
SavegameDialog.cpp \
|
SavegameDialog.cpp \
|
||||||
SavegameWidget.cpp \
|
SavegameWidget.cpp \
|
||||||
|
SidebarGenerator.cpp \
|
||||||
SnapmaticPicture.cpp \
|
SnapmaticPicture.cpp \
|
||||||
SnapmaticWidget.cpp \
|
SnapmaticWidget.cpp \
|
||||||
StandardPaths.cpp \
|
StandardPaths.cpp \
|
||||||
|
@ -51,6 +52,7 @@ HEADERS += \
|
||||||
SavegameData.h \
|
SavegameData.h \
|
||||||
SavegameDialog.h \
|
SavegameDialog.h \
|
||||||
SavegameWidget.h \
|
SavegameWidget.h \
|
||||||
|
SidebarGenerator.h \
|
||||||
SnapmaticPicture.h \
|
SnapmaticPicture.h \
|
||||||
SnapmaticWidget.h \
|
SnapmaticWidget.h \
|
||||||
StandardPaths.h \
|
StandardPaths.h \
|
||||||
|
|
Loading…
Reference in a new issue