From ed42331c2e72664b71ace0c49bfe9f23ec7365ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= Date: Thu, 29 Jan 2009 15:11:17 +0000 Subject: [PATCH] Testapp to show all icons provided by a window. svn path=/trunk/KDE/kdebase/workspace/; revision=918189 --- tools/CMakeLists.txt | 8 +++++++- tools/show_icons.cpp | 48 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 tools/show_icons.cpp diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index f0e41902f0..7fe64b884b 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -7,8 +7,14 @@ add_subdirectory( decobenchmark ) set(test_gravity_SRCS test_gravity.cpp ) - kde4_add_executable(test_gravity ${test_gravity_SRCS}) target_link_libraries(test_gravity ${KDE4_KDECORE_LIBS} ) +########### next target ############### + +set(show_icons_SRCS show_icons.cpp ) + +kde4_add_executable(show_icons ${show_icons_SRCS}) + +target_link_libraries(show_icons ${KDE4_KDEUI_LIBS} ) diff --git a/tools/show_icons.cpp b/tools/show_icons.cpp new file mode 100644 index 0000000000..d070a2890b --- /dev/null +++ b/tools/show_icons.cpp @@ -0,0 +1,48 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +int main( int argc, char* argv[] ) + { + KAboutData about( "a", "b", ki18n( "c" ), "d" ); + KCmdLineArgs::init( argc, argv, &about ); + KCmdLineOptions args; + args.add( "window ", ki18n( "Window to show icons for" )); + KCmdLineArgs::addCmdLineOptions( args ); + KApplication app; + QWidget w; + QGridLayout l( &w ); + l.setSpacing( 5 ); + WId window = KCmdLineArgs::parsedArgs()->getOption( "window" ).toLong(); + NETWinInfo info( QX11Info::display(), window, QX11Info::appRootWindow(), NET::WMIcon ); + const int* sizes = info.iconSizes(); + int i = 0; + for(; + sizes[ i * 2 ] != 0; + ++i ) + { + int width = sizes[ i * 2 ]; + int height = sizes[ i * 2 + 1 ]; + l.addWidget( new QLabel( QString( "EWMH: %1x%2" ).arg( width ).arg( height ), &w ), 0, i ); + QLabel* ll = new QLabel( &w ); + ll->setPixmap( KWindowSystem::icon( window, width, height, KWindowSystem::NETWM )); + l.addWidget( ll, 1, i, Qt::AlignCenter ); + } + QLabel* ll; + l.addWidget( new QLabel( "ICCCM", &w ), 0, i ); + ll = new QLabel( &w ); + ll->setPixmap( KWindowSystem::icon( window, -1, -1, KWindowSystem::WMHints )); + l.addWidget( ll, 1, i, Qt::AlignCenter ); + ++i; + l.addWidget( new QLabel( "CLASS", &w ), 0, i ); + ll = new QLabel( &w ); + ll->setPixmap( KWindowSystem::icon( window, -1, -1, KWindowSystem::WMHints )); + l.addWidget( ll, 1, i, Qt::AlignCenter ); + w.show(); + return app.exec(); + }