From 5c9b53edd30236c49fc7b1fcba00aaf71390d9d7 Mon Sep 17 00:00:00 2001 From: hama Date: Tue, 2 Jun 2015 00:13:24 +0200 Subject: [PATCH] ReFind: history of some text comboboxes * ReFind: version 2015.06.01 * ReImgConvert: combobox history --- appl/.gitignore | 2 + appl/refind/dialogoptions.hpp | 17 +- appl/refind/mainwindow.cpp | 20 +- appl/refind/mainwindow.hpp | 3 +- appl/reimgconvert/converter.cpp | 3 +- appl/reimgconvert/main.cpp | 5 +- appl/reimgconvert/mainwindow.cpp | 314 +++++-- appl/reimgconvert/mainwindow.hpp | 32 +- appl/reimgconvert/mainwindow.ui | 1395 ++++++++++++++++------------ appl/reimgconvert/reimgconvert.pro | 17 +- gui/ReGuiValidator.cpp | 21 +- gui/ReGuiValidator.hpp | 3 +- 12 files changed, 1075 insertions(+), 757 deletions(-) diff --git a/appl/.gitignore b/appl/.gitignore index 5ec952f..511285d 100644 --- a/appl/.gitignore +++ b/appl/.gitignore @@ -1,2 +1,4 @@ build-reviewer-Desktop5-Debug/ +build-refind-Desktop5-Debug/ +build-reimgconvert-Desktop5-Debug/ diff --git a/appl/refind/dialogoptions.hpp b/appl/refind/dialogoptions.hpp index 5f15e91..6684443 100644 --- a/appl/refind/dialogoptions.hpp +++ b/appl/refind/dialogoptions.hpp @@ -16,15 +16,14 @@ class DialogOptions; } class DialogOptions; -class TableKeyPressEater : public QObject -{ - Q_OBJECT +class TableKeyPressEater: public QObject { + Q_OBJECT public: - TableKeyPressEater(DialogOptions* dialog); + TableKeyPressEater(DialogOptions* dialog); protected: - bool eventFilter(QObject *obj, QEvent *event); + bool eventFilter(QObject *obj, QEvent *event); private: - DialogOptions* m_dialog; + DialogOptions* m_dialog; }; class DialogOptions: public QDialog { @@ -32,8 +31,7 @@ class DialogOptions: public QDialog { public: explicit DialogOptions(ContextHandlerList& handlers, QWidget *parent = 0); - ~DialogOptions(); -private slots: + ~DialogOptions();private slots: void accepted(); void add(); void cellEntered(int row, int column); @@ -46,7 +44,8 @@ public: void handleKey(int key); private: void currentToTable(int row); - void currentItemChanged(QTableWidgetItem* current, QTableWidgetItem* previous); + void currentItemChanged(QTableWidgetItem* current, + QTableWidgetItem* previous); void fillContextHandler(int row, ContextHandler& handler); void fillTable(); void fromTable(); diff --git a/appl/refind/mainwindow.cpp b/appl/refind/mainwindow.cpp index 6360171..c7ec31b 100644 --- a/appl/refind/mainwindow.cpp +++ b/appl/refind/mainwindow.cpp @@ -31,7 +31,7 @@ #include #include -const QString VERSION("2015.05.27"); +const QString VERSION("2015.06.01"); /** * @brief Constructor. * @@ -52,7 +52,7 @@ MainWindow::MainWindow(const QString& startDir, const QString& homeDir, m_contextHandlers(){ ui->setupUi(this); initializeHome(); - m_statusMessage = new QLabel(tr("Welcome at reviewer")); + m_statusMessage = new QLabel(tr("Welcome at refind")); if (!startDir.isEmpty()) ui->comboBoxDirectory->setCurrentText(startDir); if (ui->comboBoxDirectory->currentText().isEmpty()) @@ -188,9 +188,9 @@ QString MainWindow::buildAbsPath(int row, bool withNode, bool uriFormat){ rc += cellAsText(row, TC_NODE); } if (uriFormat){ - rc = "file://" + rc; + rc = "file://" + rc; #if defined WIN32 - rc = rc.replace('\\', '/'); + rc = rc.replace('\\', '/'); #endif } return rc; @@ -713,7 +713,7 @@ ui->checkBoxTextIgnoreCase->setChecked(false); } /** - * Handles the push of the button "select directory". + * Reads the history of the widget values and other parameters and set it. */ void MainWindow::restoreState(){ ReStateStorage storage(m_storageFile); @@ -737,7 +737,7 @@ storage.close(); } /** - * Handles the push of the button "select directory". + * Stores the history of the widget values and other parameters. */ void MainWindow::saveState(){ ReStateStorage storage(m_storageFile); @@ -766,7 +766,7 @@ storage.close(); void MainWindow::search(){ m_errors = 0; QApplication::setOverrideCursor (QCursor(Qt::WaitCursor));QString -path = ui->comboBoxDirectory->currentText(); +path = comboText(ui->comboBoxDirectory); QFileInfo dir(path); if (!dir.exists()) guiError(ui->comboBoxDirectory, tr("directory not found: ") + path); @@ -784,11 +784,11 @@ else{ finder.setMaxDepth(comboInt(ui->comboBoxMaxDepth, -1)); finder.setFiletypes(buildFileTypes()); QStringList patterns; - QString value = ui->comboBoxFilePatterns->currentText(); + QString value = comboText(ui->comboBoxFilePatterns); if (!value.isEmpty()) patterns = value.split(","); finder.setPatterns(patterns); - value = ui->comboBoxExcludedDirs->currentText(); + value = comboText(ui->comboBoxExcludedDirs); if (value.indexOf('/') >= 0 || value.indexOf('\\') >= 0) guiError(ui->comboBoxExcludedDirs, tr("no path delimiter allowed")); else if (value.indexOf('*') >= 0) @@ -799,7 +799,7 @@ else{ finder.setExcludedDirs(patterns); prepareTextFind(); if (m_errors == 0){ - if (!ui->comboBoxTextPattern->currentText().isEmpty()) + if (!comboText(ui->comboBoxTextPattern).isEmpty()) finder.setTextFinder(&m_textFinder); m_statistics.clear(); clock_t start = clock(); diff --git a/appl/refind/mainwindow.hpp b/appl/refind/mainwindow.hpp index d93c9b8..e353573 100644 --- a/appl/refind/mainwindow.hpp +++ b/appl/refind/mainwindow.hpp @@ -45,8 +45,7 @@ public: ~MainWindow(); public: - void fileDragging(); -private slots: + void fileDragging();private slots: void about(); void absPathToClipboard(); void baseDirToClipboard(); diff --git a/appl/reimgconvert/converter.cpp b/appl/reimgconvert/converter.cpp index c1faf61..c8f4009 100644 --- a/appl/reimgconvert/converter.cpp +++ b/appl/reimgconvert/converter.cpp @@ -6,7 +6,8 @@ * The original sources can be found on https://github.com/republib. */ -#include "../../base/rebase.hpp" +#include "base/rebase.hpp" +#include "gui/regui.hpp" #include "converter.hpp" #include "mainwindow.hpp" #include diff --git a/appl/reimgconvert/main.cpp b/appl/reimgconvert/main.cpp index 6d571f3..4f431aa 100644 --- a/appl/reimgconvert/main.cpp +++ b/appl/reimgconvert/main.cpp @@ -6,13 +6,16 @@ * The original sources can be found on https://github.com/republib. */ +#include "base/rebase.hpp" +#include "gui/regui.hpp" #include "mainwindow.hpp" #include char** g_argv; int main(int argc, char *argv[]){ g_argv = argv; + QString homeDir = argc > 1 ? argv[1] : ""; QApplication a(argc, argv); - MainWindow w; + MainWindow w(homeDir); w.show(); return a.exec(); diff --git a/appl/reimgconvert/mainwindow.cpp b/appl/reimgconvert/mainwindow.cpp index 4ffd4af..e4187d8 100644 --- a/appl/reimgconvert/mainwindow.cpp +++ b/appl/reimgconvert/mainwindow.cpp @@ -6,6 +6,8 @@ * The original sources can be found on https://github.com/republib. */ +#include "base/rebase.hpp" +#include "gui/regui.hpp" #include "mainwindow.hpp" #include "ui_mainwindow.h" #include "aboutdialog.hpp" @@ -26,51 +28,71 @@ const QString VERSION("2015.05.31"); * * @param parent NULL or the parent (who destroys the objects at the end) */ -MainWindow::MainWindow(QWidget *parent) : - QMainWindow(parent), ui(new Ui::MainWindow), m_converter(NULL){ +MainWindow::MainWindow(const QString& homeDir, QWidget *parent) : + QMainWindow(parent), + m_homeDir(homeDir), + m_storageFile(), + ui(new Ui::MainWindow), + m_converter(NULL){ + ui->setupUi(this); + initializeHome(); switchRun(true); - QStringList defaultX; - defaultX.append("*"); - defaultX.append("1024"); - defaultX.append("1920"); - defaultX.append("800"); - QStringList defaultY; - defaultY.append("*"); - defaultY.append("768"); - defaultY.append("1050"); - defaultY.append("600"); - QStringList quality; - quality.append("70"); - quality.append("85"); - quality.append("100"); - QStringList target; - target.append("normal"); - target.append("mini"); - target.append("1024"); - target.append("1920"); - ui->comboLandscapeX->addItems(defaultX); - ui->comboLandscapeY->addItems(defaultY); - ui->comboPortraitX->addItems(defaultX); - ui->comboPortraitY->addItems(defaultY); - ui->comboSquareX->addItems(defaultX); - ui->comboQuality->addItems(quality); - ui->comboTarget->addItems(target); - ui->comboLandscapeX->setCurrentText("1024"); - ui->comboLandscapeY->setCurrentText("*"); - ui->comboPortraitX->setCurrentText("*"); - ui->comboPortraitY->setCurrentText("768"); - ui->comboSquareX->setCurrentText("768"); - ui->comboQuality->setCurrentText("70"); - ui->comboTarget->setCurrentText("normal"); - ui->buttonStop->hide(); - + m_statusMessage = new QLabel(tr("Welcome at reimgconvert")); + statusBar()->addWidget(m_statusMessage); connect(ui->actionSelectDestination, SIGNAL(triggered()), this, SLOT(selectDestination())); connect(ui->pushButtonSelectDest, SIGNAL(clicked()), this, SLOT(selectDestination())); + connect(ui->actionSelectSource, SIGNAL(triggered()), this, + SLOT(selectSource())); + connect(ui->pushButtonSelectDest, SIGNAL(clicked()), this, + SLOT(selectDestination())); connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(about())); + restoreState(); + connect(ui->comboBoxTemplate, SIGNAL(currentIndexChanged(const QString&)), + this, SLOT(on_templateChangeIndex(const QString&))); + connect(ui->pushButtonActivate, SIGNAL(clicked()), this, SLOT(activate())); + restoreState(); +} + +/** + * @brief Destructor + */ +MainWindow::~MainWindow(){ + delete ui; + delete m_converter; +} +/** + * Slot when the pushbutton "activate" is clicked. + */ +void MainWindow::activate(){ + int width = comboInt(ui->comboBoxMaxWidth, 0); + int height = comboInt(ui->comboBoxMaxHeight, 0); + setMaxDimensions(width, height); +} + +/** + * Sets the maximal dimensions (from the "simple" interface). + * + * @param maxWidth the maximal width + * @param maxHeight the maximal height + */ +void MainWindow::setMaxDimensions(int maxWidth, int maxHeight){ + if (maxWidth > maxHeight){ + ui->comboBoxLandscapeX->setCurrentText(QString::number(maxWidth)); + ui->comboBoxLandscapeY->setCurrentText("*"); + ui->comboBoxPortraitX->setCurrentText("*"); + ui->comboBoxPortraitY->setCurrentText(QString::number(maxHeight)); + ui->comboBoxSquareX->setCurrentText(QString::number(maxHeight)); + }else{ + ui->comboBoxLandscapeY->setCurrentText(QString::number(maxHeight)); + ui->comboBoxLandscapeX->setCurrentText("*"); + ui->comboBoxPortraitY->setCurrentText("*"); + ui->comboBoxPortraitX->setCurrentText(QString::number(maxWidth)); + ui->comboBoxSquareX->setCurrentText(QString::number(maxWidth)); + } } /** @@ -78,18 +100,21 @@ MainWindow::MainWindow(QWidget *parent) : */ void MainWindow::selectDestination(){ QString dir = QFileDialog::getExistingDirectory(this, - tr("Select Destination Directory"), ui->comboTarget->currentText(), + tr("Select Destination Directory"), ui->comboBoxTarget->currentText(), QFileDialog::ShowDirsOnly); if (!dir.isEmpty()) - ui->comboTarget->setCurrentText(dir); + ui->comboBoxTarget->setCurrentText(dir); } /** - * @brief Destructor + * Selects the destination directory with a dialog. */ -MainWindow::~MainWindow(){ - delete ui; - delete m_converter; +void MainWindow::selectSource(){ + QString dir = QFileDialog::getExistingDirectory(this, + tr("Select Source Directory"), ui->comboBoxSourceDir->currentText(), + QFileDialog::ShowDirsOnly); + if (!dir.isEmpty()) + ui->comboBoxSourceDir->setCurrentText(dir); } /** @@ -101,63 +126,87 @@ void MainWindow::about(){ } /** - * @brief Logs a message - * - * @param message the message to log - * @return true + * initializeHomeializes the program home directory. */ -bool MainWindow::log(const QString& message){ - ui->listWidget->insertItem(0, message); - return true; +void MainWindow::initializeHome(){ + if (m_homeDir.isEmpty()){ + m_homeDir = QDir::home().absoluteFilePath(".reimgconvert"); + } + + QDir home(m_homeDir); + if (!home.exists()){ + if (!home.mkpath(m_homeDir)){ + m_homeDir = home.tempPath() + "/.reimgconvert"; + home.mkpath(m_homeDir); + } + } + if (!m_homeDir.endsWith("/")) + m_homeDir += "/"; + m_storageFile = m_homeDir + "state.conf"; + restoreState(); } /** - * @brief Logs a message + * @brief Handles the click on the button "stop". + */ +void MainWindow::on_pushButtonStop_clicked(){ + m_converter->stop(); + ui->pushButtonConvert->show(); + ui->pushButtonStop->hide(); +} + +/** + * @brief Handles the click on the button "file select". * - * @param message the message to log - * @return true + * Shows a selection dialog for directories and sets the source directory + * onto the selected directory. */ -bool MainWindow::logAppendLast(const QString& message){ - QListWidgetItem* item = ui->listWidget->item(0); - item->setText(item->text() + " " + message); - return true; +void MainWindow::on_pushButtonFileSelect_clicked(){ + QFileDialog selection; + selection.setFileMode(QFileDialog::DirectoryOnly); + QString dir = ui->comboBoxSourceDir->currentText(); + if (!dir.isEmpty()) + selection.setDirectory(dir); + if (selection.exec()) + ui->comboBoxSourceDir->setCurrentText(selection.selectedFiles().at(0)); } /** - * Enables/disables the buttons/actions relevant for running. + * Slot when the value of the template combobox has been changed. * - * @param runActive true: the conversion is possible + * @param text the new selected combobox text */ -void MainWindow::switchRun(bool runActive){ - if (runActive){ - ui->buttonConvert->show(); - ui->buttonStop->hide(); - }else{ - ui->buttonConvert->hide(); - ui->buttonStop->show(); - } - ui->actionConvert->setEnabled(runActive); - ui->actionStop->setEnabled(not runActive); +void MainWindow::on_templateChangeIndex(const QString & text){ + QRegularExpression rexpr("(\\d+)x(\\d+)"); + QRegularExpressionMatch match = rexpr.match(text); + int width = match.captured(1).toInt(); + int height = match.captured(2).toInt(); + setMaxDimensions(width, height); } /** * @brief Handles the button click on "convert". */ -void MainWindow::on_buttonConvert_clicked(){ +void MainWindow::on_pushButtonConvert_clicked(){ switchRun(false); delete m_converter; - m_converter = new Converter(ui->comboSourceDir->currentText(), - ui->comboLandscapeX->currentText(), - ui->comboBoxSourcePattern->currentText(), - ui->comboBoxDestType->currentText(), - atol(ui->comboLandscapeX->currentText().toLatin1().constData()), - atol(ui->comboLandscapeY->currentText().toLatin1().constData()), - atol(ui->comboPortraitX->currentText().toLatin1().constData()), - atol(ui->comboPortraitY->currentText().toLatin1().constData()), - atol(ui->comboSquareX->currentText().toLatin1().constData()), - atol(ui->comboQuality->currentText().toLatin1().constData()), this); - // start the thread: - m_converter->start(); + m_errors = 0; + int landscapeX = comboInt(ui->comboBoxLandscapeX, 0, "*", 0); + int landscapeY = comboInt(ui->comboBoxLandscapeY, 0, "*", 0); + int portraitX = comboInt(ui->comboBoxPortraitX, 0, "*", 0); + int portraitY = comboInt(ui->comboBoxPortraitY, 0, "*", 0); + int squareX = comboInt(ui->comboBoxSquareX, 0); + int quality = comboInt(ui->comboBoxQuality, 70); + if (m_errors == 0){ + m_converter = new Converter(ui->comboBoxSourceDir->currentText(), + ui->comboBoxLandscapeX->currentText(), + ui->comboBoxSourcePattern->currentText(), + ui->comboBoxDestType->currentText(), landscapeX, landscapeY, portraitX, + portraitY, squareX, quality, this); + // start the thread: + m_converter->start(); + } + } /** @@ -169,8 +218,8 @@ void MainWindow::on_buttonConvert_clicked(){ void MainWindow::on_threadStateChanged(Converter::State state, const QString&){ switch (state) { case Converter::STATE_READY: - ui->buttonConvert->show(); - ui->buttonStop->hide(); + ui->pushButtonConvert->show(); + ui->pushButtonStop->hide(); //ui->statusBar->showMessage(info); break; case Converter::STATE_SUB_TASK_STOPPED: @@ -180,30 +229,95 @@ void MainWindow::on_threadStateChanged(Converter::State state, const QString&){ default: break; } +} +/** + * @brief Logs a message + * + * @param message the message to log + * @return true + */ +bool MainWindow::log(const QString& message){ + ui->listWidget->insertItem(0, message); + return true; } + /** - * @brief Handles the click on the button "stop". + * @brief Logs a message + * + * @param message the message to log + * @return true */ -void MainWindow::on_buttonStop_clicked(){ - m_converter->stop(); - ui->buttonConvert->show(); - ui->buttonStop->hide(); +bool MainWindow::logAppendLast(const QString& message){ + QListWidgetItem* item = ui->listWidget->item(0); + item->setText(item->text() + " " + message); + return true; } /** - * @brief Handles the click on the button "file select". + * Reads the history of the widget values and other parameters and set it. + */ +void MainWindow::restoreState(){ + ReStateStorage storage(m_storageFile); + storage.setForm("main"); + storage.restore(ui->comboBoxMaxHeight, "comboBoxMaxHeight", true); + storage.restore(ui->comboBoxMaxWidth, "comboBoxMaxWidth", true); + storage.restore(ui->comboBoxSourcePattern, "comboBoxSourcePattern", true); + storage.restore(ui->comboBoxLandscapeX, "comboBoxLandscapeX", true); + storage.restore(ui->comboBoxLandscapeY, "comboBoxLandscapeY"); + storage.restore(ui->comboBoxPortraitX, "comboBoxPortraitX", true); + storage.restore(ui->comboBoxPortraitY, "comboBoxPortraitY", true); + storage.restore(ui->comboBoxQuality, "comboBoxQuality", true); + storage.restore(ui->comboBoxSourceDir, "comboBoxSourceDir", true); + storage.restore(ui->comboBoxSquareX, "comboBoxSquareX", true); + storage.restore(ui->comboBoxTarget, "comboBoxTarget", true); + storage.close(); +} + +/** + * Stores the history of the widget values and other parameters. + */ +void MainWindow::saveState(){ + ReStateStorage storage(m_storageFile); + storage.setForm("main"); + storage.store(ui->comboBoxMaxHeight, "comboBoxMaxHeight"); + storage.store(ui->comboBoxMaxWidth, "comboBoxMaxWidth"); + storage.store(ui->comboBoxSourcePattern, "comboBoxSourcePattern"); + storage.store(ui->comboBoxLandscapeX, "comboBoxLandscapeX"); + storage.store(ui->comboBoxLandscapeY, "comboBoxLandscapeY"); + storage.store(ui->comboBoxPortraitX, "comboBoxPortraitX"); + storage.store(ui->comboBoxPortraitY, "comboBoxPortraitY"); + storage.store(ui->comboBoxQuality, "comboBoxQuality"); + storage.store(ui->comboBoxSourceDir, "comboBoxSourceDir"); + storage.store(ui->comboBoxSquareX, "comboBoxSquareX"); + storage.store(ui->comboBoxTarget, "comboBoxTarget"); + storage.close(); +} + +/** + * Writes a text to the status line. * - * Shows a selection dialog for directories and sets the source directory - * onto the selected directory. + * @param error true: the message is an error message + * @param message the text to set */ -void MainWindow::on_buttonFileSelect_clicked(){ - QFileDialog selection; - selection.setFileMode(QFileDialog::DirectoryOnly); - QString dir = ui->comboSourceDir->currentText(); - if (!dir.isEmpty()) - selection.setDirectory(dir); - if (selection.exec()) - ui->comboSourceDir->setCurrentText(selection.selectedFiles().at(0)); +void MainWindow::setStatusMessage(bool error, const QString& message){ + m_statusMessage->setText(message); +} + +/** + * Enables/disables the buttons/actions relevant for running. + * + * @param runActive true: the conversion is possible + */ +void MainWindow::switchRun(bool runActive){ + if (runActive){ + ui->pushButtonConvert->show(); + ui->pushButtonStop->hide(); + }else{ + ui->pushButtonConvert->hide(); + ui->pushButtonStop->show(); + } + ui->actionConvert->setEnabled(runActive); + ui->actionStop->setEnabled(not runActive); } diff --git a/appl/reimgconvert/mainwindow.hpp b/appl/reimgconvert/mainwindow.hpp index 43f957f..637f568 100644 --- a/appl/reimgconvert/mainwindow.hpp +++ b/appl/reimgconvert/mainwindow.hpp @@ -12,16 +12,20 @@ #include #include #include +#include #include "converter.hpp" +#include "gui/regui.hpp" namespace Ui { class MainWindow; } -class MainWindow: public QMainWindow, public ConvertLogger { +class MainWindow: public QMainWindow, + public ReGuiValidator, + public ConvertLogger { Q_OBJECT public: - explicit MainWindow(QWidget *parent = 0); + explicit MainWindow(const QString& homeDir, QWidget *parent = 0); ~MainWindow(); public: @@ -31,16 +35,28 @@ public: } bool log(const QString& message); bool logAppendLast(const QString& message); - void switchRun(bool runActive);private slots: + void setStatusMessage(bool error, const QString& message); + void switchRun(bool runActive); +private: + void initializeHome(); + void restoreState(); + void saveState(); + void setMaxDimensions(int maxWidth, int maxHeight);public slots: + void on_threadStateChanged(Converter::State state, const QString& info);private slots: + void activate(); void about(); - void on_buttonFileSelect_clicked(); - void on_buttonStop_clicked(); - void on_buttonConvert_clicked(); - void selectDestination();public slots: - void on_threadStateChanged(Converter::State state, const QString& info); + void on_pushButtonFileSelect_clicked(); + void on_pushButtonStop_clicked(); + void on_pushButtonConvert_clicked(); + void on_templateChangeIndex(const QString& text); + void selectDestination(); + void selectSource(); private: + QString m_homeDir; + QString m_storageFile; Ui::MainWindow *ui; Converter* m_converter; + QLabel* m_statusMessage; }; #endif // MAINWINDOW_HPP diff --git a/appl/reimgconvert/mainwindow.ui b/appl/reimgconvert/mainwindow.ui index 34b0e9b..63681a2 100644 --- a/appl/reimgconvert/mainwindow.ui +++ b/appl/reimgconvert/mainwindow.ui @@ -6,8 +6,8 @@ 0 0 - 772 - 556 + 799 + 651 @@ -17,126 +17,144 @@ - Bilder verkleinern V1.0 + ReImgConvert - - - - - - + + + + 11 + 11 + 787 + 647 + + + + + + + + 0 + 150 + + + + + 16777215 + 150 + + + + 0 + + + + Dimensions (quick) + + - + - + - 230 - 100 + 100 + 0 - 230 - 100 + 100 + 16777215 - - Portrait: + + Template: - - - - 2 - 30 - 221 - 61 - + + + + + + + Website: 1024x768 - - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - Max. Width: - - - - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - true - - - - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - Max. Height: - - - - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - true - - - - - + + + + Website II: 800x600 + + + + + Photo: 2048x1536 + + + + + Photo II: 3072x2304 + + + + + Midi: 600x400 + + + + + Mini: 150x100 + + + + + + - + + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + Max. Width: + + + + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + true + + + + + + + Qt::Horizontal @@ -149,114 +167,49 @@ - - - - 230 - 100 - - - - - 230 - 100 - - - - Landscape: - - - - - 3 - 31 - 221 - 61 - - - - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - Max. Width: - - - - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - true - - - - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - Max. Height: - - - - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - true - - - - - - + + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + Max. Height: + + + + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + true + + + + - + Qt::Horizontal @@ -269,31 +222,353 @@ - - - - 150 - 100 - - - - - 150 - 100 - - - - Square: + + + &Activate - - - - 0 - 60 - 100 - 26 - - + + + + + + + + + Dimensions (separated) + + + + + + + 230 + 100 + + + + + 230 + 100 + + + + Portrait: + + + + + 2 + 30 + 221 + 61 + + + + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + Max. Width: + + + + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + true + + + + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + Max. Height: + + + + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + true + + + + + + + + + + + Qt::Horizontal + + + + 48 + 20 + + + + + + + + + 230 + 100 + + + + + 230 + 100 + + + + Landscape: + + + + + 3 + 31 + 221 + 61 + + + + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + Max. Width: + + + + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + true + + + + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + Max. Height: + + + + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + true + + + + + + + + + + + Qt::Horizontal + + + + 47 + 20 + + + + + + + + + 150 + 100 + + + + + 150 + 100 + + + + Square: + + + + + 0 + 60 + 100 + 26 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + true + + + + + + 0 + 40 + 141 + 18 + + + + Max. Width/Height: + + + + + + groupBox_2 + groupBox_3 + groupBox + horizontalSpacer + + + + + + + + 0 + 150 + + + + + 16777215 + 150 + + + + Others: + + + + QLayout::SetFixedSize + + + + + + + 100 @@ -306,235 +581,52 @@ 16777215 - - true - - - - - - 0 - 40 - 141 - 18 - - - Max. Width/Height: + Quality (%) - - - - - - - - - - - 0 - 150 - - - - - 16777215 - 999999 - - - - Others: - - - - - - - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - Quality (%) - - - - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - true - - - - - - - - Qt::Horizontal - - + + + - 40 - 20 + 100 + 0 - - - - - - QFormLayout::AllNonFixedFieldsGrow - - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - File Pattern: - - - - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - A pattern of the source files with wildcards '*' (anything) and '?' (exact one char) - - - true - - - - *.jpg - - - - - *.png - - - - - *.gif - - - - - - - - - - Qt::Horizontal - - + - 40 - 20 + 100 + 16777215 - - - - - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - Dest. Type: - - - - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - - jpg - - - - - png - - - - - + + true + + - - - + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + QFormLayout::AllNonFixedFieldsGrow + + + 100 @@ -548,212 +640,204 @@ - Destination: + File Pattern: - - + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + A pattern of the source files with wildcards '*' (anything) and '?' (exact one char) + true - - - + + + *.jpg + + + + + *.png + + + + + *.gif + + - - + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + - 50 + 100 0 - 50 + 100 16777215 - ... + Dest. Type: - - - - - - + + + + + 100 + 0 + + + + + 100 + 16777215 + + - - - - 100 - 0 - - - - - 100 - 16777215 - - - - Template: - - + + jpg + - - - - Website: 1024x768 - - - - - Website II: 800x600 - - - - - Photo: 2048x1536 - - - - - Photo II: 3072x2304 - - - - - Midi: 600x400 - - - - - Mini: 150x100 - - - + + png + - + - - + + + + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + Destination: + + + + + + + true + + + + + + + + + + + 50 + 0 + + + + + 50 + 16777215 + + + + ... + + + + + + + + + + - + - - - - - Source Directory (Images): - - - - - - - - - true - - - /tmp/img - - - - - - - - 30 - 16777215 - - - - Auswahldialog - - - ... - - - - - - + + + Source Directory (Images): + + - + - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - 150 - 0 - - - - - 150 - 16777215 - - - - Alle Bilder aus dem Quellverzeichnis konvertieren und im Zielverzeichnis ablegen + + + true - - &Convert - - - - :/main/icons/action_go.png:/main/icons/action_go.png + + /tmp/img - - - - 150 - 0 - - + - 150 + 30 16777215 - Alle Bilder aus dem Quellverzeichnis konvertieren und im Zielverzeichnis ablegen + Auswahldialog - &Stop - - - - :/main/icons/cancel.png:/main/icons/cancel.png + ... @@ -762,21 +846,91 @@ - + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + 150 + 0 + + + + + 150 + 16777215 + + + + Alle Bilder aus dem Quellverzeichnis konvertieren und im Zielverzeichnis ablegen + + + &Convert + + + + :/main/icons/action_go.png:/main/icons/action_go.png + + + + + + + + 150 + 0 + + + + + 150 + 16777215 + + + + Alle Bilder aus dem Quellverzeichnis konvertieren und im Zielverzeichnis ablegen + + + &Stop + + + + :/main/icons/cancel.png:/main/icons/cancel.png + + + + - listWidget - groupBox_4 - - - + + + + + + listWidget + groupBox_4 + tabWidget + 0 0 - 772 + 799 23 @@ -830,6 +984,17 @@ + + + toolBar_2 + + + TopToolBarArea + + + false + + diff --git a/appl/reimgconvert/reimgconvert.pro b/appl/reimgconvert/reimgconvert.pro index 075cbef..03d87e6 100644 --- a/appl/reimgconvert/reimgconvert.pro +++ b/appl/reimgconvert/reimgconvert.pro @@ -17,18 +17,29 @@ SOURCES += main.cpp\ ../../base/ReException.cpp \ ../../base/ReQStringUtil.cpp \ ../../base/ReLogger.cpp \ + ../../gui/ReStateStorage.cpp \ + ../../gui/ReGuiValidator.cpp \ mainwindow.cpp \ converter.cpp \ - aboutdialog.cpp + aboutdialog.cpp HEADERS += mainwindow.hpp \ + ../../base/rebase.hpp \ + ../../base/ReQStringUtil.hpp \ + ../../gui/ReStateStorage.hpp \ + ../../gui/ReGuiValidator.hpp \ + ../../gui/regui.hpp \ converter.hpp \ - aboutdialog.hpp + aboutdialog.hpp FORMS += mainwindow.ui \ - aboutdialog.ui + aboutdialog.ui RESOURCES += \ reimgconvert.qrc +TRANSLATIONS = reimgconvert_de.ts + +CODECFORSRC = UTF-8 + OTHER_FILES += diff --git a/gui/ReGuiValidator.cpp b/gui/ReGuiValidator.cpp index 8c985e8..2f90347 100644 --- a/gui/ReGuiValidator.cpp +++ b/gui/ReGuiValidator.cpp @@ -55,19 +55,26 @@ QDateTime ReGuiValidator::comboDate(QComboBox* combo){ * * @param combo the combobox with the integer * @param defaultValue the value if the combobox is empty or invalid + * @param specialString NULL or a (non integer) string which is allowed + * @param specialValue the value which is returned if specialString is found * @return defaultValue: empty or invalid input
* otherwise: or the size resulting from the formula */ -int ReGuiValidator::comboInt(QComboBox* combo, int defaultValue){ +int ReGuiValidator::comboInt(QComboBox* combo, int defaultValue, + const char* specialString, int specialValue){ QString value = combo->currentText(); int rc = defaultValue; if (!value.isEmpty()){ - uint nValue = 0; - if (ReQStringUtil::lengthOfUInt(value, 0, 10, &nValue) == 0) - guiError(combo, QObject::tr("not an integer: ") + value); - else{ - setInHistory(combo, value); - rc = (int) nValue; + if (specialString != NULL && value == specialString){ + rc = specialValue; + }else{ + uint nValue = 0; + if (ReQStringUtil::lengthOfUInt(value, 0, 10, &nValue) == 0) + guiError(combo, QObject::tr("not an integer: ") + value); + else{ + setInHistory(combo, value); + rc = (int) nValue; + } } } return rc; diff --git a/gui/ReGuiValidator.hpp b/gui/ReGuiValidator.hpp index 59e6697..fb4d077 100644 --- a/gui/ReGuiValidator.hpp +++ b/gui/ReGuiValidator.hpp @@ -21,7 +21,8 @@ public: ~ReGuiValidator(); public: QDateTime comboDate(QComboBox* combo); - int comboInt(QComboBox* combo, int defaultValue); + int comboInt(QComboBox* combo, int defaultValue, const char* specialString = + NULL, int specialValue = 0); int64_t comboSize(QComboBox* combo); QString comboText(QComboBox* combo); virtual void guiError(QWidget* widget, const QString& message); -- 2.39.5