add SidebarGenerator, add Pictures path to Sidebar/StandardPaths

This commit is contained in:
Rafael 2016-03-29 15:14:49 +02:00
parent 95968f5986
commit e7ba721687
8 changed files with 110 additions and 73 deletions

View File

@ -19,6 +19,7 @@
#include "PictureDialog.h"
#include "ProfileDatabase.h"
#include "ui_PictureDialog.h"
#include "SidebarGenerator.h"
#include "StandardPaths.h"
#include <QJsonDocument>
@ -168,30 +169,7 @@ fileDialogPreSave:
filters << tr("Portable Network Graphics (*.png)");
fileDialog.setNameFilters(filters);
QList<QUrl> sidebarUrls = 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()));
}
}
QList<QUrl> sidebarUrls = SidebarGenerator::generateSidebarUrls(fileDialog.sidebarUrls());
fileDialog.setSidebarUrls(sidebarUrls);
fileDialog.restoreState(settings.value("ExportPicture","").toByteArray());
@ -220,7 +198,9 @@ fileDialogPreSave:
yearStr = dateStrList.at(2);
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);

View File

@ -18,6 +18,7 @@
#include "ProfileInterface.h"
#include "ui_ProfileInterface.h"
#include "SidebarGenerator.h"
#include "SnapmaticWidget.h"
#include "DatabaseThread.h"
#include "SavegameWidget.h"
@ -171,30 +172,7 @@ fileDialogPreOpen:
filters << tr("All files (**)");
fileDialog.setNameFilters(filters);
QList<QUrl> sidebarUrls = 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()));
}
}
QList<QUrl> sidebarUrls = SidebarGenerator::generateSidebarUrls(fileDialog.sidebarUrls());
fileDialog.setSidebarUrls(sidebarUrls);
fileDialog.restoreState(settings.value("ImportCopy","").toByteArray());

View File

@ -18,6 +18,7 @@
#include "SavegameWidget.h"
#include "ui_SavegameWidget.h"
#include "SidebarGenerator.h"
#include "StandardPaths.h"
#include "SavegameData.h"
#include <QFileDialog>
@ -92,30 +93,7 @@ fileDialogPreSave:
filters << tr("All files (**)");
fileDialog.setNameFilters(filters);
QList<QUrl> sidebarUrls = 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()));
}
}
QList<QUrl> sidebarUrls = SidebarGenerator::generateSidebarUrls(fileDialog.sidebarUrls());
fileDialog.setSidebarUrls(sidebarUrls);
fileDialog.restoreState(settings.value("CopySavegame","").toByteArray());

57
SidebarGenerator.cpp Executable file
View 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
View 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

View File

@ -82,6 +82,15 @@ QString StandardPaths::moviesLocation()
#endif
}
QString StandardPaths::picturesLocation()
{
#if QT_VERSION >= 0x050000
return QStandardPaths::writableLocation(QStandardPaths::PicturesLocation);
#else
return QDesktopServices::storageLocation(QDesktopServices::PicturesLocation);
#endif
}
QString StandardPaths::fontsLocation()
{
#if QT_VERSION >= 0x050000

View File

@ -33,6 +33,7 @@ public:
static QString fontsLocation();
static QString homeLocation();
static QString moviesLocation();
static QString picturesLocation();
static QString musicLocation();
static QString tempLocation();
};

View File

@ -35,6 +35,7 @@ SOURCES += main.cpp \
SavegameData.cpp \
SavegameDialog.cpp \
SavegameWidget.cpp \
SidebarGenerator.cpp \
SnapmaticPicture.cpp \
SnapmaticWidget.cpp \
StandardPaths.cpp \
@ -51,6 +52,7 @@ HEADERS += \
SavegameData.h \
SavegameDialog.h \
SavegameWidget.h \
SidebarGenerator.h \
SnapmaticPicture.h \
SnapmaticWidget.h \
StandardPaths.h \