Skip to content
Permalink
Browse files

Add public method for displaying options dialog and switching to a sp…

…ecific page

Add shortcut to composer options to composer menu
  • Loading branch information
nyalldawson committed Nov 19, 2013
1 parent a013a3a commit c12956c805bf3207070de3cb639a0834d7b4122d
@@ -303,6 +303,9 @@ QgsComposer::QgsComposer( QgisApp *qgis, const QString& title )
layoutMenu->addAction( mActionLockItems );
layoutMenu->addAction( mActionUnlockAll );

QMenu *settingsMenu = menuBar()->addMenu( tr( "Settings" ) );
settingsMenu->addAction( mActionOptions );

#ifdef Q_WS_MAC
// this doesn't work on Mac anymore: menuBar()->addMenu( mQgis->windowMenu() );
// QgsComposer::populateWithOtherMenu should work recursively with submenus and regardless of Qt version
@@ -659,6 +662,11 @@ void QgsComposer::showItemOptions( QgsComposerItem* item )
mItemDock->setWidget( newWidget );
}

void QgsComposer::on_mActionOptions_triggered()
{
mQgis->showOptionsDialog( this, QString("mOptionsPageComposer") );
}

QgsMapCanvas *QgsComposer::mapCanvas( void )
{
return mQgis->mapCanvas();
@@ -306,6 +306,9 @@ class QgsComposer: public QMainWindow, private Ui::QgsComposerBase
//!Clear guides
void on_mActionClearGuides_triggered();

//!Show options dialog
void on_mActionOptions_triggered();

//! Save window state
void saveWindowState();

@@ -6839,8 +6839,12 @@ void QgisApp::customize()
QgsCustomization::instance()->openDialog( this );
}


void QgisApp::options()
{
showOptionsDialog( this );
}

void QgisApp::showOptionsDialog( QWidget *parent, QString currentPage )
{
if ( mMapCanvas && mMapCanvas->isDrawing() )
{
@@ -6850,7 +6854,12 @@ void QgisApp::options()
QSettings mySettings;
QString oldScales = mySettings.value( "Map/scales", PROJECT_SCALES ).toString();

QgsOptions *optionsDialog = new QgsOptions( this );
QgsOptions *optionsDialog = new QgsOptions( parent );
if ( !currentPage.isEmpty() )
{
optionsDialog->setCurrentPage( currentPage );
}

if ( optionsDialog->exec() )
{
// set the theme if it changed
@@ -618,6 +618,9 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
//! Update project menu with the project templates
void updateProjectFromTemplates();

//! Opens the options dialog
void showOptionsDialog( QWidget *parent = 0, QString currentPage = QString() );

protected:

//! Handle state changes (WindowTitleChange)
@@ -684,7 +684,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
//
// Composer settings
//

//default composer font
mComposerFontComboBox->blockSignals( true );

@@ -730,7 +730,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
//default grid is dots
mGridStyleComboBox->setCurrentIndex( 1 );
}

//
// Locale settings
//
@@ -846,6 +846,21 @@ QgsOptions::~QgsOptions()
{
}

void QgsOptions::setCurrentPage( QString pageWidgetName )
{
//find the page with a matching widget name
for ( int idx = 0; idx < mOptionsStackedWidget->count(); ++idx )
{
QWidget * currentPage = mOptionsStackedWidget->widget( idx );
if ( currentPage->objectName() == pageWidgetName )
{
//found the page, set it as current
mOptionsStackedWidget->setCurrentIndex( idx );
return;
}
}
}

void QgsOptions::on_cbxProjectDefaultNew_toggled( bool checked )
{
if ( checked )
@@ -1264,7 +1279,7 @@ void QgsOptions::saveOptions()
//
// Composer settings
//

//default font
QString composerFont = mComposerFontComboBox->currentFont().family();
settings.setValue( "/Composer/defaultFont", composerFont );
@@ -1288,7 +1303,7 @@ void QgsOptions::saveOptions()
{
settings.setValue( "/Composer/gridStyle", "Crosses" );
}

//
// Locale settings
//
@@ -1676,7 +1691,7 @@ void QgsOptions::on_mOptionsStackedWidget_currentChanged( int theIndx )
{
Q_UNUSED( theIndx );
// load gdal driver list when gdal tab is first opened
if ( mOptionsStackedWidget->currentWidget()->objectName() == QString( "mOptionsPage_02" )
if ( mOptionsStackedWidget->currentWidget()->objectName() == QString( "mOptionsPageGDAL" )
&& ! mLoadedGdalDriverList )
{
loadGdalDriverList();
@@ -52,6 +52,11 @@ class APP_EXPORT QgsOptions : public QgsOptionsDialogBase, private Ui::QgsOption
*/
QString theme();

/** Sets the page with the specified widget name as the current page
* @note added in QGIS 2.1
*/
void setCurrentPage( QString pageWidgetName );

public slots:
void on_cbxProjectDefaultNew_toggled( bool checked );
void on_pbnProjectDefaultSetCurrent_clicked();
@@ -780,7 +780,19 @@
<property name="text">
<string>Pan Composer</string>
</property>
</action>
</action>
<action name="mActionOptions">
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/mActionOptions.svg</normaloff>:/images/themes/default/mActionOptions.svg</iconset>
</property>
<property name="text">
<string>Composer Options...</string>
</property>
<property name="menuRole">
<enum>QAction::PreferencesRole</enum>
</property>
</action>
</widget>
<resources>
<include location="../../images/images.qrc"/>
@@ -250,7 +250,7 @@
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="mOptionsPage_01">
<widget class="QWidget" name="mOptionsPageGeneral">
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="margin">
<number>0</number>
@@ -896,7 +896,7 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="mOptionsPage_03">
<widget class="QWidget" name="mOptionsPageSystem">
<layout class="QVBoxLayout" name="verticalLayout_7">
<property name="margin">
<number>0</number>
@@ -1232,7 +1232,7 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="mOptionsPage_11">
<widget class="QWidget" name="mOptionsPageDataSources">
<layout class="QVBoxLayout" name="verticalLayout_26">
<property name="margin">
<number>0</number>
@@ -1561,7 +1561,7 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="mOptionsPage_04">
<widget class="QWidget" name="mOptionsPageRendering">
<layout class="QVBoxLayout" name="verticalLayout_12">
<property name="margin">
<number>0</number>
@@ -2076,7 +2076,7 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="mOptionsPage_06">
<widget class="QWidget" name="mOptionsPageMapCanvas">
<layout class="QVBoxLayout" name="verticalLayout_16">
<property name="margin">
<number>0</number>
@@ -2422,7 +2422,7 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="mOptionsPage_05">
<widget class="QWidget" name="mOptionsPageMapTools">
<layout class="QVBoxLayout" name="verticalLayout_14">
<property name="margin">
<number>0</number>
@@ -2836,7 +2836,7 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="mOptionsPage_12">
<widget class="QWidget" name="mOptionsPageComposer">
<layout class="QVBoxLayout" name="verticalLayout_9">
<property name="margin">
<number>0</number>
@@ -2945,7 +2945,7 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="mOptionsPage_07">
<widget class="QWidget" name="mOptionsPageDigitizing">
<layout class="QVBoxLayout" name="verticalLayout_17">
<property name="margin">
<number>0</number>
@@ -3446,7 +3446,7 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="mOptionsPage_02">
<widget class="QWidget" name="mOptionsPageGDAL">
<layout class="QVBoxLayout" name="verticalLayout_4">
<property name="margin">
<number>0</number>
@@ -3586,7 +3586,7 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="mOptionsPage_08">
<widget class="QWidget" name="mOptionsPageCRS">
<layout class="QVBoxLayout" name="verticalLayout_18">
<property name="margin">
<number>0</number>
@@ -3843,7 +3843,7 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="mOptionsPage_09">
<widget class="QWidget" name="mOptionsPageLocale">
<layout class="QVBoxLayout" name="verticalLayout_19">
<property name="margin">
<number>0</number>
@@ -3943,7 +3943,7 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="mOptionsPage_10">
<widget class="QWidget" name="mOptionsPageNetwork">
<layout class="QVBoxLayout" name="verticalLayout_20">
<property name="margin">
<number>0</number>

0 comments on commit c12956c

Please sign in to comment.
You can’t perform that action at this time.