[Pkg-running-devel] [openambit] 62/131: Added automatic sync when device connected
Christian Perrier
bubulle at moszumanska.debian.org
Thu Jul 17 20:19:11 UTC 2014
This is an automated email from the git hooks/post-receive script.
bubulle pushed a commit to branch master
in repository openambit.
commit 3df0b0c0aee983bc4ca8b81ad5d2529098237dda
Author: Emil Ljungdahl <emil at kratern.se>
Date: Tue Jan 21 21:08:16 2014 +0100
Added automatic sync when device connected
---
src/openambit/mainwindow.cpp | 125 +++++++++++++++++++++------------------
src/openambit/mainwindow.h | 4 +-
src/openambit/mainwindow.ui | 19 ++++++
src/openambit/settingsdialog.cpp | 2 +
src/openambit/settingsdialog.ui | 13 +++-
5 files changed, 99 insertions(+), 64 deletions(-)
diff --git a/src/openambit/mainwindow.cpp b/src/openambit/mainwindow.cpp
index bfb0872..354cca9 100644
--- a/src/openambit/mainwindow.cpp
+++ b/src/openambit/mainwindow.cpp
@@ -67,8 +67,6 @@ MainWindow::MainWindow(QWidget *parent) :
}
}
- connect(ui->actionSettings, SIGNAL(triggered()), this, SLOT(showSettings()));
-
// System tray icon
trayIcon = new QSystemTrayIcon(QIcon(":/icon_disconnected"));
trayIcon->show();
@@ -123,36 +121,14 @@ void MainWindow::settingsSaved()
void MainWindow::syncNowClicked()
{
- bool syncTime, syncOrbit, syncMovescount;
-
- ui->checkBoxResyncAll->setEnabled(false);
- ui->buttonSyncNow->setEnabled(false);
- currentLogMessageRow = NULL;
- QLayoutItem *tmpItem;
- while ((tmpItem = ui->verticalLayoutLogMessages->takeAt(0)) != NULL) {
- delete tmpItem->widget();
- delete tmpItem;
- }
- ui->syncProgressBar->setHidden(false);
- ui->syncProgressBar->setValue(0);
-
- settings.beginGroup("syncSettings");
- syncTime = settings.value("syncTime", true).toBool();
- syncOrbit = settings.value("syncOrbit", true).toBool();
- settings.endGroup();
- settings.beginGroup("movescountSettings");
- syncMovescount = settings.value("movescountEnable", true).toBool();
- settings.endGroup();
-
- trayIcon->setIcon(QIcon(":/icon_syncing"));
-
- emit MainWindow::syncNow(ui->checkBoxResyncAll->isChecked(), syncTime, syncOrbit, syncMovescount);
+ startSync();
}
void MainWindow::deviceDetected(ambit_device_info_t deviceInfo, bool supported)
{
ui->labelDeviceDetected->setText(deviceInfo.name);
ui->labelSerial->setText(deviceInfo.serial);
+ trayIcon->setIcon(QIcon(":/icon_connected"));
if (!supported) {
ui->labelNotSupportedIcon->setHidden(false);
ui->labelNotSupported->setHidden(false);
@@ -190,9 +166,13 @@ void MainWindow::deviceDetected(ambit_device_info_t deviceInfo, bool supported)
}
settings.endGroup();
}
- }
- trayIcon->setIcon(QIcon(":/icon_connected"));
+ settings.beginGroup("syncSettings");
+ if (settings.value("syncAutomatically", false).toBool()) {
+ startSync();
+ }
+ settings.endGroup();
+ }
}
void MainWindow::deviceRemoved(void)
@@ -329,6 +309,65 @@ void MainWindow::updateLogList()
}
}
+void MainWindow::startSync()
+{
+ bool syncTime, syncOrbit, syncMovescount;
+
+ ui->checkBoxResyncAll->setEnabled(false);
+ ui->buttonSyncNow->setEnabled(false);
+ currentLogMessageRow = NULL;
+ QLayoutItem *tmpItem;
+ while ((tmpItem = ui->verticalLayoutLogMessages->takeAt(0)) != NULL) {
+ delete tmpItem->widget();
+ delete tmpItem;
+ }
+ ui->syncProgressBar->setHidden(false);
+ ui->syncProgressBar->setValue(0);
+
+ settings.beginGroup("syncSettings");
+ syncTime = settings.value("syncTime", true).toBool();
+ syncOrbit = settings.value("syncOrbit", true).toBool();
+ settings.endGroup();
+ settings.beginGroup("movescountSettings");
+ syncMovescount = settings.value("movescountEnable", true).toBool();
+ settings.endGroup();
+
+ trayIcon->setIcon(QIcon(":/icon_syncing"));
+
+ emit MainWindow::syncNow(ui->checkBoxResyncAll->isChecked(), syncTime, syncOrbit, syncMovescount);
+}
+
+void MainWindow::movesCountSetup()
+{
+ bool syncOrbit = false;
+ bool movescountEnable = false;
+
+ settings.beginGroup("syncSettings");
+ syncOrbit = settings.value("syncOrbit").toBool();
+ settings.endGroup();
+
+ settings.beginGroup("movescountSettings");
+ movescountEnable = settings.value("movescountEnable").toBool();
+ if (syncOrbit || movescountEnable) {
+ if (movesCount == NULL) {
+ movesCount = MovesCount::instance();
+ movesCount->setAppkey(APPKEY);
+ movesCount->setBaseAddress(settings.value("movescountBaseAddress", MOVESCOUNT_DEFAULT_URL).toString());
+ if (settings.value("movescountUserkey", "").toString().length() == 0) {
+ settings.setValue("movescountUserkey", movesCount->generateUserkey());
+ }
+ movesCount->setUserkey(settings.value("movescountUserkey").toString());
+
+ connect(movesCount, SIGNAL(newerFirmwareExists(QByteArray)), this, SLOT(newerFirmwareExists(QByteArray)), Qt::QueuedConnection);
+ connect(movesCount, SIGNAL(movesCountAuth(bool)), this, SLOT(movesCountAuth(bool)), Qt::QueuedConnection);
+ }
+ if (movescountEnable) {
+ movesCount->setUsername(settings.value("email").toString());
+ }
+ }
+ settings.endGroup();
+}
+
MainWindow::LogMessageRow::LogMessageRow(QWidget *parent) :
QHBoxLayout(parent)
{
@@ -368,33 +407,3 @@ void MainWindow::LogMessageRow::setStatus(Status status)
iconLabel->setPixmap(icon.pixmap(8,8));
}
-void MainWindow::movesCountSetup()
-{
- bool syncOrbit = false;
- bool movescountEnable = false;
-
- settings.beginGroup("syncSettings");
- syncOrbit = settings.value("syncOrbit").toBool();
- settings.endGroup();
-
- settings.beginGroup("movescountSettings");
- movescountEnable = settings.value("movescountEnable").toBool();
- if (syncOrbit || movescountEnable) {
- if (movesCount == NULL) {
- movesCount = MovesCount::instance();
- movesCount->setAppkey(APPKEY);
- movesCount->setBaseAddress(settings.value("movescountBaseAddress", MOVESCOUNT_DEFAULT_URL).toString());
- if (settings.value("movescountUserkey", "").toString().length() == 0) {
- settings.setValue("movescountUserkey", movesCount->generateUserkey());
- }
- movesCount->setUserkey(settings.value("movescountUserkey").toString());
-
- connect(movesCount, SIGNAL(newerFirmwareExists(QByteArray)), this, SLOT(newerFirmwareExists(QByteArray)), Qt::QueuedConnection);
- connect(movesCount, SIGNAL(movesCountAuth(bool)), this, SLOT(movesCountAuth(bool)), Qt::QueuedConnection);
- }
- if (movescountEnable) {
- movesCount->setUsername(settings.value("email").toString());
- }
- }
- settings.endGroup();
-}
diff --git a/src/openambit/mainwindow.h b/src/openambit/mainwindow.h
index 5bfb8ee..ce4d9f3 100644
--- a/src/openambit/mainwindow.h
+++ b/src/openambit/mainwindow.h
@@ -69,9 +69,7 @@ private slots:
void updateLogList();
private:
- void addLogMessageRow(QString message);
- void updateLogMessageRow(QString message);
- void finalizeLogMessageRow();
+ void startSync();
void movesCountSetup();
diff --git a/src/openambit/mainwindow.ui b/src/openambit/mainwindow.ui
index f6a50c1..6826d40 100644
--- a/src/openambit/mainwindow.ui
+++ b/src/openambit/mainwindow.ui
@@ -416,5 +416,24 @@
</hint>
</hints>
</connection>
+ <connection>
+ <sender>actionSettings</sender>
+ <signal>triggered()</signal>
+ <receiver>MainWindow</receiver>
+ <slot>showSettings()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>-1</x>
+ <y>-1</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>435</x>
+ <y>270</y>
+ </hint>
+ </hints>
+ </connection>
</connections>
+ <slots>
+ <slot>showSettings()</slot>
+ </slots>
</ui>
diff --git a/src/openambit/settingsdialog.cpp b/src/openambit/settingsdialog.cpp
index 3e2bf34..5ba3cbd 100644
--- a/src/openambit/settingsdialog.cpp
+++ b/src/openambit/settingsdialog.cpp
@@ -72,6 +72,7 @@ void SettingsDialog::readSettings()
settings.endGroup();
settings.beginGroup("syncSettings");
+ ui->checkBoxSyncAutomatically->setChecked(settings.value("syncAutomatically", false).toBool());
ui->checkBoxSyncTime->setChecked(settings.value("syncTime", true).toBool());
ui->checkBoxSyncOrbit->setChecked(settings.value("syncOrbit", true).toBool());
settings.endGroup();
@@ -91,6 +92,7 @@ void SettingsDialog::writeSettings()
settings.endGroup();
settings.beginGroup("syncSettings");
+ settings.setValue("syncAutomatically", ui->checkBoxSyncAutomatically->isChecked());
settings.setValue("syncTime", ui->checkBoxSyncTime->isChecked());
settings.setValue("syncOrbit", ui->checkBoxSyncOrbit->isChecked());
settings.endGroup();
diff --git a/src/openambit/settingsdialog.ui b/src/openambit/settingsdialog.ui
index 423d07d..2697ecb 100644
--- a/src/openambit/settingsdialog.ui
+++ b/src/openambit/settingsdialog.ui
@@ -88,7 +88,7 @@
</sizepolicy>
</property>
<property name="currentIndex">
- <number>0</number>
+ <number>1</number>
</property>
<widget class="QWidget" name="generalSettingsPage">
<layout class="QVBoxLayout" name="verticalLayout_5">
@@ -130,20 +130,27 @@
<string>Device syncronisation settings</string>
</property>
<layout class="QFormLayout" name="formLayout">
- <item row="0" column="0">
+ <item row="1" column="0">
<widget class="QCheckBox" name="checkBoxSyncTime">
<property name="text">
<string>Sync time from computer</string>
</property>
</widget>
</item>
- <item row="1" column="0">
+ <item row="2" column="0">
<widget class="QCheckBox" name="checkBoxSyncOrbit">
<property name="text">
<string>Sync orbital data (from Movescount)</string>
</property>
</widget>
</item>
+ <item row="0" column="0">
+ <widget class="QCheckBox" name="checkBoxSyncAutomatically">
+ <property name="text">
+ <string>Start sync automatically when device connected</string>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
</item>
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-running/openambit.git
More information about the Pkg-running-devel
mailing list