File indexing completed on 2024-04-14 14:31:19

0001 /*
0002     SPDX-FileCopyrightText: 2008 Volker Krause <vkrause@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "dictionarycombobox.h"
0008 
0009 #include <QApplication>
0010 #include <QDebug>
0011 #include <QHBoxLayout>
0012 #include <QPushButton>
0013 
0014 using namespace Sonnet;
0015 
0016 class DictionaryComboBoxTest : public QWidget
0017 {
0018     Q_OBJECT
0019 public:
0020     DictionaryComboBoxTest()
0021     {
0022         QHBoxLayout *topLayout = new QHBoxLayout(this);
0023         dcb = new DictionaryComboBox(this);
0024         topLayout->addWidget(dcb, 1);
0025         connect(dcb, &DictionaryComboBox::dictionaryChanged, this, &DictionaryComboBoxTest::dictChanged);
0026         connect(dcb, &DictionaryComboBox::dictionaryNameChanged, this, &DictionaryComboBoxTest::dictNameChanged);
0027         QPushButton *btn = new QPushButton(QStringLiteral("Dump"), this);
0028         topLayout->addWidget(btn);
0029         connect(btn, &QPushButton::clicked, this, &DictionaryComboBoxTest::dump);
0030     }
0031 
0032 public Q_SLOTS:
0033     void dump()
0034     {
0035         qDebug() << "Current dictionary: " << dcb->currentDictionary();
0036         qDebug() << "Current dictionary name: " << dcb->currentDictionaryName();
0037     }
0038 
0039     void dictChanged(const QString &name)
0040     {
0041         qDebug() << "Current dictionary changed: " << name;
0042     }
0043 
0044     void dictNameChanged(const QString &name)
0045     {
0046         qDebug() << "Current dictionary name changed: " << name;
0047     }
0048 
0049 private:
0050     DictionaryComboBox *dcb;
0051 };
0052 
0053 int main(int argc, char **argv)
0054 {
0055     QApplication app(argc, argv);
0056 
0057     DictionaryComboBoxTest *test = new DictionaryComboBoxTest();
0058     test->show();
0059 
0060     return app.exec();
0061 }
0062 
0063 #include "dictionarycombobox.moc"