Skip to content

Commit

Permalink
added ignore reset navigation by mouse press for diagnostic
Browse files Browse the repository at this point in the history
  • Loading branch information
igorkorsukov committed Aug 25, 2021
1 parent e36e8c6 commit 5a3cf8f
Show file tree
Hide file tree
Showing 14 changed files with 122 additions and 4 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ option(BUILD_INSTRUMENTSSCENE_MODULE "Build instruments scene module" ON)
option(BUILD_INSPECTOR_MODULE "Build inspector module" ON)
option(BUILD_AUTOBOT_MODULE "Build autobot module" OFF)
option(BUILD_MULTIINSTANCES_MODULE "Build multiinstances module" ON)
option(BUILD_DIAGNOSTICS "Build diagnostic code" ON)
set(YOUTUBE_API_KEY "" CACHE STRING "YouTube API key")

option(ENGRAVING_BUILD_ACCESSIBLE_TREE "Build score accessible tree" OFF)
Expand Down
1 change: 1 addition & 0 deletions build/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
#cmakedefine BUILD_AUTOBOT_MODULE
#cmakedefine BUILD_MULTIINSTANCES_MODULE
#cmakedefine BUILD_VST
#cmakedefine BUILD_DIAGNOSTICS

#cmakedefine ENGRAVING_BUILD_ACCESSIBLE_TREE
#cmakedefine ENGRAVING_COMPAT_WRITESTYLE_302
Expand Down
3 changes: 3 additions & 0 deletions src/appshell/view/appmenumodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "translation.h"

#include "log.h"
#include "config.h"

using namespace mu::appshell;
using namespace mu::ui;
Expand Down Expand Up @@ -55,7 +56,9 @@ void AppMenuModel::load()
formatItem(),
toolsItem(),
helpItem(),
#ifdef BUILD_DIAGNOSTICS
diagnosticItem()
#endif
};

setItems(items);
Expand Down
1 change: 1 addition & 0 deletions src/diagnostics/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ set(MODULE_SRC
${CMAKE_CURRENT_LIST_DIR}/diagnosticsmodule.cpp
${CMAKE_CURRENT_LIST_DIR}/diagnosticsmodule.h
${CMAKE_CURRENT_LIST_DIR}/idiagnosticspathsregister.h
${CMAKE_CURRENT_LIST_DIR}/diagnosticscheck.h

${CMAKE_CURRENT_LIST_DIR}/internal/diagnosticsactions.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/diagnosticsactions.h
Expand Down
85 changes: 85 additions & 0 deletions src/diagnostics/diagnosticscheck.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*
* 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/>.
*/
#ifndef MU_DIAGNOSTICS_DIAGNOSTICSCHECK_H
#define MU_DIAGNOSTICS_DIAGNOSTICSCHECK_H

#include <QObject>

#include "log.h"

namespace mu::diagnostics {
inline bool isDiagnosticObject(const QObject* obj, bool print = false)
{
if (print) {
LOGI() << "objectName: " << obj->objectName() << ", className: " << obj->metaObject()->className();
}
if (obj->objectName().toLower().contains("diagnostic")) {
return true;
}
return false;
}

inline bool isDiagnosticChild(const QObject* obj, bool print = false)
{
for (const QObject* ch : obj->children()) {
if (isDiagnosticObject(ch, print)) {
return true;
}

if (isDiagnosticChild(ch, print)) {
return true;
}
}

return false;
}

inline bool isDiagnosticParent(const QObject* obj, bool print = false)
{
QObject* prn = obj->parent();
if (!prn) {
return false;
}

if (isDiagnosticObject(prn, print)) {
return true;
}

return isDiagnosticParent(prn, print);
}

inline bool isDiagnosticHierarchy(const QObject* obj, bool print = false)
{
if (isDiagnosticObject(obj, print)) {
return true;
}
if (isDiagnosticParent(obj, print)) {
return true;
}
if (isDiagnosticChild(obj, print)) {
return true;
}
return false;
}
}

#endif // MU_DIAGNOSTICS_DIAGNOSTICSCHECK_H
2 changes: 1 addition & 1 deletion src/diagnostics/diagnosticsmodule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void DiagnosticsModule::resolveImports()
auto ir = ioc()->resolve<ui::IInteractiveUriRegister>(moduleName());
if (ir) {
ir->registerQmlUri(Uri("musescore://diagnostics/system/paths"), "MuseScore/Diagnostics/DiagnosticPathsDialog.qml");
ir->registerQmlUri(Uri("musescore://diagnostics/navigation/controls"), "MuseScore/Diagnostics/DiagnosticNavigationDialog.qml");
ir->registerQmlUri(Uri("musescore://diagnostics/navigation/tree"), "MuseScore/Diagnostics/DiagnosticNavigationDialog.qml");
ir->registerQmlUri(Uri("musescore://diagnostics/accessible/tree"), "MuseScore/Diagnostics/DiagnosticAccessibleDialog.qml");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ StyledDialogView {
contentWidth: 600
resizable: true

//! NOTE It is necessary that it can be determined that this is an object for diagnostics
contentItem.objectName: panel.objectName

DiagnosticAccessiblePanel {
id: panel
anchors.fill: parent
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ Rectangle {

id: root

objectName: "DiagnosticAccessiblePanel"

color: ui.theme.backgroundPrimaryColor

Component.onCompleted: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,16 @@ import MuseScore.UiComponents 1.0
StyledDialogView {
id: root

title: "Diagnostic Navigation"
title: "Diagnostic: Navigation"

contentHeight: 900
contentWidth: 600

//! NOTE It is necessary that it can be determined that this is an object for diagnostics
contentItem.objectName: panel.objectName

DiagnosticNavigationPanel {
id: panel
anchors.fill: parent
anchors.margins: 8
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ Rectangle {

id: root

objectName: "DiagnosticNavigationPanel"

color: ui.theme.backgroundPrimaryColor

Component.onCompleted: {
Expand Down Expand Up @@ -68,6 +70,7 @@ Rectangle {

ListView {
id: view
objectName: "DiagnosticNavigationView"
anchors.top: tools.bottom
anchors.bottom: parent.bottom
anchors.left: parent.left
Expand Down Expand Up @@ -112,6 +115,7 @@ Rectangle {

ListView {
id: subView
objectName: "DiagnosticNavigationSubView"
anchors.top: secLabel.bottom
anchors.left: parent.left
anchors.right: parent.right
Expand Down Expand Up @@ -152,6 +156,7 @@ Rectangle {

GridView {
id: ctrlView
objectName: "DiagnosticNavigationGridView"
anchors.top: subLabel.bottom
anchors.left: parent.left
anchors.right: parent.right
Expand Down
5 changes: 5 additions & 0 deletions src/engraving/accessibility/accessiblescore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ QString AccessibleScore::accessibleName() const
return m_score->title();
}

QString AccessibleScore::accessibleDescription() const
{
return QString();
}

bool AccessibleScore::accessibleState(State st) const
{
switch (st) {
Expand Down
1 change: 1 addition & 0 deletions src/engraving/accessibility/accessiblescore.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class AccessibleScore : public accessibility::IAccessible
const IAccessible* accessibleChild(size_t i) const override;
Role accessibleRole() const override;
QString accessibleName() const override;
QString accessibleDescription() const override;
bool accessibleState(State st) const override;
QRect accessibleRect() const override;
mu::async::Channel<Property> accessiblePropertyChanged() const override;
Expand Down
4 changes: 2 additions & 2 deletions src/framework/ui/internal/interactiveuriregister.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ using namespace mu::ui;
void InteractiveUriRegister::registerUri(const Uri& uri, const ContainerMeta& meta)
{
IF_ASSERT_FAILED(!m_uriHash.contains(uri)) {
LOGW() << "URI" << uri.toString() << "already register. Will be rewrite";
LOGW() << "URI " << uri.toString() << " already register. Will be rewrite";
}

m_uriHash[uri] = meta;
Expand All @@ -37,7 +37,7 @@ void InteractiveUriRegister::registerUri(const Uri& uri, const ContainerMeta& me
ContainerMeta InteractiveUriRegister::meta(const Uri& uri) const
{
if (!m_uriHash.contains(uri)) {
LOGW() << "URI" << uri.toString() << "not registered";
LOGW() << "URI " << uri.toString() << " not registered";
return ContainerMeta();
}

Expand Down
6 changes: 6 additions & 0 deletions src/framework/ui/internal/navigationcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@
#include <limits>
#include <utility>

#include "diagnostics/diagnosticscheck.h"
#include "async/async.h"
#include "log.h"

#include "config.h"

//#define NAVIGATION_LOGGING_ENABLED

#ifdef NAVIGATION_LOGGING_ENABLED
Expand Down Expand Up @@ -323,6 +326,9 @@ const std::set<INavigationSection*>& NavigationController::sections() const
bool NavigationController::eventFilter(QObject* watched, QEvent* event)
{
if (event->type() == QEvent::MouseButtonPress) {
#ifdef BUILD_DIAGNOSTICS
if (!diagnostics::isDiagnosticHierarchy(watched, true))
#endif
resetActive();
}

Expand Down

0 comments on commit 5a3cf8f

Please sign in to comment.