Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
OpenWalnut Core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
44
Issues
44
List
Boards
Labels
Service Desk
Milestones
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
OpenWalnut
OpenWalnut Core
Commits
818cdda3
Commit
818cdda3
authored
Jul 20, 2012
by
Sebastian Eichelbaum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FIX
#195
] now using icon of meta file if available. Fallback is still the XPM.
parent
5ba5ae19
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
68 additions
and
25 deletions
+68
-25
src/core/kernel/WModuleMetaInformation.cpp
src/core/kernel/WModuleMetaInformation.cpp
+12
-0
src/core/kernel/WModuleMetaInformation.h
src/core/kernel/WModuleMetaInformation.h
+7
-0
src/modules/template/WMTemplate.cpp
src/modules/template/WMTemplate.cpp
+5
-8
src/modules/template/resources/META
src/modules/template/resources/META
+2
-2
src/modules/template/resources/WMTemplate.xpm
src/modules/template/resources/WMTemplate.xpm
+0
-0
src/qt4gui/qt4/WIconManager.cpp
src/qt4gui/qt4/WIconManager.cpp
+34
-2
src/qt4gui/qt4/WQtModuleConfig.cpp
src/qt4gui/qt4/WQtModuleConfig.cpp
+4
-12
src/qt4gui/qt4/guiElements/WQtModuleMetaInfo.cpp
src/qt4gui/qt4/guiElements/WQtModuleMetaInfo.cpp
+4
-1
No files found.
src/core/kernel/WModuleMetaInformation.cpp
View file @
818cdda3
...
...
@@ -93,6 +93,18 @@ boost::filesystem::path WModuleMetaInformation::getIcon() const
return
m_localPath
/
m_metaData
.
getValue
<
boost
::
filesystem
::
path
>
(
m_name
+
"/icon"
,
boost
::
filesystem
::
path
(
"icon.png"
)
);
}
bool
WModuleMetaInformation
::
isIconAvailable
()
const
{
if
(
m_loaded
)
{
return
m_metaData
.
exists
(
m_name
+
"/icon"
,
true
);
}
else
{
return
false
;
}
}
std
::
string
WModuleMetaInformation
::
getWebsite
()
const
{
// return a default if not meta data was loaded
...
...
src/core/kernel/WModuleMetaInformation.h
View file @
818cdda3
...
...
@@ -154,6 +154,13 @@ public:
*/
boost
::
filesystem
::
path
getIcon
()
const
;
/**
* Check whether the meta info contained an icon.
*
* \return true if icon is available. Does not check existence or validity of image file.
*/
bool
isIconAvailable
()
const
;
/**
* The URL to a module website. Can be empty.
*
...
...
src/modules/template/WMTemplate.cpp
View file @
818cdda3
...
...
@@ -72,7 +72,6 @@
#include "core/graphicsEngine/WGEUtils.h"
#include "core/graphicsEngine/WGERequirement.h"
#include "WMTemplate.xpm"
#include "icons/bier.xpm"
#include "icons/wurst.xpm"
#include "icons/steak.xpm"
...
...
@@ -129,13 +128,11 @@ boost::shared_ptr< WModule > WMTemplate::factory() const
const
char
**
WMTemplate
::
getXPMIcon
()
const
{
// The template_xpm char array comes from the template.xpm file as included above.
// Such char arrays, i.e. files, can be easily created using an image manipulation program
// like GIMP. Be aware that the xpm file is a simple header file. Thus it contains real
// code. This code can be manipulated by hand. Unfortunately, you really have to fix the
// xpm files produced by gimp. You need to make the char array const in order to prevent
// compiler warnings or even errors.
return
template_xpm
;
// This is deprecated! You can still use it as fallback if you do not specify a META file. If you return NULL here, a default icon is used.
//
// This was used to provide an icon for your module. You should use the META file in your resource directory. This file is commented and
// explains each entry in detail.
return
NULL
;
}
const
std
::
string
WMTemplate
::
getName
()
const
...
...
src/modules/template/resources/META
View file @
818cdda3
...
...
@@ -33,8 +33,8 @@
"Template"
{
// Provide an icon. If the icon exists, it overrides the one provided by your
// getIcon method. This path is relative to your module's resource directory.
icon="WMTeamplate.
png
";
// get
XPM
Icon method. This path is relative to your module's resource directory.
icon="WMTeamplate.
xpm
";
// Where to find the module?
website = "http://www.openwalnut.org";
...
...
src/modules/template/WMTemplate.xpm
→
src/modules/template/
resources/
WMTemplate.xpm
View file @
818cdda3
File moved
src/qt4gui/qt4/WIconManager.cpp
View file @
818cdda3
...
...
@@ -66,7 +66,23 @@ QIcon WIconManager::getIcon( const std::string name )
}
else
if
(
WModuleFactory
::
getModuleFactory
()
->
getPrototypeByName
(
name
)
)
{
icon
=
QIcon
(
QPixmap
(
WModuleFactory
::
getModuleFactory
()
->
getPrototypeByName
(
name
)
->
getXPMIcon
()
)
);
// get module icon from meta info if available
WModuleMetaInformation
::
ConstSPtr
meta
=
WModuleFactory
::
getModuleFactory
()
->
getPrototypeByName
(
name
)
->
getMetaInformation
();
if
(
meta
->
isIconAvailable
()
&&
boost
::
filesystem
::
exists
(
meta
->
getIcon
()
)
)
{
try
{
icon
=
QIcon
(
QPixmap
(
QString
::
fromStdString
(
meta
->
getIcon
().
string
()
)
)
);
}
catch
(
...
)
{
icon
=
QIcon
(
QPixmap
(
WModuleFactory
::
getModuleFactory
()
->
getPrototypeByName
(
name
)
->
getXPMIcon
()
)
);
}
}
else
{
icon
=
QIcon
(
QPixmap
(
WModuleFactory
::
getModuleFactory
()
->
getPrototypeByName
(
name
)
->
getXPMIcon
()
)
);
}
}
else
{
...
...
@@ -84,7 +100,23 @@ QIcon WIconManager::getIcon( const std::string name, const QIcon& defaultIcon )
}
else
if
(
WModuleFactory
::
getModuleFactory
()
->
getPrototypeByName
(
name
)
)
{
return
QIcon
(
QPixmap
(
WModuleFactory
::
getModuleFactory
()
->
getPrototypeByName
(
name
)
->
getXPMIcon
()
)
);
// get module icon from meta info if available
WModuleMetaInformation
::
ConstSPtr
meta
=
WModuleFactory
::
getModuleFactory
()
->
getPrototypeByName
(
name
)
->
getMetaInformation
();
if
(
meta
->
isIconAvailable
()
&&
boost
::
filesystem
::
exists
(
meta
->
getIcon
()
)
)
{
try
{
return
QIcon
(
QPixmap
(
QString
::
fromStdString
(
meta
->
getIcon
().
string
()
)
)
);
}
catch
(
...
)
{
return
QIcon
(
QPixmap
(
WModuleFactory
::
getModuleFactory
()
->
getPrototypeByName
(
name
)
->
getXPMIcon
()
)
);
}
}
else
{
return
QIcon
(
QPixmap
(
WModuleFactory
::
getModuleFactory
()
->
getPrototypeByName
(
name
)
->
getXPMIcon
()
)
);
}
}
else
{
...
...
src/qt4gui/qt4/WQtModuleConfig.cpp
View file @
818cdda3
...
...
@@ -245,18 +245,10 @@ WQtModuleConfig::WQtModuleConfig( QWidget* parent, Qt::WindowFlags f ):
QLabel
*
icon
=
new
QLabel
();
icon
->
setSizePolicy
(
sizePolicy
);
// if there is an icon -> show it
if
(
(
*
iter
)
->
getXPMIcon
()
)
{
// we need to enforce some size
QPixmap
qicon
(
(
*
iter
)
->
getXPMIcon
()
);
qicon
=
qicon
.
scaled
(
32
,
32
,
Qt
::
KeepAspectRatio
);
icon
->
setPixmap
(
qicon
);
}
else
{
icon
->
setPixmap
(
noIcon
.
pixmap
(
32
,
32
)
);
}
// we need to enforce some size
QPixmap
qicon
(
WQt4Gui
::
getMainWindow
()
->
getIconManager
()
->
getIcon
(
(
*
iter
)
->
getName
(),
noIcon
).
pixmap
(
32
,
32
)
);
qicon
=
qicon
.
scaled
(
32
,
32
,
Qt
::
KeepAspectRatio
);
icon
->
setPixmap
(
qicon
);
layoutWidget
->
addWidget
(
icon
,
0
,
column
,
2
,
1
);
++
column
;
...
...
src/qt4gui/qt4/guiElements/WQtModuleMetaInfo.cpp
View file @
818cdda3
...
...
@@ -48,6 +48,9 @@
#include "core/common/WLogger.h"
#include "core/common/WPathHelper.h"
#include "../WQt4Gui.h"
#include "../WMainWindow.h"
#include "WQtModuleMetaInfo.h"
#include "WQtModuleMetaInfo.moc"
...
...
@@ -226,7 +229,7 @@ WQtModuleMetaInfo::WQtModuleMetaInfo( WModule::SPtr module, QWidget* parent ):
toolbar
->
setLayout
(
tbLayout
);
// we need a special home-action to set the html content again
QAction
*
homeAction
=
new
QAction
(
QIcon
(
QPixmap
(
module
->
getXPMIcon
()
)
),
QAction
*
homeAction
=
new
QAction
(
WQt4Gui
::
getMainWindow
()
->
getIconManager
()
->
getIcon
(
module
->
getName
(
)
),
QString
(
"Back to "
)
+
QString
::
fromStdString
(
module
->
getName
()
),
toolbar
);
homeAction
->
setIconText
(
QString
(
"Back to "
)
+
QString
::
fromStdString
(
module
->
getName
()
)
);
...
...
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