Commit aa8b60d2 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum

[CHANGE #195] further improvements in icon management

parent 86127489
/* XPM */
static const char * emptyIcon_xpm[] = {
"32 32 35 1",
" c None",
". c #FFFFFF",
"+ c #D0D0D0",
"@ c #EAEAEA",
"# c #DBDBDB",
"$ c #F9F9F9",
"% c #F6F6F6",
"& c #DEDEDE",
"* c #E5E5E5",
"= c #EEEEEE",
"- c #F0F0F0",
"; c #D7D7D7",
"> c #D1D1D1",
", c #FDFDFD",
"' c #DADADA",
") c #FBFBFB",
"! c #F3F3F3",
"~ c #D4D4D4",
"{ c #F2F2F2",
"] c #E2E2E2",
"^ c #DDDDDD",
"/ c #EDEDED",
"( c #E1E1E1",
"_ c #D3D3D3",
": c #FEFEFE",
"< c #FAFAFA",
"[ c #DCDCDC",
"} c #EFEFEF",
"| c #F4F4F4",
"1 c #F8F8F8",
"2 c #EBEBEB",
"3 c #D8D8D8",
"4 c #D5D5D5",
"5 c #F1F1F1",
"6 c #E9E9E9",
"................................",
"................................",
".+@......+......................",
".+#$.....+......................",
".+%&.....+......................",
".+.*=....+....-;>;-.............",
".+.,')...+...!~{,{~!............",
".+..{]...+...^=.../^............",
".+...({..+..._)...)_............",
".+...)',.+...+:...:+............",
".+....=*.+..._)...<_............",
".+.....&%+...^/.../[............",
".+.....$#+...{~{,{~!............",
".+......@+....};+;-.............",
"................................",
"................................",
"................................",
"..+.............................",
"..+.............................",
"..+.............................",
"..+....{'>'}....-;>;-...+!#>++-.",
"..+...|_},1'2..!~{,{~!..+3{,.-+.",
"..+...&/...%4..^=.../^..+!....+.",
"..+...~)......._)...)_..+,....+.",
"..+...+:.......+:...:+..+.....+.",
"..+..._)......._)...<_..+.....+.",
"..+...^=...14..^/.../[..+.....+.",
"..+...!~{,%'@..{~{,{~!..+.....+.",
"..+....53+46....};+;-...+.....+.",
"................................",
"................................",
"................................"};
......@@ -27,7 +27,6 @@
#include <utility>
#include <vector>
#include "../../emptyIcon.xpm" // Please put a real icon here.
#include "core/common/datastructures/WDendrogram.h"
#include "core/common/datastructures/WUnionFind.h"
#include "core/common/WLimits.h"
......@@ -50,7 +49,7 @@ boost::shared_ptr< WModule > WMDetTractClusteringGP::factory() const
const char** WMDetTractClusteringGP::getXPMIcon() const
{
return emptyIcon_xpm; // Please put a real icon here.
return NULL; // Please put a real icon here.
}
const std::string WMDetTractClusteringGP::getName() const
{
......
......@@ -29,7 +29,6 @@
#include "core/graphicsEngine/WGEGeodeUtils.h"
#include "core/graphicsEngine/callbacks/WGEFunctorCallback.h"
#include "core/kernel/WKernel.h"
#include "../../emptyIcon.xpm" // Please put a real icon here.
#include "WMGpView.h"
......@@ -50,7 +49,7 @@ boost::shared_ptr< WModule > WMGpView::factory() const
const char** WMGpView::getXPMIcon() const
{
return emptyIcon_xpm; // Please put a real icon here.
return NULL; // Please put a real icon here.
}
const std::string WMGpView::getName() const
{
......
......@@ -25,7 +25,6 @@
#include <string>
#include "core/kernel/WKernel.h"
#include "modules/emptyIcon.xpm" // Please put a real icon here.
#include "core/dataHandler/WDataSetScalar.h"
#include "core/kernel/WSelectionManager.h"
......@@ -56,7 +55,7 @@ boost::shared_ptr< WModule > WMOpenIGTLinkSender::factory() const
const char** WMOpenIGTLinkSender::getXPMIcon() const
{
return emptyIcon_xpm; // Please put a real icon here.
return NULL; // Please put a real icon here.
}
const std::string WMOpenIGTLinkSender::getName() const
{
......
......@@ -128,7 +128,7 @@ boost::shared_ptr< WModule > WMTemplate::factory() const
const char** WMTemplate::getXPMIcon() const
{
// 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 is deprecated! You can still use it as fallback if you do not specify a META file.
//
// 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.
......
......@@ -27,7 +27,6 @@
#include "core/dataHandler/WDataSetVector.h"
#include "core/kernel/WKernel.h"
#include "modules/emptyIcon.xpm" // Please put a real icon here.
#include "WMVectorAlign.h"
// This line is needed by the module loader to actually find your module. Do not remove. Do NOT add a ";" here.
......@@ -49,7 +48,7 @@ boost::shared_ptr< WModule > WMVectorAlign::factory() const
const char** WMVectorAlign::getXPMIcon() const
{
return emptyIcon_xpm; // Please put a real icon here.
return NULL; // Please put a real icon here.
}
const std::string WMVectorAlign::getName() const
......
/* XPM */
const char * moduleDefault_xpm[] = {
"32 32 129 2",
" c None",
". c #858585",
"+ c #BFBFBF",
"@ c #D0D0D0",
"# c #D6D6D6",
"$ c #C2C2C2",
"% c #848484",
"& c #949494",
"* c #FFFFFF",
"= c #F9F9F9",
"- c #939393",
"; c #B6B6B6",
"> c #FEFEFE",
", c #FAFAFA",
"' c #9C9C9C",
") c #727272",
"! c #EEEEEE",
"~ c #555555",
"{ c #DEDEDE",
"] c #F7F7F7",
"^ c #F6F6F6",
"/ c #CDCDCD",
"( c #333333",
"_ c #EDEDED",
": c #585858",
"< c #7F7F7F",
"[ c #F5F5F5",
"} c #F3F3F3",
"| c #606060",
"1 c #979797",
"2 c #EFEFEF",
"3 c #F4F4F4",
"4 c #F8F8F8",
"5 c #DBDBDB",
"6 c #8F8F8F",
"7 c #626262",
"8 c #F0F0F0",
"9 c #6A6A6A",
"0 c #757575",
"a c #F1F1F1",
"b c #F2F2F2",
"c c #494949",
"d c #D3D3D3",
"e c #EBEBEB",
"f c #E9E9E9",
"g c #ECECEC",
"h c #EAEAEA",
"i c #363636",
"j c #E4E4E4",
"k c #E7E7E7",
"l c #E8E8E8",
"m c #E1E1E1",
"n c #DDDDDD",
"o c #D4D4D4",
"p c #DCDCDC",
"q c #DFDFDF",
"r c #E0E0E0",
"s c #343434",
"t c #434343",
"u c #DADADA",
"v c #717171",
"w c #E2E2E2",
"x c #E6E6E6",
"y c #E5E5E5",
"z c #6F6F6F",
"A c #CACACA",
"B c #E3E3E3",
"C c #C9C9C9",
"D c #3C3C3C",
"E c #D7D7D7",
"F c #7D7D7D",
"G c #303030",
"H c #313131",
"I c #828282",
"J c #3D3D3D",
"K c #7A7A7A",
"L c #A7A7A7",
"M c #ADADAD",
"N c #C8C8C8",
"O c #D9D9D9",
"P c #D2D2D2",
"Q c #D8D8D8",
"R c #C3C3C3",
"S c #B0B0B0",
"T c #AFAFAF",
"U c #CECECE",
"V c #CFCFCF",
"W c #D5D5D5",
"X c #747474",
"Y c #777777",
"Z c #CBCBCB",
"` c #D1D1D1",
" . c #989898",
".. c #C7C7C7",
"+. c #959595",
"@. c #C5C5C5",
"#. c #C0C0C0",
"$. c #696969",
"%. c #737373",
"&. c #CCCCCC",
"*. c #8A8A8A",
"=. c #545454",
"-. c #999999",
";. c #B9B9B9",
">. c #8E8E8E",
",. c #4B4B4B",
"'. c #484848",
"). c #404040",
"!. c #B7B7B7",
"~. c #BBBBBB",
"{. c #C6C6C6",
"]. c #BDBDBD",
"^. c #676767",
"/. c #6C6C6C",
"(. c #373737",
"_. c #393939",
":. c #C1C1C1",
"<. c #616161",
"[. c #636363",
"}. c #515151",
"|. c #6B6B6B",
"1. c #505050",
"2. c #2B2B2B",
"3. c #8C8C8C",
"4. c #929292",
"5. c #595959",
"6. c #A6A6A6",
"7. c #AEAEAE",
"8. c #A4A4A4",
" ",
" . + @ # $ % ",
" & * = = * - ",
" ; > , , * ' ",
" ) ! ~ { ] ^ ^ = / ( _ : ",
" < , [ } | 1 2 * ^ 3 3 3 [ 4 * 5 6 7 8 ^ 3 9 ",
" 0 ^ ! ! a 4 [ a a a a b b b a a } ^ ^ a ! 2 8 c ",
" d e f g _ ! 2 8 2 8 b a a b 8 2 ! ! _ g e h _ + ",
" i j k l g _ 2 8 m { n d o p q r 8 g e h f f f s ",
" t g j l ! 8 { n q q q { { n u # e h l k _ ~ ",
" v k w j f q q q r q q q q n p 5 u l x y h z ",
" A r r y d u { r m k f l y q p 5 u n x B B C ",
" D j p q E o E 5 w q F G H I n m 5 u # r w q k J ",
" K L M N O u q P o E 5 n 5 { u Q E w { { R S T ",
" & U V P W O { V o E r X Y y u Q @ w n O E d P & ",
" - C Z V d E u U P # m k u E ` n 5 E o V U . ",
" 6 ..C / @ W o Z ` W { x u W V u O W ` / Z +. ",
" ' @...A U ` O #.V d q $. %.B Q o C n E d V &.Z *. ",
" =.*.-.;./ V W Z / @ # d Q u W ` Z u d P ;.>.< ,. ",
" '.@ Z @ &.A U ` Q W . -.{ r E ` V / o @ # ). ",
" !.C &.d ~.A U @ W 5 m B r p 5 O ` {.Q ` U ]. ",
" ^./ / @ P C &.V ` o E Q O O Q E P O o ` d /. ",
" (.` / @ d # @.U V ` d W W W # ` m m E @ # _. ",
" $ Z &.@ P W u C A U V V @ P O B r { 5 P U :. ",
" #.A C &.V P o E O p n n n q r { n p u Q W U U / ",
" c @ Z &.` Q O # E O u 5 u 5 5 5 p q q E d @ d <. ",
" [.W ` d }.%.&.w O Q O O O u B A |.1.W d # v ",
" : ].i t :.Q Q Q O :.t 2.:.<. ",
" 3.O E E 5 6 ",
" 4.{ u 5 r % ",
" 5.6.T 7.8.1. ",
" "};
static const char * moduleDefault_xpm[] = {
"32 32 35 1",
" c None",
". c #FFFFFF",
"+ c #D0D0D0",
"@ c #EAEAEA",
"# c #DBDBDB",
"$ c #F9F9F9",
"% c #F6F6F6",
"& c #DEDEDE",
"* c #E5E5E5",
"= c #EEEEEE",
"- c #F0F0F0",
"; c #D7D7D7",
"> c #D1D1D1",
", c #FDFDFD",
"' c #DADADA",
") c #FBFBFB",
"! c #F3F3F3",
"~ c #D4D4D4",
"{ c #F2F2F2",
"] c #E2E2E2",
"^ c #DDDDDD",
"/ c #EDEDED",
"( c #E1E1E1",
"_ c #D3D3D3",
": c #FEFEFE",
"< c #FAFAFA",
"[ c #DCDCDC",
"} c #EFEFEF",
"| c #F4F4F4",
"1 c #F8F8F8",
"2 c #EBEBEB",
"3 c #D8D8D8",
"4 c #D5D5D5",
"5 c #F1F1F1",
"6 c #E9E9E9",
"................................",
"................................",
".+@......+......................",
".+#$.....+......................",
".+%&.....+......................",
".+.*=....+....-;>;-.............",
".+.,')...+...!~{,{~!............",
".+..{]...+...^=.../^............",
".+...({..+..._)...)_............",
".+...)',.+...+:...:+............",
".+....=*.+..._)...<_............",
".+.....&%+...^/.../[............",
".+.....$#+...{~{,{~!............",
".+......@+....};+;-.............",
"................................",
"................................",
"................................",
"..+.............................",
"..+.............................",
"..+.............................",
"..+....{'>'}....-;>;-...+!#>++-.",
"..+...|_},1'2..!~{,{~!..+3{,.-+.",
"..+...&/...%4..^=.../^..+!....+.",
"..+...~)......._)...)_..+,....+.",
"..+...+:.......+:...:+..+.....+.",
"..+..._)......._)...<_..+.....+.",
"..+...^=...14..^/.../[..+.....+.",
"..+...!~{,%'@..{~{,{~!..+.....+.",
"..+....53+46....};+;-...+.....+.",
"................................",
"................................",
"................................"};
......@@ -28,6 +28,7 @@
#include <QtGui/QPixmap>
#include "core/common/WAssert.h"
#include "core/common/WLogger.h"
#include "core/common/exceptions/WFileNotFound.h"
#include "core/kernel/WModuleFactory.h"
#include "WIconManager.h"
......@@ -59,37 +60,51 @@ void WIconManager::addIcon( std::string name, const QPixmap& pixmap )
QIcon WIconManager::getIcon( const std::string name )
{
QIcon icon;
if( m_iconList.count( name ) != 0 )
{
icon = *m_iconList[name];
return *m_iconList[name];
}
else if( WModuleFactory::getModuleFactory()->getPrototypeByName( name ) )
{
// get module icon from meta info if available
WModuleMetaInformation::ConstSPtr meta = WModuleFactory::getModuleFactory()->getPrototypeByName( name )->getMetaInformation();
const char** xpm = WModuleFactory::getModuleFactory()->getPrototypeByName( name )->getXPMIcon();
// prefer meta info icon
if( meta->isIconAvailable() && boost::filesystem::exists( meta->getIcon() ) )
{
try
{
icon = QIcon( QPixmap( QString::fromStdString( meta->getIcon().string() ) ) );
return QIcon( QPixmap( QString::fromStdString( meta->getIcon().string() ) ) );
}
catch( ... )
{
icon = QIcon( QPixmap( WModuleFactory::getModuleFactory()->getPrototypeByName( name )->getXPMIcon() ) );
if( xpm )
{
return QIcon( QPixmap( xpm ) );
}
else
{
return QIcon();
}
}
}
else
{
icon = QIcon( QPixmap( WModuleFactory::getModuleFactory()->getPrototypeByName( name )->getXPMIcon() ) );
if( xpm )
{
return QIcon( QPixmap( xpm ) );
}
else
{
return QIcon();
}
}
}
else
{
WAssert( 0, "Found no icon named: " + name );
}
return icon;
}
QIcon WIconManager::getIcon( const std::string name, const QIcon& defaultIcon )
......@@ -102,24 +117,45 @@ QIcon WIconManager::getIcon( const std::string name, const QIcon& defaultIcon )
{
// get module icon from meta info if available
WModuleMetaInformation::ConstSPtr meta = WModuleFactory::getModuleFactory()->getPrototypeByName( name )->getMetaInformation();
const char** xpm = WModuleFactory::getModuleFactory()->getPrototypeByName( name )->getXPMIcon();
// prefer meta info icon
if( meta->isIconAvailable() && boost::filesystem::exists( meta->getIcon() ) )
{
try
{
wlog::error( "hhhhhhhhhhhhhhhhhhHaaaaaaaaaaaaasssssssssssssssa" ) << meta->getIcon().string() << " " << name;
return QIcon( QPixmap( QString::fromStdString( meta->getIcon().string() ) ) );
}
catch( ... )
{
return QIcon( QPixmap( WModuleFactory::getModuleFactory()->getPrototypeByName( name )->getXPMIcon() ) );
if( xpm )
{
return QIcon( QPixmap( xpm ) );
}
else
{
return defaultIcon;
}
}
}
else
{
return QIcon( QPixmap( WModuleFactory::getModuleFactory()->getPrototypeByName( name )->getXPMIcon() ) );
if( xpm )
{
return QIcon( QPixmap( xpm ) );
}
else
{
return defaultIcon;
}
}
}
else
{
return QIcon( defaultIcon );
return defaultIcon;
}
}
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