void NowPlaying::toolTipAboutToShow()
{
    Plasma::ToolTipContent toolTip;
    if (m_state == Playing || m_state == Paused) {
        toolTip.setMainText(m_title);
        toolTip.setSubText(i18nc("song performer, displayed below the song title", "by %1", m_artist));
        toolTip.setImage(m_artwork.scaled(QSize(50,50),Qt::KeepAspectRatio));
    } else {
        toolTip.setMainText(i18n("No current track."));
    }

    Plasma::ToolTipManager::self()->setContent(this, toolTip);
}
void GraphicalTimetableLine::createTooltip( Departure *departure )
{
    if ( isPopupShowing() || (formFactor() != Plasma::Horizontal
                          && formFactor() != Plasma::Vertical) ) {
        return;
    }

    Plasma::ToolTipContent tooltipData;
    tooltipData.setMainText( i18nc("@info", "Public Transport") );
    if ( m_departures.isEmpty() ) {
        tooltipData.setSubText( i18nc("@info", "View departures for public transport") );
    } else {
        QList<DepartureData> dataList = departure ? departure->departureData()
                : m_departures.first()->departureData();
        if ( dataList.count() == 1 ) {
            // Signle departure item hovered
            DepartureData data = dataList.first();
            tooltipData.setSubText( i18n("Line %1 (%2) %3",
                    data.transportLine, data.target, KGlobal::locale()->formatTime(data.time.time())) );
        } else {
            // Multiple departure items hovered
            QString text;
            foreach ( const DepartureData &data, dataList ) {
                text.append( i18n("Line %1 (%2) %3\n",
                        data.transportLine, data.target, KGlobal::locale()->formatTime(data.time.time())) );
            }
            if ( text.endsWith('\n') ) {
                text.remove( text.length() - 1, 1 );
            }
            tooltipData.setSubText( text );
        }
    }
Exemple #3
0
void ClockApplet::updateTipContent()
{
    Plasma::ToolTipContent tipData;

    QString subText("<table>");
    QList<Plasma::DataEngine::Data> tzs;
    Plasma::DataEngine *engine = dataEngine("time");
    Plasma::DataEngine::Data data = engine->query("Local");
    const QDate localDate = data["Date"].toDate();
    const QString localTz = data["Timezone"].toString();
    tzs.append(data);
    bool highlightLocal = false;

    const bool hasEvents = d->calendarWidget ? d->calendarWidget->dateHasDetails(localDate) : false;
    tipData.setMainText(hasEvents ? i18n("Current Time and Events") : i18n("Current Time"));

    foreach (const QString &tz, d->selectedTimezones) {
        if (tz != "UTC") {
            highlightLocal = true;
        }

        data = engine->query(tz);
        tzs.append(data);
    }

    qSort(tzs.begin(), tzs.end(), sortTzByData);
    QDate currentDate;
    foreach (const Plasma::DataEngine::Data &data, tzs) {
        bool shouldHighlight = highlightLocal && (data["Timezone"].toString() == localTz);
        currentDate = d->addTzToTipText(subText, data, currentDate, shouldHighlight);
    }
void GamesViewItem::setToolTips()
{
    Plasma::ToolTipContent data;
    data.setImage( m_preview->icon() );
    data.setMainText( m_gameName->text() );
    data.setSubText( i18n( "Click here to Start the game" ) );
    Plasma::ToolTipManager::self()->setContent( m_playButton, data );
}
Exemple #5
0
void Options::randomTrack()
{
   Plasma::ToolTipContent data;
   data.setSubText(i18n("Play random track"));
   data.setImage(KIcon("roll").pixmap(IconSize(KIconLoader::Desktop)));
   if (randomFlag) {
       data.setMainText(i18n("Random - off"));
       randomFlag = false;
       emit activeRandom(false);
   }
   else {
       data.setMainText(i18n("Random - on"));
       randomFlag = true;
       emit activeRandom(true);
   }

   Plasma::ToolTipManager::self()->setContent(m_random, data);
}
void ActivityManager::toolTipAboutToShow() {
  Plasma::ToolTipContent toolTip;

  toolTip.setMainText(i18n("Current Activity: %1").arg(m_currentName));
  if (!m_currentIcon.isEmpty())
    toolTip.setImage(KIcon(m_currentIcon));

  Plasma::ToolTipManager::self()->setContent(this, toolTip);
}
Exemple #7
0
void Options::loopList()
{
   Plasma::ToolTipContent data;
   data.setSubText(i18n("Play again the tracklist"));
   data.setImage(KIcon("object-rotate-right").pixmap(IconSize(KIconLoader::Desktop)));
   
   if (loopFlag) {
       data.setMainText(i18n("Repeat - off"));
       loopFlag = false;
       emit activeRepeat(false);
   }
   else {
       data.setMainText(i18n("Repeat - on"));
       loopFlag = true;
       emit activeRepeat(true);
   }

   Plasma::ToolTipManager::self()->setContent(m_loop, data);
}
void FastUserSwitch::setupTooltip()
{
  QString username = getUsername(!m_useCompleteName);
  QPixmap pixmap;

  if (m_useUserImage) {
    pixmap = m_userpixmap.scaledToHeight(qMin(IconSize(KIconLoader::Desktop),
                                              m_userpixmap.height()));
  } else
    pixmap = KIcon(DEFAULT_ICON_NAME).pixmap(IconSize(KIconLoader::Desktop));

  Plasma::ToolTipContent data;
  data.setMainText(i18n("Fast user switch"));
  data.setSubText(i18n("You are currently logged in as <em>%1</em>.",
                       username));
  data.setImage(pixmap);
  Plasma::ToolTipManager::self()->setContent(this, data);
}
Exemple #9
0
void StackFolder::updateIconWidget()
{
    if (!m_placesModel) {
        m_placesModel = new KFilePlacesModel(this);

        const QModelIndex index = m_placesModel->closestItem(m_topUrl);
        const KUrl url = m_placesModel->url(index);

        KFileItem item = m_dirModel->itemForIndex(QModelIndex());

        if (!item.isNull() && item.iconName() != "inode-directory") {
            m_icon = KIcon(item.iconName(), 0, item.overlays());
        } 
        else if (m_topUrl.protocol() == "desktop") {
            m_icon = KIcon("user-desktop");
        } 
        else if (m_topUrl.protocol() == "trash") {
            m_icon = m_model->rowCount() > 0 ? KIcon("user-trash-full") : KIcon("user-trash");
        } 
        else if (index.isValid() && url.equals(m_topUrl, KUrl::CompareWithoutTrailingSlash)) {
            m_icon = m_placesModel->icon(index);
        }

        m_iconAnimation1 = new QPropertyAnimation(this, "popupIconSize");
        m_iconAnimation1->setDuration(600);
        m_iconAnimation2 = new QPropertyAnimation(this, "popupIconSize");
        m_iconAnimation1->setDuration(600);
        m_iconAnimationGroup = new QSequentialAnimationGroup;
        m_iconAnimationGroup->addAnimation(m_iconAnimation1);
        m_iconAnimationGroup->addAnimation(m_iconAnimation2);
        m_iconAnimationGroup->setLoopCount(4);
        connect(m_iconAnimationGroup, SIGNAL(finished()), this, SLOT(iconAnimationFinished()));

        setPopupIcon(m_icon);

        // Update the tooltip
        Plasma::ToolTipContent data;
        data.setMainText(i18n("Stack Folder"));
        data.setSubText(m_topUrl.fileName(KUrl::IgnoreTrailingSlash));
        data.setImage(m_icon);
        Plasma::ToolTipManager::self()->setContent(this, data);

    }
}
Exemple #10
0
//-----------------------------------------------------------------------------
// 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);
  }

  
}
Exemple #11
0
MainWindow::MainWindow(QObject *parent, const QVariantList &args)
        : Plasma::PopupApplet(parent, args),
          takeoff(new TakeoffWidget(this))
{
    // Plasmoid aspect
    this->setBackgroundHints(DefaultBackground);
    this->setAspectRatioMode(Plasma::IgnoreAspectRatio);

    // Hide the popup when an application is launched
    connect(this->takeoff, SIGNAL(clicked()), this, SLOT(hidePopup()));

    // Load the configuration
    this->loadConfig();

    // Tooltip
    Plasma::ToolTipContent data;
    data.setMainText(i18n("Takeoff Launcher"));
    data.setSubText(i18n("Launch your applications with elegance"));
    data.setImage(this->popupIcon().pixmap(IconSize(KIconLoader::Desktop)));
    Plasma::ToolTipManager::self()->setContent(this, data);

    connect(this->takeoff, SIGNAL(hideWindow()),
            this, SLOT(slotHide()));
}
Exemple #12
0
Options::Options(QGraphicsWidget *parent)
    : QGraphicsWidget(parent),
     // m_volume(new Plasma::IconWidget(this)),
      //m_meter(new KcdMeter(this)),
      //m_tracklist(new Plasma::IconWidget(this)),
      m_albumText(new Plasma::Label(this)),
      m_random(new Plasma::IconWidget(this)),
      m_loop(new Plasma::IconWidget(this))
{
 
   //m_volume->setIcon("audio-volume-high");
   //connect (m_volume, SIGNAL(clicked()), this, SLOT(handleVolume()));
   //m_volume->setMinimumSize(m_random->sizeFromIconSize(10));

   //m_meter->setMinimum(0);
   //m_meter->setMaximum(10);
   //m_meter->setMeterType(Plasma::Meter::BarMeterHorizontal);
   //connect (m_meter, SIGNAL(valueChanged(int)), this, SIGNAL(volumeChanged(int)));

   //m_tracklist->setIcon("format-list-unordered");
   //m_tracklist->setMinimumSize(m_random->sizeFromIconSize(10));
   //connect(m_tracklist, SIGNAL(clicked()), this, SIGNAL(showTrackList()));

   Plasma::ToolTipContent data;
   //data.setMainText(i18n("Tracklist"));
   //data.setSubText(i18n("View the tracklist"));
   //data.setImage(KIcon("format-list-unordered").pixmap(IconSize(KIconLoader::Desktop)));
   //Plasma::ToolTipManager::self()->setContent(m_tracklist, data);

   m_random->setIcon("roll");
   connect(m_random, SIGNAL(clicked()), this, SLOT(randomTrack()));
   
   data.setMainText(i18n("Random - off"));
   data.setSubText(i18n("Play random track"));
   data.setImage(KIcon("roll").pixmap(IconSize(KIconLoader::Desktop)));
   Plasma::ToolTipManager::self()->setContent(m_random, data);

   m_loop->setIcon("object-rotate-right");
   connect(m_loop, SIGNAL(clicked()), this, SLOT(loopList()));

   data.setMainText(i18n("Repeat - off"));
   data.setSubText(i18n("Play again the tracklist"));
   data.setImage(KIcon("object-rotate-right").pixmap(IconSize(KIconLoader::Desktop)));
   Plasma::ToolTipManager::self()->setContent(m_loop, data);

   QGraphicsLinearLayout *layout = new QGraphicsLinearLayout;
   layout->setOrientation(Qt::Horizontal);
   //layout->addItem(m_volume);
   //layout->addItem(m_meter);
   layout->addItem(m_albumText);
   layout->addItem(m_random);
   layout->addItem(m_loop);
   layout->setAlignment(m_albumText, Qt::AlignLeft);
   layout->setAlignment(m_random, Qt::AlignRight);
   layout->setAlignment(m_loop, Qt::AlignRight);
   layout->setStretchFactor(m_random, 0);
   layout->setStretchFactor(m_loop, 0);
   setPreferredHeight(35);
   
   //layout->setItemSpacing(0, 50);
  
  
   //layout->addItem(m_tracklist);
   //layout->setStretchFactor(m_meter, 20);
   //layout->setSpacing(0);
   //layout->setAlignment(m_random, Qt::AlignRight);
   //layout->setAlignment(m_loop, Qt::AlignRight);
   //layout->setAlignment(m_tracklist, Qt::AlignRight);
   //layout->setItemSpacing(1, 10);
   setLayout(layout);

   randomFlag = false;
   loopFlag = false;
   //volumeFlag = true;

   
}
Exemple #13
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;
}
Exemple #14
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();
      }
    }
  
    
    
  }

  
}