From 621d20cc899e701616780efd77f2ac5b3a8d8f80 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Mardelle Date: Thu, 6 Sep 2012 00:15:22 +0200 Subject: [PATCH] Fix warning when several proxy clips fail, also add passive popup warning for KDE < 4.7 --- src/projectlist.cpp | 77 ++++++++++++++++++++++++++++++++++++--------- src/projectlist.h | 44 +++++++++++++++++++++----- 2 files changed, 99 insertions(+), 22 deletions(-) diff --git a/src/projectlist.cpp b/src/projectlist.cpp index c6f7368b..a3bae049 100644 --- a/src/projectlist.cpp +++ b/src/projectlist.cpp @@ -58,6 +58,8 @@ #include #include #include +#include +#include #ifdef USE_NEPOMUK #include @@ -77,6 +79,17 @@ #include #include #include +#include + + +MyMessageWidget::MyMessageWidget(QWidget *parent) : KMessageWidget(parent) {} +MyMessageWidget::MyMessageWidget(const QString &text, QWidget *parent) : KMessageWidget(text, parent) {} + + +bool MyMessageWidget::event(QEvent* ev) { + if (ev->type() == QEvent::Hide || ev->type() == QEvent::Close) emit messageClosing(); + return KMessageWidget::event(ev); +} SmallInfoLabel::SmallInfoLabel(QWidget *parent) : QPushButton(parent) { @@ -278,10 +291,11 @@ ProjectList::ProjectList(QWidget *parent) : m_listView = new ProjectListView(this); layout->addWidget(m_listView); -#if KDE_IS_VERSION(4,7,0) - m_infoMessage = new KMessageWidget; +#if KDE_IS_VERSION(4,7,0) + m_infoMessage = new MyMessageWidget; layout->addWidget(m_infoMessage); m_infoMessage->setCloseButtonVisible(true); + connect(m_infoMessage, SIGNAL(messageClosing()), this, SLOT(slotResetInfoMessage())); //m_infoMessage->setWordWrap(true); m_infoMessage->hide(); m_logAction = new QAction(i18n("Show Log"), this); @@ -3297,14 +3311,11 @@ void ProjectList::slotUpdateJobStatus(ProjectItem *item, int type, int status, c item->setJobStatus((JOBTYPE) type, (CLIPJOBSTATUS) status); if (status != JOBCRASHED) return; #if KDE_IS_VERSION(4,7,0) - m_infoMessage->animatedHide(); - m_errorLog.clear(); - m_infoMessage->setText(label); - m_infoMessage->setWordWrap(label.length() > 35); - m_infoMessage->setMessageType(KMessageWidget::Warning); QList actions = m_infoMessage->actions(); - for (int i = 0; i < actions.count(); i++) { - m_infoMessage->removeAction(actions.at(i)); + if (m_infoMessage->isHidden()) { + m_infoMessage->setText(label); + m_infoMessage->setWordWrap(m_infoMessage->text().length() > 35); + m_infoMessage->setMessageType(KMessageWidget::Warning); } if (!actionName.isEmpty()) { @@ -3315,27 +3326,47 @@ void ProjectList::slotUpdateJobStatus(ProjectItem *item, int type, int status, c action = coll->action(actionName); if (action) break; } - if (action) m_infoMessage->addAction(action); + if (action && !actions.contains(action)) m_infoMessage->addAction(action); } if (!details.isEmpty()) { - m_errorLog = details; - m_infoMessage->addAction(m_logAction); + m_errorLog.append(details); + if (!actions.contains(m_logAction)) m_infoMessage->addAction(m_logAction); } m_infoMessage->animatedShow(); +#else + // warning for KDE < 4.7 + KPassivePopup *passivePop = new KPassivePopup( this ); + passivePop->setAutoDelete(true); + connect(passivePop, SIGNAL(clicked()), this, SLOT(slotClosePopup())); + m_errorLog.append(details); + KVBox *vb = new KVBox( passivePop ); + KHBox *vh1 = new KHBox( vb ); + KIcon icon("dialog-warning"); + QLabel *iconLabel = new QLabel(vh1); + iconLabel->setPixmap(icon.pixmap(m_listView->iconSize())); + (void) new QLabel( label, vh1); + KHBox *box = new KHBox( vb ); + QPushButton *but = new QPushButton( "Show log", box ); + connect(but, SIGNAL(clicked(bool)), this, SLOT(slotShowJobLog())); + + passivePop->setView( vb ); + passivePop->show(); + #endif } void ProjectList::slotShowJobLog() { -#if KDE_IS_VERSION(4,7,0) KDialog d(this); d.setButtons(KDialog::Close); QTextEdit t(&d); - t.setPlainText(m_errorLog); + for (int i = 0; i < m_errorLog.count(); i++) { + if (i > 0) t.insertHtml("


