mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-25 19:07:45 +00:00
FancyLineEdit: reformat using our indentation style
No change in function
This commit is contained in:
parent
8a9c4ed58f
commit
05004e138f
@ -39,7 +39,12 @@ enum { margin = 6 };
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
// --------- FancyLineEditPrivate
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FancyLineEditPrivate
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class FancyLineEditPrivate : public QObject {
|
||||
public:
|
||||
explicit FancyLineEditPrivate(FancyLineEdit *parent);
|
||||
@ -55,9 +60,8 @@ public:
|
||||
};
|
||||
|
||||
|
||||
FancyLineEditPrivate::FancyLineEditPrivate(FancyLineEdit *parent) :
|
||||
QObject(parent),
|
||||
m_lineEdit(parent)
|
||||
FancyLineEditPrivate::FancyLineEditPrivate(FancyLineEdit *parent)
|
||||
: QObject(parent), m_lineEdit(parent)
|
||||
{
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
m_menu[i] = nullptr;
|
||||
@ -70,6 +74,7 @@ FancyLineEditPrivate::FancyLineEditPrivate(FancyLineEdit *parent) :
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool FancyLineEditPrivate::eventFilter(QObject *obj, QEvent *event)
|
||||
{
|
||||
int buttonIndex = -1;
|
||||
@ -96,7 +101,12 @@ bool FancyLineEditPrivate::eventFilter(QObject *obj, QEvent *event)
|
||||
}
|
||||
|
||||
|
||||
// --------- FancyLineEdit
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FancyLineEdit
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
FancyLineEdit::FancyLineEdit(QWidget *parent) :
|
||||
QLineEdit(parent),
|
||||
m_d(new FancyLineEditPrivate(this))
|
||||
@ -112,6 +122,7 @@ FancyLineEdit::FancyLineEdit(QWidget *parent) :
|
||||
this, SLOT(iconClicked()));
|
||||
}
|
||||
|
||||
|
||||
void FancyLineEdit::checkButtons(const QString &text)
|
||||
{
|
||||
if (m_oldText.isEmpty() || text.isEmpty()) {
|
||||
@ -123,6 +134,7 @@ void FancyLineEdit::checkButtons(const QString &text)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FancyLineEdit::setButtonVisible(Side side, bool visible)
|
||||
{
|
||||
m_d->m_iconbutton[side]->setVisible(visible);
|
||||
@ -130,11 +142,13 @@ void FancyLineEdit::setButtonVisible(Side side, bool visible)
|
||||
updateMargins();
|
||||
}
|
||||
|
||||
|
||||
bool FancyLineEdit::isButtonVisible(Side side) const
|
||||
{
|
||||
return m_d->m_iconEnabled[side];
|
||||
}
|
||||
|
||||
|
||||
void FancyLineEdit::iconClicked()
|
||||
{
|
||||
IconButton *button = qobject_cast<IconButton *>(sender());
|
||||
@ -155,6 +169,7 @@ void FancyLineEdit::iconClicked()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FancyLineEdit::updateMargins()
|
||||
{
|
||||
bool leftToRight = (layoutDirection() == Qt::LeftToRight);
|
||||
@ -175,6 +190,7 @@ void FancyLineEdit::updateMargins()
|
||||
setTextMargins(margins);
|
||||
}
|
||||
|
||||
|
||||
void FancyLineEdit::updateButtonPositions()
|
||||
{
|
||||
QRect contentRect = rect();
|
||||
@ -185,16 +201,19 @@ void FancyLineEdit::updateButtonPositions()
|
||||
|
||||
if (iconpos == FancyLineEdit::Right) {
|
||||
const int iconoffset = textMargins().right() + 4;
|
||||
m_d->m_iconbutton[i]->
|
||||
setGeometry(contentRect.adjusted(width() - iconoffset, 0, 0, 0));
|
||||
m_d->m_iconbutton[i]->setGeometry(
|
||||
contentRect.adjusted(width() - iconoffset,
|
||||
0, 0, 0));
|
||||
} else {
|
||||
const int iconoffset = textMargins().left() + 4;
|
||||
m_d->m_iconbutton[i]->
|
||||
setGeometry(contentRect.adjusted(0, 0, -width() + iconoffset, 0));
|
||||
m_d->m_iconbutton[i]->setGeometry(
|
||||
contentRect.adjusted(0, 0,
|
||||
-width() + iconoffset, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FancyLineEdit::resizeEvent(QResizeEvent *)
|
||||
{
|
||||
updateButtonPositions();
|
||||
@ -218,27 +237,31 @@ void FancyLineEdit::setButtonPixmap(Side side, const QPixmap &buttonPixmap)
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
QPixmap FancyLineEdit::buttonPixmap(Side side) const
|
||||
{
|
||||
return m_d->m_pixmap[side];
|
||||
}
|
||||
|
||||
|
||||
void FancyLineEdit::setButtonMenu(Side side, QMenu *buttonMenu)
|
||||
{
|
||||
m_d->m_menu[side] = buttonMenu;
|
||||
m_d->m_iconbutton[side]->setIconOpacity(1.0);
|
||||
}
|
||||
}
|
||||
|
||||
QMenu *FancyLineEdit::buttonMenu(Side side) const
|
||||
{
|
||||
return m_d->m_menu[side];
|
||||
}
|
||||
|
||||
|
||||
bool FancyLineEdit::hasMenuTabFocusTrigger(Side side) const
|
||||
{
|
||||
return m_d->m_menuTabFocusTrigger[side];
|
||||
}
|
||||
|
||||
|
||||
void FancyLineEdit::setMenuTabFocusTrigger(Side side, bool v)
|
||||
{
|
||||
if (m_d->m_menuTabFocusTrigger[side] == v)
|
||||
@ -248,11 +271,13 @@ void FancyLineEdit::setMenuTabFocusTrigger(Side side, bool v)
|
||||
m_d->m_iconbutton[side]->setFocusPolicy(v ? Qt::TabFocus : Qt::NoFocus);
|
||||
}
|
||||
|
||||
|
||||
bool FancyLineEdit::hasAutoHideButton(Side side) const
|
||||
{
|
||||
return m_d->m_iconbutton[side]->hasAutoHide();
|
||||
}
|
||||
|
||||
|
||||
void FancyLineEdit::setAutoHideButton(Side side, bool h)
|
||||
{
|
||||
m_d->m_iconbutton[side]->setAutoHide(h);
|
||||
@ -262,17 +287,24 @@ void FancyLineEdit::setAutoHideButton(Side side, bool h)
|
||||
m_d->m_iconbutton[side]->setIconOpacity(1.0);
|
||||
}
|
||||
|
||||
|
||||
void FancyLineEdit::setButtonToolTip(Side side, const QString &tip)
|
||||
{
|
||||
m_d->m_iconbutton[side]->setToolTip(tip);
|
||||
}
|
||||
|
||||
|
||||
void FancyLineEdit::setButtonFocusPolicy(Side side, Qt::FocusPolicy policy)
|
||||
{
|
||||
m_d->m_iconbutton[side]->setFocusPolicy(policy);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IconButton - helper class to represent a clickable icon
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
IconButton::IconButton(QWidget *parent)
|
||||
: QAbstractButton(parent), m_iconOpacity(0.0), m_autoHide(false)
|
||||
@ -281,6 +313,7 @@ IconButton::IconButton(QWidget *parent)
|
||||
setFocusPolicy(Qt::NoFocus);
|
||||
}
|
||||
|
||||
|
||||
void IconButton::paintEvent(QPaintEvent *)
|
||||
{
|
||||
QPainter painter(this);
|
||||
@ -293,6 +326,7 @@ void IconButton::paintEvent(QPaintEvent *)
|
||||
painter.drawPixmap(pixmapRect, m_pixmap);
|
||||
}
|
||||
|
||||
|
||||
void IconButton::animateShow(bool visible)
|
||||
{
|
||||
if (visible) {
|
||||
|
Loading…
Reference in New Issue
Block a user