Skip to content

Commit 74d126b

Browse files
committed
global customization enable checkbox
1 parent 6129e92 commit 74d126b

File tree

4 files changed

+38
-6
lines changed

4 files changed

+38
-6
lines changed

src/app/main.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -512,8 +512,12 @@ int main( int argc, char *argv[] )
512512
QSettings::setPath( QSettings::IniFormat, QSettings::UserScope, optionpath.isEmpty() ? configpath : optionpath );
513513
}
514514

515-
// GUI customization is enabled by default unless --nocustomization argument is used
516-
QgsCustomization::instance()->setEnabled( myCustomization );
515+
// GUI customization is enabled according to settings (loaded when instance is created)
516+
// we force disabled here if --nocustomization argument is used
517+
if ( !myCustomization )
518+
{
519+
QgsCustomization::instance()->setEnabled( false );
520+
}
517521

518522
QgsApplication myApp( argc, argv, myUseGuiFlag, configpath );
519523

@@ -546,7 +550,7 @@ int main( int argc, char *argv[] )
546550
// Using the customizationfile option always overrides the option and config path options.
547551
if ( !customizationfile.isEmpty() )
548552
{
549-
customizationsettings = new QSettings( customizationfile, QSettings::IniFormat);
553+
customizationsettings = new QSettings( customizationfile, QSettings::IniFormat );
550554
}
551555

552556
// Load and set possible default customization, must be done afterQgsApplication init and QSettings ( QCoreApplication ) init
@@ -810,7 +814,7 @@ int main( int argc, char *argv[] )
810814
//replace backslashes with forward slashes
811815
pythonfile.replace( "\\", "/" );
812816
#endif
813-
QgsPythonRunner::run(QString("execfile('%1')").arg(pythonfile));
817+
QgsPythonRunner::run( QString( "execfile('%1')" ).arg( pythonfile ) );
814818
}
815819

816820
/////////////////////////////////`////////////////////////////////////

src/app/qgscustomization.cpp

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ QgsCustomizationDialog::QgsCustomizationDialog( QWidget *parent, QSettings* sett
4646
{
4747
mSettings = settings;
4848
setupUi( this );
49+
4950
init();
5051
QStringList myHeaders;
5152
myHeaders << tr( "Object name" ) << tr( "Label" ) << tr( "Description" );
@@ -181,6 +182,12 @@ void QgsCustomizationDialog::reset()
181182
{
182183
mSettings->sync();
183184
settingsToTree( mSettings );
185+
186+
QSettings settings;
187+
bool enabled = settings.value( "/UI/Customization/enabled", "0" ).toInt() == 1;
188+
mCustomizationEnabledCheckBox->setChecked( enabled );
189+
treeWidget->setEnabled( enabled );
190+
toolBar->setEnabled( enabled );
184191
}
185192

186193
void QgsCustomizationDialog::ok()
@@ -194,6 +201,9 @@ void QgsCustomizationDialog::apply()
194201
treeToSettings( mSettings );
195202
mSettings->setValue( QgsCustomization::instance()->statusPath(), QgsCustomization::User );
196203
mSettings->sync();
204+
205+
QSettings settings;
206+
settings.setValue( "/UI/Customization/enabled", mCustomizationEnabledCheckBox->isChecked() );
197207
}
198208

199209
void QgsCustomizationDialog::cancel()
@@ -263,6 +273,12 @@ void QgsCustomizationDialog::on_actionSelectAll_triggered( bool checked )
263273
}
264274
}
265275

276+
void QgsCustomizationDialog::on_mCustomizationEnabledCheckBox_toggled( bool checked )
277+
{
278+
treeWidget->setEnabled( checked );
279+
toolBar->setEnabled( checked );
280+
}
281+
266282
void QgsCustomizationDialog::init()
267283
{
268284
QgsDebugMsg( "Entered" );
@@ -538,7 +554,7 @@ void QgsCustomization::createTreeItemToolbars( )
538554
void QgsCustomization::createTreeItemDocks( )
539555
{
540556
QStringList data;
541-
data << "Docks";
557+
data << "Panels";
542558

543559
QTreeWidgetItem *topItem = new QTreeWidgetItem( data );
544560

@@ -598,10 +614,13 @@ QgsCustomization *QgsCustomization::instance()
598614

599615
QgsCustomization::QgsCustomization()
600616
: pDialog( 0 )
601-
, mEnabled( true )
617+
, mEnabled( false )
602618
, mStatusPath( "/Customization/status" )
603619
{
604620
QgsDebugMsg( "Entered" );
621+
622+
QSettings settings;
623+
mEnabled = settings.value( "/UI/Customization/enabled", "false" ).toString() == "true";
605624
}
606625

607626
QgsCustomization::~QgsCustomization()

src/app/qgscustomization.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ class QgsCustomizationDialog : public QMainWindow, private Ui::QgsCustomizationD
8989
void on_actionCollapseAll_triggered( bool checked );
9090
void on_actionSelectAll_triggered( bool checked );
9191

92+
void on_mCustomizationEnabledCheckBox_toggled( bool checked );
93+
9294
private:
9395
void init();
9496
QTreeWidgetItem * createTreeItemWidgets( );

src/ui/qgscustomizationdialogbase.ui

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@
1515
</property>
1616
<widget class="QWidget" name="centralwidget">
1717
<layout class="QVBoxLayout" name="verticalLayout_2">
18+
<item>
19+
<widget class="QCheckBox" name="mCustomizationEnabledCheckBox">
20+
<property name="text">
21+
<string>Enable customization</string>
22+
</property>
23+
</widget>
24+
</item>
1825
<item>
1926
<widget class="QTreeWidget" name="treeWidget">
2027
<property name="selectionBehavior">

0 commit comments

Comments
 (0)