summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2011-11-14 17:16:08 +0100
committerAndrea Diamantini <adjam7@gmail.com>2011-12-12 16:40:28 +0100
commit7932ee0fd2e683af8cc1207986504747ccfbc68e (patch)
treec66446b807778be74401bfb649a1b3784379bcf5 /src
parentSync feature, first bits (diff)
downloadrekonq-7932ee0fd2e683af8cc1207986504747ccfbc68e.tar.xz
Let the "big sync" work (the one done every minute...)
Diffstat (limited to 'src')
-rw-r--r--src/mainwindow.cpp8
-rw-r--r--src/rekonqui.rc1
-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
7 files changed, 82 insertions, 11 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 92c786df..c46fbc68 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -49,6 +49,7 @@
#include "sessionmanager.h"
#include "settingsdialog.h"
#include "stackedurlbar.h"
+#include "syncmanager.h"
#include "tabbar.h"
#include "urlbar.h"
#include "webinspectorpanel.h"
@@ -447,8 +448,8 @@ void MainWindow::setupActions()
closedTabsMenu->setDelayed(false);
actionCollection()->addAction(QL1S("closed_tab_menu"), closedTabsMenu);
- QSignalMapper *tabSignalMapper = new QSignalMapper(this);
// shortcuts for quickly switching to a tab
+ QSignalMapper *tabSignalMapper = new QSignalMapper(this);
for (int i = 1; i <= 9; i++)
{
a = new KAction(i18n("Switch to Tab %1", i), this);
@@ -529,6 +530,11 @@ void MainWindow::setupActions()
a = new KAction(KIcon("applications-internet"), i18n("Create application shortcut"), this);
actionCollection()->addAction(QL1S("webapp_shortcut"), a);
connect(a, SIGNAL(triggered(bool)), rApp, SLOT(createWebAppShortcut()));
+
+ // Sync action
+ a = new KAction(KIcon("tools-wizard"), i18n("Sync"), this); // FIXME sync icon!!
+ actionCollection()->addAction(QL1S("sync"), a);
+ connect(a, SIGNAL(triggered(bool)), rApp->syncManager(), SLOT(showSettings()));
}
diff --git a/src/rekonqui.rc b/src/rekonqui.rc
index 42b18bb3..7aeeb566 100644
--- a/src/rekonqui.rc
+++ b/src/rekonqui.rc
@@ -26,6 +26,7 @@
<Action name="set_editable" />
<Separator/>
<Action name="useragent" />
+ <Action name="sync" />
<Action name="adblock" />
</Menu>
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();