mirror of
https://github.com/Ximi1970/systray-x.git
synced 2026-07-06 04:38:27 +02:00
Merge branch 'feature-issue-8' into develop
This commit is contained in:
@@ -30,6 +30,9 @@ Preferences::Preferences( QObject *parent ) : QObject( parent )
|
||||
m_hide_minimize = true;
|
||||
m_start_minimized = false;
|
||||
|
||||
m_poll_startup_delay = 5;
|
||||
m_poll_interval = 5;
|
||||
|
||||
m_debug = false;
|
||||
}
|
||||
|
||||
@@ -178,6 +181,58 @@ void Preferences::setStartMinimized( bool state )
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Get the poll startup delay.
|
||||
*/
|
||||
int Preferences::getPollStartupDelay() const
|
||||
{
|
||||
return m_poll_startup_delay;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Set the startup poll delay.
|
||||
*/
|
||||
void Preferences::setPollStartupDelay( int val )
|
||||
{
|
||||
if( m_poll_startup_delay != val )
|
||||
{
|
||||
m_poll_startup_delay = val;
|
||||
|
||||
/*
|
||||
* Tell the world the new preference
|
||||
*/
|
||||
emit signalPollStartupDelayChange();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Get the poll interval.
|
||||
*/
|
||||
int Preferences::getPollInterval() const
|
||||
{
|
||||
return m_poll_interval;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Set the startup poll delay.
|
||||
*/
|
||||
void Preferences::setPollInterval( int val )
|
||||
{
|
||||
if( m_poll_interval != val )
|
||||
{
|
||||
m_poll_interval = val;
|
||||
|
||||
/*
|
||||
* Tell the world the new preference
|
||||
*/
|
||||
emit signalPollIntervalChange();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Get the debug state.
|
||||
*/
|
||||
|
||||
@@ -121,6 +121,34 @@ class Preferences : public QObject
|
||||
*/
|
||||
void setStartMinimized( bool state );
|
||||
|
||||
/**
|
||||
* @brief getPollStartupDelay. Get the poll startup delay.
|
||||
*
|
||||
* @return The poll startup delay.
|
||||
*/
|
||||
int getPollStartupDelay() const;
|
||||
|
||||
/**
|
||||
* @brief setPollStartupDelay. Set the poll startup delay.
|
||||
*
|
||||
* @param The poll startup delay.
|
||||
*/
|
||||
void setPollStartupDelay( int val );
|
||||
|
||||
/**
|
||||
* @brief getPollInterval. Get the poll interval.
|
||||
*
|
||||
* @return The poll interval.
|
||||
*/
|
||||
int getPollInterval() const;
|
||||
|
||||
/**
|
||||
* @brief setPollInterval. Set the poll interval.
|
||||
*
|
||||
* @param The poll interval.
|
||||
*/
|
||||
void setPollInterval( int val );
|
||||
|
||||
/**
|
||||
* @brief getDebug. Get the debug windows state.
|
||||
*
|
||||
@@ -157,6 +185,16 @@ class Preferences : public QObject
|
||||
*/
|
||||
void signalStartMinimizedChange();
|
||||
|
||||
/**
|
||||
* @brief signalPollStartupDelayChange. Signal a poll startup delay change.
|
||||
*/
|
||||
void signalPollStartupDelayChange();
|
||||
|
||||
/**
|
||||
* @brief signalPollIntervalChange. Signal a poll interval change.
|
||||
*/
|
||||
void signalPollIntervalChange();
|
||||
|
||||
/**
|
||||
* @brief signalDebugChange. Signal a debug state change.
|
||||
*/
|
||||
@@ -194,6 +232,16 @@ class Preferences : public QObject
|
||||
*/
|
||||
bool m_start_minimized;
|
||||
|
||||
/**
|
||||
* @brief m_poll_startup_delay. The startup poll delay.
|
||||
*/
|
||||
int m_poll_startup_delay;
|
||||
|
||||
/**
|
||||
* @brief m_poll_interval. The poll interval.
|
||||
*/
|
||||
int m_poll_interval;
|
||||
|
||||
/**
|
||||
* @brief m_debug. Display debug window.
|
||||
*/
|
||||
|
||||
@@ -7,177 +7,225 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>292</width>
|
||||
<height>326</height>
|
||||
<height>487</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>SysTray-X Preferences</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetFixedSize</enum>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Windows</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Windows</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="hideOnMinimizeCheckBox">
|
||||
<property name="text">
|
||||
<string>Minimizing window hides to tray</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="startMinimizedCheckBox">
|
||||
<property name="text">
|
||||
<string>Start application minimized</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QGroupBox" name="iconTypeGroupBox">
|
||||
<property name="title">
|
||||
<string>Mail notification icon</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="hideOnMinimizeCheckBox">
|
||||
<property name="text">
|
||||
<string>Minimizing window hides to tray</string>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetFixedSize</enum>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="startMinimizedCheckBox">
|
||||
<property name="text">
|
||||
<string>Start application minimized</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="iconTypeGroupBox">
|
||||
<property name="title">
|
||||
<string>Mail notification icon</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetFixedSize</enum>
|
||||
<widget class="QRadioButton" name="blankRadioButton">
|
||||
<property name="text">
|
||||
<string>Blank icon</string>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="blankRadioButton">
|
||||
<property name="text">
|
||||
<string>Blank icon</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">iconTypeGroup</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">iconTypeGroup</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetFixedSize</enum>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="newMailButton">
|
||||
<property name="text">
|
||||
<string>New mail icon</string>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">iconTypeGroup</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetFixedSize</enum>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="newMailButton">
|
||||
<property name="text">
|
||||
<string>New mail icon</string>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">iconTypeGroup</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetMaximumSize</enum>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="customRadioButton">
|
||||
<property name="text">
|
||||
<string>Custom icon</string>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">iconTypeGroup</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="imageLabel">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="chooseCustomButton">
|
||||
<property name="text">
|
||||
<string>Choose</string>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetMaximumSize</enum>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="customRadioButton">
|
||||
<property name="text">
|
||||
<string>Custom icon</string>
|
||||
</property>
|
||||
<attribute name="buttonGroup">
|
||||
<string notr="true">iconTypeGroup</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="imageLabel">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="chooseCustomButton">
|
||||
<property name="text">
|
||||
<string>Choose</string>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="debugWindowCheckBox">
|
||||
<property name="text">
|
||||
<string>Display debug window</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<property name="title">
|
||||
<string>Mail actions</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QLabel" name="pollStartupDelayLabel">
|
||||
<property name="text">
|
||||
<string>Poll startup delay</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="pollStartupDelaySpinBox">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>5</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||
<item>
|
||||
<widget class="QLabel" name="pollIntervalLabel">
|
||||
<property name="text">
|
||||
<string>Poll interval</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="pollIntervalSpinBox">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>5</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QCheckBox" name="debugWindowCheckBox">
|
||||
<property name="text">
|
||||
<string>Display debug window</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>239</width>
|
||||
<height>36</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
15
webext/js/options_mailform.js
Normal file
15
webext/js/options_mailform.js
Normal file
@@ -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);
|
||||
@@ -80,7 +80,48 @@
|
||||
<h3>Included accounts</h3>
|
||||
|
||||
<ul id="accountsTree"></ul>
|
||||
|
||||
<br />
|
||||
<table id="iconselect">
|
||||
<tr>
|
||||
<td>
|
||||
<label for="pollStartupDelay" }>Poll startup delay</label>
|
||||
</td>
|
||||
<td>
|
||||
<input
|
||||
type="number"
|
||||
id="pollStartupDelay"
|
||||
name="pollStartupDelay"
|
||||
step="1"
|
||||
min="1"
|
||||
max="99"
|
||||
value="5"
|
||||
style="width: 3em;"
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="pollInterval" }>Poll interval</label>
|
||||
</td>
|
||||
<td>
|
||||
<input
|
||||
type="number"
|
||||
id="pollInterval"
|
||||
name="pollInterval"
|
||||
step="1"
|
||||
min="1"
|
||||
max="99"
|
||||
value="5"
|
||||
style="width: 3em;"
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
<script src="js/options_mailform.js"></script>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="DebugContent" class="tabcontent">
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user