1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
|
#include "kpassivepopuptest.h"
#include <QApplication>
#include <QPushButton>
#include <kpassivepopup.h>
#include <kwindowsystem.h>
QPushButton *pb;
QPushButton *pb2;
QPushButton *pb3;
QPushButton *pb4;
QPushButton *pb5;
QPushButton *pb6;
QPushButton *pb7;
QSystemTrayIcon *icon;
void Test::showIt()
{
KPassivePopup::message(QStringLiteral("Hello World"), pb);
}
void Test::showIt2()
{
KPassivePopup::message(QStringLiteral("The caption is..."), QStringLiteral("Hello World"), pb2);
}
void Test::showIt3()
{
KPassivePopup *pop = new KPassivePopup();
pop->setView(QStringLiteral("Caption"), QStringLiteral("test"));
pop->show();
}
void Test::showIt4()
{
KPassivePopup::message(KPassivePopup::Boxed, QStringLiteral("The caption is..."), QStringLiteral("Hello World"), pb4);
}
void Test::showIt5()
{
KPassivePopup::message(KPassivePopup::Balloon, QStringLiteral("The caption is..."), QStringLiteral("Hello World"), pb5);
}
void Test::showIt6()
{
KPassivePopup::message(KPassivePopup::Boxed, QStringLiteral("The caption is..."), QStringLiteral("Hello World"), pb6);
}
void Test::showIt7()
{
int iconDimension = QApplication::fontMetrics().height();
KPassivePopup::message(QStringLiteral("The caption is..."),
QStringLiteral("Hello World"),
QIcon::fromTheme(QStringLiteral("dialog-ok")).pixmap(iconDimension, iconDimension),
pb2);
}
void Test::showItIcon(QSystemTrayIcon::ActivationReason reason)
{
if (reason == QSystemTrayIcon::Trigger) {
KPassivePopup::message(QStringLiteral("QSystemTrayIcon test"), QStringLiteral("Hello World"), icon);
}
}
int main(int argc, char **argv)
{
QApplication::setApplicationName(QStringLiteral("test"));
QApplication app(argc, argv);
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
Test *t = new Test();
pb = new QPushButton();
pb->setText(QStringLiteral("By taskbar entry (no caption, default style)"));
pb->connect(pb, &QAbstractButton::clicked, t, &Test::showIt);
pb->show();
pb2 = new QPushButton();
pb2->setText(QStringLiteral("By taskbar entry (with caption, default style)"));
pb2->connect(pb2, &QAbstractButton::clicked, t, &Test::showIt2);
pb2->show();
pb3 = new QPushButton();
pb3->setText(QStringLiteral("Without WinID"));
pb3->connect(pb3, &QAbstractButton::clicked, t, &Test::showIt3);
pb3->show();
pb4 = new QPushButton();
pb4->setText(QStringLiteral("By taskbar entry (with caption, boxed)"));
pb4->connect(pb4, &QAbstractButton::clicked, t, &Test::showIt4);
pb4->show();
pb5 = new QPushButton();
pb5->setText(QStringLiteral("By taskbar entry (with caption, balloon)"));
pb5->connect(pb5, &QAbstractButton::clicked, t, &Test::showIt5);
pb5->show();
// this test depends on X11
pb6 = new QPushButton();
pb6->setText(QStringLiteral("By window (with caption, balloon)"));
pb6->connect(pb6, &QAbstractButton::clicked, t, &Test::showIt6);
pb6->show();
KWindowSystem::setState(pb6->effectiveWinId(), NET::SkipTaskbar);
pb7 = new QPushButton();
pb7->setText(QStringLiteral("By taskbar entry (with caption and icon, default style)"));
pb7->connect(pb7, &QAbstractButton::clicked, t, &Test::showIt7);
pb7->show();
icon = new QSystemTrayIcon();
// TODO icon->setIcon(icon->loadIcon("xorg"));
icon->connect(icon, &QSystemTrayIcon::activated, t, &Test::showItIcon);
icon->show();
return app.exec();
}
#include "moc_kpassivepopuptest.cpp"
|