File indexing completed on 2021-12-21 13:19:39

0001 /* This file is part of the dbusmenu-qt library
0002    Copyright 2010 Canonical
0003    Author: Aurelien Gateau <aurelien.gateau@canonical.com>
0004 
0005    This library is free software; you can redistribute it and/or
0006    modify it under the terms of the GNU Library General Public
0007    License (LGPL) as published by the Free Software Foundation;
0008    either version 2 of the License, or (at your option) any later
0009    version.
0010 
0011    This library is distributed in the hope that it will be useful,
0012    but WITHOUT ANY WARRANTY; without even the implied warranty of
0013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0014    Library General Public License for more details.
0015 
0016    You should have received a copy of the GNU Library General Public License
0017    along with this library; see the file COPYING.LIB.  If not, write to
0018    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0019    Boston, MA 02110-1301, USA.
0020 */
0021 #include <slowmenu.moc>
0022 
0023 #include <dbusmenuexporter.h>
0024 
0025 #include <QtDBus>
0026 #include <QtGui>
0027 #include <QApplication>
0028 
0029 static const char *TEST_SERVICE = "org.kde.dbusmenu-qt-test";
0030 static const char *TEST_OBJECT_PATH = "/TestMenuBar";
0031 
0032 SlowMenu::SlowMenu()
0033 : QMenu()
0034 {
0035     connect(this, SIGNAL(aboutToShow()), SLOT(slotAboutToShow()));
0036 }
0037 
0038 void SlowMenu::slotAboutToShow()
0039 {
0040     qDebug() << __FUNCTION__ << "Entering";
0041     QTime time;
0042     time.start();
0043     while (time.elapsed() < 2000) {
0044         qApp->processEvents();
0045     }
0046     qDebug() << __FUNCTION__ << "Leaving";
0047 }
0048 
0049 int main(int argc, char** argv)
0050 {
0051     QApplication app(argc, argv);
0052     QDBusConnection::sessionBus().registerService(TEST_SERVICE);
0053     SlowMenu* inputMenu = new SlowMenu;
0054     inputMenu->addAction("Test");
0055     DBusMenuExporter exporter(TEST_OBJECT_PATH, inputMenu);
0056     qDebug() << "Looping";
0057     return app.exec();
0058 }