mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-22 12:56:11 +00:00
c4e8a1c178
* Small refactor for the widgets of Cutter This refactor include the following : * Creation of a new class Creation of a new class, named CutterWidget, that inherits from QDockWidget and is used to represent all of the widgets of the main window. The goal of this class is to regroup all the behaviour shared by the widgets of Cutter. For example : in the constructor, instructions corresponding of those present in the macro **ADD_DOCK** (in MainWindow.cpp) are executed. This was made because I think that the macro **ADD_DOCK** which is used to construct the widgets does not take advantage of the object structure. * Ensure that every widget has a parent Some widgets were created using the constructor QDockWidget, but using **nullptr** (default) as argument, thus they haven't got any parent. The constructor of a CutterWidget takes as argument the MainWindow and an action (optional) and calls the constructor of QDockWidget with the main window as argument. This is valid under the assumption that it is mandatory for every widget to have the main window as a parent. * Constructors removal The constructors of some widgets are not used anywhere and does not seem not fullfill any current usecase. They were removed. * Renaming CutterWidget to CutterDockWidget
62 lines
1.2 KiB
C++
62 lines
1.2 KiB
C++
#ifndef CONSOLEWIDGET_H
|
|
#define CONSOLEWIDGET_H
|
|
|
|
#include <memory>
|
|
#include "MainWindow.h"
|
|
#include "CutterDockWidget.h"
|
|
|
|
namespace Ui
|
|
{
|
|
class ConsoleWidget;
|
|
}
|
|
|
|
|
|
class ConsoleWidget : public CutterDockWidget
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit ConsoleWidget(MainWindow *main, QAction *action = nullptr);
|
|
|
|
~ConsoleWidget();
|
|
|
|
void addOutput(const QString &msg);
|
|
void addDebugOutput(const QString &msg);
|
|
|
|
void setDebugOutputEnabled(bool enabled) { debugOutputEnabled = enabled; }
|
|
|
|
void setMaxHistoryEntries(int max) { maxHistoryEntries = max; }
|
|
|
|
public slots:
|
|
void focusInputLineEdit();
|
|
|
|
private slots:
|
|
void setupFont();
|
|
|
|
void on_inputLineEdit_returnPressed();
|
|
|
|
void on_execButton_clicked();
|
|
|
|
void showCustomContextMenu(const QPoint &pt);
|
|
|
|
void historyNext();
|
|
void historyPrev();
|
|
|
|
void clear();
|
|
|
|
private:
|
|
void scrollOutputToEnd();
|
|
void historyAdd(const QString &input);
|
|
void invalidateHistoryPosition();
|
|
QString executeCommand(QString command);
|
|
|
|
std::unique_ptr<Ui::ConsoleWidget> ui;
|
|
QList<QAction *> actions;
|
|
bool debugOutputEnabled;
|
|
int maxHistoryEntries;
|
|
int lastHistoryPosition;
|
|
QStringList history;
|
|
};
|
|
|
|
#endif // CONSOLEWIDGET_H
|