Skip to content

Commit

Permalink
revert 637359a and manually merge pull request #1232
Browse files Browse the repository at this point in the history
Signed-off-by: Juergen E. Fischer <jef@norbit.de>
  • Loading branch information
rduivenvoorde authored and jef-n committed Mar 23, 2014
1 parent f020bbf commit 5b4d076
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 50 deletions.
12 changes: 0 additions & 12 deletions src/app/composer/qgscomposer.cpp
Expand Up @@ -339,7 +339,6 @@ 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() );
Expand Down Expand Up @@ -2499,17 +2498,6 @@ 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 )
{

Expand Down
3 changes: 0 additions & 3 deletions src/app/composer/qgscomposer.h
Expand Up @@ -326,9 +326,6 @@ 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 );

Expand Down
15 changes: 15 additions & 0 deletions src/app/main.cpp
Expand Up @@ -115,6 +115,7 @@ void usage( std::string const & appName )
<< "\t[--optionspath path]\tuse the given QSettings path\n"
<< "\t[--configpath path]\tuse the given path for all user configuration\n"
<< "\t[--code path]\trun the given python file on load\n"
<< "\t[--defaultui]\tstart by resetting user ui settings to default\n"
<< "\t[--help]\t\tthis text\n\n"
<< " FILE:\n"
<< " Files specified on the command line can include rasters,\n"
Expand Down Expand Up @@ -453,6 +454,7 @@ int main( int argc, char *argv[] )
myHideSplash = true;
#endif

bool myRestoreDefaultWindowState = false;
bool myRestorePlugins = true;
bool myCustomization = true;

Expand Down Expand Up @@ -554,6 +556,10 @@ int main( int argc, char *argv[] )
{
customizationfile = QDir::convertSeparators( QFileInfo( args[++i] ).absoluteFilePath() );
}
else if ( arg == "--defaultui" || arg == "-d" )
{
myRestoreDefaultWindowState = true;
}
else
{
myFileList.append( QDir::convertSeparators( QFileInfo( args[i] ).absoluteFilePath() ) );
Expand Down Expand Up @@ -858,6 +864,15 @@ int main( int argc, char *argv[] )
mypSplash->show();
}

// optionally restore default window state
// use restoreDefaultWindowState setting only if NOT using command line (then it is set already)
if ( myRestoreDefaultWindowState || mySettings.value( "/qgis/restoreDefaultWindowState", false ).toBool() )
{
QgsDebugMsg( "Resetting /UI/state settings!" );
mySettings.remove( "/UI/state" );
mySettings.remove( "/qgis/restoreDefaultWindowState" );
}

QgisApp *qgis = new QgisApp( mypSplash, myRestorePlugins ); // "QgisApp" used to find canonical instance
qgis->setObjectName( "QgisApp" );

Expand Down
15 changes: 0 additions & 15 deletions src/app/qgisapp.cpp
Expand Up @@ -1101,7 +1101,6 @@ 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
Expand Down Expand Up @@ -2371,20 +2370,6 @@ 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()
{
Expand Down
2 changes: 0 additions & 2 deletions src/app/qgisapp.h
Expand Up @@ -838,8 +838,6 @@ 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
Expand Down
9 changes: 9 additions & 0 deletions src/app/qgsoptions.cpp
Expand Up @@ -1531,6 +1531,15 @@ QStringList QgsOptions::i18nList()
return myList;
}

void QgsOptions::on_mRestoreDefaultWindowStateBtn_clicked()
{
// richard
QSettings mySettings;
if ( QMessageBox::warning( this, tr( "Restore UI defaults" ), tr( "Are you sure to reset the UI to default (needs restart)?" ), QMessageBox::Ok | QMessageBox::Cancel ) == QMessageBox::Cancel )
return;
mySettings.setValue( "/qgis/restoreDefaultWindowState", true );
}

void QgsOptions::on_mCustomVariablesChkBx_toggled( bool chkd )
{
mAddCustomVarBtn->setEnabled( chkd );
Expand Down
3 changes: 3 additions & 0 deletions src/app/qgsoptions.h
Expand Up @@ -141,6 +141,9 @@ class APP_EXPORT QgsOptions : public QgsOptionsDialogBase, private Ui::QgsOption
/**Remove an URL to exclude from Proxy*/
void on_mRemoveUrlPushButton_clicked();

/**Slot to flag restoring/delete window state settings upon restart*/
void on_mRestoreDefaultWindowStateBtn_clicked();

/** Slot to enable custom environment variables table and buttons
* @note added in QGIS 1.9
*/
Expand Down
6 changes: 0 additions & 6 deletions src/ui/qgisapp.ui
Expand Up @@ -194,7 +194,6 @@
<addaction name="mActionCustomization"/>
<addaction name="mActionOptions"/>
<addaction name="mActionSnappingOptions"/>
<addaction name="mActionResetUIdefaults"/>
</widget>
<widget class="QMenu" name="mRasterMenu">
<property name="title">
Expand Down Expand Up @@ -2159,11 +2158,6 @@ 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>
<action name="mActionAddLayerDefinition">
<property name="text">
<string>Add from Layer Definition File...</string>
Expand Down
12 changes: 0 additions & 12 deletions src/ui/qgscomposerbase.ui
Expand Up @@ -836,18 +836,6 @@
<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>
Expand Down
36 changes: 36 additions & 0 deletions src/ui/qgsoptionsbase.ui
Expand Up @@ -1042,6 +1042,42 @@
</layout>
</widget>
</item>
<item>
<widget class="QgsCollapsibleGroupBox" name="mQSettingsGrpBx">
<property name="title">
<string>QSettings</string>
</property>
<layout class="QGridLayout" name="gridLayout_13">
<item row="0" column="1">
<spacer name="horizontalSpacer_42">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="mRestoreDefaultWindowStateBtn">
<property name="text">
<string>Reset</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="mRestoreDefaultWindowStateLbl">
<property name="text">
<string>Reset the User Interface settings, to reset QGIS to it's default view</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QgsCollapsibleGroupBox" name="mEnvironmentGrpBx">
<property name="minimumSize">
Expand Down

0 comments on commit 5b4d076

Please sign in to comment.