Add new option

This commit is contained in:
Ximi1970
2023-11-02 17:11:08 +01:00
parent b25e41d87d
commit 7989435e87
16 changed files with 202 additions and 0 deletions

View File

@@ -913,6 +913,32 @@ void Preferences::setCloseAppArgs( QString args )
}
/*
* Get the API count method state.
*/
bool Preferences::getApiCountMethod() const
{
return m_api_count_method;
}
/*
* Set the API count method state.
*/
void Preferences::setApiCountMethod( bool state )
{
if( m_api_count_method != state )
{
m_api_count_method = state;
/*
* Tell the world the new preference
*/
emit signalApiCountMethodChange();
}
}
/*
* Get the debug state.
*/

View File

@@ -564,6 +564,20 @@ class Preferences : public QObject
*/
void setCloseAppArgs( QString args );
/**
* @brief getApiCountMethod. Get the API count method state.
*
* @return The state.
*/
bool getApiCountMethod() const;
/**
* @brief setApiCountMethod. Set the API count method state.
*
* @param state The state.
*/
void setApiCountMethod( bool state );
/**
* @brief getDebug. Get the debug windows state.
*
@@ -745,6 +759,11 @@ class Preferences : public QObject
*/
void signalCloseAppArgsChange();
/**
* @brief signalApiCountMethodChange
*/
void signalApiCountMethodChange();
private:
/**
@@ -931,6 +950,11 @@ class Preferences : public QObject
*/
QString m_close_app_args;
/**
* @brief m_api_count_method. The API count method state.
*/
bool m_api_count_method;
/**
* @brief m_debug. Display debug window.
*/

View File

@@ -115,6 +115,15 @@ PreferencesDialog::PreferencesDialog( SysTrayXLink *link, Preferences *pref, QWi
m_ui->newIndicatorTypeGroup->setId( m_ui->newIconStarRadioButton, Preferences::PREF_NEW_INDICATOR_STAR );
m_ui->newIndicatorTypeGroup->setId( m_ui->newShadeRadioButton, Preferences::PREF_NEW_INDICATOR_SHADE);
if( m_pref->getBrowserVersion().split(".")[0].toInt() < 115 )
{
m_ui->specialOptionsGroupBox->setVisible( false );
}
else
{
setApiCountMethod( m_pref->getApiCountMethod() );
}
/*
* Signals and slots
*/
@@ -519,6 +528,15 @@ void PreferencesDialog::setCloseAppArgs( QString args )
}
/*
* Set the API count method state
*/
void PreferencesDialog::setApiCountMethod( bool state )
{
m_ui->apiCountMethod->setChecked( state );
}
/*
* Handle show dialog signal
*/
@@ -994,3 +1012,12 @@ void PreferencesDialog::slotCloseAppArgsChange()
{
setCloseAppArgs( m_pref->getCloseAppArgs() );
}
/*
* Handle the API count method change signal
*/
void PreferencesDialog::slotApiCountMethodChange()
{
setApiCountMethod( m_pref->getApiCountMethod() );
}

View File

@@ -258,6 +258,12 @@ class PreferencesDialog : public QDialog
*/
void setCloseAppArgs( QString args );
/**
* @brief setApiCountMethod. Set the API count method state.
*
* @param state The state.
*/
void setApiCountMethod( bool state );
signals:
@@ -410,6 +416,11 @@ class PreferencesDialog : public QDialog
*/
void slotCloseAppArgsChange();
/**
* @brief slotApiCountMethodChange. Slot for handling the API count methid change.
*/
void slotApiCountMethodChange();
private slots:
/**

View File

@@ -140,6 +140,7 @@ SysTrayX::SysTrayX( QObject *parent ) : QObject( parent )
connect( m_preferences, &Preferences::signalStartAppArgsChange, m_pref_dialog, &PreferencesDialog::slotStartAppArgsChange );
connect( m_preferences, &Preferences::signalCloseAppChange, m_pref_dialog, &PreferencesDialog::slotCloseAppChange );
connect( m_preferences, &Preferences::signalCloseAppArgsChange, m_pref_dialog, &PreferencesDialog::slotCloseAppArgsChange );
connect( m_preferences, &Preferences::signalApiCountMethodChange, m_pref_dialog, &PreferencesDialog::slotApiCountMethodChange );
connect( m_preferences, &Preferences::signalDebugChange, m_pref_dialog, &PreferencesDialog::slotDebugChange );
connect( m_preferences, &Preferences::signalDefaultIconTypeChange, m_link, &SysTrayXLink::slotDefaultIconTypeChange );
@@ -167,6 +168,7 @@ SysTrayX::SysTrayX( QObject *parent ) : QObject( parent )
connect( m_preferences, &Preferences::signalStartAppArgsChange, m_link, &SysTrayXLink::slotStartAppArgsChange );
connect( m_preferences, &Preferences::signalCloseAppChange, m_link, &SysTrayXLink::slotCloseAppChange );
connect( m_preferences, &Preferences::signalCloseAppArgsChange, m_link, &SysTrayXLink::slotCloseAppArgsChange );
connect( m_preferences, &Preferences::signalApiCountMethodChange, m_link, &SysTrayXLink::slotApiCountMethodChange );
connect( m_preferences, &Preferences::signalDebugChange, m_link, &SysTrayXLink::slotDebugChange );
connect( m_preferences, &Preferences::signalHideDefaultIconChange, this, &SysTrayX::slotSelectIconObjectPref );

View File

@@ -857,6 +857,16 @@ void SysTrayXLink::DecodePreferences( const QJsonObject& pref )
m_pref->setCloseAppArgs( args );
}
if( pref.contains( "apiCountMethod" ) && pref[ "apiCountMethod" ].isString() )
{
bool api_count_method = pref[ "apiCountMethod" ].toString() == "true";
/*
* Store the new API cont method state
*/
m_pref->setApiCountMethod( api_count_method );
}
if( pref.contains( "debug" ) && pref[ "debug" ].isString() )
{
bool debug = pref[ "debug" ].toString() == "true";
@@ -937,6 +947,7 @@ void SysTrayXLink::EncodePreferences( const Preferences& pref )
prefObject.insert("numberMargins", marginsObject );
prefObject.insert("countType", QJsonValue::fromVariant( QString::number( pref.getCountType() ) ) );
prefObject.insert("startupDelay", QJsonValue::fromVariant( QString::number( pref.getStartupDelay() ) ) );
prefObject.insert("apiCountMethod", QJsonValue::fromVariant( QString( pref.getApiCountMethod() ? "true" : "false" ) ) );
prefObject.insert("startApp", QJsonValue::fromVariant( pref.getStartApp() ) );
prefObject.insert("startAppArgs", QJsonValue::fromVariant( pref.getStartAppArgs() ) );
@@ -1283,6 +1294,17 @@ void SysTrayXLink::slotCloseAppArgsChange()
}
/*
* Handle a API count method change signal
*/
void SysTrayXLink::slotApiCountMethodChange()
{
if( m_pref->getAppPrefChanged() )
{
sendPreferences();
}
}
/*
* Handle a debug state change signal
*/

View File

@@ -389,6 +389,11 @@ class SysTrayXLink : public QObject
*/
void slotCloseAppArgsChange();
/**
* @brief slotApiCountMethodChange. Slot for handling the API count method change signals.
*/
void slotApiCountMethodChange();
private slots:
/**

View File

@@ -244,6 +244,11 @@
"description": "Count new mails"
},
"count_api_count_method": {
"message": "API-Zählmethode",
"description": "API count method"
},
"count_number_options": {
"message": "Nummereigenschaften",
"description": "Caption for Number options"

View File

@@ -244,6 +244,11 @@
"description": "Count new mails"
},
"count_api_count_method": {
"message": "Μέθοδος καταμέτρησης API",
"description": "API count method"
},
"count_number_options": {
"message": "Αριθμός",
"description": "Caption for Number options"

View File

@@ -244,6 +244,11 @@
"description": "Count new mails"
},
"count_api_count_method": {
"message": "API count method",
"description": "API count method"
},
"count_number_options": {
"message": "Number",
"description": "Caption for Number options"

View File

@@ -244,6 +244,11 @@
"description": "Count new mails"
},
"count_api_count_method": {
"message": "Metodo di conteggio API",
"description": "API count method"
},
"count_number_options": {
"message": "Proprietà numero",
"description": "Caption for Number options"

View File

@@ -244,6 +244,11 @@
"description": "Count new mails"
},
"count_api_count_method": {
"message": "API tel methode",
"description": "API count method"
},
"count_number_options": {
"message": "Nummer opties",
"description": "Caption for Number options"

View File

@@ -244,6 +244,11 @@
"description": "Count new mails"
},
"count_api_count_method": {
"message": "Método de contagem de API",
"description": "API count method"
},
"count_number_options": {
"message": "Número",
"description": "Caption for Number options"

View File

@@ -244,6 +244,11 @@
"description": "Count new mails"
},
"count_api_count_method": {
"message": "Метод подсчета API",
"description": "API count method"
},
"count_number_options": {
"message": "Настройки индикатора кол-ва",
"description": "Caption for Number options"

View File

@@ -419,6 +419,15 @@
</tr>
</table>
<div id="apicountmethod">
<div id="inputcheck">
<input type="checkbox" name="apiCountMethod" id="apiCountMethod" value="" />
<label for="apiCountMethod" id="apiCountMethodLabel">
__MSG_count_api_count_method__
</label>
</div>
</div>
<table id="numberprops">
<caption>
__MSG_count_number_options__

View File

@@ -222,6 +222,14 @@ SysTrayX.SaveOptions = {
startupDelay: startupDelay,
});
//
// Save API count method state
//
const apiCountMethod = document.querySelector('input[name="apiCountMethod"]').checked;
await storage().set({
apiCountMethod: `${apiCountMethod}`,
});
//
// Save number color
//
@@ -496,6 +504,16 @@ SysTrayX.RestoreOptions = {
SysTrayX.RestoreOptions.ontartupDelayError
);
//
// Restore API count method state
//
await storage()
.get("apiCountMethod")
.then(
SysTrayX.RestoreOptions.setApiCountMethod,
SysTrayX.RestoreOptions.onApiCountMethodError
);
//
// Restore number color
//
@@ -924,6 +942,20 @@ SysTrayX.RestoreOptions = {
console.log(`StartupDelay Error: ${error}`);
},
//
// Restore API count method state callbacks
//
setApiCountMethod: function (result) {
const apiCountMethod = result.apiCountMethod || "false";
const checkbox = document.querySelector(`input[name="apiCountMethod"]`);
checkbox.checked = apiCountMethod === "true";
},
onApiCountMethodError: function (error) {
console.log(`ApiCountMethod Error: ${error}`);
},
//
// Restore number color
//
@@ -1278,6 +1310,11 @@ SysTrayX.StorageChanged = {
startupDelay: changes[item].newValue,
});
}
if (item === "apiCountMethod") {
SysTrayX.RestoreOptions.setApiCountMethod({
apiCountMethod: changes[item].newValue,
});
}
if (item === "numberColor") {
SysTrayX.RestoreOptions.setNumberColor({
numberColor: changes[item].newValue,
@@ -1401,6 +1438,10 @@ async function start() {
document.getElementById("kdeintegration").style.display = "none";
}
if (SysTrayX.Info.browserInfo.majorVersion < 115) {
document.getElementById("apicountmethod").style.display = "none";
}
// Setup account tree
const accountsInitPromise = () =>
new Promise((res) => res(SysTrayX.Accounts.init()));