20 #include "qgssettings.h"
23 #include <QPushButton>
27 #include <QDialogButtonBox>
30 const QString &caption,
const QString &directory,
31 const QString &filter,
const QString &encoding )
32 : QFileDialog( parent, caption, directory, filter )
35 mCancelAllButton =
nullptr;
36 mEncodingComboBox =
new QComboBox(
this );
37 QLabel *l =
new QLabel( tr(
"Encoding:" ),
this );
39 setOption( QFileDialog::DontUseNativeDialog );
40 layout()->addWidget( l );
41 layout()->addWidget( mEncodingComboBox );
50 enc = settings.value( QStringLiteral(
"UI/encoding" ),
"System" ).toString();
55 int encindex = mEncodingComboBox->findText( enc );
58 mEncodingComboBox->insertItem( 0, enc );
61 mEncodingComboBox->setCurrentIndex( encindex );
67 selectNameFilter( nameFilters().at( 0 ) );
75 return mEncodingComboBox->currentText();
81 settings.setValue( QStringLiteral(
"UI/encoding" ),
encoding() );
87 if ( ! mCancelAllButton )
89 mCancelAllButton =
new QPushButton( tr(
"Cancel &All" ),
nullptr );
90 layout()->addWidget( mCancelAllButton );
108 : QDialog( parent, flags )
112 c = tr(
"Encoding" );
114 setWindowTitle( tr(
"Select Encoding" ) );
116 QVBoxLayout *layout =
new QVBoxLayout();
117 layout->setContentsMargins( 6, 6, 6, 6 );
119 mEncodingComboBox =
new QComboBox(
this );
120 QLabel *l =
new QLabel(
c,
this );
122 QHBoxLayout *hLayout =
new QHBoxLayout();
123 hLayout->addWidget( l );
124 hLayout->addWidget( mEncodingComboBox, 1 );
125 layout->addLayout( hLayout );
127 QDialogButtonBox *buttonBox =
new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel,
128 Qt::Horizontal,
this );
129 buttonBox->button( QDialogButtonBox::Ok )->setDefault(
true );
130 connect( buttonBox, &QDialogButtonBox::rejected,
this, &QDialog::reject );
131 connect( buttonBox, &QDialogButtonBox::accepted,
this, &QDialog::accept );
132 layout->addWidget( buttonBox );
135 mEncodingComboBox->addItem( tr(
"System" ) );
142 QgsSettings settings;
143 enc = settings.value( QStringLiteral(
"UI/encoding" ),
"System" ).toString();
151 return mEncodingComboBox->currentText();
159 int encindex = mEncodingComboBox->findText(
encoding );
162 mEncodingComboBox->insertItem( 0,
encoding );
165 mEncodingComboBox->setCurrentIndex( encindex );
bool cancelAll()
Returns true if the user clicked 'Cancel All'.
void pbnCancelAll_clicked()
QString encoding() const
Returns a string describing the chosen encoding.
void addCancelAll()
Adds a 'Cancel All' button for the user to click.
QgsEncodingFileDialog(QWidget *parent=nullptr, const QString &caption=QString(), const QString &directory=QString(), const QString &filter=QString(), const QString &encoding=QString())
Constructor for QgsEncodingFileDialog.
QString encoding() const
Returns the encoding selected within the dialog.
QgsEncodingSelectionDialog(QWidget *parent=nullptr, const QString &caption=QString(), const QString &encoding=QString(), Qt::WindowFlags flags=Qt::WindowFlags())
Constructor for QgsEncodingSelectionDialog.
void setEncoding(const QString &encoding)
Sets the encoding selected within the dialog.
static QStringList availableEncodings()
Returns a list of available encodings.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c