core/ui separation

Matthias Kretz kretz at kde.org
Thu May 18 13:09:32 BST 2006


On Thursday, 18. May 2006 13:09, David Faure wrote:
> - errors and warnings. I like the idea of an ErrorHandler class that would
> be derived from in kdeui (maybe as a singleton instanciated by
> kapplication, which will be in kdeui, and which can be instanciated
> manually otherwise).

So we'd create something that is similar to the KMessageBox API (without the 
QWidget and KGuiItem parameter)? A non-GUI application could make use of a 
lot of the KMessageBox functionality as well.

A sketch of what it could look like:

kdecore:
========
class KMessageHandler
{
public:
	virtual void error( const QString& text, const QString& caption, Options 
options ) = 0;
};

class KMessage
{
public:
	static void setMessageHandler( KMessageHandler* h ) { s_handler = h; }
	static void error( const QString& text, const QString& caption = QString(), 
Options options = 0 );
private:
	static KMessageHandler* s_handler;
};

void KMessage::error( const QString& text, const QString& caption, Options 
options )
{
	if( s_handler )
		s_handler->error( text, caption, options );
	else
		kError() << text << endl;
}

kdeui:
======
KMessageBoxHandler : public KMessageHandler
{
public:
	KMessageBoxHandler( QWidget* parent ) : m_parentWidget( parent ) {}
	void error( const QString& text, const QString& caption, Options options ) 
{ KMessageBox::error( m_parentWidget, text, caption, options ); }
private:
	m_parentWidget;
};

-- 
C'ya
        Matthias
________________________________________________________
Matthias Kretz (Germany)                            <><
http://Vir.homelinux.org/
MatthiasKretz at gmx.net, kretz at kde.org,
Matthias.Kretz at urz.uni-heidelberg.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20060518/c9a32210/attachment.sig>


More information about the kde-core-devel mailing list