mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-07-29 17:48:46 -04:00
Replace MessageBox Dialog with inline MessageWidget in
EditWidget and in UnlockDatabaseWidget. Add missing method to show Information Message.
This commit is contained in:
parent
8fa070f01c
commit
c2826bb1af
5 changed files with 54 additions and 13 deletions
|
@ -25,6 +25,8 @@ EditWidget::EditWidget(QWidget* parent)
|
||||||
m_ui->setupUi(this);
|
m_ui->setupUi(this);
|
||||||
setReadOnly(false);
|
setReadOnly(false);
|
||||||
|
|
||||||
|
m_ui->messageWidget->setHidden(true);
|
||||||
|
|
||||||
QFont headerLabelFont = m_ui->headerLabel->font();
|
QFont headerLabelFont = m_ui->headerLabel->font();
|
||||||
headerLabelFont.setBold(true);
|
headerLabelFont.setBold(true);
|
||||||
headerLabelFont.setPointSize(headerLabelFont.pointSize() + 2);
|
headerLabelFont.setPointSize(headerLabelFont.pointSize() + 2);
|
||||||
|
@ -86,3 +88,25 @@ bool EditWidget::readOnly() const
|
||||||
{
|
{
|
||||||
return m_readOnly;
|
return m_readOnly;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EditWidget::showMessageError(const QString& text)
|
||||||
|
{
|
||||||
|
m_ui->messageWidget->showMessageError(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EditWidget::showMessageWarning(const QString& text)
|
||||||
|
{
|
||||||
|
m_ui->messageWidget->showMessageWarning(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EditWidget::showMessageInformation(const QString& text)
|
||||||
|
{
|
||||||
|
m_ui->messageWidget->showMessageInformation(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
void EditWidget::hideMessage()
|
||||||
|
{
|
||||||
|
if (m_ui->messageWidget->isVisible()) {
|
||||||
|
m_ui->messageWidget->animatedHide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -48,6 +48,12 @@ Q_SIGNALS:
|
||||||
void accepted();
|
void accepted();
|
||||||
void rejected();
|
void rejected();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void showMessageError(const QString& text);
|
||||||
|
void showMessageWarning(const QString& text);
|
||||||
|
void showMessageInformation(const QString& text);
|
||||||
|
void hideMessage();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const QScopedPointer<Ui::EditWidget> m_ui;
|
const QScopedPointer<Ui::EditWidget> m_ui;
|
||||||
bool m_readOnly;
|
bool m_readOnly;
|
||||||
|
|
|
@ -11,6 +11,9 @@
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="MessageWidget" name="messageWidget" native="true"/>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="headerLabel">
|
<widget class="QLabel" name="headerLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -58,6 +61,12 @@
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>MessageWidget</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header>gui/MessageWidget.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>CategoryListWidget</class>
|
<class>CategoryListWidget</class>
|
||||||
<extends>QListWidget</extends>
|
<extends>QListWidget</extends>
|
||||||
|
|
|
@ -33,6 +33,11 @@ void MessageWidget::showMessageWarning(const QString& text)
|
||||||
showMessage(text, MessageType::Warning);
|
showMessage(text, MessageType::Warning);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MessageWidget::showMessageInformation(const QString& text)
|
||||||
|
{
|
||||||
|
showMessage(text, MessageType::Information);
|
||||||
|
}
|
||||||
|
|
||||||
void MessageWidget::showMessagePositive(const QString& text)
|
void MessageWidget::showMessagePositive(const QString& text)
|
||||||
{
|
{
|
||||||
showMessage(text, MessageType::Positive);
|
showMessage(text, MessageType::Positive);
|
||||||
|
|
|
@ -395,12 +395,13 @@ void EditEntryWidget::saveEntry()
|
||||||
{
|
{
|
||||||
if (m_history) {
|
if (m_history) {
|
||||||
clear();
|
clear();
|
||||||
|
hideMessage();
|
||||||
Q_EMIT editFinished(false);
|
Q_EMIT editFinished(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!passwordsEqual()) {
|
if (!passwordsEqual()) {
|
||||||
MessageBox::warning(this, tr("Error"), tr("Different passwords supplied."));
|
showMessageError(tr("Different passwords supplied."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -474,6 +475,7 @@ void EditEntryWidget::cancel()
|
||||||
{
|
{
|
||||||
if (m_history) {
|
if (m_history) {
|
||||||
clear();
|
clear();
|
||||||
|
hideMessage();
|
||||||
Q_EMIT editFinished(false);
|
Q_EMIT editFinished(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -497,6 +499,7 @@ void EditEntryWidget::clear()
|
||||||
m_autoTypeAssoc->clear();
|
m_autoTypeAssoc->clear();
|
||||||
m_historyModel->clear();
|
m_historyModel->clear();
|
||||||
m_iconsWidget->reset();
|
m_iconsWidget->reset();
|
||||||
|
hideMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EditEntryWidget::hasBeenModified() const
|
bool EditEntryWidget::hasBeenModified() const
|
||||||
|
@ -630,15 +633,13 @@ void EditEntryWidget::insertAttachment()
|
||||||
|
|
||||||
QFile file(filename);
|
QFile file(filename);
|
||||||
if (!file.open(QIODevice::ReadOnly)) {
|
if (!file.open(QIODevice::ReadOnly)) {
|
||||||
MessageBox::warning(this, tr("Error"),
|
showMessageError(tr("Unable to open file").append(":\n").append(file.errorString()));
|
||||||
tr("Unable to open file").append(":\n").append(file.errorString()));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray data;
|
QByteArray data;
|
||||||
if (!Tools::readAllFromDevice(&file, data)) {
|
if (!Tools::readAllFromDevice(&file, data)) {
|
||||||
MessageBox::warning(this, tr("Error"),
|
showMessageError(tr("Unable to open file").append(":\n").append(file.errorString()));
|
||||||
tr("Unable to open file").append(":\n").append(file.errorString()));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -665,13 +666,11 @@ void EditEntryWidget::saveCurrentAttachment()
|
||||||
|
|
||||||
QFile file(savePath);
|
QFile file(savePath);
|
||||||
if (!file.open(QIODevice::WriteOnly)) {
|
if (!file.open(QIODevice::WriteOnly)) {
|
||||||
MessageBox::warning(this, tr("Error"),
|
showMessageError(tr("Unable to save the attachment:\n").append(file.errorString()));
|
||||||
tr("Unable to save the attachment:\n").append(file.errorString()));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (file.write(attachmentData) != attachmentData.size()) {
|
if (file.write(attachmentData) != attachmentData.size()) {
|
||||||
MessageBox::warning(this, tr("Error"),
|
showMessageError(tr("Unable to save the attachment:\n").append(file.errorString()));
|
||||||
tr("Unable to save the attachment:\n").append(file.errorString()));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -692,14 +691,12 @@ void EditEntryWidget::openAttachment(const QModelIndex& index)
|
||||||
QTemporaryFile* file = new QTemporaryFile(tmpFileTemplate, this);
|
QTemporaryFile* file = new QTemporaryFile(tmpFileTemplate, this);
|
||||||
|
|
||||||
if (!file->open()) {
|
if (!file->open()) {
|
||||||
MessageBox::warning(this, tr("Error"),
|
showMessageError(tr("Unable to save the attachment:\n").append(file->errorString()));
|
||||||
tr("Unable to save the attachment:\n").append(file->errorString()));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file->write(attachmentData) != attachmentData.size()) {
|
if (file->write(attachmentData) != attachmentData.size()) {
|
||||||
MessageBox::warning(this, tr("Error"),
|
showMessageError(tr("Unable to save the attachment:\n").append(file->errorString()));
|
||||||
tr("Unable to save the attachment:\n").append(file->errorString()));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue