Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/appshell/qml/MuseScore/AppShell/aboutmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@
* 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 "aboutmodel.h"

#include "translation.h"
#include "aboutmodel.h"

#include <QApplication>
#include <QClipboard>
#include <QGuiApplication>
#include <QUrl>

#include "translation.h"

using namespace mu::appshell;

AboutModel::AboutModel(QObject* parent)
Expand Down Expand Up @@ -85,7 +86,7 @@ QVariantMap AboutModel::musicXMLLicenseDeedUrl() const

void AboutModel::copyRevisionToClipboard() const
{
QApplication::clipboard()->setText(
QGuiApplication::clipboard()->setText(
QString("OS: %1, Arch.: %2, MuseScore Studio version (%3-bit): %4-%5, revision: github-musescore-musescore-%6")
.arg(QSysInfo::prettyProductName()
+ ((QSysInfo::productType() == "windows" && (QSysInfo::productVersion() == "10" || QSysInfo::productVersion() == "11"))
Expand Down
7 changes: 7 additions & 0 deletions src/engraving/api/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,20 @@
set(MODULE_TEST engraving_api_tests)

set(MODULE_TEST_SRC
${PROJECT_SOURCE_DIR}/src/engraving/tests/utils/scorerw.cpp
${PROJECT_SOURCE_DIR}/src/engraving/tests/utils/scorerw.h

${CMAKE_CURRENT_LIST_DIR}/environment.cpp
${CMAKE_CURRENT_LIST_DIR}/util_tests.cpp
${CMAKE_CURRENT_LIST_DIR}/score_tests.cpp
${CMAKE_CURRENT_LIST_DIR}/spanner_tests.cpp
)

set(MODULE_TEST_LINK
Qt::Qml
engraving
)

set(MODULE_TEST_DATA_ROOT ${CMAKE_CURRENT_LIST_DIR})

include(SetupGTest)
4 changes: 4 additions & 0 deletions src/engraving/api/tests/environment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
#include "engraving/dom/instrtemplate.h"
#include "engraving/dom/mscore.h"

#include "engraving/tests/utils/scorerw.h"

#include "log.h"

static muse::testing::SuiteEnvironment engraving_api_se(
Expand All @@ -39,6 +41,8 @@ static muse::testing::SuiteEnvironment engraving_api_se(
[]() {
LOGI() << "engraving API tests suite post init";

mu::engraving::ScoreRW::setRootPath(muse::String::fromUtf8(engraving_api_tests_DATA_ROOT));

mu::engraving::MScore::testMode = true;
mu::engraving::MScore::noGui = true;

Expand Down
76 changes: 76 additions & 0 deletions src/engraving/api/tests/spanner_tests.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
* SPDX-License-Identifier: GPL-3.0-only
* MuseScore-Studio-CLA-applies
*
* MuseScore Studio
* Music Composition & Notation
*
* Copyright (C) 2026 MuseScore Limited 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 <QtCore/qtypes.h>
#include <gtest/gtest.h>

#include "engraving/api/v1/score.h"
#include "engraving/api/v1/elements.h"

#include "engraving/tests/utils/scorerw.h"

using namespace muse;
using namespace mu::engraving;

static const String SPANNERS_DATA_DIR("../../tests/spanners_data/");

/// Test Plugin API score.spanners property
/// Verify that score.spanners exposes all spanners in the score
TEST(Engraving_ApiSpannerTests, scoreSpanners)
{
// Load a score file
MasterScore* score = ScoreRW::readScore(SPANNERS_DATA_DIR + u"glissando01.mscx");
ASSERT_TRUE(score);

// Create Plugin API wrapper for the score
apiv1::Score apiScore(score);

// Get spanners using Plugin API
QQmlListProperty<apiv1::Spanner> scoreSpanners = apiScore.spanners();

// Basic sanity checks: the property should return a valid list
EXPECT_NE(scoreSpanners.count, nullptr);
EXPECT_NE(scoreSpanners.at, nullptr);

qsizetype spannerCount = scoreSpanners.count(&scoreSpanners);
EXPECT_GE(spannerCount, 0) << "Count should be non-negative";

// Get spanners directly from the score for comparison
auto domSpanners = score->spannerList();

// The Plugin API should expose the same number of spanners
EXPECT_EQ(spannerCount, (qsizetype)domSpanners.size())
<< "Plugin API should expose all spanners from the score";

// Verify each spanner can be accessed and has valid properties
for (int i = 0; i < spannerCount; i++) {
auto* item = scoreSpanners.at(&scoreSpanners, i);
apiv1::Spanner* apiItem = qobject_cast<apiv1::Spanner*>(item);
ASSERT_TRUE(apiItem) << "Spanner " << i << " should be a valid Spanner API object";
ASSERT_TRUE(apiItem->spanner()) << "Spanner " << i << " should have a valid underlying Spanner";

track_idx_t track = apiItem->spanner()->track();
EXPECT_LT(track, score->ntracks()) << "Spanner " << i << "'s underlying Spanner should not be garbage";
}

delete score;
}
51 changes: 0 additions & 51 deletions src/engraving/tests/spanners_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@
#include "engraving/editing/transaction/transaction.h"
#include "engraving/editing/transaction/undostack.h"

#include "engraving/api/v1/score.h"
#include "engraving/api/v1/elements.h"

#include "utils/scorerw.h"
#include "utils/scorecomp.h"

Expand Down Expand Up @@ -600,51 +597,3 @@ TEST_F(Engraving_SpannersTests, spanners16)
EXPECT_TRUE(ScoreComp::saveCompareScore(score, u"smallstaff01.mscx", SPANNERS_DATA_DIR + u"smallstaff01-ref.mscx"));
delete score;
}

//---------------------------------------------------------
/// spanners17
/// Test Plugin API score.spanners property
/// Verify that score.spanners exposes all spanners in the score
//---------------------------------------------------------

TEST_F(Engraving_SpannersTests, spanners17_pluginAPI_scoreSpanners)
{
// Load a score file
MasterScore* score = ScoreRW::readScore(SPANNERS_DATA_DIR + u"glissando01.mscx");
EXPECT_TRUE(score);

// Create Plugin API wrapper for the score
apiv1::Score apiScore(score);

// Get spanners using Plugin API
QQmlListProperty<apiv1::Spanner> scoreSpanners = apiScore.spanners();

// Basic sanity checks: the property should return a valid list
EXPECT_NE(scoreSpanners.count, nullptr);
EXPECT_NE(scoreSpanners.at, nullptr);

int spannerCount = scoreSpanners.count(&scoreSpanners);
EXPECT_GE(spannerCount, 0) << "Count should be non-negative";

// Get spanners directly from the score for comparison
auto domSpanners = score->spannerList();

// The Plugin API should expose the same number of spanners
EXPECT_EQ(spannerCount, (int)domSpanners.size())
<< "Plugin API should expose all spanners from the score";

// Verify each spanner can be accessed and has valid properties
for (int i = 0; i < spannerCount; i++) {
auto* item = scoreSpanners.at(&scoreSpanners, i);
apiv1::Spanner* apiItem = qobject_cast<apiv1::Spanner*>(item);
EXPECT_TRUE(apiItem != nullptr) << "Spanner " << i << " should be a valid Spanner";

if (apiItem && apiItem->spanner()) {
// Verify we can access the track property (spanners have tracks)
track_idx_t track = apiItem->spanner()->track();
EXPECT_GE(track, 0) << "Spanner " << i << " should have a valid track";
}
}

delete score;
}
1 change: 1 addition & 0 deletions src/notation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ if(NOT OS_IS_WASM)
endif()

target_link_libraries(notation PRIVATE
Qt::Widgets # for QApplication::cursorFlashTime() in notationinteraction.cpp
muse::draw
engraving
)
Expand Down
22 changes: 12 additions & 10 deletions src/notation/internal/notationinteraction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,18 @@

#include <memory>
#include <limits>
#include <QRectF>
#include <QPainter>

#include <QApplication> // for QApplication::cursorFlashTime()
#include <QClipboard>
#include <QApplication>
#include <QDrag>
#include <QEventLoop>
#include <QGuiApplication>
#include <QKeyEvent>
#include <QMimeData>
#include <QDrag>
#include <QPainter>
#include <QRectF>
#include <QRegularExpression>
#include <QRegularExpressionMatch>
#include <QEventLoop>

#include "defer.h"
#include "ptrutils.h"
Expand Down Expand Up @@ -5391,7 +5393,7 @@ void NotationInteraction::copySelection()
if (!mimeData) {
return;
}
QApplication::clipboard()->setMimeData(mimeData);
QGuiApplication::clipboard()->setMimeData(mimeData);
}
}

Expand Down Expand Up @@ -5494,7 +5496,7 @@ void NotationInteraction::repeatSelection()
void NotationInteraction::copyLyrics()
{
QString text = score()->extractLyrics();
QApplication::clipboard()->setText(text);
QGuiApplication::clipboard()->setText(text);
}

void NotationInteraction::pasteSelection(const Fraction& scale)
Expand All @@ -5505,7 +5507,7 @@ void NotationInteraction::pasteSelection(const Fraction& scale)
if (isTextEditingStarted()) {
pasteIntoTextEdit();
} else {
const QMimeData* mimeData = QApplication::clipboard()->mimeData();
const QMimeData* mimeData = QGuiApplication::clipboard()->mimeData();
QMimeDataAdapter ma(mimeData);
succeeded = Paste::paste(score()->transactionManager()->currentOrDummyTransaction(), score(), &ma, nullptr, scale);
m_editData.element = nullptr;
Expand All @@ -5525,7 +5527,7 @@ void NotationInteraction::pasteSelection(const Fraction& scale)

void NotationInteraction::pasteIntoTextEdit()
{
const QMimeData* mimeData = QApplication::clipboard()->mimeData();
const QMimeData* mimeData = QGuiApplication::clipboard()->mimeData();
if (mimeData->hasFormat(TextEditData::mimeRichTextFormat)) {
const QString txt = QString::fromUtf8(mimeData->data(TextEditData::mimeRichTextFormat));
toTextBase(m_editData.element)->paste(txt);
Expand Down Expand Up @@ -5574,7 +5576,7 @@ void NotationInteraction::swapSelection()
// Save old selection to clipboard...
QMimeData* mimeData = new QMimeData();
mimeData->setData(selection.mimeType(), oldSelection);
QApplication::clipboard()->setMimeData(mimeData);
QGuiApplication::clipboard()->setMimeData(mimeData);
}

void NotationInteraction::deleteSelection()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ target_include_directories(notationscene_qml PRIVATE
)

target_link_libraries(notationscene_qml PRIVATE
Qt::Widgets # for QApplication
muse::uicomponents_qml
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ set(MODULE_TEST_SRC
)

set(MODULE_TEST_LINK
Qt::Quick
engraving
notationscene_qml
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
* 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 <QApplication>

#include <QGuiApplication>

#include "preferencesmodel.h"

Expand Down Expand Up @@ -233,15 +234,15 @@ void PreferencesModel::askForConfirmationOfPreferencesReset()
void PreferencesModel::resetFactorySettings()
{
static constexpr bool KEEP_DEFAULT_SETTINGS = true;
QApplication::setOverrideCursor(Qt::WaitCursor);
QApplication::processEvents();
QGuiApplication::setOverrideCursor(Qt::WaitCursor);
QGuiApplication::processEvents();
configuration()->revertToFactorySettings(KEEP_DEFAULT_SETTINGS);

// Unreset the "First Launch Completed" setting so the first-time launch wizard does not appear.
configuration()->setHasCompletedFirstLaunchSetup(true);

configuration()->startEditSettings();
QApplication::restoreOverrideCursor();
QGuiApplication::restoreOverrideCursor();
}

void PreferencesModel::apply()
Expand Down
Loading