Ability to disable animation of message widget

* Allows for persistent messages that can change text without disturbing the user interface
* Immediate improvement to KeeShare group edit window
This commit is contained in:
Jonathan White 2020-03-15 09:44:28 -04:00
parent 7ef1ee916b
commit 730367557f
3 changed files with 26 additions and 2 deletions

View File

@ -36,6 +36,11 @@ MessageWidget::MessageWidget(QWidget* parent)
connect(this, SIGNAL(hideAnimationFinished()), m_autoHideTimer, SLOT(stop()));
}
void MessageWidget::setAnimate(bool state)
{
m_animate = state;
}
int MessageWidget::autoHideTimeout() const
{
return m_autoHideTimeout;
@ -50,8 +55,15 @@ void MessageWidget::showMessage(const QString& text, KMessageWidget::MessageType
{
setMessageType(type);
setText(text);
emit showAnimationStarted();
animatedShow();
if (m_animate) {
animatedShow();
} else {
show();
emit showAnimationFinished();
}
if (autoHideTimeout > 0) {
m_autoHideTimer->start(autoHideTimeout);
} else {
@ -61,7 +73,14 @@ void MessageWidget::showMessage(const QString& text, KMessageWidget::MessageType
void MessageWidget::hideMessage()
{
animatedHide();
emit hideAnimationStarted();
if (m_animate) {
animatedHide();
} else {
hide();
emit hideAnimationFinished();
}
m_autoHideTimer->stop();
}

View File

@ -36,8 +36,11 @@ public:
static const int LongAutoHideTimeout;
static const int DisableAutoHide;
void setAnimate(bool state);
signals:
void showAnimationStarted();
void hideAnimationStarted();
public slots:
void showMessage(const QString& text, MessageWidget::MessageType type);
@ -49,6 +52,7 @@ public slots:
private:
QTimer* m_autoHideTimer;
int m_autoHideTimeout;
bool m_animate;
};
#endif // MESSAGEWIDGET_H

View File

@ -39,6 +39,7 @@ EditGroupWidgetKeeShare::EditGroupWidgetKeeShare(QWidget* parent)
m_ui->messageWidget->hide();
m_ui->messageWidget->setCloseButtonVisible(false);
m_ui->messageWidget->setAutoHideTimeout(-1);
m_ui->messageWidget->setAnimate(false);
m_ui->passwordEdit->enablePasswordGenerator();