Open-Typer
Open source typewriting tutor program
Loading...
Searching...
No Matches
QuickWindow.h
1/*
2 * QuickWindow.h
3 * This file is part of Open-Typer
4 *
5 * Copyright (C) 2023 - adazem009
6 *
7 * Open-Typer is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * Open-Typer is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with Open-Typer. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef QUICKWINDOW_H
22#define QUICKWINDOW_H
23
24#include <QQuickWindow>
25#include <QWidget>
26#include <QAccessibleWidget>
27
28class QuickWindow : public QQuickWindow
29{
30 Q_OBJECT
31 Q_PROPERTY(bool autoClose READ autoClose WRITE setAutoClose NOTIFY autoCloseChanged)
32 Q_PROPERTY(bool closable READ closable WRITE setClosable NOTIFY closableChanged)
33 public:
34 explicit QuickWindow(QWindow *parent = nullptr);
35
36 bool autoClose() const;
37 void setAutoClose(bool newAutoClose);
38
39 bool closable() const;
40 void setClosable(bool newClosable);
41
42 signals:
43 void autoCloseChanged();
44 void closableChanged();
45
46 protected:
47 void keyPressEvent(QKeyEvent *event) override;
48 void showEvent(QShowEvent *event) override;
49#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
50 void closeEvent(QCloseEvent *event) override;
51#else
52 bool event(QEvent *event) override;
53#endif
54
55 private:
56 bool m_autoClose = true;
57 bool m_closable = true;
58 QWidget m_widget;
59 QAccessibleWidget *m_accessibleWidget;
60};
61
62#endif // QUICKWINDOW_H
Definition QuickWindow.h:29