我编写了一个小程序来在合成器(xfwm4、dcompmgr、cairo-compmgr)之间切换,以帮助处理可以使用 nVidia 体验的视频撕裂。它在系统托盘中创建一个具有其操作的图标。问题是当我运行我的程序时图标并不总是出现,并且在我切换到不同的合成器后它消失了。我已经在可以在这里看到的视频中捕捉到它: https ://www.youtube.com/watch?v=31qqOiaOdfw
我正在使用:Manjaro Linux 64bit with Xfce
QtCreator v.2.8.0 with Qt 5.1
有人可以帮我吗?
compSwitcher.cpp
#include "compswitcher.h"
#include "ui_compswitcher.h"
#include <QMenu>
#include <QCloseEvent>
#include <QDebug>
compSwitcher::compSwitcher(QWidget *parent) :
QWidget(parent),
ui(new Ui::compSwitcher)
{
ui->setupUi(this);
createActions();
createIcon();
setIcon();
qDebug() << "Before trayIcon->show()\n";
trayIcon->show();
qDebug() << "After trayIcon->show()";
}
compSwitcher::~compSwitcher()
{
delete ui;
delete trayIcon;
delete menu;
delete xfwm4;
delete close;
delete dcompmgr;
}
void compSwitcher::createActions()
{
close = new QAction(tr("&Quit"),this);
QObject::connect(close, SIGNAL(triggered()), this, SLOT(endProgram()));
xfwm4 = new QAction(tr("&xfwm4"), this);
connect(xfwm4, SIGNAL(triggered()), this, SLOT(setXfwm4()));
dcompmgr = new QAction(tr("&dcompmgr"), this);
connect(dcompmgr, SIGNAL(triggered()), this, SLOT(setDcompmgr()));
cairo = new QAction(tr("&cairo-compmgr"), this);
connect(cairo,SIGNAL(triggered()), this, SLOT(setCairo()));
}
void compSwitcher::createIcon()
{
menu = new QMenu(this);
menu->addAction(xfwm4);
menu->addAction(dcompmgr);
menu->addAction(cairo);
menu->addSeparator();
menu->addAction(close);
trayIcon = new QSystemTrayIcon(this);
trayIcon->setContextMenu(menu);
}
void compSwitcher::setIcon()
{
QIcon ikona(":/new/prefix1/kuba_fan1.png");
trayIcon->setIcon(QIcon(ikona));
}
void compSwitcher::setXfwm4()
{
system("/home/dec/Programowanie/qt/compSwitcher/skrypty/xfwm4true.sh");
}
void compSwitcher::setDcompmgr()
{
system("/home/dec/Programowanie/qt/compSwitcher/skrypty/dcompmgr.sh");
}
void compSwitcher::setCairo()
{
system("/home/dec/Programowanie/qt/compSwitcher/skrypty/cairo.sh");
}