splash->show();
app.processEvents();
// doing first step
- splash->message("Step 1");
+ splash->setMessage("Step 1");
splash->ress(1);
qApp->processEvents();
// ... perform some actions
// doing second step
- splash->message("Step 2");
+ splash->setMessage("Step 2");
splash->setProgress(2);
qApp->processEvents();
// ... perform some actions
\endcode
There is a static function QtxSplash::setStatus() which allows to put next status message
- and progress with one call. It can substitue two calls: message() and setProgress().
+ and progress with one call. It can substitue two calls: setMessage() and setProgress().
QtxSplash class provides alos a lot of functions to set-up its behavior. Set progress
bar width with setProgressWidth() method, its position and direction with setProgressFlags().
To change the progress bar and status message transparency, use setOpacity() function.
The methods setTextAlignment(), setTextColor() and setTextColors() can be used to change
the attributes of the status message.
+
+ The displayed message text includes constant info and status message. The constant info
+ is set by setConstantInfo() method and status message is set by setMessage().
*/
//! The only one instance of splash screen
\param msg progress status message
\param progress current progress
- \sa message(), setProgress()
+ \sa setMessage(), setProgress()
*/
void QtxSplash::setStatus( const QString& msg, const int progress )
{
shadow = myShadowColor;
}
+/*!
+ \brief Set constant info text to be displayed on the splash screen.
+
+ The displayed text includes constant info and status message.
+ The constant message is set by setConstantInfo() method and status
+ message is set by setMessage().
+
+ \param info constant info text
+ \sa constantInfo(), message(), setMessage()
+*/
+void QtxSplash::setConstantInfo( const QString& info )
+{
+ myInfo = info;
+ repaint();
+}
+
+/*!
+ \brief Get constant info text.
+ \return constant info text
+ \sa setConstantInfo(), message(), setMessage()
+*/
+QString QtxSplash::constantInfo() const
+{
+ return myInfo;
+}
+
/*!
\brief Get current status message.
\return status message
+ \sa setMessage(), constantInfo(), setConstantInfo()
*/
QString QtxSplash::message() const
{
\param msg status message
\param alignment message text alignment flags (Qt::Alignment)
\param color message text color
+ \sa message(), constantInfo(), setConstantInfo()
*/
-void QtxSplash::message( const QString& msg,
- int alignment,
- const QColor& color )
+void QtxSplash::setMessage( const QString& msg,
+ int alignment,
+ const QColor& color )
{
myMessage = msg;
myAlignment = alignment;
\overload
\brief Set status message for the splash screen.
\param msg status message
+ \sa message(), constantInfo(), setConstantInfo()
*/
-void QtxSplash::message( const QString& msg )
+void QtxSplash::setMessage( const QString& msg )
{
myMessage = msg;
repaint();
}
// draw status message
- if ( !myMessage.isEmpty() ) {
+ if ( !fullMessage().isEmpty() ) {
p->save();
drawMessage( p );
p->restore();
{
if ( ce->type() == ProgressEvent::id() ) {
ProgressEvent* pe = (ProgressEvent*)ce;
- pe->message().isEmpty() ? clear() : message( pe->message() );
+ pe->message().isEmpty() ? clear() : setMessage( pe->message() );
setProgress( pe->progress() );
QApplication::instance()->processEvents();
}
// ... take into account trailing '\n' symbols
int shift = 0;
- int i = myMessage.length() - 1;
- while( i >= 0 && myMessage[ i-- ] == '\n' )
+ QString msg = fullMessage();
+ int i = msg.length() - 1;
+ while( i >= 0 && msg[ i-- ] == '\n' )
shift += spacing;
r1.setHeight( r1.height() - shift );
if ( myAlignment & Qt::AlignRight ) r2.setRight ( r2.right() + 1 );
if ( myAlignment & Qt::AlignBottom ) r2.setBottom( r2.bottom() + 1 );
p->setPen( myShadowColor );
- p->drawText( r2, myAlignment, myMessage );
+ p->drawText( r2, myAlignment, msg );
}
// draw foreground status text
p->setPen( myColor );
- p->drawText( r1, myAlignment, myMessage );
+ p->drawText( r1, myAlignment, msg );
}
/*!
myError = code;
}
+/*!
+ \brief Get full message which includes constant info and status message.
+ \return get fill message text
+ \sa constantInfo(), setConstantInfo(), message(), setMessage()
+*/
+QString QtxSplash::fullMessage() const
+{
+ QStringList info;
+ if ( !myInfo.isEmpty() )
+ info << myInfo;
+ if ( !myMessage.isEmpty() )
+ info << myMessage;
+ return info.join( "\n" );
+}
void setTextColors( const QColor&, const QColor& = QColor() );
void textColors( QColor&, QColor& ) const;
+ void setConstantInfo( const QString& info );
+ QString constantInfo() const;
+
QString message() const;
int error() const;
void repaint();
public slots:
- void message( const QString&,
- const int,
- const QColor& = QColor() );
- void message( const QString& );
+ void setMessage( const QString&,
+ const int,
+ const QColor& = QColor() );
+ void setMessage( const QString& );
void clear();
protected:
private:
void drawContents();
void setError( const int );
+ QString fullMessage() const;
private:
static QtxSplash* mySplash;
QPixmap myPixmap; //!< splash pixmap
+ QString myInfo; //!< constant info
QString myMessage; //!< current status message
int myAlignment; //!< text alignment flags (Qt::Alignment)
QColor myColor; //!< text color