Skip to content

Commit 5b4d076

Browse files
rduivenvoordejef-n
authored andcommitted
revert 637359a and manually merge pull request #1232
Signed-off-by: Juergen E. Fischer <jef@norbit.de>
1 parent f020bbf commit 5b4d076

10 files changed

+63
-50
lines changed

src/app/composer/qgscomposer.cpp

-12
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,6 @@ QgsComposer::QgsComposer( QgisApp *qgis, const QString& title )
339339

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

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

2502-
void QgsComposer::on_mActionResetUIdefaults_triggered()
2503-
{
2504-
if ( QMessageBox::warning( this, tr( "Restore UI defaults" ), tr( "Are you sure to reset the UI to default?" ), QMessageBox::Ok | QMessageBox::Cancel ) == QMessageBox::Cancel )
2505-
return;
2506-
2507-
saveWindowState();
2508-
QSettings settings;
2509-
settings.remove( "/ComposerUI/state" );
2510-
restoreWindowState();
2511-
}
2512-
25132501
void QgsComposer::writeXML( QDomDocument& doc )
25142502
{
25152503

src/app/composer/qgscomposer.h

-3
Original file line numberDiff line numberDiff line change
@@ -326,9 +326,6 @@ class QgsComposer: public QMainWindow, private Ui::QgsComposerBase
326326
//!Show options dialog
327327
void on_mActionOptions_triggered();
328328

329-
//! Restore the default window and toolbar state
330-
void on_mActionResetUIdefaults_triggered();
331-
332329
//!Toggle atlas preview
333330
void on_mActionAtlasPreview_triggered( bool checked );
334331

src/app/main.cpp

+15
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ void usage( std::string const & appName )
115115
<< "\t[--optionspath path]\tuse the given QSettings path\n"
116116
<< "\t[--configpath path]\tuse the given path for all user configuration\n"
117117
<< "\t[--code path]\trun the given python file on load\n"
118+
<< "\t[--defaultui]\tstart by resetting user ui settings to default\n"
118119
<< "\t[--help]\t\tthis text\n\n"
119120
<< " FILE:\n"
120121
<< " Files specified on the command line can include rasters,\n"
@@ -453,6 +454,7 @@ int main( int argc, char *argv[] )
453454
myHideSplash = true;
454455
#endif
455456

457+
bool myRestoreDefaultWindowState = false;
456458
bool myRestorePlugins = true;
457459
bool myCustomization = true;
458460

@@ -554,6 +556,10 @@ int main( int argc, char *argv[] )
554556
{
555557
customizationfile = QDir::convertSeparators( QFileInfo( args[++i] ).absoluteFilePath() );
556558
}
559+
else if ( arg == "--defaultui" || arg == "-d" )
560+
{
561+
myRestoreDefaultWindowState = true;
562+
}
557563
else
558564
{
559565
myFileList.append( QDir::convertSeparators( QFileInfo( args[i] ).absoluteFilePath() ) );
@@ -858,6 +864,15 @@ int main( int argc, char *argv[] )
858864
mypSplash->show();
859865
}
860866

867+
// optionally restore default window state
868+
// use restoreDefaultWindowState setting only if NOT using command line (then it is set already)
869+
if ( myRestoreDefaultWindowState || mySettings.value( "/qgis/restoreDefaultWindowState", false ).toBool() )
870+
{
871+
QgsDebugMsg( "Resetting /UI/state settings!" );
872+
mySettings.remove( "/UI/state" );
873+
mySettings.remove( "/qgis/restoreDefaultWindowState" );
874+
}
875+
861876
QgisApp *qgis = new QgisApp( mypSplash, myRestorePlugins ); // "QgisApp" used to find canonical instance
862877
qgis->setObjectName( "QgisApp" );
863878

src/app/qgisapp.cpp

-15
Original file line numberDiff line numberDiff line change
@@ -1101,7 +1101,6 @@ void QgisApp::createActions()
11011101
connect( mActionConfigureShortcuts, SIGNAL( triggered() ), this, SLOT( configureShortcuts() ) );
11021102
connect( mActionStyleManagerV2, SIGNAL( triggered() ), this, SLOT( showStyleManagerV2() ) );
11031103
connect( mActionCustomization, SIGNAL( triggered() ), this, SLOT( customize() ) );
1104-
connect( mActionResetUIdefaults, SIGNAL( triggered() ), this, SLOT( restoreDefaultWindowState() ) );
11051104

11061105
#ifdef Q_WS_MAC
11071106
// Window Menu Items
@@ -2371,20 +2370,6 @@ void QgisApp::restoreWindowState()
23712370
}
23722371

