本文整理汇总了C++中TrayIcon::attachApp方法的典型用法代码示例。如果您正苦于以下问题:C++ TrayIcon::attachApp方法的具体用法?C++ TrayIcon::attachApp怎么用?C++ TrayIcon::attachApp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TrayIcon
的用法示例。
在下文中一共展示了TrayIcon::attachApp方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkAll
// ========================
// PRIVATE FUNCTIONS
// ========================
void LSysTray::checkAll(){
if(!isRunning || stopping || checking){ return; } //Don't check if not running at the moment
checking = true;
//Make sure this tray should handle the windows (was not disabled in the backend)
bool TrayRunning = LSession::handle()->registerVisualTray(this->winId());
//qDebug() << "System Tray: Check tray apps";
bool listChanged = false;
QList<WId> wins = LSession::handle()->currentTrayApps(this->winId());
for(int i=0; i<trayIcons.length(); i++){
int index = wins.indexOf(trayIcons[i]->appID());
if(index < 0){
//Tray Icon no longer exists: remove it
qDebug() << " - Visual System Tray: Remove Icon";
TrayIcon *cont = trayIcons.takeAt(i);
LI->removeWidget(cont);
delete cont;
i--; //List size changed
listChanged = true;
//Re-adjust the maximum widget size to account for what is left
if(this->layout()->direction()==QBoxLayout::LeftToRight){
this->setMaximumSize( trayIcons.length()*this->height(), 10000);
}else{
this->setMaximumSize(10000, trayIcons.length()*this->width());
}
}else{
//Tray Icon already exists
//qDebug() << " - SysTray: Update Icon";
//trayIcons[i]->update();
wins.removeAt(index); //Already found - remove from the list
}
}
//Now go through any remaining windows and add them
for(int i=0; i<wins.length() && TrayRunning; i++){
qDebug() << " - Visual System Tray: Add Icon";
TrayIcon *cont = new TrayIcon(this);
LSession::processEvents();
trayIcons << cont;
LI->addWidget(cont);
//qDebug() << " - Update tray layout";
if(this->layout()->direction()==QBoxLayout::LeftToRight){
cont->setSizeSquare(this->height()-2*frame->frameWidth()); //horizontal tray
this->setMaximumSize( trayIcons.length()*this->height(), 10000);
}else{
cont->setSizeSquare(this->width()-2*frame->frameWidth()); //vertical tray
this->setMaximumSize(10000, trayIcons.length()*this->width());
}
LSession::processEvents();
//qDebug() << " - Attach tray app";
cont->attachApp(wins[i]);
if(cont->appID()==0){
//could not attach window - remove the widget
qDebug() << "Invalid Tray Container:";
trayIcons.takeAt(trayIcons.length()-1); //Always at the end
LI->removeWidget(cont);
delete cont;
continue;
}else{
listChanged = true;
}
LI->update(); //make sure there is no blank space in the layout
}
/*if(listChanged){
//Icons got moved around: be sure to re-draw all of them to fix visuals
for(int i=0; i<trayIcons.length(); i++){
trayIcons[i]->update();
}
}*/
//qDebug() << " - System Tray: check done";
checking = false;
}