aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/cpaster/fileshareprotocolsettingspage.cpp
blob: ad60a2ad8401c734fb32312c1e68c774c08111c1 (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// 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 "fileshareprotocolsettingspage.h"

#include "cpastertr.h"
#include "cpasterconstants.h"

#include <utils/layoutbuilder.h>
#include <utils/temporarydirectory.h>

using namespace Utils;

namespace CodePaster {

FileShareProtocolSettings &fileShareSettings()
{
    static FileShareProtocolSettings theSettings;
    return theSettings;
}

FileShareProtocolSettings::FileShareProtocolSettings()
{
    setAutoApply(false);
    setSettingsGroup("FileSharePasterSettings");

    path.setSettingsKey("Path");
    path.setExpectedKind(PathChooser::ExistingDirectory);
    path.setDefaultValue(TemporaryDirectory::masterDirectoryPath());
    path.setLabelText(Tr::tr("&Path:"));

    displayCount.setSettingsKey("DisplayCount");
    displayCount.setDefaultValue(10);
    displayCount.setSuffix(' ' + Tr::tr("entries"));
    displayCount.setLabelText(Tr::tr("&Display:"));

    setLayouter([this] {
        using namespace Layouting;

        auto label = new QLabel(Tr::tr(
            "The fileshare-based paster protocol allows for sharing code snippets using "
            "simple files on a shared network drive. Files are never deleted."));
        label->setWordWrap(true);

        return Column {
            Form {
                label, br,
                path, br,
                displayCount
            },
            st
        };
    });

    readSettings();
}

class FileShareProtocolSettingsPage final : public Core::IOptionsPage
{
public:
    FileShareProtocolSettingsPage()
    {
        setId("X.CodePaster.FileSharePaster");
        setDisplayName(Tr::tr("Fileshare"));
        setCategory(Constants::CPASTER_SETTINGS_CATEGORY);
        setSettingsProvider([] { return &fileShareSettings(); });
    }
};

Core::IOptionsPage &fileShareSettingsPage()
{
    static FileShareProtocolSettingsPage theSettings;
    return theSettings;
}

} // namespace CodePaster