Fix my small effect basket (list of favorite effects embedded in toolbar):

* react on shortcut
* do add effect when return pressed
parent 20b78493
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd"> <!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
<kpartgui name="kdenlive" version="95" translationDomain="kdenlive"> <kpartgui name="kdenlive" version="100" translationDomain="kdenlive">
<ToolBar name="extraToolBar" > <ToolBar name="extraToolBar" >
<text>Extra Toolbar</text> <text>Extra Toolbar</text>
<Action name="project_render" /> <Action name="project_render" />
<Action name="favorite_effects" />
</ToolBar> </ToolBar>
<MenuBar> <MenuBar>
......
...@@ -40,6 +40,7 @@ EffectBasket::EffectBasket(EffectsListView *effectList) : ...@@ -40,6 +40,7 @@ EffectBasket::EffectBasket(EffectsListView *effectList) :
setDragEnabled(true); setDragEnabled(true);
m_effectList->creatFavoriteBasket(this); m_effectList->creatFavoriteBasket(this);
connect(m_effectList, &EffectsListView::reloadBasket, this, &EffectBasket::slotReloadBasket); connect(m_effectList, &EffectsListView::reloadBasket, this, &EffectBasket::slotReloadBasket);
connect(this, SIGNAL(itemActivated(QListWidgetItem *)), this, SLOT(slotAddEffect(QListWidgetItem *)));
} }
void EffectBasket::slotReloadBasket() void EffectBasket::slotReloadBasket()
...@@ -65,6 +66,20 @@ QMimeData *EffectBasket::mimeData(const QList<QListWidgetItem *> list) const ...@@ -65,6 +66,20 @@ QMimeData *EffectBasket::mimeData(const QList<QListWidgetItem *> list) const
return mime; return mime;
} }
void EffectBasket::showEvent(QShowEvent * event)
{
QListWidget::showEvent(event);
if (!currentItem()) {
setCurrentRow(0);
}
}
void EffectBasket::slotAddEffect(QListWidgetItem *item)
{
int type = item->data(EffectsListWidget::TypeRole).toInt();
QStringList info = item->data(EffectsListWidget::IdRole).toStringList();
QDomElement effect = EffectsListWidget::itemEffect(type, info);
emit addEffect(effect);
}
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#define EFFECTBASKET_H #define EFFECTBASKET_H
#include <QListWidget> #include <QListWidget>
#include <QDomElement>
class EffectsListView; class EffectsListView;
...@@ -40,12 +41,17 @@ public: ...@@ -40,12 +41,17 @@ public:
protected: protected:
QMimeData *mimeData(const QList<QListWidgetItem *> list) const; QMimeData *mimeData(const QList<QListWidgetItem *> list) const;
void showEvent(QShowEvent * event);
private: private:
EffectsListView *m_effectList; EffectsListView *m_effectList;
private slots: private slots:
void slotReloadBasket(); void slotReloadBasket();
void slotAddEffect(QListWidgetItem *item);
signals:
void addEffect(QDomElement);
}; };
......
...@@ -304,9 +304,12 @@ MainWindow::MainWindow(const QString &MltPath, const QUrl &Url, const QString & ...@@ -304,9 +304,12 @@ MainWindow::MainWindow(const QString &MltPath, const QUrl &Url, const QString &
// Create Effect Basket (dropdown list of favorites) // Create Effect Basket (dropdown list of favorites)
m_effectBasket = new EffectBasket(m_effectList); m_effectBasket = new EffectBasket(m_effectList);
connect(m_effectBasket, SIGNAL(addEffect(QDomElement)), this, SLOT(slotAddEffect(QDomElement)));
QWidgetAction *widgetlist = new QWidgetAction(this); QWidgetAction *widgetlist = new QWidgetAction(this);
widgetlist->setText(i18n("Favorite Effects"));
widgetlist->setDefaultWidget(m_effectBasket); widgetlist->setDefaultWidget(m_effectBasket);
widgetlist->setText(i18n("Favorite Effects"));
widgetlist->setToolTip(i18n("Favorite Effects"));
widgetlist->setIcon(KoIconUtils::themedIcon("favorite"));
QMenu *menu = new QMenu(this); QMenu *menu = new QMenu(this);
menu->addAction(widgetlist); menu->addAction(widgetlist);
...@@ -314,15 +317,19 @@ MainWindow::MainWindow(const QString &MltPath, const QUrl &Url, const QString & ...@@ -314,15 +317,19 @@ MainWindow::MainWindow(const QString &MltPath, const QUrl &Url, const QString &
basketButton->setMenu(menu); basketButton->setMenu(menu);
basketButton->setDefaultAction(widgetlist); basketButton->setDefaultAction(widgetlist);
basketButton->setPopupMode(QToolButton::InstantPopup); basketButton->setPopupMode(QToolButton::InstantPopup);
basketButton->setIcon(KoIconUtils::themedIcon("favorite"));
basketButton->setToolTip(i18n("Favorite Effects"));
basketButton->setText(i18n("Favorite Effects")); basketButton->setText(i18n("Favorite Effects"));
basketButton->setShortcut(Qt::CTRL + Qt::Key_R); basketButton->setToolTip(i18n("Favorite Effects"));
actionCollection()->addAction("fav_aff", basketButton); basketButton->setIcon(KoIconUtils::themedIcon("favorite"));
setupGUI();
QToolBar *extraTB = static_cast<QToolBar*>(factory()->container("extraToolBar", this)); QWidgetAction* toolButtonAction = new QWidgetAction(this);
extraTB->addWidget(basketButton); toolButtonAction->setText(i18n("Favorite Effects"));
toolButtonAction->setIcon(KoIconUtils::themedIcon("favorite"));
toolButtonAction->setDefaultWidget(basketButton);
addAction("favorite_effects", toolButtonAction);
connect(toolButtonAction, SIGNAL(triggered(bool)), basketButton, SLOT(showMenu()));
setupGUI();
/*ScriptingPart* sp = new ScriptingPart(this, QStringList()); /*ScriptingPart* sp = new ScriptingPart(this, QStringList());
guiFactory()->addClient(sp);*/ guiFactory()->addClient(sp);*/
...@@ -2662,7 +2669,6 @@ void MainWindow::loadClipActions() ...@@ -2662,7 +2669,6 @@ void MainWindow::loadClipActions()
QList <QAction *>tcActions = getExtraActions("transcoderslist"); QList <QAction *>tcActions = getExtraActions("transcoderslist");
unplugActionList("transcoders_list"); unplugActionList("transcoders_list");
plugActionList("transcoders_list", tcActions); plugActionList("transcoders_list", tcActions);
} }
void MainWindow::loadDockActions() void MainWindow::loadDockActions()
......
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