diff --git a/part/part.h b/part/part.h --- a/part/part.h +++ b/part/part.h @@ -134,6 +134,7 @@ void quit(); private: + void resetGui(); void setupView(); void setupActions(); bool isSingleFolderArchive() const; @@ -174,6 +175,7 @@ QGroupBox *m_commentBox; QPlainTextEdit *m_commentView; KMessageWidget *m_commentMsgWidget; + KMessageWidget *m_messageWidget; }; } // namespace Ark diff --git a/part/part.cpp b/part/part.cpp --- a/part/part.cpp +++ b/part/part.cpp @@ -116,6 +116,9 @@ vbox->addWidget(m_commentView); m_commentBox->setLayout(vbox); + m_messageWidget = new KMessageWidget(parentWidget); + m_messageWidget->hide(); + m_commentMsgWidget = new KMessageWidget(); m_commentMsgWidget->setText(i18n("Comment has been modified.")); m_commentMsgWidget->setMessageType(KMessageWidget::Information); @@ -135,6 +138,7 @@ // Configure the QVBoxLayout and add widgets m_vlayout->setContentsMargins(0,0,0,0); + m_vlayout->addWidget(m_messageWidget); m_vlayout->addWidget(m_splitter); // Vertical QSplitter for the file view and comment field. @@ -507,6 +511,13 @@ job->start(); } +void Part::resetGui() +{ + m_messageWidget->hide(); + m_commentView->clear(); + m_commentBox->hide(); +} + void Part::slotTestingDone(KJob* job) { if (job->error() && job->error() != KJob::KilledJobError) { @@ -613,8 +624,7 @@ { qCDebug(ARK) << "Attempting to open archive" << localFilePath(); - m_commentView->clear(); - m_commentBox->hide(); + resetGui(); if (!isLocalFileValid()) { return false; @@ -1256,6 +1266,9 @@ { if (job->error() && job->error() != KJob::KilledJobError) { KMessageBox::error(widget(), job->errorString()); + } else { + // Hide the "archive will be created as soon as you add a file" message. + m_messageWidget->hide(); } } @@ -1366,11 +1379,11 @@ void Part::displayMsgWidget(KMessageWidget::MessageType type, const QString& msg) { - KMessageWidget *msgWidget = new KMessageWidget(); - msgWidget->setText(msg); - msgWidget->setMessageType(type); - m_vlayout->insertWidget(0, msgWidget); - msgWidget->animatedShow(); + // The widget could be already visible, so hide it. + m_messageWidget->hide(); + m_messageWidget->setText(msg); + m_messageWidget->setMessageType(type); + m_messageWidget->animatedShow(); } } // namespace Ark