#include <QRegularExpression>
#include <QPixmap>
+enum {
+ LOC_CONSTRUCTOR_1 = LOC_FIRST_OF(LOC_REIMGCONVERTER_CONVERTER), // 20401
+};
+
/** @file
*
* @section intro_sec Introduction
bool Converter::m_shouldStop = false;
QStringList Converter::m_files;
-uint64_t Converter::m_totalBytes = 0;
+qint64 Converter::m_totalBytes = 0;
int Converter::m_totalFiles = 0;
bool Converter::m_searchReady = false;
QMutex Converter::m_mutex;
* @param heightNew the new height of the image
* @param quality 0 or quality in % (only for JPEG targets)
*/
-void TaskConverter::callExternProgram(const QString& source, const QString& target, int width,
+void TaskConverter::callExternalProgram(const QString& source, const QString& target, int width,
int height, int widthNew, int heightNew, int quality){
QStringList args;
// convert -size 100x200 source.png -resize 50x100 target.jpg";
handleSimple(width, height, widthNew, heightNew);
else
handleUserDefined(width, height, widthNew, heightNew);
- QString node = ReFileUtils::nodeOf(source);
+ QString relPath = source.mid(m_sourceDir.length());
log(
- node + " " + info + " " + ReQStringUtils::readableSize(size)
+ relPath + " " + ReQStringUtils::readableSize(size)
+ QString(" -> %1x%2 ").arg(widthNew).arg(heightNew));
- callExternProgram(source, target, width, height, widthNew, heightNew, m_quality);
+ callExternalProgram(source, target, width, height, widthNew, heightNew, m_quality);
struct stat info;
if (stat(I18N::s2b(target).constData(), &info) == 0){
sizeTarget = info.st_size;
- m_mainWindow->logAppendLast(ReQStringUtils::readableSize(sizeTarget)
+ m_mainWindow->externalAppend(ReGuiQueueItem::ListAppendToCurrent,
+ NULL, ReQStringUtils::readableSize(sizeTarget)
+ " " + ReQStringUtils::readableDuration(
clock() - start));
}
void TaskConverter::run(){
QString msg;
clock_t start = clock();
- uint64_t preSize = 0;
- uint64_t postSize = 0;
- uint64_t lengthTarget = 0;
+ qint64 preSize = 0;
+ qint64 postSize = 0;
+ qint64 lengthTarget = 0;
int no = 0;
QString info;
QString node;
QString targetDir;
try{
- while (! m_shouldStop && ! m_searchReady){
+ while (! m_shouldStop){
m_mutex.lock();
if (m_files.size() == 0)
info.clear();
}
m_mutex.unlock();
if (info.isEmpty()){
- QThread::sleep(50);
+ if (m_searchReady)
+ break;
+ else
+ QThread::sleep(50);
} else {
int ix = info.indexOf('\t');
node = info.mid(ix + 1);
preSize += length;
postSize += lengthTarget;
int percentFiles = int(no * 100 / max(1, m_totalFiles));
- int percentSize = int(preSize * 100 / max(1, m_totalBytes));
- m_mainWindow->setStatusMessage(LOG_INFO,
- tr("%1 file(s) of %2 (%3 %), %4 -> %5 (%6 %)")
- .arg(no).arg(m_totalFiles)
- .arg(percentFiles + percentSize / 2)
- .arg(ReQStringUtils::readableSize(preSize))
- .arg(ReQStringUtils::readableSize(postSize))
- .arg(postSize * 100.0 / max(1, preSize), 0,
- 'f', 2));
+ int percentSize = int(preSize * 100 / max(1, min(preSize, m_totalBytes)));
+ int percent = preSize > m_totalBytes ? percentFiles
+ : (2 * percentFiles + percentSize) / 3;
+ info = tr("%1 file(s) of %2 (%3 %), %4 -> %5 (%6 %)")
+ .arg(no).arg(m_totalFiles)
+ .arg(percent)
+ .arg(ReQStringUtils::readableSize(preSize))
+ .arg(ReQStringUtils::readableSize(postSize))
+ .arg(postSize * 100.0 / max(1LL, preSize), 0,
+ 'f', 1);
+ m_mainWindow->externalStatusMessage(LOG_INFO, info);
}
}
QObject::tr("Execution stopped because of error(s): ")
+ exc.message());
}
- preSize = max(1, preSize);
- msg = QObject::tr("%1 file(s) converted, %2 -> %3 (%4 %), duration: %5").arg(no)
+ preSize = max(1LL, preSize);
+ msg = QObject::tr("%1 of %2 file(s) converted, %3 -> %4 (%5 %), duration: %6")
+ .arg(no).arg(m_totalFiles)
.arg(ReQStringUtils::readableSize(preSize))
.arg(ReQStringUtils::readableSize(postSize))
- .arg(postSize * 100.0 / preSize, 0, 'f', 2)
+ .arg(postSize * 100.0 / preSize, 0, 'f', 1)
.arg(ReQStringUtils::readableDuration(clock() - start));
- m_mainWindow->finishTask(msg);
+ m_mainWindow->externalTaskFinished(msg);
}
/**
*
* @param dir the directory to inspect
*/
-void TaskSearch::searchOneDirectory(const QString& dir){
+void TaskSearch::processOneDirectory(const QString& dir){
QDirIterator it(dir);
QRegExp regExpr(m_sourcePattern, Qt::CaseInsensitive, QRegExp::Wildcard);
QString relPath;
QString info;
- if (dir.length() > m_sourceDir.length())
- relPath = m_sourceDir.mid(m_sourceDir.length());
+ if (dir.length() > m_sourceDir.length()){
+ relPath = dir.mid(m_sourceDir.length() + 1) + OS_SEPARATOR_STR;
+ }
while (it.hasNext()){
if (m_shouldStop){
break;
info = relPath + "\t" + it.fileName();
m_mutex.lock();
m_files.append(info);
+ m_totalFiles++;
+ m_totalBytes += it.fileInfo().size();
m_mutex.unlock();
}
}
if (m_recursive && ! m_shouldStop){
QDirIterator it2(dir);
+ QString node;
while (it2.hasNext()){
if (m_shouldStop){
break;
}
it2.next();
- if (it2.fileInfo().isDir()){
- searchOneDirectory(it2.filePath());
+ if (it2.fileInfo().isDir() && (node = it2.fileName()) != "." && node != ".."){
+ processOneDirectory(it2.filePath());
}
}
}
*/
void TaskSearch::run(){
m_searchReady = false;
- searchOneDirectory(m_sourceDir);
+ m_totalBytes = 0;
+ m_totalFiles = 0;
+ processOneDirectory(m_sourceDir);
m_searchReady = true;
}
QRegExp regExpr(m_sourcePattern, Qt::CaseInsensitive, QRegExp::Wildcard);
QString relPath;
QString info;
- if (dir.length() > m_sourceDir.length())
- relPath = m_sourceDir.mid(m_sourceDir.length());
+ if (dir.length() > m_sourceDir.length()){
+ relPath = dir.mid(m_sourceDir.length() + 1) + OS_SEPARATOR_STR;
+ }
while (it.hasNext()){
if (m_shouldStop){
break;
if (! it.fileInfo().isDir() && regExpr.indexIn(it.fileName()) < 0){
info = relPath + it.fileName();
m_totalFiles++;
- m_mainWindow->remoteLog(info);
+ m_mainWindow->externalLog(info);
}
}
if (m_recursive && ! m_shouldStop){
QDirIterator it2(dir);
+ QString node;
while (it2.hasNext()){
if (m_shouldStop){
break;
}
it2.next();
- if (it2.fileInfo().isDir()){
+ if (it2.fileInfo().isDir() && (node = it2.fileName()) != "." && node != ".."){
processOneDirectory(it2.filePath());
}
}
m_totalFiles = 0;
processOneDirectory(m_sourceDir);
m_searchReady = true;
- m_mainWindow->finishTask(tr("Found: %1 file(s)").arg(m_totalFiles));
+ m_mainWindow->externalTaskFinished(tr("Found: %1 file(s)").arg(m_totalFiles));
}
virtual void run();
protected:
bool buildArgs();
- void callExternProgram(const QString& source, const QString& target, int width,
+ void callExternalProgram(const QString& source, const QString& target, int width,
int height, int widthNew, int heightNew, int quality);
void converterTask();
void convertOneFile(const QString& source, const QString& target,
protected:
virtual void run();
protected:
- void searchOneDirectory(const QString& dir);
+ void processOneDirectory(const QString& dir);
private:
QString m_sourcePattern;
bool m_recursive;
#include "ui_mainwindow.h"
#include "aboutdialog.hpp"
-const QString VERSION("2016.01.15");
+const QString VERSION("2016.01.20");
/** @class MainWindow mainwindow.hpp "mainwindow.hpp"
*
* @param parent NULL or the parent (who destroys the objects at the end)
*/
MainWindow::MainWindow(const QString& homeDir, QWidget *parent) :
- ReHomeApplication("reimgconvert", homeDir, 2, 100100100, parent),
+ ReGuiApplication("reimgconvert", homeDir, 2, 100100100, parent),
ui(new Ui::MainWindow),
m_taskConvert(NULL),
m_taskSearch(NULL),
- m_taskShowOther(NULL),
- m_logger(),
- m_guiQueue(),
- m_guiTimer(new QTimer(this)){
+ m_taskShowOther(NULL)
+{
ui->setupUi(this);
+ initializeGuiElements();
startStop(false);
- m_statusMessage = new QLabel(tr("Welcome at reimgconvert"));
statusBar()->addWidget(m_statusMessage);
connect(ui->actionStart, SIGNAL(triggered()), this,
SLOT(onConvert()));
connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(about()));
connect(ui->comboBoxTemplate, SIGNAL(currentIndexChanged(const QString&)),
this, SLOT(onTemplateChangeIndex(const QString&)));
- connect(m_guiTimer, SIGNAL(timeout()), this, SLOT(guiTimerUpdate()));
connect(ui->pushButtonShowOtherFiles, SIGNAL(clicked()), this, SLOT(onShowOtherFiles()));
restoreState();
- m_guiTimer->start(100);
}
/**
}
/**
- * Finishs a task with sending a ready message.
- *
- * Note: the method is called from a non-main thread.
- *
- * @param message the message to show
- */
-void MainWindow::finishTask(const QString& message){
- Converter::m_mutex.lock();
- m_guiQueue.pushBack(ReGuiQueueItem(ReGuiQueueItem::ReadyMessage, NULL, message));
- Converter::m_mutex.unlock();
-}
-/**
- * Callback method of the GUI timer.
+ * Reads the <code>m_guiQueue</code> and put the info into the GUI elements.
*/
void MainWindow::guiTimerUpdate()
{
int count = m_guiQueue.count();
while(count-- > 0){
- Converter::m_mutex.lock();
+ m_mutexGuiQueue.lock();
ReGuiQueueItem item = m_guiQueue.popFront();
- Converter::m_mutex.unlock();
+ m_mutexGuiQueue.unlock();
if (item.m_type == ReGuiQueueItem::Undef)
break;
if (! item.apply()){
say(LOG_INFO, item.m_value);
break;
case ReGuiQueueItem::StatusLine:
- setStatusMessage(false, item.m_value);
+ externalStatusMessage(false, item.m_value);
break;
case ReGuiQueueItem::ListAppendToCurrent:
{
- QListWidgetItem* item2 = reinterpret_cast<QListWidget*>(
- item.m_widget)->currentItem();
+ QListWidgetItem* item2 = ui->listWidget->currentItem();
item2->setText(item2->text() + " " + item.m_value);
break;
}
return true;
}
-/**
- * @brief Logs a message
- *
- * Note: used by non main threads
- *
- * @param message the message to log
- * @return <code>true</code>
- */
-bool MainWindow::logAppendLast(const QString& message){
- Converter::m_mutex.lock();
- m_guiQueue.pushBack(ReGuiQueueItem(ReGuiQueueItem::ListAppendToCurrent,
- ui->listWidget, message));
- Converter::m_mutex.unlock();
- return true;
-}
-
/**
* @brief Handles the button click on "convert".
*/
delete m_taskSearch;
m_taskSearch = new TaskSearch(ui->comboBoxSourceDir->currentText(),
ui->comboBoxSourcePattern->currentText(),
- ui->checkBoxCopyOtherFiles->isChecked(), this);
+ ui->checkBoxRecursive->isChecked(), this);
m_taskSearch->start();
delete m_taskConvert;
delete m_taskShowOther;
m_taskShowOther = new TaskShowOther(ui->comboBoxSourceDir->currentText(),
ui->comboBoxSourcePattern->currentText(),
- ui->checkBoxCopyOtherFiles->isChecked(), this);
+ ui->checkBoxRecursive->isChecked(), this);
m_taskShowOther->start();
}
/**
int height = match.captured(2).toInt();
setMaxDimensions(width, height);
}
-
-/**
- * Writes a text to the log.
- *
- * Note: this method is called from a non-main thread
- *
- * @param message the text to set
- */
-void MainWindow::remoteLog(const QString& message){
- Converter::m_mutex.lock();
- m_guiQueue.pushBack(ReGuiQueueItem(ReGuiQueueItem::ListEnd,
- ui->listWidget, message));
- Converter::m_mutex.unlock();
-}
/**
* Reads the history of the widget values and other parameters and set it.
*/
ui->comboBoxTargetDir->setCurrentText(dir);
}
-/**
- * Writes a text to the status line.
- *
- * Note: this method is called from a non-main thread
- *
- * @param message the text to set
- */
-void MainWindow::setRemoteStatus(const QString& message){
- Converter::m_mutex.lock();
- m_guiQueue.pushBack(ReGuiQueueItem(ReGuiQueueItem::StatusLine,
- NULL, message));
- Converter::m_mutex.unlock();
-}
-
/**
* Writes a text to the status line.
*
* @param error <code>true</code>: the message is an error message
* @param message the text to set
*/
-void MainWindow::setStatusMessage(bool error, const QString& message){
+void MainWindow::externalStatusMessage(bool error, const QString& message){
RE_UNUSED(error);
m_statusMessage->setText(message);
}
class MainWindow;
}
-class MainWindow: public ReHomeApplication,
+class MainWindow: public ReGuiApplication,
public ReGuiValidator,
public ConvertLogger {
Q_OBJECT
public:
virtual void aboutToQuit();
bool error(const QString& message);
- void finishTask(const QString& message);
bool log(const QString& message);
- bool logAppendLast(const QString& message);
- void remoteLog(const QString& message);
- void setRemoteStatus(const QString& message);
- void setStatusMessage(bool error, const QString& message);
+ void externalStatusMessage(bool error, const QString& message);
public:
virtual bool say(ReLoggerLevel level, const QString& message);
private:
TaskConverter* m_taskConvert;
TaskSearch* m_taskSearch;
TaskShowOther* m_taskShowOther;
- QLabel* m_statusMessage;
- ReLogger m_logger;
- ReGuiQueue m_guiQueue;
- QTimer* m_guiTimer;
};
#endif // MAINWINDOW_HPP
<attribute name="title">
<string>Dimensions (quick)</string>
</attribute>
- <widget class="QWidget" name="">
+ <widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>11</x>
</item>
</layout>
</widget>
- <widget class="QWidget" name="">
+ <widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>13</x>
</item>
<item>
<widget class="QCheckBox" name="checkBoxCopyOtherFiles">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
<property name="minimumSize">
<size>
<width>125</width>
TARGET = reimgconvert
TEMPLATE = app
-INCLUDEPATH = ../.. /usr/include/c++/4.9
+INCLUDEPATH += ../..
SOURCES += main.cpp\
../../base/ReException.cpp \
../../gui/ReStateStorage.cpp \
../../gui/ReGuiValidator.cpp \
../../gui/ReGuiQueue.cpp \
+ ../../gui/ReGuiApplication.cpp \
mainwindow.cpp \
converter.cpp \
aboutdialog.cpp
../../base/ReQStringUtils.hpp \
../../gui/ReStateStorage.hpp \
../../gui/ReGuiValidator.hpp \
+ ../../gui/ReGuiApplication.hpp \
../../gui/regui.hpp \
converter.hpp \
aboutdialog.hpp
OTHER_FILES +=
DISTFILES += \
- ReImgConvert.html
+ ReImgConvert.html
#include "base/rebase.hpp"
enum {
- LOC_DELETE_TREE_1 = LOC_FIRST_OF(LOC_FILE), // 11801
+ LOC_DELETE_TREE_1 = LOC_FIRST_OF(LOC_FILE_UTILS), // 11801
LOC_DELETE_TREE_2, // 11802
LOC_DELETE_TREE_3, // 11803
LOC_SET_TIMES_1, // 11804
QString ReQStringUtils::readableDuration(clock_t duration){
QString rc;
char buffer[128];
- int cl_per_sec = CLOCKS_PER_SEC;
double duration2 = (double) duration / CLOCKS_PER_SEC;
if (duration2 < 60.0){
rc = QString::number(duration2, 'f', 3) + " sec";
int min(int a, int b) {
return a < b ? a : b;
}
+inline
+int max(qint64 a, qint64 b) {
+ return a > b ? a : b;
+}
+inline
+int min(qint64 a, qint64 b) {
+ return a < b ? a : b;
+}
inline double max(double a, double b) {
return a > b ? a : b;
}
--- /dev/null
+/*
+ * ReStateStorage.cpp
+ *
+ * (Un)License: Public Domain
+ * You can use and modify this file without any restriction.
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * More info: http://unlicense.org
+ * The latest sources: https://github.com/republib
+ */
+#include "base/rebase.hpp"
+#include "gui/regui.hpp"
+#include <QCoreApplication>
+
+enum {
+ LOC_CONSTRUCTOR_1 = LOC_FIRST_OF(LOC_GUI_APPLICATION), // 12401
+ LOC_QUIT_1, // 12402
+};
+
+/**
+ * Constructor.
+ *
+ * @param applicationName the name of the application. Defines the node
+ * of the home directory
+ * @param homeDirBase "": the user's home directory will be used<br>
+ * otherwise: the home directory will created in this
+ * directory
+ * @param maxLogFiles max. count of (rotating) log files
+ * @param maxLogSize max. size of the (rotating) log files
+ */
+ReGuiApplication::ReGuiApplication(const char* applicationName,
+ const QString& homeDirBase,
+ int maxLogFiles, int maxLogSize,
+ QWidget *parent = NULL) :
+ QMainWindow(parent),
+ m_applicationName(applicationName),
+ m_homeDir(buildHomeDir(homeDirBase, ".reappl")),
+ m_logger(),
+ m_storageFile(),
+ m_guiQueue(),
+ m_guiTimer(new QTimer(this)),
+ m_statusMessage(new QLabel(tr("Welcome!"))),
+ m_mutexGuiQueue()
+{
+ m_logger.buildStandardAppender(I18N::s2b(m_homeDir) + applicationName,
+ maxLogSize, maxLogFiles);
+ m_storageFile = m_homeDir + applicationName + ".state.conf";
+ m_logger.log(LOG_INFO, LOC_CONSTRUCTOR_1, "start");
+}
+
+/**
+ * Callback method at the application's end.
+ */
+void ReGuiApplication::aboutToQuit()
+{
+ m_logger.log(LOG_INFO, LOC_QUIT_1, "end");
+}
+
+/**
+ * Build the home directory path name.
+ *
+ * @param homeDirBase "": the user's home directory will be used<br>
+ * otherwise: the home directory will created in this
+ * directory
+ * @param node
+ * @return
+ */
+QString ReGuiApplication::buildHomeDir(QString homeDirBase, const QString& node){
+ QString homeDir;
+ if (homeDirBase.isEmpty()){
+ homeDir = QDir::home().absoluteFilePath(node);
+ } else if (ReFileUtils::isRootDir(homeDirBase.toLatin1().constData())){
+ homeDir = homeDirBase + node;
+ }
+ ReQStringUtils::chomp(homeDir, OS_SEPARATOR);
+ QDir home(homeDir);
+ if (!home.exists()){
+ if (!home.mkpath(homeDir)){
+ homeDir = home.tempPath() + node;
+ home.mkpath(homeDir);
+ }
+ }
+ ReQStringUtils::ensureLastChar(homeDir, OS_SEPARATOR);
+ return homeDir;
+}
+/**
+ * Finishs a task with sending a ready message.
+ *
+ * Note: the method is called from a non-main thread.
+ *
+ * @param message the message to show
+ */
+void ReGuiApplication::externalTaskFinished(const QString& message){
+ m_mutexGuiQueue.lock();
+ m_guiQueue.pushBack(ReGuiQueueItem(ReGuiQueueItem::ReadyMessage, NULL, message));
+ m_mutexGuiQueue.unlock();
+}
+
+/**
+ * Initializes the GUI elements of this class.
+ *
+ * Should be called after initializing the formular (<code>ui->setupUi()</code>).
+ */
+void ReGuiApplication::initializeGuiElements(){
+ QCoreApplication* app = QCoreApplication::instance();
+ QObject::connect(app, SIGNAL(aboutToQuit()), this, SLOT(aboutToQuit()));
+ connect(m_guiTimer, SIGNAL(timeout()), this, SLOT(guiTimerUpdate()));
+ m_guiTimer->start(100);
+}
+
+/**
+ * @brief Logs a message
+ *
+ * Note: used by a non main thread.
+ *
+ * @param type the type of the queue entry
+ * @param widget NULL or the target widget
+ * @param info the info for the target widget
+ * @return <code>true</code>
+ */
+bool ReGuiApplication::externalAppend(ReGuiQueueItem::WidgetType type, QWidget* widget,
+ const QString& info){
+ m_mutexGuiQueue.lock();
+ m_guiQueue.pushBack(ReGuiQueueItem(type, widget, info));
+ m_mutexGuiQueue.unlock();
+ return true;
+}
+
+
+/**
+ * Writes a text to the log.
+ *
+ * Note: this method is called from a non-main thread
+ *
+ * @param message the text to set
+ */
+void ReGuiApplication::externalLog(const QString& message){
+ m_mutexGuiQueue.lock();
+ m_guiQueue.pushBack(ReGuiQueueItem(ReGuiQueueItem::LogMessage, NULL,
+ message));
+ m_mutexGuiQueue.unlock();
+}
+
--- /dev/null
+/*
+ * ReStateStorage.hpp
+ *
+ * (Un)License: Public Domain
+ * You can use and modify this file without any restriction.
+ * Do what you want.
+ * No warranties and disclaimer of any damages.
+ * More info: http://unlicense.org
+ * The latest sources: https://github.com/republib
+ */
+
+#ifndef REGUIAPPLICATION_HPP_
+#define REGUIAPPLICATION_HPP_
+
+#include <QMainWindow>
+
+/**
+ * An abstract base class for applications which stores their data in a home directory.
+ */
+class ReGuiApplication : public QMainWindow{
+public:
+ ReGuiApplication(const char* applicationName,
+ const QString& homeDir, int maxLogFiles, int maxLogSize,
+ QWidget *parent);
+public slots:
+ /**
+ * Callback method called when the application is closed.
+ */
+ void aboutToQuit();
+public:
+ static QString buildHomeDir(QString homeDirBase, const QString& node);
+ bool externalAppend(ReGuiQueueItem::WidgetType type, QWidget* widget, const QString& info);
+ void externalLog(const QString& message);
+ void externalTaskFinished(const QString& message);
+protected:
+ void initializeGuiElements();
+protected slots:
+ /**
+ * Reads the <code>m_guiQueue</code>.
+ */
+ virtual void guiTimerUpdate() = 0;
+protected:
+ QByteArray m_applicationName;
+ QString m_homeDir;
+ ReLogger m_logger;
+ QString m_storageFile;
+ ReGuiQueue m_guiQueue;
+ QTimer* m_guiTimer;
+ QLabel* m_statusMessage;
+ QMutex m_mutexGuiQueue;
+
+};
+
+#endif /* REGUIAPPLICATION_HPP_ */
public:
enum WidgetType {
Undef, LabelText, NewTableRow, ListEnd, ListAppendToCurrent,
- LogMessage, ReadyMessage, StatusLine,
+ LogMessage, LogError, ReadyMessage, StatusLine,
UserDefined1, UserDefined2
};
}
}
-/**
- * Constructor.
- *
- * @param applicationName the name of the application. Defines the node
- * of the home directory
- * @param homeDirBase "": the user's home directory will be used<br>
- * otherwise: the home directory will created in this
- * directory
- * @param maxLogFiles max. count of (rotating) log files
- * @param maxLogSize max. size of the (rotating) log files
- */
-ReHomeApplication::ReHomeApplication(const char* applicationName,
- const QString& homeDirBase,
- int maxLogFiles, int maxLogSize,
- QWidget *parent = NULL) :
- QMainWindow(parent),
- m_applicationName(applicationName),
- m_homeDir(buildHomeDir(homeDirBase, "." + m_applicationName)),
- m_logger(),
- m_storageFile()
-{
- m_logger.buildStandardAppender(I18N::s2b(m_homeDir) + "logger.",
- maxLogSize, maxLogFiles);
- m_storageFile = m_homeDir + OS_SEPARATOR_STR + "status.conf";
- m_storageFile = m_homeDir + "state.conf";
- QCoreApplication* app = QCoreApplication::instance();
- QObject::connect(app, SIGNAL(aboutToQuit()), this, SLOT(aboutToQuit()));
-}
-
-void ReHomeApplication::aboutToQuit()
-{
- m_logger.log(LOG_INFO, 999, "exit");
-}
-
-/**
- * Build the home directory path name.
- *
- * @param homeDirBase "": the user's home directory will be used<br>
- * otherwise: the home directory will created in this
- * directory
- * @param node
- * @return
- */
-QString ReHomeApplication::buildHomeDir(QString homeDirBase, const QString& node){
- QString homeDir;
- if (homeDirBase.isEmpty()){
- homeDir = QDir::home().absoluteFilePath(node);
- } else if (ReFileUtils::isRootDir(homeDirBase.toLatin1().constData())){
- homeDir = homeDirBase + node;
- }
- ReQStringUtils::chomp(homeDir, OS_SEPARATOR);
- QDir home(homeDir);
- if (!home.exists()){
- if (!home.mkpath(homeDir)){
- homeDir = home.tempPath() + node;
- home.mkpath(homeDir);
- }
- }
- ReQStringUtils::ensureLastChar(homeDir, OS_SEPARATOR);
- return homeDir;
-}
ReLogger* m_logger;
};
-/**
- * An abstract base class for applications which stores their data in a home directory.
- */
-class ReHomeApplication : public QMainWindow{
-public:
- ReHomeApplication(const char* applicationName,
- const QString& homeDir, int maxLogFiles, int maxLogSize,
- QWidget *parent);
-public slots:
- /**
- * Callback method called when the application is closed.
- */
- void aboutToQuit();
-public:
- static QString buildHomeDir(QString homeDirBase, const QString& node);
-protected:
- QByteArray m_applicationName;
- QString m_homeDir;
- ReLogger m_logger;
- QString m_storageFile;
-};
-
#endif /* GUI_RESTATESTORAGE_HPP_ */
#include <QTableWidget>
#include "gui/ReGuiQueue.hpp"
#include "gui/ReStateStorage.hpp"
+#include "gui/ReGuiApplication.hpp"
#include "gui/ReGuiValidator.hpp"
#include "gui/ReEdit.hpp"
#include "gui/ReSettings.hpp"
#include "gui/ReFileTree.hpp"
+
/**
* Tests whether a point is inside the rectangle (including border).
* @param rect rectangle to test
LOC_MFPARSER, // 115
LOC_TRAVERSER,
LOC_SETTINGS,
- LOC_FILE,
+ LOC_FILE_UTILS,
LOC_FILETREE,
LOC_STATESTORAGE, // 120
LOC_FILESYSTEM,
LOC_RANDOMIZER,
LOC_CRYPTFILESYSTEM,
+ LOC_GUI_APPLICATION,
// Applications:
LOC_RECFORM_CPPPARSER = 201,
LOC_RECFORM_CPPFORMATTER = 202,
+ LOC_REIMGCONVERTER_ = 203,
+ LOC_REIMGCONVERTER_CONVERTER = 204,
};
#define LOC_FIRST_OF(moduleNo) (moduleNo*100+1)
class RplModules {