Beispiel #1
0
LegacySystemTray::LegacySystemTray(QWidget *parent)
  : SystemTray(parent),
  _blinkState(false),
  _lastMessageId(0)
{
#ifndef HAVE_KDE
  _trayIcon = new QSystemTrayIcon(associatedWidget());
#else
  _trayIcon = new KSystemTrayIcon(associatedWidget());
  // We don't want to trigger a minimize if a highlight is pending, so we brutally remove the internal connection for that
  disconnect(_trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
                 _trayIcon, SLOT(activateOrHide(QSystemTrayIcon::ActivationReason)));
#endif
#ifndef Q_WS_MAC
  connect(_trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
                     SLOT(on_activated(QSystemTrayIcon::ActivationReason)));
#endif
  connect(_trayIcon, SIGNAL(messageClicked()),
                     SLOT(on_messageClicked()));

  _blinkTimer.setInterval(500);
  _blinkTimer.setSingleShot(false);
  connect(&_blinkTimer, SIGNAL(timeout()), SLOT(on_blinkTimeout()));

  connect(this, SIGNAL(toolTipChanged(QString,QString)), SLOT(syncLegacyIcon()));
}
Beispiel #2
0
SystemTray::SystemTray(QWidget* parent)
    : QObject(parent)
    , _associatedWidget(parent)
{
    Q_ASSERT(parent);

    NotificationSettings{}.initAndNotify("Systray/ChangeColor", this, &SystemTray::enableChangeColorChanged, true);
    NotificationSettings{}.initAndNotify("Systray/Animate", this, &SystemTray::enableBlinkChanged, false);
    UiStyleSettings{}.initAndNotify("Icons/InvertTray", this, &SystemTray::invertTrayIconChanged, false);

    ActionCollection* coll = QtUi::actionCollection("General");
    _minimizeRestoreAction = new Action(tr("&Minimize"), this, this, &SystemTray::minimizeRestore);

    _trayMenu = new QMenu(associatedWidget());
    _trayMenu->setTitle("Quassel IRC");
    _trayMenu->setAttribute(Qt::WA_Hover);

    _trayMenu->addAction(coll->action("ConnectCore"));
    _trayMenu->addAction(coll->action("DisconnectCore"));
    _trayMenu->addAction(coll->action("CoreInfo"));
    _trayMenu->addSeparator();
    _trayMenu->addAction(_minimizeRestoreAction);
    _trayMenu->addAction(coll->action("Quit"));
    connect(_trayMenu, &QMenu::aboutToShow, this, &SystemTray::trayMenuAboutToShow);

    connect(QtUi::instance(), &QtUi::iconThemeRefreshed, this, &SystemTray::iconsChanged);

    _blinkTimer.setInterval(1000);
    _blinkTimer.setSingleShot(false);
    connect(&_blinkTimer, &QTimer::timeout, this, &SystemTray::onBlinkTimeout);
}
Beispiel #3
0
void SystemTray::init()
{
    ActionCollection *coll = QtUi::actionCollection("General");
    _minimizeRestoreAction = new Action(tr("&Minimize"), this, this, SLOT(minimizeRestore()));

#ifdef HAVE_KDE
    KMenu *kmenu;
    _trayMenu = kmenu = new KMenu();
    kmenu->addTitle(_activeIcon, "Quassel IRC");
#else
    _trayMenu = new QMenu(associatedWidget());
#endif

    _trayMenu->setTitle("Quassel IRC");

#ifndef HAVE_KDE
    _trayMenu->setAttribute(Qt::WA_Hover);
#endif

    _trayMenu->addAction(coll->action("ConnectCore"));
    _trayMenu->addAction(coll->action("DisconnectCore"));
    _trayMenu->addAction(coll->action("CoreInfo"));
    _trayMenu->addSeparator();
    _trayMenu->addAction(_minimizeRestoreAction);
    _trayMenu->addAction(coll->action("Quit"));

    connect(_trayMenu, SIGNAL(aboutToShow()), SLOT(trayMenuAboutToShow()));

    NotificationSettings notificationSettings;
    notificationSettings.initAndNotify("Systray/Animate", this, SLOT(enableAnimationChanged(QVariant)), true);
}
Beispiel #4
0
void TrayIcon::updateToolTip(QList<Task*> activeTasks)
{
    if ( activeTasks.isEmpty() )
    {
        this->setToolTip( "ktimetracker", "ktimetracker", i18n("No active tasks") );
        return;
    }

    QFontMetrics fm( QToolTip::font() );
    const QString continued = i18n( ", ..." );
    const int buffer = fm.boundingRect( continued ).width();
    const int desktopWidth = KGlobalSettings::desktopGeometry(associatedWidget()).width();
    const int maxWidth = desktopWidth - buffer;

    QString qTip;
    QString s;

    // Build the tool tip with all of the names of the active tasks.
    // If at any time the width of the tool tip is larger than the desktop,
    // stop building it.

    for ( int i = 0; i < activeTasks.count(); ++i )
    {
        Task* task = activeTasks.at( i );
        if ( i > 0 )
            s += i18n( ", " ) + task->name();
        else
            s += task->name();
        int width = fm.boundingRect( s ).width();
        if ( width > maxWidth )
        {
            qTip += continued;
            break;
        }
        qTip = s;
    }
    this->setToolTip( "ktimetracker", "ktimetracker", qTip );
}
Beispiel #5
0
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()));
	}