Skip to content

Commit

Permalink
Add mac window menu integration
Browse files Browse the repository at this point in the history
  • Loading branch information
manisandro committed Apr 29, 2014
1 parent 3cfd2ef commit 4821988
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/app/composer/qgscomposermanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ QgsComposerManager::QgsComposerManager( QWidget * parent, Qt::WindowFlags f ): Q
mButtonBox->addButton( pb, QDialogButtonBox::ActionRole );
connect( pb, SIGNAL( clicked() ), this, SLOT( rename_clicked() ) );

#ifdef Q_WS_MAC
// Create action to select this window
mWindowAction = new QAction( windowTitle(), this );
connect( mWindowAction, SIGNAL( triggered() ), this, SLOT( activate() ) );
#endif

mTemplate->addItem( tr( "Empty composer" ) );
mTemplate->addItem( tr( "Specific" ) );

Expand Down Expand Up @@ -270,6 +276,32 @@ void QgsComposerManager::openLocalDirectory( const QString& localDirPath )
QDesktopServices::openUrl( QUrl::fromLocalFile( localDirPath ) );
}

#ifdef Q_WS_MAC
void QgsComposerManager::showEvent(QShowEvent* event)
{
if(!event->spontaneous()) {
QgisApp::instance()->addWindow( mWindowAction );
}
}

void QgsComposerManager::changeEvent( QEvent* event )
{
QDialog::changeEvent( event );
switch ( event->type() )
{
case QEvent::ActivationChange:
if ( QApplication::activeWindow() == this )
{
mWindowAction->setChecked( true );
}
break;

default:
break;
}
}
#endif

void QgsComposerManager::remove_clicked()
{
QListWidgetItem* item = mComposerListWidget->currentItem();
Expand Down
7 changes: 7 additions & 0 deletions src/app/composer/qgscomposermanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ class QgsComposerManager: public QDialog, private Ui::QgsComposerManagerBase
QString mDefaultTemplatesDir;
QString mUserTemplatesDir;

#ifdef Q_WS_MAC
void showEvent(QShowEvent *event);
void changeEvent(QEvent *);

QAction* mWindowAction;
#endif

private slots:
void on_mAddButton_clicked();
/** Slot to track combobox to use specific template path
Expand Down

0 comments on commit 4821988

Please sign in to comment.