"); + t.insertPlainText(m_errorLog.at(i)); + } t.setReadOnly(true); d.setMainWidget(&t); d.exec(); -#endif } QStringList ProjectList::getPendingJobs(const QString &id) @@ -3476,4 +3507,20 @@ void ProjectList::updatePalette() m_listView->updateStyleSheet(); } +void ProjectList::slotResetInfoMessage() +{ +#if KDE_IS_VERSION(4,7,0) + m_errorLog.clear(); + QList actions = m_infoMessage->actions(); + for (int i = 0; i < actions.count(); i++) { + m_infoMessage->removeAction(actions.at(i)); + } +#endif +} + +void ProjectList::slotClosePopup() +{ + m_errorLog.clear(); +} + #include "projectlist.moc" diff --git a/src/projectlist.h b/src/projectlist.h index cea80538..7d7e384f 100644 --- a/src/projectlist.h +++ b/src/projectlist.h @@ -42,10 +42,6 @@ #include #include -#if KDE_IS_VERSION(4,7,0) -#include -#endif - #ifdef NEPOMUK #include #include @@ -59,6 +55,34 @@ #include "projecttree/abstractclipjob.h" #include +#if KDE_IS_VERSION(4,7,0) +#include +#else +// Dummy KMessageWidget to allow compilation of MyMessageWidget class since Qt's moc doesn work inside #ifdef +#include +class KMessageWidget: public QLabel +{ +public: + KMessageWidget(QWidget * = 0) {}; + KMessageWidget(const QString &, QWidget * = 0) {}; + virtual ~KMessageWidget(){}; +}; +#endif + +class MyMessageWidget: public KMessageWidget +{ + Q_OBJECT +public: + MyMessageWidget(QWidget *parent = 0); + MyMessageWidget(const QString &text, QWidget *parent = 0); + +protected: + bool event(QEvent* ev); + +signals: + void messageClosing(); +}; + namespace Mlt { class Producer; @@ -349,10 +373,11 @@ private: InvalidDialog *m_invalidClipDialog; QMenu *m_jobsMenu; SmallInfoLabel *m_infoLabel; + /** @brief A list of strings containing the last error logs for clip jobs. */ + QStringList m_errorLog; + #if KDE_IS_VERSION(4,7,0) - KMessageWidget *m_infoMessage; - /** @brief A string containing the last error log for a clip job. */ - QString m_errorLog; + MyMessageWidget *m_infoMessage; /** @brief The action that will trigger the log dialog. */ QAction *m_logAction; #endif @@ -461,6 +486,10 @@ private slots: void slotDiscardClipJobs(); /** @brief Make sure current clip is visible in project tree. */ void slotCheckScrolling(); + /** @brief Reset all text and log data from info message widget. */ + void slotResetInfoMessage(); + /** @brief close warning info passive popup. */ + void slotClosePopup(); signals: void clipSelected(DocClipBase *, QPoint zone = QPoint(), bool forceUpdate = false); @@ -498,3 +527,4 @@ signals: #endif + -- 2.39.2