Changeset View
Changeset View
Standalone View
Standalone View
kcmkwin/kwindecoration/declarative-plugin/previewbutton.cpp
Show First 20 Lines • Show All 103 Lines • ▼ Show 20 Line(s) | 101 | { | |||
---|---|---|---|---|---|
104 | } | 104 | } | ||
105 | m_decoration = m_bridge->createDecoration(this); | 105 | m_decoration = m_bridge->createDecoration(this); | ||
106 | if (!m_decoration) { | 106 | if (!m_decoration) { | ||
107 | return; | 107 | return; | ||
108 | } | 108 | } | ||
109 | auto client = m_bridge->lastCreatedClient(); | 109 | auto client = m_bridge->lastCreatedClient(); | ||
110 | client->setMinimizable(true); | 110 | client->setMinimizable(true); | ||
111 | client->setMaximizable(true); | 111 | client->setMaximizable(true); | ||
112 | client->setActive(false); | 112 | client->setActive(true); | ||
113 | client->setProvidesContextHelp(true); | 113 | client->setProvidesContextHelp(true); | ||
114 | m_decoration->setSettings(m_settings->settings()); | 114 | m_decoration->setSettings(m_settings->settings()); | ||
115 | m_decoration->init(); | 115 | m_decoration->init(); | ||
116 | m_button = m_bridge->createButton(m_decoration, m_type); | 116 | m_button = m_bridge->createButton(m_decoration, m_type); | ||
117 | | ||||
117 | connect(this, &PreviewButtonItem::widthChanged, this, &PreviewButtonItem::syncGeometry); | 118 | connect(this, &PreviewButtonItem::widthChanged, this, &PreviewButtonItem::syncGeometry); | ||
118 | connect(this, &PreviewButtonItem::heightChanged, this, &PreviewButtonItem::syncGeometry); | 119 | connect(this, &PreviewButtonItem::heightChanged, this, &PreviewButtonItem::syncGeometry); | ||
119 | syncGeometry(); | 120 | syncGeometry(); | ||
120 | } | 121 | } | ||
121 | 122 | | |||
122 | void PreviewButtonItem::syncGeometry() | 123 | void PreviewButtonItem::syncGeometry() | ||
123 | { | 124 | { | ||
124 | if (!m_button) { | 125 | if (!m_button) { | ||
125 | return; | 126 | return; | ||
126 | } | 127 | } | ||
127 | m_button->setGeometry(QRect(0, 0, width(), height())); | 128 | m_button->setGeometry(QRect(0, 0, width(), height())); | ||
128 | } | 129 | } | ||
129 | 130 | | |||
130 | void PreviewButtonItem::paint(QPainter *painter) | 131 | void PreviewButtonItem::paint(QPainter *painter) | ||
131 | { | 132 | { | ||
132 | if (!m_button) { | 133 | if (!m_button) { | ||
133 | return; | 134 | return; | ||
134 | } | 135 | } | ||
135 | QRect size { 0, 0, (int)width(), (int)height() }; | 136 | QRect size { 0, 0, (int)width(), (int)height() }; | ||
136 | m_button->paint(painter, size); | 137 | m_button->paint(painter, size); | ||
137 | painter->setCompositionMode(QPainter::CompositionMode_SourceAtop); | | |||
138 | painter->fillRect(size, m_color); | | |||
139 | } | | |||
140 | | ||||
141 | void PreviewButtonItem::setColor(const QColor color) | | |||
142 | { | | |||
143 | m_color = color; | | |||
144 | m_color.setAlpha(127); | | |||
145 | update(); | | |||
146 | } | 138 | } | ||
147 | 139 | | |||
148 | } | 140 | } | ||
149 | } | 141 | } |