Rabbit Remote Control 0.0.31
Loading...
Searching...
No Matches
PluginClient.cpp
1// Author: Kang Lin <kl222@126.com>
2
3#include <QLocale>
4#include <QDebug>
5#include <QApplication>
6#include <QDir>
7#include <QLoggingCategory>
8
9#include "PluginClient.h"
10#include "RabbitCommonTools.h"
11
12static Q_LOGGING_CATEGORY(log, "Client.Plugin")
13
14CPluginClient::CPluginClient(QObject *parent) : QObject(parent)
15{}
16
18{
19 qDebug(log) << "CPluginClient::~CPluginClient()";
20 if(m_Translator)
21 RabbitCommon::CTools::Instance()->RemoveTranslator(m_Translator);
22}
23
24// 因为 Name() 是重载函数,需要子类化才有,所以此函数不能在构造函数中调用
26{
27 m_Translator = RabbitCommon::CTools::Instance()->InstallTranslator(
28 Name(),
29 RabbitCommon::CTools::TranslationType::Plugin,
30 "plugins/Client");
31 if(m_Translator)
32 return 0;
33
34 return -1;
35}
36
37const QString CPluginClient::Id() const
38{
39 return Protocol() + ":" + Name();
40}
41
42const QString CPluginClient::DisplayName() const
43{
44 return Name();
45}
46
47const QIcon CPluginClient::Icon() const
48{
49 return QIcon::fromTheme("network-wired");
50}
51
52const QString CPluginClient::Details() const
53{
54 return QString();
55}
The plugin interface.
virtual const QString Details() const
Display more information in About dialog or log.
virtual const QString Id() const
ID. Default: Protocol() + ":" + Name()
virtual const QString DisplayName() const
The plugin display name.
virtual const QString Name() const =0
This name must be the same as the project name (${PROJECT_NAME}). The translation file (${PROJECT_NAM...
Q_INVOKABLE int InitTranslator()
Initialize the translation resource, which is only called by CClient.
virtual const QString Protocol() const =0
Plugin Protocol.
virtual ~CPluginClient()
When the derived class is implemented, the resources are clean are unloaded here.