Small startup optimization

parent bbb0bc62
......@@ -123,8 +123,13 @@ int EffectsList::hasEffect(const QString & tag, const QString & id) const
QStringList EffectsList::effectIdInfo(const int ix) const
{
QStringList info;
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")) {
QString groupName = effect.attribute(QStringLiteral("name"));
info << groupName << groupName << effect.attribute(QStringLiteral("id")) << QString::number(Kdenlive::groupEffect);
......
......@@ -54,6 +54,7 @@ public:
* @param ix effect index
* @return list of name, tag and id of an effect */
QStringList effectIdInfo(const int ix) const;
QStringList effectInfo(const QDomElement &effect) const;
/** @brief Lists effects names. */
QStringList effectNames();
......
......@@ -325,6 +325,9 @@ void EffectsListView::filterList()
void EffectsListView::showInfoPanel()
{
bool show = !infopanel->isVisible();
if (show) {
infopanel->setText(m_effectsList->currentInfo());
}
infopanel->setVisible(show);
buttonInfo->setDown(show);
KdenliveSettings::setShoweffectinfo(show);
......@@ -344,7 +347,8 @@ void EffectsListView::slotEffectSelected()
void EffectsListView::slotUpdateInfo()
{
infopanel->setText(m_effectsList->currentInfo());
if (infopanel->isVisible())
infopanel->setText(m_effectsList->currentInfo());
}
void EffectsListView::reloadEffectList(QMenu *effectsMenu, KActionCategory *effectActions)
......
......@@ -242,7 +242,8 @@ void EffectsListWidget::loadEffects(const EffectsList *effectlist, QTreeWidgetIt
int fontSize = f.height();
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;
QTreeWidgetItem *parentItem = NULL;
......@@ -258,29 +259,27 @@ void EffectsListWidget::loadEffects(const EffectsList *effectlist, QTreeWidgetIt
if (parentItem == NULL)
parentItem = defaultFolder;
if (!effectInfo.isEmpty()) {
QIcon icon2 = generateIcon(fontSize, effectInfo.at(0), effectlist->at(ix));
item = new QTreeWidgetItem(parentItem, QStringList(effectInfo.takeFirst()));
QString tag = effectInfo.at(0);
if (type != EFFECT_CUSTOM && tag.startsWith(QLatin1String("movit."))) {
// GPU effect
effectInfo.append(QString::number(EFFECT_GPU));
item->setData(0, TypeRole, EFFECT_GPU);
} else {
effectInfo.append(QString::number(type));
item->setData(0, TypeRole, type);
}
if (effectInfo.count() == 4) item->setIcon(0, QIcon::fromTheme(QStringLiteral("folder")));
else item->setIcon(0, icon2);
item->setData(0, IdRole, effectInfo);
item->setToolTip(0, effectlist->getInfo(tag, effectInfo.at(1)));
if (parentItem == NULL) {
addTopLevelItem(item);
}
if (item->text(0) == current) {
setCurrentItem(item);
*found = true;
}
QIcon icon2 = generateIcon(fontSize, effectInfo.at(0), effect);
item = new QTreeWidgetItem(parentItem, QStringList(effectInfo.takeFirst()));
QString tag = effectInfo.at(0);
if (type != EFFECT_CUSTOM && tag.startsWith(QLatin1String("movit."))) {
// GPU effect
effectInfo.append(QString::number(EFFECT_GPU));
item->setData(0, TypeRole, EFFECT_GPU);
} else {
effectInfo.append(QString::number(type));
item->setData(0, TypeRole, type);
}
if (effectInfo.count() == 4) item->setIcon(0, QIcon::fromTheme(QStringLiteral("folder")));
else item->setIcon(0, icon2);
item->setData(0, IdRole, effectInfo);
item->setToolTip(0, effectlist->getEffectInfo(effect));
if (parentItem == NULL) {
addTopLevelItem(item);
}
if (item->text(0) == current) {
setCurrentItem(item);
*found = true;
}
}
}
......
......@@ -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(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(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_effectList = new EffectsListView();
......@@ -702,7 +702,7 @@ MainWindow::MainWindow(const QString &MltPath, const QUrl &Url, const QString &
#endif
scmanager->slotCheckActiveScopes();
//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)
......@@ -1781,7 +1781,7 @@ void MainWindow::connectDocument()
connect(trackView, SIGNAL(setZoom(int)), this, SLOT(slotSetZoom(int)));
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(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(playMonitor()), m_projectMonitor, SLOT(slotPlay()));
......@@ -2066,7 +2066,7 @@ void MainWindow::slotAddClipMarker()
pos = m_clipMonitor->position();
}
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;
}
QString id = clip->clipId();
......@@ -2098,7 +2098,7 @@ void MainWindow::slotDeleteClipMarker(bool allowGuideDeletion)
pos = m_clipMonitor->position();
}
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;
}
......@@ -2108,7 +2108,7 @@ void MainWindow::slotDeleteClipMarker(bool allowGuideDeletion)
if (allowGuideDeletion && m_projectMonitor->isActive()) {
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;
}
pCore->bin()->deleteClipMarker(comment, id, pos);
......@@ -2128,7 +2128,7 @@ void MainWindow::slotDeleteAllClipMarkers()
clip = m_clipMonitor->currentController();
}
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;
}
pCore->bin()->deleteAllClipMarkers(clip->clipId());
......@@ -2151,14 +2151,14 @@ void MainWindow::slotEditClipMarker()
pos = m_clipMonitor->position();
}
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;
}
QString id = clip->clipId();
CommentedTime oldMarker = clip->markerAt(pos);
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;
}
......@@ -2187,7 +2187,7 @@ void MainWindow::slotAddMarkerGuideQuickly()
GenTime pos = m_clipMonitor->position();
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;
}
//TODO: allow user to set default marker category
......@@ -2447,7 +2447,7 @@ void MainWindow::slotAddVideoEffect(QAction *result)
if (!effect.isNull()) {
slotAddEffect(effect);
} 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)
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)
{
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)
......@@ -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");
break;
}
m_messageLabel->setMessage(message, 100, InformationMessage);
m_messageLabel->setMessage(message, InformationMessage);
pCore->projectManager()->currentTimeline()->projectView()->setTool(tool);
}
}
......@@ -3051,7 +3051,7 @@ void MainWindow::slotTranscode(const QStringList &urls)
return;
}
if (urls.isEmpty()) {
m_messageLabel->setMessage(i18n("No clip to transcode"), 100, ErrorMessage);
m_messageLabel->setMessage(i18n("No clip to transcode"), ErrorMessage);
return;
}
ClipTranscode *d = new ClipTranscode(urls, params, QStringList(), desc);
......@@ -3308,12 +3308,12 @@ void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QS
// Do save scenelist
QFile file(plPath);
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;
}
file.write(docList.at(i).toString().toUtf8());
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();
return;
}
......@@ -3462,7 +3462,7 @@ void MainWindow::slotArchiveProject()
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);
if (d->exec()) {
m_messageLabel->setMessage(i18n("Archiving project"), 100, OperationCompletedMessage);
m_messageLabel->setMessage(i18n("Archiving project"), OperationCompletedMessage);
}
delete d;
}
......
......@@ -103,7 +103,7 @@ void StatusBarMessageLabel::mousePressEvent(QMouseEvent *event)
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) {
m_progress->setValue(progress);
......@@ -114,8 +114,15 @@ void StatusBarMessageLabel::setMessage(const QString& text, int progress, Messag
}
if (text == m_currentMessage.text)
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) {
KNotification::event(QStringLiteral("ErrorMessage"), item.text);
}
......@@ -155,7 +162,6 @@ void StatusBarMessageLabel::setMessage(const QString& text, int progress, Messag
}
}
m_queueSemaphore.release();
}
......
......@@ -104,7 +104,8 @@ protected:
void resizeEvent(QResizeEvent* event);
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:
......
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