fileDialog improved

This commit is contained in:
Rafael 2016-04-24 13:34:03 +02:00
parent d42f263f4e
commit ef788fa2bf
5 changed files with 34 additions and 9 deletions

View file

@ -18,6 +18,7 @@
#include "PictureCopy.h" #include "PictureCopy.h"
#include "PictureDialog.h" #include "PictureDialog.h"
#include "StandardPaths.h"
#include "SidebarGenerator.h" #include "SidebarGenerator.h"
#include <QMessageBox> #include <QMessageBox>
#include <QFileDialog> #include <QFileDialog>
@ -32,6 +33,7 @@ void PictureCopy::copyPicture(QWidget *parent, QString picPath)
{ {
QSettings settings("Syping", "gta5sync"); QSettings settings("Syping", "gta5sync");
settings.beginGroup("FileDialogs"); settings.beginGroup("FileDialogs");
settings.beginGroup("PictureCopy");
fileDialogPreSave: fileDialogPreSave:
QFileInfo sgdFileInfo(picPath); QFileInfo sgdFileInfo(picPath);
@ -54,8 +56,9 @@ fileDialogPreSave:
QList<QUrl> sidebarUrls = SidebarGenerator::generateSidebarUrls(fileDialog.sidebarUrls()); QList<QUrl> sidebarUrls = SidebarGenerator::generateSidebarUrls(fileDialog.sidebarUrls());
fileDialog.setSidebarUrls(sidebarUrls); fileDialog.setSidebarUrls(sidebarUrls);
fileDialog.restoreState(settings.value("CopyPicture","").toByteArray()); fileDialog.setDirectory(settings.value("Directory", StandardPaths::documentsLocation()).toString());
fileDialog.selectFile(sgdFileInfo.fileName()); fileDialog.selectFile(sgdFileInfo.fileName());
fileDialog.restoreGeometry(settings.value(parent->objectName() + "+Geomtery", "").toByteArray());
if (fileDialog.exec()) if (fileDialog.exec())
{ {
@ -94,6 +97,7 @@ fileDialogPreSave:
} }
} }
settings.setValue("CopyPicture", fileDialog.saveState()); settings.setValue(parent->objectName() + "+Geometry", fileDialog.saveGeometry());
settings.setValue("Directory", fileDialog.directory().absolutePath());
settings.endGroup(); settings.endGroup();
} }

View file

@ -305,6 +305,7 @@ void PictureDialog::on_labPicture_mouseDoubleClicked(Qt::MouseButton button)
{ {
QRect desktopRect = QApplication::desktop()->screenGeometry(); QRect desktopRect = QApplication::desktop()->screenGeometry();
PictureWidget *pictureWidget = new PictureWidget(this); PictureWidget *pictureWidget = new PictureWidget(this);
pictureWidget->setObjectName("PictureWidget");
pictureWidget->setWindowFlags(pictureWidget->windowFlags()^Qt::WindowContextHelpButtonHint); pictureWidget->setWindowFlags(pictureWidget->windowFlags()^Qt::WindowContextHelpButtonHint);
pictureWidget->setWindowTitle(this->windowTitle()); pictureWidget->setWindowTitle(this->windowTitle());
pictureWidget->setStyleSheet("QLabel#pictureLabel{background-color: black;}"); pictureWidget->setStyleSheet("QLabel#pictureLabel{background-color: black;}");

View file

@ -16,13 +16,15 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/ *****************************************************************************/
#include "config.h"
#include "PictureExport.h" #include "PictureExport.h"
#include "PictureDialog.h" #include "PictureDialog.h"
#include "StandardPaths.h"
#include "SidebarGenerator.h" #include "SidebarGenerator.h"
#include "config.h"
#include <QMessageBox> #include <QMessageBox>
#include <QFileDialog> #include <QFileDialog>
#include <QSettings> #include <QSettings>
#include <QDebug>
PictureExport::PictureExport() PictureExport::PictureExport()
{ {
@ -33,6 +35,7 @@ void PictureExport::exportPicture(QWidget *parent, SnapmaticPicture *picture)
{ {
QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR); QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
settings.beginGroup("FileDialogs"); settings.beginGroup("FileDialogs");
settings.beginGroup("ExportPicture");
fileDialogPreSave: fileDialogPreSave:
QFileDialog fileDialog(parent); QFileDialog fileDialog(parent);
@ -54,7 +57,8 @@ fileDialogPreSave:
QList<QUrl> sidebarUrls = SidebarGenerator::generateSidebarUrls(fileDialog.sidebarUrls()); QList<QUrl> sidebarUrls = SidebarGenerator::generateSidebarUrls(fileDialog.sidebarUrls());
fileDialog.setSidebarUrls(sidebarUrls); fileDialog.setSidebarUrls(sidebarUrls);
fileDialog.restoreState(settings.value("ExportPicture","").toByteArray()); fileDialog.setDirectory(settings.value("Directory", StandardPaths::picturesLocation()).toString());
fileDialog.restoreGeometry(settings.value(parent->objectName() + "+Geomtery", "").toByteArray());
if (picture != 0) if (picture != 0)
{ {
@ -129,7 +133,9 @@ fileDialogPreSave:
} }
} }
settings.setValue("ExportPicture", fileDialog.saveState()); settings.setValue(parent->objectName() + "+Geometry", fileDialog.saveGeometry());
settings.setValue("Directory", fileDialog.directory().absolutePath());
settings.endGroup();
settings.endGroup(); settings.endGroup();
} }

View file

@ -344,6 +344,7 @@ void ProfileInterface::on_cmdImport_clicked()
{ {
QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR); QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
settings.beginGroup("FileDialogs"); settings.beginGroup("FileDialogs");
settings.beginGroup("ImportCopy");
fileDialogPreOpen: fileDialogPreOpen:
QFileDialog fileDialog(this); QFileDialog fileDialog(this);
@ -365,7 +366,8 @@ fileDialogPreOpen:
QList<QUrl> sidebarUrls = SidebarGenerator::generateSidebarUrls(fileDialog.sidebarUrls()); QList<QUrl> sidebarUrls = SidebarGenerator::generateSidebarUrls(fileDialog.sidebarUrls());
fileDialog.setSidebarUrls(sidebarUrls); fileDialog.setSidebarUrls(sidebarUrls);
fileDialog.restoreState(settings.value("ImportCopy","").toByteArray()); fileDialog.setDirectory(settings.value(profileName + "+Directory", StandardPaths::documentsLocation()).toString());
fileDialog.restoreGeometry(settings.value(profileName + "+Geometry", "").toByteArray());
if (fileDialog.exec()) if (fileDialog.exec())
{ {
@ -403,7 +405,9 @@ fileDialogPreOpen:
} }
} }
settings.setValue("ImportCopy", fileDialog.saveState()); settings.setValue(profileName + "+Geometry", fileDialog.saveGeometry());
settings.setValue(profileName + "+Directory", fileDialog.directory().absolutePath());
settings.endGroup();
settings.endGroup(); settings.endGroup();
} }
@ -599,9 +603,13 @@ void ProfileInterface::exportSelected()
bool pictureCopyEnabled = false; bool pictureCopyEnabled = false;
bool pictureExportEnabled = false; bool pictureExportEnabled = false;
QString exportDirectory = QFileDialog::getExistingDirectory(this, tr("Export selected"), profileFolder); QSettings settings(GTA5SYNC_APPVENDOR, GTA5SYNC_APPSTR);
settings.beginGroup("FileDialogs");
settings.beginGroup("ExportDirectory");
QString exportDirectory = QFileDialog::getExistingDirectory(this, tr("Export selected"), settings.value(profileName, profileFolder).toString());
if (exportDirectory != "") if (exportDirectory != "")
{ {
settings.setValue(profileName, exportDirectory);
foreach (ProfileWidget *widget, widgets.keys()) foreach (ProfileWidget *widget, widgets.keys())
{ {
if (widget->isSelected()) if (widget->isSelected())
@ -730,6 +738,8 @@ void ProfileInterface::exportSelected()
delete exportThread; delete exportThread;
} }
} }
settings.endGroup();
settings.endGroup();
} }
else else
{ {

View file

@ -318,7 +318,8 @@ fileDialogPreOpen:
QList<QUrl> sidebarUrls = SidebarGenerator::generateSidebarUrls(fileDialog.sidebarUrls()); QList<QUrl> sidebarUrls = SidebarGenerator::generateSidebarUrls(fileDialog.sidebarUrls());
fileDialog.setSidebarUrls(sidebarUrls); fileDialog.setSidebarUrls(sidebarUrls);
fileDialog.restoreState(settings.value("OpenFile","").toByteArray()); fileDialog.setDirectory(settings.value("OpenDialogDirectory", StandardPaths::documentsLocation()).toString());
fileDialog.restoreGeometry(settings.value("OpenDialogGeometry","").toByteArray());
if (fileDialog.exec()) if (fileDialog.exec())
{ {
@ -329,6 +330,9 @@ fileDialogPreOpen:
if (!openFile(selectedFile, true)) goto fileDialogPreOpen; if (!openFile(selectedFile, true)) goto fileDialogPreOpen;
} }
} }
settings.setValue("OpenDialogGeometry", fileDialog.saveGeometry());
settings.setValue("OpenDialogDirectory", fileDialog.directory().absolutePath());
settings.endGroup(); settings.endGroup();
} }