trayicon_kde.cpp
来自「张勇的linQ学习P2P及IM软件的极佳素材代码」· C++ 代码 · 共 55 行
CPP
55 行
#include "trayicon.h"
#include <qtooltip.h>
#include <qapplication.h>
#include <ksystemtray.h>
class TrayIcon::TrayIconPrivate : public KSystemTray {
public:
TrayIconPrivate(TrayIcon *icon, QWidget *parent = 0, const char *name = 0)
: KSystemTray(parent, name), iconObject(icon) {}
private:
virtual bool event(QEvent *e) {
QEvent::Type type = e->type();
if (type == QEvent::MouseButtonPress ||
type == QEvent::MouseButtonRelease ||
type == QEvent::MouseButtonDblClick ||
type == QEvent::MouseMove)
return QApplication::sendEvent(iconObject, e);
return KSystemTray::event(e);
}
TrayIcon *iconObject;
};
void TrayIcon::sysInstall()
{
if (!d)
d = new TrayIconPrivate(this);
d->setPixmap(pm);
d->show();
}
void TrayIcon::sysRemove()
{
if (d) {
delete d;
d = 0;
}
}
void TrayIcon::sysUpdateIcon()
{
if (d)
d->setPixmap(pm);
}
void TrayIcon::sysUpdateToolTip()
{
QToolTip::remove(d);
QToolTip::add(d, tip);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?