Fix #161: Make console dockable. (#198)

This commit is contained in:
Thomas (nezza-_-) Roth 2017-12-10 17:55:42 +01:00 committed by xarkes
parent 8e0ca36e98
commit e3e108f354
7 changed files with 146 additions and 160 deletions

View File

@ -105,7 +105,7 @@ MainWindow::MainWindow(QWidget *parent) :
gotoEntry(nullptr), gotoEntry(nullptr),
sdbDock(nullptr), sdbDock(nullptr),
sectionsDock(nullptr), sectionsDock(nullptr),
consoleWidget(nullptr) consoleDock(nullptr)
{ {
doLock = false; doLock = false;
configuration = new Configuration(); configuration = new Configuration();
@ -130,8 +130,6 @@ void MainWindow::initUI()
// Hide central tab widget tabs // Hide central tab widget tabs
QTabBar *centralbar = ui->centralTabWidget->tabBar(); QTabBar *centralbar = ui->centralTabWidget->tabBar();
centralbar->setVisible(false); centralbar->setVisible(false);
consoleWidget = new ConsoleWidget(this);
ui->tabVerticalLayout->addWidget(consoleWidget);
// Sepparator between back/forward and undo/redo buttons // Sepparator between back/forward and undo/redo buttons
QWidget *spacer4 = new QWidget(); QWidget *spacer4 = new QWidget();
@ -195,12 +193,19 @@ void MainWindow::initUI()
pseudocodeDock = new PseudocodeWidget(tr("Pseudocode"), this); pseudocodeDock = new PseudocodeWidget(tr("Pseudocode"), this);
dockWidgets.push_back(pseudocodeDock); dockWidgets.push_back(pseudocodeDock);
consoleDock = new ConsoleWidget(tr("Console"), this);
dockWidgets.push_back(consoleDock);
// Add graph view as dockable // Add graph view as dockable
graphDock = new QDockWidget(tr("Graph"), this); graphDock = new QDockWidget(tr("Graph"), this);
graphDock->setObjectName("Graph"); graphDock->setObjectName("Graph");
graphDock->setAllowedAreas(Qt::AllDockWidgetAreas); graphDock->setAllowedAreas(Qt::AllDockWidgetAreas);
graphView = new DisassemblerGraphView(graphDock); graphView = new DisassemblerGraphView(graphDock);
graphDock->setWidget(graphView); graphDock->setWidget(graphView);
// Hide centralWidget as we do not need it
ui->centralWidget->hide();
connect(graphDock, &QDockWidget::visibilityChanged, graphDock, [](bool visibility) connect(graphDock, &QDockWidget::visibilityChanged, graphDock, [](bool visibility)
{ {
if (visibility) if (visibility)
@ -287,7 +292,7 @@ void MainWindow::initUI()
*/ */
// Period goes to command entry // Period goes to command entry
QShortcut *cmd_shortcut = new QShortcut(QKeySequence(Qt::Key_Period), this); QShortcut *cmd_shortcut = new QShortcut(QKeySequence(Qt::Key_Period), this);
connect(cmd_shortcut, SIGNAL(activated()), consoleWidget, SLOT(focusInputLineEdit())); connect(cmd_shortcut, SIGNAL(activated()), consoleDock, SLOT(focusInputLineEdit()));
// G and S goes to goto entry // G and S goes to goto entry
QShortcut *goto_shortcut = new QShortcut(QKeySequence(Qt::Key_G), this); QShortcut *goto_shortcut = new QShortcut(QKeySequence(Qt::Key_G), this);
@ -645,18 +650,18 @@ void MainWindow::on_actionDisasAdd_comment_triggered()
void MainWindow::restoreDocks() void MainWindow::restoreDocks()
{ {
// bottom right // In the upper half the functions are the first widget
addDockWidget(Qt::RightDockWidgetArea, sectionsDock);
// left
addDockWidget(Qt::TopDockWidgetArea, functionsDock); addDockWidget(Qt::TopDockWidgetArea, functionsDock);
// center // Function | Dashboard | Sidebar
splitDockWidget(functionsDock, dashboardDock, Qt::Horizontal); splitDockWidget(functionsDock, dashboardDock, Qt::Horizontal);
// right (sidebar)
splitDockWidget(dashboardDock, sidebarDock, Qt::Horizontal); splitDockWidget(dashboardDock, sidebarDock, Qt::Horizontal);
// In the lower half the console is the first widget
addDockWidget(Qt::BottomDockWidgetArea, consoleDock);
// Console | Sections
splitDockWidget(consoleDock, sectionsDock, Qt::Horizontal);
// tabs for center (must be applied after splitDockWidget()) // tabs for center (must be applied after splitDockWidget())
tabifyDockWidget(sectionsDock, commentsDock); tabifyDockWidget(sectionsDock, commentsDock);
@ -674,7 +679,6 @@ void MainWindow::restoreDocks()
tabifyDockWidget(dashboardDock, notepadDock); tabifyDockWidget(dashboardDock, notepadDock);
dashboardDock->raise(); dashboardDock->raise();
sectionsDock->raise();
} }
@ -693,6 +697,7 @@ void MainWindow::showDefaultDocks()
functionsDock, functionsDock,
commentsDock, commentsDock,
stringsDock, stringsDock,
consoleDock,
importsDock, importsDock,
symbolsDock, symbolsDock,
notepadDock, notepadDock,
@ -739,18 +744,6 @@ void MainWindow::on_actionDefaut_triggered()
resetToDefaultLayout(); resetToDefaultLayout();
} }
void MainWindow::on_actionhide_bottomPannel_triggered()
{
if (ui->centralWidget->isVisible())
{
ui->centralWidget->hide();
}
else
{
ui->centralWidget->show();
}
}
void MainWindow::sendToNotepad(const QString &txt) void MainWindow::sendToNotepad(const QString &txt)
{ {
core->setNotes(core->getNotes() + "```\n" + txt + "\n```"); core->setNotes(core->getNotes() + "```\n" + txt + "\n```");
@ -766,13 +759,13 @@ void MainWindow::on_actionFunctionsRename_triggered()
void MainWindow::addOutput(const QString &msg) void MainWindow::addOutput(const QString &msg)
{ {
consoleWidget->addOutput(msg); consoleDock->addOutput(msg);
} }
void MainWindow::addDebugOutput(const QString &msg) void MainWindow::addDebugOutput(const QString &msg)
{ {
printf("debug output: %s\n", msg.toLocal8Bit().constData()); printf("debug output: %s\n", msg.toLocal8Bit().constData());
consoleWidget->addDebugOutput(msg); consoleDock->addDebugOutput(msg);
} }
void MainWindow::on_actionNew_triggered() void MainWindow::on_actionNew_triggered()

View File

@ -108,8 +108,6 @@ public slots:
void on_actionTabs_triggered(); void on_actionTabs_triggered();
void on_actionhide_bottomPannel_triggered();
void lockUnlock_Docks(bool what); void lockUnlock_Docks(bool what);
void on_actionDashboard_triggered(); void on_actionDashboard_triggered();
@ -202,7 +200,7 @@ private:
SdbDock *sdbDock; SdbDock *sdbDock;
//QAction *sidebar_action; //QAction *sidebar_action;
SectionsDock *sectionsDock; SectionsDock *sectionsDock;
ConsoleWidget *consoleWidget; ConsoleWidget *consoleDock;
void toggleDockWidget(QDockWidget *dock_widget); void toggleDockWidget(QDockWidget *dock_widget);

View File

@ -90,8 +90,8 @@ static bool isForbidden(const QString &input)
return false; return false;
} }
ConsoleWidget::ConsoleWidget(QWidget *parent) : ConsoleWidget::ConsoleWidget(QWidget *parent, Qt::WindowFlags flags) :
QWidget(parent), QDockWidget(parent, flags),
ui(new Ui::ConsoleWidget), ui(new Ui::ConsoleWidget),
debugOutputEnabled(true), debugOutputEnabled(true),
maxHistoryEntries(100), maxHistoryEntries(100),
@ -144,6 +144,12 @@ ConsoleWidget::ConsoleWidget(QWidget *parent) :
connect(Config(), SIGNAL(fontsUpdated()), this, SLOT(setupFont())); connect(Config(), SIGNAL(fontsUpdated()), this, SLOT(setupFont()));
} }
ConsoleWidget::ConsoleWidget(const QString &title, QWidget *parent, Qt::WindowFlags flags)
: ConsoleWidget(parent, flags)
{
setWindowTitle(title);
}
ConsoleWidget::~ConsoleWidget() {} ConsoleWidget::~ConsoleWidget() {}
void ConsoleWidget::setupFont() void ConsoleWidget::setupFont()

View File

@ -11,12 +11,14 @@ namespace Ui
} }
class ConsoleWidget : public QWidget class ConsoleWidget : public QDockWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit ConsoleWidget(QWidget *parent = 0); explicit ConsoleWidget(const QString &title, QWidget *parent = nullptr, Qt::WindowFlags flags = 0);
explicit ConsoleWidget(QWidget *parent = nullptr, Qt::WindowFlags flags = 0);
~ConsoleWidget(); ~ConsoleWidget();
void addOutput(const QString &msg); void addOutput(const QString &msg);

