mirror of
https://github.com/GOSTSec/gostcoin
synced 2025-01-30 16:34:29 +00:00
Merge pull request #5 from hypnosis-i2p/master
silent mode added. #4 fixed
This commit is contained in:
commit
a46bef413f
1
.gitignore
vendored
1
.gitignore
vendored
@ -6,3 +6,4 @@ Makefile
|
|||||||
qrc_bitcoin.cpp
|
qrc_bitcoin.cpp
|
||||||
gostcoin-qt
|
gostcoin-qt
|
||||||
gostcoind
|
gostcoind
|
||||||
|
*.pro.user
|
@ -99,9 +99,6 @@ BitcoinGUI::BitcoinGUI(QWidget *parent) :
|
|||||||
// Create the toolbars
|
// Create the toolbars
|
||||||
createToolBars();
|
createToolBars();
|
||||||
|
|
||||||
// Create system tray icon and notification
|
|
||||||
createTrayIcon();
|
|
||||||
|
|
||||||
// Create status bar
|
// Create status bar
|
||||||
statusBar();
|
statusBar();
|
||||||
|
|
||||||
@ -310,6 +307,9 @@ void BitcoinGUI::setClientModel(ClientModel *clientModel)
|
|||||||
this->clientModel = clientModel;
|
this->clientModel = clientModel;
|
||||||
if(clientModel)
|
if(clientModel)
|
||||||
{
|
{
|
||||||
|
// Create system tray icon and notification
|
||||||
|
createTrayIcon();
|
||||||
|
|
||||||
// Replace some strings and icons, when using the testnet
|
// Replace some strings and icons, when using the testnet
|
||||||
if(clientModel->isTestNet())
|
if(clientModel->isTestNet())
|
||||||
{
|
{
|
||||||
@ -416,7 +416,7 @@ void BitcoinGUI::createTrayIcon()
|
|||||||
trayIcon->show();
|
trayIcon->show();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
notificator = new Notificator(QApplication::applicationName(), trayIcon);
|
notificator = new Notificator(clientModel->getOptionsModel(), QApplication::applicationName(), trayIcon);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitcoinGUI::createTrayIconMenu()
|
void BitcoinGUI::createTrayIconMenu()
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
// https://wiki.ubuntu.com/NotificationDevelopmentGuidelines recommends at least 128
|
// https://wiki.ubuntu.com/NotificationDevelopmentGuidelines recommends at least 128
|
||||||
const int FREEDESKTOP_NOTIFICATION_ICON_SIZE = 128;
|
const int FREEDESKTOP_NOTIFICATION_ICON_SIZE = 128;
|
||||||
|
|
||||||
Notificator::Notificator(const QString &programName, QSystemTrayIcon *trayicon, QWidget *parent):
|
Notificator::Notificator(OptionsModel* optionsModel, const QString &programName, QSystemTrayIcon *trayicon, QWidget *parent):
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
parent(parent),
|
parent(parent),
|
||||||
programName(programName),
|
programName(programName),
|
||||||
@ -33,6 +33,7 @@ Notificator::Notificator(const QString &programName, QSystemTrayIcon *trayicon,
|
|||||||
#ifdef USE_DBUS
|
#ifdef USE_DBUS
|
||||||
,interface(0)
|
,interface(0)
|
||||||
#endif
|
#endif
|
||||||
|
,fOptions(optionsModel)
|
||||||
{
|
{
|
||||||
if(trayicon && trayicon->supportsMessages())
|
if(trayicon && trayicon->supportsMessages())
|
||||||
{
|
{
|
||||||
@ -287,6 +288,9 @@ void Notificator::notifyMacUserNotificationCenter(Class cls, const QString &titl
|
|||||||
|
|
||||||
void Notificator::notify(Class cls, const QString &title, const QString &text, const QIcon &icon, int millisTimeout)
|
void Notificator::notify(Class cls, const QString &title, const QString &text, const QIcon &icon, int millisTimeout)
|
||||||
{
|
{
|
||||||
|
//skip non-crit notifications in silent mode
|
||||||
|
if(cls != Critical) if(fOptions->isSilentMode()) return;
|
||||||
|
|
||||||
switch(mode)
|
switch(mode)
|
||||||
{
|
{
|
||||||
#ifdef USE_DBUS
|
#ifdef USE_DBUS
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
|
|
||||||
|
#include "optionsmodel.h"
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QSystemTrayIcon;
|
class QSystemTrayIcon;
|
||||||
#ifdef USE_DBUS
|
#ifdef USE_DBUS
|
||||||
@ -20,7 +22,7 @@ public:
|
|||||||
/** Create a new notificator.
|
/** Create a new notificator.
|
||||||
@note Ownership of trayIcon is not transferred to this object.
|
@note Ownership of trayIcon is not transferred to this object.
|
||||||
*/
|
*/
|
||||||
Notificator(const QString &programName=QString(), QSystemTrayIcon *trayIcon=0, QWidget *parent=0);
|
Notificator(OptionsModel* options, const QString &programName=QString(), QSystemTrayIcon *trayIcon=0, QWidget *parent=0);
|
||||||
~Notificator();
|
~Notificator();
|
||||||
|
|
||||||
// Message class
|
// Message class
|
||||||
@ -66,6 +68,7 @@ private:
|
|||||||
void notifyGrowl(Class cls, const QString &title, const QString &text, const QIcon &icon);
|
void notifyGrowl(Class cls, const QString &title, const QString &text, const QIcon &icon);
|
||||||
void notifyMacUserNotificationCenter(Class cls, const QString &title, const QString &text, const QIcon &icon);
|
void notifyMacUserNotificationCenter(Class cls, const QString &title, const QString &text, const QIcon &icon);
|
||||||
#endif
|
#endif
|
||||||
|
OptionsModel* fOptions;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // NOTIFICATOR_H
|
#endif // NOTIFICATOR_H
|
||||||
|
@ -156,6 +156,7 @@ void OptionsDialog::setMapper()
|
|||||||
mapper->addMapping(ui->minimizeToTray, OptionsModel::MinimizeToTray);
|
mapper->addMapping(ui->minimizeToTray, OptionsModel::MinimizeToTray);
|
||||||
mapper->addMapping(ui->minimizeOnClose, OptionsModel::MinimizeOnClose);
|
mapper->addMapping(ui->minimizeOnClose, OptionsModel::MinimizeOnClose);
|
||||||
#endif
|
#endif
|
||||||
|
mapper->addMapping(ui->silentMode, OptionsModel::SilentMode);
|
||||||
|
|
||||||
/* Display */
|
/* Display */
|
||||||
mapper->addMapping(ui->lang, OptionsModel::Language);
|
mapper->addMapping(ui->lang, OptionsModel::Language);
|
||||||
|
@ -111,6 +111,7 @@ void OptionsModel::Init()
|
|||||||
nDisplayUnit = settings.value("nDisplayUnit", BitcoinUnits::BTC).toInt();
|
nDisplayUnit = settings.value("nDisplayUnit", BitcoinUnits::BTC).toInt();
|
||||||
bDisplayAddresses = settings.value("bDisplayAddresses", false).toBool();
|
bDisplayAddresses = settings.value("bDisplayAddresses", false).toBool();
|
||||||
fMinimizeToTray = settings.value("fMinimizeToTray", false).toBool();
|
fMinimizeToTray = settings.value("fMinimizeToTray", false).toBool();
|
||||||
|
fSilentMode = settings.value("fSilentMode", false).toBool();
|
||||||
fMinimizeOnClose = settings.value("fMinimizeOnClose", false).toBool();
|
fMinimizeOnClose = settings.value("fMinimizeOnClose", false).toBool();
|
||||||
nTransactionFee = settings.value("nTransactionFee").toLongLong();
|
nTransactionFee = settings.value("nTransactionFee").toLongLong();
|
||||||
language = settings.value("language", "").toString();
|
language = settings.value("language", "").toString();
|
||||||
@ -223,7 +224,7 @@ bool OptionsModel::Upgrade()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
QList<QString> boolOptions;
|
QList<QString> boolOptions;
|
||||||
boolOptions << "bDisplayAddresses" << "fMinimizeToTray" << "fMinimizeOnClose" << "fUseProxy" << "fUseUPnP";
|
boolOptions << "bDisplayAddresses" << "fMinimizeToTray" << "fSilentMode" << "fMinimizeOnClose" << "fUseProxy" << "fUseUPnP";
|
||||||
foreach(QString key, boolOptions)
|
foreach(QString key, boolOptions)
|
||||||
{
|
{
|
||||||
bool value = false;
|
bool value = false;
|
||||||
@ -275,6 +276,8 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const
|
|||||||
return QVariant(GUIUtil::GetStartOnSystemStartup());
|
return QVariant(GUIUtil::GetStartOnSystemStartup());
|
||||||
case MinimizeToTray:
|
case MinimizeToTray:
|
||||||
return QVariant(fMinimizeToTray);
|
return QVariant(fMinimizeToTray);
|
||||||
|
case SilentMode:
|
||||||
|
return QVariant(fSilentMode);
|
||||||
case MapPortUPnP:
|
case MapPortUPnP:
|
||||||
#ifdef USE_UPNP
|
#ifdef USE_UPNP
|
||||||
return settings.value("fUseUPnP", GetBoolArg("-upnp", true));
|
return settings.value("fUseUPnP", GetBoolArg("-upnp", true));
|
||||||
@ -393,6 +396,10 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
|
|||||||
fMinimizeToTray = value.toBool();
|
fMinimizeToTray = value.toBool();
|
||||||
settings.setValue("fMinimizeToTray", fMinimizeToTray);
|
settings.setValue("fMinimizeToTray", fMinimizeToTray);
|
||||||
break;
|
break;
|
||||||
|
case SilentMode:
|
||||||
|
fSilentMode = value.toBool();
|
||||||
|
settings.setValue("fSilentMode", fSilentMode);
|
||||||
|
break;
|
||||||
case MapPortUPnP:
|
case MapPortUPnP:
|
||||||
settings.setValue("fUseUPnP", value.toBool());
|
settings.setValue("fUseUPnP", value.toBool());
|
||||||
MapPort(value.toBool());
|
MapPort(value.toBool());
|
||||||
|
@ -49,6 +49,7 @@ public:
|
|||||||
I2POutboundAllowZeroHop, // bool
|
I2POutboundAllowZeroHop, // bool
|
||||||
I2POutboundIPRestriction, // int
|
I2POutboundIPRestriction, // int
|
||||||
I2POutboundPriority, // int
|
I2POutboundPriority, // int
|
||||||
|
SilentMode, // bool
|
||||||
OptionIDRowCount,
|
OptionIDRowCount,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -65,6 +66,7 @@ public:
|
|||||||
/* Explicit getters */
|
/* Explicit getters */
|
||||||
qint64 getTransactionFee();
|
qint64 getTransactionFee();
|
||||||
bool getMinimizeToTray() { return fMinimizeToTray; }
|
bool getMinimizeToTray() { return fMinimizeToTray; }
|
||||||
|
bool isSilentMode() { return fSilentMode; }
|
||||||
bool getMinimizeOnClose() { return fMinimizeOnClose; }
|
bool getMinimizeOnClose() { return fMinimizeOnClose; }
|
||||||
int getDisplayUnit() { return nDisplayUnit; }
|
int getDisplayUnit() { return nDisplayUnit; }
|
||||||
bool getDisplayAddresses() { return bDisplayAddresses; }
|
bool getDisplayAddresses() { return bDisplayAddresses; }
|
||||||
@ -75,6 +77,7 @@ private:
|
|||||||
int nDisplayUnit;
|
int nDisplayUnit;
|
||||||
bool bDisplayAddresses;
|
bool bDisplayAddresses;
|
||||||
bool fMinimizeToTray;
|
bool fMinimizeToTray;
|
||||||
|
bool fSilentMode;
|
||||||
bool fMinimizeOnClose;
|
bool fMinimizeOnClose;
|
||||||
QString language;
|
QString language;
|
||||||
bool fCoinControlFeatures;
|
bool fCoinControlFeatures;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user