From b765cc5e92913aa25848f845e64c7c3bd808ff50 Mon Sep 17 00:00:00 2001 From: Tobias Markmann Date: Tue, 19 May 2015 17:13:01 +0200 Subject: Add visual resize indicator in bottom right corner of QtGridSelectionDialog Test-Information: Tested on Mac OS X 10.9.5 with Qt 5.4. Change-Id: I7581ae478fb347bb468b28997be963799b82b2cb diff --git a/Swift/QtUI/Trellis/QtGridSelectionDialog.cpp b/Swift/QtUI/Trellis/QtGridSelectionDialog.cpp index 30248b0..3bcdfa0 100644 --- a/Swift/QtUI/Trellis/QtGridSelectionDialog.cpp +++ b/Swift/QtUI/Trellis/QtGridSelectionDialog.cpp @@ -1,34 +1,33 @@ /* - * Copyright (c) 2014 Isode Limited. + * Copyright (c) 2014-2015 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include -#include #include #include +#include #include #include +#include namespace Swift { -QtGridSelectionDialog::QtGridSelectionDialog(QWidget* parent) : QWidget(parent) -{ +QtGridSelectionDialog::QtGridSelectionDialog(QWidget* parent) : QWidget(parent) { frameSize = QSize(23,23) * 2; maxGridSize = QSize(7,7); minGridSize = QSize(1,1); currentGridSize = QSize(1,1); padding = 4; setWindowFlags(Qt::Popup); - horizontalMargin = style()->pixelMetric(QStyle::PM_MenuVMargin); - verticalMargin = style()->pixelMetric(QStyle::PM_MenuVMargin); setCursor(Qt::SizeAllCursor); + horizontalMargin = style()->pixelMetric(QStyle::PM_MenuVMargin) * 2; + verticalMargin = style()->pixelMetric(QStyle::PM_MenuVMargin) * 2; } -QSize QtGridSelectionDialog::sizeHint() const -{ +QSize QtGridSelectionDialog::sizeHint() const { // PM_MenuVMargin | frameSize | ( padding | frameSize ) * | PM_MenuVMargin int width = horizontalMargin + frameSize.width() + (padding + frameSize.width()) * (currentGridSize.width() - 1) + horizontalMargin; int height = verticalMargin + frameSize.height() + (padding + frameSize.height()) * (currentGridSize.height() - 1) + verticalMargin; @@ -107,6 +106,11 @@ void QtGridSelectionDialog::paintEvent(QPaintEvent*) { style()->drawControl(QStyle::CE_MenuItem, &option, &painter, 0); } } + + QStyleOptionSizeGrip sizeGripOption; + sizeGripOption.init(this); + sizeGripOption.corner = Qt::BottomRightCorner; + style()->drawControl(QStyle::CE_SizeGrip, &sizeGripOption, &painter, this); } void QtGridSelectionDialog::showEvent(QShowEvent*) { -- cgit v0.10.2-6-g49f6