Browse Source

add SidebarGenerator, add Pictures path to Sidebar/StandardPaths

1.3.x
Rafael 6 years ago
parent
commit
e7ba721687
  1. 30
      PictureDialog.cpp
  2. 26
      ProfileInterface.cpp
  3. 26
      SavegameWidget.cpp
  4. 57
      SidebarGenerator.cpp
  5. 32
      SidebarGenerator.h
  6. 9
      StandardPaths.cpp
  7. 1
      StandardPaths.h
  8. 2
      gta5sync.pro

30
PictureDialog.cpp

@ -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);

26
ProfileInterface.cpp

@ -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());

26
SavegameWidget.cpp

@ -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

@ -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

@ -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

9
StandardPaths.cpp

@ -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

1
StandardPaths.h

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

2
gta5sync.pro

@ -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 \

Loading…
Cancel
Save