Line data Source code
1 : /*
2 : * SPDX-License-Identifier: GPL-3.0-only
3 : * MuseScore-Studio-CLA-applies
4 : *
5 : * MuseScore Studio
6 : * Music Composition & Notation
7 : *
8 : * Copyright (C) 2026 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 "propertiespanelpopupcontrollermodel.h"
24 :
25 : #include "uicomponents/qml/Muse/UiComponents/popupview.h"
26 :
27 : using namespace mu::propertiespanel;
28 : using namespace muse::uicomponents;
29 :
30 0 : PropertiesPanelPopupControllerModel::PropertiesPanelPopupControllerModel(QObject* parent)
31 0 : : QObject(parent), muse::Contextable(muse::iocCtxForQmlObject(this))
32 : {
33 0 : }
34 :
35 0 : void PropertiesPanelPopupControllerModel::classBegin()
36 : {
37 0 : init();
38 0 : }
39 :
40 0 : void PropertiesPanelPopupControllerModel::init()
41 : {
42 0 : popupController()->popupChanged().onNotify(this, [this]() {
43 0 : emit isAnyPopupOpenChanged();
44 0 : });
45 :
46 0 : popupController()->dropdownChanged().onNotify(this, [this]() {
47 0 : emit isAnyPopupOpenChanged();
48 0 : });
49 :
50 0 : popupController()->menuChanged().onNotify(this, [this]() {
51 0 : emit isAnyPopupOpenChanged();
52 0 : });
53 0 : }
54 :
55 0 : bool PropertiesPanelPopupControllerModel::isAnyPopupOpen() const
56 : {
57 0 : auto controller = popupController();
58 0 : return controller->popup() || controller->dropdown() || controller->menu();
59 0 : }
60 :
61 0 : void PropertiesPanelPopupControllerModel::setNotationView(const QQuickItem* view)
62 : {
63 0 : popupController()->setNotationView(view);
64 0 : }
65 :
66 0 : void PropertiesPanelPopupControllerModel::setPopup(PopupView* popup, QQuickItem* control)
67 : {
68 0 : popupController()->setPopup(popup, control);
69 0 : }
70 :
71 0 : void PropertiesPanelPopupControllerModel::setDropdown(DropdownView* dropdown)
72 : {
73 0 : popupController()->setDropdown(dropdown);
74 0 : }
75 :
76 0 : void PropertiesPanelPopupControllerModel::setMenu(MenuView* menu)
77 : {
78 0 : popupController()->setMenu(menu);
79 0 : }
80 :
81 0 : void PropertiesPanelPopupControllerModel::repositionPopupIfNeed()
82 : {
83 0 : if (popupController()->popup()) {
84 0 : popupController()->popup()->repositionWindowIfNeed();
85 : }
86 0 : }
|