swift
enableforframelesswindow.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (C) 2014 swift Project Community / Contributors
2 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3 
5 
6 #ifndef SWIFT_GUI_ENABLEFORFRAMLESSWINDOW_H
7 #define SWIFT_GUI_ENABLEFORFRAMLESSWINDOW_H
8 
9 #include <QByteArray>
10 #include <QPoint>
11 #include <QSize>
12 #include <QString>
13 #include <Qt>
14 
15 #include "gui/swiftguiexport.h"
16 
17 class QEvent;
18 class QHBoxLayout;
19 class QMenuBar;
20 class QMouseEvent;
21 class QPushButton;
22 class QSizeGrip;
23 class QStatusBar;
24 class QWidget;
25 
26 namespace swift::gui
27 {
32  {
33  public:
36  {
37  WindowNormal,
38  WindowFrameless,
39  WindowTool
40  };
41 
47  CEnableForFramelessWindow(WindowMode mode, bool isMainApplicationWindow, const char *framelessPropertyname,
48  QWidget *correspondingWidget);
49 
52 
55 
58 
60  void setMode(WindowMode mode);
61 
63  virtual void setFrameless(bool frameless);
64 
66  bool isFrameless() const { return m_windowMode == WindowFrameless; }
67 
69  bool isMainApplicationWindow() const { return m_isMainApplicationWindow; }
70 
72  void alwaysOnTop(bool onTop);
73 
75  void activate();
76 
78  QWidget *getWidget() const { return m_widget; }
79 
81  static WindowMode stringToWindowMode(const QString &s);
82 
84  static const QString &windowModeToString(WindowMode m);
85 
86  protected:
88  QSize m_moveSize;
89  QPushButton *m_framelessCloseButton = nullptr;
90  WindowMode m_windowMode = WindowNormal;
91  WindowMode m_originalWindowMode = WindowNormal;
92  bool m_isMainApplicationWindow = false;
93  QWidget *m_widget = nullptr;
94  QSizeGrip *m_framelessSizeGrip = nullptr;
96  int m_windowFrameSizeW = -1;
97  int m_windowFrameSizeH = -1;
98 
100  virtual void windowFlagsChanged();
101 
103  void addFramelessSizeGripToStatusBar(QStatusBar *statusBar);
104 
106  void hideFramelessSizeGripInStatusBar();
107 
109  void setWindowAttributes(WindowMode mode);
110 
112  void setDynamicProperties(bool frameless);
113 
115  QHBoxLayout *addFramelessCloseButton(QMenuBar *menuBar);
116 
118  void toolToNormalWindow();
119 
121  void normalToToolWindow();
122 
124  bool isToolWindow() const;
125 
127  bool handleMousePressEvent(QMouseEvent *event);
128 
130  bool handleMouseMoveEvent(QMouseEvent *event);
131 
133  bool handleChangeEvent(QEvent *event);
134 
136  void showMinimizedModeChecked();
137 
139  void showNormalModeChecked();
140 
142  static Qt::WindowFlags modeToWindowFlags(WindowMode mode);
143  };
144 } // namespace swift::gui
145 
146 #endif // SWIFT_GUI_ENABLEFORFRAMLESSWINDOW_H
Main window which can be frameless.
bool isMainApplicationWindow() const
Is main application, explicitly set.
QWidget * getWidget() const
Corresponding QMainWindow.
QPoint m_framelessDragPosition
position, if moving is handled with frameless window
QByteArray m_framelessPropertyName
property name for frameless widgets
CEnableForFramelessWindow & operator=(const CEnableForFramelessWindow &)=delete
Copy assignment operator.
QSize m_moveSize
size when moved (in frameless window)
CEnableForFramelessWindow(const CEnableForFramelessWindow &)=delete
Copy constructor.
GUI related classes.
#define SWIFT_GUI_EXPORT
Export a class or function from the library.