Commit 248e8492 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum
Browse files

[CHANGE] GUI now loads the icons from file properly.

parent 412df090
...@@ -34,8 +34,6 @@ ...@@ -34,8 +34,6 @@
void WIconManager::addIcon( std::string name, boost::filesystem::path filename ) void WIconManager::addIcon( std::string name, boost::filesystem::path filename )
{ {
assert( ( m_iconList.count( name ) == 0 ) );
QPixmap img; QPixmap img;
bool failed = !img.load( QString::fromStdString( filename.string() ) ); bool failed = !img.load( QString::fromStdString( filename.string() ) );
if( failed ) if( failed )
...@@ -49,12 +47,16 @@ void WIconManager::addIcon( std::string name, boost::filesystem::path filename ) ...@@ -49,12 +47,16 @@ void WIconManager::addIcon( std::string name, boost::filesystem::path filename )
void WIconManager::addIcon( std::string name, const char* const xpm[] ) void WIconManager::addIcon( std::string name, const char* const xpm[] )
{ {
assert( ( m_iconList.count( name ) == 0 ) );
QIcon* icon = new QIcon( QPixmap( xpm ) ); QIcon* icon = new QIcon( QPixmap( xpm ) );
m_iconList[name] = icon; 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 WIconManager::getIcon( const std::string name )
{ {
QIcon icon; QIcon icon;
......
...@@ -39,7 +39,10 @@ class WIconManager ...@@ -39,7 +39,10 @@ class WIconManager
{ {
public: 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 name The icon's name
* \param xpm The icon itself in XPM format * \param xpm The icon itself in XPM format
*/ */
...@@ -49,12 +52,23 @@ public: ...@@ -49,12 +52,23 @@ public:
* Adds an Icon to the icon store. Use this to load an icon from a file. * 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. * \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 name The icon's name
* \param filename The path to the file. * \param filename The path to the file.
*/ */
void addIcon( std::string name, boost::filesystem::path filename ); 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. * Searches icons in the internal map and all modules for the given icon name.
* \param name Name of the requested icon * \param name Name of the requested icon
......
...@@ -174,7 +174,6 @@ void WMainWindow::setupGUI() ...@@ -174,7 +174,6 @@ void WMainWindow::setupGUI()
m_iconManager.addIcon( std::string( "load" ), fileopen_xpm ); m_iconManager.addIcon( std::string( "load" ), fileopen_xpm );
m_iconManager.addIcon( std::string( "loadProject" ), projOpen_xpm ); m_iconManager.addIcon( std::string( "loadProject" ), projOpen_xpm );
m_iconManager.addIcon( std::string( "saveProject" ), projSave_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( "help" ), question_xpm );
m_iconManager.addIcon( std::string( "quit" ), quit_xpm ); m_iconManager.addIcon( std::string( "quit" ), quit_xpm );
m_iconManager.addIcon( std::string( "moduleBusy" ), moduleBusy_xpm ); m_iconManager.addIcon( std::string( "moduleBusy" ), moduleBusy_xpm );
...@@ -189,6 +188,16 @@ void WMainWindow::setupGUI() ...@@ -189,6 +188,16 @@ void WMainWindow::setupGUI()
m_iconManager.addIcon( std::string( "image" ), image_xpm ); m_iconManager.addIcon( std::string( "image" ), image_xpm );
m_iconManager.addIcon( std::string( "preferences" ), preferences_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() ) if( objectName().isEmpty() )
{ {
setObjectName( QString::fromUtf8( "MainWindow" ) ); setObjectName( QString::fromUtf8( "MainWindow" ) );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment