Exemplo n.º 1
0
KVSO_CLASS_FUNCTION(trayIcon,setContextMenu)
{
	CHECK_INTERNAL_POINTER(m_pTrayIcon)
	KviKvsObject *ob;
	kvs_hobject_t hObject;
	KVSO_PARAMETERS_BEGIN(c)
		KVSO_PARAMETER("widget",KVS_PT_HOBJECT,0,hObject)
	KVSO_PARAMETERS_END(c)
	ob=KviKvsKernel::instance()->objectController()->lookupObject(hObject);
	if (!ob)
	{
		c->warning(__tr2qs_ctx("Widget parameter is not an object","objects"));
		return true;
	}
	if (!ob->object())
	{
		c->warning(__tr2qs_ctx("Widget parameter is not a valid object","objects"));
		return true;
	}
	if(!ob->inheritsClass("popupmenu"))
	{
		c->warning(__tr2qs_ctx("Can't add a non-popupmenu object","objects"));
		return true;
	}
	 m_pTrayIcon->setContextMenu(((QMenu  *)(ob->object())));
	return true;
}
Exemplo n.º 2
0
KVSO_CLASS_FUNCTION(mainWindow,setCentralWidget)
{
	CHECK_INTERNAL_POINTER(widget())
	KviKvsObject * pObject;
	kvs_hobject_t hObject;
	KVSO_PARAMETERS_BEGIN(c)
		KVSO_PARAMETER("widget",KVS_PT_HOBJECT,0,hObject)
	KVSO_PARAMETERS_END(c)
	pObject=KviKvsKernel::instance()->objectController()->lookupObject(hObject);
	if (!pObject)
	{
		c->warning(__tr2qs_ctx("Widget parameter is not an object","objects"));
		return true;
	}
	if (!pObject->object())
	{
		c->warning(__tr2qs_ctx("Widget parameter is not a valid object","objects"));
		return true;
	}
	if(!pObject->inheritsClass("widget"))
	{
		c->warning(__tr2qs_ctx("Widget object required","objects"));
		return true;
	}
	((KviTalMainWindow *)widget())->setCentralWidget(((QWidget  *)(pObject->object())));
	return true;
}
Exemplo n.º 3
0
KVSO_CLASS_FUNCTION(lineEdit, setMaxLength)
{
	CHECK_INTERNAL_POINTER(widget())
	kvs_uint_t iMaxlen;
	KVSO_PARAMETERS_BEGIN(c)
	KVSO_PARAMETER("maxlen", KVS_PT_UNSIGNEDINTEGER, 0, iMaxlen)
	KVSO_PARAMETERS_END(c)
	((QLineEdit *)widget())->setMaxLength(iMaxlen);
	return true;
}
Exemplo n.º 4
0
KVSO_CLASS_FUNCTION(hBox,setMargin)
{
	CHECK_INTERNAL_POINTER(widget())
	kvs_uint_t uMargin;
	KVSO_PARAMETERS_BEGIN(c)
		KVSO_PARAMETER("margin",KVS_PT_UNSIGNEDINTEGER,0,uMargin)
	KVSO_PARAMETERS_END(c)
	((KviTalHBox *)widget())->setMargin(uMargin);
	return true;
}
Exemplo n.º 5
0
KVSO_CLASS_FUNCTION(lineEdit, setText)
{
	CHECK_INTERNAL_POINTER(widget())
	QString szText;
	KVSO_PARAMETERS_BEGIN(c)
	KVSO_PARAMETER("text", KVS_PT_STRING, 0, szText)
	KVSO_PARAMETERS_END(c)
	((QLineEdit *)widget())->setText(szText);
	return true;
}
Exemplo n.º 6
0
KVSO_CLASS_FUNCTION(hBox,addStretch)
{
	CHECK_INTERNAL_POINTER(widget())
	kvs_int_t iStretch;
	KVSO_PARAMETERS_BEGIN(c)
		KVSO_PARAMETER("stretch",KVS_PT_INT,0,iStretch)
	KVSO_PARAMETERS_END(c)
	((KviTalHBox *)widget())->addStretch(iStretch);
	return true;
}
Exemplo n.º 7
0
KVSO_CLASS_FUNCTION(trayIcon,setTooltip)
{
	CHECK_INTERNAL_POINTER(m_pTrayIcon)
	QString szTooltip;
	KVSO_PARAMETERS_BEGIN(c)
		KVSO_PARAMETER("icon",KVS_PT_STRING,0,szTooltip)
	KVSO_PARAMETERS_END(c)
	m_pTrayIcon->setToolTip(szTooltip);
	return true;
}
Exemplo n.º 8
0
KVSO_CLASS_FUNCTION(groupBox,setTitle)
{
	CHECK_INTERNAL_POINTER(widget())
	QString szTitle;
	KVSO_PARAMETERS_BEGIN(c)
		KVSO_PARAMETER("title",KVS_PT_STRING,0,szTitle)
	KVSO_PARAMETERS_END(c)
	((KviTalGroupBox *)widget())->setTitle(szTitle);
	return true;
}
Exemplo n.º 9
0
KVSO_CLASS_FUNCTION(hBox,setSpacing)
{
	CHECK_INTERNAL_POINTER(widget())
	kvs_uint_t uSpacing;
	KVSO_PARAMETERS_BEGIN(c)
		KVSO_PARAMETER("spacing",KVS_PT_UNSIGNEDINTEGER,0,uSpacing)
	KVSO_PARAMETERS_END(c)
	((KviTalHBox *)widget())->setSpacing(uSpacing);
	return true;
}
Exemplo n.º 10
0
KVSO_CLASS_FUNCTION(lineEdit, setInputValidator)
{
	CHECK_INTERNAL_POINTER(widget())
	QString szReg;
	KVSO_PARAMETERS_BEGIN(c)
	KVSO_PARAMETER("reg_expression", KVS_PT_STRING, 0, szReg)
	KVSO_PARAMETERS_END(c)
	((QLineEdit *)widget())->setValidator(new QRegExpValidator(QRegExp(szReg), ((QLineEdit *)widget())));
	return true;
}
Exemplo n.º 11
0
KVSO_CLASS_FUNCTION(vBox,setSpacing)
{
	CHECK_INTERNAL_POINTER(widget())
	kvs_int_t iSpacing;
	KVSO_PARAMETERS_BEGIN(c)
		KVSO_PARAMETER("spacing",KVS_PT_INT,0,iSpacing)
	KVSO_PARAMETERS_END(c)
	((KviTalVBox *)widget())->setSpacing(iSpacing);
	return true;
}
Exemplo n.º 12
0
KVSO_CLASS_FUNCTION(vBox,setMargin)
{
	CHECK_INTERNAL_POINTER(widget())
	kvs_int_t iMargin;
	KVSO_PARAMETERS_BEGIN(c)
		KVSO_PARAMETER("margin",KVS_PT_INT,0,iMargin)
	KVSO_PARAMETERS_END(c)
	((KviTalVBox *)widget())->setMargin(iMargin);
	return true;
}
Exemplo n.º 13
0
KVSO_CLASS_FUNCTION(trayIcon,setIcon)
{
	CHECK_INTERNAL_POINTER(m_pTrayIcon)
	QString szIcon;
	KVSO_PARAMETERS_BEGIN(c)
		KVSO_PARAMETER("icon",KVS_PT_STRING,0,szIcon)
	KVSO_PARAMETERS_END(c)
	QPixmap * pix = g_pIconManager->getImage(szIcon);
	if(pix) m_pTrayIcon->setIcon(*pix);
	return true;
}
Exemplo n.º 14
0
KVSO_CLASS_FUNCTION(dateTimeEdit,time)
{

	CHECK_INTERNAL_POINTER(widget())
	QString szFormat;
	KVSO_PARAMETERS_BEGIN(c)
		KVSO_PARAMETER("format",KVS_PT_STRING,0,szFormat)
	KVSO_PARAMETERS_END(c)

	c->returnValue()->setString(((QDateTimeEdit *)widget())->time().toString(szFormat));

	return true;
}
Exemplo n.º 15
0
KVSO_CLASS_FUNCTION(toolButton,setImage)
{
    CHECK_INTERNAL_POINTER(widget())
    QString icon;
    KVSO_PARAMETERS_BEGIN(c)
    KVSO_PARAMETER("icon_id",KVS_PT_STRING,0,icon)
    KVSO_PARAMETERS_END(c)
    QPixmap * pix = g_pIconManager->getImage(icon);
    if(pix)
        ((QToolButton *)widget())->setIcon(QIcon(*pix));
    else
        ((QToolButton *)widget())->setIcon(QIcon());
    return true;
}
Exemplo n.º 16
0
KVSO_CLASS_FUNCTION(dateTimeEdit,setTime)
{

	CHECK_INTERNAL_POINTER(widget())
	QString szFormat,szTime;
	KVSO_PARAMETERS_BEGIN(c)
		KVSO_PARAMETER("format",KVS_PT_STRING,0,szFormat)
		KVSO_PARAMETER("date",KVS_PT_STRING,0,szTime)
	KVSO_PARAMETERS_END(c)
	QTime time;
	time=time.fromString(szTime,szFormat);
	((QDateTimeEdit *)widget())->setTime(time);
	return true;
}
KVSO_CLASS_FUNCTION(workspace,addSubWindow)
{
	CHECK_INTERNAL_POINTER(widget())
	KviKvsObject * pObject;
	kvs_hobject_t hObject;
	KVSO_PARAMETERS_BEGIN(c)
		KVSO_PARAMETER("widget",KVS_PT_HOBJECT,0,hObject)
	KVSO_PARAMETERS_END(c)

	pObject=KviKvsKernel::instance()->objectController()->lookupObject(hObject);
	CHECK_HOBJECT_IS_WIDGET(pObject)
	QMdiSubWindow *pMdi=((QMdiArea *)object())->addSubWindow(((QWidget *)(pObject->object())));
	pWidgetDict->insert(hObject,pMdi);
	((QMdiArea *)object())->setActiveSubWindow(pMdi);
	return true;
}
Exemplo n.º 18
0
KVSO_CLASS_FUNCTION(wizard,addPage)
{
	CHECK_INTERNAL_POINTER(widget())
	KviKvsObject *ob;
	QString szLabel;
	kvs_hobject_t hObject;
	KVSO_PARAMETERS_BEGIN(c)
		KVSO_PARAMETER("page_widget",KVS_PT_HOBJECT,0,hObject)
		KVSO_PARAMETER("label",KVS_PT_STRING,0,szLabel)
	KVSO_PARAMETERS_END(c)
	ob=KviKvsKernel::instance()->objectController()->lookupObject(hObject);
	if(!ob->object()->isWidgetType())
	{
		c->warning(__tr2qs_ctx("Can't add a non-widget object","objects"));
		return true;
	}
	((KviTalWizard *)widget())->addPage(((QWidget *)(ob->object())),szLabel);
	return true;
}
Exemplo n.º 19
0
KVSO_CLASS_FUNCTION(wizard,setTitle)
{
	CHECK_INTERNAL_POINTER(widget())
	KviKvsObject *ob;
	QString szTitle;
	kvs_hobject_t hObject;
	KVSO_PARAMETERS_BEGIN(c)
		KVSO_PARAMETER("page_widget",KVS_PT_HOBJECT,0,hObject)
		KVSO_PARAMETER("title",KVS_PT_STRING,0,szTitle)
	KVSO_PARAMETERS_END(c)
	ob=KviKvsKernel::instance()->objectController()->lookupObject(hObject);
	if(!ob->object()->isWidgetType())
	{
		c->warning(__tr2qs_ctx("Widget object required","objects"));
		return true;
	}
	((KviTalWizard *)widget())->setPageTitle(((QWidget *)(ob->object())),szTitle);
	return true;
}
Exemplo n.º 20
0
KVSO_CLASS_FUNCTION(trayIcon,showMessage)
{
	CHECK_INTERNAL_POINTER(m_pTrayIcon)
	QString szMessage,szTitle,szMessageIcon;
	kvs_uint_t uTimeout;
	KVSO_PARAMETERS_BEGIN(c)
		KVSO_PARAMETER("title",KVS_PT_STRING,0,szTitle)
		KVSO_PARAMETER("message",KVS_PT_STRING,0,szMessage)
		KVSO_PARAMETER("icon",KVS_PT_STRING,0,szMessageIcon)
		KVSO_PARAMETER("timeout",KVS_PT_UINT,0,uTimeout)
	KVSO_PARAMETERS_END(c)
	QSystemTrayIcon::MessageIcon message=QSystemTrayIcon::NoIcon;
	if(KviQString::equalCI(szMessageIcon,"NoIcon")) message= QSystemTrayIcon::NoIcon;
	else if(KviQString::equalCI(szMessageIcon,"Information"))message= QSystemTrayIcon::Information;
	else if(KviQString::equalCI(szMessageIcon,"Warning")) message= QSystemTrayIcon::Warning;
	else if(KviQString::equalCI(szMessageIcon,"Critical")) message= QSystemTrayIcon::Critical;
	else c->warning(__tr2qs_ctx("Invalid message Icon: switch to default NoIcon '%Q'","objects"),&szMessageIcon);
	m_pTrayIcon->showMessage(szTitle,szMessage,message,uTimeout);
	return true;
}
Exemplo n.º 21
0
KVSO_CLASS_FUNCTION(hBox,setStretchFactor)
{
	CHECK_INTERNAL_POINTER(widget())
	KviKvsObject * pObject;
	kvs_hobject_t hObject;
	kvs_uint_t uStretch;
	KVSO_PARAMETERS_BEGIN(c)
		KVSO_PARAMETER("widget",KVS_PT_HOBJECT,0,hObject)
		KVSO_PARAMETER("stretch",KVS_PT_UNSIGNEDINTEGER,0,uStretch)
	KVSO_PARAMETERS_END(c)
	pObject=KviKvsKernel::instance()->objectController()->lookupObject(hObject);
	CHECK_HOBJECT_IS_WIDGET(pObject)
	if(((KvsObject_widget *)pObject)->widget()->parentWidget() != widget())
	{
		c->warning(__tr2qs_ctx("The widget must be a child of this hbox","objects"));
		return true;
	}
	((KviTalHBox *)widget())->setStretchFactor(((QWidget *)(pObject->object())),uStretch);
	return true;
}
KVSO_CLASS_FUNCTION(workspace,removeSubWindow)
{
	CHECK_INTERNAL_POINTER(widget())
	KviKvsObject * pObject;
	kvs_hobject_t hObject;
	KVSO_PARAMETERS_BEGIN(c)
		KVSO_PARAMETER("widget",KVS_PT_HOBJECT,0,hObject)
	KVSO_PARAMETERS_END(c)

	pObject=KviKvsKernel::instance()->objectController()->lookupObject(hObject);
	CHECK_HOBJECT_IS_WIDGET(pObject)
	QMdiSubWindow *pMdiSubWindow=pWidgetDict->value(hObject);
	if(pMdiSubWindow)
	{
		((QMdiArea *)object())->removeSubWindow(pMdiSubWindow);
		pWidgetDict->remove(hObject);
	} else {
		c->warning(__tr2qs_ctx("The widget must be a subwindow of this workspace","objects"));
	}
	return true;
}
Exemplo n.º 23
0
KVSO_CLASS_FUNCTION(vBox,setAlignment)
{
	CHECK_INTERNAL_POINTER(widget())
	QStringList alignment;
	KviKvsObject * pObject;
	kvs_hobject_t hObject;
	KVSO_PARAMETERS_BEGIN(c)
		KVSO_PARAMETER("widget",KVS_PT_HOBJECT,0,hObject)
		KVSO_PARAMETER("alignment",KVS_PT_STRINGLIST,KVS_PF_OPTIONAL,alignment)
	KVSO_PARAMETERS_END(c)
	pObject=KviKvsKernel::instance()->objectController()->lookupObject(hObject);
	CHECK_HOBJECT_IS_WIDGET(pObject)
	if(((KvsObject_widget *)pObject)->widget()->parentWidget() != widget())
	{
		c->warning(__tr2qs_ctx("The widget must be a child of this hbox","objects"));
		return true;
	}

	int align,sum=0;
	for ( QStringList::Iterator it = alignment.begin(); it != alignment.end(); ++it )
		{

			align = 0;
			for(unsigned int j = 0; j < align_num; j++)
			{
				if(KviQString::equalCI((*it), align_tbl[j]))
				{
					align=align_cod[j];
					break;
				}
			}
			if(align)
				sum = sum | align;
			else
				c->warning(__tr2qs_ctx("Unknown alignment: '%Q'","objects"),&(*it));

		}
	if (widget()) ((KviTalHBox *)widget())->setAlignment(((QWidget *)(pObject->object())),(Qt::Alignment)sum);
	return true;
}
Exemplo n.º 24
0
KVSO_CLASS_FUNCTION(xmlReader, parse)
{
	KviKvsVariant * pVariantData;

	KVSO_PARAMETERS_BEGIN(c)
	KVSO_PARAMETER("string_or_memorybuffer_object", KVS_PT_VARIANT, 0, pVariantData)
	KVSO_PARAMETERS_END(c)
#ifdef QT_NO_XML
	fatalError(__tr2qs_ctx("XML support not available in the Qt library"));
	c->returnValue()->setBoolean(false);
#else
	m_szLastError = "";
	KviXmlHandler handler(this);
	QXmlInputSource source;

	if(pVariantData->isHObject())
	{
		KviKvsObject * pObject;
		kvs_hobject_t hObject;
		pVariantData->asHObject(hObject);
		pObject = KviKvsKernel::instance()->objectController()->lookupObject(hObject);
		if(!pObject)
		{
			c->warning(__tr2qs_ctx("Data parameter is not an object", "objects"));
			return true;
		}
		if(pObject->inheritsClass("memorybuffer"))
		{
			source.setData(*((KvsObject_memoryBuffer *)pObject)->pBuffer());
		}
		else
		{
			c->warning(__tr2qs_ctx("Data parameter is not a memorybuffer object", "objects"));
			return true;
		}
	}
	else if(pVariantData->isString())
	{
		QString szString;
		pVariantData->asString(szString);
		// We have a problem here.. most kvirc functions already interpret the data
		// read from files. We should have binary data handling features to get this to work correctly.
		// The following snippet of code tries to provide a best-effort workaround.
		QByteArray utf8data = szString.toUtf8();
		QByteArray data = utf8data;
		data.truncate(utf8data.length()); // don't include the null terminator in data
		source.setData(data);
		//qDebug("PARSING(%s) LEN(%d)",szString.toUtf8().data(),szString.toUtf8().length());
	}
	else
	{
		c->warning(__tr2qs_ctx("Data is not a memorybuffer object or string", "objects"));
		return true;
	}
	QXmlSimpleReader reader;
	reader.setContentHandler(&handler);
	reader.setErrorHandler(&handler);
	c->returnValue()->setBoolean(reader.parse(source));
#endif
	return true;
}