Qt::Horizontal
diff --git a/app/SysTray-X/preferencesdialog.cpp b/app/SysTray-X/preferencesdialog.cpp
index 62ded0f..5625d47 100644
--- a/app/SysTray-X/preferencesdialog.cpp
+++ b/app/SysTray-X/preferencesdialog.cpp
@@ -59,6 +59,24 @@ void PreferencesDialog::setDebug( bool state )
}
+/*
+ * Set the poll startup delay
+ */
+void PreferencesDialog::setPollStartupDelay( int val )
+{
+ m_ui->pollStartupDelaySpinBox->setValue( val );
+}
+
+
+/*
+ * Set the poll interval
+ */
+void PreferencesDialog::setPollInterval( int val )
+{
+ m_ui->pollIntervalSpinBox->setValue( val );
+}
+
+
/*
* Set the hide on minimize state
*/
@@ -141,6 +159,9 @@ void PreferencesDialog::slotAccept()
m_pref->setHideOnMinimize( m_ui->hideOnMinimizeCheckBox->isChecked() );
m_pref->setStartMinimized( m_ui->startMinimizedCheckBox->isChecked() );
+ m_pref->setPollStartupDelay(m_ui->pollStartupDelaySpinBox->value());
+ m_pref->setPollInterval(m_ui->pollIntervalSpinBox->value());
+
m_pref->setDebug( m_ui->debugWindowCheckBox->isChecked() );
/*
@@ -203,6 +224,24 @@ void PreferencesDialog::slotDebugChange()
}
+/*
+ * Handle the poll startup delay change signal
+ */
+void PreferencesDialog::slotPollStartupDelayChange()
+{
+ setPollStartupDelay( m_pref->getPollStartupDelay() );
+}
+
+
+/*
+ * Handle the poll interval change signal
+ */
+void PreferencesDialog::slotPollIntervalChange()
+{
+ setPollInterval( m_pref->getPollInterval() );
+}
+
+
/*
* Handle the hide on minimize change signal
*/
diff --git a/app/SysTray-X/preferencesdialog.h b/app/SysTray-X/preferencesdialog.h
index e3be69d..d1e608f 100644
--- a/app/SysTray-X/preferencesdialog.h
+++ b/app/SysTray-X/preferencesdialog.h
@@ -48,6 +48,20 @@ class PreferencesDialog : public QDialog
*/
void setDebug( bool state );
+ /**
+ * @brief setPollStartupDelay. Set the poll startup delay.
+ *
+ * @param val The new value.
+ */
+ void setPollStartupDelay( int val );
+
+ /**
+ * @brief setPollInterval. Set the poll interval.
+ *
+ * @param val The new value.
+ */
+ void setPollInterval( int val );
+
/**
* @brief setHideOnMinimize. Set the hide on minimize state.
*
@@ -96,6 +110,16 @@ class PreferencesDialog : public QDialog
*/
void slotDebugChange();
+ /**
+ * @brief slotPollStartupDelayChange. Slot for handling poll startup delay signals.
+ */
+ void slotPollStartupDelayChange();
+
+ /**
+ * @brief slotPollIntervalChange. Slot for handling poll interval signals.
+ */
+ void slotPollIntervalChange();
+
/**
* @brief slotHideOnMinimizeChange. Slot for handling hide on minimize change signals.
*/
diff --git a/app/SysTray-X/systrayx.cpp b/app/SysTray-X/systrayx.cpp
index 47dc9ab..f2febf1 100644
--- a/app/SysTray-X/systrayx.cpp
+++ b/app/SysTray-X/systrayx.cpp
@@ -86,12 +86,16 @@ SysTrayX::SysTrayX( QObject *parent ) : QObject( parent )
connect( m_preferences, &Preferences::signalIconDataChange, m_pref_dialog, &PreferencesDialog::slotIconDataChange );
connect( m_preferences, &Preferences::signalHideOnMinimizeChange, m_pref_dialog, &PreferencesDialog::slotHideOnMinimizeChange );
connect( m_preferences, &Preferences::signalStartMinimizedChange, m_pref_dialog, &PreferencesDialog::slotStartMinimizedChange );
+ connect( m_preferences, &Preferences::signalPollStartupDelayChange, m_pref_dialog, &PreferencesDialog::slotPollStartupDelayChange );
+ connect( m_preferences, &Preferences::signalPollIntervalChange, m_pref_dialog, &PreferencesDialog::slotPollIntervalChange );
connect( m_preferences, &Preferences::signalDebugChange, m_pref_dialog, &PreferencesDialog::slotDebugChange );
connect( m_preferences, &Preferences::signalIconTypeChange, m_link, &SysTrayXLink::slotIconTypeChange );
connect( m_preferences, &Preferences::signalIconDataChange, m_link, &SysTrayXLink::slotIconDataChange );
connect( m_preferences, &Preferences::signalHideOnMinimizeChange, m_link, &SysTrayXLink::slotHideOnMinimizeChange );
connect( m_preferences, &Preferences::signalStartMinimizedChange, m_link, &SysTrayXLink::slotStartMinimizedChange );
+ connect( m_preferences, &Preferences::signalPollStartupDelayChange, m_link, &SysTrayXLink::slotPollStartupDelayChange );
+ connect( m_preferences, &Preferences::signalPollIntervalChange, m_link, &SysTrayXLink::slotPollIntervalChange );
connect( m_preferences, &Preferences::signalDebugChange, m_link, &SysTrayXLink::slotDebugChange );
connect( m_preferences, &Preferences::signalDebugChange, m_debug, &DebugWidget::slotDebugChange );
diff --git a/app/SysTray-X/systrayxlink.cpp b/app/SysTray-X/systrayxlink.cpp
index 394dc27..9472521 100644
--- a/app/SysTray-X/systrayxlink.cpp
+++ b/app/SysTray-X/systrayxlink.cpp
@@ -377,6 +377,26 @@ void SysTrayXLink::DecodePreferences( const QJsonObject& pref )
m_pref->setStartMinimized( start_minimized );
}
+ if( pref.contains( "pollStartupDelay" ) && pref[ "pollStartupDelay" ].isString() )
+ {
+ QString poll_startup_delay = pref[ "pollStartupDelay" ].toString();
+
+ /*
+ * Store the new start minimized state
+ */
+ m_pref->setPollStartupDelay( poll_startup_delay.toInt() );
+ }
+
+ if( pref.contains( "pollInterval" ) && pref[ "pollInterval" ].isString() )
+ {
+ QString poll_interval = pref[ "pollInterval" ].toString();
+
+ /*
+ * Store the new poll interval
+ */
+ m_pref->setPollInterval( poll_interval.toInt() );
+ }
+
if( pref.contains( "debug" ) && pref[ "debug" ].isString() )
{
bool debug = pref[ "debug" ].toString() == "true";
@@ -399,6 +419,8 @@ void SysTrayXLink::EncodePreferences( const Preferences& pref )
*/
QJsonObject prefObject;
prefObject.insert("debug", QJsonValue::fromVariant( QString( pref.getDebug() ? "true" : "false" ) ) );
+ prefObject.insert("pollStartupDelay", QJsonValue::fromVariant( QString::number( pref.getPollStartupDelay() ) ) );
+ prefObject.insert("pollInterval", QJsonValue::fromVariant( QString::number( pref.getPollInterval() ) ) );
prefObject.insert("hideOnMinimize", QJsonValue::fromVariant( QString( pref.getHideOnMinimize() ? "true" : "false" ) ) );
prefObject.insert("startMinimized", QJsonValue::fromVariant( QString( pref.getStartMinimized() ? "true" : "false" ) ) );
prefObject.insert("iconType", QJsonValue::fromVariant( QString::number( pref.getIconType() ) ) );
@@ -448,6 +470,30 @@ void SysTrayXLink::slotDebugChange()
}
+/*
+ * Handle a poll startup delay change signal
+ */
+void SysTrayXLink::slotPollStartupDelayChange()
+{
+ if( m_pref->getAppPrefChanged() )
+ {
+ sendPreferences();
+ }
+}
+
+
+/*
+ * Handle a poll interval change signal
+ */
+void SysTrayXLink::slotPollIntervalChange()
+{
+ if( m_pref->getAppPrefChanged() )
+ {
+ sendPreferences();
+ }
+}
+
+
/*
* Handle a hide on minimize state change signal
*/
diff --git a/app/SysTray-X/systrayxlink.h b/app/SysTray-X/systrayxlink.h
index a8afd45..0f05a46 100644
--- a/app/SysTray-X/systrayxlink.h
+++ b/app/SysTray-X/systrayxlink.h
@@ -174,6 +174,16 @@ class SysTrayXLink : public QObject
*/
void slotDebugChange();
+ /**
+ * @brief slotPollStartupDelayChange. Handle a change in poll startup delay.
+ */
+ void slotPollStartupDelayChange();
+
+ /**
+ * @brief slotPollIntervalChange. Handle a change in poll interval.
+ */
+ void slotPollIntervalChange();
+
/**
* @brief slotHideOnMinimizeChange. Handle a change in hide on minimize state.
*/
diff --git a/webext/background.js b/webext/background.js
index cd2e08c..adc14ad 100644
--- a/webext/background.js
+++ b/webext/background.js
@@ -1,6 +1,11 @@
var SysTrayX = {
debugAccounts: false,
+ pollTiming: {
+ pollStartupDelay: "5",
+ pollInterval: "5"
+ },
+
platformInfo: undefined
};
@@ -13,6 +18,8 @@ SysTrayX.Messaging = {
init: function() {
// Get the accounts from the storage
SysTrayX.Messaging.getAccounts();
+
+ // Lookout for storage changes
browser.storage.onChanged.addListener(SysTrayX.Messaging.storageChanged);
// Send the window title to app
@@ -22,7 +29,11 @@ SysTrayX.Messaging = {
SysTrayX.Messaging.sendPreferences();
// this.unReadMessages(this.unreadFiltersTest).then(this.unreadCb);
- window.setInterval(SysTrayX.Messaging.pollAccounts, 1000);
+ // window.setInterval(SysTrayX.Messaging.pollAccounts, 1000);
+ window.setTimeout(
+ SysTrayX.Messaging.pollAccounts,
+ SysTrayX.pollTiming.pollStartupDelay * 1000
+ );
// Try to catch the window state
browser.windows.onFocusChanged.addListener(SysTrayX.Window.focusChanged);
@@ -35,6 +46,20 @@ SysTrayX.Messaging = {
// Get the new preferences
SysTrayX.Messaging.getAccounts();
+ if ("pollStartupDelay" in changes && changes["pollStartupDelay"].newValue) {
+ SysTrayX.pollTiming = {
+ ...SysTrayX.pollTiming,
+ pollStartupDelay: changes["pollStartupDelay"].newValue
+ };
+ }
+
+ if ("pollInterval" in changes && changes["pollInterval"].newValue) {
+ SysTrayX.pollTiming = {
+ ...SysTrayX.pollTiming,
+ pollInterval: changes["pollInterval"].newValue
+ };
+ }
+
if ("addonprefchanged" in changes && changes["addonprefchanged"].newValue) {
//
// Send new preferences to the app
@@ -73,6 +98,12 @@ SysTrayX.Messaging = {
SysTrayX.Messaging.unreadCb
);
}
+
+ // Next round...
+ window.setTimeout(
+ SysTrayX.Messaging.pollAccounts,
+ SysTrayX.pollTiming.pollInterval * 1000
+ );
},
//
@@ -112,6 +143,8 @@ SysTrayX.Messaging = {
sendPreferences: function() {
const getter = browser.storage.sync.get([
"debug",
+ "pollStartupDelay",
+ "pollInterval",
"hideOnMinimize",
"startMinimized",
"iconType",
@@ -123,6 +156,8 @@ SysTrayX.Messaging = {
sendPreferencesStorage: function(result) {
const debug = result.debug || "false";
+ const pollStartupDelay = result.pollStartupDelay || "5";
+ const pollInterval = result.pollInterval || "5";
const hideOnMinimize = result.hideOnMinimize || "true";
const startMinimized = result.startMinimized || "false";
const iconType = result.iconType || "0";
@@ -133,6 +168,8 @@ SysTrayX.Messaging = {
SysTrayX.Link.postSysTrayXMessage({
preferences: {
debug: debug,
+ pollStartupDelay: pollStartupDelay,
+ pollInterval: pollInterval,
hideOnMinimize: hideOnMinimize,
startMinimized: startMinimized,
iconType: iconType,
@@ -265,6 +302,20 @@ SysTrayX.Link = {
});
}
+ const pollStartupDelay = response["preferences"].pollStartupDelay;
+ if (pollStartupDelay) {
+ browser.storage.sync.set({
+ pollStartupDelay: pollStartupDelay
+ });
+ }
+
+ const pollInterval = response["preferences"].pollInterval;
+ if (pollInterval) {
+ browser.storage.sync.set({
+ pollInterval: pollInterval
+ });
+ }
+
const debug = response["preferences"].debug;
if (debug) {
browser.storage.sync.set({
@@ -295,6 +346,9 @@ async function start() {
});
}
+ // Get the poll timing
+ SysTrayX.pollTiming = await getPollTiming();
+
// Set platform
SysTrayX.platformInfo = await browser.runtime
.getPlatformInfo()
diff --git a/webext/js/defaults.js b/webext/js/defaults.js
index 0d1313e..b79aa90 100644
--- a/webext/js/defaults.js
+++ b/webext/js/defaults.js
@@ -67,3 +67,21 @@ async function getStartupState() {
const getState = browser.storage.sync.get("startMinimized");
return await getState.then(getStartupState, onStartupStateError);
}
+
+//
+// Get poll timing
+//
+async function getPollTiming() {
+ function getDelayAndInterval(result) {
+ return { pollStartupDelay: result.pollStartupDelay || "5", pollInterval: result.pollInterval || "5" };
+ }
+
+ function onDelayAndIntervalError() {
+ return { pollStartupDelay: "5", pollInterval: "5" };
+ }
+
+ const getTiming = browser.storage.sync.get([
+ "pollStartupDelay",
+ "pollInterval"]);
+ return await getTiming.then(getDelayAndInterval, onDelayAndIntervalError);
+}
diff --git a/webext/js/options_mailform.js b/webext/js/options_mailform.js
new file mode 100644
index 0000000..773cc0e
--- /dev/null
+++ b/webext/js/options_mailform.js
@@ -0,0 +1,15 @@
+function pollStartupDelay(e) {
+// console.debug("Startup: " + e.target.value);
+}
+
+function pollInterval(e) {
+// console.debug("Interval: " + e.target.value);
+}
+
+document
+ .getElementById("pollStartupDelay")
+ .addEventListener("change", pollStartupDelay);
+
+document
+ .getElementById("pollInterval")
+ .addEventListener("change", pollInterval);
diff --git a/webext/options.html b/webext/options.html
index 5fc1277..248424a 100644
--- a/webext/options.html
+++ b/webext/options.html
@@ -80,7 +80,48 @@
Included accounts
+
+
+
+
+
+
diff --git a/webext/options.js b/webext/options.js
index 57e7710..52a45e3 100644
--- a/webext/options.js
+++ b/webext/options.js
@@ -38,6 +38,25 @@ SysTrayX.SaveOptions = {
filters: filters
});
+ //
+ // Save poll startup delay state
+ //
+ const pollStartupDelay = document.querySelector(
+ 'input[name="pollStartupDelay"]'
+ ).value;
+ browser.storage.sync.set({
+ pollStartupDelay: pollStartupDelay
+ });
+
+ //
+ // Save poll interval state
+ //
+ const pollInterval = document.querySelector('input[name="pollInterval"]')
+ .value;
+ browser.storage.sync.set({
+ pollInterval: pollInterval
+ });
+
//
// Save debug state
//
@@ -138,6 +157,24 @@ SysTrayX.RestoreOptions = {
SysTrayX.RestoreOptions.setIcon,
SysTrayX.RestoreOptions.onIconError
);
+
+ //
+ // Restore poll startup delay state
+ //
+ const getPollStartupDelay = browser.storage.sync.get("pollStartupDelay");
+ getPollStartupDelay.then(
+ SysTrayX.RestoreOptions.setPollStartupDelay,
+ SysTrayX.RestoreOptions.onPollStartupDelayError
+ );
+
+ //
+ // Restore poll interval state
+ //
+ const getPollInterval = browser.storage.sync.get("pollInterval");
+ getPollInterval.then(
+ SysTrayX.RestoreOptions.setPollInterval,
+ SysTrayX.RestoreOptions.onPollIntervalError
+ );
},
//
@@ -242,6 +279,34 @@ SysTrayX.RestoreOptions = {
onIconError: function(error) {
console.log(`Icon Error: ${error}`);
+ },
+
+ //
+ // Restore poll startup delay state callbacks
+ //
+ setPollStartupDelay: function(result) {
+ const pollStartupDelay = result.pollStartupDelay || 5;
+
+ const input = document.querySelector(`input[name="pollStartupDelay"]`);
+ input.value = pollStartupDelay;
+ },
+
+ onPollStartupDelayError: function(error) {
+ console.log(`Poll startup delay Error: ${error}`);
+ },
+
+ //
+ // Restore poll interval state callbacks
+ //
+ setPollInterval: function(result) {
+ const pollInterval = result.pollInterval || 5;
+
+ const input = document.querySelector(`input[name="pollInterval"]`);
+ input.value = pollInterval;
+ },
+
+ onPollPollInterval: function(error) {
+ console.log(`Poll interval Error: ${error}`);
}
};
@@ -278,6 +343,16 @@ SysTrayX.StorageChanged = {
startMinimized: changes[item].newValue
});
}
+ if (item === "pollStartupDelay") {
+ SysTrayX.RestoreOptions.setPollStartupDelay({
+ pollStartupDelay: changes[item].newValue
+ });
+ }
+ if (item === "pollInterval") {
+ SysTrayX.RestoreOptions.setPollInterval({
+ pollInterval: changes[item].newValue
+ });
+ }
if (item === "debug") {
SysTrayX.RestoreOptions.setDebug({
debug: changes[item].newValue