// Copyright (C) 2009 by Arnaud Dupuis // a.dupuis@infinityperl.org // http://www.infinityperl.org // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the // Free Software Foundation, Inc., // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA #ifndef ASSUMA_PASSIVEPOPUP_H #define ASSUMA_PASSIVEPOPUP_H #include <QWidget> #include "ui_assuma_passivepopup.h" class QPixmap; class QString; /*! \class AssumaPassivePopup * \brief A class to display information messages to users. * * This class is the one used to show informations to users. * "information" is a common term to say "something users should know about", it can be * informational, a warning or a critical error (\sa Icon). * * Here is an example on how to use it in combination with the AssumaEffect class : * \code * AssumaPassivePopup *popup = new AssumaPassivePopup(this); * popup->setText(str); * AssumaEffect *effect = new AssumaEffect(0,popup, AssumaEffect::SLIDE_FROM_BOTTOM); * connect( popup, SIGNAL( closeButtonClicked() ), effect, SLOT( reverseEffect() ) ); * connect( effect, SIGNAL( AssumaEffectFinished() ), popup, SLOT( close() ) ); * effect->setTimeBeforeReversing( popup->timeToShow() ); * effect->doEffect(); * \endcode */ class AssumaPassivePopup : public QWidget , public Ui::AssumaPassivePopup { Q_OBJECT signals: /*! * This signal is emitted when the close button is clicked. * This signal must be connected to some slot to do something. * \warning since the 3.0 version this widget do not embded animation code anymore, it is only a conveniente class to display a message with an icon. * \sa AssumaEffect */ void closeButtonClicked(); public: //! Icons enum /*! This enum contains the three basic severity type you can pass as parameters to the setPixmap( Icon ). It shows different kind of icons depending on the severity */ enum Icon { Info, /*!< Enum value Info (shows an informational icon). */ Critical, /*!< Enum value Critical (shows a critical icon). */ Warning /*!< Enum value Warning (show a warning icon). */ }; //! Constructor /*! The constructor of the passive popup, it can takes a parent widget as parameter. Actually it is strongly recommended for this object to have parent. This kind of message makes no sense without a parent window. \param parent the parent widget. */ AssumaPassivePopup(QWidget *parent=0); /*! * This function returns the currently displayed text. * \return the passive popup current text. */ QString text(); /*! * \return the optimal time to show the widget to user. It is simply based on the text size. * \warning the minimum time to show you can get is 3 seconds (there is no maximum). */ int timeToShow(); public slots: /*! * Set the corner's pixmap. * \param pix the pixmap as a QPixmap. */ void setPixmap( const QPixmap & ); /*! * Same as setPixmap(const QPixmap&), provided for convenience. * \sa setPixmap( const QPixmap & ) * \param ico the desired image (as Icon) */ void setPixmap( Icon ); /*! * Set the close button's pixmap. * This method should only be used by AssumaMainWinwod class during it's initialization. * If you just want to change the look of this icon, use the theme feature. * \param pix the pixmap as a QPixmap. */ void setCloseButtonPixmap( const QPixmap & ); /*! * Set the text to display to user. You can use plaain text or * Qt supported HTML subset. * \param str the text string. */ void setText( const QString & ); /*! * Resize the popup to fit text's best size (text label's sizeHint()). * \warning The behaviour changed in version 3.0. It is now automatically called by setText(). */ void updateDimensions(); private slots: void on_pushButton_clicked(); private: QPalette windowPalette; }; #endif