Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
OpenWalnut
OpenWalnut Core
Commits
248e8492
Commit
248e8492
authored
Jun 29, 2012
by
Sebastian Eichelbaum
Browse files
[CHANGE] GUI now loads the icons from file properly.
parent
412df090
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
6 deletions
+31
-6
src/qt4gui/qt4/WIconManager.cpp
src/qt4gui/qt4/WIconManager.cpp
+6
-4
src/qt4gui/qt4/WIconManager.h
src/qt4gui/qt4/WIconManager.h
+15
-1
src/qt4gui/qt4/WMainWindow.cpp
src/qt4gui/qt4/WMainWindow.cpp
+10
-1
No files found.
src/qt4gui/qt4/WIconManager.cpp
View file @
248e8492
...
...
@@ -34,8 +34,6 @@
void
WIconManager
::
addIcon
(
std
::
string
name
,
boost
::
filesystem
::
path
filename
)
{
assert
(
(
m_iconList
.
count
(
name
)
==
0
)
);
QPixmap
img
;
bool
failed
=
!
img
.
load
(
QString
::
fromStdString
(
filename
.
string
()
)
);
if
(
failed
)
...
...
@@ -49,12 +47,16 @@ void WIconManager::addIcon( std::string name, boost::filesystem::path filename )
void
WIconManager
::
addIcon
(
std
::
string
name
,
const
char
*
const
xpm
[]
)
{
assert
(
(
m_iconList
.
count
(
name
)
==
0
)
);
QIcon
*
icon
=
new
QIcon
(
QPixmap
(
xpm
)
);
m_iconList
[
name
]
=
icon
;
}
void
WIconManager
::
addIcon
(
std
::
string
name
,
const
QPixmap
&
pixmap
)
{
QIcon
*
icon
=
new
QIcon
(
QPixmap
(
pixmap
)
);
m_iconList
[
name
]
=
icon
;
}
QIcon
WIconManager
::
getIcon
(
const
std
::
string
name
)
{
QIcon
icon
;
...
...
src/qt4gui/qt4/WIconManager.h
View file @
248e8492
...
...
@@ -39,7 +39,10 @@ class WIconManager
{
public:
/**
* Adds an Icon to the icon store
* Adds an Icon to the icon store.
*
* \note This method replaces icons with the same name.
*
* \param name The icon's name
* \param xpm The icon itself in XPM format
*/
...
...
@@ -49,12 +52,23 @@ public:
* Adds an Icon to the icon store. Use this to load an icon from a file.
*
* \throw WFileNotFound if file could not be loaded or found.
* \note This method replaces icons with the same name.
*
* \param name The icon's name
* \param filename The path to the file.
*/
void
addIcon
(
std
::
string
name
,
boost
::
filesystem
::
path
filename
);
/**
* Adds an Icon to the icon store. Use this to add some arbitrary pixmap.
*
* \note This method replaces icons with the same name.
*
* \param name The icon's name
* \param pixmap the pixmap to add.
*/
void
addIcon
(
std
::
string
name
,
const
QPixmap
&
pixmap
);
/**
* Searches icons in the internal map and all modules for the given icon name.
* \param name Name of the requested icon
...
...
src/qt4gui/qt4/WMainWindow.cpp
View file @
248e8492
...
...
@@ -174,7 +174,6 @@ void WMainWindow::setupGUI()
m_iconManager
.
addIcon
(
std
::
string
(
"load"
),
fileopen_xpm
);
m_iconManager
.
addIcon
(
std
::
string
(
"loadProject"
),
projOpen_xpm
);
m_iconManager
.
addIcon
(
std
::
string
(
"saveProject"
),
projSave_xpm
);
m_iconManager
.
addIcon
(
std
::
string
(
"logo"
),
WPathHelper
::
getPathHelper
()
->
getSharePath
()
/
"pixmaps"
/
"openwalnut_32x32.png"
);
m_iconManager
.
addIcon
(
std
::
string
(
"help"
),
question_xpm
);
m_iconManager
.
addIcon
(
std
::
string
(
"quit"
),
quit_xpm
);
m_iconManager
.
addIcon
(
std
::
string
(
"moduleBusy"
),
moduleBusy_xpm
);
...
...
@@ -189,6 +188,16 @@ void WMainWindow::setupGUI()
m_iconManager
.
addIcon
(
std
::
string
(
"image"
),
image_xpm
);
m_iconManager
.
addIcon
(
std
::
string
(
"preferences"
),
preferences_xpm
);
try
{
m_iconManager
.
addIcon
(
std
::
string
(
"logo"
),
WPathHelper
::
getPathHelper
()
->
getSharePath
()
/
".."
/
"pixmaps"
/
"openwalnut.png"
);
}
catch
(
const
WException
&
e
)
{
// ignore this. add a default pixmap
m_iconManager
.
addIcon
(
std
::
string
(
"logo"
),
QPixmap
()
);
}
if
(
objectName
().
isEmpty
()
)
{
setObjectName
(
QString
::
fromUtf8
(
"MainWindow"
)
);
...
...
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