File indexing completed on 2024-07-14 14:34:07

0001 /*
0002     This file is part of the KDE libraries
0003     SPDX-FileCopyrightText: 2005 David Faure <faure@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-only
0006 */
0007 
0008 #include "pastedialog_p.h"
0009 
0010 #include <KLocalizedString>
0011 
0012 #include <QApplication>
0013 #include <QClipboard>
0014 #include <QComboBox>
0015 #include <QDialogButtonBox>
0016 #include <QLabel>
0017 #include <QLineEdit>
0018 #include <QVBoxLayout>
0019 
0020 KIO::PasteDialog::PasteDialog(const QString &title, const QString &label, const QString &value, const QStringList &items, QWidget *parent)
0021     : QDialog(parent)
0022 {
0023     setWindowTitle(title);
0024     setModal(true);
0025 
0026     QVBoxLayout *topLayout = new QVBoxLayout(this);
0027 
0028     QFrame *frame = new QFrame(this);
0029     topLayout->addWidget(frame);
0030 
0031     QVBoxLayout *layout = new QVBoxLayout(frame);
0032 
0033     m_label = new QLabel(label, frame);
0034     m_label->setWordWrap(true);
0035     layout->addWidget(m_label);
0036 
0037     m_lineEdit = new QLineEdit(value, frame);
0038     layout->addWidget(m_lineEdit);
0039 
0040     m_lineEdit->setFocus();
0041     m_label->setBuddy(m_lineEdit);
0042 
0043     layout->addWidget(new QLabel(i18n("Data format:"), frame));
0044     m_comboBox = new QComboBox(frame);
0045     m_comboBox->addItems(items);
0046     layout->addWidget(m_comboBox);
0047 
0048     layout->addStretch();
0049 
0050     QDialogButtonBox *buttonBox = new QDialogButtonBox(this);
0051     buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
0052     connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
0053     connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
0054     topLayout->addWidget(buttonBox);
0055 
0056     setMinimumWidth(350);
0057 }
0058 
0059 QString KIO::PasteDialog::lineEditText() const
0060 {
0061     return m_lineEdit->text();
0062 }
0063 
0064 int KIO::PasteDialog::comboItem() const
0065 {
0066     return m_comboBox->currentIndex();
0067 }
0068 
0069 #include "moc_pastedialog_p.cpp"