View File

@ -1,18 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>ConsoleWidget</class> <class>ConsoleWidget</class>
<widget class="QWidget" name="ConsoleWidget"> <widget class="QDockWidget" name="ConsoleWidget">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>583</width> <width>400</width>
<height>534</height> <height>300</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Form</string> <string notr="true">Entry Points</string>
</property> </property>
<widget class="QWidget" name="dockWidgetContents">
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing"> <property name="spacing">
<number>0</number> <number>0</number>
@ -142,6 +143,7 @@ QToolButton:pressed {
</item> </item>
</layout> </layout>
</widget> </widget>
</widget>
<resources> <resources>
<include location="../resources.qrc"/> <include location="../resources.qrc"/>
</resources> </resources>

View File

@ -40,19 +40,6 @@ void SideBar::on_tabsButton_clicked()
this->main->on_actionTabs_triggered(); this->main->on_actionTabs_triggered();
} }
void SideBar::on_consoleButton_clicked()
{
this->main->on_actionhide_bottomPannel_triggered();
if (ui->consoleButton->isChecked())
{
ui->consoleButton->setIcon(QIcon(":/img/icons/up_white.svg"));
}
else
{
ui->consoleButton->setIcon(QIcon(":/img/icons/down_white.svg"));
}
}
void SideBar::on_lockButton_clicked() void SideBar::on_lockButton_clicked()
{ {
if (ui->lockButton->isChecked()) if (ui->lockButton->isChecked())

View File

@ -26,8 +26,6 @@ private slots:
void on_tabsButton_clicked(); void on_tabsButton_clicked();
void on_consoleButton_clicked();
void on_lockButton_clicked(); void on_lockButton_clicked();
void on_themesButton_clicked(); void on_themesButton_clicked();