//----------------------------------------------------------------------------- // Create task thumbnail //FIXME void daisy::createTaskThumbnail( TaskPtr task_tmp, int j ) { QIcon thumbnail; //thumbnail = QIcon( QPixmap::grabWindow ( task_tmp->win(), 0, 0, -1, -1 ) );//This would suck thumbnail = KIcon( task_tmp->icon( m_icodimension, m_icodimension, true ) ); m_taskicons[j]->setIcon(thumbnail); if ( m_orientation== QString("horizontal") ) { m_taskicons[j]->setGeometry( QRect( last_icopos[0]+( ( j* (m_icodimension+(m_icodimension*m_icospacing)) ) ), last_icopos[1], m_icodimension, m_icodimension) ); } else { m_taskicons[j]->setGeometry( QRect( last_icopos[0], last_icopos[1]+( ( j* (m_icodimension+(m_icodimension*m_icospacing)) ) ), m_icodimension, m_icodimension) ); } if (m_showtooltips_l) { Plasma::ToolTipContent toolTipData;toolTipData.setAutohide(false); QString str;QString desk_name = KWindowSystem::desktopName( task_tmp->desktop() ); if (task_tmp->desktop() != -1) {str.append( desk_name );str.insert( 0, i18n("On ") );} else str.insert( 0, i18n("On all desktops") ); toolTipData.setMainText( task_tmp->visibleNameWithState() ); toolTipData.setSubText( str ); if ( m_tiptype == "thumbnail" ) toolTipData.setWindowToPreview( task_tmp->window() ); if ( m_tiptype == "thumbnail" || m_tiptype == "icon" ) toolTipData.setImage( task_tmp->icon(32, 32, true) ); Plasma::ToolTipManager::self()->setContent(m_taskicons[j], toolTipData); } }
//----------------------------------------------------------------------------- // Get all the tasks //FIXME QList<WId> daisy::getAllTasks() { m_activetasks.clear();m_attentionwindow.clear();showedTasks.clear(); QList<WId> taskDict = KWindowSystem::windows(); m_activewindow = -1;m_startingwindow = -1;m_closingwindow = -1; Plasma::ToolTipContent toolTipData;toolTipData.setAutohide(false); QString str;QString widclass_tmp;total_taskpreviews=0; //THUMBNAILS if ( m_taskpreviews && m_type == QString("standard_dock") ) { for (int i = 0; i < m_max_taskpreviews; ++i) {m_taskicons[i]->setGeometry( QRect(-10000, -10000, 0, 0) );} } if (m_showtooltips_l)clearToolTipContent(); QList<WId>::ConstIterator it; for (it = taskDict.begin(); it != taskDict.end(); ++it ) { KWindowInfo taskInfo = KWindowSystem::windowInfo( *it, NET::WMName | NET::WMVisibleName | NET::WMVisibleIconName | NET::WMState | NET::XAWMState | NET::WMDesktop | NET::WMWindowType, NET::WM2WindowClass ); TaskPtr task_tmp = TaskManager::TaskManager::self()->findTask( *it ); if ( task_tmp && *it == KWindowSystem::activeWindow() ) {m_focusedWindow = *it;} //THUMBNAILS if ( m_taskpreviews && m_type == QString("standard_dock") && task_tmp ) { if ( !m_showtaskoflauncher && ( m_alias.indexOf( taskInfo.windowClassName() ) != -1 || m_alias.indexOf( QString(taskInfo.windowClassClass().toLower()) ) != -1 ) ) {} else if ( total_taskpreviews<m_max_taskpreviews ) { createTaskThumbnail(task_tmp, total_taskpreviews); total_taskpreviews++; showedTasks << *it; } } if ( m_alias.indexOf( taskInfo.windowClassName() ) != -1 || m_alias.indexOf( QString(taskInfo.windowClassClass().toLower()) ) != -1 ) { if ( m_alias.indexOf( taskInfo.windowClassName() ) != -1 ) widclass_tmp = QString( taskInfo.windowClassName() ); else widclass_tmp = QString(taskInfo.windowClassClass().toLower()); //ATTENTION checkAttention( taskInfo, widclass_tmp ); m_activetasks << m_alias.indexOf( widclass_tmp ); if ( *it == KWindowSystem::activeWindow() ) m_activewindow = m_alias.indexOf( widclass_tmp ); //TOLLTIPS if (m_showtooltips_l) { str.clear();QString desk_name = KWindowSystem::desktopName( taskInfo.desktop() ); int win_count = m_activetasks.count( m_alias.indexOf( widclass_tmp ) ); if ( win_count == 1 ) { if (taskInfo.desktop() != -1) {str.append( desk_name );str.insert( 0, i18n("On ") );} else str.insert( 0, i18n("On all desktops") ); toolTipData.setMainText( taskInfo.visibleIconNameWithState() ); toolTipData.setSubText( str ); } else { str.setNum( win_count );str.append( i18n(" instances") ); toolTipData.setMainText( widclass_tmp ); toolTipData.setSubText( str ); } if ( m_tiptype == "thumbnail" ) { #if (KDE_VERSION_MINOR < 3) toolTipData.setWindowToPreview(*it); #else toolTipData.setWindowsToPreview( matchAllTasks( widclass_tmp, 4 ) ); #endif } if ( m_tiptype == "thumbnail" || m_tiptype == "icon" ) toolTipData.setImage( KIcon( m_values[m_alias.indexOf( widclass_tmp )][2]).pixmap(IconSize(KIconLoader::Panel)) ); Plasma::ToolTipManager::self()->setContent(m_widgets[m_alias.indexOf( widclass_tmp )], toolTipData); } } } //THUMBNAILS if ( m_taskpreviews && m_type == QString("standard_dock") ) { resizeRepos( true ); } return taskDict; }
//----------------------------------------------------------------------------- // Window changed //FIXME Signal is emited 4 times? void daisy::windowChanged(WId id, const unsigned long* properties ) { QString widclass_tmp; Plasma::ToolTipContent toolTipData;toolTipData.setAutohide(false); KWindowInfo taskInfo = KWindowSystem::windowInfo( id, NET::WMName | NET::WMVisibleName | NET::WMVisibleIconName | NET::WMState | NET::XAWMState | NET::WMDesktop, NET::WM2WindowClass ); TaskPtr task_tmp = TaskManager::TaskManager::self()->findTask( id ); if ( m_alias.indexOf( taskInfo.windowClassName() ) != -1 || m_alias.indexOf( QString(taskInfo.windowClassClass().toLower()) ) != -1 ) { if ( m_alias.indexOf( taskInfo.windowClassName() ) != -1 ) {widclass_tmp = QString( taskInfo.windowClassName() );} else {widclass_tmp = QString(taskInfo.windowClassClass().toLower());} //ATTENTION checkAttention( taskInfo, widclass_tmp ); if (m_showtooltips_l) { int win_count = m_activetasks.count( m_alias.indexOf( widclass_tmp ) ); QString str;QString desk_name = KWindowSystem::desktopName( taskInfo.desktop() ); if ( win_count == 1 ) { if (taskInfo.desktop() != -1) {str.append( desk_name );str.insert( 0, i18n("On ") );} else str.insert( 0, i18n("On all desktops") ); toolTipData.setMainText( taskInfo.visibleIconNameWithState() ); toolTipData.setSubText( str ); } else { str.setNum( win_count );str.append( i18n(" instances") ); toolTipData.setMainText( widclass_tmp ); toolTipData.setSubText( str ); } if ( m_tiptype == "thumbnail" ) { #if (KDE_VERSION_MINOR < 3) toolTipData.setWindowToPreview(id); #else toolTipData.setWindowsToPreview( matchAllTasks( widclass_tmp, 4 ) ); #endif } if ( m_tiptype == "thumbnail" || m_tiptype == "icon" ) toolTipData.setImage( task_tmp->icon(32, 32, true) ); Plasma::ToolTipManager::self()->setContent(m_widgets[m_alias.indexOf( widclass_tmp )], toolTipData); } if ( m_taskpreviews && m_type == QString("standard_dock") && showedTasks.indexOf( id )!=-1 ) { if (m_showtooltips_l && task_tmp) {Plasma::ToolTipManager::self()->setContent(m_taskicons[showedTasks.indexOf( id )], toolTipData);} if(properties[ NETWinInfo::PROTOCOLS ] & NET::WMIcon) { m_uti_tmr->stop(); m_toupwid = id; m_uti_tmr->start(); } } } }