aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/coreplugin/editormanager/systemeditor.cpp
blob: 35b93ca4825a6126897377245e0ceeaf38625946 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#include "systemeditor.h"

#include "../coreplugintr.h"

#include <utils/mimeconstants.h>
#include <utils/filepath.h>

#include <QUrl>
#include <QDesktopServices>

using namespace Utils;

namespace Core::Internal {

SystemEditor::SystemEditor()
{
    setId("CorePlugin.OpenWithSystemEditor");
    setDisplayName(Tr::tr("System Editor"));
    setMimeTypes({Utils::Constants::OCTET_STREAM_MIMETYPE});

    setEditorStarter([](const FilePath &filePath, QString *errorMessage) {
        Q_UNUSED(errorMessage)
        QUrl url;
        url.setPath(filePath.toString());
        url.setScheme(QLatin1String("file"));
        if (!QDesktopServices::openUrl(url)) {
            if (errorMessage)
                *errorMessage = Tr::tr("Could not open URL %1.").arg(url.toString());
            return false;
        }
        return true;
    });
}

} // Core::Internal