Ejemplo n.º 1
0
KasTaskItem::KasTaskItem( KasTasker *parent, Task::Ptr task )
    : KasItem( parent ),
      task_(task),
      thumbTimer(0),
      attentionTimer(0)
{
    setIcon( icon() );
    setAttention( task->demandsAttention() );
    updateTask(false);

    connect( task, SIGNAL( changed(bool) ), this, SLOT( updateTask(bool) ) );
    connect( task, SIGNAL( activated() ), this, SLOT( startAutoThumbnail() ) );
    connect( task, SIGNAL( deactivated() ), this, SLOT( stopAutoThumbnail() ) );
    connect( task, SIGNAL( iconChanged() ), this, SLOT( iconChanged() ) );
    connect( task, SIGNAL( thumbnailChanged() ), this, SLOT( iconChanged() ) );

    connect( this, SIGNAL(leftButtonClicked(QMouseEvent *)), SLOT(toggleActivateAction()) );
    connect( this, SIGNAL(rightButtonClicked(QMouseEvent *)), SLOT(showWindowMenuAt(QMouseEvent *) ) );

    attentionTimer = new QTimer( this, "attentionTimer" );
    connect( attentionTimer, SIGNAL( timeout() ), SLOT( checkAttention() ) );
    attentionTimer->start( CHECK_ATTENTION_DELAY );
}
Ejemplo n.º 2
0
//-----------------------------------------------------------------------------
// 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;
}
Ejemplo n.º 3
0
//-----------------------------------------------------------------------------
// 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();
      }
    }
  
    
    
  }

  
}