|
41 | 41 | namespace ads
|
42 | 42 | {
|
43 | 43 | //============================================================================
|
44 |
| -static QPixmap createDropIndicatorPixmap(const QPalette& pal, const QSizeF& size, DockWidgetArea DockWidgetArea) |
| 44 | +static QPixmap createDropIndicatorPixmap_old(const QPalette& pal, const QSizeF& size, DockWidgetArea DockWidgetArea) |
45 | 45 | {
|
46 | 46 | QColor borderColor = pal.color(QPalette::Active, QPalette::Highlight);
|
47 | 47 | QColor backgroundColor = pal.color(QPalette::Active, QPalette::Base);
|
@@ -121,6 +121,87 @@ static QPixmap createDropIndicatorPixmap(const QPalette& pal, const QSizeF& size
|
121 | 121 | }
|
122 | 122 |
|
123 | 123 |
|
| 124 | +//============================================================================ |
| 125 | +static QPixmap createDropIndicatorPixmap(const QPalette& pal, const QSizeF& size, DockWidgetArea DockWidgetArea) |
| 126 | +{ |
| 127 | + QColor borderColor = pal.color(QPalette::Active, QPalette::Highlight); |
| 128 | + QColor backgroundColor = pal.color(QPalette::Active, QPalette::Base); |
| 129 | + //QColor areaBackgroundColor = pal.color(QPalette::Active, QPalette::Highlight).lighter(150); |
| 130 | + |
| 131 | + QPixmap pm(size.width(), size.height()); |
| 132 | + pm.fill(QColor(0, 0, 0, 0)); |
| 133 | + |
| 134 | + QPainter p(&pm); |
| 135 | + QPen pen = p.pen(); |
| 136 | + QRectF ShadowRect(pm.rect()); |
| 137 | + QRectF baseRect; |
| 138 | + baseRect.setSize(ShadowRect.size() * 0.7); |
| 139 | + baseRect.moveCenter(ShadowRect.center()); |
| 140 | + |
| 141 | + // Fill |
| 142 | + p.fillRect(ShadowRect, QColor(0, 0, 0, 64)); |
| 143 | + p.fillRect(baseRect, backgroundColor); |
| 144 | + |
| 145 | + // Drop area rect. |
| 146 | + p.save(); |
| 147 | + QRectF areaRect; |
| 148 | + QLineF areaLine; |
| 149 | + switch (DockWidgetArea) |
| 150 | + { |
| 151 | + case TopDockWidgetArea: |
| 152 | + areaRect = QRectF(baseRect.x(), baseRect.y(), baseRect.width(), baseRect.height() * .5f); |
| 153 | + areaLine = QLineF(areaRect.bottomLeft(), areaRect.bottomRight()); |
| 154 | + break; |
| 155 | + case RightDockWidgetArea: |
| 156 | + areaRect = QRectF(ShadowRect.width() * .5f, baseRect.y(), baseRect.width() * .5f, baseRect.height()); |
| 157 | + areaLine = QLineF(areaRect.topLeft(), areaRect.bottomLeft()); |
| 158 | + break; |
| 159 | + case BottomDockWidgetArea: |
| 160 | + areaRect = QRectF(baseRect.x(), ShadowRect.height() * .5f, baseRect.width(), baseRect.height() * .5f); |
| 161 | + areaLine = QLineF(areaRect.topLeft(), areaRect.topRight()); |
| 162 | + break; |
| 163 | + case LeftDockWidgetArea: |
| 164 | + areaRect = QRectF(baseRect.x(), baseRect.y(), baseRect.width() * .5f, baseRect.height()); |
| 165 | + areaLine = QLineF(areaRect.topRight(), areaRect.bottomRight()); |
| 166 | + break; |
| 167 | + default: |
| 168 | + break; |
| 169 | + } |
| 170 | + if (areaRect.isValid()) |
| 171 | + { |
| 172 | + pen = p.pen(); |
| 173 | + pen.setColor(borderColor); |
| 174 | + QColor Color = borderColor; |
| 175 | + Color.setAlpha(64); |
| 176 | + p.setBrush(Color); |
| 177 | + p.setPen(Qt::NoPen); |
| 178 | + p.drawRect(areaRect); |
| 179 | + |
| 180 | + pen = p.pen(); |
| 181 | + pen.setColor(borderColor); |
| 182 | + pen.setStyle(Qt::DashLine); |
| 183 | + p.setPen(pen); |
| 184 | + p.drawLine(areaLine); |
| 185 | + } |
| 186 | + p.restore(); |
| 187 | + |
| 188 | + p.save(); |
| 189 | + pen = p.pen(); |
| 190 | + pen.setColor(borderColor); |
| 191 | + pen.setWidth(1); |
| 192 | + |
| 193 | + p.setBrush(Qt::NoBrush); |
| 194 | + p.setPen(pen); |
| 195 | + p.drawRect(baseRect); |
| 196 | + |
| 197 | + p.setBrush(borderColor); |
| 198 | + QRectF FrameRect(baseRect.topLeft(), QSizeF(baseRect.width(), baseRect.height() / 10)); |
| 199 | + p.drawRect(FrameRect); |
| 200 | + p.restore(); |
| 201 | + return pm; |
| 202 | +} |
| 203 | + |
| 204 | + |
124 | 205 | //============================================================================
|
125 | 206 | QWidget* createDropIndicatorWidget(DockWidgetArea DockWidgetArea)
|
126 | 207 | {
|
@@ -334,19 +415,18 @@ void CDockOverlay::paintEvent(QPaintEvent* event)
|
334 | 415 |
|
335 | 416 |
|
336 | 417 | //============================================================================
|
337 |
| -void CDockOverlay::showEvent(QShowEvent*) |
| 418 | +void CDockOverlay::showEvent(QShowEvent* e) |
338 | 419 | {
|
339 | 420 | d->Cross->show();
|
340 |
| - QWidget* w = parentWidget() ? parentWidget() : d->TargetWidget.data(); |
341 |
| - QRect WidgetRect = w->rect(); |
342 |
| - QPoint Pos(WidgetRect.left(), WidgetRect.center().y()); |
| 421 | + QFrame::showEvent(e); |
343 | 422 | }
|
344 | 423 |
|
345 | 424 |
|
346 | 425 | //============================================================================
|
347 |
| -void CDockOverlay::hideEvent(QHideEvent*) |
| 426 | +void CDockOverlay::hideEvent(QHideEvent* e) |
348 | 427 | {
|
349 | 428 | d->Cross->hide();
|
| 429 | + QFrame::hideEvent(e); |
350 | 430 | }
|
351 | 431 |
|
352 | 432 |
|
|
0 commit comments