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()
|
endif()
|
||||||
|
|
||||||
add_subdirectory( src )
|
add_subdirectory( src )
|
||||||
add_subdirectory( pics )
|
|
||||||
add_subdirectory( colors )
|
add_subdirectory( colors )
|
||||||
add_subdirectory( themes )
|
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 "kbdtray.h"
|
||||||
|
|
||||||
#include <KAction>
|
KbdTray::KbdTray(QWidget* parent)
|
||||||
#include <KToggleAction>
|
: KStatusNotifierItem(parent)
|
||||||
#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)
|
|
||||||
{
|
{
|
||||||
setObjectName("KvkbdTray");
|
setTitle("Kvkbd");
|
||||||
setIcon(UserIcon("tray"));
|
setIconByName("input-keyboard");
|
||||||
|
|
||||||
QAction *titleAction = contextMenuTitle();
|
|
||||||
titleAction->setText("Kvkbd");
|
|
||||||
|
|
||||||
connect(this, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(activationHandler(QSystemTrayIcon::ActivationReason)));
|
|
||||||
|
|
||||||
|
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
|
#ifndef KBDTRAY_H
|
||||||
#define KBDTRAY_H
|
#define KBDTRAY_H
|
||||||
|
|
||||||
#include <KSystemTrayIcon>
|
#include <QWidget>
|
||||||
#include <QMenu>
|
#include <KStatusNotifierItem>
|
||||||
#include <QSystemTrayIcon>
|
|
||||||
#include <QFont>
|
|
||||||
|
|
||||||
class KbdTray : public KSystemTrayIcon
|
class KbdTray : public KStatusNotifierItem
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit KbdTray(QWidget* parent = 0);
|
explicit KbdTray(QWidget *parent = nullptr);
|
||||||
~KbdTray();
|
|
||||||
QMenu* getContextMenu();
|
|
||||||
|
|
||||||
public slots:
|
Q_SIGNALS:
|
||||||
void activationHandler(QSystemTrayIcon::ActivationReason reason);
|
|
||||||
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void requestVisibility();
|
void requestVisibility();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
#include <KHelpMenu>
|
#include <KHelpMenu>
|
||||||
#include <KFontDialog>
|
#include <KFontDialog>
|
||||||
#include <KCmdLineArgs>
|
#include <KCmdLineArgs>
|
||||||
|
#include <KMenu>
|
||||||
|
|
||||||
#include <iostream>
|
#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(partLoaded(MainWidget*, int, int)), this, SLOT(partLoaded(MainWidget*, int, int)));
|
||||||
connect(themeLoader, SIGNAL(buttonLoaded(VButton*)), this, SLOT(buttonLoaded(VButton*)));
|
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);
|
KAction *chooseFontAction = new KAction(KIcon("preferences-desktop-font"), i18nc("@action:inmenu", "Choose Font..."), this);
|
||||||
connect(chooseFontAction, SIGNAL(triggered(bool)), this, SLOT(chooseFont()) );
|
connect(chooseFontAction, SIGNAL(triggered(bool)), this, SLOT(chooseFont()) );
|
||||||
|
@ -200,7 +201,7 @@ KvkbdApp::KvkbdApp(bool loginhelper) : KUniqueApplication(), is_login(loginhelpe
|
||||||
widget->showMinimized();
|
widget->showMinimized();
|
||||||
}
|
}
|
||||||
widget->setWindowTitle("kvkbd");
|
widget->setWindowTitle("kvkbd");
|
||||||
tray->show();
|
tray->setStatus(KStatusNotifierItem::Active);
|
||||||
} else {
|
} else {
|
||||||
QTimer *timer = new QTimer(this);
|
QTimer *timer = new QTimer(this);
|
||||||
timer->setInterval(1000);
|
timer->setInterval(1000);
|
||||||
|
|
|
@ -66,6 +66,7 @@ void findLoginWindow()
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
setenv("KSNI_NO_DBUSMENU", "1", 1);
|
||||||
|
|
||||||
KAboutData about("kvkbd", 0, ki18n("Kvkbd"), version, ki18n(description),
|
KAboutData about("kvkbd", 0, ki18n("Kvkbd"), version, ki18n(description),
|
||||||
KAboutData::License_LGPL_V3, ki18n("(C) 2007-2014 The Kvkbd Developers"));
|
KAboutData::License_LGPL_V3, ki18n("(C) 2007-2014 The Kvkbd Developers"));
|
||||||
|
|
Loading…
Add table
Reference in a new issue