Changeset View
Changeset View
Standalone View
Standalone View
kstyle/breezestyle.cpp
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
Show First 20 Lines • Show All 1493 Lines • ▼ Show 20 Line(s) | 1492 | { | |||
---|---|---|---|---|---|
1494 | // cast option and check | 1494 | // cast option and check | ||
1495 | const auto progressBarOption( qstyleoption_cast<const QStyleOptionProgressBar*>( option ) ); | 1495 | const auto progressBarOption( qstyleoption_cast<const QStyleOptionProgressBar*>( option ) ); | ||
1496 | if( !progressBarOption ) return option->rect; | 1496 | if( !progressBarOption ) return option->rect; | ||
1497 | 1497 | | |||
1498 | // get flags and orientation | 1498 | // get flags and orientation | ||
1499 | const bool textVisible( progressBarOption->textVisible ); | 1499 | const bool textVisible( progressBarOption->textVisible ); | ||
1500 | const bool busy( progressBarOption->minimum == 0 && progressBarOption->maximum == 0 ); | 1500 | const bool busy( progressBarOption->minimum == 0 && progressBarOption->maximum == 0 ); | ||
1501 | 1501 | | |||
1502 | #if BREEZE_USE_KDE4 | ||||
1502 | const auto progressBarOption2( qstyleoption_cast<const QStyleOptionProgressBarV2*>( option ) ); | 1503 | const auto progressBarOption2( qstyleoption_cast<const QStyleOptionProgressBarV2*>( option ) ); | ||
1503 | const bool horizontal( !progressBarOption2 || progressBarOption2->orientation == Qt::Horizontal ); | 1504 | const bool horizontal( !progressBarOption2 || progressBarOption2->orientation == Qt::Horizontal ); | ||
1505 | #else | ||||
1506 | const bool horizontal( progressBarOption->state & QStyle::State_Horizontal ); | ||||
1507 | #endif | ||||
1504 | 1508 | | |||
1505 | // copy rectangle and adjust | 1509 | // copy rectangle and adjust | ||
1506 | auto rect( option->rect ); | 1510 | auto rect( option->rect ); | ||
1507 | const int frameWidth( pixelMetric( PM_DefaultFrameWidth, option, widget ) ); | 1511 | const int frameWidth( pixelMetric( PM_DefaultFrameWidth, option, widget ) ); | ||
1508 | if( horizontal ) rect = insideMargin( rect, frameWidth, 0 ); | 1512 | if( horizontal ) rect = insideMargin( rect, frameWidth, 0 ); | ||
1509 | else rect = insideMargin( rect, 0, frameWidth ); | 1513 | else rect = insideMargin( rect, 0, frameWidth ); | ||
1510 | 1514 | | |||
1511 | if( textVisible && !busy && horizontal ) | 1515 | if( textVisible && !busy && horizontal ) | ||
Show All 30 Lines | 1540 | { | |||
1542 | // get groove rect | 1546 | // get groove rect | ||
1543 | const auto rect( progressBarGrooveRect( option, widget ) ); | 1547 | const auto rect( progressBarGrooveRect( option, widget ) ); | ||
1544 | 1548 | | |||
1545 | // in busy mode, grooveRect is used | 1549 | // in busy mode, grooveRect is used | ||
1546 | const bool busy( progressBarOption->minimum == 0 && progressBarOption->maximum == 0 ); | 1550 | const bool busy( progressBarOption->minimum == 0 && progressBarOption->maximum == 0 ); | ||
1547 | if( busy ) return rect; | 1551 | if( busy ) return rect; | ||
1548 | 1552 | | |||
1549 | // get orientation | 1553 | // get orientation | ||
1554 | #if BREEZE_USE_KDE4 | ||||
1550 | const auto progressBarOption2( qstyleoption_cast<const QStyleOptionProgressBarV2*>( option ) ); | 1555 | const auto progressBarOption2( qstyleoption_cast<const QStyleOptionProgressBarV2*>( option ) ); | ||
1551 | const bool horizontal( !progressBarOption2 || progressBarOption2->orientation == Qt::Horizontal ); | 1556 | const bool horizontal( !progressBarOption2 || progressBarOption2->orientation == Qt::Horizontal ); | ||
1557 | #else | ||||
1558 | const bool horizontal( progressBarOption->state & QStyle::State_Horizontal ); | ||||
1559 | #endif | ||||
1552 | 1560 | | |||
1553 | // check inverted appearance | 1561 | // check inverted appearance | ||
1562 | #if BREEZE_USE_KDE4 | ||||
1554 | const bool inverted( progressBarOption2 ? progressBarOption2->invertedAppearance : false ); | 1563 | const bool inverted( progressBarOption2 ? progressBarOption2->invertedAppearance : false ); | ||
1564 | #else | ||||
1565 | const bool inverted( progressBarOption->invertedAppearance ); | ||||
1566 | #endif | ||||
1555 | 1567 | | |||
1556 | // get progress and steps | 1568 | // get progress and steps | ||
1557 | const qreal progress( progressBarOption->progress - progressBarOption->minimum ); | 1569 | const qreal progress( progressBarOption->progress - progressBarOption->minimum ); | ||
1558 | const int steps( qMax( progressBarOption->maximum - progressBarOption->minimum, 1 ) ); | 1570 | const int steps( qMax( progressBarOption->maximum - progressBarOption->minimum, 1 ) ); | ||
1559 | 1571 | | |||
1560 | //Calculate width fraction | 1572 | //Calculate width fraction | ||
1561 | const qreal widthFrac = qMin( qreal(1), progress/steps ); | 1573 | const qreal widthFrac = qMin( qreal(1), progress/steps ); | ||
1562 | 1574 | | |||
Show All 22 Lines | 1593 | { | |||
1585 | if( !progressBarOption ) return QRect(); | 1597 | if( !progressBarOption ) return QRect(); | ||
1586 | 1598 | | |||
1587 | // get flags and check | 1599 | // get flags and check | ||
1588 | const bool textVisible( progressBarOption->textVisible ); | 1600 | const bool textVisible( progressBarOption->textVisible ); | ||
1589 | const bool busy( progressBarOption->minimum == 0 && progressBarOption->maximum == 0 ); | 1601 | const bool busy( progressBarOption->minimum == 0 && progressBarOption->maximum == 0 ); | ||
1590 | if( !textVisible || busy ) return QRect(); | 1602 | if( !textVisible || busy ) return QRect(); | ||
1591 | 1603 | | |||
1592 | // get direction and check | 1604 | // get direction and check | ||
1605 | #if BREEZE_USE_KDE4 | ||||
1593 | const auto progressBarOption2( qstyleoption_cast<const QStyleOptionProgressBarV2*>( option ) ); | 1606 | const auto progressBarOption2( qstyleoption_cast<const QStyleOptionProgressBarV2*>( option ) ); | ||
1594 | const bool horizontal( !progressBarOption2 || progressBarOption2->orientation == Qt::Horizontal ); | 1607 | const bool horizontal( !progressBarOption2 || progressBarOption2->orientation == Qt::Horizontal ); | ||
1608 | #else | ||||
1609 | const bool horizontal( progressBarOption->state & QStyle::State_Horizontal ); | ||||
1610 | #endif | ||||
1595 | if( !horizontal ) return QRect(); | 1611 | if( !horizontal ) return QRect(); | ||
1596 | 1612 | | |||
1597 | int textWidth = qMax( | 1613 | int textWidth = qMax( | ||
1598 | option->fontMetrics.size( _mnemonics->textFlags(), progressBarOption->text ).width(), | 1614 | option->fontMetrics.size( _mnemonics->textFlags(), progressBarOption->text ).width(), | ||
1599 | option->fontMetrics.size( _mnemonics->textFlags(), QStringLiteral( "100%" ) ).width() ); | 1615 | option->fontMetrics.size( _mnemonics->textFlags(), QStringLiteral( "100%" ) ).width() ); | ||
1600 | 1616 | | |||
1601 | auto rect( insideMargin( option->rect, Metrics::Frame_FrameWidth, 0 ) ); | 1617 | auto rect( insideMargin( option->rect, Metrics::Frame_FrameWidth, 0 ) ); | ||
1602 | rect.setLeft( rect.right() - textWidth + 1 ); | 1618 | rect.setLeft( rect.right() - textWidth + 1 ); | ||
▲ Show 20 Lines • Show All 1206 Lines • ▼ Show 20 Line(s) | |||||
2809 | //______________________________________________________________ | 2825 | //______________________________________________________________ | ||
2810 | QSize Style::progressBarSizeFromContents( const QStyleOption* option, const QSize& contentsSize, const QWidget* ) const | 2826 | QSize Style::progressBarSizeFromContents( const QStyleOption* option, const QSize& contentsSize, const QWidget* ) const | ||
2811 | { | 2827 | { | ||
2812 | 2828 | | |||
2813 | // cast option | 2829 | // cast option | ||
2814 | const auto progressBarOption( qstyleoption_cast<const QStyleOptionProgressBar*>( option ) ); | 2830 | const auto progressBarOption( qstyleoption_cast<const QStyleOptionProgressBar*>( option ) ); | ||
2815 | if( !progressBarOption ) return contentsSize; | 2831 | if( !progressBarOption ) return contentsSize; | ||
2816 | 2832 | | |||
2833 | #if BREEZE_USE_KDE4 | ||||
2817 | const auto progressBarOption2( qstyleoption_cast<const QStyleOptionProgressBarV2*>( option ) ); | 2834 | const auto progressBarOption2( qstyleoption_cast<const QStyleOptionProgressBarV2*>( option ) ); | ||
2818 | const bool horizontal( !progressBarOption2 || progressBarOption2->orientation == Qt::Horizontal ); | 2835 | const bool horizontal( !progressBarOption2 || progressBarOption2->orientation == Qt::Horizontal ); | ||
2836 | #else | ||||
2837 | const bool horizontal( progressBarOption->state & QStyle::State_Horizontal ); | ||||
2838 | #endif | ||||
2819 | 2839 | | |||
2820 | // make local copy | 2840 | // make local copy | ||
2821 | QSize size( contentsSize ); | 2841 | QSize size( contentsSize ); | ||
2822 | 2842 | | |||
2823 | if( horizontal ) | 2843 | if( horizontal ) | ||
2824 | { | 2844 | { | ||
2825 | 2845 | | |||
2826 | // check text visibility | 2846 | // check text visibility | ||
▲ Show 20 Lines • Show All 2047 Lines • ▼ Show 20 Line(s) | |||||
4874 | //___________________________________________________________________________________ | 4894 | //___________________________________________________________________________________ | ||
4875 | bool Style::drawProgressBarControl( const QStyleOption* option, QPainter* painter, const QWidget* widget ) const | 4895 | bool Style::drawProgressBarControl( const QStyleOption* option, QPainter* painter, const QWidget* widget ) const | ||
4876 | { | 4896 | { | ||
4877 | 4897 | | |||
4878 | const auto progressBarOption( qstyleoption_cast<const QStyleOptionProgressBar*>( option ) ); | 4898 | const auto progressBarOption( qstyleoption_cast<const QStyleOptionProgressBar*>( option ) ); | ||
4879 | if( !progressBarOption ) return true; | 4899 | if( !progressBarOption ) return true; | ||
4880 | 4900 | | |||
4881 | // render groove | 4901 | // render groove | ||
4902 | #if BREEZE_USE_KDE4 | ||||
4882 | QStyleOptionProgressBarV2 progressBarOption2 = *progressBarOption; | 4903 | QStyleOptionProgressBarV2 progressBarOption2 = *progressBarOption; | ||
4904 | #else | ||||
4905 | QStyleOptionProgressBar progressBarOption2 = *progressBarOption; | ||||
4906 | #endif | ||||
4883 | progressBarOption2.rect = subElementRect( SE_ProgressBarGroove, progressBarOption, widget ); | 4907 | progressBarOption2.rect = subElementRect( SE_ProgressBarGroove, progressBarOption, widget ); | ||
4884 | drawControl( CE_ProgressBarGroove, &progressBarOption2, painter, widget ); | 4908 | drawControl( CE_ProgressBarGroove, &progressBarOption2, painter, widget ); | ||
4885 | 4909 | | |||
4886 | #if QT_VERSION >= 0x050000 | 4910 | #if QT_VERSION >= 0x050000 | ||
4887 | const QObject* styleObject( widget ? widget:progressBarOption->styleObject ); | 4911 | const QObject* styleObject( widget ? widget:progressBarOption->styleObject ); | ||
4888 | #else | 4912 | #else | ||
4889 | const QObject* styleObject( widget ); | 4913 | const QObject* styleObject( widget ); | ||
4890 | #endif | 4914 | #endif | ||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Line(s) | 4954 | { | |||
4932 | const auto progressBarOption( qstyleoption_cast<const QStyleOptionProgressBar*>( option ) ); | 4956 | const auto progressBarOption( qstyleoption_cast<const QStyleOptionProgressBar*>( option ) ); | ||
4933 | if( !progressBarOption ) return true; | 4957 | if( !progressBarOption ) return true; | ||
4934 | 4958 | | |||
4935 | // copy rect and palette | 4959 | // copy rect and palette | ||
4936 | auto rect( option->rect ); | 4960 | auto rect( option->rect ); | ||
4937 | const auto& palette( option->palette ); | 4961 | const auto& palette( option->palette ); | ||
4938 | 4962 | | |||
4939 | // get direction | 4963 | // get direction | ||
4964 | #if BREEZE_USE_KDE4 | ||||
4940 | const auto progressBarOption2( qstyleoption_cast<const QStyleOptionProgressBarV2*>( option ) ); | 4965 | const auto progressBarOption2( qstyleoption_cast<const QStyleOptionProgressBarV2*>( option ) ); | ||
4941 | const bool horizontal = !progressBarOption2 || progressBarOption2->orientation == Qt::Horizontal; | 4966 | const bool horizontal = !progressBarOption2 || progressBarOption2->orientation == Qt::Horizontal; | ||
4942 | const bool inverted( progressBarOption2 ? progressBarOption2->invertedAppearance : false ); | 4967 | const bool inverted( progressBarOption2 ? progressBarOption2->invertedAppearance : false ); | ||
4968 | #else | ||||
4969 | const bool horizontal( progressBarOption->state & QStyle::State_Horizontal ); | ||||
4970 | const bool inverted( progressBarOption->invertedAppearance ); | ||||
4971 | #endif | ||||
4943 | bool reverse = horizontal && option->direction == Qt::RightToLeft; | 4972 | bool reverse = horizontal && option->direction == Qt::RightToLeft; | ||
4944 | if( inverted ) reverse = !reverse; | 4973 | if( inverted ) reverse = !reverse; | ||
4945 | 4974 | | |||
4946 | // check if anything is to be drawn | 4975 | // check if anything is to be drawn | ||
4947 | const bool busy( ( progressBarOption->minimum == 0 && progressBarOption->maximum == 0 ) ); | 4976 | const bool busy( ( progressBarOption->minimum == 0 && progressBarOption->maximum == 0 ) ); | ||
4948 | if( busy ) | 4977 | if( busy ) | ||
4949 | { | 4978 | { | ||
4950 | 4979 | | |||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Line(s) | |||||
5003 | bool Style::drawProgressBarLabelControl( const QStyleOption* option, QPainter* painter, const QWidget* ) const | 5032 | bool Style::drawProgressBarLabelControl( const QStyleOption* option, QPainter* painter, const QWidget* ) const | ||
5004 | { | 5033 | { | ||
5005 | 5034 | | |||
5006 | // cast option and check | 5035 | // cast option and check | ||
5007 | const auto progressBarOption( qstyleoption_cast<const QStyleOptionProgressBar*>( option ) ); | 5036 | const auto progressBarOption( qstyleoption_cast<const QStyleOptionProgressBar*>( option ) ); | ||
5008 | if( !progressBarOption ) return true; | 5037 | if( !progressBarOption ) return true; | ||
5009 | 5038 | | |||
5010 | // get direction and check | 5039 | // get direction and check | ||
5040 | #if BREEZE_USE_KDE4 | ||||
5011 | const auto progressBarOption2( qstyleoption_cast<const QStyleOptionProgressBarV2*>( option ) ); | 5041 | const auto progressBarOption2( qstyleoption_cast<const QStyleOptionProgressBarV2*>( option ) ); | ||
5012 | const bool horizontal = !progressBarOption2 || progressBarOption2->orientation == Qt::Horizontal; | 5042 | const bool horizontal = !progressBarOption2 || progressBarOption2->orientation == Qt::Horizontal; | ||
5043 | #else | ||||
5044 | const bool horizontal( progressBarOption->state & QStyle::State_Horizontal ); | ||||
5045 | #endif | ||||
5013 | if( !horizontal ) return true; | 5046 | if( !horizontal ) return true; | ||
5014 | 5047 | | |||
5015 | // store rect and palette | 5048 | // store rect and palette | ||
5016 | const auto& rect( option->rect ); | 5049 | const auto& rect( option->rect ); | ||
5017 | const auto& palette( option->palette ); | 5050 | const auto& palette( option->palette ); | ||
5018 | 5051 | | |||
5019 | // store state and direction | 5052 | // store state and direction | ||
5020 | const State& state( option->state ); | 5053 | const State& state( option->state ); | ||
▲ Show 20 Lines • Show All 2156 Lines • Show Last 20 Lines |