17#include "moc_qgsencodingfiledialog.cpp"
28#include <QDialogButtonBox>
31 : QFileDialog( parent, caption, directory, filter )
34 mCancelAllButton =
nullptr;
35 mEncodingComboBox =
new QComboBox(
this );
36 QLabel *l =
new QLabel( tr(
"Encoding:" ),
this );
38 setOption( QFileDialog::DontUseNativeDialog );
39 layout()->addWidget( l );
40 layout()->addWidget( mEncodingComboBox );
49 enc = settings.
value( QStringLiteral(
"UI/encoding" ),
"System" ).toString();
54 int encindex = mEncodingComboBox->findText( enc );
57 mEncodingComboBox->insertItem( 0, enc );
60 mEncodingComboBox->setCurrentIndex( encindex );
66 selectNameFilter( nameFilters().at( 0 ) );
74 return mEncodingComboBox->currentText();
86 if ( !mCancelAllButton )
88 mCancelAllButton =
new QPushButton( tr(
"Cancel &All" ),
nullptr );
89 layout()->addWidget( mCancelAllButton );
107 : QDialog( parent, flags )
111 c = tr(
"Encoding" );
113 setWindowTitle( tr(
"Select Encoding" ) );
115 QVBoxLayout *layout =
new QVBoxLayout();
116 layout->setContentsMargins( 6, 6, 6, 6 );
118 mEncodingComboBox =
new QComboBox(
this );
119 QLabel *l =
new QLabel(
c,
this );
121 QHBoxLayout *hLayout =
new QHBoxLayout();
122 hLayout->addWidget( l );
123 hLayout->addWidget( mEncodingComboBox, 1 );
124 layout->addLayout( hLayout );
126 QDialogButtonBox *buttonBox =
new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal,
this );
127 buttonBox->button( QDialogButtonBox::Ok )->setDefault(
true );
128 connect( buttonBox, &QDialogButtonBox::rejected,
this, &QDialog::reject );
129 connect( buttonBox, &QDialogButtonBox::accepted,
this, &QDialog::accept );
130 layout->addWidget( buttonBox );
133 mEncodingComboBox->addItem( tr(
"System" ) );
141 enc = settings.
value( QStringLiteral(
"UI/encoding" ),
"System" ).toString();
149 return mEncodingComboBox->currentText();
157 int encindex = mEncodingComboBox->findText(
encoding );
160 mEncodingComboBox->insertItem( 0,
encoding );
163 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.
This class is a composition of two QSettings instances:
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
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
#define QgsDebugMsgLevel(str, level)