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
This commit is contained in:
marian 2010-03-08 09:35:59 +00:00
parent 08c5b34be1
commit ca5f2d3eb6
8 changed files with 57 additions and 61 deletions

View File

@ -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<QFrame*> frm = qFindChildren<QFrame*>(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<QObject*> w = qFindChildren<QObject*>(this);
for (int i = 0; i < w.size(); i++) {
@ -2436,7 +2419,6 @@ void QtWindow::doInit()
eventFilter(w[i],&ev);
}
}
#endif
qRegisterMetaType<QModelIndex>("QModelIndex");
qRegisterMetaType<QTextCursor>("QTextCursor");

View File

@ -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:".

View File

@ -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

View File

@ -989,7 +989,7 @@
<property name="toolTip" >
<string>Help on this window</string>
</property>
<property name="accessibleName" >
<property name="_yate_identity" stdset="0" >
<string>showwindow:help:3</string>
</property>
<property name="icon" >

View File

@ -174,7 +174,7 @@
<property name="toolTip" >
<string>Help on this window</string>
</property>
<property name="accessibleName" >
<property name="_yate_identity" stdset="0" >
<string>showwindow:help:2</string>
</property>
<property name="text" >

View File

@ -48,7 +48,7 @@
<height>100</height>
</size>
</property>
<property name="accessibleName" >
<property name="_yate_identity" stdset="0" >
<string/>
</property>
<property name="title" >
@ -92,7 +92,7 @@
<height>25</height>
</size>
</property>
<property name="accessibleName" >
<property name="_yate_identity" stdset="0" >
<string>debug:jingle:level 9:level 5</string>
</property>
<property name="text" >
@ -114,7 +114,7 @@
<height>25</height>
</size>
</property>
<property name="accessibleName" >
<property name="_yate_identity" stdset="0" >
<string>debug:sip:level 9:level 5</string>
</property>
<property name="text" >
@ -136,7 +136,7 @@
<height>25</height>
</size>
</property>
<property name="accessibleName" >
<property name="_yate_identity" stdset="0" >
<string>debug:h323:level 9:level 5</string>
</property>
<property name="text" >
@ -158,7 +158,7 @@
<height>25</height>
</size>
</property>
<property name="accessibleName" >
<property name="_yate_identity" stdset="0" >
<string>debug:iax:level 9:level 5</string>
</property>
<property name="text" >
@ -185,7 +185,7 @@
<layout class="QHBoxLayout" >
<item>
<widget class="QPushButton" name="debug_sniffer" >
<property name="accessibleName" >
<property name="_yate_identity" stdset="0" >
<string>command:sniffer</string>
</property>
<property name="text" >
@ -236,7 +236,7 @@
<height>25</height>
</size>
</property>
<property name="accessibleName" >
<property name="_yate_identity" stdset="0" >
<string>clear:log_events</string>
</property>
<property name="text" >
@ -320,7 +320,7 @@
<property name="toolTip" >
<string>Help on this window</string>
</property>
<property name="accessibleName" >
<property name="_yate_identity" stdset="0" >
<string>showwindow:help:4</string>
</property>
<property name="icon" >

View File

@ -102,7 +102,7 @@
<property name="toolTip" >
<string/>
</property>
<property name="accessibleName" >
<property name="_yate_identity" stdset="0" >
<string>help:prev</string>
</property>
<property name="text" >
@ -136,7 +136,7 @@
<property name="toolTip" >
<string>Home</string>
</property>
<property name="accessibleName" >
<property name="_yate_identity" stdset="0" >
<string>help:home</string>
</property>
<property name="text" >
@ -167,7 +167,7 @@
<height>25</height>
</size>
</property>
<property name="accessibleName" >
<property name="_yate_identity" stdset="0" >
<string>help:next</string>
</property>
<property name="text" >

View File

@ -116,7 +116,7 @@
<pointsize>8</pointsize>
</font>
</property>
<property name="accessibleName" >
<property name="_yate_identity" stdset="0" >
<string>selectitem:framePages:PageCalls</string>
</property>
<property name="text" >
@ -165,7 +165,7 @@
<height>60</height>
</size>
</property>
<property name="accessibleName" >
<property name="_yate_identity" stdset="0" >
<string>selectitem:framePages:PageCDR</string>
</property>
<property name="text" >
@ -211,7 +211,7 @@
<height>60</height>
</size>
</property>
<property name="accessibleName" >
<property name="_yate_identity" stdset="0" >
<string>selectitem:framePages:PageAccounts</string>
</property>
<property name="text" >
@ -257,7 +257,7 @@
<height>60</height>
</size>
</property>
<property name="accessibleName" >
<property name="_yate_identity" stdset="0" >
<string>selectitem:framePages:PageContacts</string>
</property>
<property name="text" >
@ -303,7 +303,7 @@
<height>60</height>
</size>
</property>
<property name="accessibleName" >
<property name="_yate_identity" stdset="0" >
<string>selectitem:framePages:PageSettings</string>
</property>
<property name="text" >
@ -641,7 +641,7 @@
<property name="toolTip" >
<string>Show or hide the keypad</string>
</property>
<property name="accessibleName" >
<property name="_yate_identity" stdset="0" >
<string/>
</property>
<property name="text" >
@ -759,7 +759,7 @@
<bold>true</bold>
</font>
</property>
<property name="accessibleName" >
<property name="_yate_identity" stdset="0" >
<string>digit:1</string>
</property>
<property name="text" >
@ -796,7 +796,7 @@
<bold>true</bold>
</font>
</property>
<property name="accessibleName" >
<property name="_yate_identity" stdset="0" >
<string>digit:4</string>
</property>
<property name="text" >
@ -833,7 +833,7 @@
<bold>true</bold>
</font>
</property>
<property name="accessibleName" >
<property name="_yate_identity" stdset="0" >
<string>digit:7</string>
</property>
<property name="text" >
@ -870,7 +870,7 @@
<bold>true</bold>
</font>
</property>
<property name="accessibleName" >
<property name="_yate_identity" stdset="0" >
<string>digit:*</string>
</property>
<property name="text" >
@ -917,7 +917,7 @@
<bold>true</bold>
</font>
</property>
<property name="accessibleName" >
<property name="_yate_identity" stdset="0" >
<string>digit:2</string>
</property>
<property name="text" >
@ -954,7 +954,7 @@
<bold>true</bold>
</font>
</property>
<property name="accessibleName" >
<property name="_yate_identity" stdset="0" >
<string>digit:5</string>
</property>
<property name="text" >
@ -991,7 +991,7 @@
<bold>true</bold>
</font>
</property>
<property name="accessibleName" >
<property name="_yate_identity" stdset="0" >
<string>digit:8</string>
</property>
<property name="text" >
@ -1028,7 +1028,7 @@
<bold>true</bold>
</font>
</property>
<property name="accessibleName" >
<property name="_yate_identity" stdset="0" >
<string>digit:0</string>
</property>
<property name="text" >
@ -1075,7 +1075,7 @@
<bold>true</bold>
</font>
</property>
<property name="accessibleName" >
<property name="_yate_identity" stdset="0" >
<string>digit:3</string>
</property>
<property name="text" >
@ -1112,7 +1112,7 @@
<bold>true</bold>
</font>
</property>
<property name="accessibleName" >
<property name="_yate_identity" stdset="0" >
<string>digit:6</string>
</property>
<property name="text" >
@ -1155,7 +1155,7 @@
<bold>true</bold>
</font>
</property>
<property name="accessibleName" >
<property name="_yate_identity" stdset="0" >
<string>digit:9</string>
</property>
<property name="text" >
@ -1193,7 +1193,7 @@
<kerning>true</kerning>
</font>
</property>
<property name="accessibleName" >
<property name="_yate_identity" stdset="0" >
<string>digit:#</string>
</property>
<property name="text" >
@ -1703,7 +1703,7 @@
<property name="toolTip" >
<string>Clear all incoming calls log</string>
</property>
<property name="accessibleName" >
<property name="_yate_identity" stdset="0" >
<string>clear:log_outgoing</string>
</property>
<property name="text" >
@ -1885,7 +1885,7 @@
<property name="toolTip" >
<string>Clear all incoming calls log</string>
</property>
<property name="accessibleName" >
<property name="_yate_identity" stdset="0" >
<string>clear:log_incoming</string>
</property>
<property name="text" >
@ -2477,7 +2477,7 @@
<property name="toolTip" >
<string>Show or hide the events window</string>
</property>
<property name="accessibleName" >
<property name="_yate_identity" stdset="0" >
<string>showwindow:events</string>
</property>
<property name="text" >
@ -2812,7 +2812,7 @@
<property name="toolTip" >
<string>Show or hide the Help window</string>
</property>
<property name="accessibleName" >
<property name="_yate_identity" stdset="0" >
<string>showwindow:help:0</string>
</property>
<property name="text" >