summaryrefslogtreecommitdiffstats
path: root/plugins/fossil/fossilsettings.cpp
blob: 72bb99dba688bca3ddc9018c65bade967295ef4a (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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
/****************************************************************************
**
** Copyright (c) 2018 Artur Shepilko
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/

#include "fossilsettings.h"

#include "constants.h"

#include <coreplugin/icore.h>

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

#include <vcsbase/vcsbaseconstants.h>

using namespace Utils;

namespace Fossil {
namespace Internal {

FossilSettings::FossilSettings()
{
    setSettingsGroup(Constants::FOSSIL);
    setAutoApply(false);

    registerAspect(&binaryPath);
    binaryPath.setDisplayStyle(StringAspect::PathChooserDisplay);
    binaryPath.setExpectedKind(PathChooser::ExistingCommand);
    binaryPath.setDefaultValue(Constants::FOSSILDEFAULT);
    binaryPath.setDisplayName(tr("Fossil Command"));
    binaryPath.setHistoryCompleter("Fossil.Command.History");
    binaryPath.setLabelText(tr("Command:"));

    registerAspect(&defaultRepoPath);
    defaultRepoPath.setSettingsKey("defaultRepoPath");
    defaultRepoPath.setDisplayStyle(StringAspect::PathChooserDisplay);
    defaultRepoPath.setExpectedKind(PathChooser::Directory);
    defaultRepoPath.setDisplayName(tr("Fossil Repositories"));
    defaultRepoPath.setLabelText(tr("Default path:"));
    defaultRepoPath.setToolTip(tr("Directory to store local repositories by default."));

    registerAspect(&userName);
    userName.setDisplayStyle(StringAspect::LineEditDisplay);
    userName.setLabelText(tr("Default user:"));
    userName.setToolTip(tr("Existing user to become an author of changes made to the repository."));

    registerAspect(&sslIdentityFile);
    sslIdentityFile.setSettingsKey("sslIdentityFile");
    sslIdentityFile.setDisplayStyle(StringAspect::PathChooserDisplay);
    sslIdentityFile.setExpectedKind(PathChooser::File);
    sslIdentityFile.setDisplayName(tr("SSL/TLS Identity Key"));
    sslIdentityFile.setLabelText(tr("SSL/TLS identity:"));
    sslIdentityFile.setToolTip(tr("SSL/TLS client identity key to use if requested by the server."));

    registerAspect(&diffIgnoreAllWhiteSpace);
    diffIgnoreAllWhiteSpace.setSettingsKey("diffIgnoreAllWhiteSpace");

    registerAspect(&diffStripTrailingCR);
    diffStripTrailingCR.setSettingsKey("diffStripTrailingCR");

    registerAspect(&annotateShowCommitters);
    annotateShowCommitters.setSettingsKey("annotateShowCommitters");

    registerAspect(&annotateListVersions);
    annotateListVersions.setSettingsKey("annotateListVersions");

    registerAspect(&timelineWidth);
    timelineWidth.setSettingsKey("timelineWidth");
    timelineWidth.setLabelText(tr("Log width:"));
    timelineWidth.setToolTip(tr("The width of log entry line (>20). "
        "Choose 0 to see a single line per entry."));

    registerAspect(&timelineLineageFilter);
    timelineLineageFilter.setSettingsKey("timelineLineageFilter");

    registerAspect(&timelineVerbose);
    timelineVerbose.setSettingsKey("timelineVerbose");

    registerAspect(&timelineItemType);
    timelineItemType.setDefaultValue("all");
    timelineItemType.setSettingsKey("timelineItemType");

    registerAspect(&disableAutosync);
    disableAutosync.setSettingsKey("disableAutosync");
    disableAutosync.setDefaultValue(true);
    disableAutosync.setLabelText(tr("Disable auto-sync"));
    disableAutosync.setToolTip(tr("Disable automatic pull prior to commit or update and "
        "automatic push after commit or tag or branch creation."));

    registerAspect(&timeout);
    timeout.setLabelText(tr("Timeout:"));
    timeout.setSuffix(tr("s"));

    registerAspect(&logCount);
    logCount.setLabelText(tr("Log count:"));
    logCount.setToolTip(tr("The number of recent commit log entries to show. "
        "Choose 0 to see all entries."));
};

// OptionsPage

class OptionsPageWidget final : public Core::IOptionsPageWidget
{
    Q_DECLARE_TR_FUNCTIONS(Fossil::Internal::OptionsPageWidget)

public:
    OptionsPageWidget(const std::function<void()> &onApply, FossilSettings *settings);
    void apply() final;

private:
    const std::function<void()> m_onApply;
    FossilSettings *m_settings;
};

void OptionsPageWidget::apply()
{
    if (!m_settings->isDirty())
        return;

    m_settings->apply();
    m_onApply();
}

OptionsPageWidget::OptionsPageWidget(const std::function<void()> &onApply, FossilSettings *settings) :
    m_onApply(onApply),
    m_settings(settings)
{
    FossilSettings &s = *m_settings;

    using namespace Layouting;

    Column {
        Group {
            title(tr("Configuration")),
            Row { s.binaryPath }
        },

        Group {
            title(tr("Local Repositories")),
            Row { s.defaultRepoPath }
        },
        Group {
            title(tr("User")),
            Form {
                s.userName, br,
                s.sslIdentityFile
            }
        },

        Group {
            title(tr("Miscellaneous")),
            Column {
                Row {
                s.logCount,
                s.timelineWidth,
                s.timeout,
                st
                },
                s.disableAutosync
            },
        },
        st

    }.attachTo(this);
}

OptionsPage::OptionsPage(const std::function<void()> &onApply, FossilSettings *settings)
{
    setId(Constants::VCS_ID_FOSSIL);
    setDisplayName(OptionsPageWidget::tr("Fossil"));
    setWidgetCreator([onApply, settings]() { return new OptionsPageWidget(onApply, settings); });
    setCategory(VcsBase::Constants::VCS_SETTINGS_CATEGORY);
}

} // Internal
} // Fossil