File indexing completed on 2024-05-05 04:49:24
0001 /**************************************************************************************** 0002 * Copyright (c) 2009 Nikolaj Hald Nielsen <nhn@kde.org> * 0003 * * 0004 * This program is free software; you can redistribute it and/or modify it under * 0005 * the terms of the GNU General Public License as published by the Free Software * 0006 * Foundation; either version 2 of the License, or (at your option) any later * 0007 * version. * 0008 * * 0009 * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 0010 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 0011 * PARTICULAR PURPOSE. See the GNU General Pulic License for more details. * 0012 * * 0013 * You should have received a copy of the GNU General Public License along with * 0014 * this program. If not, see <http://www.gnu.org/licenses/>. * 0015 ****************************************************************************************/ 0016 0017 #include "AmarokDockWidget.h" 0018 0019 AmarokDockWidget::AmarokDockWidget( const QString & title, QWidget * parent, Qt::WindowFlags flags ) 0020 : QDockWidget( title, parent, flags ) 0021 , m_polished( false ) 0022 { 0023 m_dummyTitleBarWidget = new QWidget( this ); 0024 connect( this, &AmarokDockWidget::visibilityChanged, this, &AmarokDockWidget::slotVisibilityChanged ); 0025 } 0026 0027 void AmarokDockWidget::slotVisibilityChanged( bool visible ) 0028 { 0029 if( visible ) 0030 ensurePolish(); 0031 } 0032 0033 void AmarokDockWidget::ensurePolish() 0034 { 0035 if( !m_polished ) 0036 { 0037 polish(); 0038 m_polished = true; 0039 } 0040 } 0041 0042 void AmarokDockWidget::setMovable( bool movable ) 0043 { 0044 if( movable ) 0045 { 0046 const QFlags<QDockWidget::DockWidgetFeature> features = QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable | QDockWidget::DockWidgetClosable; 0047 setTitleBarWidget( nullptr ); 0048 setFeatures( features ); 0049 } 0050 else 0051 { 0052 const QFlags<QDockWidget::DockWidgetFeature> features = QDockWidget::NoDockWidgetFeatures; 0053 setTitleBarWidget( m_dummyTitleBarWidget ); 0054 setFeatures( features ); 0055 } 0056 } 0057