1.调整主程序执行命令方式,链接dbus接口功能
This commit is contained in:
parent
6139108645
commit
0e321fc17e
|
@ -33,7 +33,7 @@ UkuiMenuApplication::UkuiMenuApplication(MenuMessageProcessor *processor) : QObj
|
||||||
registerQmlTypes();
|
registerQmlTypes();
|
||||||
startUkuiMenu();
|
startUkuiMenu();
|
||||||
initDbusService();
|
initDbusService();
|
||||||
connect(processor, &MenuMessageProcessor::request, this, &UkuiMenuApplication::response);
|
connect(processor, &MenuMessageProcessor::request, this, &UkuiMenuApplication::execCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UkuiMenuApplication::startUkuiMenu()
|
void UkuiMenuApplication::startUkuiMenu()
|
||||||
|
@ -71,23 +71,36 @@ void UkuiMenuApplication::initQmlEngine()
|
||||||
void UkuiMenuApplication::initDbusService()
|
void UkuiMenuApplication::initDbusService()
|
||||||
{
|
{
|
||||||
m_menuDbusService = new MenuDbusService(this);
|
m_menuDbusService = new MenuDbusService(this);
|
||||||
|
if (m_menuDbusService) {
|
||||||
|
connect(m_menuDbusService, &MenuDbusService::menuActive, this, [this] {
|
||||||
|
execCommand(Active);
|
||||||
|
});
|
||||||
|
// connect(m_menuDbusService, &MenuDbusService::reloadConfigSignal, this, [this] {
|
||||||
|
//// reload ...
|
||||||
|
// });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UkuiMenuApplication::response(MenuMessageProcessor::Command command)
|
void UkuiMenuApplication::execCommand(Command command)
|
||||||
{
|
{
|
||||||
switch (command) {
|
switch (command) {
|
||||||
case MenuMessageProcessor::Show:
|
case Active:
|
||||||
// m_applicationEngine;
|
qDebug() << "=Active=>>" << Active;
|
||||||
break;
|
break;
|
||||||
case MenuMessageProcessor::Quit:
|
case Show:
|
||||||
|
qDebug() << "=Show=>>" << Show;
|
||||||
|
break;
|
||||||
|
case Quit:
|
||||||
|
qDebug() << "=Quit=>>" << Quit;
|
||||||
m_applicationEngine->quit();
|
m_applicationEngine->quit();
|
||||||
|
QCoreApplication::quit();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// == MenuMessageProcessor == //
|
||||||
MenuMessageProcessor::MenuMessageProcessor() : QObject(nullptr) {}
|
MenuMessageProcessor::MenuMessageProcessor() : QObject(nullptr) {}
|
||||||
|
|
||||||
void MenuMessageProcessor::processMessage(quint32 instanceId, const QByteArray &message)
|
void MenuMessageProcessor::processMessage(quint32 instanceId, const QByteArray &message)
|
||||||
|
@ -105,13 +118,12 @@ void MenuMessageProcessor::processMessage(quint32 instanceId, const QByteArray &
|
||||||
parser.parse(options);
|
parser.parse(options);
|
||||||
|
|
||||||
if (parser.isSet(showUkuiMenu)) {
|
if (parser.isSet(showUkuiMenu)) {
|
||||||
Q_EMIT request(Show);
|
Q_EMIT request(UkuiMenuApplication::Show);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parser.isSet(quitUkuiMenu)) {
|
if (parser.isSet(quitUkuiMenu)) {
|
||||||
Q_EMIT request(Quit);
|
Q_EMIT request(UkuiMenuApplication::Quit);
|
||||||
QCoreApplication::quit();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,35 +24,24 @@
|
||||||
|
|
||||||
namespace UkuiMenu {
|
namespace UkuiMenu {
|
||||||
|
|
||||||
class MenuMessageProcessor : public QObject
|
class MenuMessageProcessor;
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
enum Command {
|
|
||||||
Show = 0,
|
|
||||||
Quit
|
|
||||||
};
|
|
||||||
MenuMessageProcessor();
|
|
||||||
static bool preprocessMessage(const QStringList& message);
|
|
||||||
|
|
||||||
public Q_SLOTS:
|
|
||||||
void processMessage(quint32 instanceId, const QByteArray& message);
|
|
||||||
|
|
||||||
Q_SIGNALS:
|
|
||||||
void request(Command command);
|
|
||||||
};
|
|
||||||
|
|
||||||
class UkuiMenuApplication : public QObject
|
class UkuiMenuApplication : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
enum Command {
|
||||||
|
Active = 0,
|
||||||
|
Show,
|
||||||
|
Quit
|
||||||
|
};
|
||||||
explicit UkuiMenuApplication(MenuMessageProcessor *processor);
|
explicit UkuiMenuApplication(MenuMessageProcessor *processor);
|
||||||
UkuiMenuApplication() = delete;
|
UkuiMenuApplication() = delete;
|
||||||
UkuiMenuApplication(const UkuiMenuApplication& obj) = delete;
|
UkuiMenuApplication(const UkuiMenuApplication& obj) = delete;
|
||||||
UkuiMenuApplication(const UkuiMenuApplication&& obj) = delete;
|
UkuiMenuApplication(const UkuiMenuApplication&& obj) = delete;
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void response(MenuMessageProcessor::Command command);
|
void execCommand(UkuiMenuApplication::Command command);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void registerQmlTypes();
|
static void registerQmlTypes();
|
||||||
|
@ -67,7 +56,19 @@ private:
|
||||||
MenuDbusService *m_menuDbusService = nullptr;
|
MenuDbusService *m_menuDbusService = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class MenuMessageProcessor : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
MenuMessageProcessor();
|
||||||
|
static bool preprocessMessage(const QStringList& message);
|
||||||
|
|
||||||
|
public Q_SLOTS:
|
||||||
|
void processMessage(quint32 instanceId, const QByteArray& message);
|
||||||
|
|
||||||
|
Q_SIGNALS:
|
||||||
|
void request(UkuiMenuApplication::Command command);
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue