Skip to content
Permalink
Browse files

add menu option to reset to ui defaults (implements #9746)

  • Loading branch information
jef-n committed Mar 8, 2014
1 parent 245422a commit 637359aefc0cd008f749b0fbed140e4cbbf6de15
Showing with 60 additions and 8 deletions.
  1. +21 −7 src/app/composer/qgscomposer.cpp
  2. +3 −0 src/app/composer/qgscomposer.h
  3. +16 −1 src/app/qgisapp.cpp
  4. +2 −0 src/app/qgisapp.h
  5. +6 −0 src/ui/qgisapp.ui
  6. +12 −0 src/ui/qgscomposerbase.ui
@@ -214,22 +214,24 @@ QgsComposer::QgsComposer( QgisApp *qgis, const QString& title )
composerMenu->addAction( mActionPrint );
composerMenu->addSeparator();
composerMenu->addAction( mActionQuit );
QObject::connect( mActionQuit, SIGNAL( triggered() ), this, SLOT( close() ) );
connect( mActionQuit, SIGNAL( triggered() ), this, SLOT( close() ) );

//cut/copy/paste actions. Note these are not included in the ui file
//as ui files have no support for QKeySequence shortcuts
mActionCut = new QAction( tr( "Cu&t" ), this );
mActionCut->setShortcuts( QKeySequence::Cut );
mActionCut->setStatusTip( tr( "Cut" ) );
QObject::connect( mActionCut, SIGNAL( triggered() ), this, SLOT( actionCutTriggered() ) );
connect( mActionCut, SIGNAL( triggered() ), this, SLOT( actionCutTriggered() ) );

mActionCopy = new QAction( tr( "&Copy" ), this );
mActionCopy->setShortcuts( QKeySequence::Copy );
mActionCopy->setStatusTip( tr( "Copy" ) );
QObject::connect( mActionCopy, SIGNAL( triggered() ), this, SLOT( actionCopyTriggered() ) );
connect( mActionCopy, SIGNAL( triggered() ), this, SLOT( actionCopyTriggered() ) );

mActionPaste = new QAction( tr( "&Paste" ), this );
mActionPaste->setShortcuts( QKeySequence::Paste );
mActionPaste->setStatusTip( tr( "Paste" ) );
QObject::connect( mActionPaste, SIGNAL( triggered() ), this, SLOT( actionPasteTriggered() ) );
connect( mActionPaste, SIGNAL( triggered() ), this, SLOT( actionPasteTriggered() ) );

QMenu *editMenu = menuBar()->addMenu( tr( "Edit" ) );
editMenu->addAction( mActionUndo );
@@ -337,6 +339,7 @@ QgsComposer::QgsComposer( QgisApp *qgis, const QString& title )

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

#ifdef Q_WS_MAC
// this doesn't work on Mac anymore: menuBar()->addMenu( mQgis->windowMenu() );
@@ -2496,6 +2499,17 @@ void QgsComposer::restoreWindowState()
}
}

void QgsComposer::on_mActionResetUIdefaults_triggered()
{
if ( QMessageBox::warning( this, tr( "Restore UI defaults" ), tr( "Are you sure to reset the UI to default?" ), QMessageBox::Ok | QMessageBox::Cancel ) == QMessageBox::Cancel )
return;

saveWindowState();
QSettings settings;
settings.remove( "/ComposerUI/state" );
restoreWindowState();
}

void QgsComposer::writeXML( QDomDocument& doc )
{

@@ -2593,9 +2607,9 @@ void QgsComposer::readXML( const QDomElement& composerElem, const QDomDocument&

//create compositionwidget
QgsCompositionWidget* compositionWidget = new QgsCompositionWidget( mGeneralDock, mComposition );
QObject::connect( mComposition, SIGNAL( paperSizeChanged() ), compositionWidget, SLOT( displayCompositionWidthHeight() ) );
QObject::connect( this, SIGNAL( printAsRasterChanged( bool ) ), compositionWidget, SLOT( setPrintAsRasterCheckBox( bool ) ) );
QObject::connect( compositionWidget, SIGNAL( pageOrientationChanged( QString ) ), this, SLOT( setPrinterPageOrientation( QString ) ) );
connect( mComposition, SIGNAL( paperSizeChanged() ), compositionWidget, SLOT( displayCompositionWidthHeight() ) );
connect( this, SIGNAL( printAsRasterChanged( bool ) ), compositionWidget, SLOT( setPrintAsRasterCheckBox( bool ) ) );
connect( compositionWidget, SIGNAL( pageOrientationChanged( QString ) ), this, SLOT( setPrinterPageOrientation( QString ) ) );
mGeneralDock->setWidget( compositionWidget );

//read and restore all the items
@@ -326,6 +326,9 @@ class QgsComposer: public QMainWindow, private Ui::QgsComposerBase
//!Show options dialog
void on_mActionOptions_triggered();

//! Restore the default window and toolbar state
void on_mActionResetUIdefaults_triggered();

//!Toggle atlas preview
void on_mActionAtlasPreview_triggered( bool checked );

@@ -1097,6 +1097,7 @@ void QgisApp::createActions()
connect( mActionConfigureShortcuts, SIGNAL( triggered() ), this, SLOT( configureShortcuts() ) );
connect( mActionStyleManagerV2, SIGNAL( triggered() ), this, SLOT( showStyleManagerV2() ) );
connect( mActionCustomization, SIGNAL( triggered() ), this, SLOT( customize() ) );
connect( mActionResetUIdefaults, SIGNAL( triggered() ), this, SLOT( restoreDefaultWindowState() ) );

#ifdef Q_WS_MAC
// Window Menu Items
@@ -2351,7 +2352,7 @@ void QgisApp::saveWindowState()

void QgisApp::restoreWindowState()
{
// restore the toolbar and dock widgets postions using Qt4 settings API
// restore the toolbar and dock widgets positions using Qt4 settings API
QSettings settings;

if ( !restoreState( settings.value( "/UI/state", QByteArray::fromRawData(( char * )defaultUIstate, sizeof defaultUIstate ) ).toByteArray() ) )
@@ -2366,6 +2367,20 @@ void QgisApp::restoreWindowState()
}

}

void QgisApp::restoreDefaultWindowState()
{
if ( QMessageBox::warning( this, tr( "Restore UI defaults" ), tr( "Are you sure to reset the UI to default?" ), QMessageBox::Ok | QMessageBox::Cancel ) == QMessageBox::Cancel )
return;

saveWindowState();

QSettings settings;
settings.remove( "/UI/state" );

restoreWindowState();
}

///////////// END OF GUI SETUP ROUTINES ///////////////
void QgisApp::sponsors()
{
@@ -837,6 +837,8 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
void saveWindowState();
//! Restore the window and toolbar state
void restoreWindowState();
//! Restore the default window and toolbar state
void restoreDefaultWindowState();
//! Save project. Returns true if the user selected a file to save to, false if not.
bool fileSave();
//! Save project as
@@ -192,6 +192,7 @@
<addaction name="mActionCustomization"/>
<addaction name="mActionOptions"/>
<addaction name="mActionSnappingOptions"/>
<addaction name="mActionResetUIdefaults"/>
</widget>
<widget class="QMenu" name="mRasterMenu">
<property name="title">
@@ -2156,6 +2157,11 @@ Acts on currently active editable layer</string>
<string>Fill Ring</string>
</property>
</action>
<action name="mActionResetUIdefaults">
<property name="text">
<string>Reset UI defaults</string>
</property>
</action>
</widget>
<resources>
<include location="../../images/images.qrc"/>
@@ -836,6 +836,18 @@
<enum>QAction::PreferencesRole</enum>
</property>
</action>
<action name="mActionResetUIdefaults">
<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>Reset UI defaults...</string>
</property>
<property name="menuRole">
<enum>QAction::PreferencesRole</enum>
</property>
</action>
<action name="mActionShowRulers">
<property name="text">
<string>Show Rulers</string>

0 comments on commit 637359a

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