mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-02-04 17:05:23 -05:00
Merge pull request #1059 from frostasm/add-auto-hide-functionality-to-inline-message-widget
Add auto hide functionality to inline message widget (#1006)
This commit is contained in:
commit
7cc6f6f2a3
@ -1325,9 +1325,10 @@ void DatabaseWidget::closeUnlockDialog()
|
|||||||
m_unlockDatabaseDialog->close();
|
m_unlockDatabaseDialog->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DatabaseWidget::showMessage(const QString& text, MessageWidget::MessageType type)
|
void DatabaseWidget::showMessage(const QString& text, MessageWidget::MessageType type, bool showClosebutton, int autoHideTimeout)
|
||||||
{
|
{
|
||||||
m_messageWidget->showMessage(text, type);
|
m_messageWidget->setCloseButtonVisible(showClosebutton);
|
||||||
|
m_messageWidget->showMessage(text, type, autoHideTimeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DatabaseWidget::hideMessage()
|
void DatabaseWidget::hideMessage()
|
||||||
|
@ -166,7 +166,8 @@ public slots:
|
|||||||
void setSearchLimitGroup(bool state);
|
void setSearchLimitGroup(bool state);
|
||||||
void endSearch();
|
void endSearch();
|
||||||
|
|
||||||
void showMessage(const QString& text, MessageWidget::MessageType type);
|
void showMessage(const QString& text, MessageWidget::MessageType type, bool showClosebutton = true,
|
||||||
|
int autoHideTimeout = MessageWidget::DefaultAutoHideTimeout);
|
||||||
void hideMessage();
|
void hideMessage();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
@ -952,16 +952,17 @@ bool MainWindow::isTrayIconEnabled() const
|
|||||||
&& QSystemTrayIcon::isSystemTrayAvailable();
|
&& QSystemTrayIcon::isSystemTrayAvailable();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::displayGlobalMessage(const QString& text, MessageWidget::MessageType type, bool showClosebutton)
|
void MainWindow::displayGlobalMessage(const QString& text, MessageWidget::MessageType type, bool showClosebutton,
|
||||||
|
int autoHideTimeout)
|
||||||
{
|
{
|
||||||
m_ui->globalMessageWidget->setCloseButtonVisible(showClosebutton);
|
m_ui->globalMessageWidget->setCloseButtonVisible(showClosebutton);
|
||||||
m_ui->globalMessageWidget->showMessage(text, type);
|
m_ui->globalMessageWidget->showMessage(text, type, autoHideTimeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::displayTabMessage(const QString& text, MessageWidget::MessageType type, bool showClosebutton)
|
void MainWindow::displayTabMessage(const QString& text, MessageWidget::MessageType type, bool showClosebutton,
|
||||||
|
int autoHideTimeout)
|
||||||
{
|
{
|
||||||
m_ui->globalMessageWidget->setCloseButtonVisible(showClosebutton);
|
m_ui->tabWidget->currentDatabaseWidget()->showMessage(text, type, showClosebutton, autoHideTimeout);
|
||||||
m_ui->tabWidget->currentDatabaseWidget()->showMessage(text, type);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::hideGlobalMessage()
|
void MainWindow::hideGlobalMessage()
|
||||||
@ -978,7 +979,8 @@ void MainWindow::hideTabMessage()
|
|||||||
|
|
||||||
void MainWindow::showYubiKeyPopup()
|
void MainWindow::showYubiKeyPopup()
|
||||||
{
|
{
|
||||||
displayGlobalMessage(tr("Please touch the button on your YubiKey!"), MessageWidget::Information, false);
|
displayGlobalMessage(tr("Please touch the button on your YubiKey!"), MessageWidget::Information,
|
||||||
|
false, MessageWidget::DisableAutoHide);
|
||||||
setEnabled(false);
|
setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,8 +54,10 @@ public slots:
|
|||||||
void openDatabase(const QString& fileName, const QString& pw = QString(),
|
void openDatabase(const QString& fileName, const QString& pw = QString(),
|
||||||
const QString& keyFile = QString());
|
const QString& keyFile = QString());
|
||||||
void appExit();
|
void appExit();
|
||||||
void displayGlobalMessage(const QString& text, MessageWidget::MessageType type, bool showClosebutton = true);
|
void displayGlobalMessage(const QString& text, MessageWidget::MessageType type, bool showClosebutton = true,
|
||||||
void displayTabMessage(const QString& text, MessageWidget::MessageType type, bool showClosebutton = true);
|
int autoHideTimeout = MessageWidget::DefaultAutoHideTimeout);
|
||||||
|
void displayTabMessage(const QString& text, MessageWidget::MessageType type, bool showClosebutton = true,
|
||||||
|
int autoHideTimeout = MessageWidget::DefaultAutoHideTimeout);
|
||||||
void hideGlobalMessage();
|
void hideGlobalMessage();
|
||||||
void showYubiKeyPopup();
|
void showYubiKeyPopup();
|
||||||
void hideYubiKeyPopup();
|
void hideYubiKeyPopup();
|
||||||
|
@ -18,20 +18,53 @@
|
|||||||
|
|
||||||
#include "MessageWidget.h"
|
#include "MessageWidget.h"
|
||||||
|
|
||||||
MessageWidget::MessageWidget(QWidget* parent)
|
#include "QTimer"
|
||||||
:KMessageWidget(parent)
|
|
||||||
{
|
|
||||||
|
|
||||||
|
const int MessageWidget::DefaultAutoHideTimeout = 6000;
|
||||||
|
const int MessageWidget::DisableAutoHide = -1;
|
||||||
|
|
||||||
|
MessageWidget::MessageWidget(QWidget* parent)
|
||||||
|
: KMessageWidget(parent)
|
||||||
|
, m_autoHideTimer(new QTimer(this))
|
||||||
|
, m_autoHideTimeout(DefaultAutoHideTimeout)
|
||||||
|
{
|
||||||
|
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,20 @@ class MessageWidget : public KMessageWidget
|
|||||||
public:
|
public:
|
||||||
explicit MessageWidget(QWidget* parent = 0);
|
explicit MessageWidget(QWidget* parent = 0);
|
||||||
|
|
||||||
|
int autoHideTimeout() const;
|
||||||
|
|
||||||
|
static const int DefaultAutoHideTimeout;
|
||||||
|
static const int DisableAutoHide;
|
||||||
|
|
||||||
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(MessageWidget::DisableAutoHide);
|
||||||
|
|
||||||
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