1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-07-31 11:20:22 +02:00

TWK-885: Hide resize handle when in osx full-screen mode

This commit is contained in:
Leo Franchi
2012-05-25 18:08:09 -04:00
parent ac46b080fe
commit f947005666
5 changed files with 57 additions and 15 deletions

View File

@@ -306,7 +306,7 @@ TomahawkApp::init()
#ifdef Q_WS_MAC #ifdef Q_WS_MAC
// Make sure to do this after main window is inited // Make sure to do this after main window is inited
Tomahawk::enableFullscreen(); Tomahawk::enableFullscreen( m_mainwindow );
#endif #endif
} }

View File

@@ -192,7 +192,7 @@ TomahawkWindow::applyPlatformTweaks()
if ( !QString( qApp->style()->metaObject()->className() ).toLower().contains( "qtcurve" ) ) if ( !QString( qApp->style()->metaObject()->className() ).toLower().contains( "qtcurve" ) )
qApp->setStyle( new ProxyStyle() ); qApp->setStyle( new ProxyStyle() );
#ifdef Q_WS_MAC #ifdef Q_OS_MAC
setUnifiedTitleAndToolBarOnMac( true ); setUnifiedTitleAndToolBarOnMac( true );
delete ui->hline1; delete ui->hline1;
delete ui->hline2; delete ui->hline2;
@@ -272,7 +272,7 @@ TomahawkWindow::setupSideBar()
sidebarWidget->layout()->setContentsMargins( 0, 0, 0, 0 ); sidebarWidget->layout()->setContentsMargins( 0, 0, 0, 0 );
sidebarWidget->layout()->setMargin( 0 ); sidebarWidget->layout()->setMargin( 0 );
#ifndef Q_WS_MAC #ifndef Q_OS_MAC
sidebarWidget->layout()->setSpacing( 0 ); sidebarWidget->layout()->setSpacing( 0 );
#endif #endif
@@ -287,11 +287,11 @@ TomahawkWindow::setupSideBar()
void void
TomahawkWindow::setupUpdateCheck() TomahawkWindow::setupUpdateCheck()
{ {
#ifndef Q_WS_MAC #ifndef Q_OS_MAC
ui->menu_Help->insertSeparator( ui->actionAboutTomahawk ); ui->menu_Help->insertSeparator( ui->actionAboutTomahawk );
#endif #endif
#if defined( Q_WS_MAC ) && defined( HAVE_SPARKLE ) #if defined( Q_OS_MAC ) && defined( HAVE_SPARKLE )
QAction* checkForUpdates = ui->menu_Help->addAction( tr( "Check For Updates..." ) ); QAction* checkForUpdates = ui->menu_Help->addAction( tr( "Check For Updates..." ) );
checkForUpdates->setMenuRole( QAction::ApplicationSpecificRole ); checkForUpdates->setMenuRole( QAction::ApplicationSpecificRole );
connect( checkForUpdates, SIGNAL( triggered( bool ) ), SLOT( checkForUpdates() ) ); connect( checkForUpdates, SIGNAL( triggered( bool ) ), SLOT( checkForUpdates() ) );
@@ -350,7 +350,7 @@ TomahawkWindow::setupSignals()
connect( ui->actionNext, SIGNAL( triggered() ), AudioEngine::instance(), SLOT( next() ) ); connect( ui->actionNext, SIGNAL( triggered() ), AudioEngine::instance(), SLOT( next() ) );
connect( ui->actionPrevious, SIGNAL( triggered() ), AudioEngine::instance(), SLOT( previous() ) ); connect( ui->actionPrevious, SIGNAL( triggered() ), AudioEngine::instance(), SLOT( previous() ) );
#if defined( Q_WS_MAC ) #if defined( Q_OS_MAC )
connect( ui->actionMinimize, SIGNAL( triggered() ), SLOT( minimize() ) ); connect( ui->actionMinimize, SIGNAL( triggered() ), SLOT( minimize() ) );
connect( ui->actionZoom, SIGNAL( triggered() ), SLOT( maximize() ) ); connect( ui->actionZoom, SIGNAL( triggered() ), SLOT( maximize() ) );
#else #else
@@ -399,7 +399,7 @@ TomahawkWindow::changeEvent( QEvent* e )
void void
TomahawkWindow::closeEvent( QCloseEvent* e ) TomahawkWindow::closeEvent( QCloseEvent* e )
{ {
#ifndef Q_WS_MAC #ifndef Q_OS_MAC
if ( e->spontaneous() && QSystemTrayIcon::isSystemTrayAvailable() ) if ( e->spontaneous() && QSystemTrayIcon::isSystemTrayAvailable() )
{ {
hide(); hide();
@@ -419,7 +419,7 @@ TomahawkWindow::showEvent( QShowEvent* e )
{ {
QMainWindow::showEvent( e ); QMainWindow::showEvent( e );
#if defined( Q_WS_MAC ) #if defined( Q_OS_MAC )
ui->actionMinimize->setDisabled( false ); ui->actionMinimize->setDisabled( false );
ui->actionZoom->setDisabled( false ); ui->actionZoom->setDisabled( false );
#endif #endif
@@ -431,7 +431,7 @@ TomahawkWindow::hideEvent( QHideEvent* e )
{ {
QMainWindow::hideEvent( e ); QMainWindow::hideEvent( e );
#if defined( Q_WS_MAC ) #if defined( Q_OS_MAC )
ui->actionMinimize->setDisabled( true ); ui->actionMinimize->setDisabled( true );
ui->actionZoom->setDisabled( true ); ui->actionZoom->setDisabled( true );
#endif #endif
@@ -442,7 +442,7 @@ void
TomahawkWindow::keyPressEvent( QKeyEvent* e ) TomahawkWindow::keyPressEvent( QKeyEvent* e )
{ {
bool accept = true; bool accept = true;
#if ! defined ( Q_WS_MAC ) #if ! defined ( Q_OS_MAC )
#define KEY_PRESSED Q_FUNC_INFO << "Multimedia Key Pressed:" #define KEY_PRESSED Q_FUNC_INFO << "Multimedia Key Pressed:"
switch( e->key() ) switch( e->key() )
{ {
@@ -590,11 +590,25 @@ TomahawkWindow::showOfflineSources()
} }
void
TomahawkWindow::fullScreenEntered()
{
statusBar()->setSizeGripEnabled( false );
}
void
TomahawkWindow::fullScreenExited()
{
statusBar()->setSizeGripEnabled( true );
}
void void
TomahawkWindow::loadSpiff() TomahawkWindow::loadSpiff()
{ {
LoadXSPFDialog* diag = new LoadXSPFDialog( this, Qt::Sheet ); LoadXSPFDialog* diag = new LoadXSPFDialog( this, Qt::Sheet );
#ifdef Q_WS_MAC #ifdef Q_OS_MAC
connect( diag, SIGNAL( finished( int ) ), this, SLOT( loadXspfFinished( int ) ) ); connect( diag, SIGNAL( finished( int ) ), this, SLOT( loadXspfFinished( int ) ) );
diag->show(); diag->show();
#else #else
@@ -719,7 +733,7 @@ void
TomahawkWindow::createPlaylist() TomahawkWindow::createPlaylist()
{ {
PlaylistTypeSelectorDlg* playlistSelectorDlg = new PlaylistTypeSelectorDlg( TomahawkApp::instance()->mainWindow(), Qt::Sheet ); PlaylistTypeSelectorDlg* playlistSelectorDlg = new PlaylistTypeSelectorDlg( TomahawkApp::instance()->mainWindow(), Qt::Sheet );
#ifndef Q_WS_MAC #ifndef Q_OS_MAC
playlistSelectorDlg->setModal( true ); playlistSelectorDlg->setModal( true );
#endif #endif
connect( playlistSelectorDlg, SIGNAL( finished( int ) ), this, SLOT( playlistCreateDialogFinished( int ) ) ); connect( playlistSelectorDlg, SIGNAL( finished( int ) ), this, SLOT( playlistCreateDialogFinished( int ) ) );
@@ -863,7 +877,7 @@ TomahawkWindow::showAboutTomahawk()
void void
TomahawkWindow::checkForUpdates() TomahawkWindow::checkForUpdates()
{ {
#ifdef Q_WS_MAC #ifdef Q_OS_MAC
Tomahawk::checkForUpdates(); Tomahawk::checkForUpdates();
#endif #endif
} }

View File

@@ -88,6 +88,9 @@ public slots:
void pluginMenuRemoved(QMenu*); void pluginMenuRemoved(QMenu*);
void showOfflineSources(); void showOfflineSources();
void fullScreenEntered();
void fullScreenExited();
private slots: private slots:
void onAccountAdded( Tomahawk::Accounts::Account* account ); void onAccountAdded( Tomahawk::Accounts::Account* account );
void onAccountConnected(); void onAccountConnected();

View File

@@ -23,6 +23,7 @@
// copyright David Sansome 2010 // copyright David Sansome 2010
class QString; class QString;
class QObject;
namespace Tomahawk { namespace Tomahawk {
@@ -43,7 +44,9 @@ void setShortcutHandler(Tomahawk::MacShortcutHandler* engine);
// used for opening files with tomahawk // used for opening files with tomahawk
void setApplicationHandler(PlatformInterface* handler); void setApplicationHandler(PlatformInterface* handler);
void checkForUpdates(); void checkForUpdates();
void enableFullscreen();
// Pass in a QObject with slots "fullScreenEntered() and fullScreenExited() in order to be notified
void enableFullscreen( QObject* notifier );
}; };

View File

@@ -43,6 +43,8 @@
#include <QDebug> #include <QDebug>
#include <QApplication> #include <QApplication>
#include <QObject>
#include <QMetaObject>
@interface MacApplication :NSApplication { @interface MacApplication :NSApplication {
AppDelegate* delegate_; AppDelegate* delegate_;
@@ -255,7 +257,7 @@ void Tomahawk::checkForUpdates() {
#define SET_LION_FULLSCREEN (NSUInteger)(1 << 7) // Defined as NSWindowCollectionBehaviorFullScreenPrimary in lion's NSWindow.h #define SET_LION_FULLSCREEN (NSUInteger)(1 << 7) // Defined as NSWindowCollectionBehaviorFullScreenPrimary in lion's NSWindow.h
#endif #endif
void Tomahawk::enableFullscreen() void Tomahawk::enableFullscreen( QObject* receiver )
{ {
// We don't support anything below leopard, so if it's not [snow] leopard it must be lion // We don't support anything below leopard, so if it's not [snow] leopard it must be lion
// Can't check for lion as Qt 4.7 doesn't have the enum val, not checking for Unknown as it will be lion // Can't check for lion as Qt 4.7 doesn't have the enum val, not checking for Unknown as it will be lion
@@ -273,6 +275,26 @@ void Tomahawk::enableFullscreen()
NSView *nsview = (NSView *)w->winId(); NSView *nsview = (NSView *)w->winId();
NSWindow *nswindow = [nsview window]; NSWindow *nswindow = [nsview window];
[nswindow setCollectionBehavior:SET_LION_FULLSCREEN]; [nswindow setCollectionBehavior:SET_LION_FULLSCREEN];
#ifdef LION
if ( !receiver )
continue;
[[NSNotificationCenter defaultCenter] addObserverForName:NSWindowWillEnterFullScreenNotification
object:nswindow
queue:nil
usingBlock:^(NSNotification * note) {
NSLog(@"Became Full Screen!");
QMetaObject::invokeMethod( receiver, "fullScreenEntered", Qt::DirectConnection );
}];
[[NSNotificationCenter defaultCenter] addObserverForName:NSWindowDidExitFullScreenNotification
object:nswindow
queue:nil
usingBlock:^(NSNotification * note) {
NSLog(@"Left Full Screen!");
QMetaObject::invokeMethod( receiver, "fullScreenExited", Qt::DirectConnection );
}];
#endif
} }
} }
} }