diff options
author | Tobias Markmann <tm@ayena.de> | 2015-04-02 12:52:49 (GMT) |
---|---|---|
committer | Kevin Smith <kevin.smith@isode.com> | 2015-04-03 11:47:17 (GMT) |
commit | 33fabd0c800dd7eeadfb6b98e4d0d76551380094 (patch) | |
tree | e827b853a9f68e1d59aecd936af2cfff97e69000 | |
parent | 6a97629d10651c65936f5b8fb47334df083fc546 (diff) | |
download | swift-33fabd0c800dd7eeadfb6b98e4d0d76551380094.zip swift-33fabd0c800dd7eeadfb6b98e4d0d76551380094.tar.bz2 |
Fix vertical alignment of close button in QtClosableLineEdit
Test-Information:
Tested vertical alignment of close button on OS X, Windows 7 and
Elementary OS.
Change-Id: Ia07a8476912674c94d851315f80630710e5f4217
-rw-r--r-- | Swift/QtUI/QtClosableLineEdit.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/Swift/QtUI/QtClosableLineEdit.cpp b/Swift/QtUI/QtClosableLineEdit.cpp index 6523b6b..414463a 100644 --- a/Swift/QtUI/QtClosableLineEdit.cpp +++ b/Swift/QtUI/QtClosableLineEdit.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Isode Limited. + * Copyright (c) 2014-2015 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ @@ -15,10 +15,12 @@ ****************************************************************************/ #include <Swift/QtUI/QtClosableLineEdit.h> + #include <QApplication> -#include <QToolButton> -#include <QStyle> #include <QKeyEvent> +#include <QStyle> +#include <QToolButton> +#include <QtGlobal> namespace Swift { @@ -43,7 +45,12 @@ QtClosableLineEdit::QtClosableLineEdit(QWidget *parent) : QLineEdit(parent) { void QtClosableLineEdit::resizeEvent(QResizeEvent *) { QSize size = clearButton->sizeHint(); int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth); - clearButton->move(rect().right() - frameWidth - size.width(), (rect().bottom() + 1 - size.height())/2); + int verticalAdjustment = 1; +#if defined(Q_OS_WIN32) + // This vertical adjustment is required on Windows so the close button is vertically centered in the line edit. + verticalAdjustment += 2; +#endif + clearButton->move(rect().right() - frameWidth - size.width(), (rect().bottom() + verticalAdjustment - size.height())/2); } void QtClosableLineEdit::updateCloseButton(const QString& text) { |