2017-09-09 21:40:00 +02:00
|
|
|
#include "./settingsdialog.h"
|
|
|
|
#include "./syncthingapplet.h"
|
|
|
|
|
2017-09-18 20:29:36 +02:00
|
|
|
#include "ui_appearanceoptionpage.h"
|
|
|
|
|
2017-09-09 21:40:00 +02:00
|
|
|
#include "../../widgets/settings/settingsdialog.h"
|
|
|
|
|
|
|
|
#include <qtutilities/settingsdialog/optioncategory.h>
|
|
|
|
#include <qtutilities/settingsdialog/optionpage.h>
|
|
|
|
#include <qtutilities/settingsdialog/settingsdialog.h>
|
|
|
|
|
2017-09-18 20:29:36 +02:00
|
|
|
#include <KConfigGroup>
|
|
|
|
|
2017-09-09 21:40:00 +02:00
|
|
|
#include <QCoreApplication>
|
|
|
|
#include <QFormLayout>
|
|
|
|
#include <QKeySequenceEdit>
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
|
|
|
|
using namespace Dialogs;
|
|
|
|
using namespace Data;
|
|
|
|
using namespace QtGui;
|
|
|
|
|
|
|
|
namespace Plasmoid {
|
|
|
|
|
2017-10-03 16:58:50 +02:00
|
|
|
void addPlasmoidSpecificNote(QLayout *layout, QWidget *parent)
|
|
|
|
{
|
|
|
|
auto *const infoLabel = new QLabel(
|
|
|
|
QCoreApplication::translate("Plasmoid::Settings", "The settings on this page are specific to the current instance of the Plasmoid."), parent);
|
|
|
|
infoLabel->setWordWrap(true);
|
|
|
|
QFont infoFont(infoLabel->font());
|
|
|
|
infoFont.setBold(true);
|
|
|
|
infoLabel->setFont(infoFont);
|
|
|
|
auto *const line = new QFrame(parent);
|
|
|
|
line->setFrameShape(QFrame::HLine);
|
|
|
|
line->setFrameShadow(QFrame::Sunken);
|
|
|
|
layout->addWidget(line);
|
|
|
|
layout->addWidget(infoLabel);
|
|
|
|
}
|
|
|
|
|
2017-09-09 21:40:00 +02:00
|
|
|
// ShortcutOptionPage
|
|
|
|
ShortcutOptionPage::ShortcutOptionPage(SyncthingApplet &applet, QWidget *parentWidget)
|
|
|
|
: ShortcutOptionPageBase(parentWidget)
|
|
|
|
, m_applet(&applet)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ShortcutOptionPage::~ShortcutOptionPage()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ShortcutOptionPage::apply()
|
|
|
|
{
|
2017-09-27 00:21:53 +02:00
|
|
|
m_applet->setGlobalShortcut(m_globalShortcutEdit->keySequence());
|
2017-09-09 21:40:00 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ShortcutOptionPage::reset()
|
|
|
|
{
|
2017-09-27 00:21:53 +02:00
|
|
|
m_globalShortcutEdit->setKeySequence(m_applet->globalShortcut());
|
2017-09-09 21:40:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
QWidget *ShortcutOptionPage::setupWidget()
|
|
|
|
{
|
2017-10-03 16:58:50 +02:00
|
|
|
auto *const widget = new QWidget();
|
2017-09-09 21:40:00 +02:00
|
|
|
widget->setWindowTitle(QCoreApplication::translate("Plasmoid::ShortcutOptionPage", "Shortcuts"));
|
|
|
|
widget->setWindowIcon(QIcon::fromTheme(QStringLiteral("configure-shortcuts")));
|
2017-10-03 16:58:50 +02:00
|
|
|
widget->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
|
|
|
auto *const mainLayout = new QVBoxLayout(widget);
|
|
|
|
auto *const formLayout = new QFormLayout;
|
2017-09-09 21:40:00 +02:00
|
|
|
formLayout->addRow(
|
|
|
|
QCoreApplication::translate("Plasmoid::ShortcutOptionPage", "Global shortcut"), m_globalShortcutEdit = new QKeySequenceEdit(widget));
|
|
|
|
mainLayout->addLayout(formLayout);
|
2017-10-03 16:58:50 +02:00
|
|
|
mainLayout->addStretch(1);
|
|
|
|
addPlasmoidSpecificNote(mainLayout, widget);
|
2017-09-09 21:40:00 +02:00
|
|
|
return widget;
|
|
|
|
}
|
|
|
|
|
2017-09-18 20:29:36 +02:00
|
|
|
// AppearanceOptionPage
|
|
|
|
AppearanceOptionPage::AppearanceOptionPage(SyncthingApplet &applet, QWidget *parentWidget)
|
|
|
|
: AppearanceOptionPageBase(parentWidget)
|
|
|
|
, m_applet(&applet)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
AppearanceOptionPage::~AppearanceOptionPage()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool AppearanceOptionPage::apply()
|
|
|
|
{
|
2017-09-27 00:21:53 +02:00
|
|
|
KConfigGroup config = m_applet->config();
|
|
|
|
config.writeEntry<QSize>("size", QSize(ui()->widthSpinBox->value(), ui()->heightSpinBox->value()));
|
|
|
|
config.writeEntry<bool>("brightColors", ui()->brightTextColorsCheckBox->isChecked());
|
2017-09-18 20:29:36 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void AppearanceOptionPage::reset()
|
|
|
|
{
|
2017-09-27 00:21:53 +02:00
|
|
|
const KConfigGroup config = m_applet->config();
|
|
|
|
const QSize size(config.readEntry<QSize>("size", QSize(25, 25)));
|
|
|
|
ui()->widthSpinBox->setValue(size.width());
|
|
|
|
ui()->heightSpinBox->setValue(size.height());
|
|
|
|
ui()->brightTextColorsCheckBox->setChecked(config.readEntry<bool>("brightColors", false));
|
2017-09-18 20:29:36 +02:00
|
|
|
}
|
|
|
|
|
2017-10-03 16:58:50 +02:00
|
|
|
QWidget *AppearanceOptionPage::setupWidget()
|
|
|
|
{
|
|
|
|
auto *const widget = AppearanceOptionPageBase::setupWidget();
|
|
|
|
addPlasmoidSpecificNote(ui()->verticalLayout, widget);
|
|
|
|
return widget;
|
|
|
|
}
|
|
|
|
|
2017-09-09 21:40:00 +02:00
|
|
|
QtGui::SettingsDialog *setupSettingsDialog(SyncthingApplet &applet)
|
|
|
|
{
|
|
|
|
// setup categories
|
|
|
|
QList<Dialogs::OptionCategory *> categories;
|
|
|
|
Dialogs::OptionCategory *category;
|
|
|
|
|
|
|
|
category = new OptionCategory;
|
|
|
|
category->setDisplayName(QCoreApplication::translate("Plasmoid::SettingsDialog", "Plasmoid"));
|
|
|
|
category->assignPages(QList<Dialogs::OptionPage *>()
|
2017-09-18 20:29:36 +02:00
|
|
|
<< new ConnectionOptionPage(applet.connection()) << new NotificationsOptionPage(GuiType::Plasmoid) << new AppearanceOptionPage(applet)
|
|
|
|
<< new ShortcutOptionPage(applet));
|
2017-09-09 21:40:00 +02:00
|
|
|
category->setIcon(QIcon::fromTheme(QStringLiteral("plasma")));
|
|
|
|
categories << category;
|
|
|
|
|
|
|
|
// most startup options don't make much sense for a Plasmoid, so merge webview with startup
|
|
|
|
auto *const webViewPage = new WebViewOptionPage;
|
|
|
|
webViewPage->widget()->setWindowTitle(QCoreApplication::translate("Plasmoid::SettingsDialog", "Web view"));
|
|
|
|
webViewPage->widget()->setWindowIcon(
|
|
|
|
QIcon::fromTheme(QStringLiteral("internet-web-browser"), QIcon(QStringLiteral(":/icons/hicolor/scalable/apps/internet-web-browser.svg"))));
|
|
|
|
#ifdef LIB_SYNCTHING_CONNECTOR_SUPPORT_SYSTEMD
|
|
|
|
auto *const systemdPage = new SystemdOptionPage;
|
|
|
|
systemdPage->widget()->setWindowIcon(
|
|
|
|
QIcon::fromTheme(QStringLiteral("system-run"), QIcon(QStringLiteral(":/icons/hicolor/scalable/apps/system-run.svg"))));
|
|
|
|
#endif
|
|
|
|
|
|
|
|
category = new OptionCategory;
|
|
|
|
category->setDisplayName(QCoreApplication::translate("Plasmoid::SettingsDialog", "Extras"));
|
|
|
|
category->assignPages(QList<Dialogs::OptionPage *>() << webViewPage
|
|
|
|
#ifdef LIB_SYNCTHING_CONNECTOR_SUPPORT_SYSTEMD
|
|
|
|
<< systemdPage
|
|
|
|
#endif
|
2017-09-17 21:48:15 +02:00
|
|
|
);
|
2017-09-09 21:40:00 +02:00
|
|
|
category->setIcon(
|
|
|
|
QIcon::fromTheme(QStringLiteral("preferences-other"), QIcon(QStringLiteral(":/icons/hicolor/scalable/apps/preferences-other.svg"))));
|
|
|
|
categories << category;
|
|
|
|
|
|
|
|
return new ::QtGui::SettingsDialog(categories);
|
|
|
|
}
|
2017-09-17 21:48:15 +02:00
|
|
|
} // namespace Plasmoid
|