2017-04-26 22:56:19 +00:00
|
|
|
#ifndef CONSOLEWIDGET_H
|
|
|
|
#define CONSOLEWIDGET_H
|
|
|
|
|
2017-10-02 09:41:28 +00:00
|
|
|
#include <memory>
|
2017-10-03 18:38:34 +00:00
|
|
|
#include "MainWindow.h"
|
2018-03-16 21:46:57 +00:00
|
|
|
#include "CutterDockWidget.h"
|
2018-06-22 18:34:25 +00:00
|
|
|
#include "utils/CommandTask.h"
|
2017-04-26 22:56:19 +00:00
|
|
|
|
2018-03-21 20:32:32 +00:00
|
|
|
namespace Ui {
|
|
|
|
class ConsoleWidget;
|
2017-04-26 22:56:19 +00:00
|
|
|
}
|
|
|
|
|
2017-04-27 23:57:13 +00:00
|
|
|
|
2018-03-16 21:46:57 +00:00
|
|
|
class ConsoleWidget : public CutterDockWidget
|
2017-04-26 22:56:19 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2018-03-16 21:46:57 +00:00
|
|
|
explicit ConsoleWidget(MainWindow *main, QAction *action = nullptr);
|
2017-12-10 16:55:42 +00:00
|
|
|
|
2017-04-26 22:56:19 +00:00
|
|
|
~ConsoleWidget();
|
|
|
|
|
2018-03-21 20:32:32 +00:00
|
|
|
void setDebugOutputEnabled(bool enabled)
|
|
|
|
{
|
|
|
|
debugOutputEnabled = enabled;
|
|
|
|
}
|
2017-04-27 23:57:13 +00:00
|
|
|
|
2018-03-21 20:32:32 +00:00
|
|
|
void setMaxHistoryEntries(int max)
|
|
|
|
{
|
|
|
|
maxHistoryEntries = max;
|
|
|
|
}
|
2017-04-27 23:57:13 +00:00
|
|
|
|
2017-04-26 22:56:19 +00:00
|
|
|
public slots:
|
|
|
|
void focusInputLineEdit();
|
|
|
|
|
2018-08-27 11:16:48 +00:00
|
|
|
void addOutput(const QString &msg);
|
|
|
|
void addDebugOutput(const QString &msg);
|
|
|
|
|
2017-04-26 22:56:19 +00:00
|
|
|
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();
|
2018-10-10 18:09:07 +00:00
|
|
|
void removeLastLine();
|
2018-06-22 18:34:25 +00:00
|
|
|
void executeCommand(const QString &command);
|
|
|
|
|
|
|
|
QSharedPointer<CommandTask> commandTask;
|
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
|