mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-04 21:27:58 +02:00
Made the compact and accounts menus pop up inside the window.
This commit is contained in:
@@ -73,6 +73,7 @@ SET( tomahawkSourcesGui ${tomahawkSourcesGui}
|
|||||||
TomahawkWindow.cpp
|
TomahawkWindow.cpp
|
||||||
LoadXSPFDialog.cpp
|
LoadXSPFDialog.cpp
|
||||||
SocialWidget.cpp
|
SocialWidget.cpp
|
||||||
|
ContainedMenuButton.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
IF( WITH_BREAKPAD )
|
IF( WITH_BREAKPAD )
|
||||||
|
52
src/ContainedMenuButton.cpp
Normal file
52
src/ContainedMenuButton.cpp
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
|
*
|
||||||
|
* Copyright 2012, Teo Mrnjavac <teo@kde.org>
|
||||||
|
*
|
||||||
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Tomahawk is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "ContainedMenuButton.h"
|
||||||
|
|
||||||
|
#include <QtGui/QMouseEvent>
|
||||||
|
|
||||||
|
ContainedMenuButton::ContainedMenuButton( QWidget *parent )
|
||||||
|
: QToolButton( parent )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ContainedMenuButton::setMenu( QMenu *menu )
|
||||||
|
{
|
||||||
|
m_menu = menu;
|
||||||
|
connect( m_menu, SIGNAL( aboutToHide() ), SLOT( menuHidden() ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ContainedMenuButton::mousePressEvent( QMouseEvent *event )
|
||||||
|
{
|
||||||
|
if( m_menu )
|
||||||
|
{
|
||||||
|
QPoint myPos = mapToGlobal( rect().bottomRight() );
|
||||||
|
myPos.rx() -= m_menu->sizeHint().width();
|
||||||
|
m_menu->popup( myPos );
|
||||||
|
event->accept();
|
||||||
|
}
|
||||||
|
QToolButton::mousePressEvent( event );
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ContainedMenuButton::menuHidden()
|
||||||
|
{
|
||||||
|
setDown( false );
|
||||||
|
}
|
47
src/ContainedMenuButton.h
Normal file
47
src/ContainedMenuButton.h
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
|
*
|
||||||
|
* Copyright 2012, Teo Mrnjavac <teo@kde.org>
|
||||||
|
*
|
||||||
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Tomahawk is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef CONTAINEDMENUBUTTON_H
|
||||||
|
#define CONTAINEDMENUBUTTON_H
|
||||||
|
|
||||||
|
#include <QtGui/QMenu>
|
||||||
|
#include <QtGui/QToolButton>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The ContainedMenuButton class defines a modified QToolButton that pops
|
||||||
|
* up a QMenu under itself, stretching left instead of right and witout
|
||||||
|
* drawing an arrow primitive.
|
||||||
|
*/
|
||||||
|
class ContainedMenuButton : public QToolButton
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit ContainedMenuButton( QWidget *parent = 0 );
|
||||||
|
|
||||||
|
void setMenu( QMenu *menu );
|
||||||
|
QMenu *menu() const { return m_menu; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void mousePressEvent( QMouseEvent *event );
|
||||||
|
private slots:
|
||||||
|
void menuHidden();
|
||||||
|
private:
|
||||||
|
QMenu *m_menu;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CONTAINEDMENUBUTTON_H
|
@@ -72,6 +72,7 @@
|
|||||||
#include "libtomahawk/filemetadata/ScanManager.h"
|
#include "libtomahawk/filemetadata/ScanManager.h"
|
||||||
#include "TomahawkApp.h"
|
#include "TomahawkApp.h"
|
||||||
#include "LoadXSPFDialog.h"
|
#include "LoadXSPFDialog.h"
|
||||||
|
#include "ContainedMenuButton.h"
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
#include <qtsparkle/Updater>
|
#include <qtsparkle/Updater>
|
||||||
@@ -261,23 +262,19 @@ TomahawkWindow::setupToolBar()
|
|||||||
rightSpacer->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred );
|
rightSpacer->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred );
|
||||||
toolbar->addWidget( rightSpacer );
|
toolbar->addWidget( rightSpacer );
|
||||||
|
|
||||||
QToolButton *accountsMenuButton = new QToolButton( toolbar );
|
ContainedMenuButton *accountsMenuButton = new ContainedMenuButton( toolbar );
|
||||||
accountsMenuButton->setIcon( QIcon( RESPATH "images/account-settings.png" ) );
|
accountsMenuButton->setIcon( QIcon( RESPATH "images/account-settings.png" ) );
|
||||||
accountsMenuButton->setText( tr( "&Network" ) );
|
accountsMenuButton->setText( tr( "&Network" ) );
|
||||||
accountsMenuButton->setMenu( m_menuAccounts );
|
accountsMenuButton->setMenu( m_menuAccounts );
|
||||||
//TODO: when we decide if compressed menus go left or right, if they go right, make
|
|
||||||
// them pop up *inside* the main window.
|
|
||||||
accountsMenuButton->setToolButtonStyle( Qt::ToolButtonIconOnly );
|
accountsMenuButton->setToolButtonStyle( Qt::ToolButtonIconOnly );
|
||||||
accountsMenuButton->setPopupMode( QToolButton::InstantPopup );
|
|
||||||
toolbar->addWidget( accountsMenuButton );
|
toolbar->addWidget( accountsMenuButton );
|
||||||
|
|
||||||
#ifndef Q_OS_MAC
|
#ifndef Q_OS_MAC
|
||||||
QToolButton *compactMenuButton = new QToolButton( toolbar );
|
ContainedMenuButton *compactMenuButton = new ContainedMenuButton( toolbar );
|
||||||
compactMenuButton->setIcon( QIcon( RESPATH "images/configure.png" ) );
|
compactMenuButton->setIcon( QIcon( RESPATH "images/configure.png" ) );
|
||||||
compactMenuButton->setText( tr( "&Main Menu" ) );
|
compactMenuButton->setText( tr( "&Main Menu" ) );
|
||||||
compactMenuButton->setMenu( m_compactMainMenu );
|
compactMenuButton->setMenu( m_compactMainMenu );
|
||||||
compactMenuButton->setToolButtonStyle( Qt::ToolButtonIconOnly );
|
compactMenuButton->setToolButtonStyle( Qt::ToolButtonIconOnly );
|
||||||
compactMenuButton->setPopupMode( QToolButton::InstantPopup );
|
|
||||||
m_compactMenuAction = toolbar->addWidget( compactMenuButton );
|
m_compactMenuAction = toolbar->addWidget( compactMenuButton );
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user