[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Re: core/ui separation
From:       Matthias Kretz <kretz () kde ! org>
Date:       2006-05-18 12:09:32
Message-ID: 200605181409.37503.kretz () kde ! org
[Download RAW message or body]


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@gmx.net, kretz@kde.org,
Matthias.Kretz@urz.uni-heidelberg.de

[Attachment #3 (application/pgp-signature)]

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic