mirror of
https://bitbucket.org/smil3y/kde-extraapps.git
synced 2025-02-23 18:32:53 +00:00
kvkbd: port to KStatusNotifierItem
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
49af8a3e63
commit
6db39d7067
7 changed files with 14 additions and 53 deletions
|
@ -10,7 +10,6 @@ if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
|
|||
endif()
|
||||
|
||||
add_subdirectory( src )
|
||||
add_subdirectory( pics )
|
||||
add_subdirectory( colors )
|
||||
add_subdirectory( themes )
|
||||
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
install( FILES tray.png DESTINATION ${KDE4_DATA_INSTALL_DIR}/kvkbd/pics)
|
Binary file not shown.
Before Width: | Height: | Size: 348 B |
|
@ -20,41 +20,12 @@
|
|||
|
||||
#include "kbdtray.h"
|
||||
|
||||
#include <KAction>
|
||||
#include <KToggleAction>
|
||||
#include <KToggleAction>
|
||||
#include <KLocalizedString>
|
||||
#include <KIconLoader>
|
||||
#include <KHelpMenu>
|
||||
#include <KFontDialog>
|
||||
#include <KUniqueApplication>
|
||||
|
||||
// TODO: find a way to hide the widget before asking for quit
|
||||
KbdTray::KbdTray(QWidget* parent) : KSystemTrayIcon(parent)
|
||||
KbdTray::KbdTray(QWidget* parent)
|
||||
: KStatusNotifierItem(parent)
|
||||
{
|
||||
setObjectName("KvkbdTray");
|
||||
setIcon(UserIcon("tray"));
|
||||
|
||||
QAction *titleAction = contextMenuTitle();
|
||||
titleAction->setText("Kvkbd");
|
||||
|
||||
connect(this, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(activationHandler(QSystemTrayIcon::ActivationReason)));
|
||||
setTitle("Kvkbd");
|
||||
setIconByName("input-keyboard");
|
||||
|
||||
connect(this, SIGNAL(activateRequested(bool,QPoint)), this, SIGNAL(requestVisibility()));
|
||||
}
|
||||
|
||||
KbdTray::~KbdTray()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QMenu* KbdTray::getContextMenu()
|
||||
{
|
||||
return this->contextMenu();
|
||||
|
||||
}
|
||||
void KbdTray::activationHandler(QSystemTrayIcon::ActivationReason reason)
|
||||
{
|
||||
if (reason == QSystemTrayIcon::Trigger) {
|
||||
emit requestVisibility();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,27 +19,17 @@
|
|||
#ifndef KBDTRAY_H
|
||||
#define KBDTRAY_H
|
||||
|
||||
#include <KSystemTrayIcon>
|
||||
#include <QMenu>
|
||||
#include <QSystemTrayIcon>
|
||||
#include <QFont>
|
||||
#include <QWidget>
|
||||
#include <KStatusNotifierItem>
|
||||
|
||||
class KbdTray : public KSystemTrayIcon
|
||||
class KbdTray : public KStatusNotifierItem
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit KbdTray(QWidget* parent = 0);
|
||||
~KbdTray();
|
||||
QMenu* getContextMenu();
|
||||
explicit KbdTray(QWidget *parent = nullptr);
|
||||
|
||||
public slots:
|
||||
void activationHandler(QSystemTrayIcon::ActivationReason reason);
|
||||
|
||||
|
||||
signals:
|
||||
Q_SIGNALS:
|
||||
void requestVisibility();
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include <KHelpMenu>
|
||||
#include <KFontDialog>
|
||||
#include <KCmdLineArgs>
|
||||
#include <KMenu>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
|
@ -86,7 +87,7 @@ KvkbdApp::KvkbdApp(bool loginhelper) : KUniqueApplication(), is_login(loginhelpe
|
|||
connect(themeLoader, SIGNAL(partLoaded(MainWidget*, int, int)), this, SLOT(partLoaded(MainWidget*, int, int)));
|
||||
connect(themeLoader, SIGNAL(buttonLoaded(VButton*)), this, SLOT(buttonLoaded(VButton*)));
|
||||
|
||||
QMenu *cmenu = tray->contextMenu();
|
||||
KMenu *cmenu = tray->contextMenu();
|
||||
|
||||
KAction *chooseFontAction = new KAction(KIcon("preferences-desktop-font"), i18nc("@action:inmenu", "Choose Font..."), this);
|
||||
connect(chooseFontAction, SIGNAL(triggered(bool)), this, SLOT(chooseFont()) );
|
||||
|
@ -200,7 +201,7 @@ KvkbdApp::KvkbdApp(bool loginhelper) : KUniqueApplication(), is_login(loginhelpe
|
|||
widget->showMinimized();
|
||||
}
|
||||
widget->setWindowTitle("kvkbd");
|
||||
tray->show();
|
||||
tray->setStatus(KStatusNotifierItem::Active);
|
||||
} else {
|
||||
QTimer *timer = new QTimer(this);
|
||||
timer->setInterval(1000);
|
||||
|
|
|
@ -66,6 +66,7 @@ void findLoginWindow()
|
|||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
setenv("KSNI_NO_DBUSMENU", "1", 1);
|
||||
|
||||
KAboutData about("kvkbd", 0, ki18n("Kvkbd"), version, ki18n(description),
|
||||
KAboutData::License_LGPL_V3, ki18n("(C) 2007-2014 The Kvkbd Developers"));
|
||||
|
|
Loading…
Add table
Reference in a new issue