diff --git a/cexportdialog.cpp b/cexportdialog.cpp new file mode 100644 index 0000000..c413a47 --- /dev/null +++ b/cexportdialog.cpp @@ -0,0 +1,139 @@ +/*! + \file cexportdialog.cpp + +*/ + +#include "cexportdialog.h" +#include "ui_cexportdialog.h" + +#include +#include + + +cExportDialog::cExportDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::cExportDialog) +{ + initUI(); + createActions(); +} + +cExportDialog::~cExportDialog() +{ + delete ui; +} + +void cExportDialog::initUI() +{ + ui->setupUi(this); + + QSettings settings; + + qint32 iX = settings.value("export/x", QVariant::fromValue(-1)).toInt(); + qint32 iY = settings.value("export/y", QVariant::fromValue(-1)).toInt(); + qint32 iWidth = settings.value("export/width", QVariant::fromValue(-1)).toInt(); + qint32 iHeight = settings.value("export/height", QVariant::fromValue(-1)).toInt(); + + if(iWidth != -1 && iHeight != -1) + resize(iWidth, iHeight); + if(iX != -1 && iY != -1) + move(iX, iY); + + QString str = settings.value("export/filter", "exportAll").toString(); + if(str == "exportAll") + { + ui->m_lpExportAll->setChecked(true); + ui->m_lpExportSelection->setChecked(false); + ui->m_lpExportFilter->setChecked(false); + } + else if(str == "exportSelection") + { + ui->m_lpExportAll->setChecked(false); + ui->m_lpExportSelection->setChecked(true); + ui->m_lpExportFilter->setChecked(false); + } + else + { + ui->m_lpExportAll->setChecked(false); + ui->m_lpExportSelection->setChecked(false); + ui->m_lpExportFilter->setChecked(true); + } + + ui->m_lpKeepFilename->setChecked(settings.value("export/keepFilename", true).toBool()); + ui->m_lpRenameFilename->setChecked(!settings.value("export/keepFilename", true).toBool()); + ui->m_lpFilePattern->setText(settings.value("export/filePattern", "%o").toString()); + + ui->m_lpKeepStructure->setChecked(settings.value("export/keepStructure", true).toBool()); + ui->m_lpRenameStructure->setChecked(!settings.value("export/keepStructure", true).toBool()); + ui->m_lpStructurePattern->setText(settings.value("export/structurePattern", "%o").toString()); +} + +void cExportDialog::createActions() +{ + connect(ui->m_lpPathSelect, &QPushButton::clicked, this, &cExportDialog::onPathSelect); +} + +void cExportDialog::onPathSelect() +{ + QSettings settings; + QString szPath = settings.value("export/path", QDir::homePath()).toString(); + szPath = QFileDialog::getExistingDirectory(this, tr("Export Directory"), szPath, QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); + + if(szPath.isEmpty()) + return; + + ui->m_lpPath->setText(szPath); + settings.setValue("export/path", szPath); +} + +void cExportDialog::accept() +{ + savePosition(); + QDialog::accept(); +} + +void cExportDialog::reject() +{ + savePosition(); + QDialog::reject(); +} + +void cExportDialog::savePosition() +{ + QSettings settings; + + settings.setValue("export/width", QVariant::fromValue(size().width())); + settings.setValue("export/height", QVariant::fromValue(size().height())); + settings.setValue("export/x", QVariant::fromValue(x())); + settings.setValue("export/y", QVariant::fromValue(y())); + + if(ui->m_lpExportAll->isChecked()) + settings.setValue() + QString str = settings.value("export/filter", "exportAll").toString(); + if(str == "exportAll") + { + ui->m_lpExportAll->setChecked(true); + ui->m_lpExportSelection->setChecked(false); + ui->m_lpExportFilter->setChecked(false); + } + else if(str == "exportSelection") + { + ui->m_lpExportAll->setChecked(false); + ui->m_lpExportSelection->setChecked(true); + ui->m_lpExportFilter->setChecked(false); + } + else + { + ui->m_lpExportAll->setChecked(false); + ui->m_lpExportSelection->setChecked(false); + ui->m_lpExportFilter->setChecked(true); + } + + ui->m_lpKeepFilename->setChecked(settings.value("export/keepFilename", true).toBool()); + ui->m_lpRenameFilename->setChecked(!settings.value("export/keepFilename", true).toBool()); + ui->m_lpFilePattern->setText(settings.value("export/filePattern", "%o").toString()); + + ui->m_lpKeepStructure->setChecked(settings.value("export/keepStructure", true).toBool()); + ui->m_lpRenameStructure->setChecked(!settings.value("export/keepStructure", true).toBool()); + ui->m_lpStructurePattern->setText(settings.value("export/structurePattern", "%o").toString()); +} diff --git a/cexportdialog.h b/cexportdialog.h new file mode 100644 index 0000000..0aecbf5 --- /dev/null +++ b/cexportdialog.h @@ -0,0 +1,87 @@ +/*! + \file cexportdialog.h + +*/ + +#ifndef CEXPORTDIALOG_H +#define CEXPORTDIALOG_H + + +#include +#include + + +namespace Ui { +class cExportDialog; +} + +/*! + \brief + + \class cExportDialog cexportdialog.h "cexportdialog.h" +*/ +class cExportDialog : public QDialog +{ + Q_OBJECT + +public: + /*! + \brief + + \fn cExportDialog + \param parent + */ + explicit cExportDialog(QWidget *parent = nullptr); + /*! + \brief + + \fn ~cExportDialog + */ + ~cExportDialog(); + +private slots: + /*! + \brief + + \fn onPathSelect + */ + void onPathSelect(); + +private: + Ui::cExportDialog* ui; /*!< TODO: describe */ + + /*! + \brief + + \fn initUI + */ + void initUI(); + /*! + \brief + + \fn createActions + */ + void createActions(); + + /*! + \brief + + \fn accept + */ + void accept(); + /*! + \brief + + \fn reject + */ + void reject(); + + /*! + \brief + + \fn savePosition + */ + void savePosition(); +}; + +#endif // CEXPORTDIALOG_H diff --git a/cexportdialog.ui b/cexportdialog.ui new file mode 100644 index 0000000..351310e --- /dev/null +++ b/cexportdialog.ui @@ -0,0 +1,240 @@ + + + cExportDialog + + + + 0 + 0 + 609 + 247 + + + + Export + + + + + + + + + + Path: + + + + + + + + + + ... + + + + + + + + + + + Filter + + + + + + + + all + + + + + + + all in filter + + + + + + + selection + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + Filename + + + + + + + + keep filename + + + + + + + rename to: + + + + + + + + + + <html><head/><body>%t = title<br>%n = original filename<br>%d = original date<br>%m = camera model</p></body></html> + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + Structure + + + + + + + + keep structure + + + + + + + rename to: + + + + + + + + + + <html><head/><body>%t = title<br>%n = original filename<br>%d = original date<br>%m = camera model</p></body></html> + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + cExportDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + cExportDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/cmainwindow.cpp b/cmainwindow.cpp index 7dfe174..5202b3a 100644 --- a/cmainwindow.cpp +++ b/cmainwindow.cpp @@ -7,6 +7,7 @@ #include "cmainwindow.h" #include "cimportdialog.h" +#include "cexportdialog.h" #include "cdatepicker.h" #include "cdatetimepicker.h" @@ -51,7 +52,6 @@ cMainWindow::cMainWindow(cSplashScreen* lpSplashScreen, QWidget *parent) : initUI(); createActions(); -// onFileNew(); QSettings settings; m_szOldPath = settings.value("file/lastPath", QDir::homePath()).toString(); m_pictureLibrary.openDatabase(m_szOldPath); @@ -73,6 +73,28 @@ cMainWindow::~cMainWindow() delete ui; } +void cMainWindow::closeEvent(QCloseEvent *event) +{ + QSettings settings; + settings.setValue("main/width", QVariant::fromValue(size().width())); + settings.setValue("main/height", QVariant::fromValue(size().height())); + settings.setValue("main/x", QVariant::fromValue(x())); + settings.setValue("main/y", QVariant::fromValue(y())); + if(this->isMaximized()) + settings.setValue("main/maximized", QVariant::fromValue(true)); + else + settings.setValue("main/maximized", QVariant::fromValue(false)); + + QList sizes = ui->m_lpSplitter->sizes(); + + for(int x = 0;x < sizes.count();x++) + settings.setValue(QString("main/splitter%1").arg(x+1), QVariant::fromValue(sizes[x])); + + m_lpFilterPanel->saveSettings(); + + event->accept(); +} + void cMainWindow::initUI() { ui->setupUi(this); @@ -180,26 +202,6 @@ void cMainWindow::createContextActions() connect(m_lpUnsetHDRAction, &QAction::triggered, this, &cMainWindow::onUnsetHDR); } -void cMainWindow::closeEvent(QCloseEvent *event) -{ - QSettings settings; - settings.setValue("main/width", QVariant::fromValue(size().width())); - settings.setValue("main/height", QVariant::fromValue(size().height())); - settings.setValue("main/x", QVariant::fromValue(x())); - settings.setValue("main/y", QVariant::fromValue(y())); - if(this->isMaximized()) - settings.setValue("main/maximized", QVariant::fromValue(true)); - else - settings.setValue("main/maximized", QVariant::fromValue(false)); - - QList sizes = ui->m_lpSplitter->sizes(); - - for(int x = 0;x < sizes.count();x++) - settings.setValue(QString("main/splitter%1").arg(x+1), QVariant::fromValue(sizes[x])); - - event->accept(); -} - void cMainWindow::createFileActions() { m_lpFileMenu = menuBar()->addMenu(tr("&File")); @@ -223,6 +225,9 @@ void cMainWindow::createFileActions() m_lpFileImportAction = m_lpFileMenu->addAction(tr("&Import..."), this, &cMainWindow::onFileImport); m_lpFileToolBar->addAction(m_lpFileImportAction); + m_lpFileExportAction = m_lpFileMenu->addAction(tr("&Export..."), this, &cMainWindow::onFileExport); + m_lpFileToolBar->addAction(m_lpFileExportAction); + m_lpFileMenu->addSeparator(); for(int i = 0; i < MaxRecentFiles;i++) @@ -599,6 +604,13 @@ void cMainWindow::onFileImport() displayData(); } +void cMainWindow::onFileExport() +{ + cExportDialog exportDialog(this); + if(exportDialog.exec() == QDialog::Rejected) + return; +} + void cMainWindow::onThumbnailViewContextMenu(const QPoint& pos) { QMenu menu(this); diff --git a/cmainwindow.h b/cmainwindow.h index 043c12b..e519bcc 100644 --- a/cmainwindow.h +++ b/cmainwindow.h @@ -93,6 +93,7 @@ private: QAction* m_lpFileOpenAction; /*!< TODO: describe */ QAction* m_lpFileSaveAsAction; /*!< TODO: describe */ QAction* m_lpFileImportAction; /*!< TODO: describe */ + QAction* m_lpFileExportAction; /*!< TODO: describe */ QAction* m_lpFileQuitAction; /*!< TODO: describe */ QAction* m_lpSeparatorRecent; /*!< TODO: describe */ @@ -231,6 +232,12 @@ private slots: \fn onFileImport */ void onFileImport(); + /*! + \brief + + \fn onFileExport + */ + void onFileExport(); /*! \brief diff --git a/pictureLibrary.pro b/pictureLibrary.pro index c4aa2b4..f34f36c 100644 --- a/pictureLibrary.pro +++ b/pictureLibrary.pro @@ -78,7 +78,8 @@ SOURCES += \ ctoolboxlocation.cpp \ ctoolboxtag.cpp \ cspoiler.cpp \ - cfilterpanel.cpp + cfilterpanel.cpp \ + cexportdialog.cpp HEADERS += \ cmainwindow.h \ @@ -105,7 +106,8 @@ HEADERS += \ ctoolboxlocation.h \ ctoolboxtag.h \ cspoiler.h \ - cfilterpanel.h + cfilterpanel.h \ + cexportdialog.h FORMS += \ cmainwindow.ui \ @@ -118,7 +120,8 @@ FORMS += \ cimageviewer.ui \ ctoolboxlocation.ui \ ctoolboxtag.ui \ - cfilterpanel.ui + cfilterpanel.ui \ + cexportdialog.ui # Default rules for deployment. qnx: target.path = /tmp/$${TARGET}/bin