2017-04-26 22:56:19 +00:00
|
|
|
#ifndef CONSOLEWIDGET_H
|
|
|
|
#define CONSOLEWIDGET_H
|
|
|
|
|
|
|
|
#include <QWidget>
|
2017-10-02 09:41:28 +00:00
|
|
|
#include <memory>
|
2017-10-03 18:38:34 +00:00
|
|
|
#include "MainWindow.h"
|
2017-04-26 22:56:19 +00:00
|
|
|
|
|
|
|
namespace Ui
|
|
|
|
{
|
|
|
|
class ConsoleWidget;
|
|
|
|
}
|
|
|
|
|
2017-04-27 23:57:13 +00:00
|
|
|
|
2017-04-26 22:56:19 +00:00
|
|
|
class ConsoleWidget : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2017-10-09 18:08:35 +00:00
|
|
|
explicit ConsoleWidget(QWidget *parent = 0);
|
2017-04-26 22:56:19 +00:00
|
|
|
~ConsoleWidget();
|
|
|
|
|
|
|
|
void addOutput(const QString &msg);
|
|
|
|
void addDebugOutput(const QString &msg);
|
|
|
|
|
2017-04-27 23:57:13 +00:00
|
|
|
void setDebugOutputEnabled(bool enabled) { debugOutputEnabled = enabled; }
|
|
|
|
|
|
|
|
void setMaxHistoryEntries(int max) { maxHistoryEntries = max; }
|
|
|
|
|
2017-04-26 22:56:19 +00:00
|
|
|
public slots:
|
|
|
|
void focusInputLineEdit();
|
|
|
|
|
|
|
|
private slots:
|
2017-11-26 21:54:44 +00:00
|
|
|
void setupFont();
|
|
|
|
|
2017-04-27 23:57:13 +00:00
|
|
|
void on_inputLineEdit_returnPressed();
|
|
|
|
|
|
|
|
void on_execButton_clicked();
|
2017-04-26 22:56:19 +00:00
|
|
|
|
2017-04-27 23:57:13 +00:00
|
|
|
void showCustomContextMenu(const QPoint &pt);
|
2017-04-26 22:56:19 +00:00
|
|
|
|
2017-04-27 23:57:13 +00:00
|
|
|
void historyNext();
|
|
|
|
void historyPrev();
|
2017-04-26 22:56:19 +00:00
|
|
|
|
2017-04-27 23:57:13 +00:00
|
|
|
void clear();
|
2017-04-26 22:56:19 +00:00
|
|
|
|
|
|
|
private:
|
2017-04-27 23:57:13 +00:00
|
|
|
void scrollOutputToEnd();
|
|
|
|
void historyAdd(const QString &input);
|
|
|
|
void invalidateHistoryPosition();
|
2017-10-03 18:38:34 +00:00
|
|
|
QString executeCommand(QString command);
|
2017-04-27 23:57:13 +00:00
|
|
|
|
2017-10-02 09:41:28 +00:00
|
|
|
std::unique_ptr<Ui::ConsoleWidget> ui;
|
2017-04-27 23:57:13 +00:00
|
|
|
QList<QAction *> actions;
|
|
|
|
bool debugOutputEnabled;
|
|
|
|
int maxHistoryEntries;
|
|
|
|
int lastHistoryPosition;
|
|
|
|
QStringList history;
|
2017-04-26 22:56:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CONSOLEWIDGET_H
|