Store clear clipboard settings.

This commit is contained in:
Felix Geyer 2012-05-27 20:10:41 +02:00
parent 7194a3d7a8
commit d707fb4760
3 changed files with 16 additions and 4 deletions

View File

@ -26,6 +26,8 @@
#include <QtDBus/QDBusMessage> #include <QtDBus/QDBusMessage>
#endif #endif
#include "core/Config.h"
Clipboard::Clipboard(QObject* parent) Clipboard::Clipboard(QObject* parent)
: QObject(parent) : QObject(parent)
, m_timer(new QTimer(this)) , m_timer(new QTimer(this))
@ -41,7 +43,7 @@ Clipboard::~Clipboard()
} }
} }
void Clipboard::setText(const QString& text, int clearTimeout) void Clipboard::setText(const QString& text)
{ {
QClipboard* clipboard = QApplication::clipboard(); QClipboard* clipboard = QApplication::clipboard();
@ -50,8 +52,11 @@ void Clipboard::setText(const QString& text, int clearTimeout)
clipboard->setText(text, QClipboard::Selection); clipboard->setText(text, QClipboard::Selection);
} }
if (clearTimeout > 0) { if (config()->get("security/clearclipboard").toBool()) {
m_timer->start(clearTimeout); int timeout = config()->get("security/clearclipboardtimeout").toInt();
if (timeout > 0) {
m_timer->start(timeout);
}
} }
} }

View File

@ -28,7 +28,7 @@ class Clipboard : public QObject
public: public:
~Clipboard(); ~Clipboard();
void setText(const QString& text, int clearTimeout = 0); void setText(const QString& text);
private Q_SLOTS: private Q_SLOTS:
void clearClipboard(); void clearClipboard();

View File

@ -18,6 +18,8 @@
#include "SettingsWidget.h" #include "SettingsWidget.h"
#include "ui_SettingsWidgetSecurity.h" #include "ui_SettingsWidgetSecurity.h"
#include "core/Config.h"
SettingsWidget::SettingsWidget(QWidget* parent) SettingsWidget::SettingsWidget(QWidget* parent)
: EditWidget(parent) : EditWidget(parent)
, m_secWidget(new QWidget()) , m_secWidget(new QWidget())
@ -40,9 +42,14 @@ SettingsWidget::~SettingsWidget()
void SettingsWidget::loadSettings() void SettingsWidget::loadSettings()
{ {
m_secUi->clearClipboardCheckBox->setChecked(config()->get("security/clearclipboard").toBool());
m_secUi->clearClipboardSpinBox->setValue(config()->get("security/clearclipboardtimeout").toInt());
setCurrentRow(0); setCurrentRow(0);
} }
void SettingsWidget::saveSettings() void SettingsWidget::saveSettings()
{ {
config()->set("security/clearclipboard", m_secUi->clearClipboardCheckBox->isChecked());
config()->set("security/clearclipboardtimeout", m_secUi->clearClipboardSpinBox->value());
} }