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

List:       kde-core-devel
Subject:    KMultiActionButton
From:       "Aaron J. Seigo" <aseigo () kde ! org>
Date:       2006-12-05 21:59:04
Message-ID: 200612051459.05462.aseigo () kde ! org
[Download RAW message or body]

[Attachment #2 (multipart/mixed)]


hi all...

attached is a draft API for a widget that groups multiple actions into one 
area on a toolbar. screenshot can be seen here:

 http://bddf.ca/~aseigo/actionbutton.png

it looks like crap right now, i know, but i'm more interested in the API. to 
this point i've modelled it after QToolBar's API. the idea is that you create 
one of these buttons, add actions to it and then call QToolBar::addWidget( 
multiActionButton ).

thoughts? (and yes, i know there isn't any API docu there yet)

-- 
Aaron J. Seigo
humru othro a kohnu se
GPG Fingerprint: 8B8B 2209 0C6F 7C47 B1EA  EE75 D6B7 2EB1 A7F1 DB43

Full time KDE developer sponsored by Trolltech (http://www.trolltech.com)

["kmultiactionbutton.h" (text/x-c++hdr)]

#ifndef KMULTIACTIONBUTON_H
#define KMULTIACTIONBUTON_H

#include <QtGui/QWidget>
#include <QDebug>

class KMultiActionButton : public QWidget
{
    Q_OBJECT

    public:
        KMultiActionButton(QWidget* parent);
        virtual ~KMultiActionButton();

        QAction* actionAt( const QPoint & p ) const;
        QAction* actionAt( int x, int y ) const;
        void addAction( QAction* action );
        void addActions( QList<QAction*> actions );
        QAction* addAction( const QString & text );
        QAction* addAction( const QIcon & icon, const QString & text );
        QAction* addAction( const QString & text,
                            const QObject * receiver,const char * member );
        QAction* addAction( const QIcon & icon, const QString & text,
                            const QObject * receiver, const char * member );

        QSize sizeHint() const;
        QSize minimumSizeHint() const;

    public Q_SLOTS:

    Q_SIGNALS:
        void actionTriggered( QAction* action );

    protected:
        // need to update on QAction::changed, ::toggled and maybe ::triggered
        void paintEvent( QPaintEvent* event );

        // QAction::menu() to see if this should be painted as a menu item
        // call update() when an action is added or removed
        void actionEvent( QActionEvent* event );

        // check for event->type() == QEvent::ParentChange
        void changeEvent( QEvent* event );

    private:
        class Private;
        Private* d;
};

/*
signals to connect to:

QToolBar::toolButtonStyleChanged ( Qt::ToolButtonStyle toolButtonStyle )
QToolBar::orientationChanged ( Qt::Orientation orientation )
QToolBar::iconSizeChanged ( const QSize & iconSize )

qstyle stuff to use in the paintevent:

QStyle::PM_ToolBarItemSpacing
QStyle::PM_ToolBarIconSize?
QStyle::PE_IndicatorToolBarSeparator?

paint a rounded sunken frame around the buttons and then paint the icons inside
of that.
*/

#endif

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

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

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