Small startup optimization

parent bbb0bc62
...@@ -123,8 +123,13 @@ int EffectsList::hasEffect(const QString & tag, const QString & id) const ...@@ -123,8 +123,13 @@ int EffectsList::hasEffect(const QString & tag, const QString & id) const
QStringList EffectsList::effectIdInfo(const int ix) const QStringList EffectsList::effectIdInfo(const int ix) const
{ {
QStringList info;
QDomElement effect = m_baseElement.childNodes().at(ix).toElement(); QDomElement effect = m_baseElement.childNodes().at(ix).toElement();
return effectInfo(effect);
}
QStringList EffectsList::effectInfo(const QDomElement &effect) const
{
QStringList info;
if (effect.tagName() == QLatin1String("effectgroup")) { if (effect.tagName() == QLatin1String("effectgroup")) {
QString groupName = effect.attribute(QStringLiteral("name")); QString groupName = effect.attribute(QStringLiteral("name"));
info << groupName << groupName << effect.attribute(QStringLiteral("id")) << QString::number(Kdenlive::groupEffect); info << groupName << groupName << effect.attribute(QStringLiteral("id")) << QString::number(Kdenlive::groupEffect);
......
...@@ -54,6 +54,7 @@ public: ...@@ -54,6 +54,7 @@ public:
* @param ix effect index * @param ix effect index
* @return list of name, tag and id of an effect */ * @return list of name, tag and id of an effect */
QStringList effectIdInfo(const int ix) const; QStringList effectIdInfo(const int ix) const;
QStringList effectInfo(const QDomElement &effect) const;
/** @brief Lists effects names. */ /** @brief Lists effects names. */
QStringList effectNames(); QStringList effectNames();
......
...@@ -325,6 +325,9 @@ void EffectsListView::filterList() ...@@ -325,6 +325,9 @@ void EffectsListView::filterList()
void EffectsListView::showInfoPanel() void EffectsListView::showInfoPanel()
{ {
bool show = !infopanel->isVisible(); bool show = !infopanel->isVisible();
if (show) {
infopanel->setText(m_effectsList->currentInfo());
}
infopanel->setVisible(show); infopanel->setVisible(show);
buttonInfo->setDown(show); buttonInfo->setDown(show);
KdenliveSettings::setShoweffectinfo(show); KdenliveSettings::setShoweffectinfo(show);
...@@ -344,7 +347,8 @@ void EffectsListView::slotEffectSelected() ...@@ -344,7 +347,8 @@ void EffectsListView::slotEffectSelected()
void EffectsListView::slotUpdateInfo() void EffectsListView::slotUpdateInfo()
{ {
infopanel->setText(m_effectsList->currentInfo()); if (infopanel->isVisible())
infopanel->setText(m_effectsList->currentInfo());
} }
void EffectsListView::reloadEffectList(QMenu *effectsMenu, KActionCategory *effectActions) void EffectsListView::reloadEffectList(QMenu *effectsMenu, KActionCategory *effectActions)
......
...@@ -242,7 +242,8 @@ void EffectsListWidget::loadEffects(const EffectsList *effectlist, QTreeWidgetIt ...@@ -242,7 +242,8 @@ void EffectsListWidget::loadEffects(const EffectsList *effectlist, QTreeWidgetIt
int fontSize = f.height(); int fontSize = f.height();
for (int ix = 0; ix < ct; ++ix) { for (int ix = 0; ix < ct; ++ix) {
effectInfo = effectlist->effectIdInfo(ix); const QDomElement effect = effectlist->at(ix);
effectInfo = effectlist->effectInfo(effect);
if (effectInfo.isEmpty()) continue; if (effectInfo.isEmpty()) continue;
QTreeWidgetItem *parentItem = NULL; QTreeWidgetItem *parentItem = NULL;
...@@ -258,29 +259,27 @@ void EffectsListWidget::loadEffects(const EffectsList *effectlist, QTreeWidgetIt ...@@ -258,29 +259,27 @@ void EffectsListWidget::loadEffects(const EffectsList *effectlist, QTreeWidgetIt
if (parentItem == NULL) if (parentItem == NULL)
parentItem = defaultFolder; parentItem = defaultFolder;
if (!effectInfo.isEmpty()) { QIcon icon2 = generateIcon(fontSize, effectInfo.at(0), effect);
QIcon icon2 = generateIcon(fontSize, effectInfo.at(0), effectlist->at(ix)); item = new QTreeWidgetItem(parentItem, QStringList(effectInfo.takeFirst()));
item = new QTreeWidgetItem(parentItem, QStringList(effectInfo.takeFirst())); QString tag = effectInfo.at(0);
QString tag = effectInfo.at(0); if (type != EFFECT_CUSTOM && tag.startsWith(QLatin1String("movit."))) {
if (type != EFFECT_CUSTOM && tag.startsWith(QLatin1String("movit."))) { // GPU effect
// GPU effect effectInfo.append(QString::number(EFFECT_GPU));
effectInfo.append(QString::number(EFFECT_GPU)); item->setData(0, TypeRole, EFFECT_GPU);
item->setData(0, TypeRole, EFFECT_GPU); } else {
} else { effectInfo.append(QString::number(type));
effectInfo.append(QString::number(type)); item->setData(0, TypeRole, type);
item->setData(0, TypeRole, type); }
} if (effectInfo.count() == 4) item->setIcon(0, QIcon::fromTheme(QStringLiteral("folder")));
if (effectInfo.count() == 4) item->setIcon(0, QIcon::fromTheme(QStringLiteral("folder"))); else item->setIcon(0, icon2);
else item->setIcon(0, icon2); item->setData(0, IdRole, effectInfo);
item->setData(0, IdRole, effectInfo); item->setToolTip(0, effectlist->getEffectInfo(effect));
item->setToolTip(0, effectlist->getInfo(tag, effectInfo.at(1))); if (parentItem == NULL) {
if (parentItem == NULL) { addTopLevelItem(item);
addTopLevelItem(item); }
} if (item->text(0) == current) {
if (item->text(0) == current) { setCurrentItem(item);
setCurrentItem(item); *found = true;
*found = true;
}
} }
} }
} }
......
...@@ -410,7 +410,7 @@ MainWindow::MainWindow(const QString &MltPath, const QUrl &Url, const QString & ...@@ -410,7 +410,7 @@ MainWindow::MainWindow(const QString &MltPath, const QUrl &Url, const QString &
connect(m_effectStack, SIGNAL(removeMasterEffect(QString,QDomElement)), pCore->bin(), SLOT(slotDeleteEffect(QString,QDomElement))); connect(m_effectStack, SIGNAL(removeMasterEffect(QString,QDomElement)), pCore->bin(), SLOT(slotDeleteEffect(QString,QDomElement)));
connect(m_effectStack, SIGNAL(changeEffectPosition(QString,const QList <int>,int)), pCore->bin(), SLOT(slotMoveEffect(QString,const QList <int>,int))); connect(m_effectStack, SIGNAL(changeEffectPosition(QString,const QList <int>,int)), pCore->bin(), SLOT(slotMoveEffect(QString,const QList <int>,int)));
connect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects())); connect(m_effectStack, SIGNAL(reloadEffects()), this, SLOT(slotReloadEffects()));
connect(m_effectStack, SIGNAL(displayMessage(QString,int)), m_messageLabel, SLOT(setMessage(QString,int))); connect(m_effectStack, SIGNAL(displayMessage(QString,int)), m_messageLabel, SLOT(setProgressMessage(QString,int)));
m_effectStackDock = addDock(i18n("Properties"), QStringLiteral("effect_stack"), m_effectStack); m_effectStackDock = addDock(i18n("Properties"), QStringLiteral("effect_stack"), m_effectStack);
m_effectList = new EffectsListView(); m_effectList = new EffectsListView();
...@@ -702,7 +702,7 @@ MainWindow::MainWindow(const QString &MltPath, const QUrl &Url, const QString & ...@@ -702,7 +702,7 @@ MainWindow::MainWindow(const QString &MltPath, const QUrl &Url, const QString &
#endif #endif
scmanager->slotCheckActiveScopes(); scmanager->slotCheckActiveScopes();
//TODO: remove for release //TODO: remove for release
m_messageLabel->setMessage("This is an untested development version. Always backup your data", 100, MltError); m_messageLabel->setMessage("This is an untested development version. Always backup your data", MltError);
} }
void MainWindow::slotThemeChanged(const QString &theme) void MainWindow::slotThemeChanged(const QString &theme)
...@@ -1781,7 +1781,7 @@ void MainWindow::connectDocument() ...@@ -1781,7 +1781,7 @@ void MainWindow::connectDocument()
connect(trackView, SIGNAL(setZoom(int)), this, SLOT(slotSetZoom(int))); connect(trackView, SIGNAL(setZoom(int)), this, SLOT(slotSetZoom(int)));
connect(trackView->projectView(), SIGNAL(displayMessage(QString,MessageType)), m_messageLabel, SLOT(setMessage(QString,MessageType))); connect(trackView->projectView(), SIGNAL(displayMessage(QString,MessageType)), m_messageLabel, SLOT(setMessage(QString,MessageType)));
connect(pCore->bin(), SIGNAL(clipNameChanged(QString)), trackView->projectView(), SLOT(clipNameChanged(QString))); connect(pCore->bin(), SIGNAL(clipNameChanged(QString)), trackView->projectView(), SLOT(clipNameChanged(QString)));
connect(pCore->bin(), SIGNAL(displayMessage(QString,int,MessageType)), m_messageLabel, SLOT(setMessage(QString,int,MessageType))); connect(pCore->bin(), SIGNAL(displayMessage(QString,int,MessageType)), m_messageLabel, SLOT(setProgressMessage(QString,int,MessageType)));
connect(trackView->projectView(), SIGNAL(showClipFrame(const QString&,int)), pCore->bin(), SLOT(selectClipById(const QString&,int))); connect(trackView->projectView(), SIGNAL(showClipFrame(const QString&,int)), pCore->bin(), SLOT(selectClipById(const QString&,int)));
connect(trackView->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay())); connect(trackView->projectView(), SIGNAL(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
...@@ -2066,7 +2066,7 @@ void MainWindow::slotAddClipMarker() ...@@ -2066,7 +2066,7 @@ void MainWindow::slotAddClipMarker()
pos = m_clipMonitor->position(); pos = m_clipMonitor->position();
} }
if (!clip) { if (!clip) {
m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), 100, ErrorMessage); m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
return; return;
} }
QString id = clip->clipId(); QString id = clip->clipId();
...@@ -2098,7 +2098,7 @@ void MainWindow::slotDeleteClipMarker(bool allowGuideDeletion) ...@@ -2098,7 +2098,7 @@ void MainWindow::slotDeleteClipMarker(bool allowGuideDeletion)
pos = m_clipMonitor->position(); pos = m_clipMonitor->position();
} }
if (!clip) { if (!clip) {
m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), 100, ErrorMessage); m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
return; return;
} }
...@@ -2108,7 +2108,7 @@ void MainWindow::slotDeleteClipMarker(bool allowGuideDeletion) ...@@ -2108,7 +2108,7 @@ void MainWindow::slotDeleteClipMarker(bool allowGuideDeletion)
if (allowGuideDeletion && m_projectMonitor->isActive()) { if (allowGuideDeletion && m_projectMonitor->isActive()) {
slotDeleteGuide(); slotDeleteGuide();
} }
else m_messageLabel->setMessage(i18n("No marker found at cursor time"), 100, ErrorMessage); else m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
return; return;
} }
pCore->bin()->deleteClipMarker(comment, id, pos); pCore->bin()->deleteClipMarker(comment, id, pos);
...@@ -2128,7 +2128,7 @@ void MainWindow::slotDeleteAllClipMarkers() ...@@ -2128,7 +2128,7 @@ void MainWindow::slotDeleteAllClipMarkers()
clip = m_clipMonitor->currentController(); clip = m_clipMonitor->currentController();
} }
if (!clip) { if (!clip) {
m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), 100, ErrorMessage); m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
return; return;
} }
pCore->bin()->deleteAllClipMarkers(clip->clipId()); pCore->bin()->deleteAllClipMarkers(clip->clipId());
...@@ -2151,14 +2151,14 @@ void MainWindow::slotEditClipMarker() ...@@ -2151,14 +2151,14 @@ void MainWindow::slotEditClipMarker()
pos = m_clipMonitor->position(); pos = m_clipMonitor->position();
} }
if (!clip) { if (!clip) {
m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), 100, ErrorMessage); m_messageLabel->setMessage(i18n("Cannot find clip to remove marker"), ErrorMessage);
return; return;
} }
QString id = clip->clipId(); QString id = clip->clipId();
CommentedTime oldMarker = clip->markerAt(pos); CommentedTime oldMarker = clip->markerAt(pos);
if (oldMarker == CommentedTime()) { if (oldMarker == CommentedTime()) {
m_messageLabel->setMessage(i18n("No marker found at cursor time"), 100, ErrorMessage); m_messageLabel->setMessage(i18n("No marker found at cursor time"), ErrorMessage);
return; return;
} }
...@@ -2187,7 +2187,7 @@ void MainWindow::slotAddMarkerGuideQuickly() ...@@ -2187,7 +2187,7 @@ void MainWindow::slotAddMarkerGuideQuickly()
GenTime pos = m_clipMonitor->position(); GenTime pos = m_clipMonitor->position();
if (!clip) { if (!clip) {
m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), 100, ErrorMessage); m_messageLabel->setMessage(i18n("Cannot find clip to add marker"), ErrorMessage);
return; return;
} }
//TODO: allow user to set default marker category //TODO: allow user to set default marker category
...@@ -2447,7 +2447,7 @@ void MainWindow::slotAddVideoEffect(QAction *result) ...@@ -2447,7 +2447,7 @@ void MainWindow::slotAddVideoEffect(QAction *result)
if (!effect.isNull()) { if (!effect.isNull()) {
slotAddEffect(effect); slotAddEffect(effect);
} else { } else {
m_messageLabel->setMessage(i18n("Cannot find effect %1 / %2", info.at(0), info.at(1)), 100, ErrorMessage); m_messageLabel->setMessage(i18n("Cannot find effect %1 / %2", info.at(0), info.at(1)), ErrorMessage);
} }
} }
...@@ -2510,13 +2510,13 @@ void MainWindow::slotUpdateZoomSliderToolTip(int zoomlevel) ...@@ -2510,13 +2510,13 @@ void MainWindow::slotUpdateZoomSliderToolTip(int zoomlevel)
void MainWindow::slotGotProgressInfo(const QString &message, int progress, MessageType type) void MainWindow::slotGotProgressInfo(const QString &message, int progress, MessageType type)
{ {
m_messageLabel->setMessage(message, progress, type); m_messageLabel->setProgressMessage(message, progress, type);
} }
void MainWindow::customEvent(QEvent* e) void MainWindow::customEvent(QEvent* e)
{ {
if (e->type() == QEvent::User) if (e->type() == QEvent::User)
m_messageLabel->setMessage(static_cast <MltErrorEvent *>(e)->message(), 100, MltError); m_messageLabel->setMessage(static_cast <MltErrorEvent *>(e)->message(), MltError);
} }
void MainWindow::slotTimelineClipSelected(ClipItem* item, bool reloadStack, bool raise) void MainWindow::slotTimelineClipSelected(ClipItem* item, bool reloadStack, bool raise)
...@@ -2621,7 +2621,7 @@ void MainWindow::slotSetTool(ProjectTool tool) ...@@ -2621,7 +2621,7 @@ void MainWindow::slotSetTool(ProjectTool tool)
message = i18n("Shift + click to create a selection rectangle, Ctrl + click to add an item to selection"); message = i18n("Shift + click to create a selection rectangle, Ctrl + click to add an item to selection");
break; break;
} }
m_messageLabel->setMessage(message, 100, InformationMessage); m_messageLabel->setMessage(message, InformationMessage);
pCore->projectManager()->currentTimeline()->projectView()->setTool(tool); pCore->projectManager()->currentTimeline()->projectView()->setTool(tool);
} }
} }
...@@ -3051,7 +3051,7 @@ void MainWindow::slotTranscode(const QStringList &urls) ...@@ -3051,7 +3051,7 @@ void MainWindow::slotTranscode(const QStringList &urls)
return; return;
} }
if (urls.isEmpty()) { if (urls.isEmpty()) {
m_messageLabel->setMessage(i18n("No clip to transcode"), 100, ErrorMessage); m_messageLabel->setMessage(i18n("No clip to transcode"), ErrorMessage);
return; return;
} }
ClipTranscode *d = new ClipTranscode(urls, params, QStringList(), desc); ClipTranscode *d = new ClipTranscode(urls, params, QStringList(), desc);
...@@ -3308,12 +3308,12 @@ void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QS ...@@ -3308,12 +3308,12 @@ void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QS
// Do save scenelist // Do save scenelist
QFile file(plPath); QFile file(plPath);
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
m_messageLabel->setMessage(i18n("Cannot write to file %1", plPath), 100, ErrorMessage); m_messageLabel->setMessage(i18n("Cannot write to file %1", plPath), ErrorMessage);
return; return;
} }
file.write(docList.at(i).toString().toUtf8()); file.write(docList.at(i).toString().toUtf8());
if (file.error() != QFile::NoError) { if (file.error() != QFile::NoError) {
m_messageLabel->setMessage(i18n("Cannot write to file %1", plPath), 100, ErrorMessage); m_messageLabel->setMessage(i18n("Cannot write to file %1", plPath), ErrorMessage);
file.close(); file.close();
return; return;
} }
...@@ -3462,7 +3462,7 @@ void MainWindow::slotArchiveProject() ...@@ -3462,7 +3462,7 @@ void MainWindow::slotArchiveProject()
QDomDocument doc = pCore->projectManager()->current()->xmlSceneList(m_projectMonitor->sceneList()); QDomDocument doc = pCore->projectManager()->current()->xmlSceneList(m_projectMonitor->sceneList());
QPointer<ArchiveWidget> d = new ArchiveWidget(pCore->projectManager()->current()->url().fileName(), doc, list, pCore->projectManager()->currentTimeline()->projectView()->extractTransitionsLumas(), this); QPointer<ArchiveWidget> d = new ArchiveWidget(pCore->projectManager()->current()->url().fileName(), doc, list, pCore->projectManager()->currentTimeline()->projectView()->extractTransitionsLumas(), this);
if (d->exec()) { if (d->exec()) {
m_messageLabel->setMessage(i18n("Archiving project"), 100, OperationCompletedMessage); m_messageLabel->setMessage(i18n("Archiving project"), OperationCompletedMessage);
} }
delete d; delete d;
} }
......
...@@ -103,7 +103,7 @@ void StatusBarMessageLabel::mousePressEvent(QMouseEvent *event) ...@@ -103,7 +103,7 @@ void StatusBarMessageLabel::mousePressEvent(QMouseEvent *event)
confirmErrorMessage(); confirmErrorMessage();
} }
void StatusBarMessageLabel::setMessage(const QString& text, int progress, MessageType type, int timeoutMS) void StatusBarMessageLabel::setProgressMessage(const QString& text, int progress, MessageType type, int timeoutMS)
{ {
if (type == ProcessingJobMessage) { if (type == ProcessingJobMessage) {
m_progress->setValue(progress); m_progress->setValue(progress);
...@@ -114,8 +114,15 @@ void StatusBarMessageLabel::setMessage(const QString& text, int progress, Messag ...@@ -114,8 +114,15 @@ void StatusBarMessageLabel::setMessage(const QString& text, int progress, Messag
} }
if (text == m_currentMessage.text) if (text == m_currentMessage.text)
return; return;
StatusBarMessageItem item(text, type, timeoutMS); setMessage(text, type, timeoutMS);
}
void StatusBarMessageLabel::setMessage(const QString& text, MessageType type, int timeoutMS)
{
StatusBarMessageItem item(text, type, timeoutMS);
if (type == OperationCompletedMessage) {
m_progress->setVisible(false);
}
if (item.type == ErrorMessage || item.type == MltError) { if (item.type == ErrorMessage || item.type == MltError) {
KNotification::event(QStringLiteral("ErrorMessage"), item.text); KNotification::event(QStringLiteral("ErrorMessage"), item.text);
} }
...@@ -155,7 +162,6 @@ void StatusBarMessageLabel::setMessage(const QString& text, int progress, Messag ...@@ -155,7 +162,6 @@ void StatusBarMessageLabel::setMessage(const QString& text, int progress, Messag
} }
} }
m_queueSemaphore.release(); m_queueSemaphore.release();
} }
......
...@@ -104,7 +104,8 @@ protected: ...@@ -104,7 +104,8 @@ protected:
void resizeEvent(QResizeEvent* event); void resizeEvent(QResizeEvent* event);
public slots: public slots:
void setMessage(const QString& text, int progress = 100, MessageType type = DefaultMessage, int timeoutMS = 0); void setProgressMessage(const QString& text, int progress = 100, MessageType type = ProcessingJobMessage, int timeoutMS = 0);
void setMessage(const QString& text, MessageType type = DefaultMessage, int timeoutMS = 0);
private slots: private slots:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment