move add tool items to main menu
Makes them shortcut-assignable. Fixes #2158
This commit is contained in:
@@ -41,7 +41,6 @@ ToolPanel::ToolPanel() :
|
||||
connect(t, &Toolbar::SnappingChanged, Core::instance(), &Core::SetSnapping);
|
||||
connect(Core::instance(), &Core::SnappingChanged, t, &Toolbar::SetSnapping);
|
||||
|
||||
connect(t, &Toolbar::AddableObjectChanged, Core::instance(), &Core::SetSelectedAddableObject);
|
||||
connect(t, &Toolbar::SelectedTransitionChanged, Core::instance(), &Core::SetSelectedTransitionObject);
|
||||
|
||||
Retranslate();
|
||||
|
||||
@@ -132,6 +132,30 @@ public:
|
||||
return QCoreApplication::translate("Tool", "Unknown");
|
||||
}
|
||||
|
||||
static QString GetAddableObjectID(const AddableObject& a)
|
||||
{
|
||||
switch (a) {
|
||||
case kAddableEmpty:
|
||||
return QStringLiteral("empty");
|
||||
case kAddableBars:
|
||||
return QStringLiteral("bars");
|
||||
case kAddableShape:
|
||||
return QStringLiteral("shape");
|
||||
case kAddableSolid:
|
||||
return QStringLiteral("solid");
|
||||
case kAddableTitle:
|
||||
return QStringLiteral("title");
|
||||
case kAddableTone:
|
||||
return QStringLiteral("tone");
|
||||
case kAddableSubtitle:
|
||||
return QStringLiteral("subtitle");
|
||||
case kAddableCount:
|
||||
break;
|
||||
}
|
||||
|
||||
return QString();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -50,6 +50,14 @@ MenuShared::MenuShared()
|
||||
edit_split_item_ = Menu::CreateItem(this, "split", this, &MenuShared::SplitAtPlayheadTriggered, tr("Ctrl+K"));
|
||||
edit_speedduration_item_ = Menu::CreateItem(this, "speeddur", this, &MenuShared::SpeedDurationTriggered, tr("Ctrl+R"));
|
||||
|
||||
// List of addable items
|
||||
for (int i=0;i<Tool::kAddableCount;i++) {
|
||||
Tool::AddableObject t = static_cast<Tool::AddableObject>(i);
|
||||
QAction *a = Menu::CreateItem(this, QStringLiteral("add:%1").arg(Tool::GetAddableObjectID(t)), this, &MenuShared::AddableItemTriggered);
|
||||
a->setData(t);
|
||||
addable_items_.append(a);
|
||||
}
|
||||
|
||||
// "In/Out" menu shared items
|
||||
inout_set_in_item_ = Menu::CreateItem(this, "setinpoint", this, &MenuShared::SetInTriggered, tr("I"));
|
||||
inout_set_out_item_ = Menu::CreateItem(this, "setoutpoint", this, &MenuShared::SetOutTriggered, tr("O"));
|
||||
@@ -150,6 +158,14 @@ void MenuShared::AddItemsForEditMenu(Menu *m, bool for_clips)
|
||||
}
|
||||
}
|
||||
|
||||
void MenuShared::AddItemsForAddableObjectsMenu(Menu *m)
|
||||
{
|
||||
for (QAction *a : qAsConst(addable_items_)) {
|
||||
a->setChecked((a->data().toInt() == Core::instance()->GetSelectedAddableObject()));
|
||||
m->addAction(a);
|
||||
}
|
||||
}
|
||||
|
||||
void MenuShared::AddItemsForInOutMenu(Menu *m)
|
||||
{
|
||||
m->addAction(inout_set_in_item_);
|
||||
@@ -328,6 +344,14 @@ void MenuShared::SpeedDurationTriggered()
|
||||
}
|
||||
}
|
||||
|
||||
void MenuShared::AddableItemTriggered()
|
||||
{
|
||||
QAction *a = static_cast<QAction*>(sender());
|
||||
Tool::AddableObject i = static_cast<Tool::AddableObject>(a->data().toInt());
|
||||
Core::instance()->SetTool(Tool::kAdd);
|
||||
Core::instance()->SetSelectedAddableObject(i);
|
||||
}
|
||||
|
||||
void MenuShared::Retranslate()
|
||||
{
|
||||
// "New" menu shared items
|
||||
@@ -347,6 +371,10 @@ void MenuShared::Retranslate()
|
||||
edit_split_item_->setText(tr("Split"));
|
||||
edit_speedduration_item_->setText(tr("Speed/Duration"));
|
||||
|
||||
for (QAction *a : qAsConst(addable_items_)) {
|
||||
a->setText(Tool::GetAddableObjectName(static_cast<Tool::AddableObject>(a->data().toInt())));
|
||||
}
|
||||
|
||||
// "In/Out" menu shared items
|
||||
inout_set_in_item_->setText(tr("Set In Point"));
|
||||
inout_set_out_item_->setText(tr("Set Out Point"));
|
||||
|
||||
@@ -32,7 +32,8 @@ using namespace core;
|
||||
/**
|
||||
* @brief A static object that provides various "stock" menus for use throughout the application
|
||||
*/
|
||||
class MenuShared : public QObject {
|
||||
class MenuShared : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MenuShared();
|
||||
@@ -45,6 +46,7 @@ public:
|
||||
|
||||
void AddItemsForNewMenu(Menu* m);
|
||||
void AddItemsForEditMenu(Menu* m, bool for_clips);
|
||||
void AddItemsForAddableObjectsMenu(Menu* m);
|
||||
void AddItemsForInOutMenu(Menu* m);
|
||||
void AddColorCodingMenu(Menu* m);
|
||||
void AddItemsForClipEditMenu(Menu* m);
|
||||
@@ -80,6 +82,9 @@ private:
|
||||
QAction* edit_split_item_;
|
||||
QAction* edit_speedduration_item_;
|
||||
|
||||
// List of addable items
|
||||
QVector<QAction*> addable_items_;
|
||||
|
||||
// "In/Out" menu shared items
|
||||
QAction* inout_set_in_item_;
|
||||
QAction* inout_set_out_item_;
|
||||
@@ -153,6 +158,8 @@ private slots:
|
||||
|
||||
void SpeedDurationTriggered();
|
||||
|
||||
void AddableItemTriggered();
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "node/factory.h"
|
||||
#include "ui/icons/icons.h"
|
||||
#include "widget/menu/menu.h"
|
||||
#include "widget/menu/menushared.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
@@ -191,12 +192,7 @@ void Toolbar::AddButtonClicked()
|
||||
{
|
||||
Menu m(this);
|
||||
|
||||
for (int i=0;i<Tool::kAddableCount;i++) {
|
||||
QAction* action = m.addAction(Tool::GetAddableObjectName(static_cast<Tool::AddableObject>(i)));
|
||||
action->setData(i);
|
||||
}
|
||||
|
||||
connect(&m, &QMenu::triggered, this, &Toolbar::AddMenuItemTriggered);
|
||||
MenuShared::instance()->AddItemsForAddableObjectsMenu(&m);
|
||||
|
||||
m.exec(QCursor::pos());
|
||||
}
|
||||
@@ -212,11 +208,6 @@ void Toolbar::TransitionButtonClicked()
|
||||
delete m;
|
||||
}
|
||||
|
||||
void Toolbar::AddMenuItemTriggered(QAction* a)
|
||||
{
|
||||
emit AddableObjectChanged(static_cast<Tool::AddableObject>(a->data().toInt()));
|
||||
}
|
||||
|
||||
void Toolbar::TransitionMenuItemTriggered(QAction *a)
|
||||
{
|
||||
emit SelectedTransitionChanged(NodeFactory::GetIDFromMenuAction(a));
|
||||
|
||||
@@ -110,11 +110,6 @@ signals:
|
||||
*/
|
||||
void SnappingChanged(const bool& b);
|
||||
|
||||
/**
|
||||
* @brief Emitted when the addable object is changed from the add tool menu
|
||||
*/
|
||||
void AddableObjectChanged(const Tool::AddableObject& obj);
|
||||
|
||||
/**
|
||||
* @brief Emitted when the selected transition is changed from the transition tool menu
|
||||
*/
|
||||
@@ -225,11 +220,6 @@ private slots:
|
||||
*/
|
||||
void TransitionButtonClicked();
|
||||
|
||||
/**
|
||||
* @brief Receiver for the menu created by AddButtonClicked()
|
||||
*/
|
||||
void AddMenuItemTriggered(QAction* a);
|
||||
|
||||
/**
|
||||
* @brief Receiver for the menu created by TransitionButtonClicked()
|
||||
*/
|
||||
|
||||
@@ -266,6 +266,13 @@ MainMenu::MainMenu(MainWindow *parent) :
|
||||
|
||||
tools_menu_->addSeparator();
|
||||
|
||||
tools_add_item_menu_ = new Menu(tools_menu_);
|
||||
tools_menu_->addMenu(tools_add_item_menu_);
|
||||
|
||||
MenuShared::instance()->AddItemsForAddableObjectsMenu(tools_add_item_menu_);
|
||||
|
||||
tools_menu_->addSeparator();
|
||||
|
||||
tools_snapping_item_ = tools_menu_->AddItem("snapping", Core::instance(), &Core::SetSnapping, tr("S"));
|
||||
tools_snapping_item_->setCheckable(true);
|
||||
tools_snapping_item_->setChecked(Core::instance()->snapping());
|
||||
@@ -772,6 +779,7 @@ void MainMenu::Retranslate()
|
||||
tools_record_item_->setText(tr("Record Tool"));
|
||||
tools_snapping_item_->setText(tr("Enable Snapping"));
|
||||
tools_preferences_item_->setText(tr("Preferences"));
|
||||
tools_add_item_menu_->setTitle(tr("Add Tool Item"));
|
||||
#ifndef NDEBUG
|
||||
tools_magic_item_->setText("Magic");
|
||||
#endif
|
||||
|
||||
@@ -281,6 +281,7 @@ private:
|
||||
QAction* tools_record_item_;
|
||||
QAction* tools_snapping_item_;
|
||||
QAction* tools_preferences_item_;
|
||||
Menu *tools_add_item_menu_;
|
||||
|
||||
#ifndef NDEBUG
|
||||
QAction* tools_magic_item_;
|
||||
|
||||
Reference in New Issue
Block a user