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