From 2f0a7a3d892b6b2c458b3e3eba215a6334f6c187 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Fri, 17 Jun 2022 12:12:12 +0800 Subject: [PATCH] - fix: reduce height of the message panel when dragging from right to bottom --- NEWS.md | 1 + RedPandaIDE/mainwindow.cpp | 32 ++++++++++++++++++++++++++------ RedPandaIDE/mainwindow.h | 1 + RedPandaIDE/mainwindow.ui | 18 ++++++++++++++++++ 4 files changed, 46 insertions(+), 6 deletions(-) diff --git a/NEWS.md b/NEWS.md index 8872df5a..381d9d26 100644 --- a/NEWS.md +++ b/NEWS.md @@ -8,6 +8,7 @@ Red Panda C++ Version 1.1.1 - fix: when run/debug the executable, add current compiler set's bin folders to path - fix: when open in shell, add current compiler set's bin folders to path - fix: when debug the executable using gdb server, add current compiler set's bin folders to path + - fix: reduce height of the message panel when dragging from right to bottom Red Panda C++ Version 1.1.0 - enhancement: when ctrl+mouse cursor hovered an identifier or header name, use underline to highlight it diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index 3f1bb9c6..a996c169 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -6266,6 +6266,8 @@ static void setSplitterInDockLocation(QSplitter* splitter, const Qt::DockWidgetA } void MainWindow::setDockExplorerToArea(const Qt::DockWidgetArea &area) { + if (area==Qt::DockWidgetArea::NoDockWidgetArea) + return; setDockTitlebarLocation(ui->dockExplorer,area); setTabsInDockLocation(ui->tabExplorer,area); ui->dockMessages->setAllowedAreas( @@ -6277,15 +6279,32 @@ void MainWindow::setDockExplorerToArea(const Qt::DockWidgetArea &area) void MainWindow::setDockMessagesToArea(const Qt::DockWidgetArea &area) { - setDockTitlebarLocation(ui->dockMessages,area); - setTabsInDockLocation(ui->tabMessages,area); - setSplitterInDockLocation(ui->splitterDebug,area); - setSplitterInDockLocation(ui->splitterProblem,area); + Qt::DockWidgetArea effectiveArea; + if (area==Qt::DockWidgetArea::NoDockWidgetArea) { + switch (mMessagesDockLocation) { + case Qt::DockWidgetArea::BottomDockWidgetArea: + case Qt::DockWidgetArea::TopDockWidgetArea: + effectiveArea = Qt::DockWidgetArea::RightDockWidgetArea; + break; + default: + if (dockWidgetArea(ui->dockExplorer)!=Qt::DockWidgetArea::BottomDockWidgetArea) + effectiveArea = Qt::DockWidgetArea::BottomDockWidgetArea; + else + effectiveArea = Qt::DockWidgetArea::LeftDockWidgetArea; + } + } else { + effectiveArea = area; + mMessagesDockLocation = area; + setDockTitlebarLocation(ui->dockMessages,effectiveArea); + } + setTabsInDockLocation(ui->tabMessages,effectiveArea); + setSplitterInDockLocation(ui->splitterDebug,effectiveArea); + setSplitterInDockLocation(ui->splitterProblem,effectiveArea); ui->dockExplorer->setAllowedAreas( (Qt::DockWidgetArea::LeftDockWidgetArea | Qt::DockWidgetArea::BottomDockWidgetArea | Qt::DockWidgetArea::RightDockWidgetArea) - & ~area); + & ~effectiveArea); QGridLayout* layout=(QGridLayout*)ui->panelProblemCase->layout(); layout->removeWidget(ui->widgetProblemCaseInputCaption); layout->removeWidget(ui->widgetProblemCaseOutputCaption); @@ -6296,7 +6315,7 @@ void MainWindow::setDockMessagesToArea(const Qt::DockWidgetArea &area) layout->removeWidget(ui->lblProblemCaseInput); layout->removeWidget(ui->lblProblemCaseOutput); layout->removeWidget(ui->lblProblemCaseExpected); - switch(area) { + switch(effectiveArea) { case Qt::DockWidgetArea::BottomDockWidgetArea: case Qt::DockWidgetArea::TopDockWidgetArea: layout->addWidget(ui->widgetProblemCaseInputCaption, 0, 0, 1, 1); @@ -7934,3 +7953,4 @@ void MainWindow::on_chkIgnoreSpaces_stateChanged(int /*arg1*/) pSettings->executor().setIgnoreSpacesWhenValidatingCases(ui->chkIgnoreSpaces->isChecked()); } + diff --git a/RedPandaIDE/mainwindow.h b/RedPandaIDE/mainwindow.h index 1dac7a20..0596abca 100644 --- a/RedPandaIDE/mainwindow.h +++ b/RedPandaIDE/mainwindow.h @@ -713,6 +713,7 @@ private: QElapsedTimer mParserTimer; QFileSystemWatcher mFileSystemWatcher; std::shared_ptr mProject; + Qt::DockWidgetArea mMessagesDockLocation; std::shared_ptr mCompletionPopup; std::shared_ptr mHeaderCompletionPopup; diff --git a/RedPandaIDE/mainwindow.ui b/RedPandaIDE/mainwindow.ui index daff73d3..cd64aff0 100644 --- a/RedPandaIDE/mainwindow.ui +++ b/RedPandaIDE/mainwindow.ui @@ -1747,6 +1747,12 @@ + + + 0 + 0 + + QPlainTextEdit::NoWrap @@ -1757,6 +1763,12 @@ + + + 0 + 0 + + QPlainTextEdit::NoWrap @@ -1884,6 +1896,12 @@ + + + 0 + 0 + + QPlainTextEdit::NoWrap