1
0
mirror of https://github.com/KDE/latte-dock.git synced 2024-12-23 13:33:50 +03:00

dialogs:provide drawings remained rectangle

This commit is contained in:
Michail Vourlakos 2021-04-11 02:34:01 +03:00
parent f92f54f041
commit c26600e9c0
4 changed files with 18 additions and 10 deletions

View File

@ -188,7 +188,17 @@ void drawLayoutIcon(QPainter *painter, const QStyleOption &option, const QRect &
}
}
QRect drawChangesIndicatorBackground(QPainter *painter, const QStyleOptionViewItem &option)
QRect remainedFromChangesIndicator(const QStyleOptionViewItem &option)
{
int tsize{INDICATORCHANGESLENGTH + INDICATORCHANGESMARGIN*2};
QRect optionRemainedRect = (qApp->layoutDirection() == Qt::RightToLeft) ? QRect(option.rect.x() + tsize, option.rect.y(), option.rect.width() - tsize, option.rect.height()) :
QRect(option.rect.x(), option.rect.y(), option.rect.width() - tsize, option.rect.height());
return optionRemainedRect;
}
void drawChangesIndicatorBackground(QPainter *painter, const QStyleOptionViewItem &option)
{
int tsize{INDICATORCHANGESLENGTH + INDICATORCHANGESMARGIN*2};
@ -204,11 +214,6 @@ QRect drawChangesIndicatorBackground(QPainter *painter, const QStyleOptionViewIt
}
option.widget->style()->drawControl(QStyle::CE_ItemViewItem, &indicatorOption, painter);
QRect optionRemainedRect = (qApp->layoutDirection() == Qt::RightToLeft) ? QRect(option.rect.x() + tsize, option.rect.y(), option.rect.width() - tsize, option.rect.height()) :
QRect(option.rect.x(), option.rect.y(), option.rect.width() - tsize, option.rect.height());
return optionRemainedRect;
}
void drawChangesIndicator(QPainter *painter, const QStyleOptionViewItem &option)

View File

@ -51,8 +51,10 @@ void drawFormattedText(QPainter *painter, const QStyleOptionViewItem &option);
void drawLayoutIcon(QPainter *painter, const QStyleOption &option, const QRect &target, const Latte::Data::LayoutIcon &icon);
//! changes indicator
QRect remainedFromChangesIndicator(const QStyleOptionViewItem &option);
void drawChangesIndicatorBackground(QPainter *painter, const QStyleOptionViewItem &option);
void drawChangesIndicator(QPainter *painter, const QStyleOptionViewItem &option);
QRect drawChangesIndicatorBackground(QPainter *painter, const QStyleOptionViewItem &option);
//! screen icon
QRect remainedFromScreenDrawing(const QStyleOptionViewItem &option);

View File

@ -99,7 +99,8 @@ void LayoutName::paint(QPainter *painter, const QStyleOptionViewItem &option, co
painter->setRenderHint(QPainter::Antialiasing, true);
QRect optionRect = Latte::drawChangesIndicatorBackground(painter, option);
QRect optionRect = Latte::remainedFromChangesIndicator(option);
Latte::drawChangesIndicatorBackground(painter, option);
adjustedOption.rect = optionRect;
if (isLocked || isConsideredActive) {

View File

@ -81,8 +81,8 @@ void NameDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
}
// draw changes indicator
QRect availableTextRect = Latte::drawChangesIndicatorBackground(painter, option);
QRect availableTextRect = Latte::remainedFromChangesIndicator(option);
Latte::drawChangesIndicatorBackground(painter, option);
if (isChanged) {
Latte::drawChangesIndicator(painter, option);
}