summaryrefslogtreecommitdiff
path: root/src/sync
diff options
context:
space:
mode:
Diffstat (limited to 'src/sync')
-rw-r--r--src/sync/settings_sync.ui12
-rw-r--r--src/sync/syncmanager.cpp48
-rw-r--r--src/sync/syncmanager.h6
-rw-r--r--src/sync/syncwidget.cpp16
-rw-r--r--src/sync/syncwidget.h2
5 files changed, 74 insertions, 10 deletions
diff --git a/src/sync/settings_sync.ui b/src/sync/settings_sync.ui
index 35415f53..f45c8b6c 100644
--- a/src/sync/settings_sync.ui
+++ b/src/sync/settings_sync.ui
@@ -6,10 +6,16 @@
<rect>
<x>0</x>
<y>0</y>
- <width>633</width>
- <height>551</height>
+ <width>378</width>
+ <height>369</height>
</rect>
</property>
+ <property name="minimumSize">
+ <size>
+ <width>300</width>
+ <height>0</height>
+ </size>
+ </property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QCheckBox" name="kcfg_syncEnabled">
@@ -113,7 +119,7 @@
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
- <height>289</height>
+ <height>50</height>
</size>
</property>
</spacer>
diff --git a/src/sync/syncmanager.cpp b/src/sync/syncmanager.cpp
index cf3f2df7..53149ee1 100644
--- a/src/sync/syncmanager.cpp
+++ b/src/sync/syncmanager.cpp
@@ -31,6 +31,9 @@
// Auto Includes
#include "rekonq.h"
+// Local Includes
+#include "syncwidget.h"
+
// KDE Includes
#include <KStandardDirs>
#include <KMessageBox>
@@ -43,20 +46,53 @@
SyncManager::SyncManager(QObject *parent)
: QObject(parent)
, _firstTimeSynced(false)
+ , _syncTimer(0)
+{
+ loadSettings();
+}
+
+
+SyncManager::~SyncManager()
+{
+ sync();
+}
+
+
+void SyncManager::loadSettings()
{
if (ReKonfig::syncEnabled())
{
- // sync every minute
- QTimer *timer = new QTimer(this);
- connect(timer, SIGNAL(timeout()), this, SLOT(sync()));
- timer->start(60 * 1000);
+ if (_syncTimer)
+ return;
+
+ _syncTimer = new QTimer(this);
+ connect(_syncTimer, SIGNAL(timeout()), this, SLOT(sync()));
+ _syncTimer->start(60 * 1000); // sync every minute
+ }
+ else
+ {
+ if (_syncTimer)
+ {
+ _syncTimer->stop();
+ delete _syncTimer;
+ }
}
}
-SyncManager::~SyncManager()
+void SyncManager::showSettings()
{
- sync();
+ QPointer<KDialog> dialog = new KDialog();
+ dialog->setCaption(i18nc("@title:window", "Sync Settings"));
+ dialog->setButtons(KDialog::Ok | KDialog::Cancel);
+
+ SyncWidget widget;
+ dialog->setMainWidget(&widget);
+ connect(dialog, SIGNAL(okClicked()), &widget, SLOT(save()));
+ connect(dialog, SIGNAL(okClicked()), this, SLOT(loadSettings()));
+ dialog->exec();
+
+ dialog->deleteLater();
}
diff --git a/src/sync/syncmanager.h b/src/sync/syncmanager.h
index 3a78191f..c6f8a76a 100644
--- a/src/sync/syncmanager.h
+++ b/src/sync/syncmanager.h
@@ -39,6 +39,7 @@
// Forward Declarations
class KJob;
+class QTimer;
class REKONQ_TESTS_EXPORT SyncManager : public QObject
@@ -55,6 +56,9 @@ public Q_SLOTS:
void sync();
private Q_SLOTS:
+ void loadSettings();
+ void showSettings();
+
void onBookmarksSyncFinished(KJob *);
void onBookmarksStatFinished(KJob *);
@@ -80,6 +84,8 @@ private:
QUrl _remotePasswordsUrl;
KUrl _localPasswordsUrl;
+
+ QTimer *_syncTimer;
};
#endif // SYNC_MANAGER_H
diff --git a/src/sync/syncwidget.cpp b/src/sync/syncwidget.cpp
index c5295c93..b8e95753 100644
--- a/src/sync/syncwidget.cpp
+++ b/src/sync/syncwidget.cpp
@@ -42,6 +42,14 @@ SyncWidget::SyncWidget(QWidget *parent)
{
setupUi(this);
+ kcfg_syncEnabled->setChecked(ReKonfig::syncEnabled());
+ kcfg_syncBookmarks->setChecked(ReKonfig::syncBookmarks());
+ kcfg_syncHistory->setChecked(ReKonfig::syncHistory());
+ kcfg_syncPasswords->setChecked(ReKonfig::syncPasswords());
+ kcfg_syncHost->setText(ReKonfig::syncHost());
+ kcfg_syncUser->setText(ReKonfig::syncUser());
+ kcfg_syncPass->setText(ReKonfig::syncPass());
+
bool isSyncEnabled = ReKonfig::syncEnabled();
enablewidgets(isSyncEnabled);
@@ -56,6 +64,14 @@ SyncWidget::SyncWidget(QWidget *parent)
void SyncWidget::save()
{
+ ReKonfig::setSyncEnabled(kcfg_syncEnabled->isChecked());
+ ReKonfig::setSyncBookmarks(kcfg_syncBookmarks->isChecked());
+ ReKonfig::setSyncHistory(kcfg_syncHistory->isChecked());
+ ReKonfig::setSyncPasswords(kcfg_syncPasswords->isChecked());
+ ReKonfig::setSyncHost(kcfg_syncHost->text());
+ ReKonfig::setSyncUser(kcfg_syncUser->text());
+ ReKonfig::setSyncPass(kcfg_syncPass->text());
+
rApp->syncManager()->firstTimeSync();
}
diff --git a/src/sync/syncwidget.h b/src/sync/syncwidget.h
index 0e1d57ff..8621eae1 100644
--- a/src/sync/syncwidget.h
+++ b/src/sync/syncwidget.h
@@ -45,13 +45,13 @@ class SyncWidget : public QWidget, private Ui::Sync
public:
SyncWidget(QWidget *parent = 0);
- void save();
bool changed();
Q_SIGNALS:
void changed(bool);
private Q_SLOTS:
+ void save();
void hasChanged();
void syncNow();