Added flash item feature to the widget list (change tab text color).

git-svn-id: http://yate.null.ro/svn/yate/trunk@3977 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
marian 2010-12-17 15:55:05 +00:00
parent 38015a7ec5
commit c712be0b1e
2 changed files with 59 additions and 0 deletions

View File

@ -458,6 +458,30 @@ void WidgetList::setHideWidgetWhenEmpty(QString value)
hideEmpty();
}
// Start/stop item flash
void WidgetList::setFlashItem(QString value)
{
if (!m_tab)
return;
String on;
String item;
int pos = value.indexOf(':');
if (pos > 0) {
QtClient::getUtf8(on,value.left(pos));
QtClient::getUtf8(item,value.right(value.length() - pos - 1));
}
else
return;
QWidget* w = findItem(item);
if (!w)
return;
int index = m_tab->indexOf(w);
if (on.toBoolean())
m_tab->setTabTextColor(index,QColor("green"));
else
m_tab->setTabTextColor(index,QColor("black"));
}
// Handle selection changes
void WidgetList::currentChanged(int index)
{

View File

@ -43,6 +43,27 @@ public:
*/
WidgetListTabWidget(WidgetList* parent, const NamedList& params);
/**
* Set tab text color
* @param index Tab index
* @param color Tab text color
*/
inline void setTabTextColor(int index, QColor color) {
QTabBar* bar = tabBar();
if (bar)
bar->setTabTextColor(index,color);
}
/**
* Retrieve the tab text color
* @param index Tab index
* @return Text color of the given index
*/
inline QColor tabTextColor(int index) {
QTabBar* bar = tabBar();
return bar ? bar->tabTextColor(index) : QColor();
}
protected:
/**
* Build and set a close button for a given tab or a global close if index is negative
@ -88,6 +109,7 @@ class WidgetList : public QtCustomWidget
Q_PROPERTY(QString _yate_itemstyle READ itemStyle WRITE setItemStyle(QString))
Q_PROPERTY(QString _yate_itemtextparam READ itemTextParam WRITE setItemTextParam(QString))
Q_PROPERTY(QString _yate_itemimageparam READ itemImageParam WRITE setItemImageParam(QString))
Q_PROPERTY(QString _yate_flashitem READ flashItem WRITE setFlashItem(QString))
public:
/**
* Delete item button type
@ -302,6 +324,19 @@ public:
void setItemImageParam(QString value)
{ QtClient::getUtf8(m_itemImgParam,value); }
/**
* Read _yate_flashitem property accessor: does nothing
* This method is here to stop MOC compiler complaining about missing READ accessor function
*/
QString flashItem()
{ return QString(); }
/**
* Start/stop item flash
* @param value Item value. Format bool_value:item_id
*/
void setFlashItem(QString value);
public slots:
/**
* Handle item children actions