Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable minimization on all subwindows #2983

Merged
merged 7 commits into from Sep 27, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Binary file modified data/themes/classic/maximize.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed data/themes/classic/minimize.png
Binary file not shown.
Binary file modified data/themes/default/maximize.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed data/themes/default/minimize.png
Binary file not shown.
1 change: 0 additions & 1 deletion include/SubWindow.h
Expand Up @@ -70,7 +70,6 @@ class EXPORT SubWindow : public QMdiSubWindow
const QSize m_buttonSize;
const int m_titleBarHeight;
QPushButton * m_closeBtn;
QPushButton * m_minimizeBtn;
QPushButton * m_maximizeBtn;
QPushButton * m_restoreBtn;
QBrush m_activeColor;
Expand Down
36 changes: 13 additions & 23 deletions src/gui/SubWindow.cpp
Expand Up @@ -49,7 +49,7 @@ SubWindow::SubWindow( QWidget *parent, Qt::WindowFlags windowFlags ) :
m_textShadowColor = Qt::black;
m_borderColor = Qt::black;

// close, minimize, maximize and restore (after minimizing) buttons
// close, maximize and restore (after maximizing) buttons
m_closeBtn = new QPushButton( embed::getIconPixmap( "close" ), QString::null, this );
m_closeBtn->resize( m_buttonSize );
m_closeBtn->setFocusPolicy( Qt::NoFocus );
Expand All @@ -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 );
Expand All @@ -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 );
}


Expand Down Expand Up @@ -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;
Expand All @@ -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 );
Expand All @@ -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 );
}

Expand Down
14 changes: 5 additions & 9 deletions src/gui/widgets/EffectView.cpp
Expand Up @@ -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() ) );

Expand Down Expand Up @@ -291,8 +292,3 @@ void EffectView::modelChanged()
m_autoQuit->setModel( &effect()->m_autoQuitModel );
m_gate->setModel( &effect()->m_gateModel );
}