mirror of
https://github.com/qgis/QGIS.git
synced 2025-11-13 00:07:27 -05:00
ui tweaks to make dialog more compact, add right-click action to swap options ui
This commit is contained in:
parent
e3855de948
commit
ce6140201d
@ -6,13 +6,24 @@ class QgsRasterFormatSaveOptionsWidget : QWidget
|
||||
%End
|
||||
|
||||
public:
|
||||
QgsRasterFormatSaveOptionsWidget( QWidget* parent = 0, QString format = "GTiff", QString provider = "gdal" );
|
||||
|
||||
enum Type
|
||||
{
|
||||
Default, // everything except profile buttons (save as dlg)
|
||||
Full, // everything (options dlg)
|
||||
Table, // just table
|
||||
LineEdit // just the line edit
|
||||
};
|
||||
|
||||
QgsRasterFormatSaveOptionsWidget( QWidget* parent = 0, QString format = "GTiff",
|
||||
QgsRasterFormatSaveOptionsWidget::Type type = Default,
|
||||
QString provider = "gdal" );
|
||||
~QgsRasterFormatSaveOptionsWidget();
|
||||
|
||||
void setFormat( QString format );
|
||||
void setProvider( QString provider );
|
||||
QStringList options() const;
|
||||
void showProfileButtons( bool show = true );
|
||||
void setType( QgsRasterFormatSaveOptionsWidget::Type type = Default );
|
||||
|
||||
public slots:
|
||||
|
||||
@ -32,6 +43,7 @@ class QgsRasterFormatSaveOptionsWidget : QWidget
|
||||
void optionsTableChanged();
|
||||
void optionsTableEnableDeleteButton();
|
||||
void updateOptions();
|
||||
void swapOptionsUI( int newIndex = -1 );
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@ -20,6 +20,8 @@ class GdalToolsDialog(QWidget, Ui_Widget, BasePluginWidget):
|
||||
self.inSelector.setType( self.inSelector.FILE )
|
||||
self.outSelector.setType( self.outSelector.FILE )
|
||||
self.recurseCheck.hide()
|
||||
# use this for approx. previous UI
|
||||
#self.creationOptionsTable.setType(QgsRasterFormatSaveOptionsWidget.Table)
|
||||
|
||||
self.outputFormat = Utils.fillRasterOutputFormat()
|
||||
self.extent = None
|
||||
|
||||
@ -1104,9 +1104,9 @@ void QgsOptions::editGdalDriver( const QString& driverName )
|
||||
label->setAlignment( Qt::AlignHCenter );
|
||||
layout->addWidget( label );
|
||||
QgsRasterFormatSaveOptionsWidget* optionsWidget =
|
||||
new QgsRasterFormatSaveOptionsWidget( &dlg, driverName, "gdal" );
|
||||
new QgsRasterFormatSaveOptionsWidget( &dlg, driverName,
|
||||
QgsRasterFormatSaveOptionsWidget::Full, "gdal" );
|
||||
layout->addWidget( optionsWidget );
|
||||
optionsWidget->showProfileButtons( true );
|
||||
|
||||
if ( dlg.exec() == QDialog::Accepted )
|
||||
{
|
||||
|
||||
@ -29,6 +29,7 @@
|
||||
#include <QMessageBox>
|
||||
#include <QTextEdit>
|
||||
#include <QMouseEvent>
|
||||
#include <QMenu>
|
||||
|
||||
// todo put this somewhere else - how can we access gdal provider?
|
||||
char** papszFromStringList( const QStringList& list )
|
||||
@ -43,12 +44,17 @@ char** papszFromStringList( const QStringList& list )
|
||||
|
||||
QMap< QString, QStringList > QgsRasterFormatSaveOptionsWidget::mBuiltinProfiles;
|
||||
|
||||
QgsRasterFormatSaveOptionsWidget::QgsRasterFormatSaveOptionsWidget( QWidget* parent, QString format, QString provider )
|
||||
QgsRasterFormatSaveOptionsWidget::QgsRasterFormatSaveOptionsWidget( QWidget* parent, QString format,
|
||||
QgsRasterFormatSaveOptionsWidget::Type type,
|
||||
QString provider )
|
||||
: QWidget( parent ), mFormat( format ), mProvider( provider )
|
||||
|
||||
{
|
||||
setupUi( this );
|
||||
|
||||
|
||||
setType( type );
|
||||
|
||||
if ( mBuiltinProfiles.isEmpty() )
|
||||
{
|
||||
// key=profileKey values=format,profileName,options
|
||||
@ -66,16 +72,16 @@ QgsRasterFormatSaveOptionsWidget::QgsRasterFormatSaveOptionsWidget( QWidget* par
|
||||
<< "COMPRESS=JPEG" );
|
||||
}
|
||||
|
||||
showProfileButtons( false );
|
||||
|
||||
connect( mProfileComboBox, SIGNAL( currentIndexChanged( const QString & ) ),
|
||||
this, SLOT( updateOptions() ) );
|
||||
connect( mOptionsTable, SIGNAL( cellChanged( int, int ) ), this, SLOT( optionsTableChanged() ) );
|
||||
connect( mOptionsHelpButton, SIGNAL( clicked() ), this, SLOT( helpOptions() ) );
|
||||
connect( mOptionsValidateButton, SIGNAL( clicked() ), this, SLOT( validateOptions() ) );
|
||||
|
||||
// map options label left mouse click to optionsToggle()
|
||||
mOptionsLabel->installEventFilter( this );
|
||||
// create eventFilter to map right click to swapOptionsUI()
|
||||
// mOptionsLabel->installEventFilter( this );
|
||||
mOptionsLineEdit->installEventFilter( this );
|
||||
mOptionsStackedWidget->installEventFilter( this );
|
||||
|
||||
updateProfiles();
|
||||
}
|
||||
@ -95,10 +101,40 @@ void QgsRasterFormatSaveOptionsWidget::setProvider( QString provider )
|
||||
mProvider = provider;
|
||||
}
|
||||
|
||||
|
||||
void QgsRasterFormatSaveOptionsWidget::showProfileButtons( bool show )
|
||||
// show/hide widgets - we need this function if widget is used in creator
|
||||
void QgsRasterFormatSaveOptionsWidget::setType( QgsRasterFormatSaveOptionsWidget::Type type )
|
||||
{
|
||||
mProfileButtons->setVisible( show );
|
||||
QList< QWidget* > widgets = this->findChildren<QWidget *>();
|
||||
if (( type == Table ) || ( type == LineEdit ) )
|
||||
{
|
||||
// hide all controls, except stacked widget
|
||||
foreach( QWidget* widget, widgets )
|
||||
{
|
||||
widget->setVisible( false );
|
||||
}
|
||||
mOptionsStackedWidget->setVisible( true );
|
||||
foreach( QWidget* widget, mOptionsStackedWidget->findChildren<QWidget *>() )
|
||||
{
|
||||
widget->setVisible( true );
|
||||
}
|
||||
// show page relevant page
|
||||
if ( type == Table )
|
||||
swapOptionsUI( 0 );
|
||||
else if ( type == LineEdit )
|
||||
swapOptionsUI( 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
// show all widgets, except profile buttons (unless Full)
|
||||
foreach( QWidget* widget, widgets )
|
||||
{
|
||||
widget->setVisible( true );
|
||||
}
|
||||
if ( type != Full )
|
||||
{
|
||||
mProfileButtons->setVisible( false );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QgsRasterFormatSaveOptionsWidget::updateProfiles()
|
||||
@ -152,7 +188,7 @@ void QgsRasterFormatSaveOptionsWidget::updateOptions()
|
||||
QString myOptions = mOptionsMap.value( currentProfileKey() );
|
||||
QStringList myOptionsList = myOptions.trimmed().split( " ", QString::SkipEmptyParts );
|
||||
|
||||
if ( mOptionsStackedWIdget->currentIndex() == 0 )
|
||||
if ( mOptionsStackedWidget->currentIndex() == 0 )
|
||||
{
|
||||
mOptionsTable->setRowCount( 0 );
|
||||
for ( int i = 0; i < myOptionsList.count(); i++ )
|
||||
@ -392,19 +428,61 @@ QStringList QgsRasterFormatSaveOptionsWidget::profiles() const
|
||||
return mySettings.value( mProvider + "/driverOptions/" + mFormat.toLower() + "/profiles", "" ).toString().trimmed().split( " ", QString::SkipEmptyParts );
|
||||
}
|
||||
|
||||
void QgsRasterFormatSaveOptionsWidget::swapOptionsUI( int newIndex )
|
||||
{
|
||||
// set new page
|
||||
int oldIndex;
|
||||
if ( newIndex == -1 )
|
||||
{
|
||||
oldIndex = mOptionsStackedWidget->currentIndex();
|
||||
newIndex = ( oldIndex + 1 ) % 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
oldIndex = ( newIndex + 1 ) % 2;
|
||||
}
|
||||
|
||||
// resize pages to minimum - this works well with gdaltools merge ui, but not raster save as...
|
||||
mOptionsStackedWidget->setCurrentIndex( newIndex );
|
||||
mOptionsStackedWidget->widget( newIndex )->setSizePolicy(
|
||||
QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) );
|
||||
mOptionsStackedWidget->widget( oldIndex )->setSizePolicy(
|
||||
QSizePolicy( QSizePolicy::Ignored, QSizePolicy::Ignored ) );
|
||||
layout()->activate();
|
||||
|
||||
updateOptions();
|
||||
}
|
||||
|
||||
// map options label left mouse click to optionsToggle()
|
||||
bool QgsRasterFormatSaveOptionsWidget::eventFilter( QObject *obj, QEvent *event )
|
||||
{
|
||||
if ( event->type() == QEvent::MouseButtonPress )
|
||||
{
|
||||
QMouseEvent *mouseEvent = static_cast<QMouseEvent *>( event );
|
||||
if ( mouseEvent && ( mouseEvent->button() == Qt::LeftButton ) )
|
||||
if ( mouseEvent && ( mouseEvent->button() == Qt::RightButton ) )
|
||||
{
|
||||
mOptionsStackedWIdget->setCurrentIndex(( mOptionsStackedWIdget->currentIndex() + 1 ) % 2 );
|
||||
updateOptions();
|
||||
QMenu* menu = 0;
|
||||
QString text;
|
||||
if ( mOptionsStackedWidget->currentIndex() == 0 )
|
||||
text = tr( "Use simple interface" );
|
||||
else
|
||||
text = tr( "Use table interface" );
|
||||
if ( obj->objectName() == "mOptionsLineEdit" )
|
||||
{
|
||||
menu = mOptionsLineEdit->createStandardContextMenu();
|
||||
menu->addSeparator();
|
||||
}
|
||||
else
|
||||
menu = new QMenu( this );
|
||||
QAction* action = new QAction( text, menu );
|
||||
menu->addAction( action );
|
||||
connect( action, SIGNAL( triggered() ), this, SLOT( swapOptionsUI() ) );
|
||||
menu->exec( mouseEvent->globalPos() );
|
||||
delete menu;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// standard event processing
|
||||
return QObject::eventFilter( obj, event );
|
||||
}
|
||||
|
||||
|
||||
@ -23,19 +23,30 @@
|
||||
/** \ingroup gui
|
||||
* A widget to select format-specific raster saving options
|
||||
*/
|
||||
class GUI_EXPORT QgsRasterFormatSaveOptionsWidget: public QWidget, private Ui::QgsRasterFormatSaveOptionsWidgetBase
|
||||
class GUI_EXPORT QgsRasterFormatSaveOptionsWidget: public QWidget,
|
||||
private Ui::QgsRasterFormatSaveOptionsWidgetBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
QgsRasterFormatSaveOptionsWidget( QWidget* parent = 0, QString format = "GTiff", QString provider = "gdal" );
|
||||
enum Type
|
||||
{
|
||||
Default, // everything except profile buttons (save as dlg)
|
||||
Full, // everything (options dlg)
|
||||
Table, // just table
|
||||
LineEdit // just the line edit
|
||||
};
|
||||
|
||||
QgsRasterFormatSaveOptionsWidget( QWidget* parent = 0, QString format = "GTiff",
|
||||
QgsRasterFormatSaveOptionsWidget::Type type = Default,
|
||||
QString provider = "gdal" );
|
||||
~QgsRasterFormatSaveOptionsWidget();
|
||||
|
||||
void setFormat( QString format );
|
||||
void setProvider( QString provider );
|
||||
QStringList options() const;
|
||||
void showProfileButtons( bool show = true );
|
||||
void setType( QgsRasterFormatSaveOptionsWidget::Type type = Default );
|
||||
|
||||
public slots:
|
||||
|
||||
@ -54,6 +65,7 @@ class GUI_EXPORT QgsRasterFormatSaveOptionsWidget: public QWidget, private Ui::Q
|
||||
void optionsTableChanged();
|
||||
void optionsTableEnableDeleteButton();
|
||||
void updateOptions();
|
||||
void swapOptionsUI( int newIndex = -1 );
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>389</width>
|
||||
<width>341</width>
|
||||
<height>203</height>
|
||||
</rect>
|
||||
</property>
|
||||
@ -14,48 +14,9 @@
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="0">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>5</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="mOptionsLabel">
|
||||
<property name="text">
|
||||
<string>Options</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<item row="0" column="1">
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QComboBox" name="mProfileComboBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<item row="1" column="1">
|
||||
<widget class="QWidget" name="mProfileButtons" native="true">
|
||||
<layout class="QHBoxLayout" name="mProfileButtonsLayout">
|
||||
<property name="margin">
|
||||
@ -85,10 +46,33 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="mProfileComboBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="mProfileLabel">
|
||||
<property name="text">
|
||||
<string>Profile</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QStackedWidget" name="mOptionsStackedWIdget">
|
||||
<item row="2" column="1">
|
||||
<widget class="QStackedWidget" name="mOptionsStackedWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
@ -207,28 +191,12 @@
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="mProfileLabel">
|
||||
<property name="text">
|
||||
<string>Profile</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<spacer name="horizontalSpacer">
|
||||
<item row="1" column="1">
|
||||
<widget class="Line" name="mSeparator">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>5</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user