Changeset View
Changeset View
Standalone View
Standalone View
libbreezecommon/breezerenderdecorationbuttonicon.cpp
- This file was added.
| Property | Old Value | New Value |
|---|---|---|
| File Mode | null | 100755 |
| 1 | /* | ||||
|---|---|---|---|---|---|
| 2 | * Copyright 2020 Paul McAuley <kde@paulmcauley.com> | ||||
| 3 | * | ||||
| 4 | * This program is free software; you can redistribute it and/or | ||||
| 5 | * modify it under the terms of the GNU General Public License as | ||||
| 6 | * published by the Free Software Foundation; either version 2 of | ||||
| 7 | * the License or (at your option) version 3 or any later version | ||||
| 8 | * accepted by the membership of KDE e.V. (or its successor approved | ||||
| 9 | * by the membership of KDE e.V.), which shall act as a proxy | ||||
| 10 | * defined in Section 14 of version 3 of the license. | ||||
| 11 | * | ||||
| 12 | * This program is distributed in the hope that it will be useful, | ||||
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
| 15 | * GNU General Public License for more details. | ||||
| 16 | * | ||||
| 17 | * You should have received a copy of the GNU General Public License | ||||
| 18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||
| 19 | */ | ||||
| 20 | | ||||
| 21 | #include "breezerenderdecorationbuttonicon.h" | ||||
| 22 | #include "breezestyleclassic.h" | ||||
| 23 | #include "breezestyleoxygen.h" | ||||
| 24 | #include "breezestyleredmond.h" | ||||
| 25 | | ||||
| 26 | namespace Breeze | ||||
| 27 | { | ||||
| 28 | | ||||
| 29 | std::unique_ptr<RenderDecorationButtonIcon18By18> RenderDecorationButtonIcon18By18::factory( QPainter* painter, const QPen& pen, int buttonIconStyle, const bool notInTitlebar) | ||||
| 30 | { | ||||
| 31 | switch( EnumButtonIconStyle(buttonIconStyle) ) | ||||
| 32 | { | ||||
| 33 | case StyleClassic: | ||||
| 34 | return std::unique_ptr<RenderDecorationButtonIcon18By18>( new RenderStyleClassic18By18(painter, pen, notInTitlebar) ); | ||||
| 35 | case StyleOxygen: | ||||
| 36 | default: | ||||
| 37 | return std::unique_ptr<RenderDecorationButtonIcon18By18>( new RenderStyleOxygen18By18(painter, pen, notInTitlebar) ); | ||||
| 38 | case StyleRedmond: | ||||
| 39 | return std::unique_ptr<RenderDecorationButtonIcon18By18>( new RenderStyleRedmond18By18(painter, pen, notInTitlebar) ); | ||||
| 40 | } | ||||
| 41 | } | ||||
| 42 | | ||||
| 43 | | ||||
| 44 | | ||||
| 45 | RenderDecorationButtonIcon18By18::RenderDecorationButtonIcon18By18( QPainter* painter, const QPen& pen, const bool notInTitlebar ) | ||||
| 46 | { | ||||
| 47 | this->painter = painter; | ||||
| 48 | this->pen = pen; | ||||
| 49 | this->notInTitlebar = notInTitlebar; | ||||
| 50 | | ||||
| 51 | initPainter(); | ||||
| 52 | } | ||||
| 53 | | ||||
| 54 | | ||||
| 55 | | ||||
| 56 | void RenderDecorationButtonIcon18By18::initPainter() | ||||
| 57 | { | ||||
| 58 | pen.setCapStyle( Qt::RoundCap ); | ||||
| 59 | pen.setJoinStyle( Qt::MiterJoin ); | ||||
| 60 | painter->setPen( pen ); | ||||
| 61 | painter->setBrush( Qt::NoBrush ); | ||||
| 62 | } | ||||
| 63 | | ||||
| 64 | | ||||
| 65 | /* base methods are based on Oxygen style -- override with other styles */ | ||||
| 66 | void RenderDecorationButtonIcon18By18::renderCloseIcon() | ||||
| 67 | { | ||||
| 68 | painter->drawLine( 5, 5, 13, 13 ); | ||||
| 69 | painter->drawLine( 13, 5, 5, 13 ); | ||||
| 70 | } | ||||
| 71 | | ||||
| 72 | void RenderDecorationButtonIcon18By18::renderMaximizeIcon() | ||||
| 73 | { | ||||
| 74 | //up arrow | ||||
| 75 | painter->drawPolyline( QVector<QPointF>{ | ||||
| 76 | QPointF( 4, 11 ), | ||||
| 77 | QPointF( 9, 6 ), | ||||
| 78 | QPointF( 14, 11 )} ); | ||||
| 79 | } | ||||
| 80 | | ||||
| 81 | void RenderDecorationButtonIcon18By18::renderRestoreIcon() | ||||
| 82 | { | ||||
| 83 | pen.setJoinStyle( Qt::RoundJoin ); | ||||
| 84 | painter->setPen( pen ); | ||||
| 85 | | ||||
| 86 | if (this->notInTitlebar) { // slightly smaller diamond | ||||
| 87 | | ||||
| 88 | //diamond / floating kite | ||||
| 89 | painter->drawConvexPolygon( QVector<QPointF>{ | ||||
| 90 | QPointF( 4.5, 9 ), | ||||
| 91 | QPointF( 9, 4.5 ), | ||||
| 92 | QPointF( 13.5, 9 ), | ||||
| 93 | QPointF( 9, 13.5 )}); | ||||
| 94 | | ||||
| 95 | } else { | ||||
| 96 | | ||||
| 97 | //diamond / floating kite | ||||
| 98 | painter->drawConvexPolygon( QVector<QPointF>{ | ||||
| 99 | QPointF( 4, 9 ), | ||||
| 100 | QPointF( 9, 4 ), | ||||
| 101 | QPointF( 14, 9 ), | ||||
| 102 | QPointF( 9, 14 )} ); | ||||
| 103 | } | ||||
| 104 | } | ||||
| 105 | | ||||
| 106 | void RenderDecorationButtonIcon18By18::renderMinimizeIcon() | ||||
| 107 | { | ||||
| 108 | //down arrow | ||||
| 109 | painter->drawPolyline( QVector<QPointF>{ | ||||
| 110 | QPointF( 4, 7 ), | ||||
| 111 | QPointF( 9, 12 ), | ||||
| 112 | QPointF( 14, 7 )} ); | ||||
| 113 | } | ||||
| 114 | | ||||
| 115 | void RenderDecorationButtonIcon18By18::renderPinnedOnAllDesktopsIcon() | ||||
| 116 | { | ||||
| 117 | // thick hollow ring | ||||
| 118 | pen.setWidthF(5); | ||||
| 119 | painter->setPen( pen ); | ||||
| 120 | painter->drawEllipse( QPointF( 9, 9 ), qreal(3.5), qreal(3.5) ); | ||||
| 121 | } | ||||
| 122 | | ||||
| 123 | void RenderDecorationButtonIcon18By18::renderPinOnAllDesktopsIcon() | ||||
| 124 | { | ||||
| 125 | painter->setBrush( pen.color() ); | ||||
| 126 | painter->setPen( Qt::NoPen ); | ||||
| 127 | painter->drawConvexPolygon( QVector<QPointF>{ | ||||
| 128 | QPointF( 6.5, 8.5 ), | ||||
| 129 | QPointF( 12, 3 ), | ||||
| 130 | QPointF( 15, 6 ), | ||||
| 131 | QPointF( 9.5, 11.5 )} ); | ||||
| 132 | | ||||
| 133 | painter->setPen( pen ); | ||||
| 134 | painter->drawLine( QPointF( 5.5, 7.5 ), QPointF( 10.5, 12.5 ) ); | ||||
| 135 | painter->drawLine( QPointF( 12, 6 ), QPointF( 4.5, 13.5 ) ); | ||||
| 136 | } | ||||
| 137 | | ||||
| 138 | void RenderDecorationButtonIcon18By18::renderShadeIcon() | ||||
| 139 | { | ||||
| 140 | painter->drawLine( QPointF( 4, 4.5 ), QPointF( 14, 4.5 ) ); | ||||
| 141 | painter->drawPolyline( QVector<QPointF>{ | ||||
| 142 | QPointF( 4, 13 ), | ||||
| 143 | QPointF( 9, 8 ), | ||||
| 144 | QPointF( 14, 13 )} ); | ||||
| 145 | } | ||||
| 146 | | ||||
| 147 | void RenderDecorationButtonIcon18By18::renderUnShadeIcon() | ||||
| 148 | { | ||||
| 149 | painter->drawLine( QPointF( 4, 4.5 ), QPointF( 14, 4.5 ) ); | ||||
| 150 | painter->drawPolyline( QVector<QPointF>{ | ||||
| 151 | QPointF( 4, 8 ), | ||||
| 152 | QPointF( 9, 13 ), | ||||
| 153 | QPointF( 14, 8 )} ); | ||||
| 154 | } | ||||
| 155 | | ||||
| 156 | void RenderDecorationButtonIcon18By18::renderKeepBehindIcon() | ||||
| 157 | { | ||||
| 158 | //two down arrows | ||||
| 159 | painter->drawPolyline( QVector<QPointF>{ | ||||
| 160 | QPointF( 4, 5 ), | ||||
| 161 | QPointF( 9, 10 ), | ||||
| 162 | QPointF( 14, 5 )} ); | ||||
| 163 | | ||||
| 164 | painter->drawPolyline( QVector<QPointF>{ | ||||
| 165 | QPointF( 4, 9 ), | ||||
| 166 | QPointF( 9, 14 ), | ||||
| 167 | QPointF( 14, 9 )} ); | ||||
| 168 | } | ||||
| 169 | | ||||
| 170 | void RenderDecorationButtonIcon18By18::renderKeepInFrontIcon() | ||||
| 171 | { | ||||
| 172 | //two up arrows | ||||
| 173 | painter->drawPolyline( QVector<QPointF>{ | ||||
| 174 | QPointF( 4, 9 ), | ||||
| 175 | QPointF( 9, 4 ), | ||||
| 176 | QPointF( 14, 9 )} ); | ||||
| 177 | | ||||
| 178 | painter->drawPolyline( QVector<QPointF>{ | ||||
| 179 | QPointF( 4, 13 ), | ||||
| 180 | QPointF( 9, 8 ), | ||||
| 181 | QPointF( 14, 13 )} ); | ||||
| 182 | } | ||||
| 183 | | ||||
| 184 | void RenderDecorationButtonIcon18By18::renderApplicationMenuIcon() | ||||
| 185 | { | ||||
| 186 | painter->drawRect( QRectF( 3.5, 4.5, 11, 1 ) ); | ||||
| 187 | painter->drawRect( QRectF( 3.5, 8.5, 11, 1 ) ); | ||||
| 188 | painter->drawRect( QRectF( 3.5, 12.5, 11, 1 ) ); | ||||
| 189 | } | ||||
| 190 | | ||||
| 191 | void RenderDecorationButtonIcon18By18::renderContextHelpIcon() | ||||
| 192 | { | ||||
| 193 | QPainterPath path; | ||||
| 194 | path.moveTo( 5, 6 ); | ||||
| 195 | path.arcTo( QRectF( 5, 3.5, 8, 5 ), 180, -180 ); | ||||
| 196 | path.cubicTo( QPointF(12.5, 9.5), QPointF( 9, 7.5 ), QPointF( 9, 11.5 ) ); | ||||
| 197 | painter->drawPath( path ); | ||||
| 198 | | ||||
| 199 | painter->drawRect( QRectF( 9, 15, 0.5, 0.5 ) ); | ||||
| 200 | } | ||||
| 201 | | ||||
| 202 | } | ||||