mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-02-17 21:04:19 -05:00
Add the auto hide functionality to the MessageWidget
This commit is contained in:
parent
1374c68274
commit
75cfe1c5dd
@ -18,20 +18,50 @@
|
|||||||
|
|
||||||
#include "MessageWidget.h"
|
#include "MessageWidget.h"
|
||||||
|
|
||||||
MessageWidget::MessageWidget(QWidget* parent)
|
#include "QTimer"
|
||||||
:KMessageWidget(parent)
|
|
||||||
{
|
|
||||||
|
|
||||||
|
MessageWidget::MessageWidget(QWidget* parent)
|
||||||
|
: KMessageWidget(parent)
|
||||||
|
, m_autoHideTimer(new QTimer(this))
|
||||||
|
, m_autoHideTimeout(6000)
|
||||||
|
{
|
||||||
|
m_autoHideTimer->setSingleShot(true);
|
||||||
|
connect(m_autoHideTimer, SIGNAL(timeout()), this, SLOT(animatedHide()));
|
||||||
|
connect(this, SIGNAL(hideAnimationFinished()), m_autoHideTimer, SLOT(stop()));
|
||||||
|
}
|
||||||
|
|
||||||
|
int MessageWidget::autoHideTimeout() const
|
||||||
|
{
|
||||||
|
return m_autoHideTimeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageWidget::showMessage(const QString& text, MessageWidget::MessageType type)
|
void MessageWidget::showMessage(const QString& text, MessageWidget::MessageType type)
|
||||||
|
{
|
||||||
|
showMessage(text, type, m_autoHideTimeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MessageWidget::showMessage(const QString &text, KMessageWidget::MessageType type, int autoHideTimeout)
|
||||||
{
|
{
|
||||||
setMessageType(type);
|
setMessageType(type);
|
||||||
setText(text);
|
setText(text);
|
||||||
animatedShow();
|
animatedShow();
|
||||||
|
if (autoHideTimeout > 0) {
|
||||||
|
m_autoHideTimer->start(autoHideTimeout);
|
||||||
|
} else {
|
||||||
|
m_autoHideTimer->stop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageWidget::hideMessage()
|
void MessageWidget::hideMessage()
|
||||||
{
|
{
|
||||||
animatedHide();
|
animatedHide();
|
||||||
|
m_autoHideTimer->stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MessageWidget::setAutoHideTimeout(int autoHideTimeout)
|
||||||
|
{
|
||||||
|
m_autoHideTimeout = autoHideTimeout;
|
||||||
|
if (autoHideTimeout <= 0) {
|
||||||
|
m_autoHideTimer->stop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
|
|
||||||
#include "gui/KMessageWidget.h"
|
#include "gui/KMessageWidget.h"
|
||||||
|
|
||||||
|
class QTimer;
|
||||||
|
|
||||||
class MessageWidget : public KMessageWidget
|
class MessageWidget : public KMessageWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -28,10 +30,17 @@ class MessageWidget : public KMessageWidget
|
|||||||
public:
|
public:
|
||||||
explicit MessageWidget(QWidget* parent = 0);
|
explicit MessageWidget(QWidget* parent = 0);
|
||||||
|
|
||||||
|
int autoHideTimeout() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void showMessage(const QString& text, MessageWidget::MessageType type);
|
void showMessage(const QString& text, MessageWidget::MessageType type);
|
||||||
|
void showMessage(const QString& text, MessageWidget::MessageType type, int autoHideTimeout);
|
||||||
void hideMessage();
|
void hideMessage();
|
||||||
|
void setAutoHideTimeout(int autoHideTimeout);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QTimer* m_autoHideTimer;
|
||||||
|
int m_autoHideTimeout;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MESSAGEWIDGET_H
|
#endif // MESSAGEWIDGET_H
|
||||||
|
@ -35,6 +35,7 @@ OptionDialog::OptionDialog(QWidget *parent) :
|
|||||||
m_ui->warningWidget->showMessage(tr("The following options can be dangerous!\nChange them only if you know what you are doing."), MessageWidget::Warning);
|
m_ui->warningWidget->showMessage(tr("The following options can be dangerous!\nChange them only if you know what you are doing."), MessageWidget::Warning);
|
||||||
m_ui->warningWidget->setIcon(FilePath::instance()->icon("status", "dialog-warning"));
|
m_ui->warningWidget->setIcon(FilePath::instance()->icon("status", "dialog-warning"));
|
||||||
m_ui->warningWidget->setCloseButtonVisible(false);
|
m_ui->warningWidget->setCloseButtonVisible(false);
|
||||||
|
m_ui->warningWidget->setAutoHideTimeout(-1);
|
||||||
|
|
||||||
m_ui->tabWidget->setEnabled(m_ui->enableHttpServer->isChecked());
|
m_ui->tabWidget->setEnabled(m_ui->enableHttpServer->isChecked());
|
||||||
connect(m_ui->enableHttpServer, SIGNAL(toggled(bool)), m_ui->tabWidget, SLOT(setEnabled(bool)));
|
connect(m_ui->enableHttpServer, SIGNAL(toggled(bool)), m_ui->tabWidget, SLOT(setEnabled(bool)));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user