Skip to content
Permalink
Browse files

external resource widget config: use single combobox rather than chec…

…kable group box + combobox

this will allow to use a data defined button later on
  • Loading branch information
3nids committed Mar 14, 2017
1 parent 1e5f649 commit b1327380c604d00bb098392e8024de1ac3b97978
@@ -35,7 +35,6 @@ QgsExternalResourceConfigDlg::QgsExternalResourceConfigDlg( QgsVectorLayer *vl,
// By default, uncheck some options
mUseLink->setChecked( false );
mFullUrl->setChecked( false );
mDocumentViewerGroupBox->setChecked( false );

QString defpath = QgsProject::instance()->fileName().isEmpty() ? QDir::homePath() : QgsProject::instance()->fileInfo().absolutePath();

@@ -61,10 +60,6 @@ QgsExternalResourceConfigDlg::QgsExternalResourceConfigDlg( QgsVectorLayer *vl,
mRelativeButtonGroup->setId( mRelativeDefault, QgsFileWidget::RelativeDefaultPath );
mRelativeProject->setChecked( true );

mDocumentViewerContentComboBox->addItem( tr( "Image" ), QgsExternalResourceWidget::Image );
mDocumentViewerContentComboBox->addItem( tr( "Web view" ), QgsExternalResourceWidget::Web );


connect( mFileWidgetGroupBox, &QGroupBox::toggled, this, &QgsEditorConfigWidget::changed );
connect( mFileWidgetButtonGroupBox, &QGroupBox::toggled, this, &QgsEditorConfigWidget::changed );
connect( mFileWidgetFilterLineEdit, SIGNAL( textChanged( QString ) ), this, SIGNAL( changed() ) );
@@ -74,9 +69,14 @@ QgsExternalResourceConfigDlg::QgsExternalResourceConfigDlg( QgsVectorLayer *vl,
connect( mStorageButtonGroup, SIGNAL( buttonClicked( int ) ), this, SIGNAL( changed() ) );
connect( mRelativeGroupBox, &QGroupBox::toggled, this, &QgsEditorConfigWidget::changed );
connect( mDocumentViewerGroupBox, &QGroupBox::toggled, this, &QgsEditorConfigWidget::changed );
connect( mDocumentViewerContentComboBox, SIGNAL( currentIndexChanged( int ) ), this, SIGNAL( changed() ) );
connect( mDocumentViewerHeight, SIGNAL( valueChanged( int ) ), this, SIGNAL( changed() ) );
connect( mDocumentViewerWidth, SIGNAL( valueChanged( int ) ), this, SIGNAL( changed() ) );
connect( mDocumentViewerContentComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, [ = ]( int idx )
{ mDocumentViewerContentSettingsWidget->setEnabled( ( QgsExternalResourceWidget::DocumentViewerContent )idx != QgsExternalResourceWidget::NoContent ); } );
connect( mDocumentViewerHeight, static_cast<void ( QSpinBox::* )( int )>( &QSpinBox::valueChanged ), this, &QgsEditorConfigWidget::changed );
connect( mDocumentViewerWidth, static_cast<void ( QSpinBox::* )( int )>( &QSpinBox::valueChanged ), this, &QgsEditorConfigWidget::changed );

mDocumentViewerContentComboBox->addItem( tr( "No content" ), QgsExternalResourceWidget::NoContent );
mDocumentViewerContentComboBox->addItem( tr( "Image" ), QgsExternalResourceWidget::Image );
mDocumentViewerContentComboBox->addItem( tr( "Web view" ), QgsExternalResourceWidget::Web );
}

void QgsExternalResourceConfigDlg::chooseDefaultPath()
@@ -164,16 +164,9 @@ QVariantMap QgsExternalResourceConfigDlg::config()
cfg.insert( QStringLiteral( "RelativeStorage" ), ( int )QgsFileWidget::Absolute );
}

if ( mDocumentViewerGroupBox->isChecked() )
{
cfg.insert( QStringLiteral( "DocumentViewer" ), mDocumentViewerContentComboBox->currentData().toInt() );
cfg.insert( QStringLiteral( "DocumentViewerHeight" ), mDocumentViewerHeight->value() );
cfg.insert( QStringLiteral( "DocumentViewerWidth" ), mDocumentViewerWidth->value() );
}
else
{
cfg.insert( QStringLiteral( "DocumentViewer" ), ( int )QgsExternalResourceWidget::NoContent );
}
cfg.insert( QStringLiteral( "DocumentViewer" ), mDocumentViewerContentComboBox->currentData().toInt() );
cfg.insert( QStringLiteral( "DocumentViewerHeight" ), mDocumentViewerHeight->value() );
cfg.insert( QStringLiteral( "DocumentViewerWidth" ), mDocumentViewerWidth->value() );

return cfg;
}
@@ -235,7 +228,6 @@ void QgsExternalResourceConfigDlg::setConfig( const QVariantMap &config )
if ( config.contains( QStringLiteral( "DocumentViewer" ) ) )
{
QgsExternalResourceWidget::DocumentViewerContent content = ( QgsExternalResourceWidget::DocumentViewerContent )config.value( QStringLiteral( "DocumentViewer" ) ).toInt();
mDocumentViewerGroupBox->setChecked( content != QgsExternalResourceWidget::NoContent );
int idx = mDocumentViewerContentComboBox->findData( content );
if ( idx >= 0 )
{
@@ -45,7 +45,7 @@
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<y>-17</y>
<width>467</width>
<height>715</height>
</rect>
@@ -325,62 +325,9 @@
<string>Integrated document viewer</string>
</property>
<property name="checkable">
<bool>true</bool>
<bool>false</bool>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="1">
<widget class="QLabel" name="label_13">
<property name="text">
<string>Height</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QgsSpinBox" name="mDocumentViewerHeight">
<property name="specialValueText">
<string>Auto</string>
</property>
<property name="suffix">
<string> px</string>
</property>
<property name="prefix">
<string/>
</property>
<property name="maximum">
<number>10000</number>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QgsSpinBox" name="mDocumentViewerWidth">
<property name="specialValueText">
<string>Auto</string>
</property>
<property name="suffix">
<string> px</string>
</property>
<property name="maximum">
<number>10000</number>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label_12">
<property name="text">
<string>Width</string>
</property>
</widget>
</item>
<item row="1" column="3" rowspan="2">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Specify the size of the preview. If you leave it set to Auto, an optimal size will be calculated.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_3">
<property name="text">
@@ -391,6 +338,103 @@
<item row="0" column="2">
<widget class="QComboBox" name="mDocumentViewerContentComboBox"/>
</item>
<item row="0" column="3">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1" colspan="3">
<widget class="QWidget" name="mDocumentViewerContentSettingsWidget" native="true">
<layout class="QGridLayout" name="gridLayout_4">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="2" rowspan="2">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Specify the size of the preview. If you leave it set to Auto, an optimal size will be calculated.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_12">
<property name="text">
<string>Width</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QgsSpinBox" name="mDocumentViewerHeight">
<property name="specialValueText">
<string>Auto</string>
</property>
<property name="suffix">
<string> px</string>
</property>
<property name="prefix">
<string/>
</property>
<property name="maximum">
<number>10000</number>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QgsSpinBox" name="mDocumentViewerWidth">
<property name="specialValueText">
<string>Auto</string>
</property>
<property name="suffix">
<string> px</string>
</property>
<property name="maximum">
<number>10000</number>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_13">
<property name="text">
<string>Height</string>
</property>
</widget>
</item>
<item row="0" column="3">
<spacer name="horizontalSpacer_2">
<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>
</widget>
</item>
</layout>
</widget>
</item>
@@ -440,13 +484,11 @@
<tabstop>mFullUrl</tabstop>
<tabstop>mDocumentViewerGroupBox</tabstop>
<tabstop>mDocumentViewerContentComboBox</tabstop>
<tabstop>mDocumentViewerWidth</tabstop>
<tabstop>mDocumentViewerHeight</tabstop>
</tabstops>
<resources/>
<connections/>
<buttongroups>
<buttongroup name="mRelativeButtonGroup"/>
<buttongroup name="mStorageButtonGroup"/>
<buttongroup name="mRelativeButtonGroup"/>
</buttongroups>
</ui>

0 comments on commit b132738

Please sign in to comment.
You can’t perform that action at this time.