From c712be0b1ecdebda0ff151489f41290beaaf33b2 Mon Sep 17 00:00:00 2001 From: marian Date: Fri, 17 Dec 2010 15:55:05 +0000 Subject: [PATCH] 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 --- modules/qt4/widgetlist.cpp | 24 ++++++++++++++++++++++++ modules/qt4/widgetlist.h | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/modules/qt4/widgetlist.cpp b/modules/qt4/widgetlist.cpp index 9784fe93..d9aa1f64 100644 --- a/modules/qt4/widgetlist.cpp +++ b/modules/qt4/widgetlist.cpp @@ -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) { diff --git a/modules/qt4/widgetlist.h b/modules/qt4/widgetlist.h index ec062e5a..5a4c4601 100644 --- a/modules/qt4/widgetlist.h +++ b/modules/qt4/widgetlist.h @@ -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