void KMixDockWidget::updatePixmap() { shared_ptr<MixDevice> md = Mixer::getGlobalMasterMD(); char newPixmapType; if ( !md ) { // no such control => error newPixmapType = 'e'; } else { int percentage = md->getUserfriendlyVolumeLevel(); if ( percentage <= 0 ) newPixmapType = '0'; // Hint: also muted, and also negative-values else if ( percentage < 25 ) newPixmapType = '1'; else if ( percentage < 75 ) newPixmapType = '2'; else newPixmapType = '3'; } if ( newPixmapType != _oldPixmapType ) { // Pixmap must be changed => do so switch ( newPixmapType ) { case 'e': setIconByName( "kmixdocked_error" ); break; case 'm': case '0': setIconByName( "audio-volume-muted" ); break; case '1': setIconByName( "audio-volume-low" ); break; case '2': setIconByName( "audio-volume-medium" ); break; case '3': setIconByName( "audio-volume-high" ); break; } } _oldPixmapType = newPixmapType; }
void SysTrayIcon::setTimeLineUpdatesEnabled( bool isEnabled ) { if ( isEnabled ) { setToolTip( "choqok", i18n( "Choqok" ), QString() ); setIconByName("choqok"); } else { setToolTip( "choqok", i18n( "Choqok - Disabled" ), QString() ); setIconByName("choqok_offline"); } isOffline = !isEnabled; updateUnreadCount( 0 ); }
void KopeteSystemTray::slotReevaluateAccountStates() { // If there is a pending message, we don't need to refresh the system tray now. // This function will even be called when the animation will stop. if ( mBlinkTimer->isActive() ) return; Kopete::OnlineStatus highestStatus; foreach ( Kopete::Account *account, Kopete::AccountManager::self()->accounts()) { if ( account->myself() && account->myself()->onlineStatus() > highestStatus ) { highestStatus = account->myself()->onlineStatus(); } } switch ( highestStatus.status() ) { case Kopete::OnlineStatus::Unknown: case Kopete::OnlineStatus::Offline: case Kopete::OnlineStatus::Connecting: { setIconByName("kopete-offline"); setOverlayIconByName("user-offline"); break; } case Kopete::OnlineStatus::Invisible: { setIconByName(mKopeteIcon); setOverlayIconByName("user-invisible"); break; } case Kopete::OnlineStatus::Away: { setIconByName(mKopeteIcon); setOverlayIconByName("user-away"); break; } case Kopete::OnlineStatus::Busy: { setIconByName(mKopeteIcon); setOverlayIconByName("user-busy"); break; } case Kopete::OnlineStatus::Online: { setIconByName(mKopeteIcon); setOverlayIconByName(QString()); break; } } }
/** class Tray * Reimplementation of the KStatusNotifierItem class */ Tray::Tray(MainWindow * parent) : KStatusNotifierItem(parent) { // set up the context menu KMenu * cm = contextMenu(); cm->addAction( parent->actionCollection()->action("new_download") ); cm->addAction( parent->actionCollection()->action("import_links") ); cm->addSeparator(); cm->addAction( parent->actionCollection()->action("start_all_download") ); cm->addAction( parent->actionCollection()->action("stop_all_download") ); cm->addSeparator(); cm->addAction( parent->actionCollection()->action("konqueror_integration") ); cm->addAction( parent->actionCollection()->action("options_configure") ); // Set up basic tray parameters setCategory(ApplicationStatus); setIconByName("kget"); setTitle(i18n("KGet")); setContextMenu(cm); setAssociatedWidget(parent); setToolTipIconByName("kget"); setToolTipTitle(i18n("Download Manager")); // Not of much use atm, but maybe we want to set this later? // setToolTipSubTitle("[..]"); // filter middle mouse clicks to ask scheduler to paste URL connect( this, SIGNAL(secondaryActivateRequested(QPoint)), this, SLOT(slotActivated()) ); }
TrayIcon::TrayIcon(QObject* parent) : KStatusNotifierItem(parent), m_unread(0) { setToolTipTitle( i18n("Akregator") ); setToolTipIconByName( i18n("Akregator") ); setIconByName( "akregator" ); m_defaultIcon = KIcon( "akregator" ); }
KRulerSystemTray::KRulerSystemTray( const QString& iconName, QWidget *parent, KActionCollection *actions) : KStatusNotifierItem( parent ) { setIconByName( iconName ); setStatus(KStatusNotifierItem::Active); setToolTip( iconName, i18n( "KDE Screen Ruler" ), QString() ); QMenu *cm = contextMenu(); cm->addAction( actions->action( QStringLiteral( "preferences" ) ) ); }
void BangarangNotifierItem::setState(Phonon::State state) { if (m_currentState == state) return; m_currentState = state; if (m_currentState == Phonon::StoppedState) { setStatus(KStatusNotifierItem::Passive); setIconByName("bangarang-notifier"); } else if (m_currentState == Phonon::PausedState){ setStatus(KStatusNotifierItem::Active); setIconByName("bangarang-notifier-active-pause"); } else { setStatus(KStatusNotifierItem::Active); setIconByName("bangarang-notifier-active"); } }
SysTrayIcon::SysTrayIcon( Choqok::UI::MainWindow* parent ) : KStatusNotifierItem( parent ), _mainwin(parent), isOffline(false) { kDebug(); unread = 0; setAssociatedWidget(parent); setCategory(ApplicationStatus); setStandardActionsEnabled(false); setStatus(Active); setIconByName( currentIconName() ); }
BangarangNotifierItem::BangarangNotifierItem(QObject* parent) : KStatusNotifierItem(parent) { setTitle(i18n("Bangarang")); setIconByName("bangarang-notifier"); setStandardActionsEnabled(false); connect(this, SIGNAL(scrollRequested(int,Qt::Orientation)), this, SLOT(handleScrollRequested(int,Qt::Orientation))); connect(this, SIGNAL(secondaryActivateRequested(QPoint)), this, SLOT(handleMiddleClick())); }
void TorrentGroup::load(bt::BDictNode* dn) { name = QString::fromLocal8Bit(dn->getByteArray("name")); setIconByName(QString::fromLocal8Bit(dn->getByteArray("icon"))); BListNode* ln = dn->getList("hashes"); if (!ln) return; path = "/all/custom/" + name; for (Uint32 i = 0; i < ln->getNumChildren(); i++) { QByteArray ba = ln->getByteArray(i); if (ba.size() != 20) continue; hashes.insert(SHA1Hash((const Uint8*)ba.data())); } BDictNode* gp = dn->getDict(QString("policy")); if (gp) { // load the group policy if (gp->getValue("default_save_location")) { policy.default_save_location = gp->getString("default_save_location", 0); if (policy.default_save_location.length() == 0) policy.default_save_location = QString(); // make sure that 0 length strings are loaded as null strings } if (gp->getValue("default_move_on_completion_location")) { policy.default_move_on_completion_location = gp->getString("default_move_on_completion_location", 0); if (policy.default_move_on_completion_location.length() == 0) policy.default_move_on_completion_location = QString(); // make sure that 0 length strings are loaded as null strings } if (gp->getValue("max_share_ratio")) policy.max_share_ratio = gp->getString("max_share_ratio", 0).toFloat(); if (gp->getValue("max_seed_time")) policy.max_seed_time = gp->getString("max_seed_time", 0).toFloat(); if (gp->getValue("max_upload_rate")) policy.max_upload_rate = gp->getInt("max_upload_rate"); if (gp->getValue("max_download_rate")) policy.max_download_rate = gp->getInt("max_download_rate"); if (gp->getValue("only_apply_on_new_torrents")) policy.only_apply_on_new_torrents = gp->getInt("only_apply_on_new_torrents"); } }
void SysTrayIcon::updateUnreadCount( int changeOfUnreadPosts ) { kDebug(); unread += changeOfUnreadPosts; if ( unread <= 0 ) { setIconByName(currentIconName()); unread = 0; } else { // adapted from KMSystemTray::updateCount() int oldWidth = 22; QString countStr = QString::number( unread ); QFont f = KGlobalSettings::generalFont(); f.setBold( true ); float pointSize = f.pointSizeF(); QFontMetrics fm( f ); int w = fm.width( countStr ); if ( w > ( oldWidth - 2 ) ) { pointSize *= float( oldWidth - 2 ) / float( w ); f.setPointSizeF( pointSize ); } // overlay QPixmap overlayImg = KIcon(currentIconName()).pixmap(22,22); QPainter p( &overlayImg ); p.setFont( f ); KColorScheme scheme( QPalette::Active, KColorScheme::View ); fm = QFontMetrics( f ); QRect boundingRect = fm.tightBoundingRect( countStr ); boundingRect.adjust( 0, 0, 0, 2 ); boundingRect.setHeight( qMin( boundingRect.height(), oldWidth ) ); boundingRect.moveTo(( oldWidth - boundingRect.width() ) / 2, (( oldWidth - boundingRect.height() ) / 2 ) - 1 ); p.setOpacity( 0.7 ); QBrush br(QColor(255, 255, 255), Qt::SolidPattern); p.setBrush( br ); p.setPen( QColor(255, 255, 255) ); p.drawRoundedRect( boundingRect, 2.0, 2.0 ); p.setBrush( Qt::NoBrush ); p.setPen( QColor( 0, 0, 0 ) ); p.setOpacity( 1.0 ); p.drawText( overlayImg.rect(), Qt::AlignCenter, countStr ); setIconByPixmap( overlayImg ); } this->setToolTip( "choqok", i18n("Choqok"), i18np( "1 unread post", "%1 unread posts", unread ) ); }
KopeteSystemTray::KopeteSystemTray(QWidget* parent) : KStatusNotifierItem(parent) { kDebug(14010) ; setCategory(Communications); setToolTip("kopete", "Kopete", KGlobal::mainComponent().aboutData()->shortDescription()); setStatus(Passive); mIsBlinkIcon = false; mBlinkTimer = new QTimer(this); mBlinkTimer->setObjectName("mBlinkTimer"); mKopeteIcon = "kopete"; connect(contextMenu(), SIGNAL(aboutToShow()), this, SLOT(slotAboutToShowMenu())); connect(mBlinkTimer, SIGNAL(timeout()), this, SLOT(slotBlink())); connect(Kopete::ChatSessionManager::self() , SIGNAL(newEvent(Kopete::MessageEvent*)), this, SLOT(slotNewEvent(Kopete::MessageEvent*))); connect(Kopete::BehaviorSettings::self(), SIGNAL(configChanged()), this, SLOT(slotConfigChanged())); connect(Kopete::AccountManager::self(), SIGNAL(accountOnlineStatusChanged(Kopete::Account *, const Kopete::OnlineStatus &, const Kopete::OnlineStatus &)), this, SLOT(slotReevaluateAccountStates())); // the slot called by default by the quit action, KSystemTray::maybeQuit(), // just closes the parent window, which is hard to distinguish in that window's closeEvent() // from a click on the window's close widget // in the quit case, we want to quit the application // in the close widget click case, we only want to hide the parent window // so instead, we make it call our general purpose quit slot on the window, which causes a window close and everything else we need // KDE4 - app will have to listen for quitSelected instead QAction *quit = actionCollection()->action( "file_quit" ); quit->disconnect(); KopeteWindow *myParent = static_cast<KopeteWindow *>( parent ); connect( quit, SIGNAL(activated()), myParent, SLOT(slotQuit()) ); setIconByName(mKopeteIcon); setAttentionMovieByName( QLatin1String( "newmessage" ) ); slotReevaluateAccountStates(); slotConfigChanged(); }
CloudSync::CloudSync() : KStatusNotifierItem() { setIconByName("weather-many-clouds"); setCategory(KStatusNotifierItem::Communications); updateTooltip(); // then, setup our actions setupActions(); contextMenu()->setTitle("CloudSync"); DirSyncer *syncer = new DirSyncer(Settings::localUrl(), Settings::remoteUrl()); connect(syncer, SIGNAL(downloading(QString)), this, SLOT(transferring(QString))); connect(syncer, SIGNAL(finished(QString)), this, SLOT(finished(QString))); syncer->compareDirs(); }
KRandRSystemTray::KRandRSystemTray(RandRDisplay *dpy, QWidget* parent) : KStatusNotifierItem(parent), m_help(new KHelpMenu(parent, KGlobal::mainComponent().aboutData(), false, actionCollection())), m_popupUp(false), m_display(dpy) { setIconByName("preferences-desktop-display-randr"); setCategory(Hardware); m_menu = new KMenu(associatedWidget()); setContextMenu(m_menu); setStatus(Active); //TODO: probably we need an about to show signal connect(m_menu, SIGNAL(aboutToShow()), this, SLOT(slotPrepareMenu())); m_display->refresh(); updateToolTip(); OutputMap outputs = m_display->currentScreen()->outputs(); foreach(RandROutput *output, outputs) { connect(output, SIGNAL(outputChanged(RROutput,int)), this, SLOT(slotPrepareMenu())); connect(output, SIGNAL(outputChanged(RROutput,int)), this, SLOT(updateToolTip())); }
UploadGroup::UploadGroup() : Group(i18n("Uploads"),UPLOADS_ONLY_GROUP) { setIconByName("up"); }
TorrentGroup::TorrentGroup(const QString& name): Group(name, MIXED_GROUP | CUSTOM_GROUP, "/all/custom/" + name) { setIconByName("application-x-bittorrent"); }
void KopeteSystemTray::slotBlink() { setIconByName( mIsBlinkIcon ? mKopeteIcon : mBlinkIcon ); mIsBlinkIcon = !mIsBlinkIcon; }
InactiveUploadsGroup::InactiveUploadsGroup() : Group(i18n("Inactive uploads"), UPLOADS_ONLY_GROUP) { setIconByName("up"); }
UserUploadsGroup::UserUploadsGroup() : Group(i18n("User uploads"),UPLOADS_ONLY_GROUP) { setIconByName("userconfig"); }
ScriptableGroup::ScriptableGroup(const QString& name, const QString& icon, const QString& path, Kross::Object::Ptr script, DBus* api) : kt::Group(name, MIXED_GROUP, path), script(script), api(api) { setIconByName(icon); }
AllGroup::AllGroup() : Group(i18n("All Torrents"), MIXED_GROUP, "/all") { setIconByName("folder"); }
void TrayIcon::slotSetUnread(int unread) { m_unread = unread; this->setToolTip( m_defaultIcon.name(), i18n("Akregator"), i18np( "1 unread article", "%1 unread articles", unread ) ); if (unread <= 0 || !Settings::enableTrayIconUnreadArticleCount()) { setIconByName( m_defaultIcon.name() ); } else { // adapted from KMSystemTray::updateCount() int oldWidth = KIconLoader::SizeSmallMedium; QString countStr = QString::number( unread ); QFont f = KGlobalSettings::generalFont(); f.setBold(true); float pointSize = f.pointSizeF(); QFontMetrics fm(f); int w = fm.width(countStr); if( w > (oldWidth - 2) ) { pointSize *= float(oldWidth - 2) / float(w); f.setPointSizeF(pointSize); } // overlay QPixmap overlayImg( oldWidth, oldWidth ); overlayImg.fill( Qt::transparent ); QPainter p(&overlayImg); p.setFont(f); KColorScheme scheme(QPalette::Active, KColorScheme::View); fm = QFontMetrics(f); QRect boundingRect = fm.tightBoundingRect(countStr); boundingRect.adjust(0, 0, 0, 2); boundingRect.setHeight(qMin(boundingRect.height(), oldWidth)); boundingRect.moveTo((oldWidth - boundingRect.width()) / 2, ((oldWidth - boundingRect.height()) / 2) - 1); p.setOpacity(0.7); p.setBrush(scheme.background(KColorScheme::LinkBackground)); p.setPen(scheme.background(KColorScheme::LinkBackground).color()); p.drawRoundedRect(boundingRect, 2.0, 2.0); p.setBrush(Qt::NoBrush); p.setPen(scheme.foreground(KColorScheme::LinkText).color()); p.setOpacity(1.0); p.drawText(overlayImg.rect(), Qt::AlignCenter, countStr); p.end(); QPixmap iconPixmap = m_defaultIcon.pixmap( oldWidth, oldWidth ); QPainter pp( &iconPixmap ); pp.drawPixmap( 0, 0, overlayImg ); pp.end(); setIconByPixmap( iconPixmap ); } }