Skip to content
Permalink
Browse files
global customization enable checkbox
  • Loading branch information
blazek committed Dec 1, 2012
1 parent 6129e92 commit 74d126b23ee612be671d9463eb5ce304eb7fc54c
Showing with 38 additions and 6 deletions.
  1. +8 −4 src/app/main.cpp
  2. +21 −2 src/app/qgscustomization.cpp
  3. +2 −0 src/app/qgscustomization.h
  4. +7 −0 src/ui/qgscustomizationdialogbase.ui
@@ -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 );

@@ -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
@@ -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 ) );
}

/////////////////////////////////`////////////////////////////////////
@@ -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" );
@@ -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()
@@ -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()
@@ -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" );
@@ -538,7 +554,7 @@ void QgsCustomization::createTreeItemToolbars( )
void QgsCustomization::createTreeItemDocks( )
{
QStringList data;
data << "Docks";
data << "Panels";

QTreeWidgetItem *topItem = new QTreeWidgetItem( data );

@@ -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()
@@ -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( );
@@ -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">

0 comments on commit 74d126b

Please sign in to comment.