17#include "moc_qgsencodingfiledialog.cpp"
28#include <QDialogButtonBox>
31 const QString &caption,
const QString &directory,
32 const QString &filter,
const QString &encoding )
33 : QFileDialog( parent, caption, directory, filter )
36 mCancelAllButton =
nullptr;
37 mEncodingComboBox =
new QComboBox(
this );
38 QLabel *l =
new QLabel( tr(
"Encoding:" ),
this );
40 setOption( QFileDialog::DontUseNativeDialog );
41 layout()->addWidget( l );
42 layout()->addWidget( mEncodingComboBox );
51 enc = settings.
value( QStringLiteral(
"UI/encoding" ),
"System" ).toString();
56 int encindex = mEncodingComboBox->findText( enc );
59 mEncodingComboBox->insertItem( 0, enc );
62 mEncodingComboBox->setCurrentIndex( encindex );
68 selectNameFilter( nameFilters().at( 0 ) );
76 return mEncodingComboBox->currentText();
88 if ( ! mCancelAllButton )
90 mCancelAllButton =
new QPushButton( tr(
"Cancel &All" ),
nullptr );
91 layout()->addWidget( mCancelAllButton );
109 : QDialog( parent, flags )
113 c = tr(
"Encoding" );
115 setWindowTitle( tr(
"Select Encoding" ) );
117 QVBoxLayout *layout =
new QVBoxLayout();
118 layout->setContentsMargins( 6, 6, 6, 6 );
120 mEncodingComboBox =
new QComboBox(
this );
121 QLabel *l =
new QLabel(
c,
this );
123 QHBoxLayout *hLayout =
new QHBoxLayout();
124 hLayout->addWidget( l );
125 hLayout->addWidget( mEncodingComboBox, 1 );
126 layout->addLayout( hLayout );
128 QDialogButtonBox *buttonBox =
new QDialogButtonBox( QDialogButtonBox::Ok | QDialogButtonBox::Cancel,
129 Qt::Horizontal,
this );
130 buttonBox->button( QDialogButtonBox::Ok )->setDefault(
true );
131 connect( buttonBox, &QDialogButtonBox::rejected,
this, &QDialog::reject );
132 connect( buttonBox, &QDialogButtonBox::accepted,
this, &QDialog::accept );
133 layout->addWidget( buttonBox );
136 mEncodingComboBox->addItem( tr(
"System" ) );
144 enc = settings.
value( QStringLiteral(
"UI/encoding" ),
"System" ).toString();
152 return mEncodingComboBox->currentText();
160 int encindex = mEncodingComboBox->findText(
encoding );
163 mEncodingComboBox->insertItem( 0,
encoding );
166 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)