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();
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->setMargin( 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" ) );
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 );