mirror of
https://github.com/status-im/snorenotify.git
synced 2025-02-17 02:46:23 +00:00
change the way the singleton is created.
This commit is contained in:
parent
711e880dd7
commit
229b725c55
@ -48,13 +48,8 @@ SnoreCore::SnoreCore(QObject *parent):
|
|||||||
|
|
||||||
SnoreCore &SnoreCore::instance()
|
SnoreCore &SnoreCore::instance()
|
||||||
{
|
{
|
||||||
static SnoreCore *instance = nullptr;
|
static SnoreCore instance(qApp);
|
||||||
if (!instance) {
|
return instance;
|
||||||
SnoreCorePrivate::loadTranslator();
|
|
||||||
SnoreCorePrivate::registerMetaTypes();
|
|
||||||
instance = new SnoreCore(qApp);
|
|
||||||
}
|
|
||||||
return *instance;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SnoreCore::~SnoreCore()
|
SnoreCore::~SnoreCore()
|
||||||
|
@ -44,6 +44,8 @@ SnoreCorePrivate::SnoreCorePrivate():
|
|||||||
snoreDebug(SNORE_DEBUG) << "Snore local settings are located in" << normalizeKey("Test", LOCAL_SETTING);
|
snoreDebug(SNORE_DEBUG) << "Snore local settings are located in" << normalizeKey("Test", LOCAL_SETTING);
|
||||||
|
|
||||||
connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(slotAboutToQuit()));
|
connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(slotAboutToQuit()));
|
||||||
|
|
||||||
|
m_defaultApp = Application("SnoreNotify", Icon(":/root/snore.png"));
|
||||||
}
|
}
|
||||||
|
|
||||||
SnoreCorePrivate::~SnoreCorePrivate()
|
SnoreCorePrivate::~SnoreCorePrivate()
|
||||||
@ -141,7 +143,6 @@ void SnoreCorePrivate::init()
|
|||||||
Q_Q(SnoreCore);
|
Q_Q(SnoreCore);
|
||||||
setDefaultValueIntern("Timeout", 10);
|
setDefaultValueIntern("Timeout", 10);
|
||||||
setDefaultValueIntern("Silent", false);
|
setDefaultValueIntern("Silent", false);
|
||||||
q->setDefaultApplication(Application("SnoreNotify", Icon(":/root/snore.png")));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SnoreCorePrivate::setDefaultValueIntern(const QString &key, const QVariant &value)
|
void SnoreCorePrivate::setDefaultValueIntern(const QString &key, const QVariant &value)
|
||||||
@ -192,14 +193,6 @@ void SnoreCorePrivate::setLocalSttingsPrefix(const QString &prefix)
|
|||||||
syncSettings();
|
syncSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SnoreCorePrivate::registerMetaTypes()
|
|
||||||
{
|
|
||||||
qRegisterMetaType<Notification>();
|
|
||||||
qRegisterMetaType<Application>();
|
|
||||||
qRegisterMetaType<SnorePlugin::PluginTypes>();
|
|
||||||
qRegisterMetaTypeStreamOperators<SnorePlugin::PluginTypes>();
|
|
||||||
}
|
|
||||||
|
|
||||||
QString SnoreCorePrivate::tempPath()
|
QString SnoreCorePrivate::tempPath()
|
||||||
{
|
{
|
||||||
static QTemporaryDir dir;
|
static QTemporaryDir dir;
|
||||||
@ -233,7 +226,7 @@ void SnoreCorePrivate::slotAboutToQuit()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SnoreCorePrivate::loadTranslator()
|
static void loadTranslator()
|
||||||
{
|
{
|
||||||
auto installTranslator = [](const QString & locale) {
|
auto installTranslator = [](const QString & locale) {
|
||||||
snoreDebug(SNORE_DEBUG) << locale;
|
snoreDebug(SNORE_DEBUG) << locale;
|
||||||
@ -260,3 +253,20 @@ void SnoreCorePrivate::loadTranslator()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void registerMetaTypes()
|
||||||
|
{
|
||||||
|
qRegisterMetaType<Notification>();
|
||||||
|
qRegisterMetaType<Application>();
|
||||||
|
qRegisterMetaType<SnorePlugin::PluginTypes>();
|
||||||
|
qRegisterMetaTypeStreamOperators<SnorePlugin::PluginTypes>();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void snoreStartup(){
|
||||||
|
loadTranslator();
|
||||||
|
registerMetaTypes();
|
||||||
|
}
|
||||||
|
|
||||||
|
Q_COREAPP_STARTUP_FUNCTION(snoreStartup)
|
||||||
|
|
||||||
|
|
||||||
|
@ -35,16 +35,12 @@ class SNORE_EXPORT SnoreCorePrivate : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void registerMetaTypes();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief tempPath
|
* @brief tempPath
|
||||||
* @return the path of a QTemporaryDir, this location is used to store images.
|
* @return the path of a QTemporaryDir, this location is used to store images.
|
||||||
*/
|
*/
|
||||||
static QString tempPath();
|
static QString tempPath();
|
||||||
|
|
||||||
static void loadTranslator();
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static SnoreCorePrivate *instance();
|
static SnoreCorePrivate *instance();
|
||||||
~SnoreCorePrivate();
|
~SnoreCorePrivate();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user