mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-01-25 14:07:44 -05:00
Support RTL layout in LineEdit.
This commit is contained in:
parent
adbce87ccd
commit
3f4f9abb36
3
COPYING
3
COPYING
@ -20,6 +20,7 @@ Source: http://www.keepassx.org/
|
|||||||
|
|
||||||
Copyright: 2010-2012, Felix Geyer <debfx@fobos.de>
|
Copyright: 2010-2012, Felix Geyer <debfx@fobos.de>
|
||||||
2011-2012, Florian Geyer <blueice@fobos.de>
|
2011-2012, Florian Geyer <blueice@fobos.de>
|
||||||
|
2007, Trolltech ASA <info@trolltech.com>
|
||||||
License: GPL-2 or GPL-3
|
License: GPL-2 or GPL-3
|
||||||
|
|
||||||
Files: share/icons/database/*.png
|
Files: share/icons/database/*.png
|
||||||
@ -59,6 +60,8 @@ Files: share/icons/application/*/actions/application-exit.png,
|
|||||||
share/icons/application/*/actions/document-open.png,
|
share/icons/application/*/actions/document-open.png,
|
||||||
share/icons/application/*/actions/document-save.png,
|
share/icons/application/*/actions/document-save.png,
|
||||||
share/icons/application/*/actions/document-save-as.png,
|
share/icons/application/*/actions/document-save-as.png,
|
||||||
|
share/icons/application/*/actions/edit-clear-locationbar-ltr.png,
|
||||||
|
share/icons/application/*/actions/edit-clear-locationbar-rtl.png,
|
||||||
share/icons/application/*/actions/system-search.png,
|
share/icons/application/*/actions/system-search.png,
|
||||||
share/icons/application/*/status/dialog-error.png,
|
share/icons/application/*/status/dialog-error.png,
|
||||||
share/icons/application/*/status/dialog-information.png,
|
share/icons/application/*/status/dialog-information.png,
|
||||||
|
Binary file not shown.
After Width: | Height: | Size: 793 B |
Binary file not shown.
After Width: | Height: | Size: 579 B |
Binary file not shown.
Before Width: | Height: | Size: 750 B |
@ -1,16 +1,26 @@
|
|||||||
/****************************************************************************
|
/*
|
||||||
**
|
* Copyright (C) 2007 Trolltech ASA <info@trolltech.com>
|
||||||
** Copyright (c) 2007 Trolltech ASA <info@trolltech.com>
|
* Copyright (C) 2012 Felix Geyer <debfx@fobos.de>
|
||||||
**
|
* Copyright (C) 2012 Florian Geyer <blueice@fobos.de>
|
||||||
** Use, modification and distribution is allowed without limitation,
|
*
|
||||||
** warranty, liability or support of any kind.
|
* This program is free software: you can redistribute it and/or modify
|
||||||
**
|
* it under the terms of the GNU General Public License as published by
|
||||||
****************************************************************************/
|
* the Free Software Foundation, either version 2 or (at your option)
|
||||||
|
* version 3 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
#include "LineEdit.h"
|
#include "LineEdit.h"
|
||||||
|
|
||||||
#include <QtGui/QToolButton>
|
|
||||||
#include <QtGui/QStyle>
|
#include <QtGui/QStyle>
|
||||||
|
#include <QtGui/QToolButton>
|
||||||
|
|
||||||
#include "core/DataPath.h"
|
#include "core/DataPath.h"
|
||||||
|
|
||||||
@ -19,7 +29,18 @@ LineEdit::LineEdit(QWidget* parent)
|
|||||||
{
|
{
|
||||||
m_clearButton = new QToolButton(this);
|
m_clearButton = new QToolButton(this);
|
||||||
m_clearButton->setObjectName("clearButton");
|
m_clearButton->setObjectName("clearButton");
|
||||||
QIcon icon = dataPath()->icon("actions", "edit-clear-locationbar-rtl");
|
|
||||||
|
QIcon icon;
|
||||||
|
QString iconNameDirected = QString("edit-clear-locationbar-").append(
|
||||||
|
(layoutDirection() == Qt::LeftToRight) ? "rtl" : "ltr");
|
||||||
|
icon = QIcon::fromTheme(iconNameDirected);
|
||||||
|
if (icon.isNull()) {
|
||||||
|
icon = QIcon::fromTheme("edit-clear");
|
||||||
|
if (icon.isNull()) {
|
||||||
|
icon = dataPath()->icon("actions", iconNameDirected, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
m_clearButton->setIcon(icon);
|
m_clearButton->setIcon(icon);
|
||||||
m_clearButton->setCursor(Qt::ArrowCursor);
|
m_clearButton->setCursor(Qt::ArrowCursor);
|
||||||
m_clearButton->setStyleSheet("QToolButton { border: none; padding: 0px; }");
|
m_clearButton->setStyleSheet("QToolButton { border: none; padding: 0px; }");
|
||||||
@ -36,12 +57,18 @@ LineEdit::LineEdit(QWidget* parent)
|
|||||||
|
|
||||||
void LineEdit::resizeEvent(QResizeEvent* event)
|
void LineEdit::resizeEvent(QResizeEvent* event)
|
||||||
{
|
{
|
||||||
Q_UNUSED(event);
|
|
||||||
|
|
||||||
QSize sz = m_clearButton->sizeHint();
|
QSize sz = m_clearButton->sizeHint();
|
||||||
int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
|
int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
|
||||||
m_clearButton->move(rect().right() - frameWidth - sz.width(),
|
int y = (rect().bottom() + 1 - sz.height()) / 2;
|
||||||
(rect().bottom() + 1 - sz.height())/2);
|
|
||||||
|
if (layoutDirection() == Qt::LeftToRight) {
|
||||||
|
m_clearButton->move(rect().right() - frameWidth - sz.width(), y);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
m_clearButton->move(rect().left() + frameWidth, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
QLineEdit::resizeEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LineEdit::updateCloseButton(const QString& text)
|
void LineEdit::updateCloseButton(const QString& text)
|
||||||
|
@ -1,11 +1,21 @@
|
|||||||
/****************************************************************************
|
/*
|
||||||
**
|
* Copyright (C) 2007 Trolltech ASA <info@trolltech.com>
|
||||||
** Copyright (c) 2007 Trolltech ASA <info@trolltech.com>
|
* Copyright (C) 2012 Felix Geyer <debfx@fobos.de>
|
||||||
**
|
* Copyright (C) 2012 Florian Geyer <blueice@fobos.de>
|
||||||
** Use, modification and distribution is allowed without limitation,
|
*
|
||||||
** warranty, liability or support of any kind.
|
* This program is free software: you can redistribute it and/or modify
|
||||||
**
|
* it under the terms of the GNU General Public License as published by
|
||||||
****************************************************************************/
|
* the Free Software Foundation, either version 2 or (at your option)
|
||||||
|
* version 3 of the License.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef KEEPASSX_LINEEDIT_H
|
#ifndef KEEPASSX_LINEEDIT_H
|
||||||
#define KEEPASSX_LINEEDIT_H
|
#define KEEPASSX_LINEEDIT_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user