1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-05 13:47:26 +02:00

OSX: adds 'Window' menu with 'Minimize'/'Zoom' actions

This commit is contained in:
Tieg Zaharia
2011-04-12 20:25:47 -04:00
parent aca94b1b55
commit e76ca1fdef
3 changed files with 79 additions and 1 deletions

View File

@@ -21,6 +21,8 @@
#include <QAction> #include <QAction>
#include <QCloseEvent> #include <QCloseEvent>
#include <QShowEvent>
#include <QHideEvent>
#include <QInputDialog> #include <QInputDialog>
#include <QPixmap> #include <QPixmap>
#include <QPropertyAnimation> #include <QPropertyAnimation>
@@ -263,6 +265,13 @@ TomahawkWindow::setupSignals()
connect( ui->actionCreate_New_Station, SIGNAL( triggered() ), SLOT( createStation() )); connect( ui->actionCreate_New_Station, SIGNAL( triggered() ), SLOT( createStation() ));
connect( ui->actionAboutTomahawk, SIGNAL( triggered() ), SLOT( showAboutTomahawk() ) ); connect( ui->actionAboutTomahawk, SIGNAL( triggered() ), SLOT( showAboutTomahawk() ) );
connect( ui->actionExit, SIGNAL( triggered() ), APP, SLOT( quit() ) ); connect( ui->actionExit, SIGNAL( triggered() ), APP, SLOT( quit() ) );
#if defined( Q_OS_DARWIN )
connect( ui->actionMinimize, SIGNAL( triggered() ), SLOT( minimize() ) );
connect( ui->actionZoom, SIGNAL( triggered() ), SLOT( maximize() ) );
#else
ui->menuWindow->clear();
ui->menuWindow->menuAction()->setVisible( false );
#endif
// <SipHandler> // <SipHandler>
connect( APP->sipHandler(), SIGNAL( connected() ), SLOT( onSipConnected() ) ); connect( APP->sipHandler(), SIGNAL( connected() ), SLOT( onSipConnected() ) );
@@ -290,7 +299,6 @@ TomahawkWindow::changeEvent( QEvent* e )
} }
} }
void void
TomahawkWindow::closeEvent( QCloseEvent* e ) TomahawkWindow::closeEvent( QCloseEvent* e )
{ {
@@ -306,6 +314,27 @@ TomahawkWindow::closeEvent( QCloseEvent* e )
e->accept(); e->accept();
} }
void
TomahawkWindow::showEvent( QShowEvent* e )
{
QMainWindow::showEvent( e );
#if defined( Q_OS_DARWIN )
ui->actionMinimize->setDisabled( false );
ui->actionZoom->setDisabled( false );
#endif
}
void
TomahawkWindow::hideEvent( QHideEvent* e )
{
QMainWindow::hideEvent( e );
#if defined( Q_OS_DARWIN )
ui->actionMinimize->setDisabled( true );
ui->actionZoom->setDisabled( true );
#endif
}
void void
TomahawkWindow::showSettingsDialog() TomahawkWindow::showSettingsDialog()
@@ -513,3 +542,23 @@ TomahawkWindow::checkForUpdates()
Tomahawk::checkForUpdates(); Tomahawk::checkForUpdates();
#endif #endif
} }
void
TomahawkWindow::minimize()
{
if (isMinimized()) {
showNormal();
} else {
showMinimized();
}
}
void
TomahawkWindow::maximize()
{
if (isMaximized()) {
showNormal();
} else {
showMaximized();
}
}

View File

@@ -54,6 +54,8 @@ public:
protected: protected:
void changeEvent( QEvent* e ); void changeEvent( QEvent* e );
void closeEvent( QCloseEvent* e ); void closeEvent( QCloseEvent* e );
void showEvent( QShowEvent* e );
void hideEvent( QHideEvent* e );
public slots: public slots:
void createAutomaticPlaylist(); void createAutomaticPlaylist();
@@ -79,6 +81,9 @@ private slots:
void showAboutTomahawk(); void showAboutTomahawk();
void checkForUpdates(); void checkForUpdates();
void minimize();
void maximize();
private: private:
void loadSettings(); void loadSettings();
void saveSettings(); void saveSettings();

View File

@@ -72,6 +72,13 @@
<addaction name="actionToggleConnect"/> <addaction name="actionToggleConnect"/>
<addaction name="separator"/> <addaction name="separator"/>
</widget> </widget>
<widget class="QMenu" name="menuWindow">
<property name="title">
<string>&amp;Window</string>
</property>
<addaction name="actionMinimize"/>
<addaction name="actionZoom"/>
</widget>
<widget class="QMenu" name="menu_Help"> <widget class="QMenu" name="menu_Help">
<property name="title"> <property name="title">
<string>&amp;Help</string> <string>&amp;Help</string>
@@ -82,6 +89,7 @@
<addaction name="menuPlaylist"/> <addaction name="menuPlaylist"/>
<addaction name="menuNetwork"/> <addaction name="menuNetwork"/>
<addaction name="menuSettings"/> <addaction name="menuSettings"/>
<addaction name="menuWindow"/>
<addaction name="menu_Help"/> <addaction name="menu_Help"/>
</widget> </widget>
<widget class="QStatusBar" name="statusBar"/> <widget class="QStatusBar" name="statusBar"/>
@@ -157,6 +165,22 @@
<string>Hide Offline Sources</string> <string>Hide Offline Sources</string>
</property> </property>
</action> </action>
<action name="actionMinimize">
<property name="text">
<string>Minimize</string>
</property>
<property name="shortcut">
<string>Ctrl+M</string>
</property>
</action>
<action name="actionZoom">
<property name="text">
<string>Zoom</string>
</property>
<property name="shortcut">
<string>Meta+Ctrl+Z</string>
</property>
</action>
</widget> </widget>
<layoutdefault spacing="6" margin="11"/> <layoutdefault spacing="6" margin="11"/>
<resources/> <resources/>