From 95a061f862f06a62dfe4178d45bc0bdfb320edcb Mon Sep 17 00:00:00 2001 From: vsr Date: Fri, 10 Aug 2007 12:27:15 +0000 Subject: [PATCH] *** empty log message *** --- src/CAF/CAF_Application.cxx | 4 +- src/CAF/CAF_Study.h | 2 +- src/CAM/CAM_Application.cxx | 8 +- src/Qtx/Qtx.cxx | 376 ++++++++++++++++++++++++++++++++++ src/Qtx/Qtx.h | 13 ++ src/Qtx/QtxActionMgr.h | 4 +- src/Qtx/QtxColorScale.cxx | 6 +- src/Qtx/QtxComboBox.cxx | 2 +- src/Qtx/QtxMRUAction.cxx | 4 +- src/Qtx/QtxPathDialog.h | 2 +- src/Qtx/QtxPathListEdit.cxx | 2 +- src/Qtx/QtxPreferenceMgr.h | 2 +- src/Qtx/QtxResourceMgr.cxx | 190 +++++++++++++---- src/Qtx/QtxResourceMgr.h | 210 ++++++++++--------- src/Qtx/QtxSplash.cxx | 159 +++++++++++++- src/Qtx/QtxSplash.h | 14 +- src/Qtx/QtxTable.cxx | 4 +- src/Qtx/QtxWorkstack.cxx | 102 ++++++--- src/Qtx/QtxWorkstack.h | 21 +- src/STD/STD_Application.cxx | 6 +- src/STD/STD_Application.h | 2 +- src/SUIT/SUIT_Application.cxx | 4 +- src/SUIT/SUIT_Operation.cxx | 2 +- src/SUIT/SUIT_Operation.h | 2 +- src/SUIT/SUIT_ResourceMgr.h | 2 +- src/SUIT/SUIT_SelectionMgr.h | 4 +- src/SUIT/SUIT_Study.h | 2 +- src/SUIT/SUIT_ViewWindow.cxx | 2 +- 28 files changed, 936 insertions(+), 215 deletions(-) diff --git a/src/CAF/CAF_Application.cxx b/src/CAF/CAF_Application.cxx index 8a5b2a359..e553490c0 100755 --- a/src/CAF/CAF_Application.cxx +++ b/src/CAF/CAF_Application.cxx @@ -105,7 +105,7 @@ Handle( TDocStd_Application ) CAF_Application::stdApp() const QString CAF_Application::getFileFilter() const { if ( stdApp().IsNull() ) - return QString::null; + return QString(); TColStd_SequenceOfExtendedString formats; stdApp()->Formats( formats ); @@ -135,7 +135,7 @@ QString CAF_Application::getFileFilter() const } if ( wildCards.isEmpty() ) - return QString::null; + return QString(); QStringList filters; for ( QMap::ConstIterator it = wildCards.begin(); it != wildCards.end(); ++it ) diff --git a/src/CAF/CAF_Study.h b/src/CAF/CAF_Study.h index ccde84d35..f56d7bd49 100755 --- a/src/CAF/CAF_Study.h +++ b/src/CAF/CAF_Study.h @@ -69,7 +69,7 @@ protected: virtual bool openTransaction(); virtual bool abortTransaction(); virtual bool hasTransaction() const; - virtual bool commitTransaction( const QString& = QString::null ); + virtual bool commitTransaction( const QString& = QString() ); virtual void setStdDoc( Handle(TDocStd_Document)& ); diff --git a/src/CAM/CAM_Application.cxx b/src/CAM/CAM_Application.cxx index 2089441d5..ce462811c 100755 --- a/src/CAM/CAM_Application.cxx +++ b/src/CAM/CAM_Application.cxx @@ -562,7 +562,7 @@ void CAM_Application::readModuleList() } } if ( modList.isEmpty() ) { - QString mods = resMgr->stringValue( "launch", "modules", QString::null ); + QString mods = resMgr->stringValue( "launch", "modules", QString() ); modList = mods.split( ",", QString::SkipEmptyParts ); } @@ -572,7 +572,7 @@ void CAM_Application::readModuleList() if ( modName.isEmpty() ) continue; - QString modTitle = resMgr->stringValue( *it, "name", QString::null ); + QString modTitle = resMgr->stringValue( *it, "name", QString() ); if ( modTitle.isEmpty() ) { printf( "****************************************************************\n" ); @@ -582,9 +582,9 @@ void CAM_Application::readModuleList() continue; } - QString modIcon = resMgr->stringValue( *it, "icon", QString::null ); + QString modIcon = resMgr->stringValue( *it, "icon", QString() ); - QString modLibrary = resMgr->stringValue( *it, "library", QString::null ).trimmed(); + QString modLibrary = resMgr->stringValue( *it, "library", QString() ).trimmed(); if ( !modLibrary.isEmpty() ) { modLibrary = SUIT_Tools::file( modLibrary.trimmed() ); diff --git a/src/Qtx/Qtx.cxx b/src/Qtx/Qtx.cxx index be51ce08a..a5b3ea2e2 100755 --- a/src/Qtx/Qtx.cxx +++ b/src/Qtx/Qtx.cxx @@ -33,6 +33,9 @@ #include #include #include +#include +#include +#include #include #include @@ -879,3 +882,376 @@ QPixmap Qtx::composite( const QPixmap& pix, const int x, const int y, const QPix return res; } + +/*! + \brief Convert color to the string representation. + + The resulting string is in the one of two possible formats + (\c RR, \c GG, \c BB and \c AA value represent red, green, blue + and alpha components of the color): + - if color has alpha channel : "#RR,#GG,#BB,#AA" + - if color does not have alpha channel : "#RRGGBB" + + If color is invalid, null string is returned. + + Backward conversion can be done with stringToColor() method. + + \param color color to be converted + \return string representation of the color + + \sa stringToColor() +*/ +QString Qtx::colorToString( const QColor& color ) +{ + QString str; + if ( color.isValid() ) + { + if ( color.alpha() != 255 ) + { + QStringList vals; + vals << QString( "#%1" ).arg( color.red(), 0, 16 ); + vals << QString( "#%1" ).arg( color.green(), 0, 16 ); + vals << QString( "#%1" ).arg( color.blue(), 0, 16 ); + vals << QString( "#%1" ).arg( color.alpha(), 0, 16 ); + str = vals.join( "," ); + } + else + { + str = color.name(); + } + } + return str; +} + +/*! + \brief Create color from the string representation. + + The parameter \a str must be in the one of following formats + (\c RR, \c GG, \c BB and \c AA value represent red, green, blue + and alpha components of the color): + - "#RR,#GG,#BB[,#AA]" or "#RR #GG #BB[ #AA]" (\c RR, \c GG, \c BB + and optional \c AA values represent red, green, blue and alpha + components of the color in hexadecimal form) + - "RR,GG,BB[,AA]" or "RR GG BB[ AA]" (\c RR, \c GG, \c BB + and optional \c AA values represent red, green, blue and alpha + components of the color in decimal form) + - #RRGGBB" - (\c RR, \c GG and \c BB values represent red, green and blue + components of the color in hexadecimal form) + - an integer value representing packed color components (see rgbSet()) + - a name from the list of colors defined in the list of SVG color keyword names + provided by the World Wide Web Consortium; for example, "steelblue" or "gainsboro". + + Backward conversion can be done with colorToString() method. + + \param str string representation of the color + \param color resulting color value + \return \c true if the conversion is successful and \c false otherwise + + \sa colorToString(), rgbSet() +*/ +bool Qtx::stringToColor( const QString& str, QColor& color ) +{ + bool res = true; + QStringList vals = str.split( QRegExp( "[\\s|,]" ), QString::SkipEmptyParts ); + + QIntList nums; + for ( QStringList::const_iterator it = vals.begin(); it != vals.end() && res; ++it ) + { + int num = 0; + if ( (*it).startsWith( "#" ) ) + num = (*it).mid( 1 ).toInt( &res, 16 ); + else + num = (*it).toInt( &res, 10 ); + if ( res ) + nums.append( num ); + } + + res = res && nums.count() >= 3; + if ( res ) + color.setRgb( nums[0], nums[1], nums[2] ); + + if ( !res ) + { + int pack = str.toInt( &res ); + if ( res ) + color = Qtx::rgbSet( pack ); + } + + if ( !res ) + { + color = QColor( str ); + res = color.isValid(); + } + + return res; +} + +/*! + \brief Dump linear gradient to the string description. + \param gradient linear gradient to be converted + \return string representation of the linear gradient + \sa stringToLinearGradient() +*/ +QString Qtx::gradientToString( const QLinearGradient& gradient ) +{ + QStringList data; + data << "linear"; + data << QString::number( gradient.start().x() ); + data << QString::number( gradient.start().y() ); + data << QString::number( gradient.finalStop().x() ); + data << QString::number( gradient.finalStop().y() ); + switch( gradient.spread() ) + { + case QGradient::PadSpread: + data << "pad"; + break; + case QGradient::RepeatSpread: + data << "repeat"; + break; + case QGradient::ReflectSpread: + data << "reflect"; + break; + default: + break; + } + QGradientStops stops = gradient.stops(); + QGradientStop stop; + foreach ( stop, stops ) + { + data << QString::number( stop.first ); + data << colorToString( stop.second ); + } + return data.join( "|" ); +} + +/*! + \brief Dump radial gradient to the string description. + \param gradient radial gradient to be converted + \return string representation of the radial gradient + \sa stringToRadialGradient() +*/ +QString Qtx::gradientToString( const QRadialGradient& gradient ) +{ + QStringList data; + data << "radial"; + data << QString::number( gradient.center().x() ); + data << QString::number( gradient.center().y() ); + data << QString::number( gradient.radius() ); + data << QString::number( gradient.focalPoint().x() ); + data << QString::number( gradient.focalPoint().y() ); + switch( gradient.spread() ) + { + case QGradient::PadSpread: + data << "pad"; + break; + case QGradient::RepeatSpread: + data << "repeat"; + break; + case QGradient::ReflectSpread: + data << "reflect"; + break; + default: + break; + } + QGradientStops stops = gradient.stops(); + QGradientStop stop; + foreach ( stop, stops ) + { + data << QString::number( stop.first ); + data << colorToString( stop.second ); + } + return data.join( "|" ); +} + +/*! + \brief Dump conical gradient to the string description. + \param gradient conical gradient to be converted + \return string representation of the conical gradient + \sa stringToConicalGradient() +*/ +QString Qtx::gradientToString( const QConicalGradient& gradient ) +{ + QStringList data; + data << "conical"; + data << QString::number( gradient.center().x() ); + data << QString::number( gradient.center().y() ); + data << QString::number( gradient.angle() ); + switch( gradient.spread() ) + { + case QGradient::PadSpread: + data << "pad"; + break; + case QGradient::RepeatSpread: + data << "repeat"; + break; + case QGradient::ReflectSpread: + data << "reflect"; + break; + default: + break; + } + QGradientStops stops = gradient.stops(); + QGradientStop stop; + foreach ( stop, stops ) + { + data << QString::number( stop.first ); + data << colorToString( stop.second ); + } + return data.join( "|" ); +} + +/*! + \brief Create linear gradient from its string representation. + \param str string representation of the linear gradient + \param gradient resulting linear gradient object + \return \c true if the conversion is successful and \c false otherwise + \sa gradientToString() +*/ +bool Qtx::stringToLinearGradient( const QString& str, QLinearGradient& gradient ) +{ + bool success = false; + QStringList vals = str.split( "|", QString::SkipEmptyParts ); + if ( vals.count() > 4 && ( vals[0] == "linear" || vals[0] == "lg" ) ) + { + // start and end points + double x1, y1, x2, y2; + bool bOk1, bOk2, bOk3, bOk4; + x1 = vals[1].toDouble( &bOk1 ); + y1 = vals[2].toDouble( &bOk2 ); + x2 = vals[3].toDouble( &bOk3 ); + y2 = vals[4].toDouble( &bOk4 ); + if ( bOk1 && bOk2 && bOk3 && bOk4 ) + { + gradient = QLinearGradient( x1, y1, x2, y2 ); + // spread type + if ( vals.count() > 5 ) + { + if ( vals[ 5 ] == "pad" || vals[ 5 ] == "0" ) + gradient.setSpread( QGradient::PadSpread ); + else if ( vals[ 5 ] == "repeat" || vals[ 5 ] == "2" ) + gradient.setSpread( QGradient::RepeatSpread ); + else if ( vals[ 5 ] == "reflect" || vals[ 5 ] == "1" ) + gradient.setSpread( QGradient::ReflectSpread ); + } + // stop points + QGradientStops stops; + for ( int i = 6; i < vals.count(); i+=2 ) + { + bool bOk5, bOk6 = false; + QColor c; + double stop = vals[i].toDouble( &bOk5 ); + if ( i+1 < vals.count() ) + bOk6 = stringToColor( vals[ i+1 ], c ); + if ( bOk5 && stop >= 0.0 && stop <= 1.0 && bOk6 && c.isValid() ) + stops.append( QGradientStop( stop, c ) ); + } + gradient.setStops( stops ); + success = true; + } + } + return success; +} + +/*! + \brief Create radial gradient from its string representation. + \param str string representation of the radial gradient + \param gradient resulting radial gradient object + \return \c true if the conversion is successful and \c false otherwise + \sa gradientToString() +*/ +bool Qtx::stringToRadialGradient( const QString& str, QRadialGradient& gradient ) +{ + bool success = false; + QStringList vals = str.split( "|", QString::SkipEmptyParts ); + if ( vals.count() > 5 && vals[0] == "radial" || vals[0] == "rg" ) + { + // center, radius and focal point + double cx, cy, r, fx, fy; + bool bOk1, bOk2, bOk3, bOk4, bOk5; + cx = vals[1].toDouble( &bOk1 ); + cy = vals[2].toDouble( &bOk2 ); + r = vals[3].toDouble( &bOk3 ); + fx = vals[4].toDouble( &bOk4 ); + fy = vals[5].toDouble( &bOk5 ); + if ( bOk1 && bOk2 && bOk3 && bOk4 && bOk5 ) + { + gradient = QRadialGradient( cx, cy, r, fx, fy ); + // spread type + if ( vals.count() > 6 ) + { + if ( vals[ 6 ] == "pad" || vals[ 6 ] == "0" ) + gradient.setSpread( QGradient::PadSpread ); + else if ( vals[ 6 ] == "repeat" || vals[ 6 ] == "2" ) + gradient.setSpread( QGradient::RepeatSpread ); + else if ( vals[ 6 ] == "reflect" || vals[ 6 ] == "1" ) + gradient.setSpread( QGradient::ReflectSpread ); + } + // stop points + QGradientStops stops; + for ( int i = 7; i < vals.count(); i+=2 ) + { + bool bOk7, bOk8 = false; + QColor c; + double stop = vals[i].toDouble( &bOk7 ); + if ( i+1 < vals.count() ) + bOk8 = stringToColor( vals[ i+1 ], c ); + if ( bOk7 && stop >= 0.0 && stop <= 1.0 && bOk8 && c.isValid() ) + stops.append( QGradientStop( stop, c ) ); + } + gradient.setStops( stops ); + success = true; + } + } + return success; +} + +/*! + \brief Create conical gradient from its string representation. + \param str string representation of the conical gradient + \param gradient resulting conical gradient object + \return \c true if the conversion is successful and \c false otherwise + \sa gradientToString() +*/ +bool Qtx::stringToConicalGradient( const QString& str, QConicalGradient& gradient ) +{ + bool success = false; + QStringList vals = str.split( "|", QString::SkipEmptyParts ); + if ( vals.count() > 3 && vals[0] == "conical" || vals[0] == "cg" ) + { + // center and angle + double cx, cy, a; + bool bOk1, bOk2, bOk3; + cx = vals[1].toDouble( &bOk1 ); + cy = vals[2].toDouble( &bOk2 ); + a = vals[3].toDouble( &bOk3 ); + if ( bOk1 && bOk2 && bOk3 ) + { + gradient = QConicalGradient( cx, cy, a ); + // spread type + if ( vals.count() > 4 ) + { + if ( vals[ 4 ] == "pad" || vals[ 4 ] == "0" ) + gradient.setSpread( QGradient::PadSpread ); + else if ( vals[ 4 ] == "repeat" || vals[ 4 ] == "2" ) + gradient.setSpread( QGradient::RepeatSpread ); + else if ( vals[ 4 ] == "reflect" || vals[ 4 ] == "1" ) + gradient.setSpread( QGradient::ReflectSpread ); + } + // stop points + QGradientStops stops; + for ( int i = 5; i < vals.count(); i+=2 ) + { + bool bOk4, bOk5 = false; + QColor c; + double stop = vals[i].toDouble( &bOk4 ); + if ( i+1 < vals.count() ) + bOk5 = stringToColor( vals[ i+1 ], c ); + if ( bOk4 && stop >= 0.0 && stop <= 1.0 && bOk5 && c.isValid() ) + stops.append( QGradientStop( stop, c ) ); + } + gradient.setStops( stops ); + success = true; + } + } + return success; +} diff --git a/src/Qtx/Qtx.h b/src/Qtx/Qtx.h index 90a79b30e..e13edd281 100755 --- a/src/Qtx/Qtx.h +++ b/src/Qtx/Qtx.h @@ -47,6 +47,9 @@ class QObject; class QWidget; class QCompleter; +class QLinearGradient; +class QRadialGradient; +class QConicalGradient; typedef QList QIntList; //!< list of int values typedef QList QShortList; //!< list of short int values @@ -135,6 +138,16 @@ public: static QImage transparentImage( const int, const int, const int = -1 ); static QPixmap transparentPixmap( const int, const int, const int = -1 ); static QPixmap composite( const QPixmap&, const int, const int, const QPixmap& = QPixmap() ); + + static QString colorToString( const QColor& ); + static bool stringToColor( const QString&, QColor& ); + + static QString gradientToString( const QLinearGradient& ); + static QString gradientToString( const QRadialGradient& ); + static QString gradientToString( const QConicalGradient& ); + static bool stringToLinearGradient( const QString&, QLinearGradient& ); + static bool stringToRadialGradient( const QString&, QRadialGradient& ); + static bool stringToConicalGradient( const QString&, QConicalGradient& ); }; #endif diff --git a/src/Qtx/QtxActionMgr.h b/src/Qtx/QtxActionMgr.h index 98d99e3c6..d7c4d6a6d 100644 --- a/src/Qtx/QtxActionMgr.h +++ b/src/Qtx/QtxActionMgr.h @@ -118,7 +118,7 @@ public: protected: static int intValue( const ItemAttributes&, const QString&, const int ); static QString strValue( const ItemAttributes&, const QString&, - const QString& = QString::null ); + const QString& = QString() ); private: QtxActionMgr::Reader* myReader; //!< actions reader }; @@ -130,7 +130,7 @@ public: virtual ~Reader(); QStringList options() const; - QString option( const QString&, const QString& = QString::null ) const; + QString option( const QString&, const QString& = QString() ) const; void setOption( const QString&, const QString& ); virtual bool read( const QString&, Creator& ) const = 0; diff --git a/src/Qtx/QtxColorScale.cxx b/src/Qtx/QtxColorScale.cxx index 97b61a2b3..b7dbf558a 100755 --- a/src/Qtx/QtxColorScale.cxx +++ b/src/Qtx/QtxColorScale.cxx @@ -269,7 +269,7 @@ void QtxColorScale::setRange( const double min, const double max ) myMin = min; myMax = max; - myPrecise = QString::null; + myPrecise = QString(); if ( colorMode() == Auto || labelMode() == Auto ) updateScale(); @@ -299,7 +299,7 @@ void QtxColorScale::setFormat( const QString& format ) return; myFormat = format; - myPrecise = QString::null; + myPrecise = QString(); if ( colorMode() == Auto ) updateScale(); } @@ -314,7 +314,7 @@ void QtxColorScale::setIntervalsNumber( const int num ) return; myInterval = num; - myPrecise = QString::null; + myPrecise = QString(); updateScale(); } diff --git a/src/Qtx/QtxComboBox.cxx b/src/Qtx/QtxComboBox.cxx index eaffefbdf..817138c96 100755 --- a/src/Qtx/QtxComboBox.cxx +++ b/src/Qtx/QtxComboBox.cxx @@ -187,7 +187,7 @@ void QtxComboBox::paintClear( QPaintEvent* e ) setUpdatesEnabled( false ); setItemIcon( curIndex, QIcon() ); - setItemText( curIndex, QString::null ); + setItemText( curIndex, QString() ); QComboBox::paintEvent( e ); diff --git a/src/Qtx/QtxMRUAction.cxx b/src/Qtx/QtxMRUAction.cxx index 6f1b81844..c78b0c6de 100755 --- a/src/Qtx/QtxMRUAction.cxx +++ b/src/Qtx/QtxMRUAction.cxx @@ -261,7 +261,7 @@ void QtxMRUAction::loadLinks( QtxResourceMgr* resMgr, const QString& section, co if ( !(*it).startsWith( itemPrefix ) ) continue; - QString link = resMgr->stringValue( section, *it, QString::null ); + QString link = resMgr->stringValue( section, *it, QString() ); if ( link.isEmpty() || map.contains( link ) ) continue; @@ -299,7 +299,7 @@ void QtxMRUAction::saveLinks( QtxResourceMgr* resMgr, const QString& section, co if ( !(*it).startsWith( itemPrefix ) ) continue; - QString link = resMgr->stringValue( section, *it, QString::null ); + QString link = resMgr->stringValue( section, *it, QString() ); if ( !link.isEmpty() && !map.contains( link ) ) { lst.append( link ); diff --git a/src/Qtx/QtxPathDialog.h b/src/Qtx/QtxPathDialog.h index 57b887756..29dbac051 100755 --- a/src/Qtx/QtxPathDialog.h +++ b/src/Qtx/QtxPathDialog.h @@ -94,7 +94,7 @@ private: QStringList prepareFilters( const QString& ) const; bool hasVisibleChildren( QWidget* ) const; QStringList filterWildCards( const QString& ) const; - QString autoExtension( const QString&, const QString& = QString::null ) const; + QString autoExtension( const QString&, const QString& = QString() ) const; protected: enum { OpenFile, SaveFile, OpenDir, SaveDir, NewDir }; diff --git a/src/Qtx/QtxPathListEdit.cxx b/src/Qtx/QtxPathListEdit.cxx index dee61a389..0c3adfede 100644 --- a/src/Qtx/QtxPathListEdit.cxx +++ b/src/Qtx/QtxPathListEdit.cxx @@ -516,7 +516,7 @@ bool QtxPathListEdit::validate( const bool quietMode ) if ( !quietMode && QMessageBox::information(this, tr("Warning"), tr("%1\n\nThe directory doesn't exist.\nAdd directory anyway?").arg(dir.absPath()), - tr("Yes"), tr("No"), QString::null, 1, 1) == 1) { + tr("Yes"), tr("No"), QString(), 1, 1) == 1) { myEdit->setFocus(); return false; } diff --git a/src/Qtx/QtxPreferenceMgr.h b/src/Qtx/QtxPreferenceMgr.h index 50fc32416..cc3b2d913 100644 --- a/src/Qtx/QtxPreferenceMgr.h +++ b/src/Qtx/QtxPreferenceMgr.h @@ -94,7 +94,7 @@ protected: bool getBoolean( const bool = false ) const; QColor getColor( const QColor& = QColor() ) const; QFont getFont( const QFont& = QFont() ) const; - QString getString( const QString& = QString::null ) const; + QString getString( const QString& = QString() ) const; void setInteger( const int ); void setDouble( const double ); diff --git a/src/Qtx/QtxResourceMgr.cxx b/src/Qtx/QtxResourceMgr.cxx index 2741e8352..45f5a2609 100644 --- a/src/Qtx/QtxResourceMgr.cxx +++ b/src/Qtx/QtxResourceMgr.cxx @@ -269,7 +269,7 @@ QString QtxResourceMgr::Resources::path( const QString& sec, const QString& pref if ( !filePath.isEmpty() ) { if ( !QFileInfo( filePath ).exists() ) - filePath = QString::null; + filePath = QString(); } return filePath; } @@ -451,7 +451,7 @@ QTranslator* QtxResourceMgr::Resources::loadTranslator( const QString& sect, con */ QString QtxResourceMgr::Resources::environmentVariable( const QString& str, int& start, int& len ) const { - QString varName = QString::null; + QString varName; len = 0; QRegExp rx( "(^\\$\\{|[^\\$]\\$\\{)([a-zA-Z]+[a-zA-Z0-9_]*)(\\})|(^\\$\\(|[^\\$]\\$\\()([a-zA-Z]+[a-zA-Z0-9_]*)(\\))|(^\\$|[^\\$]\\$)([a-zA-Z]+[a-zA-Z0-9_]*)|(^%|[^%]%)([a-zA-Z]+[a-zA-Z0-9_]*)(%[^%]|%$)" ); @@ -1383,39 +1383,7 @@ bool QtxResourceMgr::value( const QString& sect, const QString& name, QColor& cV if ( !value( sect, name, val, true ) ) return false; - bool res = true; - QStringList vals = val.split( QRegExp( "[\\s|,]" ), QString::SkipEmptyParts ); - - QIntList nums; - for ( QStringList::const_iterator it = vals.begin(); it != vals.end() && res; ++it ) - { - int num = 0; - if ( (*it).startsWith( "#" ) ) - num = (*it).mid( 1 ).toInt( &res, 16 ); - else - num = (*it).toInt( &res, 10 ); - if ( res ) - nums.append( num ); - } - - res = res && nums.count() >= 3; - if ( res ) - cVal.setRgb( nums[0], nums[1], nums[2] ); - - if ( !res ) - { - int pack = val.toInt( &res ); - if ( res ) - cVal = Qtx::rgbSet( pack ); - } - - if ( !res ) - { - cVal = QColor( val ); - res = cVal.isValid(); - } - - return res; + return Qtx::stringToColor( val, cVal ); } /*! @@ -1499,6 +1467,57 @@ bool QtxResourceMgr::value( const QString& sect, const QString& name, QByteArray return !baVal.isEmpty(); } +/*! + \brief Get linear gradient parameter value. + \param sect section name + \param name parameter name + \param gVal parameter to return resulting linear gradient value value + \return \c true if parameter is found and \c false if parameter is not found + (in this case \a gVal value is undefined) +*/ +bool QtxResourceMgr::value( const QString& sect, const QString& name, QLinearGradient& gVal ) const +{ + QString val; + if ( !value( sect, name, val, true ) ) + return false; + + return Qtx::stringToLinearGradient( val, gVal ); +} + +/*! + \brief Get radial gradient parameter value. + \param sect section name + \param name parameter name + \param gVal parameter to return resulting radial gradient value value + \return \c true if parameter is found and \c false if parameter is not found + (in this case \a gVal value is undefined) +*/ +bool QtxResourceMgr::value( const QString& sect, const QString& name, QRadialGradient& gVal ) const +{ + QString val; + if ( !value( sect, name, val, true ) ) + return false; + + return Qtx::stringToRadialGradient( val, gVal ); +} + +/*! + \brief Get conical gradient parameter value. + \param sect section name + \param name parameter name + \param gVal parameter to return resulting conical gradient value value + \return \c true if parameter is found and \c false if parameter is not found + (in this case \a gVal value is undefined) +*/ +bool QtxResourceMgr::value( const QString& sect, const QString& name, QConicalGradient& gVal ) const +{ + QString val; + if ( !value( sect, name, val, true ) ) + return false; + + return Qtx::stringToConicalGradient( val, gVal ); +} + /*! \brief Get string parameter value (native format). \param sect section name @@ -1659,6 +1678,60 @@ QByteArray QtxResourceMgr::byteArrayValue( const QString& sect, const QString& n return val; } +/*! + \brief Get linear gradient parameter value. + + If the specified parameter is not found, the specified default value is returned instead. + + \param sect section name + \param name parameter name + \param def default value + \return parameter value (or default value if parameter is not found) +*/ +QLinearGradient QtxResourceMgr::linearGradientValue( const QString& sect, const QString& name, const QLinearGradient& def ) const +{ + QLinearGradient val; + if ( !value( sect, name, val ) ) + val = def; + return val; +} + +/*! + \brief Get radial gradient parameter value. + + If the specified parameter is not found, the specified default value is returned instead. + + \param sect section name + \param name parameter name + \param def default value + \return parameter value (or default value if parameter is not found) +*/ +QRadialGradient QtxResourceMgr::radialGradientValue( const QString& sect, const QString& name, const QRadialGradient& def ) const +{ + QRadialGradient val; + if ( !value( sect, name, val ) ) + val = def; + return val; +} + +/*! + \brief Get conical gradient parameter value. + + If the specified parameter is not found, the specified default value is returned instead. + + \param sect section name + \param name parameter name + \param def default value + \return parameter value (or default value if parameter is not found) +*/ +QConicalGradient QtxResourceMgr::conicalGradientValue( const QString& sect, const QString& name, const QConicalGradient& def ) const +{ + QConicalGradient val; + if ( !value( sect, name, val ) ) + val = def; + return val; +} + /*! \brief Check parameter existence. \param sect section name @@ -1749,7 +1822,7 @@ void QtxResourceMgr::setValue( const QString& sect, const QString& name, const Q if ( checkExisting() && value( sect, name, res ) && res == val ) return; - setResource( sect, name, val.isValid() ? val.name() : QString() ); + setResource( sect, name, Qtx::colorToString( val ) ); } /*! @@ -1814,6 +1887,51 @@ void QtxResourceMgr::setValue( const QString& sect, const QString& name, const Q setResource( sect, name, lst.join( " " ) ); } +/*! + \brief Set linear gradient parameter value. + \param sect section name + \param name parameter name + \param val parameter value +*/ +void QtxResourceMgr::setValue( const QString& sect, const QString& name, const QLinearGradient& val ) +{ + QLinearGradient res; + if ( checkExisting() && value( sect, name, res ) && res == val ) + return; + + setResource( sect, name, Qtx::gradientToString( val ) ); +} + +/*! + \brief Set radial gradient parameter value. + \param sect section name + \param name parameter name + \param val parameter value +*/ +void QtxResourceMgr::setValue( const QString& sect, const QString& name, const QRadialGradient& val ) +{ + QRadialGradient res; + if ( checkExisting() && value( sect, name, res ) && res == val ) + return; + + setResource( sect, name, Qtx::gradientToString( val ) ); +} + +/*! + \brief Set conical gradient parameter value. + \param sect section name + \param name parameter name + \param val parameter value +*/ +void QtxResourceMgr::setValue( const QString& sect, const QString& name, const QConicalGradient& val ) +{ + QConicalGradient res; + if ( checkExisting() && value( sect, name, res ) && res == val ) + return; + + setResource( sect, name, Qtx::gradientToString( val ) ); +} + /*! \brief Remove resources section. \param sect section name diff --git a/src/Qtx/QtxResourceMgr.h b/src/Qtx/QtxResourceMgr.h index b70caa2c5..9e5ba1716 100644 --- a/src/Qtx/QtxResourceMgr.h +++ b/src/Qtx/QtxResourceMgr.h @@ -35,6 +35,9 @@ #include #include #include +#include +#include +#include class QTranslator; @@ -58,101 +61,110 @@ public: #endif public: - QtxResourceMgr( const QString&, const QString& = QString::null ); + QtxResourceMgr( const QString&, const QString& = QString() ); virtual ~QtxResourceMgr(); - QString appName() const; - QStringList dirList() const; - - bool checkExisting() const; - virtual void setCheckExisting( const bool ); - - bool isPixmapCached() const; - void setIsPixmapCached( const bool ); - - void clear(); - - void setIgnoreUserValues( const bool = true ); - bool ignoreUserValues() const; - - bool value( const QString&, const QString&, int& ) const; - bool value( const QString&, const QString&, double& ) const; - bool value( const QString&, const QString&, bool& ) const; - bool value( const QString&, const QString&, QColor& ) const; - bool value( const QString&, const QString&, QFont& ) const; - bool value( const QString&, const QString&, QByteArray& ) const; - bool value( const QString&, const QString&, QString&, const bool = true ) const; - - int integerValue( const QString&, const QString&, const int = 0 ) const; - double doubleValue( const QString&, const QString&, const double = 0 ) const; - bool booleanValue( const QString&, const QString&, const bool = false ) const; - QFont fontValue( const QString&, const QString&, const QFont& = QFont() ) const; - QColor colorValue( const QString&, const QString&, const QColor& = QColor() ) const; - QString stringValue( const QString&, const QString&, const QString& = QString::null ) const; - QByteArray byteArrayValue( const QString&, const QString&, const QByteArray& = QByteArray() ) const; - - bool hasSection( const QString& ) const; - bool hasValue( const QString&, const QString& ) const; - - void setValue( const QString&, const QString&, const int ); - void setValue( const QString&, const QString&, const double ); - void setValue( const QString&, const QString&, const bool ); - void setValue( const QString&, const QString&, const QFont& ); - void setValue( const QString&, const QString&, const QColor& ); - void setValue( const QString&, const QString&, const QString& ); - void setValue( const QString&, const QString&, const QByteArray& ); - - void remove( const QString& ); - void remove( const QString&, const QString& ); - - QString currentFormat() const; - void setCurrentFormat( const QString& ); - - Format* format( const QString& ) const; - void installFormat( Format* ); - void removeFormat( Format* ); - - QStringList options() const; - QString option( const QString& ) const; - void setOption( const QString&, const QString& ); - - QPixmap defaultPixmap() const; - virtual void setDefaultPixmap( const QPixmap& ); - - QString resSection() const; - QString langSection() const; - - QPixmap loadPixmap( const QString&, const QString& ) const; - QPixmap loadPixmap( const QString&, const QString&, const bool ) const; - QPixmap loadPixmap( const QString&, const QString&, const QPixmap& ) const; - void loadLanguage( const QString& = QString::null, const QString& = QString::null ); - - void raiseTranslators( const QString& ); - void removeTranslators( const QString& ); - void loadTranslator( const QString&, const QString& ); - void loadTranslators( const QString&, const QStringList& ); - - QString path( const QString&, const QString&, const QString& ) const; - - bool load(); - bool import( const QString& ); - bool save(); - - QStringList sections() const; - QStringList parameters( const QString& ) const; - - void refresh(); + QString appName() const; + QStringList dirList() const; + + bool checkExisting() const; + virtual void setCheckExisting( const bool ); + + bool isPixmapCached() const; + void setIsPixmapCached( const bool ); + + void clear(); + + void setIgnoreUserValues( const bool = true ); + bool ignoreUserValues() const; + + bool value( const QString&, const QString&, int& ) const; + bool value( const QString&, const QString&, double& ) const; + bool value( const QString&, const QString&, bool& ) const; + bool value( const QString&, const QString&, QColor& ) const; + bool value( const QString&, const QString&, QFont& ) const; + bool value( const QString&, const QString&, QByteArray& ) const; + bool value( const QString&, const QString&, QLinearGradient& ) const; + bool value( const QString&, const QString&, QRadialGradient& ) const; + bool value( const QString&, const QString&, QConicalGradient& ) const; + bool value( const QString&, const QString&, QString&, const bool = true ) const; + + int integerValue( const QString&, const QString&, const int = 0 ) const; + double doubleValue( const QString&, const QString&, const double = 0 ) const; + bool booleanValue( const QString&, const QString&, const bool = false ) const; + QFont fontValue( const QString&, const QString&, const QFont& = QFont() ) const; + QColor colorValue( const QString&, const QString&, const QColor& = QColor() ) const; + QString stringValue( const QString&, const QString&, const QString& = QString() ) const; + QByteArray byteArrayValue( const QString&, const QString&, const QByteArray& = QByteArray() ) const; + QLinearGradient linearGradientValue( const QString&, const QString&, const QLinearGradient& = QLinearGradient() ) const; + QRadialGradient radialGradientValue( const QString&, const QString&, const QRadialGradient& = QRadialGradient() ) const; + QConicalGradient conicalGradientValue( const QString&, const QString&, const QConicalGradient& = QConicalGradient() ) const; + + bool hasSection( const QString& ) const; + bool hasValue( const QString&, const QString& ) const; + + void setValue( const QString&, const QString&, const int ); + void setValue( const QString&, const QString&, const double ); + void setValue( const QString&, const QString&, const bool ); + void setValue( const QString&, const QString&, const QFont& ); + void setValue( const QString&, const QString&, const QColor& ); + void setValue( const QString&, const QString&, const QString& ); + void setValue( const QString&, const QString&, const QByteArray& ); + void setValue( const QString&, const QString&, const QLinearGradient& ); + void setValue( const QString&, const QString&, const QRadialGradient& ); + void setValue( const QString&, const QString&, const QConicalGradient& ); + + void remove( const QString& ); + void remove( const QString&, const QString& ); + + QString currentFormat() const; + void setCurrentFormat( const QString& ); + + Format* format( const QString& ) const; + void installFormat( Format* ); + void removeFormat( Format* ); + + QStringList options() const; + QString option( const QString& ) const; + void setOption( const QString&, const QString& ); + + QPixmap defaultPixmap() const; + virtual void setDefaultPixmap( const QPixmap& ); + + QString resSection() const; + QString langSection() const; + + QPixmap loadPixmap( const QString&, const QString& ) const; + QPixmap loadPixmap( const QString&, const QString&, const bool ) const; + QPixmap loadPixmap( const QString&, const QString&, const QPixmap& ) const; + void loadLanguage( const QString& = QString(), const QString& = QString() ); + + void raiseTranslators( const QString& ); + void removeTranslators( const QString& ); + void loadTranslator( const QString&, const QString& ); + void loadTranslators( const QString&, const QStringList& ); + + QString path( const QString&, const QString&, const QString& ) const; + + bool load(); + bool import( const QString& ); + bool save(); + + QStringList sections() const; + QStringList parameters( const QString& ) const; + + void refresh(); protected: - virtual void setDirList( const QStringList& ); - virtual void setResource( const QString&, const QString&, const QString& ); + virtual void setDirList( const QStringList& ); + virtual void setResource( const QString&, const QString&, const QString& ); - virtual QString userFileName( const QString&, const bool = true ) const; - virtual QString globalFileName( const QString& ) const; + virtual QString userFileName( const QString&, const bool = true ) const; + virtual QString globalFileName( const QString& ) const; private: - void initialize( const bool = true ) const; - QString substMacro( const QString&, const QMap& ) const; + void initialize( const bool = true ) const; + QString substMacro( const QString&, const QMap& ) const; private: typedef QList ResList; @@ -162,17 +174,17 @@ private: typedef QMap TransListMap; private: - QString myAppName; //!< application name - QStringList myDirList; //!< list of resources directories - FormatList myFormats; //!< list of formats - OptionsMap myOptions; //!< options map - ResList myResources; //!< resources list - bool myCheckExist; //!< "check existance" flag - TransListMap myTranslator; //!< map of loaded translators - QPixmap* myDefaultPix; //!< default icon - bool myIsPixmapCached; //!< "cached pixmaps" flag - - bool myIsIgnoreUserValues; //!< "ignore user values" flag + QString myAppName; //!< application name + QStringList myDirList; //!< list of resources directories + FormatList myFormats; //!< list of formats + OptionsMap myOptions; //!< options map + ResList myResources; //!< resources list + bool myCheckExist; //!< "check existance" flag + TransListMap myTranslator; //!< map of loaded translators + QPixmap* myDefaultPix; //!< default icon + bool myIsPixmapCached; //!< "cached pixmaps" flag + + bool myIsIgnoreUserValues; //!< "ignore user values" flag friend class QtxResourceMgr::Format; }; diff --git a/src/Qtx/QtxSplash.cxx b/src/Qtx/QtxSplash.cxx index c954e9b0c..db4d6afa1 100644 --- a/src/Qtx/QtxSplash.cxx +++ b/src/Qtx/QtxSplash.cxx @@ -21,6 +21,7 @@ // #include "QtxSplash.h" +#include "QtxResourceMgr.h" #include #include @@ -651,6 +652,42 @@ QString QtxSplash::constantInfo() const return myInfo; } +/*! + \brief Set constant information option value. + + The option is a part of the constant information text, + which is replaced at the time of the displaying. + + The following options are supported: + - %A - could be used as application name + - %V - could be used as application version + - %L - could be used as application license information + - %C - could be used as application copyright information + + \param name option name + \param option value + \sa option() +*/ +void QtxSplash::setOption( const QString& name, const QString& value ) +{ + myOptions[ name ] = value; + repaint(); +} + +/*! + \brief Get constant information option value. + \param name option name + \return option value or empty string if option is not set + \sa setOption() +*/ +QString QtxSplash::option( const QString& name ) const +{ + QString val; + if ( myOptions.contains( name ) ) + val = myOptions[ name ]; + return val; +} + /*! \brief Get current status message. \return status message @@ -705,6 +742,115 @@ void QtxSplash::repaint() QApplication::flush(); } +/*! + \brief Read splash settings from the resources manager. + \param resMgr resources manager + \param section resources file section name (if empty, the default name is used). +*/ +void QtxSplash::readSettings( QtxResourceMgr* resMgr, const QString& section ) +{ + QString resSection = section.isEmpty() ? "splash" : section; + + // pixmap + QString pxname; + if ( resMgr->value( resSection, "image", pxname ) ) { + QPixmap px( pxname ); + if ( !px.isNull() ) + setPixmap( px ); + } + + // hide-on-click +#ifdef _DEBUG_ + setHideOnClick( true ); +#else + bool bHide; + if ( resMgr->value( resSection, "hide_on_click", bHide ) ) { + setHideOnClick( bHide ); + } +#endif + + // margin + int m; + if ( resMgr->value( resSection, "margin", m ) ) { + setMargin( m ); + } + + // progress bar width + int pw; + if ( resMgr->value( resSection, "progress_width", pw ) ) { + setProgressWidth( pw ); + } + + // progress bar position and direction + int pf; + if ( resMgr->value( resSection, "progress_flags", pf ) ) { + setProgressFlags( pf ); + } + + // opacity + double op; + if ( resMgr->value( resSection, "opacity", op ) ) { + setOpacity( op ); + } + + // font + QFont f; + if ( resMgr->value( resSection, "font", f ) ) { + setFont( f ); + } + + // text alignment + int al; + if ( resMgr->value( resSection, "alignment", al ) ) { + setTextAlignment( al ); + } + + // progress color(s) + QString pc; + QLinearGradient grad; + if ( resMgr->value( resSection, "progress_gradient", grad ) ) { + // gradient-colored progress bar + setProgressGradient( grad ); + } + else if ( resMgr->value( resSection, "progress_color", pc ) || + resMgr->value( resSection, "progress_colors", pc ) ) { + // one/two-colored progress bar + QStringList colors = pc.split( "|", QString::SkipEmptyParts ); + QColor c1, c2; + QtxSplash::GradientType gradType = QtxSplash::Vertical; + if ( colors.count() > 0 ) c1 = QColor( colors[0] ); + if ( colors.count() > 1 ) c2 = QColor( colors[1] ); + int gt; + bool bOk; + if ( colors.count() > 2 ) { + gt = colors[2].toInt( &bOk ); + if ( bOk && gt >= QtxSplash::Horizontal && gt <= QtxSplash::Vertical ) + gradType = (QtxSplash::GradientType)gt; + } + setProgressColors( c1, c2, gradType ); + } + + // text color(s) + QString tc; + if ( resMgr->value( resSection, "text_color", tc ) || + resMgr->value( resSection, "text_colors", tc ) ) { + QStringList colors = tc.split( "|", QString::SkipEmptyParts ); + QColor c1, c2; + if ( colors.count() > 0 ) + c1 = QColor( colors[0] ); + if ( colors.count() > 1 ) + c2 = QColor( colors[1] ); + setTextColors( c1, c2 ); + } + + // const info + QString cinfo; + if ( resMgr->value( resSection, "constant_info", cinfo, false ) || + resMgr->value( resSection, "info", cinfo, false ) ) { + setConstantInfo( cinfo.split( "|", QString::KeepEmptyParts ).join( "\n" ) ); + } +} + /*! \brief Set status message for the splash screen and define its color and aligment flags. @@ -742,7 +888,7 @@ void QtxSplash::setMessage( const QString& msg ) */ void QtxSplash::clear() { - myMessage = QString::null; + myMessage.clear(); repaint(); } @@ -971,8 +1117,15 @@ void QtxSplash::setError( const int code ) QString QtxSplash::fullMessage() const { QStringList info; - if ( !myInfo.isEmpty() ) - info << myInfo; + + QString cinfo = myInfo; + cinfo = cinfo.replace( QRegExp( "%A" ), option( "%A" ) ); + cinfo = cinfo.replace( QRegExp( "%V" ), option( "%V" ) ); + cinfo = cinfo.replace( QRegExp( "%L" ), option( "%L" ) ); + cinfo = cinfo.replace( QRegExp( "%C" ), option( "%C" ) ); + + if ( !cinfo.isEmpty() ) + info << cinfo; if ( !myMessage.isEmpty() ) info << myMessage; return info.join( "\n" ); diff --git a/src/Qtx/QtxSplash.h b/src/Qtx/QtxSplash.h index 280851166..1d92e70fb 100644 --- a/src/Qtx/QtxSplash.h +++ b/src/Qtx/QtxSplash.h @@ -28,11 +28,14 @@ #include #include #include +#include #ifdef WIN32 #pragma warning( disable:4251 ) #endif +class QtxResourceMgr; + class QTX_EXPORT QtxSplash : public QWidget { Q_OBJECT @@ -62,7 +65,7 @@ public: static QtxSplash* splash( const QPixmap& = QPixmap() ); static void setStatus( const QString&, const int = -1 ); - static void setError( const QString&, const QString& = QString::null, const int = -1 ); + static void setError( const QString&, const QString& = QString(), const int = -1 ); void setPixmap( const QPixmap& ); QPixmap pixmap() const; @@ -108,6 +111,9 @@ public: void setConstantInfo( const QString& info ); QString constantInfo() const; + void setOption( const QString&, const QString& ); + QString option( const QString& ) const; + QString message() const; int error() const; @@ -115,6 +121,8 @@ public: void finish( QWidget* ); void repaint(); + void readSettings( QtxResourceMgr*, const QString& = QString() ); + public slots: void setMessage( const QString&, const int, @@ -137,6 +145,9 @@ private: void setError( const int ); QString fullMessage() const; +private: + typedef QMap OptMap; + private: static QtxSplash* mySplash; @@ -159,6 +170,7 @@ private: double myOpacity; //!< progress bar / status message opacity int myError; //!< error code bool myGradientUsed; //!< 'use custom gradient color scale' flag + OptMap myOptions; //!< constant info options }; #endif diff --git a/src/Qtx/QtxTable.cxx b/src/Qtx/QtxTable.cxx index 1f7c0be55..1add70775 100644 --- a/src/Qtx/QtxTable.cxx +++ b/src/Qtx/QtxTable.cxx @@ -260,12 +260,12 @@ void QtxTable::endHeaderEdit( const bool accept ) if ( !isHeaderEditing() ) return; - QString oldTxt = myEditedHeader ? myEditedHeader->label( myEditedSection ) : QString::null; + QString oldTxt = myEditedHeader ? myEditedHeader->label( myEditedSection ) : QString(); if ( accept && myEditedHeader ) setHeaderContentFromEditor( myEditedHeader, myEditedSection, myHeaderEditor ); - QString newTxt = myEditedHeader ? myEditedHeader->label( myEditedSection ) : QString::null; + QString newTxt = myEditedHeader ? myEditedHeader->label( myEditedSection ) : QString(); int sec = myEditedSection; QHeader* hdr = myEditedHeader; diff --git a/src/Qtx/QtxWorkstack.cxx b/src/Qtx/QtxWorkstack.cxx index aaec1636c..a2f573213 100644 --- a/src/Qtx/QtxWorkstack.cxx +++ b/src/Qtx/QtxWorkstack.cxx @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -240,64 +241,119 @@ void QtxWorkstackDrag::startDrawRect() } -QtxWorkstackAreaTitleButton::QtxWorkstackAreaTitleButton(QWidget *widget) -: QAbstractButton(widget) +/* + \class CloseButton + \brief Workstack area close button. + \internal +*/ +class CloseButton : public QAbstractButton +{ +public: + CloseButton( QWidget* ); + + QSize sizeHint() const; + QSize minimumSizeHint() const; + + void enterEvent( QEvent* ); + void leaveEvent( QEvent* ); + void paintEvent( QPaintEvent* ); +}; + +/*! + \brief Constructor + \internal + \param parent parent widget +*/ +CloseButton::CloseButton( QWidget* parent ) +: QAbstractButton( parent ) { - setFocusPolicy(Qt::NoFocus); + setFocusPolicy( Qt::NoFocus ); } -QSize QtxWorkstackAreaTitleButton::sizeHint() const +/*! + \brief Get appropriate size for the button. + \internal + \return size value +*/ +QSize CloseButton::sizeHint() const { ensurePolished(); int dim = 0; - if( !icon().isNull() ) { + if( !icon().isNull() ) + { const QPixmap pm = icon().pixmap( style()->pixelMetric( QStyle::PM_SmallIconSize ), QIcon::Normal ); - dim = qMax(pm.width(), pm.height()); + dim = qMax( pm.width(), pm.height() ); } return QSize( dim + 4, dim + 4 ); } -void QtxWorkstackAreaTitleButton::enterEvent( QEvent *event ) + +/*! + \brief Get minimum appropriate size for the button. + \internal + \return minimum size value +*/ +QSize CloseButton::minimumSizeHint() const +{ + return sizeHint(); +} + +/*! + \brief Process mouse enter event. + \internal + \param event mouse enter event +*/ +void CloseButton::enterEvent( QEvent *event ) { if ( isEnabled() ) update(); QAbstractButton::enterEvent( event ); } -void QtxWorkstackAreaTitleButton::leaveEvent( QEvent *event ) +/*! + \brief Process mouse leave event. + \internal + \param event mouse leave event +*/ +void CloseButton::leaveEvent( QEvent *event ) { if( isEnabled() ) update(); QAbstractButton::leaveEvent( event ); } -void QtxWorkstackAreaTitleButton::paintEvent( QPaintEvent* ) +/*! + \brief Process paint event. + \internal + \param event paint event +*/ +void CloseButton::paintEvent( QPaintEvent* ) { - QPainter p(this); + QPainter p( this ); QRect r = rect(); QStyleOption opt; - opt.init(this); + opt.init( this ); opt.state |= QStyle::State_AutoRaise; - if (isEnabled() && underMouse() && !isChecked() && !isDown()) + if ( isEnabled() && underMouse() && !isChecked() && !isDown() ) opt.state |= QStyle::State_Raised; - if (isChecked()) + if ( isChecked() ) opt.state |= QStyle::State_On; - if (isDown()) + if ( isDown() ) opt.state |= QStyle::State_Sunken; - style()->drawPrimitive(QStyle::PE_PanelButtonTool, &opt, &p, this); + style()->drawPrimitive( QStyle::PE_PanelButtonTool, &opt, &p, this ); - int shiftHorizontal = opt.state & QStyle::State_Sunken ? style()->pixelMetric(QStyle::PM_ButtonShiftHorizontal, &opt, this) : 0; - int shiftVertical = opt.state & QStyle::State_Sunken ? style()->pixelMetric(QStyle::PM_ButtonShiftVertical, &opt, this) : 0; + int shiftHorizontal = opt.state & QStyle::State_Sunken ? style()->pixelMetric( QStyle::PM_ButtonShiftHorizontal, &opt, this ) : 0; + int shiftVertical = opt.state & QStyle::State_Sunken ? style()->pixelMetric( QStyle::PM_ButtonShiftVertical, &opt, this ) : 0; - r.adjust(2, 2, -2, -2); - r.translate(shiftHorizontal, shiftVertical); + r.adjust( 2, 2, -2, -2 ); + r.translate( shiftHorizontal, shiftVertical ); QPixmap pm = icon().pixmap( style()->pixelMetric( QStyle::PM_SmallIconSize ), isEnabled() ? underMouse() ? QIcon::Active : QIcon::Normal - : QIcon::Disabled, - isDown() ? QIcon::On : QIcon::Off); - style()->drawItemPixmap(&p, r, Qt::AlignCenter, pm); + : QIcon::Disabled, + isDown() ? QIcon::On : QIcon::Off ); + style()->drawItemPixmap( &p, r, Qt::AlignCenter, pm ); } /*! @@ -328,7 +384,7 @@ QtxWorkstackArea::QtxWorkstackArea( QWidget* parent ) myBar = new QtxWorkstackTabBar( top ); tl->addWidget( myBar, 1 ); - QtxWorkstackAreaTitleButton* close = new QtxWorkstackAreaTitleButton( top ); + CloseButton* close = new CloseButton( top ); close->setIcon( style()->standardIcon( QStyle::SP_TitleBarCloseButton ) ); myClose = close; tl->addWidget( myClose ); diff --git a/src/Qtx/QtxWorkstack.h b/src/Qtx/QtxWorkstack.h index d2ee2b10e..e4ae55381 100644 --- a/src/Qtx/QtxWorkstack.h +++ b/src/Qtx/QtxWorkstack.h @@ -29,12 +29,12 @@ #include #include #include -#include class QAction; class QSplitter; class QStackedWidget; class QRubberBand; +class QAbstractButton; class QtxWorkstackArea; class QtxWorkstackDrag; @@ -155,25 +155,6 @@ private: friend class QtxWorkstackDrag; }; -/* - Tool window title -*/ -class QtxWorkstackAreaTitleButton : public QAbstractButton -{ - Q_OBJECT - -public: - QtxWorkstackAreaTitleButton(QWidget *widget); - - QSize sizeHint() const; - inline QSize minimumSizeHint() const - { return sizeHint(); } - - void enterEvent(QEvent *event); - void leaveEvent(QEvent *event); - void paintEvent(QPaintEvent *event); -}; - class QtxWorkstackArea : public QFrame { Q_OBJECT diff --git a/src/STD/STD_Application.cxx b/src/STD/STD_Application.cxx index c7fc077e1..cc889eec6 100755 --- a/src/STD/STD_Application.cxx +++ b/src/STD/STD_Application.cxx @@ -302,7 +302,7 @@ bool STD_Application::onNewDoc( const QString& name ) void STD_Application::onOpenDoc() { // It is preferrable to use OS-specific file dialog box here !!! - QString aName = getFileName( true, QString::null, getFileFilter(), QString::null, 0 ); + QString aName = getFileName( true, QString(), getFileFilter(), QString(), 0 ); if ( aName.isNull() ) return; @@ -499,7 +499,7 @@ bool STD_Application::onSaveAsDoc() bool isOk = false; while ( !isOk ) { - QString aName = getFileName( false, study->studyName(), getFileFilter(), QString::null, 0 ); + QString aName = getFileName( false, study->studyName(), getFileFilter(), QString(), 0 ); if ( aName.isNull() ) return false; @@ -815,7 +815,7 @@ QString STD_Application::getFileName( bool open, const QString& initial, const Q SUIT_MessageBox::Yes | SUIT_MessageBox::No | SUIT_MessageBox::Cancel, SUIT_MessageBox::Yes ); if ( aAnswer == SUIT_MessageBox::Cancel ) { // cancelled - aName = QString::null; + aName = QString(); isOk = true; } else if ( aAnswer == SUIT_MessageBox::No ) // not save to this file diff --git a/src/STD/STD_Application.h b/src/STD/STD_Application.h index 9ea5b736d..73cbacfc0 100755 --- a/src/STD/STD_Application.h +++ b/src/STD/STD_Application.h @@ -82,7 +82,7 @@ public: void viewManagers( ViewManagerList& ) const; void viewManagers( const QString&, ViewManagerList& ) const; - virtual QString getFileFilter() const { return QString::null; } + virtual QString getFileFilter() const { return QString(); } virtual QString getFileName( bool open, const QString& initial, const QString& filters, const QString& caption, QWidget* parent ); QString getDirectory( const QString& initial, const QString& caption, QWidget* parent ); diff --git a/src/SUIT/SUIT_Application.cxx b/src/SUIT/SUIT_Application.cxx index f07565b4e..d841f3e63 100755 --- a/src/SUIT/SUIT_Application.cxx +++ b/src/SUIT/SUIT_Application.cxx @@ -94,7 +94,7 @@ SUIT_Study* SUIT_Application::activeStudy() const */ QString SUIT_Application::applicationVersion() const { - return QString::null; + return QString(); } /*! @@ -195,7 +195,7 @@ void SUIT_Application::onInfoClear() bool changed = !myStatusLabel->text().isEmpty(); myStatusLabel->clear(); if ( changed ) - emit infoChanged( QString::null ); + emit infoChanged( QString() ); } /*! diff --git a/src/SUIT/SUIT_Operation.cxx b/src/SUIT/SUIT_Operation.cxx index 31ff40f8f..73ab85cc2 100755 --- a/src/SUIT/SUIT_Operation.cxx +++ b/src/SUIT/SUIT_Operation.cxx @@ -154,7 +154,7 @@ bool SUIT_Operation::testFlags( const int f ) const */ QString SUIT_Operation::operationName() const { - return QString::null; + return QString(); } /*! diff --git a/src/SUIT/SUIT_Operation.h b/src/SUIT/SUIT_Operation.h index 6a1785e2a..cf29007d7 100755 --- a/src/SUIT/SUIT_Operation.h +++ b/src/SUIT/SUIT_Operation.h @@ -140,7 +140,7 @@ protected: virtual bool openTransaction(); virtual bool abortTransaction(); virtual bool hasTransaction() const; - virtual bool commitTransaction( const QString& = QString::null ); + virtual bool commitTransaction( const QString& = QString() ); void setExecStatus( const int ); diff --git a/src/SUIT/SUIT_ResourceMgr.h b/src/SUIT/SUIT_ResourceMgr.h index db0eda711..2717de2c4 100755 --- a/src/SUIT/SUIT_ResourceMgr.h +++ b/src/SUIT/SUIT_ResourceMgr.h @@ -26,7 +26,7 @@ class SUIT_EXPORT SUIT_ResourceMgr : public QtxResourceMgr { public: - SUIT_ResourceMgr( const QString&, const QString& = QString::null ); + SUIT_ResourceMgr( const QString&, const QString& = QString() ); virtual ~SUIT_ResourceMgr(); virtual QString version() const; diff --git a/src/SUIT/SUIT_SelectionMgr.h b/src/SUIT/SUIT_SelectionMgr.h index 7f3082737..ec2ecb9fa 100755 --- a/src/SUIT/SUIT_SelectionMgr.h +++ b/src/SUIT/SUIT_SelectionMgr.h @@ -40,14 +40,14 @@ public: virtual ~SUIT_SelectionMgr(); void clearSelected(); - virtual void selected( SUIT_DataOwnerPtrList&, const QString& = QString::null ) const; + virtual void selected( SUIT_DataOwnerPtrList&, const QString& = QString() ) const; virtual void setSelected( const SUIT_DataOwnerPtrList&, const bool = false ); void selectors( QList& ) const; void selectors( const QString&, QList& ) const; - void setEnabled( const bool, const QString& = QString::null ); + void setEnabled( const bool, const QString& = QString() ); bool hasSelectionMode( const int ) const; diff --git a/src/SUIT/SUIT_Study.h b/src/SUIT/SUIT_Study.h index 6ebf2bcad..97e12f493 100755 --- a/src/SUIT/SUIT_Study.h +++ b/src/SUIT/SUIT_Study.h @@ -93,7 +93,7 @@ protected: virtual bool openTransaction(); virtual bool abortTransaction(); virtual bool hasTransaction() const; - virtual bool commitTransaction( const QString& = QString::null ); + virtual bool commitTransaction( const QString& = QString() ); private: typedef QList Operations; diff --git a/src/SUIT/SUIT_ViewWindow.cxx b/src/SUIT/SUIT_ViewWindow.cxx index 7ab233d84..689a3a786 100755 --- a/src/SUIT/SUIT_ViewWindow.cxx +++ b/src/SUIT/SUIT_ViewWindow.cxx @@ -167,7 +167,7 @@ bool SUIT_ViewWindow::event( QEvent* e ) // get file name SUIT_Application* app = myManager->study()->application(); - QString fileName = app->getFileName( false, QString::null, filter(), tr( "TLT_DUMP_VIEW" ), 0 ); + QString fileName = app->getFileName( false, QString(), filter(), tr( "TLT_DUMP_VIEW" ), 0 ); if ( !fileName.isEmpty() ) { QString fmt = SUIT_Tools::extension( fileName ).toUpper(); -- 2.39.2