mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-01 00:46:20 -05:00
add option to choose whether enable project macros
This commit is contained in:
parent
2910a8eaf0
commit
7a241046a2
@ -474,6 +474,11 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
|
||||
|
||||
centralLayout->addWidget( mMapCanvas, 0, 0, 2, 1 );
|
||||
|
||||
// a bar to warn the user with non-blocking messages
|
||||
mInfoBar = new QgsMessageBar( centralWidget );
|
||||
mInfoBar->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed );
|
||||
centralLayout->addWidget( mInfoBar, 0, 0, 1, 1 );
|
||||
|
||||
//set the focus to the map canvas
|
||||
mMapCanvas->setFocus();
|
||||
|
||||
@ -502,11 +507,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
|
||||
updateProjectFromTemplates();
|
||||
activateDeactivateLayerRelatedActions( NULL );
|
||||
|
||||
// a bar to warn the user with non-blocking messages
|
||||
mInfoBar = new QgsMessageBar( centralWidget );
|
||||
mInfoBar->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed );
|
||||
centralLayout->addWidget( mInfoBar, 0, 0, 1, 1 );
|
||||
|
||||
// create the notification widget for macros
|
||||
mMacrosWarn = QgsMessageBar::createMessage( tr( "Security warning:" ),
|
||||
tr( "macros have been disabled." ),
|
||||
QgsApplication::getThemeIcon( "/mIconWarn.png" ),
|
||||
@ -514,7 +515,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
|
||||
|
||||
QToolButton *btnEnableMacros = new QToolButton( mMacrosWarn );
|
||||
btnEnableMacros->setText( tr( "Enable" ) );
|
||||
btnEnableMacros->setStyleSheet( "background-color: rgba(255, 255, 255, 0);text-decoration: underline;" );
|
||||
btnEnableMacros->setStyleSheet( "background-color: rgba(255, 255, 255, 0); color: black; text-decoration: underline;" );
|
||||
btnEnableMacros->setCursor( Qt::PointingHandCursor );
|
||||
connect( btnEnableMacros, SIGNAL( clicked() ), mInfoBar, SLOT( popWidget() ) );
|
||||
connect( btnEnableMacros, SIGNAL( clicked() ), this, SLOT( enableProjectMacros() ) );
|
||||
@ -841,6 +842,13 @@ void QgisApp::readSettings()
|
||||
|
||||
// Add the recently accessed project file paths to the File menu
|
||||
mRecentProjectPaths = settings.value( "/UI/recentProjectsList" ).toStringList();
|
||||
|
||||
// this is a new session! reset enable macros value to "ask"
|
||||
// whether set to "just for this session"
|
||||
if ( settings.value( "/qgis/enableMacros", 1 ).toInt() == 2 )
|
||||
{
|
||||
settings.setValue( "/qgis/enableMacros", 1 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -3239,13 +3247,20 @@ void QgisApp::fileOpen()
|
||||
// does the project have any macros?
|
||||
if ( mPythonUtils && mPythonUtils->isEnabled() )
|
||||
{
|
||||
if ( settings.value( "/qgis/enable_macros", false ).toBool() )
|
||||
if ( !QgsProject::instance()->readEntry( "Macros", "/pythonCode", QString::null ).isEmpty() )
|
||||
{
|
||||
enableProjectMacros();
|
||||
}
|
||||
else if ( !QgsProject::instance()->readEntry( "Macros", "/pythonCode", QString::null ).isEmpty() )
|
||||
{
|
||||
mInfoBar->pushWidget( mMacrosWarn, 1 );
|
||||
int enableMacros = settings.value( "/qgis/enableMacros", 1 ).toInt();
|
||||
// 0 = never, 1 = ask, 2 = just for this session, 3 = always
|
||||
|
||||
if ( enableMacros == 3 || enableMacros == 2 )
|
||||
{
|
||||
enableProjectMacros();
|
||||
}
|
||||
else if ( enableMacros == 1 ) // ask
|
||||
{
|
||||
// display the macros notification widget
|
||||
mInfoBar->pushWidget( mMacrosWarn, 1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -429,6 +429,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
|
||||
|
||||
chbAskToSaveProjectChanges->setChecked( settings.value( "qgis/askToSaveProjectChanges", QVariant( true ) ).toBool() );
|
||||
chbWarnOldProjectVersion->setChecked( settings.value( "/qgis/warnOldProjectVersion", QVariant( true ) ).toBool() );
|
||||
cmbEnableMacros->setCurrentIndex( settings.value( "/qgis/enableMacros", 1 ).toInt() );
|
||||
|
||||
// templates
|
||||
cbxProjectDefaultNew->setChecked( settings.value( "/qgis/newProjectDefault", QVariant( false ) ).toBool() );
|
||||
@ -843,6 +844,7 @@ void QgsOptions::saveOptions()
|
||||
settings.setValue( "/qgis/projectTemplateDir", leTemplateFolder->text() );
|
||||
QgisApp::instance()->updateProjectFromTemplates();
|
||||
}
|
||||
settings.setValue( "/qgis/enableMacros", cmbEnableMacros->currentIndex() );
|
||||
|
||||
settings.setValue( "/qgis/nullValue", leNullValue->text() );
|
||||
settings.setValue( "/qgis/style", cmbStyle->currentText() );
|
||||
|
@ -66,8 +66,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>784</width>
|
||||
<height>1099</height>
|
||||
<width>772</width>
|
||||
<height>1062</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
@ -174,6 +174,60 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_21">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_33">
|
||||
<property name="text">
|
||||
<string>Enable macros</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="cmbEnableMacros">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QComboBox::AdjustToContents</enum>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Never</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Ask</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>For this session only</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Always (not recommended)</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_17">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
@ -949,8 +1003,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1201</width>
|
||||
<height>850</height>
|
||||
<width>1012</width>
|
||||
<height>815</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_8">
|
||||
@ -1464,8 +1518,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>646</width>
|
||||
<height>778</height>
|
||||
<width>772</width>
|
||||
<height>724</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
@ -1834,8 +1888,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>317</width>
|
||||
<height>91</height>
|
||||
<width>788</width>
|
||||
<height>585</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_10">
|
||||
@ -1915,8 +1969,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>679</width>
|
||||
<height>642</height>
|
||||
<width>772</width>
|
||||
<height>606</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_13">
|
||||
@ -2291,8 +2345,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>745</width>
|
||||
<height>431</height>
|
||||
<width>788</width>
|
||||
<height>585</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_15">
|
||||
@ -2478,8 +2532,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>519</width>
|
||||
<height>575</height>
|
||||
<width>788</width>
|
||||
<height>585</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_17">
|
||||
@ -2575,8 +2629,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>589</width>
|
||||
<height>582</height>
|
||||
<width>788</width>
|
||||
<height>585</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_20">
|
||||
|
Loading…
x
Reference in New Issue
Block a user