Commit 3abd1032 by NitefullWind

1. 新增Toast通知接口。

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