Disable automatic hiding of an information message for YubiKey

This commit is contained in:
frostasm 2017-10-19 21:46:09 +03:00
parent 75cfe1c5dd
commit f38fe5a9dd
7 changed files with 25 additions and 13 deletions

View File

@ -1325,9 +1325,10 @@ void DatabaseWidget::closeUnlockDialog()
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()

View File

@ -166,7 +166,8 @@ public slots:
void setSearchLimitGroup(bool state);
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();
private slots:

View File

@ -952,16 +952,17 @@ bool MainWindow::isTrayIconEnabled() const
&& 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->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);
m_ui->tabWidget->currentDatabaseWidget()->showMessage(text, type, showClosebutton, autoHideTimeout);
}
void MainWindow::hideGlobalMessage()
@ -978,7 +979,8 @@ void MainWindow::hideTabMessage()
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);
}

View File

@ -54,8 +54,10 @@ public slots:
void openDatabase(const QString& fileName, const QString& pw = QString(),
const QString& keyFile = QString());
void appExit();
void displayGlobalMessage(const QString& text, MessageWidget::MessageType type, bool showClosebutton = true);
void displayTabMessage(const QString& text, MessageWidget::MessageType type, bool showClosebutton = true);
void displayGlobalMessage(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 showYubiKeyPopup();
void hideYubiKeyPopup();

View File

@ -20,10 +20,13 @@
#include "QTimer"
const int MessageWidget::DefaultAutoHideTimeout = 6000;
const int MessageWidget::DisableAutoHide = -1;
MessageWidget::MessageWidget(QWidget* parent)
: KMessageWidget(parent)
, m_autoHideTimer(new QTimer(this))
, m_autoHideTimeout(6000)
, m_autoHideTimeout(DefaultAutoHideTimeout)
{
m_autoHideTimer->setSingleShot(true);
connect(m_autoHideTimer, SIGNAL(timeout()), this, SLOT(animatedHide()));

View File

@ -32,6 +32,9 @@ public:
int autoHideTimeout() const;
static const int DefaultAutoHideTimeout;
static const int DisableAutoHide;
public slots:
void showMessage(const QString& text, MessageWidget::MessageType type);
void showMessage(const QString& text, MessageWidget::MessageType type, int autoHideTimeout);

View File

@ -35,7 +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->setIcon(FilePath::instance()->icon("status", "dialog-warning"));
m_ui->warningWidget->setCloseButtonVisible(false);
m_ui->warningWidget->setAutoHideTimeout(-1);
m_ui->warningWidget->setAutoHideTimeout(MessageWidget::DisableAutoHide);
m_ui->tabWidget->setEnabled(m_ui->enableHttpServer->isChecked());
connect(m_ui->enableHttpServer, SIGNAL(toggled(bool)), m_ui->tabWidget, SLOT(setEnabled(bool)));