Warning, file /multimedia/amarok/src/toolbar/SlimToolbar.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /**************************************************************************************** 0002 * Copyright (c) 2009 Nikolaj Hald Nielsen <nhn@kde.org> * 0003 * Copyright (c) 2009 Mark Kretschmann <kretschmann@kde.org> * 0004 * * 0005 * This program is free software; you can redistribute it and/or modify it under * 0006 * the terms of the GNU General Public License as published by the Free Software * 0007 * Foundation; either version 2 of the License, or (at your option) any later * 0008 * version. * 0009 * * 0010 * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 0011 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 0012 * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 0013 * * 0014 * You should have received a copy of the GNU General Public License along with * 0015 * this program. If not, see <http://www.gnu.org/licenses/>. * 0016 ****************************************************************************************/ 0017 0018 #include "SlimToolbar.h" 0019 0020 #include "ActionClasses.h" 0021 #include "core/support/Amarok.h" 0022 #include "EngineController.h" 0023 #include "VolumePopupButton.h" 0024 0025 #include "widgets/ProgressWidget.h" 0026 0027 #include <QApplication> 0028 #include <QIcon> 0029 #include <KLocalizedString> 0030 #include <QVBoxLayout> 0031 0032 #include <QEvent> 0033 #include <QLayout> 0034 0035 SlimToolbar::SlimToolbar( QWidget * parent ) 0036 : QToolBar( i18n( "Slim Toolbar" ), parent ) 0037 , m_currentTrackToolbar( nullptr ) 0038 , m_volumePopupButton( nullptr ) 0039 { 0040 setObjectName( "Slim Toolbar" ); 0041 0042 setIconSize( QSize( 28, 28 ) ); 0043 layout()->setSpacing( 0 ); 0044 setContentsMargins( 0, 0, 0, 0 ); 0045 0046 addAction( Amarok::actionCollection()->action( "prev" ) ); 0047 addAction( Amarok::actionCollection()->action( "play_pause" ) ); 0048 addAction( Amarok::actionCollection()->action( "stop" ) ); 0049 addAction( Amarok::actionCollection()->action( "next" ) ); 0050 0051 m_currentTrackToolbar = new CurrentTrackToolbar( nullptr ); 0052 0053 addWidget( m_currentTrackToolbar ); 0054 0055 ProgressWidget *progressWidget = new ProgressWidget( nullptr ); 0056 addWidget( progressWidget ); 0057 0058 0059 QToolBar *volumeToolBar = new QToolBar( this ); 0060 volumeToolBar->setIconSize( QSize( 22, 22 ) ); 0061 volumeToolBar->setContentsMargins( 0, 0, 0, 0 ); 0062 m_volumePopupButton = new VolumePopupButton( this ); 0063 volumeToolBar->addWidget( m_volumePopupButton ); 0064 addWidget( volumeToolBar ); 0065 0066 installEventFilter( this ); 0067 } 0068 0069 SlimToolbar::~SlimToolbar() 0070 {} 0071 0072 bool 0073 SlimToolbar::eventFilter( QObject* object, QEvent* event ) 0074 { 0075 // This makes it possible to change volume by using the mouse wheel anywhere on the toolbar 0076 if( event->type() == QEvent::Wheel && object == this ) 0077 { 0078 qApp->sendEvent( m_volumePopupButton, event ); 0079 return true; 0080 } 0081 0082 return QToolBar::eventFilter( object, event ); 0083 } 0084 0085