Line data Source code
1 : /*
2 : * SPDX-License-Identifier: GPL-3.0-only
3 : * MuseScore-CLA-applies
4 : *
5 : * MuseScore Studio
6 : * Music Composition & Notation
7 : *
8 : * Copyright (C) 2026 MuseScore Limited and others
9 : *
10 : * This program is free software: you can redistribute it and it under the terms of the GNU General Public License version 3 as
11 : * published by the Free Software Foundation.
12 : *
13 : * This program is distributed in the hope that it will be useful,
14 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 : * GNU General Public License for more details.
17 : *
18 : * You should have received a copy of the GNU General Public License
19 : * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 : */
21 :
22 : #include "platforminteractive.h"
23 :
24 : #include <QDesktopServices>
25 :
26 : #ifdef Q_OS_MAC
27 : #include "platform/macos/macosinteractivehelper.h"
28 : #elif defined(Q_OS_WIN)
29 : #include <QDir>
30 : #include <QProcess>
31 : #include "platform/win/wininteractivehelper.h"
32 : #endif
33 :
34 : using namespace muse;
35 :
36 0 : Ret PlatformInteractive::openUrl(const std::string& url) const
37 : {
38 0 : return openUrl(QUrl(QString::fromStdString(url)));
39 : }
40 :
41 0 : Ret PlatformInteractive::openUrl(const QUrl& url) const
42 : {
43 0 : return QDesktopServices::openUrl(url);
44 : }
45 :
46 0 : Ret PlatformInteractive::isAppExists(const std::string& appIdentifier) const
47 : {
48 : #ifdef Q_OS_MACOS
49 : return MacOSInteractiveHelper::isAppExists(appIdentifier);
50 : #else
51 0 : NOT_IMPLEMENTED;
52 : UNUSED(appIdentifier);
53 0 : return false;
54 : #endif
55 : }
56 :
57 0 : Ret PlatformInteractive::canOpenApp(const UriQuery& uri) const
58 : {
59 : #ifdef Q_OS_MACOS
60 : return MacOSInteractiveHelper::canOpenApp(uri);
61 : #else
62 0 : NOT_IMPLEMENTED;
63 : UNUSED(uri);
64 0 : return false;
65 : #endif
66 : }
67 :
68 0 : async::Promise<Ret> PlatformInteractive::openApp(const UriQuery& uri) const
69 : {
70 : #ifdef Q_OS_MACOS
71 : return MacOSInteractiveHelper::openApp(uri);
72 : #elif defined(Q_OS_WIN)
73 : return WinInteractiveHelper::openApp(uri);
74 : #else
75 : UNUSED(uri);
76 0 : return async::Promise<Ret>([](auto, auto reject) {
77 0 : Ret ret = make_ret(Ret::Code::NotImplemented);
78 0 : return reject(ret.code(), ret.text());
79 0 : });
80 : #endif
81 : }
82 :
83 0 : Ret PlatformInteractive::revealInFileBrowser(const io::path_t& filePath) const
84 : {
85 : #ifdef Q_OS_MACOS
86 : if (MacOSInteractiveHelper::revealInFinder(filePath)) {
87 : return true;
88 : }
89 : #elif defined(Q_OS_WIN)
90 : QString program = "explorer.exe";
91 : QString arg = QLatin1String("/select,\"%1\"").arg(QDir::toNativeSeparators(filePath.toQString()));
92 : QProcess process;
93 : process.setProgram(program);
94 : process.setNativeArguments(arg);
95 : if (process.startDetached()) {
96 : return true;
97 : }
98 : #endif
99 0 : io::path_t dirPath = io::dirpath(filePath);
100 0 : return openUrl(QUrl::fromLocalFile(dirPath.toQString()));
101 0 : }
|