Changed the tray icon updating logic so existing icons can be reused.

This prevents the tray icon from being repeatedly deleted and inserted.


git-svn-id: http://voip.null.ro/svn/yate@3987 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
paulc 2010-12-19 15:16:24 +00:00
parent 31a328e80c
commit 62956d7119
2 changed files with 11 additions and 10 deletions

View File

@ -545,7 +545,7 @@ static bool translateName(QtWidget& w, String& name, NamedList** params = 0)
}
// Utility: raise a select event if a list is empty
inline void raiseSelectIfEmpty(int count, Window* wnd, const String& name)
static inline void raiseSelectIfEmpty(int count, Window* wnd, const String& name)
{
if (!Client::exiting() && count <= 0 && Client::self())
Client::self()->select(wnd,name,String::empty());
@ -595,7 +595,7 @@ static void addDynamicProps(QObject* obj, NamedList& props)
}
// Find a QSystemTrayIcon child of an object
inline QSystemTrayIcon* findSysTrayIcon(QObject* obj, const char* name)
static inline QSystemTrayIcon* findSysTrayIcon(QObject* obj, const char* name)
{
return qFindChild<QSystemTrayIcon*>(obj,QtClient::setUtf8(name));
}
@ -994,9 +994,8 @@ bool QtWindow::setParams(const NamedList& params)
NamedList* nl = static_cast<NamedList*>(ns ? ns->getObject("NamedList") : 0);
if (!nl)
continue;
// Create a new one
bool newObj = !trayIcon;
if (newObj) {
// Create a new one if needed
if (!trayIcon) {
if (!ns->toBoolean())
continue;
trayIcon = new QSystemTrayIcon(wndWidget());
@ -1007,9 +1006,9 @@ bool QtWindow::setParams(const NamedList& params)
s_allHiddenQuit++;
}
ok = true;
// Add dynamic properties on creation
if (newObj)
addDynamicProps(trayIcon,*nl);
// Add dynamic properties
// TODO: track the properties, clear the old ones if needed
addDynamicProps(trayIcon,*nl);
// Set icon and tooltip
NamedString* tmp = nl->getParam("icon");
if (tmp && *tmp)

View File

@ -2877,14 +2877,16 @@ bool Client::updateTrayIcon(const String& wndName)
ObjList* o = list->skipNull();
TrayIconDef* def = o ? static_cast<TrayIconDef*>(o->get()) : 0;
NamedList p("systemtrayicon");
// Remove the old one
p.addParam("stackedicon","");
NamedPointer* np = 0;
if (def) {
// Add or replace
NamedList* nl = YOBJECT(NamedList,def);
np = new NamedPointer("stackedicon",nl,String::boolText(true));
p.addParam(np);
}
else
// Remove the old one
p.addParam("stackedicon","");
bool ok = Client::self()->setParams(&p,w);
if (np)
np->takeData();