2
我已經編寫了一個小程序來在合成器(xfwm4,dcompmgr,cairo-compmgr)之間進行切換,以幫助處理nVidia可能遇到的視頻撕裂。它在系統托盤中創建一個具有其操作的圖標。問題是,當我運行我的程序時,圖標並不總是顯示出來,並且在我切換到不同的合成器後它會消失。我已經捕捉到了這對在這裏可以看到一個視頻: https://www.youtube.com/watch?v=31qqOiaOdfwQSystemTrayIcon並不總是顯示
我使用: Manjaro Linux的64位與Xfce的
使用Qt QtCreator v.2.8.0 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");
}