mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-12-16 08:54:30 -05:00
Replace deprecated foreground() by windowText()
This commit is contained in:
parent
e1471cbd19
commit
c669ecb4dd
1 changed files with 34 additions and 34 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
/* This file is part of the KDE libraries
|
/* This file is part of the KDE libraries
|
||||||
*
|
*
|
||||||
* Copyright (c) 2011 Aurélien Gâteau <agateau@kde.org>
|
* Copyright (c) 2011 Aurélien Gâteau <agateau@kde.org>
|
||||||
* Copyright (c) 2014 Dominik Haumann <dhaumann@kde.org>
|
* Copyright (c) 2014 Dominik Haumann <dhaumann@kde.org>
|
||||||
*
|
*
|
||||||
|
|
@ -42,7 +42,7 @@ class KMessageWidgetPrivate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void init(KMessageWidget *);
|
void init(KMessageWidget *);
|
||||||
|
|
||||||
KMessageWidget *q;
|
KMessageWidget *q;
|
||||||
QFrame *content;
|
QFrame *content;
|
||||||
QLabel *iconLabel;
|
QLabel *iconLabel;
|
||||||
|
|
@ -51,51 +51,51 @@ public:
|
||||||
QTimeLine *timeLine;
|
QTimeLine *timeLine;
|
||||||
QIcon icon;
|
QIcon icon;
|
||||||
QPixmap closeButtonPixmap;
|
QPixmap closeButtonPixmap;
|
||||||
|
|
||||||
KMessageWidget::MessageType messageType;
|
KMessageWidget::MessageType messageType;
|
||||||
bool wordWrap;
|
bool wordWrap;
|
||||||
QList<QToolButton *> buttons;
|
QList<QToolButton *> buttons;
|
||||||
QPixmap contentSnapShot;
|
QPixmap contentSnapShot;
|
||||||
|
|
||||||
void createLayout();
|
void createLayout();
|
||||||
void updateSnapShot();
|
void updateSnapShot();
|
||||||
void updateLayout();
|
void updateLayout();
|
||||||
void slotTimeLineChanged(qreal);
|
void slotTimeLineChanged(qreal);
|
||||||
void slotTimeLineFinished();
|
void slotTimeLineFinished();
|
||||||
|
|
||||||
int bestContentHeight() const;
|
int bestContentHeight() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
void KMessageWidgetPrivate::init(KMessageWidget *q_ptr)
|
void KMessageWidgetPrivate::init(KMessageWidget *q_ptr)
|
||||||
{
|
{
|
||||||
q = q_ptr;
|
q = q_ptr;
|
||||||
|
|
||||||
q->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
|
q->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
|
||||||
|
|
||||||
timeLine = new QTimeLine(500, q);
|
timeLine = new QTimeLine(500, q);
|
||||||
QObject::connect(timeLine, SIGNAL(valueChanged(qreal)), q, SLOT(slotTimeLineChanged(qreal)));
|
QObject::connect(timeLine, SIGNAL(valueChanged(qreal)), q, SLOT(slotTimeLineChanged(qreal)));
|
||||||
QObject::connect(timeLine, SIGNAL(finished()), q, SLOT(slotTimeLineFinished()));
|
QObject::connect(timeLine, SIGNAL(finished()), q, SLOT(slotTimeLineFinished()));
|
||||||
|
|
||||||
content = new QFrame(q);
|
content = new QFrame(q);
|
||||||
content->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
content->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||||
|
|
||||||
wordWrap = false;
|
wordWrap = false;
|
||||||
|
|
||||||
iconLabel = new QLabel(content);
|
iconLabel = new QLabel(content);
|
||||||
iconLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
iconLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||||
iconLabel->hide();
|
iconLabel->hide();
|
||||||
|
|
||||||
textLabel = new QLabel(content);
|
textLabel = new QLabel(content);
|
||||||
textLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
textLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||||
textLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
|
textLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
|
||||||
QObject::connect(textLabel, SIGNAL(linkActivated(QString)), q, SIGNAL(linkActivated(QString)));
|
QObject::connect(textLabel, SIGNAL(linkActivated(QString)), q, SIGNAL(linkActivated(QString)));
|
||||||
QObject::connect(textLabel, SIGNAL(linkHovered(QString)), q, SIGNAL(linkHovered(QString)));
|
QObject::connect(textLabel, SIGNAL(linkHovered(QString)), q, SIGNAL(linkHovered(QString)));
|
||||||
|
|
||||||
QAction *closeAction = new QAction(q);
|
QAction *closeAction = new QAction(q);
|
||||||
closeAction->setText(KMessageWidget::tr("&Close"));
|
closeAction->setText(KMessageWidget::tr("&Close"));
|
||||||
closeAction->setToolTip(KMessageWidget::tr("Close message"));
|
closeAction->setToolTip(KMessageWidget::tr("Close message"));
|
||||||
closeAction->setIcon(FilePath::instance()->icon("actions", "message-close", false));
|
closeAction->setIcon(FilePath::instance()->icon("actions", "message-close", false));
|
||||||
|
|
||||||
QObject::connect(closeAction, SIGNAL(triggered(bool)), q, SLOT(animatedHide()));
|
QObject::connect(closeAction, SIGNAL(triggered(bool)), q, SLOT(animatedHide()));
|
||||||
|
|
||||||
closeButton = new QToolButton(content);
|
closeButton = new QToolButton(content);
|
||||||
|
|
@ -108,19 +108,19 @@ void KMessageWidgetPrivate::init(KMessageWidget *q_ptr)
|
||||||
"QToolButton::hover, QToolButton::focus {"
|
"QToolButton::hover, QToolButton::focus {"
|
||||||
"border: 1px solid rgb(90, 200, 250); }");
|
"border: 1px solid rgb(90, 200, 250); }");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
q->setMessageType(KMessageWidget::Information);
|
q->setMessageType(KMessageWidget::Information);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KMessageWidgetPrivate::createLayout()
|
void KMessageWidgetPrivate::createLayout()
|
||||||
{
|
{
|
||||||
delete content->layout();
|
delete content->layout();
|
||||||
|
|
||||||
content->resize(q->size());
|
content->resize(q->size());
|
||||||
|
|
||||||
qDeleteAll(buttons);
|
qDeleteAll(buttons);
|
||||||
buttons.clear();
|
buttons.clear();
|
||||||
|
|
||||||
const auto actions = q->actions();
|
const auto actions = q->actions();
|
||||||
for (QAction *action: actions) {
|
for (QAction *action: actions) {
|
||||||
QToolButton *button = new QToolButton(content);
|
QToolButton *button = new QToolButton(content);
|
||||||
|
|
@ -128,18 +128,18 @@ void KMessageWidgetPrivate::createLayout()
|
||||||
button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
|
button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
|
||||||
buttons.append(button);
|
buttons.append(button);
|
||||||
}
|
}
|
||||||
|
|
||||||
// AutoRaise reduces visual clutter, but we don't want to turn it on if
|
// AutoRaise reduces visual clutter, but we don't want to turn it on if
|
||||||
// there are other buttons, otherwise the close button will look different
|
// there are other buttons, otherwise the close button will look different
|
||||||
// from the others.
|
// from the others.
|
||||||
closeButton->setAutoRaise(buttons.isEmpty());
|
closeButton->setAutoRaise(buttons.isEmpty());
|
||||||
|
|
||||||
if (wordWrap) {
|
if (wordWrap) {
|
||||||
QGridLayout *layout = new QGridLayout(content);
|
QGridLayout *layout = new QGridLayout(content);
|
||||||
// Set alignment to make sure icon does not move down if text wraps
|
// Set alignment to make sure icon does not move down if text wraps
|
||||||
layout->addWidget(iconLabel, 0, 0, 1, 1, Qt::AlignHCenter | Qt::AlignTop);
|
layout->addWidget(iconLabel, 0, 0, 1, 1, Qt::AlignHCenter | Qt::AlignTop);
|
||||||
layout->addWidget(textLabel, 0, 1);
|
layout->addWidget(textLabel, 0, 1);
|
||||||
|
|
||||||
QHBoxLayout *buttonLayout = new QHBoxLayout;
|
QHBoxLayout *buttonLayout = new QHBoxLayout;
|
||||||
buttonLayout->addStretch();
|
buttonLayout->addStretch();
|
||||||
for (QToolButton* button: asConst(buttons)) {
|
for (QToolButton* button: asConst(buttons)) {
|
||||||
|
|
@ -155,14 +155,14 @@ void KMessageWidgetPrivate::createLayout()
|
||||||
QHBoxLayout *layout = new QHBoxLayout(content);
|
QHBoxLayout *layout = new QHBoxLayout(content);
|
||||||
layout->addWidget(iconLabel);
|
layout->addWidget(iconLabel);
|
||||||
layout->addWidget(textLabel);
|
layout->addWidget(textLabel);
|
||||||
|
|
||||||
for (QToolButton* button: asConst(buttons)) {
|
for (QToolButton* button: asConst(buttons)) {
|
||||||
layout->addWidget(button);
|
layout->addWidget(button);
|
||||||
}
|
}
|
||||||
|
|
||||||
layout->addWidget(closeButton);
|
layout->addWidget(closeButton);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (q->isVisible()) {
|
if (q->isVisible()) {
|
||||||
q->setFixedHeight(content->sizeHint().height());
|
q->setFixedHeight(content->sizeHint().height());
|
||||||
}
|
}
|
||||||
|
|
@ -201,7 +201,7 @@ void KMessageWidgetPrivate::slotTimeLineFinished()
|
||||||
// We set the whole geometry here, because it may be wrong if a
|
// We set the whole geometry here, because it may be wrong if a
|
||||||
// KMessageWidget is shown right when the toplevel window is created.
|
// KMessageWidget is shown right when the toplevel window is created.
|
||||||
content->setGeometry(0, 0, q->width(), bestContentHeight());
|
content->setGeometry(0, 0, q->width(), bestContentHeight());
|
||||||
|
|
||||||
// notify about finished animation
|
// notify about finished animation
|
||||||
emit q->showAnimationFinished();
|
emit q->showAnimationFinished();
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -273,7 +273,7 @@ void KMessageWidget::setMessageType(KMessageWidget::MessageType type)
|
||||||
break;
|
break;
|
||||||
case Warning:
|
case Warning:
|
||||||
bg1.setRgb(252, 193, 57);
|
bg1.setRgb(252, 193, 57);
|
||||||
fg = palette().foreground().color();
|
fg = palette().windowText().color();
|
||||||
break;
|
break;
|
||||||
case Error:
|
case Error:
|
||||||
bg1.setRgb(198, 69, 21);
|
bg1.setRgb(198, 69, 21);
|
||||||
|
|
@ -294,7 +294,7 @@ void KMessageWidget::setMessageType(KMessageWidget::MessageType type)
|
||||||
painter.fillRect(QRect(0, 0, 16, 16), fg);
|
painter.fillRect(QRect(0, 0, 16, 16), fg);
|
||||||
painter.end();
|
painter.end();
|
||||||
d->closeButton->setIcon(closeButtonPixmap);
|
d->closeButton->setIcon(closeButtonPixmap);
|
||||||
|
|
||||||
d->content->setStyleSheet(
|
d->content->setStyleSheet(
|
||||||
QString(QLatin1String(".QFrame {"
|
QString(QLatin1String(".QFrame {"
|
||||||
"background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,"
|
"background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,"
|
||||||
|
|
@ -342,7 +342,7 @@ bool KMessageWidget::event(QEvent *event)
|
||||||
void KMessageWidget::resizeEvent(QResizeEvent *event)
|
void KMessageWidget::resizeEvent(QResizeEvent *event)
|
||||||
{
|
{
|
||||||
QFrame::resizeEvent(event);
|
QFrame::resizeEvent(event);
|
||||||
|
|
||||||
if (d->timeLine->state() == QTimeLine::NotRunning) {
|
if (d->timeLine->state() == QTimeLine::NotRunning) {
|
||||||
d->content->resize(width(), d->bestContentHeight());
|
d->content->resize(width(), d->bestContentHeight());
|
||||||
}
|
}
|
||||||
|
|
@ -415,18 +415,18 @@ void KMessageWidget::animatedShow()
|
||||||
emit showAnimationFinished();
|
emit showAnimationFinished();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isVisible()) {
|
if (isVisible()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QFrame::show();
|
QFrame::show();
|
||||||
setFixedHeight(0);
|
setFixedHeight(0);
|
||||||
int wantedHeight = d->bestContentHeight();
|
int wantedHeight = d->bestContentHeight();
|
||||||
d->content->setGeometry(0, -wantedHeight, width(), wantedHeight);
|
d->content->setGeometry(0, -wantedHeight, width(), wantedHeight);
|
||||||
|
|
||||||
d->updateSnapShot();
|
d->updateSnapShot();
|
||||||
|
|
||||||
d->timeLine->setDirection(QTimeLine::Forward);
|
d->timeLine->setDirection(QTimeLine::Forward);
|
||||||
if (d->timeLine->state() == QTimeLine::NotRunning) {
|
if (d->timeLine->state() == QTimeLine::NotRunning) {
|
||||||
d->timeLine->start();
|
d->timeLine->start();
|
||||||
|
|
@ -440,15 +440,15 @@ void KMessageWidget::animatedHide()
|
||||||
emit hideAnimationFinished();
|
emit hideAnimationFinished();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isVisible()) {
|
if (!isVisible()) {
|
||||||
hide();
|
hide();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
d->content->move(0, -d->content->height());
|
d->content->move(0, -d->content->height());
|
||||||
d->updateSnapShot();
|
d->updateSnapShot();
|
||||||
|
|
||||||
d->timeLine->setDirection(QTimeLine::Backward);
|
d->timeLine->setDirection(QTimeLine::Backward);
|
||||||
if (d->timeLine->state() == QTimeLine::NotRunning) {
|
if (d->timeLine->state() == QTimeLine::NotRunning) {
|
||||||
d->timeLine->start();
|
d->timeLine->start();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue