Warning, file /frameworks/kconfigwidgets/tests/kcodecactiontest.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 #include "kcodecactiontest.h" 0002 0003 #include <QApplication> 0004 #include <QMenuBar> 0005 #include <QToolBar> 0006 0007 #include <QDebug> 0008 0009 #include <kcodecaction.h> 0010 0011 int main(int argc, char **argv) 0012 { 0013 QApplication::setApplicationName(QStringLiteral("kcodecactiontest")); 0014 QApplication app(argc, argv); 0015 0016 CodecActionTest *test = new CodecActionTest; 0017 test->show(); 0018 0019 return app.exec(); 0020 } 0021 0022 CodecActionTest::CodecActionTest(QWidget *parent) 0023 : QMainWindow(parent) 0024 , m_comboCodec(new KCodecAction(QStringLiteral("Combo Codec Action"), this)) 0025 , m_buttonCodec(new KCodecAction(QStringLiteral("Button Codec Action"), this)) 0026 { 0027 // clang-format off 0028 m_comboCodec->setToolBarMode(KCodecAction::ComboBoxMode); 0029 connect(m_comboCodec, qOverload<QAction *>(&KSelectAction::triggered), this, &CodecActionTest::actionTriggered); 0030 connect(m_comboCodec, &KSelectAction::indexTriggered, this, &CodecActionTest::indexTriggered); 0031 connect(m_comboCodec, &KSelectAction::textTriggered, this, &CodecActionTest::textTriggered); 0032 #if KCONFIGWIDGETS_BUILD_DEPRECATED_SINCE(5, 103) 0033 connect(m_comboCodec, &KCodecAction::codecTriggered, this, &CodecActionTest::codecTriggered); 0034 #endif 0035 connect(m_comboCodec, &KCodecAction::codecNameTriggered, this, &CodecActionTest::nameTriggered); 0036 0037 m_buttonCodec->setToolBarMode(KCodecAction::MenuMode); 0038 connect(m_buttonCodec, qOverload<QAction *>(&KSelectAction::triggered), this, &CodecActionTest::actionTriggered); 0039 connect(m_buttonCodec, &KSelectAction::indexTriggered, this, &CodecActionTest::indexTriggered); 0040 connect(m_buttonCodec, &KSelectAction::textTriggered, this, &CodecActionTest::textTriggered); 0041 #if KCONFIGWIDGETS_BUILD_DEPRECATED_SINCE(5, 103) 0042 connect(m_buttonCodec, &KCodecAction::codecTriggered, this, &CodecActionTest::codecTriggered); 0043 #endif 0044 connect(m_buttonCodec, &KCodecAction::codecNameTriggered, this, &CodecActionTest::nameTriggered); 0045 // clang-format on 0046 0047 menuBar()->addAction(m_comboCodec); 0048 menuBar()->addAction(m_buttonCodec); 0049 0050 QToolBar *toolBar = addToolBar(QStringLiteral("Test")); 0051 toolBar->addAction(m_comboCodec); 0052 toolBar->addAction(m_buttonCodec); 0053 } 0054 0055 void CodecActionTest::actionTriggered(QAction *action) 0056 { 0057 qDebug() << action; 0058 } 0059 0060 void CodecActionTest::indexTriggered(int index) 0061 { 0062 qDebug() << index; 0063 } 0064 0065 void CodecActionTest::textTriggered(const QString &text) 0066 { 0067 qDebug() << text; 0068 } 0069 0070 #if KCONFIGWIDGETS_BUILD_DEPRECATED_SINCE(5, 103) 0071 void CodecActionTest::codecTriggered(QTextCodec *codec) 0072 { 0073 qDebug() << codec->name() << ':' << codec->mibEnum(); 0074 } 0075 #endif 0076 0077 void CodecActionTest::nameTriggered(const QString &codecName) 0078 { 0079 qDebug() << codecName; 0080 } 0081 0082 void CodecActionTest::slotActionTriggered(bool state) 0083 { 0084 qDebug() << sender() << " state " << state; 0085 }