* @brief Constructs a Window decorator. */
| 769 | * @brief Constructs a Window decorator. |
| 770 | */ |
| 771 | Window::Window(QWindow* window, const QString& color, bool shadow, QObject* parent) |
| 772 | : QObject(parent) |
| 773 | , m_resizing(false) |
| 774 | , m_shadowEnabled(shadow) |
| 775 | , m_frame(nullptr) |
| 776 | , m_border(nullptr) |
| 777 | , m_color(color) |
| 778 | , m_titleBar(nullptr) |
| 779 | , m_resizeEdge(ResizeEdge::None) |
| 780 | , m_minSize(0, 0) |
| 781 | , m_window(window) |
| 782 | , m_contentContainer(nullptr) |
| 783 | , m_lastCursor(Qt::ArrowCursor) |
| 784 | { |
| 785 | if (!m_window) |
| 786 | return; |
| 787 | |
| 788 | m_window->setFlags(m_window->flags() | Qt::FramelessWindowHint); |
| 789 | m_window->installEventFilter(this); |
| 790 | |
| 791 | setupFrame(); |
| 792 | setupContentContainer(); |
| 793 | setupTitleBar(); |
| 794 | setupBorder(); |
| 795 | |
| 796 | connect(m_window, &QWindow::windowStateChanged, this, [this]() { |
| 797 | if (!m_window) |
| 798 | return; |
| 799 | |
| 800 | const auto state = m_window->windowStates(); |
| 801 | const bool fillScreen = state & (Qt::WindowMaximized | Qt::WindowFullScreen); |
| 802 | |
| 803 | if (m_frame) |
| 804 | m_frame->setVisible(!fillScreen); |
| 805 | |
| 806 | if (m_border) |
| 807 | m_border->setVisible(!fillScreen); |
| 808 | |
| 809 | updateFrameGeometry(); |
| 810 | updateBorderGeometry(); |
| 811 | updateContentContainerGeometry(); |
| 812 | updateTitleBarGeometry(); |
| 813 | updateMinimumSize(); |
| 814 | |
| 815 | if (m_titleBar) |
| 816 | m_titleBar->update(); |
| 817 | }); |
| 818 | |
| 819 | connect(m_window, &QWindow::minimumWidthChanged, this, &Window::onMinimumSizeChanged); |
| 820 | connect(m_window, &QWindow::minimumHeightChanged, this, &Window::onMinimumSizeChanged); |
| 821 | |
| 822 | connect( |
| 823 | &Misc::ThemeManager::instance(), &Misc::ThemeManager::themeChanged, this, &Window::updateTheme); |
| 824 | updateTheme(); |
| 825 | updateMinimumSize(); |
| 826 | } |
| 827 | |
| 828 | /** |