From ca5f2d3eb61cf059e4f5e6ba78c84b0d6359fde7 Mon Sep 17 00:00:00 2001 From: marian Date: Mon, 8 Mar 2010 09:35:59 +0000 Subject: [PATCH] Store custom identity in dynamic property (avoid using accessibleName). Requires QT 4.2. git-svn-id: http://voip.null.ro/svn/yate@3118 acf43c95-373e-0410-b603-e72c3f656dc1 --- clients/qt4/qt4client.cpp | 32 +++++------------------ clients/qt4/qt4client.h | 10 ++++++++ configure.in | 6 ++++- share/skins/default/account.ui | 2 +- share/skins/default/addrbook.ui | 2 +- share/skins/default/events.ui | 16 ++++++------ share/skins/default/help.ui | 6 ++--- share/skins/default/qt4client.ui | 44 ++++++++++++++++---------------- 8 files changed, 57 insertions(+), 61 deletions(-) diff --git a/clients/qt4/qt4client.cpp b/clients/qt4/qt4client.cpp index 5c7d9f57..e31202c4 100644 --- a/clients/qt4/qt4client.cpp +++ b/clients/qt4/qt4client.cpp @@ -468,28 +468,15 @@ static void setWidget(QWidget* parent, QWidget* child) // Utility function used to get the name of a control // The name of the control indicates actions, toggles ... // The action name alias can contain parameters -// The accessible name property can override controls's name static bool translateName(QtWidget& w, String& name, NamedList** params = 0) { - static String actionProp = "accessibleName"; - if (w.invalid()) return false; - bool noAlias = true; - if (w.type() != QtWidget::Action) { - noAlias = w->accessibleName().isEmpty(); - if (noAlias) - QtClient::getUtf8(name,w->objectName()); - else - QtClient::getUtf8(name,w->accessibleName()); - } - else { - QtClient::getProperty(w.action(),actionProp,name); - noAlias = name.null(); - if (noAlias) - QtClient::getUtf8(name,w.action()->objectName()); - } - if (noAlias) + if (w.type() != QtWidget::Action) + QtClient::getIdentity(w.widget(),name); + else + QtClient::getIdentity(w.action(),name); + if (!name) return true; // Check params int pos = name.find('|'); @@ -790,7 +777,6 @@ QtWindow::QtWindow(const char* name, const char* description, const char* alias) m_maximized(false), m_mainWindow(false) { setObjectName(QtClient::setUtf8(m_id)); - setAccessibleName(QtClient::setUtf8(description)); } QtWindow::~QtWindow() @@ -1999,7 +1985,6 @@ bool QtWindow::eventFilter(QObject* obj, QEvent* event) { if (!obj) return false; -#if QT_VERSION >= 0x040200 // Apply dynamic properties changes if (event->type() == QEvent::DynamicPropertyChange) { String name = YQT_OBJECT_NAME(obj); @@ -2053,7 +2038,6 @@ bool QtWindow::eventFilter(QObject* obj, QEvent* event) prop.c_str(),value.c_str(),name.c_str()); return false; } -#endif if (event->type() == QEvent::KeyPress) { static int mask = Qt::SHIFT | Qt::CTRL | Qt::ALT; @@ -2235,11 +2219,11 @@ void QtWindow::doInit() m_visible = m_mainWindow || m_visible; // Create custom widgets from - // accessibleName=customwidget|[separator=sep|] sep widgetclass sep widgetname [sep param=value] + // _yate_identity=customwidget|[separator=sep|] sep widgetclass sep widgetname [sep param=value] QList frm = qFindChildren(this); for (int i = 0; i < frm.size(); i++) { String create; - QtClient::getUtf8(create,frm[i]->accessibleName()); + QtClient::getProperty(frm[i],"yate_identity",create); if (!create.startSkip("customwidget|",false)) continue; char sep = '|'; @@ -2412,7 +2396,6 @@ void QtWindow::doInit() } } -#if QT_VERSION >= 0x040200 // Install event filer and apply dynamic properties QList w = qFindChildren(this); for (int i = 0; i < w.size(); i++) { @@ -2436,7 +2419,6 @@ void QtWindow::doInit() eventFilter(w[i],&ev); } } -#endif qRegisterMetaType("QModelIndex"); qRegisterMetaType("QTextCursor"); diff --git a/clients/qt4/qt4client.h b/clients/qt4/qt4client.h index 45ac9e97..f86fc1ad 100644 --- a/clients/qt4/qt4client.h +++ b/clients/qt4/qt4client.h @@ -229,6 +229,16 @@ public: */ static bool getProperty(QObject* obj, const char* name, String& value); + /** + * Retrieve an object's identity from '_yate_identity' property or object name + * @param obj The object + * @param ident String to be filled with object identity + */ + static inline void getIdentity(QObject* obj, String& ident) { + if (obj && !(getProperty(obj,"_yate_identity",ident) && ident)) + getUtf8(ident,obj->objectName()); + } + /** * Build a menu object from a list of parameters. * Each menu item is indicated by a parameter starting with 'item:". diff --git a/configure.in b/configure.in index 3047aaa3..01d4bdb3 100644 --- a/configure.in +++ b/configure.in @@ -964,7 +964,7 @@ QT4_MOC="" QT4_VER="" AC_ARG_WITH(libqt4,AC_HELP_STRING([--with-libqt4],[use Qt for graphical clients (default)]),[ac_cv_use_libqt4=$withval],[ac_cv_use_libqt4=yes]) if [[ "x$ac_cv_use_libqt4" = "xyes" ]]; then - AC_MSG_CHECKING([for Qt4 using pkg-config]) + AC_MSG_CHECKING([for Qt4 >= 4.2.0 using pkg-config]) pkgd="/usr/lib/qt4/$ARCHLIB/pkgconfig" if [[ -d "$pkgd" ]]; then export PKG_CONFIG_LIBDIR="$pkgd" @@ -984,6 +984,10 @@ if [[ "x$ac_cv_use_libqt4" = "xyes" ]]; then test -z "$QT4_MOC" && QT4_MOC="moc" QT4_VER=`echo "$verqt" | sed "$vsed" | sed "$vsed" | sed 's/\(..\)\.\(..\)\.\(..\)/\1\2\3/'` ac_cv_use_libqt="no" + if [[ 1$QT4_VER -lt 1040200 ]]; then + HAVE_QT4=no + verqt="too old ($verqt)" + fi else verqt="no" fi diff --git a/share/skins/default/account.ui b/share/skins/default/account.ui index 7aa8db80..02bf0279 100644 --- a/share/skins/default/account.ui +++ b/share/skins/default/account.ui @@ -989,7 +989,7 @@ Help on this window - + showwindow:help:3 diff --git a/share/skins/default/addrbook.ui b/share/skins/default/addrbook.ui index 757a977c..ff30e516 100644 --- a/share/skins/default/addrbook.ui +++ b/share/skins/default/addrbook.ui @@ -174,7 +174,7 @@ Help on this window - + showwindow:help:2 diff --git a/share/skins/default/events.ui b/share/skins/default/events.ui index 610b1a0c..71eab9c0 100644 --- a/share/skins/default/events.ui +++ b/share/skins/default/events.ui @@ -48,7 +48,7 @@ 100 - + @@ -92,7 +92,7 @@ 25 - + debug:jingle:level 9:level 5 @@ -114,7 +114,7 @@ 25 - + debug:sip:level 9:level 5 @@ -136,7 +136,7 @@ 25 - + debug:h323:level 9:level 5 @@ -158,7 +158,7 @@ 25 - + debug:iax:level 9:level 5 @@ -185,7 +185,7 @@ - + command:sniffer @@ -236,7 +236,7 @@ 25 - + clear:log_events @@ -320,7 +320,7 @@ Help on this window - + showwindow:help:4 diff --git a/share/skins/default/help.ui b/share/skins/default/help.ui index 256ac844..4f8ec699 100644 --- a/share/skins/default/help.ui +++ b/share/skins/default/help.ui @@ -102,7 +102,7 @@ - + help:prev @@ -136,7 +136,7 @@ Home - + help:home @@ -167,7 +167,7 @@ 25 - + help:next diff --git a/share/skins/default/qt4client.ui b/share/skins/default/qt4client.ui index 0b83b769..9a476b52 100644 --- a/share/skins/default/qt4client.ui +++ b/share/skins/default/qt4client.ui @@ -116,7 +116,7 @@ 8 - + selectitem:framePages:PageCalls @@ -165,7 +165,7 @@ 60 - + selectitem:framePages:PageCDR @@ -211,7 +211,7 @@ 60 - + selectitem:framePages:PageAccounts @@ -257,7 +257,7 @@ 60 - + selectitem:framePages:PageContacts @@ -303,7 +303,7 @@ 60 - + selectitem:framePages:PageSettings @@ -641,7 +641,7 @@ Show or hide the keypad - + @@ -759,7 +759,7 @@ true - + digit:1 @@ -796,7 +796,7 @@ true - + digit:4 @@ -833,7 +833,7 @@ true - + digit:7 @@ -870,7 +870,7 @@ true - + digit:* @@ -917,7 +917,7 @@ true - + digit:2 @@ -954,7 +954,7 @@ true - + digit:5 @@ -991,7 +991,7 @@ true - + digit:8 @@ -1028,7 +1028,7 @@ true - + digit:0 @@ -1075,7 +1075,7 @@ true - + digit:3 @@ -1112,7 +1112,7 @@ true - + digit:6 @@ -1155,7 +1155,7 @@ true - + digit:9 @@ -1193,7 +1193,7 @@ true - + digit:# @@ -1703,7 +1703,7 @@ Clear all incoming calls log - + clear:log_outgoing @@ -1885,7 +1885,7 @@ Clear all incoming calls log - + clear:log_incoming @@ -2477,7 +2477,7 @@ Show or hide the events window - + showwindow:events @@ -2812,7 +2812,7 @@ Show or hide the Help window - + showwindow:help:0