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) 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 "maintoolbarmodel.h"
24 :
25 : #include "translation.h"
26 :
27 : #include "project/notationpageinfo.h"
28 :
29 : using namespace mu::appshell;
30 : using namespace muse::uicomponents;
31 :
32 : static const QString HOME_PAGE("musescore://home");
33 : static const QString PUBLISH_PAGE("musescore://publish");
34 : static const QString DEVTOOLS_PAGE("musescore://devtools");
35 :
36 0 : MainToolBarModel::MainToolBarModel(QObject* parent)
37 0 : : PageTabsModel(parent), muse::Contextable(muse::iocCtxForQmlObject(this))
38 : {
39 0 : }
40 :
41 0 : MainToolBarModel::~MainToolBarModel() = default;
42 :
43 0 : void MainToolBarModel::load()
44 : {
45 0 : m_notationPage = std::make_unique<project::NotationPageInfo>(iocContext());
46 :
47 0 : QList<PageTab> tabs;
48 0 : tabs << PageTab { muse::qtrc("appshell", "Home"), HOME_PAGE };
49 :
50 0 : m_notationTabIndex = static_cast<int>(tabs.size());
51 0 : tabs << notationTab();
52 :
53 0 : tabs << PageTab { muse::qtrc("appshell", "Publish"), PUBLISH_PAGE };
54 :
55 0 : if (globalConfiguration()->devModeEnabled()) {
56 0 : tabs << PageTab { muse::qtrc("appshell", "DevTools"), DEVTOOLS_PAGE };
57 : }
58 :
59 0 : setTabs(tabs);
60 :
61 0 : m_notationPage->changed().onNotify(this, [this]() {
62 0 : setTab(m_notationTabIndex, notationTab());
63 0 : });
64 0 : }
65 :
66 0 : PageTab MainToolBarModel::notationTab() const
67 : {
68 0 : PageTab tab;
69 0 : tab.title = muse::qtrc("appshell", "Score");
70 0 : tab.uri = m_notationPage->uri();
71 0 : tab.alsoCheckedOnUris = project::NotationPageInfo::pageUris();
72 0 : tab.isTitleBold = m_notationPage->isProjectOpened();
73 :
74 0 : return tab;
75 0 : }
|