File indexing completed on 2024-04-28 04:32:37
0001 /* 0002 SPDX-FileCopyrightText: 2006 Pino Toscano <toscano.pino@tiscali.it> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "chooseenginedialog_p.h" 0008 0009 #include <QComboBox> 0010 #include <QLabel> 0011 0012 #include <KLocalizedString> 0013 #include <QDialogButtonBox> 0014 #include <QPushButton> 0015 #include <QVBoxLayout> 0016 0017 #include "ui_chooseenginewidget.h" 0018 0019 ChooseEngineDialog::ChooseEngineDialog(const QStringList &generators, const QMimeType &mime, QWidget *parent) 0020 : QDialog(parent) 0021 { 0022 setWindowTitle(i18n("Backend Selection")); 0023 QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); 0024 QVBoxLayout *mainLayout = new QVBoxLayout; 0025 setLayout(mainLayout); 0026 QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok); 0027 okButton->setDefault(true); 0028 okButton->setShortcut(Qt::CTRL | Qt::Key_Return); // NOLINT(bugprone-suspicious-enum-usage) 0029 connect(buttonBox, &QDialogButtonBox::accepted, this, &ChooseEngineDialog::accept); 0030 connect(buttonBox, &QDialogButtonBox::rejected, this, &ChooseEngineDialog::reject); 0031 okButton->setDefault(true); 0032 QWidget *main = new QWidget(this); 0033 m_widget = new Ui_ChooseEngineWidget(); 0034 m_widget->setupUi(main); 0035 mainLayout->addWidget(main); 0036 mainLayout->addWidget(buttonBox); 0037 m_widget->engineList->addItems(generators); 0038 0039 m_widget->description->setText( 0040 i18n("<qt>More than one backend found for the MIME type:<br />" 0041 "<b>%1</b> (%2).<br /><br />" 0042 "Please select which one to use:</qt>", 0043 mime.comment(), 0044 mime.name())); 0045 } 0046 0047 ChooseEngineDialog::~ChooseEngineDialog() 0048 { 0049 delete m_widget; 0050 } 0051 0052 int ChooseEngineDialog::selectedGenerator() const 0053 { 0054 return m_widget->engineList->currentIndex(); 0055 }