23732372
}
2374-
2375-
void QgisApp::restoreDefaultWindowState()
2376-
{
2377-
if ( QMessageBox::warning( this, tr( "Restore UI defaults" ), tr( "Are you sure to reset the UI to default?" ), QMessageBox::Ok | QMessageBox::Cancel ) == QMessageBox::Cancel )
2378-
return;
2379-
2380-
saveWindowState();
2381-
2382-
QSettings settings;
2383-
settings.remove( "/UI/state" );
2384-
2385-
restoreWindowState();
2386-
}
2387-
23882373
///////////// END OF GUI SETUP ROUTINES ///////////////
23892374
void QgisApp::sponsors()
23902375
{

src/app/qgisapp.h

-2
Original file line numberDiff line numberDiff line change
@@ -838,8 +838,6 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
838838
void saveWindowState();
839839
//! Restore the window and toolbar state
840840
void restoreWindowState();
841-
//! Restore the default window and toolbar state
842-
void restoreDefaultWindowState();
843841
//! Save project. Returns true if the user selected a file to save to, false if not.
844842
bool fileSave();
845843
//! Save project as

src/app/qgsoptions.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -1531,6 +1531,15 @@ QStringList QgsOptions::i18nList()
15311531
return myList;
15321532
}
15331533

1534+
void QgsOptions::on_mRestoreDefaultWindowStateBtn_clicked()
1535+
{
1536+
// richard
1537+
QSettings mySettings;
1538+
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 )
1539+
return;
1540+
mySettings.setValue( "/qgis/restoreDefaultWindowState", true );
1541+
}
1542+
15341543
void QgsOptions::on_mCustomVariablesChkBx_toggled( bool chkd )
15351544
{
15361545
mAddCustomVarBtn->setEnabled( chkd );

src/app/qgsoptions.h

+3
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ class APP_EXPORT QgsOptions : public QgsOptionsDialogBase, private Ui::QgsOption
141141
/**Remove an URL to exclude from Proxy*/
142142
void on_mRemoveUrlPushButton_clicked();
143143

144+
/**Slot to flag restoring/delete window state settings upon restart*/
145+
void on_mRestoreDefaultWindowStateBtn_clicked();
146+
144147
/** Slot to enable custom environment variables table and buttons
145148
* @note added in QGIS 1.9
146149
*/

src/ui/qgisapp.ui

-6
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@
194194
<addaction name="mActionCustomization"/>
195195
<addaction name="mActionOptions"/>
196196
<addaction name="mActionSnappingOptions"/>
197-
<addaction name="mActionResetUIdefaults"/>
198197
</widget>
199198
<widget class="QMenu" name="mRasterMenu">
200199
<property name="title">
@@ -2159,11 +2158,6 @@ Acts on currently active editable layer</string>
21592158
<string>Fill Ring</string>
21602159
</property>
21612160
</action>
2162-
<action name="mActionResetUIdefaults">
2163-
<property name="text">
2164-
<string>Reset UI defaults</string>
2165-
</property>
2166-
</action>
21672161
<action name="mActionAddLayerDefinition">
21682162
<property name="text">
21692163
<string>Add from Layer Definition File...</string>

src/ui/qgscomposerbase.ui

-12
Original file line numberDiff line numberDiff line change
@@ -836,18 +836,6 @@
836836
<enum>QAction::PreferencesRole</enum>
837837
</property>
838838
</action>
839-
<action name="mActionResetUIdefaults">
840-
<property name="icon">
841-
<iconset resource="../../images/images.qrc">
842-
<normaloff>:/images/themes/default/mActionOptions.svg</normaloff>:/images/themes/default/mActionOptions.svg</iconset>
843-
</property>
844-
<property name="text">
845-
<string>Reset UI defaults...</string>
846-
</property>
847-
<property name="menuRole">
848-
<enum>QAction::PreferencesRole</enum>
849-
</property>
850-
</action>
851839
<action name="mActionShowRulers">
852840
<property name="text">
853841
<string>Show Rulers</string>

src/ui/qgsoptionsbase.ui

+36
Original file line numberDiff line numberDiff line change
@@ -1042,6 +1042,42 @@
10421042
</layout>
10431043
</widget>
10441044
</item>
1045+
<item>
1046+
<widget class="QgsCollapsibleGroupBox" name="mQSettingsGrpBx">
1047+
<property name="title">
1048+
<string>QSettings</string>
1049+
</property>
1050+
<layout class="QGridLayout" name="gridLayout_13">
1051+
<item row="0" column="1">
1052+
<spacer name="horizontalSpacer_42">
1053+
<property name="orientation">
1054+
<enum>Qt::Horizontal</enum>
1055+
</property>
1056+
<property name="sizeHint" stdset="0">
1057+
<size>
1058+
<width>40</width>
1059+
<height>20</height>
1060+
</size>
1061+
</property>
1062+
</spacer>
1063+
</item>
1064+
<item row="0" column="2">
1065+
<widget class="QPushButton" name="mRestoreDefaultWindowStateBtn">
1066+
<property name="text">
1067+
<string>Reset</string>
1068+
</property>
1069+
</widget>
1070+
</item>
1071+
<item row="0" column="0">
1072+
<widget class="QLabel" name="mRestoreDefaultWindowStateLbl">
1073+
<property name="text">
1074+
<string>Reset the User Interface settings, to reset QGIS to it's default view</string>
1075+
</property>
1076+
</widget>
1077+
</item>
1078+
</layout>
1079+
</widget>
1080+
</item>
10451081
<item>
10461082
<widget class="QgsCollapsibleGroupBox" name="mEnvironmentGrpBx">
10471083
<property name="minimumSize">

0 commit comments

Comments
 (0)