saveState();
}
-
-/**
- * Show a message.
- *
- * @param level LOG_ERROR or LOG_INFO
- * @param message the message to show
- * @return <code>false</code>: the message is an error message
- */
-bool MainWindow::say(ReLoggerLevel level, const QString& message)
-{
- if (level == LOG_ERROR)
- error(message);
- else
- log(message);
- setStatusMessage(level, message);
- return level >= LOG_INFO;
-}
-
-/**
-* 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){
- RE_UNUSED(error);
- m_statusMessage->setText(message);
-}
-
/**
* Reads the history of the widget values and other parameters and set it.
*/
void expandFileList(const QString info);
bool log(const QString& message);
virtual bool say(ReLoggerLevel level, const QString& message);
- void setStatusMessage(bool error, const QString& message);
void startStop(bool isStart);
void restoreState();
void saveState();
TARGET = rebackgui
TEMPLATE = app
-INCLUDEPATH = ../.. /usr/include/c++/4.9
+INCLUDEPATH = ../..
SOURCES += main.cpp\
../../base/ReException.cpp \
DISTFILES += \
ReBackGui.html \
- osconnect.pl
+ osconnect.pl
--- /dev/null
+/*
+ * Licence:
+ * You can use and modify this file without any restriction.
+ * There is no warranty.
+ * You also can use the licence from http://www.wtfpl.net/.
+ * The original sources can be found on https://github.com/republib.
+*/
+
+#include "recommand.hpp"
+
+/**
+ * Constructor.
+ *
+ * @param mainWindow the GUI object
+ */
+CommandProcessor::CommandProcessor(MainWindow* mainWindow) :
+ m_mainWindow(mainWindow)
+{
+
+}
+
+void CommandProcessor::interpret(const QString& text)
+{
+
+}
--- /dev/null
+/*
+ * Licence:
+ * You can use and modify this file without any restriction.
+ * There is no warranty.
+ * You also can use the licence from http://www.wtfpl.net/.
+ * The original sources can be found on https://github.com/republib.
+*/
+
+#ifndef COMMANDPROCESSOR_HPP
+#define COMMANDPROCESSOR_HPP
+
+class MainWindow;
+
+class CommandProcessor
+{
+public:
+ CommandProcessor(MainWindow* mainWindow);
+public:
+ void interpret(const QString& text);
+protected:
+ MainWindow* m_mainWindow;
+};
+
+#endif // COMMANDPROCESSOR_HPP
--- /dev/null
+/*
+ * Licence:
+ * You can use and modify this file without any restriction.
+ * There is no warranty.
+ * You also can use the licence from http://www.wtfpl.net/.
+ * The original sources can be found on https://github.com/republib.
+*/
+
+#include "recommand.hpp"
+#include <QApplication>
+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();
+}
--- /dev/null
+/*
+ * Licence:
+ * You can use and modify this file without any restriction.
+ * There is no warranty.
+ * You also can use the licence from http://www.wtfpl.net/.
+ * The original sources can be found on https://github.com/republib.
+*/
+
+#include "recommand.hpp"
+
+MainWindow::MainWindow(const QString& homeDir, QWidget *parent) :
+ ReGuiApplication("recommand", homeDir, 2, 100100100, parent),
+ ReGuiValidator(),
+ ui(new Ui::MainWindow),
+ m_processor(NULL)
+{
+ ui->setupUi(this);
+ initializeGuiElements();
+ connect(ui->pushButtonRun, SIGNAL(clicked()), this, SLOT(onRun()));
+ connect(ui->pushButtonClear, SIGNAL(clicked()), this, SLOT(onClear()));
+}
+
+MainWindow::~MainWindow()
+{
+ delete ui;
+}
+
+
+/**
+ * Clears the result field.
+ */
+void MainWindow::onClear()
+{
+ ui->textEditResult->clear();
+}
+
+/**
+ * Set GUI elements from the queue when the GUI timer is triggered.
+ */
+void MainWindow::onGuiTimerUpdate()
+{
+ int count = m_guiQueue.count();
+ while(count-- > 0){
+ m_mutexGuiQueue.lock();
+ ReGuiQueueItem item = m_guiQueue.popFront();
+ m_mutexGuiQueue.unlock();
+ if (item.m_type == ReGuiQueueItem::Undef)
+ break;
+ if (! item.apply()){
+ switch (item.m_type){
+ case ReGuiQueueItem::ReadyMessage:
+ say(LOG_INFO, item.m_value);
+ 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;
+ }
+ }
+ }
+}
+
+/**
+ * Executes the current commands.
+ */
+void MainWindow::onRun()
+{
+
+}
+
+/**
+ * Writes a message.
+ *
+ * @param level mode of the message, e.g. LOG_ERROR
+ * @param message the message
+ * @return <code>false</code>level is error or warning
+ */
+bool MainWindow::say(ReLoggerLevel level, const QString& message){
+ QString edit = ui->textEditResult->toPlainText();
+ QString msg;
+ switch(level){
+ case LOG_WARNING:
+ msg = "+++ ";
+ break;
+ case LOG_ERROR:
+ msg = "*** ";
+ break;
+ default:
+ break;
+ }
+
+ if (! edit.endsWith("\n")){
+ msg += "\n";
+ }
+ msg += message;
+ edit += msg;
+ ui->textEditResult->setText(edit);
+ return level >= LOG_INFO;
+}
+
--- /dev/null
+/*
+ * Licence:
+ * You can use and modify this file without any restriction.
+ * There is no warranty.
+ * You also can use the licence from http://www.wtfpl.net/.
+ * The original sources can be found on https://github.com/republib.
+*/
+
+#ifndef RECOMMAND_HPP
+#include "recommand.hpp"
+#endif
+#ifndef MAINWINDOW_HPP
+#define MAINWINDOW_HPP
+
+#include <QMainWindow>
+
+namespace Ui {
+class MainWindow;
+}
+
+class MainWindow : public ReGuiApplication, public ReGuiValidator
+{
+ Q_OBJECT
+
+public:
+ explicit MainWindow(const QString& homeDir, QWidget *parent = 0);
+ virtual ~MainWindow();
+
+public:
+ virtual void onGuiTimerUpdate();
+ void onRun();
+ void onClear();
+ virtual bool say(ReLoggerLevel level, const QString& message);
+
+private:
+ Ui::MainWindow *ui;
+ CommandProcessor* m_processor;
+};
+
+#endif // MAINWINDOW_HPP
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MainWindow</class>
+ <widget class="QMainWindow" name="MainWindow">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>977</width>
+ <height>624</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>MainWindow</string>
+ </property>
+ <widget class="QWidget" name="centralWidget">
+ <layout class="QVBoxLayout" name="verticalLayout_3">
+ <item>
+ <widget class="QSplitter" name="splitter">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <widget class="QWidget" name="layoutWidget">
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Write command, try "help;"</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="pushButtonRun">
+ <property name="minimumSize">
+ <size>
+ <width>125</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Run</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="pushButtonSave">
+ <property name="text">
+ <string>Save</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QTextEdit" name="textEditPad"/>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="layoutWidget">
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Result:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="pushButtonClear">
+ <property name="text">
+ <string>Clear</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QTextEdit" name="textEditResult"/>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QMenuBar" name="menuBar">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>977</width>
+ <height>26</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="QToolBar" name="mainToolBar">
+ <attribute name="toolBarArea">
+ <enum>TopToolBarArea</enum>
+ </attribute>
+ <attribute name="toolBarBreak">
+ <bool>false</bool>
+ </attribute>
+ </widget>
+ <widget class="QStatusBar" name="statusBar"/>
+ <widget class="QToolBar" name="toolBar">
+ <property name="windowTitle">
+ <string>toolBar</string>
+ </property>
+ <attribute name="toolBarArea">
+ <enum>TopToolBarArea</enum>
+ </attribute>
+ <attribute name="toolBarBreak">
+ <bool>false</bool>
+ </attribute>
+ </widget>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <resources/>
+ <connections/>
+</ui>
--- /dev/null
+/*
+ * Licence:
+ * You can use and modify this file without any restriction.
+ * There is no warranty.
+ * You also can use the licence from http://www.wtfpl.net/.
+ * The original sources can be found on https://github.com/republib.
+*/
+
+#ifndef RECOMMAND_HPP
+#define RECOMMAND_HPP
+#include "base/rebase.hpp"
+#include "gui/regui.hpp"
+#include "CommandProcessor.hpp"
+#include "mainwindow.hpp"
+#include "ui_mainwindow.h"
+#endif // RECOMMAND_HPP
--- /dev/null
+#-------------------------------------------------
+#
+# Project created by QtCreator 2016-02-09T13:02:50
+#
+#-------------------------------------------------
+
+QT += core gui
+
+greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
+
+TARGET = recommand
+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 \
+ CommandProcessor.cpp
+
+HEADERS += mainwindow.hpp \
+ CommandProcessor.hpp \
+ recommand.hpp
+
+FORMS += mainwindow.ui
m_guiQueue(),
m_guiTimer(new QTimer(this)),
m_statusMessage(new QLabel(tr("Welcome!"))),
- m_mutexGuiQueue()
+ m_mutexGuiQueue()
{
m_logger.buildStandardAppender(I18N::s2b(m_homeDir) + applicationName,
maxLogSize, maxLogFiles);
m_mutexGuiQueue.unlock();
}
+/**
+* Writes a text to the status line.
+*
+* @param level level of the messge: LOG_INFO, LOG_ERROR...
+* @param message the text to set
+*/
+void ReGuiApplication::setStatusMessage(ReLoggerLevel level, const QString& message){
+ switch(level){
+ case LOG_ERROR:
+ m_statusMessage->setText("! " + message);
+ break;
+ case LOG_WARNING:
+ m_statusMessage->setText("+ " + message);
+ break;
+ default:
+ m_statusMessage->setText(message);
+ break;
+ }
+}
+
ReLogger* logger();
public:
static QString buildHomeDir(QString homeDirBase, const QString& node);
+ void setStatusMessage(ReLoggerLevel level, const QString& message);
protected:
void initializeGuiElements();
protected slots: