From 798bd883ffdf09407c4c5a9d83dae7555584f415 Mon Sep 17 00:00:00 2001 From: hama Date: Sun, 14 Feb 2016 11:36:34 +0100 Subject: [PATCH] proj. example, rebackgui: fix for clean --- appl/example/aboutdialog.cpp | 23 ++++ appl/example/aboutdialog.hpp | 32 +++++ appl/example/aboutdialog.ui | 117 ++++++++++++++++++ appl/example/example.hpp | 19 +++ appl/example/example.pro | 47 ++++++++ appl/example/main.cpp | 24 ++++ appl/example/mainwindow.cpp | 207 ++++++++++++++++++++++++++++++++ appl/example/mainwindow.hpp | 49 ++++++++ appl/example/mainwindow.ui | 85 +++++++++++++ appl/rebackgui/BackupEngine.cpp | 57 ++++----- appl/rebackgui/mainwindow.cpp | 17 +-- base/ReQStringUtils.cpp | 7 +- gui/ReGuiApplication.cpp | 6 +- gui/ReGuiApplication.hpp | 6 +- gui/regui.hpp | 1 + 15 files changed, 650 insertions(+), 47 deletions(-) create mode 100644 appl/example/aboutdialog.cpp create mode 100644 appl/example/aboutdialog.hpp create mode 100644 appl/example/aboutdialog.ui create mode 100644 appl/example/example.hpp create mode 100644 appl/example/example.pro create mode 100644 appl/example/main.cpp create mode 100644 appl/example/mainwindow.cpp create mode 100644 appl/example/mainwindow.hpp create mode 100644 appl/example/mainwindow.ui diff --git a/appl/example/aboutdialog.cpp b/appl/example/aboutdialog.cpp new file mode 100644 index 0000000..eedd0a8 --- /dev/null +++ b/appl/example/aboutdialog.cpp @@ -0,0 +1,23 @@ +/* + * aboutdialog.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 "aboutdialog.hpp" +#include "ui_aboutdialog.h" + +AboutDialog::AboutDialog(const QString& version, QWidget *parent) : + QDialog(parent), ui(new Ui::AboutDialog){ + ui->setupUi(this); + ui->labelVersion->setText(version); +} + +AboutDialog::~AboutDialog(){ + delete ui; +} diff --git a/appl/example/aboutdialog.hpp b/appl/example/aboutdialog.hpp new file mode 100644 index 0000000..bf51cc7 --- /dev/null +++ b/appl/example/aboutdialog.hpp @@ -0,0 +1,32 @@ +/* + * aboutdialog.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 ABOUTDIALOG_HPP +#define ABOUTDIALOG_HPP + +#include + +namespace Ui { +class AboutDialog; +} + +class AboutDialog: public QDialog { + Q_OBJECT + +public: + explicit AboutDialog(const QString& version, QWidget *parent = 0); + ~AboutDialog(); + +private: + Ui::AboutDialog *ui; +}; + +#endif // ABOUTDIALOG_HPP diff --git a/appl/example/aboutdialog.ui b/appl/example/aboutdialog.ui new file mode 100644 index 0000000..5870ff0 --- /dev/null +++ b/appl/example/aboutdialog.ui @@ -0,0 +1,117 @@ + + + AboutDialog + + + + 0 + 0 + 423 + 289 + + + + Dialog + + + true + + + + + 20 + 20 + 381 + 221 + + + + true + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Droid Sans'; font-size:10pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans Serif'; font-size:9pt; font-weight:600;">ReBackupGui</span><span style=" font-family:'Sans Serif'; font-size:9pt;"> for backup of directories to external media.</span></p> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans Serif'; font-size:9pt;">This is a program of the project</span></p> +<p align="center" style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans Serif'; font-size:9pt; font-weight:600;">Re</span><span style=" font-family:'Sans Serif'; font-size:9pt;">al </span><span style=" font-family:'Sans Serif'; font-size:9pt; font-weight:600;">Pub</span><span style=" font-family:'Sans Serif'; font-size:9pt;">lic </span><span style=" font-family:'Sans Serif'; font-size:9pt; font-weight:600;">Lib</span><span style=" font-family:'Sans Serif'; font-size:9pt;">rary (RePubLib)</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans Serif'; font-size:9pt;">Sources are public domain and available under</span></p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="https://github.com/republib"><span style=" font-family:'Sans Serif'; font-size:9pt; text-decoration: underline; color:#0000ff;">https://github.com/republib</span></a><span style=" font-family:'Sans Serif'; font-size:9pt;"> </span></p> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans Serif'; font-size:9pt;">Implemented in QT (C++) 5.x</span></p> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Sans Serif'; font-size:9pt;">Icons: Mark James, </span><a href="http://famfamfam.com"><span style=" font-family:'Sans Serif'; font-size:9pt; text-decoration: underline; color:#0000ff;">http://famfamfam.com</span></a><span style=" font-family:'Sans Serif'; font-size:9pt;"> </span></p></body></html> + + + false + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + 20 + 250 + 381 + 32 + + + + + + + Version: + + + + + + + 2015.05.00 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + &OK + + + + + + + + + + pushButtonOK + clicked() + AboutDialog + close() + + + 196 + 183 + + + 199 + 108 + + + + + diff --git a/appl/example/example.hpp b/appl/example/example.hpp new file mode 100644 index 0000000..c13a13c --- /dev/null +++ b/appl/example/example.hpp @@ -0,0 +1,19 @@ +/* + * backupgui.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 BACKUPGUI_HPP +#define BACKUPGUI_HPP +#include "base/rebase.hpp" +#include "gui/regui.hpp" +#include "mainwindow.hpp" +#include "ui_mainwindow.h" + +#endif // BACKUPGUI_HPP diff --git a/appl/example/example.pro b/appl/example/example.pro new file mode 100644 index 0000000..7ebd176 --- /dev/null +++ b/appl/example/example.pro @@ -0,0 +1,47 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2016-01-18T00:51:17 +# +#------------------------------------------------- + +QT += core gui + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = rebackgui +TEMPLATE = app +INCLUDEPATH = ../.. + +SOURCES += main.cpp\ + ../../base/ReException.cpp \ + ../../base/ReConfig.cpp \ + ../../base/ReQStringUtils.cpp \ + ../../base/ReFileUtils.cpp \ + ../../base/ReMatcher.cpp \ + ../../base/ReLogger.cpp \ + ../../base/ReRandomizer.cpp \ + ../../base/ReStringUtils.cpp \ + ../../gui/ReStateStorage.cpp \ + ../../gui/ReGuiApplication.cpp \ + ../../gui/ReGuiValidator.cpp \ + ../../gui/ReGuiQueue.cpp \ + ../../gui/ReGuiUtils.cpp \ + mainwindow.cpp \ + aboutdialog.cpp + +HEADERS += mainwindow.hpp \ + ../../base/rebase.hpp \ + ../../base/ReQStringUtils.hpp \ + ../../gui/ReStateStorage.hpp \ + ../../gui/ReGuiValidator.hpp \ + ../../gui/regui.hpp \ + ../../gui/ReGuiUtils.hpp \ + aboutdialog.hpp + +FORMS += mainwindow.ui \ + aboutdialog.ui + +DISTFILES += \ + ReBackGui.html \ + osconnect.pl + diff --git a/appl/example/main.cpp b/appl/example/main.cpp new file mode 100644 index 0000000..0d45da3 --- /dev/null +++ b/appl/example/main.cpp @@ -0,0 +1,24 @@ +/* + * main.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 "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(homeDir); + w.show(); + return a.exec(); +} diff --git a/appl/example/mainwindow.cpp b/appl/example/mainwindow.cpp new file mode 100644 index 0000000..916b6cc --- /dev/null +++ b/appl/example/mainwindow.cpp @@ -0,0 +1,207 @@ +/* + * mainwindow.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 "example.hpp" +#include "aboutdialog.hpp" +#include + +const QString VERSION("2016.02.14"); + +/** + * Constructor. + * + * @param homeDir the home directory. If "": usage of the user's homedir + * @param parent QT parent or NULL + */ +MainWindow::MainWindow(const QString& homeDir, QWidget *parent) : + ReGuiApplication("rebackupgui", homeDir, 2, 100100100, parent), + ReGuiValidator(), + ui(new Ui::MainWindow), + m_errors(0) +{ + ui->setupUi(this); + initializeGuiElements(); + startStop(false); + connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(onAbout())); + connect(ui->pushButtonStart, SIGNAL(clicked()), this, SLOT(onStart())); +} + +/** + * Destructor. + */ +MainWindow::~MainWindow() +{ + delete ui; +} + +/** + * Appends a line to the filelist. + * + * Note: this method is called by a non main thread. + * + * @param info info to add + */ +void MainWindow::addToFileList(const QString info){ + // externalAppend(ReGuiQueueItem::ListEnd, ui->listWidgetFile, info); +} + +/** + * Returns the error count. + * @return the error count + */ +int MainWindow::errors() const +{ + return m_errors; +} + + +/** + * Set GUI elements from the queue when the GUI timer is triggered. + */ +void MainWindow::onGuiTimerUpdate() +{ + int count = m_guiQueue.count(); + QListWidget* list; + while(count-- > 0){ + m_mutexGuiQueue.lock(); + ReGuiQueueItem item = m_guiQueue.popFront(); + m_mutexGuiQueue.unlock(); + int m_maxListSize = 0x7fffffff; + if (item.m_type == ReGuiQueueItem::ListEnd + && (list = reinterpret_cast(item.m_widget))->count() >= m_maxListSize) + delete list->takeItem(0); + if (item.m_type == ReGuiQueueItem::Undef) + break; + if (! item.apply()){ + switch (item.m_type){ + case ReGuiQueueItem::ListEnd: + // todo + break; + case ReGuiQueueItem::ReadyMessage: + say(LOG_INFO, item.m_value); + startStop(false); + break; + case ReGuiQueueItem::LogMessage: + say(LOG_INFO, item.m_value); + break; + case ReGuiQueueItem::LogError: + say(LOG_ERROR, item.m_value); + break; + case ReGuiQueueItem::StatusLine: + setStatusMessage(LOG_INFO, item.m_value); + break; + default: + say(LOG_ERROR, "unknown item type: " + QString::number(item.m_type) + + " " + item.m_value); + break; + } + } + } +} + +/** + * Common initializations for all task starts. + * + * @return true: success
+ * otherwise: error occurred + */ +bool MainWindow::initializeStart(){ + bool rc = true; + startStop(true); + // ToDo + return rc; +} + +/** + * Called at the program's end. + */ +void MainWindow::onAboutToQuit() +{ + ReGuiApplication::onAboutToQuit(); +} + +/** + * Shows the "about" window. + */ +void MainWindow::onAbout() +{ + AboutDialog dialog(VERSION); + dialog.exec(); +} + + +/** + * Starts the backup. + */ +void MainWindow::onStart(){ + // ToDo +} + +/** + * Reads the history of the widget values and other parameters and set it. + */ +void MainWindow::restoreState(){ + ReStateStorage storage(m_storageFile, &m_logger); + storage.setForm("main"); + //storage.restore(ui->comboBoxFilePatterns, "comboBoxFilePatterns", false); + //storage.restore(ui->comboBoxDirPatterns, "comboBoxDirPatterns", false); + storage.close(); +} + +/** + * Stores the history of the widget values and other parameters. + */ +void MainWindow::saveState(){ + ReStateStorage storage(m_storageFile, &m_logger); + storage.setForm("main"); + //storage.store(ui->comboBoxFilePatterns, "comboBoxFilePatterns"); + //storage.store(ui->comboBoxDirPatterns, "comboBoxDirPatterns"); + storage.close(); +} + +/** + * Writes a message. + * + * @param level mode of the message, e.g. LOG_ERROR + * @param message the message + * @return falselevel is error or warning + */ +bool MainWindow::say(ReLoggerLevel level, const QString& message){ + switch(level){ + case LOG_ERROR: + case LOG_WARNING: + // todo + setStatusMessage(LOG_ERROR, message); + m_errors++; + break; + default: + case LOG_INFO: + //ui->listWidgetLog->addItem(message); + //ui->listWidgetLog->setCurrentRow(ui->listWidgetLog->count() - 1); + break; + } + return level >= LOG_INFO; +} + +/** + * Starts or stops the backup. + * + * @param start true: the search should start + */ +void MainWindow::startStop(bool isStart){ + ReUseParameter(isStart); + // ui->actionStart->setEnabled(!isStart); + // todo +} + + + + diff --git a/appl/example/mainwindow.hpp b/appl/example/mainwindow.hpp new file mode 100644 index 0000000..3da3df4 --- /dev/null +++ b/appl/example/mainwindow.hpp @@ -0,0 +1,49 @@ +/* + * mainwindow.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 MAINWINDOW_HPP +#define MAINWINDOW_HPP +#ifndef BACKUPGUI_HPP +#include "example.hpp" +#endif +namespace Ui { +class MainWindow; +} + +class MainWindow : public ReGuiApplication, public ReGuiValidator +{ + Q_OBJECT + +public: + explicit MainWindow(const QString& homeDir, QWidget *parent = 0); + ~MainWindow(); +public: + int errors() const; + void expandFileList(const QString info); + virtual bool say(ReLoggerLevel level, const QString& message); + void startStop(bool isStart); + void restoreState(); + void saveState(); + + void addToFileList(const QString info); +private: + bool initializeStart(); +private slots: + void onAbout(); + virtual void onAboutToQuit(); + virtual void onGuiTimerUpdate(); + void onStart(); +private: + Ui::MainWindow *ui; + int m_errors; +}; + +#endif // MAINWINDOW_HPP diff --git a/appl/example/mainwindow.ui b/appl/example/mainwindow.ui new file mode 100644 index 0000000..8128739 --- /dev/null +++ b/appl/example/mainwindow.ui @@ -0,0 +1,85 @@ + + + MainWindow + + + + 0 + 0 + 535 + 405 + + + + MainWindow + + + + + + 11 + 155 + 106 + 30 + + + + PushButton + + + + + + + 0 + 0 + 535 + 26 + + + + + File + + + + + + Edit + + + + + Help + + + + + + Action + + + + + + + + + + TopToolBarArea + + + false + + + + + + About + + + + + + + diff --git a/appl/rebackgui/BackupEngine.cpp b/appl/rebackgui/BackupEngine.cpp index 0a6b39a..1f71848 100644 --- a/appl/rebackgui/BackupEngine.cpp +++ b/appl/rebackgui/BackupEngine.cpp @@ -206,8 +206,8 @@ void BackupTask::run() node = info.mid(pos + 1); copyFile(index, relPath, node); if (m_verboseLevel > VerboseQuiet){ - qint64 duration = QDateTime::currentMSecsSinceEpoch() - start.toMSecsSinceEpoch(); - double factor = double(m_processedBytes) / max(1LL, m_hotBytes); + qint64 duration = QDateTime::currentMSecsSinceEpoch() - start.toMSecsSinceEpoch(); + double factor = double(m_processedBytes) / max(1LL, m_hotBytes); m_mainWindow->externalAppend(ReGuiQueueItem::StatusLine, NULL, tr("%1 of %2 (%3 of %4) %5 MB/sec runtime: %6") .arg(m_processedFiles).arg(m_hotFiles) @@ -220,7 +220,7 @@ void BackupTask::run() } m_mainWindow->externalTaskFinished(tr("backup complete after %1. Errors: %2") .arg(ReQStringUtils::readableDuration( - QDateTime::currentMSecsSinceEpoch() - start.toMSecsSinceEpoch())) + QDateTime::currentMSecsSinceEpoch() - start.toMSecsSinceEpoch())) .arg(m_mainWindow->errors())); } @@ -398,22 +398,22 @@ void ChecksumOfTargetTask::run() + " [" + sourceChecksum + "/" + checksum + "]"); } if (m_verboseLevel > VerboseQuiet){ - qint64 processedBytes, hotBytes; - int hotFiles, processedFiles; - m_mutex.lock(); - hotFiles = m_hotFiles; - hotBytes = m_hotBytes; - processedBytes = m_processedBytes; - processedFiles = m_processedFiles; - m_mutex.unlock(); - now = QDateTime::currentMSecsSinceEpoch(); - qint64 duration = (now - start.toMSecsSinceEpoch()); - double factor = m_processedBytes / double(max(1LL, m_hotBytes * 2)); + qint64 processedBytes, hotBytes; + int hotFiles, processedFiles; + m_mutex.lock(); + hotFiles = m_hotFiles * 2; + hotBytes = m_hotBytes * 2; + processedBytes = m_processedBytes; + processedFiles = m_processedFiles; + m_mutex.unlock(); + now = QDateTime::currentMSecsSinceEpoch(); + qint64 duration = (now - start.toMSecsSinceEpoch()); + double factor = processedBytes / double(max(1LL, hotBytes)); m_mainWindow->externalAppend(ReGuiQueueItem::StatusLine, NULL, tr("%1 of %2 (%3 of %4) %5 MB/sec runtime: %6") .arg(processedFiles).arg(hotFiles * 2) .arg(ReQStringUtils::readableSize(processedBytes)) - .arg(ReQStringUtils::readableSize(hotBytes * 2)) + .arg(ReQStringUtils::readableSize(hotBytes)) .arg(processedBytes / 1024.0 / 1024 / max(1LL, duration) * 1000.0, 0, 'f', 3) .arg(ReQStringUtils::runtimeEstimation(start, factor))); } @@ -422,7 +422,7 @@ void ChecksumOfTargetTask::run() } now = QDateTime::currentMSecsSinceEpoch(); m_mainWindow->externalTaskFinished(tr("Building target checksums complete after %1. Processed: %2 Errors: %3") - .arg(ReQStringUtils::readableDuration(now - start.toMSecsSinceEpoch())) + .arg(ReQStringUtils::readableDuration(now - start.toMSecsSinceEpoch())) .arg(count) .arg(m_mainWindow->errors())); } @@ -526,8 +526,8 @@ void CleanTask::run() break; } if (m_verboseLevel > VerboseQuiet){ - double factor = double(m_processedFiles) / max(1, m_hotFiles); - qint64 duration = QDateTime::currentMSecsSinceEpoch() - start.toMSecsSinceEpoch(); + double factor = double(m_processedFiles) / max(1, m_hotFiles); + qint64 duration = QDateTime::currentMSecsSinceEpoch() - start.toMSecsSinceEpoch(); m_mainWindow->externalAppend(ReGuiQueueItem::StatusLine, NULL, tr("%1 of %2 (%3 of %4) %5 MB/sec runtime: %6") .arg(m_processedFiles) @@ -542,7 +542,7 @@ void CleanTask::run() } m_mainWindow->externalTaskFinished(tr("backup complete after %1. Errors: %2") .arg(ReQStringUtils::readableDuration( - QDateTime::currentMSecsSinceEpoch() - start.toMSecsSinceEpoch())) + QDateTime::currentMSecsSinceEpoch() - start.toMSecsSinceEpoch())) .arg(m_mainWindow->errors())); } @@ -639,29 +639,29 @@ void SearchTask::searchOneDirectory(const QString& source, m_mutex.unlock(); } else { qint64 diff = 0; - bool doTransfer = false; + bool doTransfer = false; if (! m_compareWithTarget) - doTransfer = true; + doTransfer = true; else if (target.isEmpty()) - doTransfer = true; + doTransfer = true; else { QFileInfo trg(target + it.fileName()); if (! trg.exists()) - doTransfer = true; + doTransfer = true; else { const QFileInfo src = it.fileInfo(); if (trg.size() != src.size()) - doTransfer = true; + doTransfer = true; else if ((diff = src.lastModified().toMSecsSinceEpoch() - trg.lastModified().toMSecsSinceEpoch()) > 2000) - doTransfer = true; + doTransfer = true; } } - if (doTransfer){ + if (doTransfer){ info = prefix + it.fileName(); } m_mutex.lock(); - if (doTransfer){ + if (doTransfer){ m_files.append(info); m_hotFiles++; m_hotBytes += it.fileInfo().size(); @@ -835,7 +835,6 @@ void SearchTargetTask::searchOneDirectory(const QString& target, if (! m_shouldStop){ QDirIterator it2(target); QString node; - QString source; while (it2.hasNext()){ if (m_shouldStop){ break; @@ -872,6 +871,8 @@ void SearchTargetTask::moveToShadow(const QString& target, const QString& relPat if (rename(I18N::s2b(target).constData(), I18N::s2b(shadow).constData()) != 0){ error(QObject::tr("cannot move to shadow directory (%1): %2 -> %3") .arg(errno).arg(target).arg(shadow)); + } else if (m_verboseLevel >= VerboseStandard){ + m_mainWindow->addToFileList("~ " + target); } } } diff --git a/appl/rebackgui/mainwindow.cpp b/appl/rebackgui/mainwindow.cpp index 860aa06..60a2f92 100644 --- a/appl/rebackgui/mainwindow.cpp +++ b/appl/rebackgui/mainwindow.cpp @@ -87,14 +87,6 @@ MainWindow::~MainWindow() delete ui; } -/** - * Calles at the program's end. - */ -void MainWindow::onAboutToQuit() -{ - -} - /** * Appends a line to the filelist. * @@ -222,6 +214,15 @@ bool MainWindow::initializeStart(){ return rc; } +/** + * Called at the program's end. + */ +void MainWindow::onAboutToQuit() +{ + saveState(); + ReGuiApplication::onAboutToQuit(); +} + /** * Shows the "about" window. */ diff --git a/base/ReQStringUtils.cpp b/base/ReQStringUtils.cpp index 8271905..c4609df 100644 --- a/base/ReQStringUtils.cpp +++ b/base/ReQStringUtils.cpp @@ -546,14 +546,15 @@ QString ReQStringUtils::readableDuration(qint64 durationMilliSec){ */ QString ReQStringUtils::runtimeEstimation(const QDateTime& start, double factor){ - qint64 duration = QDateTime::currentMSecsSinceEpoch() - start.toMSecsSinceEpoch(); + qint64 duration = QDateTime::currentMSecsSinceEpoch() - start.toMSecsSinceEpoch(); if (factor < 1) factor = 1; else if (factor <= 0.001) factor = 0.001; qint64 estimated = qint64((double) duration / factor); - QString rc = QObject::tr("%1 of %2").arg(readableDuration(duration)) - .arg(readableDuration(estimated)); + QString rc = QObject::tr("%1 of %2 (%3 %)").arg(readableDuration(duration)) + .arg(readableDuration(estimated)) + .arg(min(100, int (factor * 100))); return rc; } /** diff --git a/gui/ReGuiApplication.cpp b/gui/ReGuiApplication.cpp index cbaab68..131bd68 100644 --- a/gui/ReGuiApplication.cpp +++ b/gui/ReGuiApplication.cpp @@ -114,7 +114,7 @@ void ReGuiApplication::externalTaskFinished(const QString& message){ */ void ReGuiApplication::initializeGuiElements(){ QCoreApplication* app = QCoreApplication::instance(); - QObject::connect(app, SIGNAL(aboutToQuit()), this, SLOT(aboutToQuit())); + QObject::connect(app, SIGNAL(aboutToQuit()), this, SLOT(onAboutToQuit())); connect(m_guiTimer, SIGNAL(timeout()), this, SLOT(onGuiTimerUpdate())); m_guiTimer->start(100); statusBar()->addWidget(m_statusMessage); @@ -196,10 +196,10 @@ void ReGuiApplication::externalLog(const QString& message){ void ReGuiApplication::setStatusMessage(ReLoggerLevel level, const QString& message){ switch(level){ case LOG_ERROR: - m_statusMessage->setText("! " + message); + m_statusMessage->setText("+ " + message); break; case LOG_WARNING: - m_statusMessage->setText("+ " + message); + m_statusMessage->setText("! " + message); break; default: m_statusMessage->setText(message); diff --git a/gui/ReGuiApplication.hpp b/gui/ReGuiApplication.hpp index 868528d..0d6c7bf 100644 --- a/gui/ReGuiApplication.hpp +++ b/gui/ReGuiApplication.hpp @@ -22,11 +22,6 @@ public: ReGuiApplication(const char* applicationName, const QString& homeDir, int maxLogFiles, int maxLogSize, QWidget *parent); -public slots: - /** - * Callback method called when the application is closed. - */ - virtual void onAboutToQuit(); public: const QByteArray& applicationName() const; QString fileOfHome(const QString& node); @@ -45,6 +40,7 @@ protected slots: * Reads the m_guiQueue. */ virtual void onGuiTimerUpdate() = 0; + virtual void onAboutToQuit(); protected: QByteArray m_applicationName; /// the base directory for resources of the program like configuration file. diff --git a/gui/regui.hpp b/gui/regui.hpp index 2255d12..8e8f9e7 100644 --- a/gui/regui.hpp +++ b/gui/regui.hpp @@ -15,6 +15,7 @@ #include #include #include +#include #include "gui/ReGuiUtils.hpp" #include "gui/ReGuiQueue.hpp" #include "gui/ReStateStorage.hpp" -- 2.39.5