Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
OpenFlipper-Free
OpenFlipper
Commits
cf7bbf72
Commit
cf7bbf72
authored
May 31, 2016
by
Hans-Christian Ebke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed the header area widget installation mechanism to something more robust.
parent
baced5ca
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
53 additions
and
71 deletions
+53
-71
BasePlugin/ToolboxInterface.hh
BasePlugin/ToolboxInterface.hh
+12
-0
Core/Core.hh
Core/Core.hh
+4
-0
Core/PluginInfo.hh
Core/PluginInfo.hh
+5
-0
Core/PluginLoader.cc
Core/PluginLoader.cc
+5
-1
Core/scripting.cc
Core/scripting.cc
+7
-39
widgets/coreWidget/SideArea.cc
widgets/coreWidget/SideArea.cc
+3
-13
widgets/coreWidget/SideArea.hh
widgets/coreWidget/SideArea.hh
+3
-8
widgets/coreWidget/SideElement.cc
widgets/coreWidget/SideElement.cc
+10
-7
widgets/coreWidget/SideElement.hh
widgets/coreWidget/SideElement.hh
+3
-2
widgets/coreWidget/viewMode.cc
widgets/coreWidget/viewMode.cc
+1
-1
No files found.
BasePlugin/ToolboxInterface.hh
View file @
cf7bbf72
...
...
@@ -111,6 +111,18 @@ class ToolboxInterface {
* @param _icon Icon for the toolbox
*/
virtual
void
addToolbox
(
QString
_name
,
QWidget
*
_widget
,
QIcon
*
_icon
)
{};
/** \brief Add a toolbox widget to the gui with the given name, icon and header area widget.
*
* This signal adds a toolbox widget to the toolbox area on the right. And sets an icon for it
*
* @param _name Visible name of the toolbox
* @param _widget Pointer to the toolbox widget
* @param _icon Icon for the toolbox
* @param _headerAreaWidget Widget displayed in the toolbox header between
* the title and the detach button.
*/
virtual
void
addToolbox
(
QString
_name
,
QWidget
*
_widget
,
QIcon
*
_icon
,
QWidget
*
_headerAreaWidget
)
{};
};
...
...
Core/Core.hh
View file @
cf7bbf72
...
...
@@ -1022,6 +1022,10 @@ private slots:
/// Add a Toolbox from a plugin or from scripting (with icon)
void
addToolbox
(
QString
_name
,
QWidget
*
_widget
,
QIcon
*
_icon
);
/// Add a Toolbox from a plugin or from scripting (with icon)
void
addToolbox
(
QString
_name
,
QWidget
*
_widget
,
QIcon
*
_icon
,
QWidget
*
_headerAreaWidget
);
/**
* Get a toolbox.
*
...
...
Core/PluginInfo.hh
View file @
cf7bbf72
...
...
@@ -93,6 +93,7 @@ class PluginInfo{
slotInfos
.
clear
();
keys
.
clear
();
toolboxWidgets
.
clear
();
headerAreaWidgets
.
clear
();
toolboxIcons
.
clear
();
toolbars
.
clear
();
contextMenus
.
clear
();
...
...
@@ -111,6 +112,7 @@ class PluginInfo{
slotInfos
(
_i
.
slotInfos
),
keys
(
_i
.
keys
),
toolboxWidgets
(
_i
.
toolboxWidgets
),
headerAreaWidgets
(
_i
.
headerAreaWidgets
),
toolboxIcons
(
_i
.
toolboxIcons
),
toolbars
(
_i
.
toolbars
),
contextMenus
(
_i
.
contextMenus
),
...
...
@@ -151,6 +153,9 @@ class PluginInfo{
/// Pointer to plugins toolbox widget (if available)
std
::
vector
<
std
::
pair
<
QString
,
QWidget
*
>
>
toolboxWidgets
;
/// Pointer to plugins header area widgets (if available)
std
::
vector
<
std
::
pair
<
QString
,
QWidget
*
>
>
headerAreaWidgets
;
/// Pointer to plugins toolbox widget icons (if available)
std
::
vector
<
QIcon
*
>
toolboxIcons
;
...
...
Core/PluginLoader.cc
View file @
cf7bbf72
...
...
@@ -1069,7 +1069,11 @@ void Core::loadPlugin(const QString& _filename,const bool _silent, QString& _lic
if
(
checkSignal
(
plugin
,
"addToolbox(QString,QWidget*,QIcon*)"
))
connect
(
plugin
,
SIGNAL
(
addToolbox
(
QString
,
QWidget
*
,
QIcon
*
)
),
this
,
SLOT
(
addToolbox
(
QString
,
QWidget
*
,
QIcon
*
)
),
Qt
::
DirectConnection
);
}
if
(
checkSignal
(
plugin
,
"addToolbox(QString,QWidget*,QIcon*,QWidget*)"
))
connect
(
plugin
,
SIGNAL
(
addToolbox
(
QString
,
QWidget
*
,
QIcon
*
,
QWidget
*
)
),
this
,
SLOT
(
addToolbox
(
QString
,
QWidget
*
,
QIcon
*
,
QWidget
*
)
),
Qt
::
DirectConnection
);
}
//Check if the plugin supports ViewMode-Interface
ViewModeInterface
*
viewModePlugin
=
qobject_cast
<
ViewModeInterface
*
>
(
plugin
);
...
...
Core/scripting.cc
View file @
cf7bbf72
...
...
@@ -254,48 +254,15 @@ void Core::activateToolbox(QString _pluginName, QString _toolboxName, bool activ
}
void
Core
::
addToolbox
(
QString
_name
,
QWidget
*
_widget
)
{
int
id
=
-
1
;
// Find the plugin which added this Toolbox
for
(
uint
i
=
0
;
i
<
plugins_
.
size
();
++
i
)
{
if
(
plugins_
[
i
].
plugin
==
sender
()
)
{
id
=
i
;
break
;
}
}
// Find the scripting plugin because we assign this toolBox to it as we did not find the original sender
if
(
id
==
-
1
)
{
for
(
uint
i
=
0
;
i
<
plugins_
.
size
();
++
i
)
{
if
(
plugins_
[
i
].
name
==
"Scripting"
)
{
id
=
i
;
break
;
}
}
if
(
id
==
-
1
)
{
std
::
cerr
<<
"Unknown sender plugin when adding Toolbox!"
<<
std
::
endl
;
return
;
}
}
spinBoxEventFilter_
.
hookUpToWidgetTree
(
_widget
);
plugins_
[
id
].
toolboxWidgets
.
push_back
(
std
::
pair
<
QString
,
QWidget
*
>
(
_name
,
_widget
)
);
plugins_
[
id
].
toolboxIcons
.
push_back
(
0
);
// add widget name to viewMode 'all'
if
(
!
viewModes_
[
0
]
->
visibleToolboxes
.
contains
(
_name
)
){
viewModes_
[
0
]
->
visibleToolboxes
<<
_name
;
viewModes_
[
0
]
->
visibleToolboxes
.
sort
();
}
setViewMode
(
OpenFlipper
::
Options
::
currentViewMode
()
);
addToolbox
(
_name
,
_widget
,
0
,
0
);
}
//-----------------------------------------------------------------------------
void
Core
::
addToolbox
(
QString
_name
,
QWidget
*
_widget
,
QIcon
*
_icon
)
{
addToolbox
(
_name
,
_widget
,
_icon
,
0
);
}
void
Core
::
addToolbox
(
QString
_name
,
QWidget
*
_widget
,
QIcon
*
_icon
,
QWidget
*
_headerAreaWidget
)
{
int
id
=
-
1
;
// Find the plugin which added this Toolbox
...
...
@@ -325,6 +292,7 @@ void Core::addToolbox(QString _name ,QWidget* _widget, QIcon* _icon) {
spinBoxEventFilter_
.
hookUpToWidgetTree
(
_widget
);
plugins_
[
id
].
toolboxWidgets
.
push_back
(
std
::
pair
<
QString
,
QWidget
*
>
(
_name
,
_widget
)
);
plugins_
[
id
].
toolboxIcons
.
push_back
(
_icon
);
plugins_
[
id
].
headerAreaWidgets
.
push_back
(
std
::
pair
<
QString
,
QWidget
*
>
(
_name
,
_headerAreaWidget
)
);
// add widget name to viewMode 'all'
if
(
!
viewModes_
[
0
]
->
visibleToolboxes
.
contains
(
_name
)
){
...
...
widgets/coreWidget/SideArea.cc
View file @
cf7bbf72
...
...
@@ -75,20 +75,10 @@ SideArea::SideArea (QWidget *_parent) :
//-----------------------------------------------------------------------------
void
SideArea
::
addItem
(
QObject
const
*
const
_plugin
,
QWidget
*
_w
,
QString
_name
,
QIcon
*
_icon
)
void
SideArea
::
addItem
(
QObject
const
*
const
_plugin
,
QWidget
*
_w
,
QString
_name
,
QIcon
*
_icon
,
QWidget
*
_headerAreaWidget
)
{
SideElement
*
e
=
new
SideElement
(
this
,
_w
,
_name
,
_icon
);
layout_
->
addWidget
(
e
);
items_
.
push_back
(
e
);
plugins_
.
push_back
(
_plugin
);
itemNames_
.
push_back
(
_name
);
}
//-----------------------------------------------------------------------------
void
SideArea
::
addItem
(
QObject
const
*
const
_plugin
,
QWidget
*
_w
,
QString
_name
)
{
SideElement
*
e
=
new
SideElement
(
this
,
_w
,
_name
);
SideElement
*
e
=
new
SideElement
(
this
,
_w
,
_name
,
_icon
,
_headerAreaWidget
);
layout_
->
addWidget
(
e
);
items_
.
push_back
(
e
);
plugins_
.
push_back
(
_plugin
);
...
...
widgets/coreWidget/SideArea.hh
View file @
cf7bbf72
...
...
@@ -85,20 +85,15 @@ class SideArea : public QWidget {
*/
SideArea
(
QWidget
*
_parent
=
0
);
/** Adds a plugin tool widget
\param _plugin plugin corresponding to the widget
\param _w Plugin widget
\param _name Plugin name
*/
void
addItem
(
QObject
const
*
const
_plugin
,
QWidget
*
_w
,
QString
_name
);
/** Adds a plugin tool widget
\param _plugin plugin corresponding to the widget
\param _w Plugin widget
\param _name Plugin name
\param _icon an icon
\param _headerAreaWidget
*/
void
addItem
(
QObject
const
*
const
_plugin
,
QWidget
*
_w
,
QString
_name
,
QIcon
*
_icon
);
void
addItem
(
QObject
const
*
const
_plugin
,
QWidget
*
_w
,
QString
_name
,
QIcon
*
_icon
=
0
,
QWidget
*
_headerAreaWidget
=
0
);
/// clears the whole tool widget area
void
clear
();
...
...
widgets/coreWidget/SideElement.cc
View file @
cf7bbf72
...
...
@@ -64,9 +64,11 @@
//== IMPLEMENTATION ==========================================================
SideElement
::
SideElement
(
SideArea
*
_parent
,
QWidget
*
_w
,
QString
_name
,
QIcon
*
_icon
)
:
SideElement
::
SideElement
(
SideArea
*
_parent
,
QWidget
*
_w
,
QString
_name
,
QIcon
*
_icon
,
QWidget
*
_headerAreaWidget
)
:
parent_
(
_parent
),
widget_
(
_w
),
headerAreaWidget_
(
_headerAreaWidget
),
name_
(
_name
),
icon_
(
_icon
),
active_
(
0
),
...
...
@@ -98,12 +100,11 @@ SideElement::SideElement (SideArea *_parent, QWidget *_w, QString _name, QIcon*
detachButton_
->
setAutoRaise
(
true
);
hl
->
addWidget
(
iconHolder_
);
hl
->
addWidget
(
label_
);
QWidget
*
stretcher_wdgt
=
new
QWidget
(
this
);
stretcher_wdgt
->
setObjectName
(
"ChildControlArea"
);
connect
(
this
,
SIGNAL
(
toggleActive
(
bool
)),
stretcher_wdgt
,
SLOT
(
setVisible
(
bool
)));
stretcher_wdgt
->
setSizePolicy
(
QSizePolicy
::
MinimumExpanding
,
QSizePolicy
::
Minimum
);
stretcher_wdgt
->
setVisible
(
false
);
hl
->
addWidget
(
stretcher_wdgt
);
if
(
headerAreaWidget_
)
{
headerAreaWidget_
->
setVisible
(
false
);
connect
(
this
,
SIGNAL
(
toggleActive
(
bool
)),
headerAreaWidget_
,
SLOT
(
setVisible
(
bool
)));
hl
->
addWidget
(
headerAreaWidget_
);
}
hl
->
addStretch
(
1
);
hl
->
addWidget
(
detachButton_
);
...
...
@@ -145,6 +146,8 @@ SideElement::~SideElement ()
dialog_
->
close
();
}
widget_
->
setParent
(
0
);
if
(
headerAreaWidget_
)
headerAreaWidget_
->
setParent
(
0
);
}
//-----------------------------------------------------------------------------
...
...
widgets/coreWidget/SideElement.hh
View file @
cf7bbf72
...
...
@@ -94,7 +94,8 @@ class SideElement : public QWidget
@param _icon An icon that should be shown in the title bar of the side element
*/
SideElement
(
SideArea
*
_parent
,
QWidget
*
_w
,
QString
_name
,
QIcon
*
_icon
=
0
);
SideElement
(
SideArea
*
_parent
,
QWidget
*
_w
,
QString
_name
,
QIcon
*
_icon
,
QWidget
*
_headerAreaWidget
);
/// Destructor
~
SideElement
();
...
...
@@ -150,7 +151,7 @@ class SideElement : public QWidget
SideArea
*
parent_
;
// plugin widget
QWidget
*
widget_
;
QWidget
*
widget_
,
*
headerAreaWidget_
;
// plugin name
QString
name_
;
...
...
widgets/coreWidget/viewMode.cc
View file @
cf7bbf72
...
...
@@ -378,7 +378,7 @@ void CoreWidget::slotChangeView(QString _mode, QStringList _toolboxWidgets, QStr
// only add items that have not been added yet
if
(
!
skip
)
{
toolBox_
->
addItem
(
plugins_
[
p
].
plugin
,
plugins_
[
p
].
toolboxWidgets
[
j
].
second
,
plugins_
[
p
].
toolboxWidgets
[
j
].
first
,
plugins_
[
p
].
toolboxIcons
[
j
]
);
toolBox_
->
addItem
(
plugins_
[
p
].
plugin
,
plugins_
[
p
].
toolboxWidgets
[
j
].
second
,
plugins_
[
p
].
toolboxWidgets
[
j
].
first
,
plugins_
[
p
].
toolboxIcons
[
j
]
,
plugins_
[
p
].
headerAreaWidgets
[
j
].
second
);
// move item to the correct position
if
(
i
<
toolBox_
->
lastPos_
)
{
...
...
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