Skip to content

Commit

Permalink
added show graphics info to diagnostics
Browse files Browse the repository at this point in the history
  • Loading branch information
igorkorsukov committed Sep 10, 2024
1 parent 0755eaa commit 8e678be
Show file tree
Hide file tree
Showing 10 changed files with 234 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/appshell/view/appmenumodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ MenuItem* AppMenuModel::makeDiagnosticMenu()
{
MenuItemList systemItems {
makeMenuItem("diagnostic-show-paths"),
makeMenuItem("diagnostic-show-graphicsinfo"),
makeMenuItem("diagnostic-show-profiler"),
};

Expand Down
2 changes: 2 additions & 0 deletions src/framework/diagnostics/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ set(MODULE_SRC

${CMAKE_CURRENT_LIST_DIR}/view/system/profilerviewmodel.cpp
${CMAKE_CURRENT_LIST_DIR}/view/system/profilerviewmodel.h
${CMAKE_CURRENT_LIST_DIR}/view/system/graphicsinfomodel.cpp
${CMAKE_CURRENT_LIST_DIR}/view/system/graphicsinfomodel.h

${CMAKE_CURRENT_LIST_DIR}/view/keynav/diagnosticnavigationmodel.cpp
${CMAKE_CURRENT_LIST_DIR}/view/keynav/diagnosticnavigationmodel.h
Expand Down
2 changes: 2 additions & 0 deletions src/framework/diagnostics/diagnostics.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@
<file>qml/Muse/Diagnostics/DiagnosticAccessiblePanel.qml</file>
<file>qml/Muse/Diagnostics/DiagnosticProfilerDialog.qml</file>
<file>qml/Muse/Diagnostics/DiagnosticProfilerPanel.qml</file>
<file>qml/Muse/Diagnostics/DiagnosticGraphicsInfoDialog.qml</file>
<file>qml/Muse/Diagnostics/DiagnosticGraphicsInfoPanel.qml</file>
</qresource>
</RCC>
3 changes: 3 additions & 0 deletions src/framework/diagnostics/diagnosticsmodule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@

#include "view/diagnosticspathsmodel.h"
#include "view/system/profilerviewmodel.h"
#include "view/system/graphicsinfomodel.h"

#include "view/keynav/diagnosticnavigationmodel.h"
#include "view/keynav/abstractkeynavdevitem.h"
Expand Down Expand Up @@ -82,6 +83,7 @@ void DiagnosticsModule::resolveImports()
auto ir = ioc()->resolve<muse::ui::IInteractiveUriRegister>(moduleName());
if (ir) {
ir->registerQmlUri(Uri("muse://diagnostics/system/paths"), "Muse/Diagnostics/DiagnosticPathsDialog.qml");
ir->registerQmlUri(Uri("muse://diagnostics/system/graphicsinfo"), "Muse/Diagnostics/DiagnosticGraphicsInfoDialog.qml");
ir->registerQmlUri(Uri("muse://diagnostics/system/profiler"), "Muse/Diagnostics/DiagnosticProfilerDialog.qml");
ir->registerQmlUri(Uri("muse://diagnostics/navigation/tree"), "Muse/Diagnostics/DiagnosticNavigationDialog.qml");
ir->registerQmlUri(Uri("muse://diagnostics/accessible/tree"), "Muse/Diagnostics/DiagnosticAccessibleDialog.qml");
Expand All @@ -102,6 +104,7 @@ void DiagnosticsModule::registerUiTypes()
{
qmlRegisterType<DiagnosticsPathsModel>("Muse.Diagnostics", 1, 0, "DiagnosticsPathsModel");
qmlRegisterType<ProfilerViewModel>("Muse.Diagnostics", 1, 0, "ProfilerViewModel");
qmlRegisterType<GraphicsInfoModel>("Muse.Diagnostics", 1, 0, "GraphicsInfoModel");

qmlRegisterType<DiagnosticNavigationModel>("Muse.Diagnostics", 1, 0, "DiagnosticNavigationModel");
qmlRegisterUncreatableType<AbstractKeyNavDevItem>("Muse.Diagnostics", 1, 0, "AbstractKeyNavDevItem", "Cannot create a Abstract");
Expand Down
5 changes: 5 additions & 0 deletions src/framework/diagnostics/internal/diagnosticsactions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ const UiActionList DiagnosticsActions::m_actions = {
muse::shortcuts::CTX_ANY,
TranslatableString("action", "Show pr&ofiler…")
),
UiAction("diagnostic-show-graphicsinfo",
muse::ui::UiCtxAny,
muse::shortcuts::CTX_ANY,
TranslatableString("action", "Show g&raphics info…")
),
UiAction("diagnostic-show-navigation-tree",
muse::ui::UiCtxAny,
muse::shortcuts::CTX_ANY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ using namespace muse;
using namespace muse::accessibility;

static const muse::UriQuery SYSTEM_PATHS_URI("muse://diagnostics/system/paths?sync=false&modal=false&floating=true");
static const muse::UriQuery GRAPHICSINFO_URI("muse://diagnostics/system/graphicsinfo?sync=false&modal=false&floating=true");
static const muse::UriQuery PROFILER_URI("muse://diagnostics/system/profiler?sync=false&modal=false&floating=true");
static const muse::UriQuery NAVIGATION_TREE_URI("muse://diagnostics/navigation/tree?sync=false&modal=false&floating=true");
static const muse::UriQuery ACCESSIBLE_TREE_URI("muse://diagnostics/accessible/tree?sync=false&modal=false&floating=true");
Expand All @@ -40,6 +41,7 @@ static const muse::UriQuery ENGRAVING_ELEMENTS_URI("muse://diagnostics/engraving
void DiagnosticsActionsController::init()
{
dispatcher()->reg(this, "diagnostic-show-paths", [this]() { openUri(SYSTEM_PATHS_URI); });
dispatcher()->reg(this, "diagnostic-show-graphicsinfo", [this]() { openUri(GRAPHICSINFO_URI); });
dispatcher()->reg(this, "diagnostic-show-profiler", [this]() { openUri(PROFILER_URI); });
dispatcher()->reg(this, "diagnostic-show-navigation-tree", [this]() { openUri(NAVIGATION_TREE_URI); });
dispatcher()->reg(this, "diagnostic-show-accessible-tree", [this]() { openUri(ACCESSIBLE_TREE_URI); });
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* 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 Muse.Ui 1.0
import Muse.UiComponents 1.0

StyledDialogView {
id: root

title: "Diagnostic: Graphics Info"

contentHeight: 480
contentWidth: 600
resizable: true

DiagnosticGraphicsInfoPanel {
anchors.fill: parent
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
* 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 Muse.Ui 1.0
import Muse.UiComponents 1.0
import Muse.Diagnostics 1.0

Rectangle {

anchors.fill: parent

color: ui.theme.backgroundPrimaryColor

Component.onCompleted: {
graphicsInfo.init()
}

GraphicsInfoModel {
id: graphicsInfo
}

Item {
id: toolPanel
anchors.left: parent.left
anchors.right: parent.right
anchors.margins: 16
height: 48

Row {
id: btnRow
anchors.fill: parent
spacing: 8

FlatButton {
anchors.verticalCenter: parent.verticalCenter
text: "Copy to clipboard"
onClicked: graphicsInfo.copyToClipboard()
}
}
}

StyledTextLabel {
anchors.top: toolPanel.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
anchors.margins: 16
verticalAlignment: Text.AlignTop
horizontalAlignment: Text.AlignLeft
text: graphicsInfo.info
}

}
56 changes: 56 additions & 0 deletions src/framework/diagnostics/view/system/graphicsinfomodel.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* SPDX-License-Identifier: GPL-3.0-only
* MuseScore-CLA-applies
*
* MuseScore
* Music Composition & Notation
*
* Copyright (C) 2024 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 "graphicsinfomodel.h"

#include <QClipboard>

#include "ui/graphicsapiprovider.h"

using namespace muse::diagnostics;

GraphicsInfoModel::GraphicsInfoModel()
{
}

void GraphicsInfoModel::init()
{
if (!uiengine()) {
return;
}

QString gApi = uiengine()->graphicsApiName();

m_info = "\n";
m_info += "Graphics Api: " + gApi;

emit infoChanged();
}

void GraphicsInfoModel::copyToClipboard()
{
QApplication::clipboard()->setText(m_info);
}

QString GraphicsInfoModel::info() const
{
return m_info;
}
52 changes: 52 additions & 0 deletions src/framework/diagnostics/view/system/graphicsinfomodel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* SPDX-License-Identifier: GPL-3.0-only
* MuseScore-CLA-applies
*
* MuseScore
* Music Composition & Notation
*
* Copyright (C) 2024 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/>.
*/
#pragma once

#include <QObject>

#include "modularity/ioc.h"
#include "ui/iuiengine.h"

namespace muse::diagnostics {
class GraphicsInfoModel : public QObject
{
Q_OBJECT

Q_PROPERTY(QString info READ info NOTIFY infoChanged FINAL)

muse::Inject<ui::IUiEngine> uiengine;

public:
GraphicsInfoModel();

QString info() const;

Q_INVOKABLE void init();
Q_INVOKABLE void copyToClipboard();

signals:
void infoChanged();

private:
QString m_info;
};
}

0 comments on commit 8e678be

Please sign in to comment.