Add braille options to Preferences

This commit is contained in:
TuanLa1972 2023-06-13 03:17:27 +01:00 committed by Peter Jonas
parent 886995e13c
commit c8fd7bd567
9 changed files with 315 additions and 1 deletions

View file

@ -89,6 +89,8 @@ set(MODULE_SRC
${CMAKE_CURRENT_LIST_DIR}/view/preferences/iopreferencesmodel.h
${CMAKE_CURRENT_LIST_DIR}/view/preferences/commonaudioapiconfigurationmodel.cpp
${CMAKE_CURRENT_LIST_DIR}/view/preferences/commonaudioapiconfigurationmodel.h
${CMAKE_CURRENT_LIST_DIR}/view/preferences/braillepreferencesmodel.cpp
${CMAKE_CURRENT_LIST_DIR}/view/preferences/braillepreferencesmodel.h
${CMAKE_CURRENT_LIST_DIR}/view/framelesswindow/framelesswindowmodel.cpp
${CMAKE_CURRENT_LIST_DIR}/view/framelesswindow/framelesswindowmodel.h
${CMAKE_CURRENT_LIST_DIR}/view/publish/publishtoolbarmodel.cpp

View file

@ -106,5 +106,8 @@
<file>qml/platform/AppButtonBackground.qml</file>
<file>qml/platform/PlatformMenuBar.qml</file>
<file>resources/LoadingScreen.svg</file>
<file>qml/Preferences/BraillePreferencesPage.qml</file>
<file>qml/Preferences/internal/BrailleSection.qml</file>
<file>qml/Preferences/internal/BrailleTableSection.qml</file>
</qresource>
</RCC>

View file

@ -56,6 +56,7 @@
#include "view/preferences/importpreferencesmodel.h"
#include "view/preferences/iopreferencesmodel.h"
#include "view/preferences/commonaudioapiconfigurationmodel.h"
#include "view/preferences/braillepreferencesmodel.h"
#include "view/framelesswindow/framelesswindowmodel.h"
#include "view/publish/publishtoolbarmodel.h"
#include "view/windowdroparea.h"
@ -161,6 +162,7 @@ void AppShellModule::registerUiTypes()
qmlRegisterType<ImportPreferencesModel>("MuseScore.Preferences", 1, 0, "ImportPreferencesModel");
qmlRegisterType<IOPreferencesModel>("MuseScore.Preferences", 1, 0, "IOPreferencesModel");
qmlRegisterType<CommonAudioApiConfigurationModel>("MuseScore.Preferences", 1, 0, "CommonAudioApiConfigurationModel");
qmlRegisterType<BraillePreferencesModel>("MuseScore.Preferences", 1, 0, "BraillePreferencesModel");
#if defined(Q_OS_MACOS)
qmlRegisterType<AppMenuModel>("MuseScore.AppShell", 1, 0, "PlatformAppMenuModel");

View file

@ -0,0 +1,76 @@
/*
* SPDX-License-Identifier: GPL-3.0-only
* MuseScore-CLA-applies
*
* MuseScore
* Music Composition & Notation
*
* Copyright (C) 2021 MuseScore BVBA and others
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import QtQuick 2.15
import MuseScore.Ui 1.0
import MuseScore.UiComponents 1.0
import MuseScore.Preferences 1.0
import "internal"
PreferencesPage {
id: root
BraillePreferencesModel {
id: preferencesModel
}
Column {
width: parent.width
spacing: root.sectionsSpacing
BrailleSection {
braillePanelEnabled: preferencesModel.braillePanelEnabled
navigation.section: root.navigationSection
navigation.order: root.navigationOrderStart + 1
onBraillePanelEnabledChangeRequested: function(val) {
preferencesModel.braillePanelEnabled = val
brailleTable.enabled = val;
}
}
SeparatorLine { }
BrailleTableSection {
id: brailleTable
tables: preferencesModel.tables()
brailleTable: preferencesModel.brailleTable
navigation.section: root.navigationSection
navigation.order: root.navigationOrderStart + 2
enabled: preferencesModel.braillePanelEnabled
onBrailleTableChangeRequested: function(table) {
preferencesModel.brailleTable = table
}
onFocusChanged: {
if (activeFocus) {
root.ensureContentVisibleRequested(Qt.rect(x, y, width, height))
}
}
}
}
}

View file

@ -0,0 +1,50 @@
/*
* SPDX-License-Identifier: GPL-3.0-only
* MuseScore-CLA-applies
*
* MuseScore
* Music Composition & Notation
*
* Copyright (C) 2021 MuseScore BVBA and others
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import QtQuick 2.15
import QtQuick.Layouts 1.15
import MuseScore.Ui 1.0
import MuseScore.UiComponents 1.0
BaseSection {
id: root
title: qsTrc("appshell/preferences", "Enable/disable")
property alias braillePanelEnabled: brailleBox.checked
signal braillePanelEnabledChangeRequested(bool enabled)
CheckBox {
id: brailleBox
width: parent.width
text: qsTrc("appshell/preferences", "Show braille panel")
navigation.name: "BrailleBox"
navigation.panel: root.navigation
navigation.row: 0
onClicked: {
root.braillePanelEnabledChangeRequested(!checked)
}
}
}

View file

@ -0,0 +1,51 @@
/*
* SPDX-License-Identifier: GPL-3.0-only
* MuseScore-CLA-applies
*
* MuseScore
* Music Composition & Notation
*
* Copyright (C) 2021 MuseScore BVBA and others
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import QtQuick 2.15
import MuseScore.UiComponents 1.0
BaseSection {
id: root
title: qsTrc("appshell/preferences", "Advanced options")
property var tables: null
property string brailleTable: ""
signal brailleTableChangeRequested(string table)
ComboBoxWithTitle {
title: qsTrc("appshell/preferences", "Braille table for lyrics:")
columnWidth: root.columnWidth
currentIndex: control.indexOfValue(root.brailleTable)
model: root.tables
navigation.name: "BrailleTableBox"
navigation.panel: root.navigation
navigation.row: 1
onValueEdited: function(newIndex, newValue) {
root.brailleTableChangeRequested(newValue)
}
}
}

View file

@ -0,0 +1,67 @@
/*
* SPDX-License-Identifier: GPL-3.0-only
* MuseScore-CLA-applies
*
* MuseScore
* Music Composition & Notation
*
* Copyright (C) 2023 MuseScore BVBA and others
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "braillepreferencesmodel.h"
#include "log.h"
using namespace mu::appshell;
BraillePreferencesModel::BraillePreferencesModel(QObject* parent)
: QObject(parent)
{
}
bool BraillePreferencesModel::braillePanelEnabled() const
{
return brailleConfiguration()->braillePanelEnabled();
}
void BraillePreferencesModel::setBraillePanelEnabled(bool value)
{
if (value == braillePanelEnabled()) {
return;
}
brailleConfiguration()->setBraillePanelEnabled(value);
emit braillePanelEnabledChanged(value);
}
QString BraillePreferencesModel::brailleTable() const
{
return brailleConfiguration()->brailleTable();
}
void BraillePreferencesModel::setBrailleTable(QString table)
{
if (table == brailleTable()) {
return;
}
brailleConfiguration()->setBrailleTable(table);
emit brailleTableChanged(table);
}
QStringList BraillePreferencesModel::tables() const
{
return brailleConfiguration()->brailleTableList();
}

View file

@ -0,0 +1,60 @@
/*
* SPDX-License-Identifier: GPL-3.0-only
* MuseScore-CLA-applies
*
* MuseScore
* Music Composition & Notation
*
* Copyright (C) 2023 MuseScore BVBA and others
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef MU_APPSHELL_BRAILLEPREFERENCESMODEL_H
#define MU_APPSHELL_BRAILLEPREFERENCESMODEL_H
#include <QObject>
#include "modularity/ioc.h"
#include "braille/ibrailleconfiguration.h"
namespace mu::appshell {
class BraillePreferencesModel : public QObject
{
Q_OBJECT
INJECT(braille::IBrailleConfiguration, brailleConfiguration)
Q_PROPERTY(
bool braillePanelEnabled READ braillePanelEnabled WRITE setBraillePanelEnabled NOTIFY braillePanelEnabledChanged)
Q_PROPERTY(
QString brailleTable READ brailleTable WRITE setBrailleTable NOTIFY brailleTableChanged)
public:
explicit BraillePreferencesModel(QObject* parent = nullptr);
Q_INVOKABLE QStringList tables() const;
bool braillePanelEnabled() const;
QString brailleTable() const;
public slots:
void setBraillePanelEnabled(bool value);
void setBrailleTable(QString table);
signals:
void braillePanelEnabledChanged(bool value);
void brailleTableChanged(QString value);
};
}
#endif // MU_APPSHELL_BRAILLEPREFERENCESMODEL_H

View file

@ -189,7 +189,10 @@ void PreferencesModel::load(const QString& currentPageId)
"Preferences/UpdatePreferencesPage.qml"),
makeItem("advanced", QT_TRANSLATE_NOOP("appshell/preferences", "Advanced"), IconCode::Code::CONFIGURE,
"Preferences/AdvancedPreferencesPage.qml")
"Preferences/AdvancedPreferencesPage.qml"),
makeItem("braille", QT_TRANSLATE_NOOP("appshell/preferences", "Braille"), IconCode::Code::VISIBILITY_OFF,
"Preferences/BraillePreferencesPage.qml")
};
for (PreferencePageItem* item: items) {