From be5cc6685e5d894c58e860d4f764bd29cc302012 Mon Sep 17 00:00:00 2001 From: Umcaruje Date: Wed, 28 Sep 2016 01:01:24 +0200 Subject: [PATCH] Disable minimization on all subwindows (#2983) * Disable minimization on all subwindows * Change the maximize button icon * Remove redundant boolean * Make the maximize icon play better with the close icon * I removed too much maaan * Fix spaces * Change comments --- data/themes/classic/maximize.png | Bin 163 -> 210 bytes data/themes/classic/minimize.png | Bin 150 -> 0 bytes data/themes/default/maximize.png | Bin 163 -> 210 bytes data/themes/default/minimize.png | Bin 150 -> 0 bytes include/SubWindow.h | 1 - src/gui/SubWindow.cpp | 36 +++++++++++-------------------- src/gui/widgets/EffectView.cpp | 14 +++++------- 7 files changed, 18 insertions(+), 33 deletions(-) delete mode 100644 data/themes/classic/minimize.png delete mode 100644 data/themes/default/minimize.png diff --git a/data/themes/classic/maximize.png b/data/themes/classic/maximize.png index 1cb4186241a166d2ccf8692e0c8aa6a32889ff22..fac7b46e9411913e7faa9db10d93371db5cc8406 100644 GIT binary patch delta 182 zcmZ3?c!_a>NgTe~DWM4fx<5jd delta 114 zcmcb_xR`N*3O`$tx4R3&e-K=-clqRrh7u9%C7!;n>H Q0rfI?y85}Sb4q9e0IMl1B>(^b diff --git a/data/themes/classic/minimize.png b/data/themes/classic/minimize.png deleted file mode 100644 index 33bb26378ea6458ea8a19f2a09925c29d211e8f9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 150 zcmeAS@N?(olHy`uVBq!ia0vp^f*{Pn1|+R>-G2cowj^(N7l!{JxM1({$v_d#0*}aI zppNSx%;=;sy8Er|n*2M`T6PP6?TK)$D m|1EBAZadNgTe~DWM4fx<5jd delta 114 zcmcb_xR`N*3O`$tx4R3&e-K=-clqRrh7u9%C7!;n>H Q0rfI?y85}Sb4q9e0IMl1B>(^b diff --git a/data/themes/default/minimize.png b/data/themes/default/minimize.png deleted file mode 100644 index 33bb26378ea6458ea8a19f2a09925c29d211e8f9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 150 zcmeAS@N?(olHy`uVBq!ia0vp^f*{Pn1|+R>-G2cowj^(N7l!{JxM1({$v_d#0*}aI zppNSx%;=;sy8Er|n*2M`T6PP6?TK)$D m|1EBAZadresize( m_buttonSize ); m_closeBtn->setFocusPolicy( Qt::NoFocus ); @@ -66,14 +66,6 @@ SubWindow::SubWindow( QWidget *parent, Qt::WindowFlags windowFlags ) : m_maximizeBtn->setToolTip( tr( "Maximize" ) ); connect( m_maximizeBtn, SIGNAL( clicked( bool ) ), this, SLOT( showMaximized() ) ); - m_minimizeBtn = new QPushButton( embed::getIconPixmap( "minimize" ), QString::null, this ); - m_minimizeBtn->resize( m_buttonSize ); - m_minimizeBtn->setFocusPolicy( Qt::NoFocus ); - m_minimizeBtn->setCursor( Qt::ArrowCursor ); - m_minimizeBtn->setAttribute( Qt::WA_NoMousePropagation ); - m_minimizeBtn->setToolTip( tr( "Minimize" ) ); - connect( m_minimizeBtn, SIGNAL( clicked( bool ) ), this, SLOT( showMinimized() ) ); - m_restoreBtn = new QPushButton( embed::getIconPixmap( "restore" ), QString::null, this ); m_restoreBtn->resize( m_buttonSize ); m_restoreBtn->setFocusPolicy( Qt::NoFocus ); @@ -92,6 +84,11 @@ SubWindow::SubWindow( QWidget *parent, Qt::WindowFlags windowFlags ) : m_windowTitle->setFocusPolicy( Qt::NoFocus ); m_windowTitle->setAttribute( Qt::WA_TransparentForMouseEvents, true ); m_windowTitle->setGraphicsEffect( m_shadow ); + + // disable the minimize button + setWindowFlags( Qt::SubWindow | Qt::WindowMaximizeButtonHint | + Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint | + Qt::CustomizeWindowHint ); } @@ -236,12 +233,9 @@ void SubWindow::moveEvent( QMoveEvent * event ) void SubWindow::adjustTitleBar() { // button adjustments - m_minimizeBtn->hide(); m_maximizeBtn->hide(); m_restoreBtn->hide(); - const bool isMax = isMaximized(); - const bool isMin = isMinimized(); const int rightSpace = 3; const int buttonGap = 1; const int menuButtonSpace = 24; @@ -258,23 +252,19 @@ void SubWindow::adjustTitleBar() // the close button is always needed and on the rightButtonPos m_closeBtn->move( rightButtonPos ); - // here we ask: is the Subwindow maximizable and/or minimizable + // here we ask: is the Subwindow maximizable and // then we set the buttons and show them if needed if( windowFlags() & Qt::WindowMaximizeButtonHint ) { buttonBarWidth = buttonBarWidth + m_buttonSize.width() + buttonGap; m_maximizeBtn->move( middleButtonPos ); m_restoreBtn->move( middleButtonPos ); - m_maximizeBtn->setHidden( isMax ); + m_maximizeBtn->setHidden( isMaximized() ); } - if( windowFlags() & Qt::WindowMinimizeButtonHint ) - { - buttonBarWidth = buttonBarWidth + m_buttonSize.width() + buttonGap; - m_minimizeBtn->move( m_maximizeBtn->isHidden() && !isMax ? middleButtonPos : leftButtonPos ); - m_minimizeBtn->setHidden( isMin ); - } - m_restoreBtn->setVisible( isMax || isMin ); + // we're keeping the restore button around if we open projects + // from older versions that have saved minimized windows + m_restoreBtn->setVisible( isMaximized() || isMinimized() ); // title QLabel adjustments m_windowTitle->setAlignment( Qt::AlignHCenter ); @@ -284,9 +274,9 @@ void SubWindow::adjustTitleBar() // if minimized we can't use widget()->width(). We have to hard code the width, // as the width of all minimized windows is the same. - if( isMin ) + if( isMinimized() ) { - m_restoreBtn->move( m_maximizeBtn->isHidden() ? middleButtonPos : leftButtonPos ); + m_restoreBtn->move( m_maximizeBtn->isHidden() ? middleButtonPos : leftButtonPos ); m_windowTitle->setFixedWidth( 120 ); } diff --git a/src/gui/widgets/EffectView.cpp b/src/gui/widgets/EffectView.cpp index e8effc1d7..e5935905a 100644 --- a/src/gui/widgets/EffectView.cpp +++ b/src/gui/widgets/EffectView.cpp @@ -110,13 +110,14 @@ EffectView::EffectView( Effect * _model, QWidget * _parent ) : m_controlView = effect()->controls()->createView(); if( m_controlView ) { - m_subWindow = gui->mainWindow()->addWindowedWidget( - m_controlView, - Qt::SubWindow | Qt::CustomizeWindowHint | - Qt::WindowTitleHint | Qt::WindowSystemMenuHint ); + m_subWindow = gui->mainWindow()->addWindowedWidget( m_controlView ); m_subWindow->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ); m_subWindow->setFixedSize( m_subWindow->size() ); + Qt::WindowFlags flags = m_subWindow->windowFlags(); + flags &= ~Qt::WindowMaximizeButtonHint; + m_subWindow->setWindowFlags( flags ); + connect( m_controlView, SIGNAL( closed() ), this, SLOT( closeEffects() ) ); @@ -291,8 +292,3 @@ void EffectView::modelChanged() m_autoQuit->setModel( &effect()->m_autoQuitModel ); m_gate->setModel( &effect()->m_gateModel ); } - - - - -