Commit ea9f0805 authored by Maximilian Schiller's avatar Maximilian Schiller
Browse files

Show a system tray icon

Displays a system tray icon for yakuake. On right click it shows the
yakuake menu and on left click it toggles yakuake.
The tooltip is set to show the current shortcut for toggling yakuake.
parent 78a60708
......@@ -47,6 +47,7 @@
#include <KWindowSystem>
#include <KWindowEffects>
#include <KLocalizedString>
#include <KStatusNotifierItem>
#include <QApplication>
#include <QDesktopWidget>
......@@ -90,6 +91,8 @@ MainWindow::MainWindow(QWidget* parent)
m_sessionStack = new SessionStack(this);
m_titleBar = new TitleBar(this);
m_tabBar = new TabBar(this);
m_notifierItem = new KStatusNotifierItem(this);
m_firstRunDialog = NULL;
m_isFullscreen = false;
......@@ -142,6 +145,16 @@ MainWindow::MainWindow(QWidget* parent)
m_sessionStack->addSession();
m_notifierItem->setStandardActionsEnabled(false);
m_notifierItem->setIconByName(QStringLiteral("yakuake"));
m_notifierItem->setStatus(KStatusNotifierItem::Active);
m_notifierItem->setContextMenu(m_menu);
// Prevent the default implementation of showing
// and instead run toggleWindowState
m_notifierItem->setAssociatedWidget(nullptr);
connect(m_notifierItem, &KStatusNotifierItem::activateRequested, this, &MainWindow::toggleWindowState);
if (Settings::firstRun())
{
QMetaObject::invokeMethod(this, "toggleWindowState", Qt::QueuedConnection);
......@@ -149,7 +162,6 @@ MainWindow::MainWindow(QWidget* parent)
}
else
{
showStartupPopup();
if (Settings::pollMouse()) toggleMousePoll(true);
}
......@@ -269,6 +281,10 @@ void MainWindow::setupActions()
KGlobalAccel::self()->setGlobalShortcut(action, QList<QKeySequence>() << QKeySequence(Qt::Key_F11));
#endif
connect(action, SIGNAL(triggered()), this, SLOT(toggleWindowState()));
connect(action, SIGNAL(changed()), this, SLOT(updateTrayTooltip()));
connect(KGlobalAccel::self(), SIGNAL(globalShortcutChanged(QAction*, const QKeySequence&)),
this, SLOT(updateTrayTooltip()));
updateTrayTooltip();
action = actionCollection()->addAction(QStringLiteral("keep-open"));
action->setText(xi18nc("@action", "Keep window open when it loses focus"));
......@@ -1550,21 +1566,6 @@ void MainWindow::whatsThis()
QWhatsThis::enterWhatsThisMode();
}
void MainWindow::showStartupPopup()
{
QAction* action = static_cast<QAction*>(actionCollection()->action(QStringLiteral("toggle-window-state")));
const QList<QKeySequence> &shortcuts = KGlobalAccel::self()->shortcut(action);
if (shortcuts.isEmpty())
return;
QString shortcut(shortcuts.first().toString(QKeySequence::NativeText));
QString message(xi18nc("@info", "Application successfully started.<nl/>" "Press <shortcut>%1</shortcut> to use it ...", shortcut));
KNotification::event(QLatin1String("startup"), message, QPixmap(), this);
}
void MainWindow::showFirstRunDialog()
{
if (!m_firstRunDialog)
......@@ -1602,3 +1603,15 @@ void MainWindow::updateUseTranslucency()
{
m_useTranslucency = (Settings::translucency() && KWindowSystem::compositingActive());
}
void MainWindow::updateTrayTooltip()
{
auto* action = actionCollection()->action(QStringLiteral("toggle-window-state"));
const QList<QKeySequence> &shortcuts = KGlobalAccel::self()->shortcut(action);
if (!shortcuts.isEmpty()) {
const QString shortcut(shortcuts.first().toString(QKeySequence::NativeText));
m_notifierItem->setToolTip(QStringLiteral("yakuake"),
QStringLiteral("Yakuake"), xi18nc("@info", "Press <shortcut>%1</shortcut> to open", shortcut));
}
}
......@@ -39,6 +39,7 @@ class TitleBar;
class KHelpMenu;
class KActionCollection;
class KStatusNotifierItem;
#if HAVE_KWAYLAND
namespace KWayland {
......@@ -142,6 +143,7 @@ class MainWindow : public KMainWindow
void configureKeys();
void configureNotifications();
void configureApp();
void updateTrayTooltip();
void showFirstRunDialog();
void firstRunDialogFinished();
......@@ -179,8 +181,6 @@ class MainWindow : public KMainWindow
QRect m_availableScreenRect;
void _toggleWindowState();
void showStartupPopup();
void updateUseTranslucency();
bool m_useTranslucency;
bool m_isFullscreen;
......@@ -200,6 +200,7 @@ class MainWindow : public KMainWindow
QMenu* m_windowHeightMenu;
FirstRunDialog* m_firstRunDialog;
KStatusNotifierItem *m_notifierItem;
QTimer m_animationTimer;
QTimer m_mousePoller;
......
......@@ -54,105 +54,6 @@ Comment[x-test]=xxYakuakexx
Comment[zh_CN]=Yakuake
Comment[zh_TW]=Yakuake
[Event/startup]
Name=Startup
Name[ar]=بدء
Name[ast]=Aniciu
Name[bs]=Pokretanje
Name[ca]=Inici
Name[ca@valencia]=Inici
Name[cs]=Spuštění
Name[da]=Opstart
Name[de]=Programmstart
Name[el]=Εκκίνηση
Name[en_GB]=Startup
Name[es]=Inicio
Name[et]=Käivitamine
Name[eu]=Abioa
Name[fi]=Käynnistys
Name[fr]=Démarrage
Name[gl]=Inicio
Name[hu]=Indulás
Name[ia]=Starta
Name[id]=Pemulaian
Name[it]=Avvio
Name[km]=ចាប់ផ្ដើម
Name[ko]=시작
Name[lt]=Paleidimas
Name[mr]=सुरुवात
Name[nb]=Oppstart
Name[nds]=Start
Name[nl]=Opstarten
Name[nn]=Oppstart
Name[pa]=ਸ਼ੁਰੂਆਤ
Name[pl]=Uruchamianie
Name[pt]=Arranque
Name[pt_BR]=Inicialização
Name[ro]=Pornire
Name[ru]=Запуск
Name[sk]=Spustenie
Name[sl]=Zagon
Name[sr]=Покретање
Name[sr@ijekavian]=Покретање
Name[sr@ijekavianlatin]=Pokretanje
Name[sr@latin]=Pokretanje
Name[sv]=Start
Name[tr]=Başlangıç
Name[ug]=قوزغىلىش
Name[uk]=Запуск
Name[x-test]=xxStartupxx
Name[zh_CN]=开始
Name[zh_TW]=啟動
Comment=Yakuake has started
Comment[ar]=بدأ ياكواكي
Comment[ast]=Anicióse Yakuake
Comment[bs]=Yakuake je pokrenut
Comment[ca]=S'ha engegat el Yakuake
Comment[ca@valencia]=S'ha engegat el Yakuake
Comment[cs]=Yakuake byl spuštěn
Comment[da]=Yakuake er startet
Comment[de]=Yakuake wurde gestartet
Comment[el]=Το Yakuake έχει ξεκινήσει
Comment[en_GB]=Yakuake has started
Comment[es]=Yakuake se ha iniciado
Comment[et]=Yakuake on käivitatud
Comment[eu]=Yakuake abiatu da
Comment[fi]=Yakuake on käynnistynyt
Comment[fr]=Yakuake a démarré
Comment[gl]=Yakuake iniciouse.
Comment[hi]=याकुआके चालु हुआ
Comment[hu]=A Yakuake elindult
Comment[ia]=Yakuake ha initiate
Comment[id]=Yakuake telah dimulai
Comment[it]=Yakuake è avviato
Comment[km]=Yakuake បាន​ចាប់ផ្ដើម
Comment[ko]=Yakuake가 시작됨
Comment[lt]=Yakuake paleistas
Comment[mr]=याकुआके सुरु झाला आहे
Comment[nb]=Yakuake har startet
Comment[nds]=Yakuake hett start.
Comment[nl]=Yakuake is opgestart
Comment[nn]=Yakuake er starta
Comment[pa]=ਯਾਕੂਕੀ ਚਾਲੂ ਹੋਇਆ
Comment[pl]=Yakuake został uruchomiony
Comment[pt]=O Yakuake foi iniciado
Comment[pt_BR]=O Yakuake foi iniciado
Comment[ro]=Yakuake s-a pornit
Comment[ru]=Yakuake запущен
Comment[sk]=Yakuake bolo spustené
Comment[sl]=Yakuake je zagnan
Comment[sr]=Јакуаке је покренут
Comment[sr@ijekavian]=Јакуаке је покренут
Comment[sr@ijekavianlatin]=Yakuake je pokrenut
Comment[sr@latin]=Yakuake je pokrenut
Comment[sv]=Yakuake har startats
Comment[tr]=Yakuake başlatıldı
Comment[uk]=Yakuake запущено
Comment[x-test]=xxYakuake has startedxx
Comment[zh_CN]=Yakuake 已经启动
Comment[zh_TW]=Yakuake 已啟動
Action=Popup
[Event/silence]
Name=Silence detected
Name[ar]=اكتُشف سكون
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment