Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fmp_settings
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhenfei.zhang
fmp_settings
Commits
bcada99b
Commit
bcada99b
authored
Aug 09, 2017
by
guanghui.cui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
插件更新
parent
c6adf35d
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
36 additions
and
40 deletions
+36
-40
fmp_settings.cpp
+10
-13
fmp_settings.h
+8
-8
fmp_settings_def.h
+4
-5
fmp_settings_i.h
+5
-3
fmp_settings_plugin.cpp
+6
-6
res/MANIFEST.MF
+1
-1
ui/window.cpp
+2
-2
ui/window.h
+0
-2
No files found.
fmp_settings.cpp
View file @
bcada99b
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
#include <QSettings>
#include <QSettings>
#include <fmp_logger_i.h>
#include <fmp_logger_i.h>
#include <ctkServiceReference.h>
#include <ctkServiceReference.h>
#include <ctkPluginContext.h>
#include "ui/window.h"
#include "ui/window.h"
#include <QDebug>
#include <QDebug>
...
@@ -13,10 +12,10 @@
...
@@ -13,10 +12,10 @@
/**
/**
* @brief The FMPSettings class
* @brief The FMPSettings class
*/
*/
FMPSettings
::
FMPSettings
(
ctkPluginContext
*
context
)
FMPSettings
::
FMPSettings
(
const
FMPContext
ctx
)
:
d_ptr
(
new
FMPSettingsPrivate
(
context
))
:
context
(
ctx
),
d_ptr
(
new
FMPSettingsPrivate
())
{
{
FMPLoggerInterface
::
InitContext
(
context
);
StartService
();
StartService
();
}
}
...
@@ -48,14 +47,14 @@ int FMPSettings::PostEvent(const QString &topic, const FMPProps &pps)
...
@@ -48,14 +47,14 @@ int FMPSettings::PostEvent(const QString &topic, const FMPProps &pps)
}
}
QVariant
FMPSettings
::
GetValue
(
const
QString
&
k
,
QVariant
default_val
)
QVariant
FMPSettings
::
GetValue
(
const
QString
&
k
,
const
QVariant
&
default_val
)
{
{
Q_D
(
FMPSettings
);
Q_D
(
FMPSettings
);
return
d
->
GetValue
(
k
,
default_val
);
return
d
->
GetValue
(
k
,
default_val
);
}
}
bool
FMPSettings
::
SetValue
(
const
QString
&
k
,
QVariant
v
)
bool
FMPSettings
::
SetValue
(
const
QString
&
k
,
const
QVariant
&
v
)
{
{
Q_D
(
FMPSettings
);
Q_D
(
FMPSettings
);
...
@@ -65,9 +64,8 @@ bool FMPSettings::SetValue(const QString &k, QVariant v)
...
@@ -65,9 +64,8 @@ bool FMPSettings::SetValue(const QString &k, QVariant v)
/**
/**
***************************************************************
***************************************************************
*/
*/
FMPSettingsPrivate
::
FMPSettingsPrivate
(
ctkPluginContext
*
ctx
)
FMPSettingsPrivate
::
FMPSettingsPrivate
()
:
_ctx
(
ctx
),
:
_sets
(
0
)
_sets
(
0
)
{
{
}
}
...
@@ -75,11 +73,10 @@ FMPSettingsPrivate::FMPSettingsPrivate(ctkPluginContext *ctx)
...
@@ -75,11 +73,10 @@ FMPSettingsPrivate::FMPSettingsPrivate(ctkPluginContext *ctx)
int
FMPSettingsPrivate
::
Init
()
int
FMPSettingsPrivate
::
Init
()
{
{
if
(
!
_sets
)
{
if
(
!
_sets
)
{
_sets
=
new
QSettings
(
_ctx
->
getProperty
(
FMP_PROPKEY_CFG
)
.
toString
(),
QSettings
::
IniFormat
);
_sets
=
new
QSettings
(
FMP
::
GetProperties
()[
FMP_PROPKEY_CFG
]
.
toString
(),
QSettings
::
IniFormat
);
}
}
else
{
else
{
FMPSettingsWindow
*
set_dlg
=
new
FMPSettingsWindow
(
q_ptr
);
FMPSettingsWindow
*
set_dlg
=
new
FMPSettingsWindow
(
q_ptr
);
set_dlg
->
SetPluginContext
(
_ctx
);
set_dlg
->
setsettings
(
_sets
);
set_dlg
->
setsettings
(
_sets
);
set_dlg
->
show
();
set_dlg
->
show
();
connect
(
set_dlg
,
&
FMPSettingsWindow
::
settingChanged
,
this
,
&
FMPSettingsPrivate
::
SetValue
);
connect
(
set_dlg
,
&
FMPSettingsWindow
::
settingChanged
,
this
,
&
FMPSettingsPrivate
::
SetValue
);
...
@@ -98,12 +95,12 @@ int FMPSettingsPrivate::Uninit()
...
@@ -98,12 +95,12 @@ int FMPSettingsPrivate::Uninit()
return
FMP_SUCCESS
;
return
FMP_SUCCESS
;
}
}
QVariant
FMPSettingsPrivate
::
GetValue
(
const
QString
&
k
,
QVariant
default_val
)
QVariant
FMPSettingsPrivate
::
GetValue
(
const
QString
&
k
,
const
QVariant
&
default_val
)
{
{
return
_sets
->
value
(
k
,
default_val
);
return
_sets
->
value
(
k
,
default_val
);
}
}
bool
FMPSettingsPrivate
::
SetValue
(
const
QString
&
k
,
QVariant
v
)
bool
FMPSettingsPrivate
::
SetValue
(
const
QString
&
k
,
const
QVariant
&
v
)
{
{
_sets
->
setValue
(
k
,
v
);
_sets
->
setValue
(
k
,
v
);
return
(
_sets
->
value
(
k
)
==
v
);
return
(
_sets
->
value
(
k
)
==
v
);
...
...
fmp_settings.h
View file @
bcada99b
...
@@ -4,7 +4,6 @@
...
@@ -4,7 +4,6 @@
#include "fmp_settings_i.h"
#include "fmp_settings_i.h"
#include "ui./window.h"
#include "ui./window.h"
class
ctkPluginContext
;
class
FMPSettingsPrivate
;
class
FMPSettingsPrivate
;
/**
/**
...
@@ -18,7 +17,7 @@ class FMPSettings : public QObject, public FMPSettingsInterface
...
@@ -18,7 +17,7 @@ class FMPSettings : public QObject, public FMPSettingsInterface
Q_DECLARE_PRIVATE
(
FMPSettings
)
Q_DECLARE_PRIVATE
(
FMPSettings
)
public
:
public
:
explicit
FMPSettings
(
c
tkPluginContext
*
context
);
explicit
FMPSettings
(
c
onst
FMPContext
ctx
);
virtual
~
FMPSettings
();
virtual
~
FMPSettings
();
protected
:
protected
:
...
@@ -26,14 +25,16 @@ protected:
...
@@ -26,14 +25,16 @@ protected:
void
InitService
();
void
InitService
();
void
UninitService
();
void
UninitService
();
int
PostEvent
(
const
QString
&
topic
,
const
FMPProps
&
pps
=
FMPProps
());
int
PostEvent
(
const
QString
&
topic
,
const
FMPProps
&
pps
=
FMPProps
());
const
FMPContext
GetContext
()
const
{
return
context
;
}
//! SettingsInterface
//! SettingsInterface
public:
public:
QVariant
GetValue
(
const
QString
&
k
,
QVariant
default_val
);
QVariant
GetValue
(
const
QString
&
k
,
const
QVariant
&
default_val
);
bool
SetValue
(
const
QString
&
k
,
QVariant
v
);
bool
SetValue
(
const
QString
&
k
,
const
QVariant
&
v
);
private
:
private
:
FMPSettingsPrivate
*
d_ptr
;
FMPSettingsPrivate
*
d_ptr
;
const
FMPContext
context
;
};
};
...
@@ -46,16 +47,15 @@ class FMPSettingsPrivate:public QObject
...
@@ -46,16 +47,15 @@ class FMPSettingsPrivate:public QObject
Q_OBJECT
Q_OBJECT
Q_DECLARE_PUBLIC
(
FMPSettings
)
Q_DECLARE_PUBLIC
(
FMPSettings
)
public
:
public
:
explicit
FMPSettingsPrivate
(
ctkPluginContext
*
ctx
);
explicit
FMPSettingsPrivate
();
int
Init
();
int
Init
();
int
Uninit
();
int
Uninit
();
QVariant
GetValue
(
const
QString
&
k
,
QVariant
default_val
);
QVariant
GetValue
(
const
QString
&
k
,
const
QVariant
&
default_val
);
bool
SetValue
(
const
QString
&
k
,
QVariant
v
);
bool
SetValue
(
const
QString
&
k
,
const
QVariant
&
v
);
public
:
public
:
FMPSettings
*
q_ptr
;
FMPSettings
*
q_ptr
;
ctkPluginContext
*
_ctx
;
QSettings
*
_sets
;
QSettings
*
_sets
;
private
:
private
:
FMPSettingsWindow
*
settingwindow
;
FMPSettingsWindow
*
settingwindow
;
...
...
fmp_settings_def.h
View file @
bcada99b
...
@@ -3,17 +3,16 @@
...
@@ -3,17 +3,16 @@
//! 插件全局属性
//! 插件全局属性
#define FMP_PROPKEY_PLUGINPATH "FMPPath"
#define FMP_PROPKEY_LOADER "Loader"
#define FMP_PROPKEY_PLUGINPATH "PluginPath"
#define FMP_PROPKEY_CFG "FMPConfig"
#define FMP_PROPKEY_CFG "FMPConfig"
#define FMP_PROPKEY_ENTRY "
FMPEntry
"
#define FMP_PROPKEY_ENTRY "
EntryService
"
#define FMP_PROPKEY_PID "PMPPid"
#define FMP_PROPKEY_PID "PMPPid"
//! 配置文件 Key
//! 配置文件 Key
#define FMP_INIKEY_SERVICENAME "Service/Name"
#define FMP_INIKEY_SERVICENAME "Service/Name"
#define FMP_INIKEY_SERVICEDESC "Service/Desc"
#define FMP_INIKEY_SERVICEDESC "Service/Desc"
#define FMP_INIKEY_SERVICESTARTTYPE "Service/StartType"
#define FMP_INIKEY_SERVICESTARTTYPE "Service/StartType"
#define FMP_INIKEY_ENTRYSERVICE "Plugin/EntryService"
#define FMP_INIKEY_PLUGINPATH "Plugin/Path"
#define FMP_INIKEY_ANIMATION "Plugin/Animation"
#define FMP_INIKEY_ANIMATION "Plugin/Animation"
...
@@ -21,7 +20,7 @@
...
@@ -21,7 +20,7 @@
#define FMP_INIKEY_SYNCNTERVAL "Syncer/Interval"
#define FMP_INIKEY_SYNCNTERVAL "Syncer/Interval"
#define FMP_APPNAME "非码
POS
"
#define FMP_APPNAME "非码
POS 插件
"
...
...
fmp_settings_i.h
View file @
bcada99b
...
@@ -13,8 +13,10 @@
...
@@ -13,8 +13,10 @@
class
FMPSettingsInterface
:
public
FMPBaseInterface
class
FMPSettingsInterface
:
public
FMPBaseInterface
{
{
public
:
public
:
virtual
QVariant
GetValue
(
const
QString
&
k
,
QVariant
default_val
=
QVariant
())
=
0
;
virtual
long
GetPluginId
()
const
{
return
GetContext
()
->
getPlugin
()
->
getPluginId
();
}
virtual
bool
SetValue
(
const
QString
&
k
,
QVariant
v
)
=
0
;
virtual
QVariant
GetValue
(
const
QString
&
k
,
const
QVariant
&
default_val
=
QVariant
())
=
0
;
virtual
bool
SetValue
(
const
QString
&
k
,
const
QVariant
&
v
)
=
0
;
bool
GetBool
(
const
QString
&
k
)
{
return
GetValue
(
k
).
toBool
();
}
bool
GetBool
(
const
QString
&
k
)
{
return
GetValue
(
k
).
toBool
();
}
...
@@ -27,6 +29,6 @@ public:
...
@@ -27,6 +29,6 @@ public:
QString
GetString
(
const
QString
&
k
)
{
return
GetValue
(
k
).
toString
();
}
QString
GetString
(
const
QString
&
k
)
{
return
GetValue
(
k
).
toString
();
}
};
};
Q_DECLARE_INTERFACE
(
FMPSettingsInterface
,
"
com.
fmp.settings"
)
Q_DECLARE_INTERFACE
(
FMPSettingsInterface
,
"fmp.settings"
)
#endif // FMP_SETTINGS_I_H
#endif // FMP_SETTINGS_I_H
fmp_settings_plugin.cpp
View file @
bcada99b
...
@@ -39,12 +39,12 @@ void FMPSettingsPlugin::start(ctkPluginContext* context)
...
@@ -39,12 +39,12 @@ void FMPSettingsPlugin::start(ctkPluginContext* context)
void
FMPSettingsPlugin
::
stop
(
ctkPluginContext
*
context
)
void
FMPSettingsPlugin
::
stop
(
ctkPluginContext
*
context
)
{
{
Q_UNUSED
(
context
)
Q_UNUSED
(
context
)
if
(
_sets_service
)
if
(
_sets_service
)
{
{
delete
_sets_service
;
delete
_sets_service
;
_sets_service
=
0
;
_sets_service
=
0
;
}
}
}
}
#if (QT_VERSION < QT_VERSION_CHECK(5,0,0))
#if (QT_VERSION < QT_VERSION_CHECK(5,0,0))
...
...
res/MANIFEST.MF
View file @
bcada99b
Plugin-SymbolicName: fmp.settings
Plugin-SymbolicName: fmp.settings
Plugin-Version: 0.1.
1
Plugin-Version: 0.1.
0
Plugin-Name: fmp.settings
Plugin-Name: fmp.settings
Plugin-Copyright: Freemud Ltd. Copyright (C) 2014-2017
Plugin-Copyright: Freemud Ltd. Copyright (C) 2014-2017
Plugin-Vendor: Freemud
Plugin-Vendor: Freemud
ui/window.cpp
View file @
bcada99b
...
@@ -163,10 +163,10 @@ void FMPSettingsWindow::on_btn_showwidget_clicked()
...
@@ -163,10 +163,10 @@ void FMPSettingsWindow::on_btn_showwidget_clicked()
void
FMPSettingsWindow
::
OnTestPrintClicked
()
void
FMPSettingsWindow
::
OnTestPrintClicked
()
{
{
if
(
_fmp_sets
)
{
if
(
_fmp_sets
)
{
FMPPrinterInterface
*
printer
=
_fmp_sets
->
GetService
<
FMPPrinterInterface
>
(
_ctx
);
FMPPrinterInterface
*
printer
=
FMP
::
GetService
<
FMPPrinterInterface
>
(
);
if
(
printer
)
{
if
(
printer
)
{
printer
->
GetPrintName
();
printer
->
GetPrintName
();
printer
->
DoPrint
(
QString
::
fromLocal8Bit
(
"这是一个测试页看到此页说明打印正常!
\r\n\r\n\r\n
"
));
//
printer->DoPrint(QString::fromLocal8Bit("这是一个测试页看到此页说明打印正常!\r\n\r\n\r\n"));
}
}
}
}
}
}
ui/window.h
View file @
bcada99b
...
@@ -22,7 +22,6 @@ public:
...
@@ -22,7 +22,6 @@ public:
explicit
FMPSettingsWindow
(
FMPSettingsInterface
*
fmp_sets
,
QWidget
*
parent
=
0
);
explicit
FMPSettingsWindow
(
FMPSettingsInterface
*
fmp_sets
,
QWidget
*
parent
=
0
);
~
FMPSettingsWindow
();
~
FMPSettingsWindow
();
void
setsettings
(
QSettings
*
set
);
void
setsettings
(
QSettings
*
set
);
void
SetPluginContext
(
ctkPluginContext
*
ctx
)
{
_ctx
=
ctx
;
}
signals
:
signals
:
bool
settingChanged
(
const
QString
&
,
QVariant
);
bool
settingChanged
(
const
QString
&
,
QVariant
);
...
@@ -31,7 +30,6 @@ private:
...
@@ -31,7 +30,6 @@ private:
QSettings
*
m_set
;
QSettings
*
m_set
;
QWidget
*
getwidget
(
QString
widgetname
);
QWidget
*
getwidget
(
QString
widgetname
);
FMPSettingsInterface
*
_fmp_sets
;
FMPSettingsInterface
*
_fmp_sets
;
ctkPluginContext
*
_ctx
;
private
slots
:
private
slots
:
void
onSettingeditingFinished
();
void
onSettingeditingFinished
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment