Browse Source

silent mode added

pull/5/head
hypnosis-i2p 8 years ago
parent
commit
ffdaf1e4b4
  1. 1
      .gitignore
  2. 8
      src/qt/bitcoingui.cpp
  3. 6
      src/qt/notificator.cpp
  4. 5
      src/qt/notificator.h
  5. 1
      src/qt/optionsdialog.cpp
  6. 9
      src/qt/optionsmodel.cpp
  7. 3
      src/qt/optionsmodel.h

1
.gitignore vendored

@ -6,3 +6,4 @@ Makefile @@ -6,3 +6,4 @@ Makefile
qrc_bitcoin.cpp
gostcoin-qt
gostcoind
*.pro.user

8
src/qt/bitcoingui.cpp

@ -99,9 +99,6 @@ BitcoinGUI::BitcoinGUI(QWidget *parent) : @@ -99,9 +99,6 @@ BitcoinGUI::BitcoinGUI(QWidget *parent) :
// Create the toolbars
createToolBars();
// Create system tray icon and notification
createTrayIcon();
// Create status bar
statusBar();
@ -310,6 +307,9 @@ void BitcoinGUI::setClientModel(ClientModel *clientModel) @@ -310,6 +307,9 @@ void BitcoinGUI::setClientModel(ClientModel *clientModel)
this->clientModel = clientModel;
if(clientModel)
{
// Create system tray icon and notification
createTrayIcon();
// Replace some strings and icons, when using the testnet
if(clientModel->isTestNet())
{
@ -416,7 +416,7 @@ void BitcoinGUI::createTrayIcon() @@ -416,7 +416,7 @@ void BitcoinGUI::createTrayIcon()
trayIcon->show();
#endif
notificator = new Notificator(QApplication::applicationName(), trayIcon);
notificator = new Notificator(clientModel->getOptionsModel(), QApplication::applicationName(), trayIcon);
}
void BitcoinGUI::createTrayIconMenu()

6
src/qt/notificator.cpp

@ -24,7 +24,7 @@ @@ -24,7 +24,7 @@
// https://wiki.ubuntu.com/NotificationDevelopmentGuidelines recommends at least 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),
parent(parent),
programName(programName),
@ -33,6 +33,7 @@ Notificator::Notificator(const QString &programName, QSystemTrayIcon *trayicon, @@ -33,6 +33,7 @@ Notificator::Notificator(const QString &programName, QSystemTrayIcon *trayicon,
#ifdef USE_DBUS
,interface(0)
#endif
,fOptions(optionsModel)
{
if(trayicon && trayicon->supportsMessages())
{
@ -287,6 +288,9 @@ void Notificator::notifyMacUserNotificationCenter(Class cls, const QString &titl @@ -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)
{
//skip non-crit notifications in silent mode
if(cls != Critical) if(fOptions->isSilentMode()) return;
switch(mode)
{
#ifdef USE_DBUS

5
src/qt/notificator.h

@ -4,6 +4,8 @@ @@ -4,6 +4,8 @@
#include <QObject>
#include <QIcon>
#include "optionsmodel.h"
QT_BEGIN_NAMESPACE
class QSystemTrayIcon;
#ifdef USE_DBUS
@ -20,7 +22,7 @@ public: @@ -20,7 +22,7 @@ public:
/** Create a new notificator.
@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();
// Message class
@ -66,6 +68,7 @@ private: @@ -66,6 +68,7 @@ private:
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);
#endif
OptionsModel* fOptions;
};
#endif // NOTIFICATOR_H

1
src/qt/optionsdialog.cpp

@ -156,6 +156,7 @@ void OptionsDialog::setMapper() @@ -156,6 +156,7 @@ void OptionsDialog::setMapper()
mapper->addMapping(ui->minimizeToTray, OptionsModel::MinimizeToTray);
mapper->addMapping(ui->minimizeOnClose, OptionsModel::MinimizeOnClose);
#endif
mapper->addMapping(ui->silentMode, OptionsModel::SilentMode);
/* Display */
mapper->addMapping(ui->lang, OptionsModel::Language);

9
src/qt/optionsmodel.cpp

@ -111,6 +111,7 @@ void OptionsModel::Init() @@ -111,6 +111,7 @@ void OptionsModel::Init()
nDisplayUnit = settings.value("nDisplayUnit", BitcoinUnits::BTC).toInt();
bDisplayAddresses = settings.value("bDisplayAddresses", false).toBool();
fMinimizeToTray = settings.value("fMinimizeToTray", false).toBool();
fSilentMode = settings.value("fSilentMode", false).toBool();
fMinimizeOnClose = settings.value("fMinimizeOnClose", false).toBool();
nTransactionFee = settings.value("nTransactionFee").toLongLong();
language = settings.value("language", "").toString();
@ -223,7 +224,7 @@ bool OptionsModel::Upgrade() @@ -223,7 +224,7 @@ bool OptionsModel::Upgrade()
}
}
QList<QString> boolOptions;
boolOptions << "bDisplayAddresses" << "fMinimizeToTray" << "fMinimizeOnClose" << "fUseProxy" << "fUseUPnP";
boolOptions << "bDisplayAddresses" << "fMinimizeToTray" << "fSilentMode" << "fMinimizeOnClose" << "fUseProxy" << "fUseUPnP";
foreach(QString key, boolOptions)
{
bool value = false;
@ -275,6 +276,8 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const @@ -275,6 +276,8 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const
return QVariant(GUIUtil::GetStartOnSystemStartup());
case MinimizeToTray:
return QVariant(fMinimizeToTray);
case SilentMode:
return QVariant(fSilentMode);
case MapPortUPnP:
#ifdef USE_UPNP
return settings.value("fUseUPnP", GetBoolArg("-upnp", true));
@ -393,6 +396,10 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in @@ -393,6 +396,10 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
fMinimizeToTray = value.toBool();
settings.setValue("fMinimizeToTray", fMinimizeToTray);
break;
case SilentMode:
fSilentMode = value.toBool();
settings.setValue("fSilentMode", fSilentMode);
break;
case MapPortUPnP:
settings.setValue("fUseUPnP", value.toBool());
MapPort(value.toBool());

3
src/qt/optionsmodel.h

@ -49,6 +49,7 @@ public: @@ -49,6 +49,7 @@ public:
I2POutboundAllowZeroHop, // bool
I2POutboundIPRestriction, // int
I2POutboundPriority, // int
SilentMode, // bool
OptionIDRowCount,
};
@ -65,6 +66,7 @@ public: @@ -65,6 +66,7 @@ public:
/* Explicit getters */
qint64 getTransactionFee();
bool getMinimizeToTray() { return fMinimizeToTray; }
bool isSilentMode() { return fSilentMode; }
bool getMinimizeOnClose() { return fMinimizeOnClose; }
int getDisplayUnit() { return nDisplayUnit; }
bool getDisplayAddresses() { return bDisplayAddresses; }
@ -75,6 +77,7 @@ private: @@ -75,6 +77,7 @@ private:
int nDisplayUnit;
bool bDisplayAddresses;
bool fMinimizeToTray;
bool fSilentMode;
bool fMinimizeOnClose;
QString language;
bool fCoinControlFeatures;

Loading…
Cancel
Save