cutter/src/widgets/ConsoleWidget.h

87 lines
1.7 KiB
C
Raw Normal View History

#ifndef CONSOLEWIDGET_H
#define CONSOLEWIDGET_H
#include "core/MainWindow.h"
#include "CutterDockWidget.h"
2018-10-17 07:55:53 +00:00
#include "common/CommandTask.h"
#include <QStringListModel>
#include <memory>
class QCompleter;
class QShortcut;
2018-03-21 20:32:32 +00:00
namespace Ui {
class ConsoleWidget;
}
class ConsoleWidget : public CutterDockWidget
{
Q_OBJECT
public:
explicit ConsoleWidget(MainWindow *main, QAction *action = nullptr);
~ConsoleWidget();
2018-03-21 20:32:32 +00:00
void setDebugOutputEnabled(bool enabled)
{
debugOutputEnabled = enabled;
}
2018-03-21 20:32:32 +00:00
void setMaxHistoryEntries(int max)
{
maxHistoryEntries = max;
}
protected:
bool eventFilter(QObject *obj, QEvent *event);
public slots:
void focusInputLineEdit();
void addOutput(const QString &msg);
void addDebugOutput(const QString &msg);
private slots:
void setupFont();
void on_inputLineEdit_returnPressed();
void on_execButton_clicked();
void showCustomContextMenu(const QPoint &pt);
void historyNext();
void historyPrev();
void updateCompletion();
void clear();
private:
void scrollOutputToEnd();
void historyAdd(const QString &input);
void invalidateHistoryPosition();
void removeLastLine();
void executeCommand(const QString &command);
2019-05-17 17:48:59 +00:00
void setWrap(bool wrap);
QSharedPointer<CommandTask> commandTask;
2017-10-02 09:41:28 +00:00
std::unique_ptr<Ui::ConsoleWidget> ui;
QAction *actionWrapLines;
QList<QAction *> actions;
bool debugOutputEnabled;
int maxHistoryEntries;
int lastHistoryPosition;
QStringList history;
QStringListModel completionModel;
QCompleter *completer;
QShortcut *historyUpShortcut;
QShortcut *historyDownShortcut;
};
#endif // CONSOLEWIDGET_H