Initial qt-tests tray app with split amd64/arm64 AppImage CI workflows
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
#include <QAction>
|
||||
#include <QApplication>
|
||||
#include <QMainWindow>
|
||||
#include <QMenu>
|
||||
#include <QSystemTrayIcon>
|
||||
#include <QVBoxLayout>
|
||||
#include <QLabel>
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
QApplication app(argc, argv);
|
||||
app.setApplicationName("qt_tray_demo");
|
||||
|
||||
QMainWindow window;
|
||||
window.setWindowTitle("Qt Tray Demo");
|
||||
auto *central = new QWidget();
|
||||
auto *layout = new QVBoxLayout(central);
|
||||
layout->addWidget(new QLabel("Qt test app window (tray + window)."));
|
||||
layout->addWidget(new QLabel("Close hides to tray; use tray menu to quit."));
|
||||
window.setCentralWidget(central);
|
||||
window.resize(720, 420);
|
||||
|
||||
auto *tray = new QSystemTrayIcon(QIcon::fromTheme("applications-system"), &app);
|
||||
auto *menu = new QMenu();
|
||||
QAction *showAction = menu->addAction("Show Window");
|
||||
QAction *quitAction = menu->addAction("Quit");
|
||||
QObject::connect(showAction, &QAction::triggered, [&window]() {
|
||||
window.show();
|
||||
window.raise();
|
||||
window.activateWindow();
|
||||
});
|
||||
QObject::connect(quitAction, &QAction::triggered, &app, &QApplication::quit);
|
||||
tray->setContextMenu(menu);
|
||||
tray->setToolTip("Qt Tray Demo");
|
||||
tray->show();
|
||||
|
||||
QObject::connect(&window, &QMainWindow::windowTitleChanged, [](){});
|
||||
window.show();
|
||||
return app.exec();
|
||||
}
|
||||
Reference in New Issue
Block a user