Line data Source code
1 : /*
2 : * SPDX-License-Identifier: GPL-3.0-only
3 : * MuseScore-CLA-applies
4 : *
5 : * MuseScore Studio
6 : * Music Composition & Notation
7 : *
8 : * Copyright (C) 2021 MuseScore Limited and others
9 : *
10 : * This program is free software: you can redistribute it and/or modify
11 : * it under the terms of the GNU General Public License version 3 as
12 : * published by the Free Software Foundation.
13 : *
14 : * This program is distributed in the hope that it will be useful,
15 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 : * GNU General Public License for more details.
18 : *
19 : * You should have received a copy of the GNU General Public License
20 : * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 : */
22 :
23 : #include "mainwindow.h"
24 :
25 : #include <QWindow>
26 :
27 : #include "view/mainwindowbridge.h"
28 : #include "async/notification.h"
29 :
30 : #include "log.h"
31 :
32 : using namespace muse::ui;
33 : using namespace muse::modularity;
34 :
35 0 : void MainWindow::init(MainWindowBridge* bridge)
36 : {
37 0 : IF_ASSERT_FAILED(!m_bridge) {
38 0 : LOGW() << "MainWindowBridge is already set. Refusing to set it again.";
39 0 : return;
40 : }
41 :
42 0 : m_bridge = bridge;
43 :
44 0 : m_bridge->isFullScreenChanged().onNotify(this, [this]() {
45 0 : m_isFullScreenChanged.notify();
46 0 : });
47 : }
48 :
49 0 : void MainWindow::deinit()
50 : {
51 0 : m_bridge = nullptr;
52 0 : }
53 :
54 0 : QWindow* MainWindow::qWindow() const
55 : {
56 0 : return m_bridge ? m_bridge->qWindow() : nullptr;
57 : }
58 :
59 0 : void MainWindow::requestShowOnBack()
60 : {
61 0 : if (!m_bridge) {
62 0 : return;
63 : }
64 :
65 0 : m_bridge->showOnBack();
66 : }
67 :
68 0 : void MainWindow::requestShowOnFront()
69 : {
70 0 : if (!m_bridge) {
71 0 : return;
72 : }
73 :
74 0 : m_bridge->showOnFront();
75 : }
76 :
77 0 : bool MainWindow::isFullScreen() const
78 : {
79 0 : return m_bridge ? m_bridge->isFullScreen() : false;
80 : }
81 :
82 0 : muse::async::Notification MainWindow::isFullScreenChanged() const
83 : {
84 0 : return m_isFullScreenChanged;
85 : }
86 :
87 0 : void MainWindow::toggleFullScreen()
88 : {
89 0 : if (!m_bridge) {
90 0 : return;
91 : }
92 :
93 0 : m_bridge->toggleFullScreen();
94 : }
95 :
96 0 : QScreen* MainWindow::screen() const
97 : {
98 0 : return m_bridge ? m_bridge->screen() : nullptr;
99 : }
|