File indexing completed on 2024-04-21 16:20:01

0001 /* This file is part of the KDE libraries
0002 
0003     SPDX-FileCopyrightText: 2017 David Edmundson <davidedmundson@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.1-or-later
0006 */
0007 
0008 /*
0009  * This class is for checking that wayland server side window decorations remain
0010  * after a window is hidden and shown.
0011  */
0012 
0013 #include <KColorSchemeManager>
0014 #include <QApplication>
0015 #include <QComboBox>
0016 #include <QPushButton>
0017 #include <QTimer>
0018 #include <QVBoxLayout>
0019 #include <QWidget>
0020 
0021 class ATestWindow : public QWidget
0022 {
0023     Q_OBJECT
0024 public:
0025     ATestWindow();
0026 
0027 private:
0028     QPushButton *mBtn = nullptr;
0029     QWidget *m_area = nullptr;
0030 };
0031 
0032 ATestWindow::ATestWindow()
0033 {
0034     mBtn = new QPushButton(QStringLiteral("Hide and Show"));
0035 
0036     m_area = new QWidget;
0037     m_area->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
0038 
0039     connect(mBtn, &QPushButton::clicked, this, [this]() {
0040         this->hide();
0041         QTimer::singleShot(1000, this, [this]() {
0042             this->show();
0043         });
0044     });
0045 
0046     QComboBox *colorCombo = new QComboBox();
0047     KColorSchemeManager *schemes = new KColorSchemeManager(this);
0048     colorCombo->setModel(schemes->model());
0049 
0050     connect(colorCombo, QOverload<int>::of(&QComboBox::activated), schemes, [=](int row) {
0051         schemes->activateScheme(colorCombo->model()->index(row, 0));
0052     });
0053 
0054     QVBoxLayout *layout = new QVBoxLayout;
0055     layout->addWidget(mBtn);
0056     layout->addWidget(colorCombo);
0057     setLayout(layout);
0058 }
0059 
0060 int main(int argc, char **argv)
0061 {
0062     QApplication app(argc, argv);
0063 
0064     ATestWindow wnd;
0065     wnd.show();
0066 
0067     return app.exec();
0068 }
0069 
0070 #include "windowdecotest.moc"