Source: actions.h


Annotated List
Files
Globals
Hierarchy
Index
// -*- c++ -*-

#ifndef ACTIONS_H
#define ACTIONS_H

#include 
#include 

class QLCDNumber;
class QSlider;
class KMainWindow;

/**
 * A KAction that toggles a QWidget between normal and full-screen
 * display.
 *
 * @author Richard Moore, rich@kde.org
 * @version $Id: actions.h,v 1.2 2002/03/18 20:45:33 rich Exp $
 */
class FullScreenAction : public KAction
{
    Q_OBJECT

public:
    /**
     * Creates a FullScreenAction that will operate on the specified
     * @ref QWidget object.
     */
    FullScreenAction( QWidget *window, QObject *parent = 0, const char *name = 0 );

    /**
     * Creates a FullScreenAction.
     */
    FullScreenAction( QObject *parent = 0, const char *name = 0 );

    /**
     * Returns the @ref QWidget the action will operate on.
     */
    QWidget *widget() const { return mainwin; }

    /**
     * Returns true iff the widget is in full-screen mode.
     */
    bool isFullScreen() const { return fullscreen; }

public slots:
    /**
     * Toggles the widget between normal and full-screen modes.
     */
    void toggleFullScreen();

    /**
     * Sets the display mode of the widget.
     */
    virtual void setFullScreen( bool full=true );

    /**
     * Specifies the QWidget the action should operate on.
     */
    virtual void setWidget( QWidget *w );

protected slots:
    /**
     * Reimplemented to call the @ref toggleFullScreen() method.
     */
    virtual void slotActivated();

private:
    QWidget *mainwin;
    bool fullscreen;
};

/**
 * A KAction that hides and shows the various bars of a main window.
 * This action hides and shows the menubar, toolbars and statusbar of
 * a KMainWindow. In addition, it allows applications to specify
 * additional widgets that it should affect, so application defined
 * bars such as sidebars can behave consistently.
 *
 * @author Richard Moore, rich@kde.org
 * @version $Id: actions.h,v 1.2 2002/03/18 20:45:33 rich Exp $
 */
class ToggleAllBarsAction : public KAction
{
    Q_OBJECT

public:
    /**
     * Creates a ToggleAllBarsAction that will control the bars of the
     * specified KMainWindow.
     */
    ToggleAllBarsAction( KMainWindow *win, QObject *parent = 0, const char *name = 0 );

    /**
     * Creates a ToggleAllBarsAction.
     */
    ToggleAllBarsAction( QObject *parent = 0, const char *name = 0 );

    /**
     * Returns the main window.
     */
    KMainWindow *mainWindow() const { return mainwin; }

    /**
     * Returns true iff the action has hidden the bars.
     */
    bool hasHiddenBars() const { return hidden; }

    /**
     * Returns true iff the specified widget has been added as a bar.
     */
    bool hasBar( QWidget *w );

public slots:
    /**
     * Toggles the state of the bars shown by the current main window.
     */
    void toggleBars();

    /**
     * Shows any bars that were previously hidden by this action. Note
     * that this does not affect bars that this action did not hide.
     */
    virtual void showBars();

    /**
     * Hides any bars displayed by the main window.
     */
    virtual void hideBars();

    /**
     * Specifies the main window to control.
     */
    virtual void setMainWindow( KMainWindow *w );

    /**
     * Adds a widget to the list that will be affected by the
     * @ref hideBars() method.
     */
    virtual void addBar( QWidget *w );

    /**
     * Removes the widget from the list that will be affected by
     * the @ref hideBars() method.
     */
    virtual void removeBar( QWidget *w );

protected slots:
    /**
     * Used internally when a widget is destroyed to ensure we don't
     * subsequently try to use it. This method simply checks we have a
     * QWidget, then calls @ref removeBar(QWidget *) to remove it from
     * the list of bars.
     */
    void removeBar( QObject *w );

    /**
     * Reimplemented to call the @ref toggleBars() method.
     */
    virtual void slotActivated();

private:
    KMainWindow *mainwin;
    bool hidden;
    QPtrList hiddenWidgets;
    QPtrList fluff;
};

//
// Actions for displaying custom QWidgets.
//

/**
 * A KAction that displays a number using the @ref QLCDNumber class.
 *
 * @author Richard Moore, rich@kde.org
 * @version $Id: actions.h,v 1.2 2002/03/18 20:45:33 rich Exp $
 */
class LCDNumberAction : public KAction
{
    Q_OBJECT

public:
    /**
     * Creates a LCDNumberAction.
     *
     * @param text  The label for the LCD. Currently this is displayed
     *              as a tooltip.
     */
    LCDNumberAction( const QString &text, int accel,
		     QObject *receiver, const char *slot,
		     QObject *parent = 0, const char *name = 0 );

    virtual int plug( QWidget *widget, int index = -1 );
    virtual void unplug( QWidget *widget );

    QLCDNumber *widget() const { return lcd; }

    int intValue() const { return val.toInt(); }
    QString value() const { return val; }

    int numDigits() const { return numDig; }

public slots:
    void display( int num );
    void display( const QString &s );

    void setNumDigits( int nDigits );

protected:
    virtual QLCDNumber *createWidget( QWidget *parent, const char *name=0 );

private:
    QLCDNumber *lcd;
    int numDig;
    QString val;
};

/**
 * A KAction that displays an a value using a QSlider. Applications
 * can use this class to add a QSlider widget to their toolbars (eg. a
 * volume control).
 *
 * @author Richard Moore, rich@kde.org
 * @version $Id: actions.h,v 1.2 2002/03/18 20:45:33 rich Exp $
 */
class SliderAction : public KAction
{
    Q_OBJECT

public:
    SliderAction( int min, int max, int step, int val,
		  const QString &text,
		  QObject *parent = 0, const char *name = 0 );

    virtual int plug( QWidget *widget, int index = -1 );
    virtual void unplug( QWidget *widget );

    /**
     * Returns a pointer to the QSlider object.
     */
    QSlider *widget() const { return slide; }

    /**
     * Returns the current value of the slider.
     */
    int value() const { return val; }

    /**
     * A factory method that creates the QSlider object.
     */
    virtual QSlider *createWidget( QWidget *parent, const char *name=0 );

public slots:
    /**
     * Sets the value of the slider.
     *
     * @ref QSlider::setValue(int)
     */
    void setValue( int num );

    /**
     * Sets the interval between the tickmarks of the slider.
     *
     * @ref QSlider::setTickInteral(int)
     */
    void setTickInterval( int ticks );

    /**
     * Sets the orientation of the slider.
     */
    void setOrientation( Orientation o );

signals:
    /**
     * Emitted when the value of the slider is changed.
     */
    void valueChanged( int );

private:
    QSlider *slide;
    int min;
    int max;
    int step;
    int val;
    int tickStep;
};

#endif // ACTIONS_H


Generated by: rich on pegasus on Wed Mar 20 03:16:53 2002, using kdoc 2.0a53.