Commit 3abd1032 by NitefullWind

1. 新增Toast通知接口。

parent 13c338a0
...@@ -63,3 +63,10 @@ bool FMPHome::stopBlink(int blinkId) ...@@ -63,3 +63,10 @@ bool FMPHome::stopBlink(int blinkId)
Q_D(FMPHome); Q_D(FMPHome);
return d->stopBlink(blinkId); return d->stopBlink(blinkId);
} }
void FMPHome::notification(const QString &msg, const QString &title,
QSystemTrayIcon::MessageIcon icon, int mecs)
{
Q_D(FMPHome);
return d->notification(msg, title, icon, mecs);
}
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#define FMP_HOME_H #define FMP_HOME_H
#include <QObject> #include <QObject>
#include <QSystemTrayIcon>
#include "fmp_home_i.h" #include "fmp_home_i.h"
...@@ -30,6 +31,8 @@ public: ...@@ -30,6 +31,8 @@ public:
int blink(FMPluginInterface *plugin, const QString &image); int blink(FMPluginInterface *plugin, const QString &image);
bool stopBlink(int blinkId); bool stopBlink(int blinkId);
void notification(const QString &msg, const QString &title = QString::fromLocal8Bit(FMP_APPNAME),
QSystemTrayIcon::MessageIcon icon = QSystemTrayIcon::Information, int mecs = 1000);
private: private:
FMPHomePrivate *d_ptr; FMPHomePrivate *d_ptr;
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#define FMP_HOME_I_H #define FMP_HOME_I_H
#include <fmp_plugin_i.h> #include <fmp_plugin_i.h>
#include <QSystemTrayIcon>
class FMPHomeInterface : public FMPluginInterface class FMPHomeInterface : public FMPluginInterface
{ {
...@@ -26,6 +27,18 @@ public: ...@@ -26,6 +27,18 @@ public:
* @return bool 如果参数blinkId标识的闪烁不存在或已结束则返回false, 否则返回true * @return bool 如果参数blinkId标识的闪烁不存在或已结束则返回false, 否则返回true
*/ */
virtual bool stopBlink(int blinkId) = 0; virtual bool stopBlink(int blinkId) = 0;
/**
* @brief notification
* 弹出一个Toast通知
* @param msg
* @param title
* @param icon
* @param mecs
*/
virtual void notification(const QString &msg, const QString &title = QString::fromLocal8Bit(FMP_APPNAME),
QSystemTrayIcon::MessageIcon icon = QSystemTrayIcon::Information, int mecs = 1000) = 0;
}; };
Q_DECLARE_INTERFACE(FMPHomeInterface, "com.fmp.home") Q_DECLARE_INTERFACE(FMPHomeInterface, "com.fmp.home")
......
...@@ -218,7 +218,7 @@ int NavWindow::addBlink(FMPluginInterface *plugin, const QString &image) ...@@ -218,7 +218,7 @@ int NavWindow::addBlink(FMPluginInterface *plugin, const QString &image)
blink(); blink();
} }
HOME_DEBUG() << "Add blink: " << blinkId; FMP_DEBUG() << "Add blink: " << blinkId;
return blinkId; return blinkId;
} }
...@@ -242,7 +242,7 @@ bool NavWindow::removeBlink(int blinkId) ...@@ -242,7 +242,7 @@ bool NavWindow::removeBlink(int blinkId)
} }
} while(0); } while(0);
HOME_DEBUG() << "Stop blink: " << blinkId << " isOk: " << isOk; FMP_DEBUG() << "Stop blink: " << blinkId << " isOk: " << isOk;
return isOk; return isOk;
} }
...@@ -287,7 +287,7 @@ void NavWindow::blink() ...@@ -287,7 +287,7 @@ void NavWindow::blink()
loop.exec(); loop.exec();
} }
if(_blinkObjIdSet.contains(blinkObject.id)) { if(_blinkObjIdSet.contains(blinkObject.id)) {
HOME_DEBUG() << "Active blink plugin: " << blinkObject.id; FMP_DEBUG() << "Active blink plugin: " << blinkObject.id;
// 如果blinkObject.id还在set中,说明没有调用该闪烁的stop方法,可以发送激活插件信号 // 如果blinkObject.id还在set中,说明没有调用该闪烁的stop方法,可以发送激活插件信号
emit pluginActived(blinkObject.plugin); emit pluginActived(blinkObject.plugin);
_blinkObjIdSet.remove(blinkObject.id); _blinkObjIdSet.remove(blinkObject.id);
...@@ -316,7 +316,7 @@ void NavWindow::onNavImageChanged() ...@@ -316,7 +316,7 @@ void NavWindow::onNavImageChanged()
"border: none;}" "border: none;}"
).arg(_navImage)); ).arg(_navImage));
} }
void NavWindow::showMessage(const QString &message) void NavWindow::showMessage(const QString &title, const QString &msg, QSystemTrayIcon::MessageIcon icon, int mecs)
{ {
_systemTrayIcon->showMessage(QString::fromLocal8Bit(FMP_APPNAME), message); _systemTrayIcon->showMessage(title, msg, icon, mecs);
} }
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <QSet> #include <QSet>
#include <QString> #include <QString>
#include <QFuture> #include <QFuture>
#include <QSystemTrayIcon>
namespace Ui { namespace Ui {
class NavWindow; class NavWindow;
...@@ -19,7 +20,6 @@ class QSequentialAnimationGroup; ...@@ -19,7 +20,6 @@ class QSequentialAnimationGroup;
class FMPSettingsInterface; class FMPSettingsInterface;
class QStateMachine; class QStateMachine;
class QState; class QState;
class QSystemTrayIcon;
class FMPluginInterface; class FMPluginInterface;
/** /**
...@@ -76,7 +76,9 @@ public slots: ...@@ -76,7 +76,9 @@ public slots:
* @brief showMessage * @brief showMessage
* @param message * @param message
*/ */
void showMessage(const QString &message); void showMessage(const QString &title, const QString &msg,
QSystemTrayIcon::MessageIcon icon = QSystemTrayIcon::Information, int mecs = 1000);
signals: signals:
void menuBtnClicked(QString btnName); void menuBtnClicked(QString btnName);
......
...@@ -19,6 +19,7 @@ FMPHomePrivate::FMPHomePrivate(FMPHome *q) ...@@ -19,6 +19,7 @@ FMPHomePrivate::FMPHomePrivate(FMPHome *q)
_userName(""), _userName(""),
_errorMsg("") _errorMsg("")
{ {
FMPLoggerInterface::InitContext(q->_ctx);
} }
FMPHomePrivate::~FMPHomePrivate() FMPHomePrivate::~FMPHomePrivate()
...@@ -29,9 +30,8 @@ FMPHomePrivate::~FMPHomePrivate() ...@@ -29,9 +30,8 @@ FMPHomePrivate::~FMPHomePrivate()
int FMPHomePrivate::Init() int FMPHomePrivate::Init()
{ {
Q_Q(FMPHome); Q_Q(FMPHome);
FMPLoggerInterface* logger = q->GetService<FMPLoggerInterface>(q->_ctx);
_settings = q->GetService<FMPSettingsInterface>(q->_ctx); _settings = q->GetService<FMPSettingsInterface>(q->_ctx);
FMPHomeSettings::instance()->init(_settings, logger); FMPHomeSettings::instance()->init(_settings);
_navWindow = new NavWindow; _navWindow = new NavWindow;
...@@ -62,7 +62,7 @@ int FMPHomePrivate::Uninit() ...@@ -62,7 +62,7 @@ int FMPHomePrivate::Uninit()
void FMPHomePrivate::StartPlugins(const QVariantList &pids) void FMPHomePrivate::StartPlugins(const QVariantList &pids)
{ {
HOME_DEBUG() << pids; FMP_DEBUG() << pids;
} }
int FMPHomePrivate::login() int FMPHomePrivate::login()
...@@ -103,6 +103,12 @@ bool FMPHomePrivate::stopBlink(int blinkId) ...@@ -103,6 +103,12 @@ bool FMPHomePrivate::stopBlink(int blinkId)
return _navWindow->removeBlink(blinkId); return _navWindow->removeBlink(blinkId);
} }
void FMPHomePrivate::notification(const QString &msg, const QString &title,
QSystemTrayIcon::MessageIcon icon, int mecs)
{
_navWindow->showMessage(title, msg, icon, mecs);
}
void FMPHomePrivate::onPluginActived(FMPBaseInterface *plugin) void FMPHomePrivate::onPluginActived(FMPBaseInterface *plugin)
{ {
if(plugin != nullptr) { if(plugin != nullptr) {
...@@ -113,10 +119,10 @@ void FMPHomePrivate::onPluginActived(FMPBaseInterface *plugin) ...@@ -113,10 +119,10 @@ void FMPHomePrivate::onPluginActived(FMPBaseInterface *plugin)
void FMPHomePrivate::onMenuBtnClicked(QString btnName) void FMPHomePrivate::onMenuBtnClicked(QString btnName)
{ {
Q_Q(FMPHome); Q_Q(FMPHome);
FMP_DEBUG_CTX(q->_ctx) << "Menu clicked: " << btnName; FMP_DEBUG() << "Menu clicked: " << btnName;
if(btnName == "quit") { if(btnName == "quit") {
FMP_DEBUG_CTX(q->_ctx) << "Will Quit!"; FMP_DEBUG() << "Will Quit!";
q->PostEvent(FMP_TOPICS_QUIT); q->PostEvent(FMP_TOPICS_QUIT);
return; return;
} }
...@@ -132,16 +138,14 @@ void FMPHomePrivate::onMenuBtnClicked(QString btnName) ...@@ -132,16 +138,14 @@ void FMPHomePrivate::onMenuBtnClicked(QString btnName)
e->StartService(); e->StartService();
} else if(btnName == "vip") { } else if(btnName == "vip") {
FMPVipInterface *e = q->GetService<FMPVipInterface>(q->_ctx); FMPVipInterface *e = q->GetService<FMPVipInterface>(q->_ctx);
if(e->StartService() == FMP_SUCCESS) { e->StartService();
_navWindow->showMessage(QString::fromLocal8Bit("[非码会员]已启动")); } else if(btnName == "takeout") {
} // FMPTakeoutInterface *e = q->GetService<FMPTakeoutInterface>(q->_ctx);
} else if(btnName == "takeaway") {
// FMPTakeawayInterface *e = q->GetService<FMPTakeawayInterface>(q->_ctx);
// e->StartService(); // e->StartService();
} else if(btnName == "coupons") { } else if(btnName == "coupons") {
// FMPVipInterface *e = q->GetService<FMPVipInterface>(q->_ctx); // FMPVipInterface *e = q->GetService<FMPVipInterface>(q->_ctx);
// e->StartService(); // e->StartService();
} else if(btnName == "tool") { } else if(btnName == "tool") {
HOME_DEBUG() << "tool menu"; FMP_DEBUG() << "tool menu";
} }
} }
#ifndef FMP_HOME_P_H #ifndef FMP_HOME_P_H
#define FMP_HOME_P_H #define FMP_HOME_P_H
#include <QSystemTrayIcon>
#include "fmp_home.h" #include "fmp_home.h"
class NavWindow; class NavWindow;
...@@ -23,6 +25,9 @@ public: ...@@ -23,6 +25,9 @@ public:
int blink(FMPluginInterface *plugin, const QString &image); int blink(FMPluginInterface *plugin, const QString &image);
bool stopBlink(int blinkId); bool stopBlink(int blinkId);
void notification(const QString &msg, const QString &title = QString::fromLocal8Bit(FMP_APPNAME),
QSystemTrayIcon::MessageIcon icon = QSystemTrayIcon::Information, int mecs = 1000);
public slots: public slots:
void onMenuBtnClicked(QString btnName); void onMenuBtnClicked(QString btnName);
void onPluginActived(FMPBaseInterface* plugin); void onPluginActived(FMPBaseInterface* plugin);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment