forked from qt-creator/qt-creator
CodePaster: Some more settings page cleanup
Change-Id: Ieac61eda5081025a3fe3cbbfffbd46d5433d0ebc Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -26,8 +26,6 @@
|
||||
#include "fileshareprotocolsettingspage.h"
|
||||
#include "cpasterconstants.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include <utils/layoutbuilder.h>
|
||||
#include <utils/temporarydirectory.h>
|
||||
|
||||
@@ -56,48 +54,30 @@ FileShareProtocolSettings::FileShareProtocolSettings()
|
||||
|
||||
// Settings page
|
||||
|
||||
class FileShareProtocolSettingsWidget final : public Core::IOptionsPageWidget
|
||||
FileShareProtocolSettingsPage::FileShareProtocolSettingsPage(FileShareProtocolSettings *settings)
|
||||
{
|
||||
public:
|
||||
FileShareProtocolSettingsWidget(FileShareProtocolSettings *settings)
|
||||
: m_settings(settings)
|
||||
{
|
||||
FileShareProtocolSettings &s = *settings;
|
||||
setId("X.CodePaster.FileSharePaster");
|
||||
setDisplayName(FileShareProtocolSettings::tr("Fileshare"));
|
||||
setCategory(Constants::CPASTER_SETTINGS_CATEGORY);
|
||||
setSettings(settings);
|
||||
|
||||
setLayouter([&s = *settings](QWidget *widget) {
|
||||
using namespace Layouting;
|
||||
|
||||
auto label = new QLabel(tr("The fileshare-based paster protocol allows for sharing code"
|
||||
"snippets using simple files on a shared network drive. "
|
||||
"Files are never deleted."));
|
||||
auto label = new QLabel(FileShareProtocolSettingsPage::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);
|
||||
|
||||
Column {
|
||||
Form {
|
||||
label, Break(),
|
||||
label, Break(),
|
||||
s.path,
|
||||
s.displayCount
|
||||
},
|
||||
Stretch()
|
||||
}.attachTo(this);
|
||||
}
|
||||
|
||||
void apply() final
|
||||
{
|
||||
if (m_settings->isDirty()) {
|
||||
m_settings->apply();
|
||||
m_settings->writeSettings(Core::ICore::settings());
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
FileShareProtocolSettings *m_settings;
|
||||
};
|
||||
|
||||
FileShareProtocolSettingsPage::FileShareProtocolSettingsPage(FileShareProtocolSettings *s)
|
||||
{
|
||||
setId("X.CodePaster.FileSharePaster");
|
||||
setDisplayName(FileShareProtocolSettingsWidget::tr("Fileshare"));
|
||||
setCategory(Constants::CPASTER_SETTINGS_CATEGORY);
|
||||
setWidgetCreator([s] { return new FileShareProtocolSettingsWidget(s); });
|
||||
}.attachTo(widget);
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace CodePaster
|
||||
|
||||
@@ -45,7 +45,7 @@ public:
|
||||
class FileShareProtocolSettingsPage final : public Core::IOptionsPage
|
||||
{
|
||||
public:
|
||||
explicit FileShareProtocolSettingsPage(FileShareProtocolSettings *s);
|
||||
explicit FileShareProtocolSettingsPage(FileShareProtocolSettings *settings);
|
||||
};
|
||||
|
||||
} // namespace CodePaster
|
||||
|
||||
@@ -26,9 +26,6 @@
|
||||
#include "settings.h"
|
||||
|
||||
#include "cpasterconstants.h"
|
||||
#include "pastebindotcomprotocol.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include <utils/layoutbuilder.h>
|
||||
|
||||
@@ -80,53 +77,31 @@ Settings::Settings()
|
||||
|
||||
// SettingsPage
|
||||
|
||||
class SettingsWidget final : public Core::IOptionsPageWidget
|
||||
{
|
||||
public:
|
||||
SettingsWidget(Settings *settings);
|
||||
|
||||
private:
|
||||
void apply() final;
|
||||
|
||||
Settings *m_settings;
|
||||
};
|
||||
|
||||
SettingsWidget::SettingsWidget(Settings *settings)
|
||||
: m_settings(settings)
|
||||
{
|
||||
Settings &s = *settings;
|
||||
using namespace Layouting;
|
||||
const Break nl;
|
||||
|
||||
Column {
|
||||
Form {
|
||||
s.protocols, nl,
|
||||
s.username, nl,
|
||||
s.expiryDays
|
||||
},
|
||||
s.copyToClipboard,
|
||||
s.displayOutput,
|
||||
s.publicPaste,
|
||||
Stretch()
|
||||
}.attachTo(this);
|
||||
}
|
||||
|
||||
void SettingsWidget::apply()
|
||||
{
|
||||
if (m_settings->isDirty()) {
|
||||
m_settings->apply();
|
||||
m_settings->writeSettings(Core::ICore::settings());
|
||||
}
|
||||
}
|
||||
|
||||
SettingsPage::SettingsPage(Settings *settings)
|
||||
{
|
||||
setId("A.CodePaster.General");
|
||||
setDisplayName(tr("General"));
|
||||
setDisplayName(Settings::tr("General"));
|
||||
setCategory(Constants::CPASTER_SETTINGS_CATEGORY);
|
||||
setDisplayCategory(QCoreApplication::translate("CodePaster", "Code Pasting"));
|
||||
setDisplayCategory(Settings::tr("Code Pasting"));
|
||||
setCategoryIconPath(":/cpaster/images/settingscategory_cpaster.png");
|
||||
setWidgetCreator([settings] { return new SettingsWidget(settings); });
|
||||
setSettings(settings);
|
||||
|
||||
setLayouter([settings](QWidget *widget) {
|
||||
Settings &s = *settings;
|
||||
using namespace Layouting;
|
||||
|
||||
Column {
|
||||
Form {
|
||||
s.protocols,
|
||||
s.username,
|
||||
s.expiryDays
|
||||
},
|
||||
s.copyToClipboard,
|
||||
s.displayOutput,
|
||||
s.publicPaste,
|
||||
Stretch()
|
||||
}.attachTo(widget);
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace CodePaster
|
||||
|
||||
@@ -48,8 +48,6 @@ public:
|
||||
|
||||
class SettingsPage final : public Core::IOptionsPage
|
||||
{
|
||||
Q_DECLARE_TR_FUNCTIONS(CodePaster::SettingsPage)
|
||||
|
||||
public:
|
||||
SettingsPage(Settings *settings);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user