Skip to content

Commit

Permalink
global customization enable checkbox
Browse files Browse the repository at this point in the history
  • Loading branch information
blazek committed Dec 1, 2012
1 parent 6129e92 commit 74d126b
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 6 deletions.
12 changes: 8 additions & 4 deletions src/app/main.cpp
Expand Up @@ -512,8 +512,12 @@ int main( int argc, char *argv[] )
QSettings::setPath( QSettings::IniFormat, QSettings::UserScope, optionpath.isEmpty() ? configpath : optionpath );
}

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

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

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

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

/////////////////////////////////`////////////////////////////////////
Expand Down
23 changes: 21 additions & 2 deletions src/app/qgscustomization.cpp
Expand Up @@ -46,6 +46,7 @@ QgsCustomizationDialog::QgsCustomizationDialog( QWidget *parent, QSettings* sett
{
mSettings = settings;
setupUi( this );

init();
QStringList myHeaders;
myHeaders << tr( "Object name" ) << tr( "Label" ) << tr( "Description" );
Expand Down Expand Up @@ -181,6 +182,12 @@ void QgsCustomizationDialog::reset()
{
mSettings->sync();
settingsToTree( mSettings );

QSettings settings;
bool enabled = settings.value( "/UI/Customization/enabled", "0" ).toInt() == 1;
mCustomizationEnabledCheckBox->setChecked( enabled );
treeWidget->setEnabled( enabled );
toolBar->setEnabled( enabled );
}

void QgsCustomizationDialog::ok()
Expand All @@ -194,6 +201,9 @@ void QgsCustomizationDialog::apply()
treeToSettings( mSettings );
mSettings->setValue( QgsCustomization::instance()->statusPath(), QgsCustomization::User );
mSettings->sync();

QSettings settings;
settings.setValue( "/UI/Customization/enabled", mCustomizationEnabledCheckBox->isChecked() );
}

void QgsCustomizationDialog::cancel()
Expand Down Expand Up @@ -263,6 +273,12 @@ void QgsCustomizationDialog::on_actionSelectAll_triggered( bool checked )
}
}

void QgsCustomizationDialog::on_mCustomizationEnabledCheckBox_toggled( bool checked )
{
treeWidget->setEnabled( checked );
toolBar->setEnabled( checked );
}

void QgsCustomizationDialog::init()
{
QgsDebugMsg( "Entered" );
Expand Down Expand Up @@ -538,7 +554,7 @@ void QgsCustomization::createTreeItemToolbars( )
void QgsCustomization::createTreeItemDocks( )
{
QStringList data;
data << "Docks";
data << "Panels";

QTreeWidgetItem *topItem = new QTreeWidgetItem( data );

Expand Down Expand Up @@ -598,10 +614,13 @@ QgsCustomization *QgsCustomization::instance()

QgsCustomization::QgsCustomization()
: pDialog( 0 )
, mEnabled( true )
, mEnabled( false )
, mStatusPath( "/Customization/status" )
{
QgsDebugMsg( "Entered" );

QSettings settings;
mEnabled = settings.value( "/UI/Customization/enabled", "false" ).toString() == "true";
}

QgsCustomization::~QgsCustomization()
Expand Down
2 changes: 2 additions & 0 deletions src/app/qgscustomization.h
Expand Up @@ -89,6 +89,8 @@ class QgsCustomizationDialog : public QMainWindow, private Ui::QgsCustomizationD
void on_actionCollapseAll_triggered( bool checked );
void on_actionSelectAll_triggered( bool checked );

void on_mCustomizationEnabledCheckBox_toggled( bool checked );

private:
void init();
QTreeWidgetItem * createTreeItemWidgets( );
Expand Down
7 changes: 7 additions & 0 deletions src/ui/qgscustomizationdialogbase.ui
Expand Up @@ -15,6 +15,13 @@
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QCheckBox" name="mCustomizationEnabledCheckBox">
<property name="text">
<string>Enable customization</string>
</property>
</widget>
</item>
<item>
<widget class="QTreeWidget" name="treeWidget">
<property name="selectionBehavior">
Expand Down

0 comments on commit 74d126b

Please sign in to comment.