File indexing completed on 2024-04-21 14:56:12

0001 /* This file is part of the KDE libraries
0002     Copyright (C) 2013 Kevin Ottens <ervin+bluesystems@kde.org>
0003 
0004     This library is free software; you can redistribute it and/or
0005     modify it under the terms of the GNU Library General Public
0006     License as published by the Free Software Foundation; either
0007     version 2 of the License, or (at your option) any later version.
0008 
0009     This library is distributed in the hope that it will be useful,
0010     but WITHOUT ANY WARRANTY; without even the implied warranty of
0011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012     Library General Public License for more details.
0013 
0014     You should have received a copy of the GNU Library General Public License
0015     along with this library; see the file COPYING.LIB.  If not, write to
0016     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0017     Boston, MA 02110-1301, USA.
0018 */
0019 
0020 #include <QApplication>
0021 #include <QDebug>
0022 #include <QPushButton>
0023 
0024 #include "kmessagebox_queued.h"
0025 
0026 class TriggerObject : public QObject
0027 {
0028     Q_OBJECT
0029 public:
0030     TriggerObject(QWidget *parent = nullptr)
0031         : QObject(parent), m_widget(parent) {}
0032 
0033 public Q_SLOTS:
0034     void showMessages()
0035     {
0036         const int total = 10;
0037 
0038         for (int i = 0; i < total; i++) {
0039             QString message = "You should see only one of these (%1/%2)";
0040             KMessageBox::queuedMessageBox(m_widget, KMessageBox::Information, message.arg(i + 1).arg(total));
0041             qDebug() << message.arg(i + 1).arg(total);
0042         }
0043     }
0044 
0045 private:
0046     QWidget *const m_widget;
0047 };
0048 
0049 int main(int argc, char *argv[])
0050 {
0051     QApplication app(argc, argv);
0052 
0053     QPushButton *button = new QPushButton("Click me to see messages");
0054     TriggerObject *trigger = new TriggerObject(button);
0055     QObject::connect(button, SIGNAL(clicked()), trigger, SLOT(showMessages()));
0056     button->show();
0057 
0058     return app.exec();
0059 }
0060 
0061 #include "kmessageboxqueuedtest.moc"