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>
#endif
#include "core/Config.h"
Clipboard::Clipboard(QObject* parent)
: QObject(parent)
, 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();
@ -50,8 +52,11 @@ void Clipboard::setText(const QString& text, int clearTimeout)
clipboard->setText(text, QClipboard::Selection);
}
if (clearTimeout > 0) {
m_timer->start(clearTimeout);
if (config()->get("security/clearclipboard").toBool()) {
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:
~Clipboard();
void setText(const QString& text, int clearTimeout = 0);
void setText(const QString& text);
private Q_SLOTS:
void clearClipboard();

View File

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