File indexing completed on 2024-10-13 12:19:30
0001 /* 0002 SPDX-FileCopyrightText: 2001 Simon Hausmann <hausmann@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "kxmlguitest.h" 0008 0009 #include <QAction> 0010 #include <QApplication> 0011 #include <QDir> 0012 #include <QLineEdit> 0013 #include <QTest> 0014 0015 #include <kactioncollection.h> 0016 #include <kmainwindow.h> 0017 #include <kxmlguibuilder.h> 0018 #include <kxmlguifactory.h> 0019 0020 void Client::slotSec() 0021 { 0022 qDebug() << "Client::slotSec()"; 0023 } 0024 0025 int main(int argc, char **argv) 0026 { 0027 QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); 0028 QApplication::setApplicationName(QStringLiteral("test")); 0029 QApplication app(argc, argv); 0030 QAction *a; 0031 0032 KMainWindow *mainwindow = new KMainWindow; 0033 0034 QLineEdit *line = new QLineEdit(mainwindow); 0035 mainwindow->setCentralWidget(line); 0036 0037 mainwindow->show(); 0038 0039 KXMLGUIBuilder *builder = new KXMLGUIBuilder(mainwindow); 0040 0041 KXMLGUIFactory *factory = new KXMLGUIFactory(builder); 0042 0043 Client *shell = new Client; 0044 shell->setComponentName(QStringLiteral("konqueror"), QStringLiteral("Konqueror")); 0045 0046 a = new QAction(QIcon::fromTheme(QStringLiteral("view-split-left-right")), QStringLiteral("Split"), shell); 0047 shell->actionCollection()->addAction(QStringLiteral("splitviewh"), a); 0048 0049 shell->setXMLFile(QFINDTESTDATA("kxmlguitest_shell.rc")); 0050 0051 factory->addClient(shell); 0052 0053 Client *part = new Client; 0054 0055 a = new QAction(QIcon::fromTheme(QStringLiteral("zoom-out")), QStringLiteral("decfont"), part); 0056 part->actionCollection()->addAction(QStringLiteral("decFontSizes"), a); 0057 a = new QAction(QIcon::fromTheme(QStringLiteral("security-low")), QStringLiteral("sec"), part); 0058 part->actionCollection()->addAction(QStringLiteral("security"), a); 0059 part->actionCollection()->setDefaultShortcuts(a, QList<QKeySequence>() << QKeySequence{Qt::ALT | Qt::Key_1}); 0060 a->connect(a, &QAction::triggered, part, &Client::slotSec); 0061 0062 part->setXMLFile(QFINDTESTDATA("kxmlguitest_part.rc")); 0063 0064 factory->addClient(part); 0065 for (int i = 0; i < 10; ++i) { 0066 factory->removeClient(part); 0067 factory->addClient(part); 0068 } 0069 0070 return app.exec(); 0071 } 0072 0073 #include "moc_kxmlguitest.cpp"