diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index 5fee3d26..0e10e004 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -4935,6 +4935,9 @@ void MainWindow::on_tabMessages_tabBarClicked(int index) { if (index == ui->tabMessages->currentIndex()) { ui->tabMessages->toggleShrined(); + if (!ui->tabMessages->isShrinked()) { + resizeDocks({ui->dockMessages},{ui->tabMessages->beforeShrinkWidthOrHeight()},ui->tabMessages->shrinkOrientation()); + } } } @@ -5366,9 +5369,10 @@ void MainWindow::on_actionForward_triggered() void MainWindow::on_tabInfos_tabBarClicked(int index) { if (index == ui->tabInfos->currentIndex()) { - int width = ui->tabInfos->tabBar()->width(); ui->tabInfos->toggleShrined(); -// openCloseLeftPanel(!mLeftPanelOpenned); + if (!ui->tabInfos->isShrinked()) { + resizeDocks({ui->dockInfos},{ui->tabInfos->beforeShrinkWidthOrHeight()},ui->tabInfos->shrinkOrientation()); + } } } @@ -7703,19 +7707,17 @@ void MainWindow::on_dockInfos_dockLocationChanged(const Qt::DockWidgetArea &area void MainWindow::on_dockMessages_dockLocationChanged(const Qt::DockWidgetArea &area) { - qDebug()<<"-----"; - qDebug()<dockMessages->minimumSize(); - qDebug()<tabMessages->minimumSize(); - qDebug()<tabMessages->minimumSizeHint(); switch(area) { case Qt::DockWidgetArea::BottomDockWidgetArea: case Qt::DockWidgetArea::TopDockWidgetArea: ui->splitterDebug->setOrientation(Qt::Orientation::Horizontal); ui->splitterProblem->setOrientation(Qt::Orientation::Horizontal); + ui->dockMessages->setFeatures( ui->dockMessages->features() | QDockWidget::DockWidgetVerticalTitleBar); break; default: ui->splitterDebug->setOrientation(Qt::Orientation::Vertical); ui->splitterProblem->setOrientation(Qt::Orientation::Vertical); + ui->dockMessages->setFeatures( ui->dockMessages->features() & ~QDockWidget::DockWidgetVerticalTitleBar); } switch(area) { case Qt::DockWidgetArea::BottomDockWidgetArea: @@ -7734,8 +7736,5 @@ void MainWindow::on_dockMessages_dockLocationChanged(const Qt::DockWidgetArea &a default: break; } - qDebug()<dockMessages->minimumSize(); - qDebug()<tabMessages->minimumSize(); - qDebug()<tabMessages->minimumSizeHint(); } diff --git a/RedPandaIDE/mainwindow.ui b/RedPandaIDE/mainwindow.ui index 625461ff..cec471c2 100644 --- a/RedPandaIDE/mainwindow.ui +++ b/RedPandaIDE/mainwindow.ui @@ -6,8 +6,8 @@ 0 0 - 1114 - 627 + 945 + 619 @@ -116,7 +116,7 @@ 0 0 - 1114 + 945 26 @@ -829,14 +829,8 @@ - - - 818 - 235 - - - QDockWidget::DockWidgetMovable + QDockWidget::DockWidgetMovable|QDockWidget::DockWidgetVerticalTitleBar Qt::BottomDockWidgetArea|Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea @@ -858,7 +852,7 @@ QTabWidget::South - 0 + 4 diff --git a/RedPandaIDE/widgets/shrinkabletabwidget.cpp b/RedPandaIDE/widgets/shrinkabletabwidget.cpp index 24a81eb3..9d004707 100644 --- a/RedPandaIDE/widgets/shrinkabletabwidget.cpp +++ b/RedPandaIDE/widgets/shrinkabletabwidget.cpp @@ -18,6 +18,8 @@ #include #include +QHash ShrinkableTabWidget::BeforeShrinkSizes; + ShrinkableTabWidget::ShrinkableTabWidget(QWidget *parent):QTabWidget(parent), mShrinked(false) { @@ -26,8 +28,8 @@ ShrinkableTabWidget::ShrinkableTabWidget(QWidget *parent):QTabWidget(parent), void ShrinkableTabWidget::setShrinked(bool shrinked) { - if (!mShrinked) { - mBeforeShrinkSize = size(); + if (!mShrinked && shrinked) { + BeforeShrinkSizes.insert(this, size()); } mShrinked = shrinked; switch(this->tabPosition()) { @@ -49,11 +51,43 @@ void ShrinkableTabWidget::setShrinked(bool shrinked) } } +bool ShrinkableTabWidget::isShrinked() const +{ + return mShrinked; +} + void ShrinkableTabWidget::toggleShrined() { setShrinked(!mShrinked); } +QSize ShrinkableTabWidget::beforeShrinkSize() +{ + QSize size = BeforeShrinkSizes.value(this,QSize()); + if (!size.isValid()) + size = QSize(width(),height()); + return size; +} + +int ShrinkableTabWidget::beforeShrinkWidthOrHeight() +{ + if (shrinkOrientation()==Qt::Vertical) + return beforeShrinkSize().height(); + else + return beforeShrinkSize().width(); +} + +Qt::Orientation ShrinkableTabWidget::shrinkOrientation() +{ + switch(this->tabPosition()) { + case QTabWidget::East: + case QTabWidget::West: + return Qt::Horizontal; + default: + return Qt::Vertical; + } +} + QSize ShrinkableTabWidget::sizeHint() const { return QTabWidget::sizeHint(); @@ -71,7 +105,5 @@ QSize ShrinkableTabWidget::minimumSizeHint() const case QTabWidget::South: size.setHeight(tabBar()->height()); } -// qDebug()<<"min size hint()"< BeforeShrinkSizes; }; #endif // SHRINKABLETABWIDGET_H