File indexing completed on 2024-12-22 05:16:21
0001 /* 0002 SPDX-FileCopyrightText: 2023 Fushan Wen <qydwhotmail@gmail.com> 0003 0004 SPDX-License-Identifier: MIT 0005 */ 0006 0007 #include <QGuiApplication> 0008 #include <QRasterWindow> 0009 #include <QTimer> 0010 0011 #include <cstdlib> 0012 0013 /** 0014 * Usage: samplewidgetwindow [title] [icon path/name] [width] [height] 0015 */ 0016 int main(int argc, char *argv[]) 0017 { 0018 QGuiApplication a(argc, argv); 0019 QRasterWindow w; 0020 if (argc >= 2) { 0021 w.setTitle(QString::fromUtf8(argv[1])); 0022 } else { 0023 w.setTitle(QStringLiteral("__test_window_no_title__")); 0024 } 0025 if (argc >= 3) { 0026 const QString iconString = QString::fromLatin1(argv[2]); 0027 QIcon icon(iconString); 0028 if (icon.isNull()) { 0029 icon = QIcon::fromTheme(iconString); 0030 } 0031 if (!icon.isNull()) { 0032 w.setIcon(icon); 0033 } 0034 } 0035 if (argc >= 5) { 0036 const int width = std::max(1, std::stoi(argv[3])); 0037 const int height = std::max(1, std::stoi(argv[4])); 0038 w.setBaseSize(QSize(width, height)); 0039 } else { 0040 w.setBaseSize(QSize(100, 100)); 0041 } 0042 0043 w.show(); 0044 w.raise(); 0045 w.requestActivate(); 0046 0047 QTimer::singleShot(120000, &a, &QCoreApplication::quit); // openbox is slow to respond 0048 0049 return a.exec(); 0050 }