26 #include <QFileDialog>
36 mUseLink->setChecked(
false );
37 mFullUrl->setChecked(
false );
41 mRootPath->setPlaceholderText(
QgsSettings().
value( QStringLiteral(
"/UI/lastExternalResourceWidgetDefaultPath" ), QDir::toNativeSeparators( QDir::cleanPath( defpath ) ) ).toString() );
43 connect( mRootPathButton, &QToolButton::clicked,
this, &QgsExternalResourceConfigDlg::chooseDefaultPath );
46 mRootPathPropertyOverrideButton->registerVisibleWidget( mRootPathExpression );
47 mRootPathPropertyOverrideButton->registerExpressionWidget( mRootPathExpression );
48 mRootPathPropertyOverrideButton->registerVisibleWidget( mRootPath,
false );
49 mRootPathPropertyOverrideButton->registerEnabledWidget( mRootPathButton,
false );
53 mDocumentViewerContentPropertyOverrideButton->registerVisibleWidget( mDocumentViewerContentExpression );
54 mDocumentViewerContentPropertyOverrideButton->registerExpressionWidget( mDocumentViewerContentExpression );
55 mDocumentViewerContentPropertyOverrideButton->registerEnabledWidget( mDocumentViewerContentComboBox,
false );
58 connect( mRootPath, &QLineEdit::textChanged,
this, &QgsExternalResourceConfigDlg::enableRelativeDefault );
59 connect( mRootPathExpression, &QLineEdit::textChanged,
this, &QgsExternalResourceConfigDlg::enableRelativeDefault );
60 connect( mRelativeGroupBox, &QGroupBox::toggled,
this, &QgsExternalResourceConfigDlg::enableRelativeDefault );
65 mStoreFilesButton->setChecked(
true );
70 mRelativeProject->setChecked(
true );
78 connect( mStorageButtonGroup,
static_cast<void ( QButtonGroup::* )(
int )
>( &QButtonGroup::buttonClicked ),
this, &
QgsEditorConfigWidget::changed );
81 connect( mDocumentViewerContentComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, [ = ](
int idx )
91 void QgsExternalResourceConfigDlg::chooseDefaultPath()
94 if ( !mRootPath->text().isEmpty() )
96 dir = mRootPath->text();
101 dir =
QgsSettings().
value( QStringLiteral(
"/UI/lastExternalResourceWidgetDefaultPath" ), QDir::toNativeSeparators( QDir::cleanPath( path ) ) ).toString();
104 QString rootName = QFileDialog::getExistingDirectory(
this, tr(
"Select a directory" ), dir, QFileDialog::ShowDirsOnly );
106 if ( !rootName.isNull() )
107 mRootPath->setText( rootName );
110 void QgsExternalResourceConfigDlg::enableRelativeDefault()
112 bool relativePathActive =
false;
114 if ( mRootPathPropertyOverrideButton->isActive() )
116 if ( !mRootPathExpression->text().isEmpty() )
117 relativePathActive =
true;
121 if ( !mRootPath->text().isEmpty() )
122 relativePathActive =
true;
126 if ( mRelativeGroupBox->isChecked() )
127 mRelativeDefault->setEnabled( relativePathActive );
130 if ( !relativePathActive )
131 mRelativeProject->toggle();
138 cfg.insert( QStringLiteral(
"FileWidget" ), mFileWidgetGroupBox->isChecked() );
139 cfg.insert( QStringLiteral(
"FileWidgetButton" ), mFileWidgetButtonGroupBox->isChecked() );
140 cfg.insert( QStringLiteral(
"FileWidgetFilter" ), mFileWidgetFilterLineEdit->text() );
142 if ( mUseLink->isChecked() )
144 cfg.insert( QStringLiteral(
"UseLink" ), mUseLink->isChecked() );
145 if ( mFullUrl->isChecked() )
146 cfg.insert( QStringLiteral(
"FullUrl" ), mFullUrl->isChecked() );
151 if ( !mRootPath->text().isEmpty() )
152 cfg.insert( QStringLiteral(
"DefaultRoot" ), mRootPath->text() );
155 cfg.insert( QStringLiteral(
"StorageMode" ), mStorageButtonGroup->checkedId() );
158 if ( mRelativeGroupBox->isChecked() )
160 cfg.insert( QStringLiteral(
"RelativeStorage" ), mRelativeButtonGroup->checkedId() );
167 cfg.insert( QStringLiteral(
"DocumentViewer" ), mDocumentViewerContentComboBox->currentData().toInt() );
168 cfg.insert( QStringLiteral(
"DocumentViewerHeight" ), mDocumentViewerHeight->value() );
169 cfg.insert( QStringLiteral(
"DocumentViewerWidth" ), mDocumentViewerWidth->value() );
177 if (
config.contains( QStringLiteral(
"FileWidget" ) ) )
179 mFileWidgetGroupBox->setChecked(
config.value( QStringLiteral(
"FileWidget" ) ).toBool() );
181 if (
config.contains( QStringLiteral(
"FileWidget" ) ) )
183 mFileWidgetButtonGroupBox->setChecked(
config.value( QStringLiteral(
"FileWidgetButton" ) ).toBool() );
185 if (
config.contains( QStringLiteral(
"FileWidgetFilter" ) ) )
187 mFileWidgetFilterLineEdit->setText(
config.value( QStringLiteral(
"FileWidgetFilter" ) ).toString() );
190 if (
config.contains( QStringLiteral(
"UseLink" ) ) )
192 mUseLink->setChecked(
config.value( QStringLiteral(
"UseLink" ) ).toBool() );
193 if (
config.contains( QStringLiteral(
"FullUrl" ) ) )
194 mFullUrl->setChecked(
true );
198 updateDataDefinedButtons();
200 mRootPath->setText(
config.value( QStringLiteral(
"DefaultRoot" ) ).toString() );
203 if (
config.contains( QStringLiteral(
"RelativeStorage" ) ) )
205 int relative =
config.value( QStringLiteral(
"RelativeStorage" ) ).toInt();
208 mRelativeGroupBox->setChecked(
false );
212 mRelativeGroupBox->setChecked(
true );
213 mRelativeButtonGroup->button( relative )->setChecked(
true );
218 if (
config.contains( QStringLiteral(
"StorageMode" ) ) )
220 int mode =
config.value( QStringLiteral(
"StorageMode" ) ).toInt();
221 mStorageButtonGroup->button( mode )->setChecked(
true );
225 if (
config.contains( QStringLiteral(
"DocumentViewer" ) ) )
228 int idx = mDocumentViewerContentComboBox->findData( content );
231 mDocumentViewerContentComboBox->setCurrentIndex( idx );
233 if (
config.contains( QStringLiteral(
"DocumentViewerHeight" ) ) )
235 mDocumentViewerHeight->setValue(
config.value( QStringLiteral(
"DocumentViewerHeight" ) ).toInt() );
237 if (
config.contains( QStringLiteral(
"DocumentViewerWidth" ) ) )
239 mDocumentViewerWidth->setValue(
config.value( QStringLiteral(
"DocumentViewerWidth" ) ).toInt() );