Replaced MessageBox dialogs with inline MessageWidget in

DatabaseOpenWidget.
This commit is contained in:
Pedro Alves 2015-01-19 23:14:59 +00:00 committed by Janek Bevendorff
parent c6ad476cb7
commit a710181388
No known key found for this signature in database
GPG Key ID: CFEC2F6850BFFA53
2 changed files with 20 additions and 6 deletions

View File

@ -35,6 +35,8 @@ DatabaseOpenWidget::DatabaseOpenWidget(QWidget* parent)
{ {
m_ui->setupUi(this); m_ui->setupUi(this);
m_ui->messageWidget->setHidden(true);
QFont font = m_ui->labelHeadline->font(); QFont font = m_ui->labelHeadline->font();
font.setBold(true); font.setBold(true);
font.setPointSize(font.pointSize() + 2); font.setPointSize(font.pointSize() + 2);
@ -106,8 +108,8 @@ void DatabaseOpenWidget::openDatabase()
QFile file(m_filename); QFile file(m_filename);
if (!file.open(QIODevice::ReadOnly)) { if (!file.open(QIODevice::ReadOnly)) {
MessageBox::warning(this, tr("Error"), tr("Unable to open the database.").append("\n") m_ui->messageWidget->showMessageError(
.append(file.errorString())); tr("Unable to open the database.").append("\n").append(file.errorString()));
return; return;
} }
if (m_db) { if (m_db) {
@ -118,11 +120,14 @@ void DatabaseOpenWidget::openDatabase()
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
if (m_db) { if (m_db) {
if (m_ui->messageWidget->isVisible()) {
m_ui->messageWidget->animatedHide();
}
Q_EMIT editFinished(true); Q_EMIT editFinished(true);
} }
else { else {
MessageBox::warning(this, tr("Error"), tr("Unable to open the database.").append("\n") m_ui->messageWidget->showMessageError(tr("Unable to open the database.")
.append(reader.errorString())); .append("\n").append(reader.errorString()));
m_ui->editPassword->clear(); m_ui->editPassword->clear();
} }
} }
@ -142,7 +147,7 @@ CompositeKey DatabaseOpenWidget::databaseKey()
QString keyFilename = m_ui->comboKeyFile->currentText(); QString keyFilename = m_ui->comboKeyFile->currentText();
QString errorMsg; QString errorMsg;
if (!key.load(keyFilename, &errorMsg)) { if (!key.load(keyFilename, &errorMsg)) {
MessageBox::warning(this, tr("Error"), tr("Can't open key file").append(":\n").append(errorMsg)); m_ui->messageWidget->showMessageError(tr("Can't open key file").append(":\n").append(errorMsg));
return CompositeKey(); return CompositeKey();
} }
masterKey.addKey(key); masterKey.addKey(key);

View File

@ -10,10 +10,13 @@
<height>250</height> <height>250</height>
</rect> </rect>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout" stretch="1,0,0,1,0,0,3"> <layout class="QVBoxLayout" name="verticalLayout" stretch="0,1,0,0,1,0,0,3">
<property name="spacing"> <property name="spacing">
<number>8</number> <number>8</number>
</property> </property>
<item>
<widget class="MessageWidget" name="messageWidget" native="true"/>
</item>
<item> <item>
<spacer name="verticalSpacer_2"> <spacer name="verticalSpacer_2">
<property name="orientation"> <property name="orientation">
@ -144,6 +147,12 @@
<extends>QLineEdit</extends> <extends>QLineEdit</extends>
<header>gui/PasswordEdit.h</header> <header>gui/PasswordEdit.h</header>
</customwidget> </customwidget>
<customwidget>
<class>MessageWidget</class>
<extends>QWidget</extends>
<header>gui/MessageWidget.h</header>
<container>1</container>
</customwidget>
</customwidgets> </customwidgets>
<tabstops> <tabstops>
<tabstop>checkPassword</tabstop> <tabstop>checkPassword</tabstop>