Changeset View
Changeset View
Standalone View
Standalone View
tests/windowdecotest.cpp
- This file was added.
1 | /* This file is part of the KDE libraries | ||||
---|---|---|---|---|---|
2 | | ||||
3 | Copyright 2017 David Edmundson <davidedmundson@kde.org> | ||||
4 | | ||||
5 | This library is free software; you can redistribute it and/or | ||||
6 | modify it under the terms of the GNU Lesser General Public | ||||
7 | License as published by the Free Software Foundation; either | ||||
8 | version 2.1 of the License, or (at your option) any later version. | ||||
9 | | ||||
10 | This library is distributed in the hope that it will be useful, | ||||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||
13 | Lesser General Public License for more details. | ||||
14 | | ||||
15 | You should have received a copy of the GNU Lesser General Public | ||||
16 | License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||||
17 | */ | ||||
18 | | ||||
19 | /* | ||||
20 | * This class is for checking that wayland server side window decorations remain | ||||
21 | * after a window is hidden and shown. | ||||
22 | */ | ||||
23 | | ||||
24 | #include <QApplication> | ||||
25 | #include <QWidget> | ||||
26 | #include <QPushButton> | ||||
27 | #include <QVBoxLayout> | ||||
28 | #include <QTimer> | ||||
29 | | ||||
30 | class ATestWindow: public QWidget | ||||
31 | { | ||||
32 | Q_OBJECT | ||||
33 | public: | ||||
34 | ATestWindow(); | ||||
35 | | ||||
36 | private: | ||||
37 | QPushButton *mBtn; | ||||
38 | QWidget *m_area; | ||||
39 | }; | ||||
40 | | ||||
41 | ATestWindow::ATestWindow() | ||||
42 | { | ||||
43 | mBtn = new QPushButton(QStringLiteral("Hide and Show")); | ||||
44 | | ||||
45 | m_area = new QWidget; | ||||
46 | m_area->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); | ||||
47 | | ||||
48 | connect(mBtn, &QPushButton::clicked, this, [this]() { | ||||
49 | this->hide(); | ||||
50 | QTimer::singleShot(1000, this, [this](){this->show();}); | ||||
51 | }); | ||||
52 | | ||||
53 | QVBoxLayout *layout = new QVBoxLayout; | ||||
54 | layout->addWidget(mBtn); | ||||
55 | setLayout(layout); | ||||
56 | } | ||||
57 | | ||||
58 | | ||||
59 | | ||||
60 | int main(int argc, char **argv) | ||||
61 | { | ||||
62 | QApplication app(argc, argv); | ||||
63 | | ||||
64 | ATestWindow wnd; | ||||
65 | wnd.show(); | ||||
66 | | ||||
67 | return app.exec(); | ||||
68 | } | ||||
69 | | ||||
70 | | ||||
71 | #include "windowdecotest.moc" |