fixed menu bugs introduced in f2bff5f150
Turns out setting a QMenu parent *not* in the constructor leads to very strange behavior. All parents are now set in the constructor.
This commit is contained in:
@@ -63,9 +63,9 @@ void NodeFactory::Destroy()
|
||||
library_.clear();
|
||||
}
|
||||
|
||||
Menu *NodeFactory::CreateMenu()
|
||||
Menu *NodeFactory::CreateMenu(QWidget* parent)
|
||||
{
|
||||
Menu* menu = new Menu();
|
||||
Menu* menu = new Menu(parent);
|
||||
menu->setToolTipsVisible(true);
|
||||
|
||||
for (int i=0;i<library_.size();i++) {
|
||||
@@ -98,8 +98,7 @@ Menu *NodeFactory::CreateMenu()
|
||||
|
||||
// Create menu here if it doesn't exist
|
||||
if (!found_cat) {
|
||||
Menu* new_category = new Menu(dir_name);
|
||||
new_category->setParent(destination);
|
||||
Menu* new_category = new Menu(dir_name, destination);
|
||||
destination->InsertAlphabetically(new_category);
|
||||
destination = new_category;
|
||||
}
|
||||
|
||||
+1
-1
@@ -55,7 +55,7 @@ public:
|
||||
|
||||
static void Destroy();
|
||||
|
||||
static Menu* CreateMenu();
|
||||
static Menu* CreateMenu(QWidget *parent);
|
||||
|
||||
static Node* CreateFromMenuAction(QAction* action);
|
||||
|
||||
|
||||
@@ -89,9 +89,8 @@ void FootageComboBox::TraverseFolder(const Folder *f, QMenu *m)
|
||||
|
||||
if (child->CanHaveChildren()) {
|
||||
|
||||
Menu* sub = new Menu(child->name());
|
||||
Menu* sub = new Menu(child->name(), m);
|
||||
m->addMenu(sub);
|
||||
sub->setParent(m);
|
||||
|
||||
TraverseFolder(static_cast<Folder*>(child), sub);
|
||||
|
||||
@@ -100,9 +99,8 @@ void FootageComboBox::TraverseFolder(const Folder *f, QMenu *m)
|
||||
Footage* footage = static_cast<Footage*>(child);
|
||||
|
||||
if (!only_show_ready_footage_ || footage->status() == Footage::kReady) {
|
||||
Menu* stream_menu = new Menu(footage->name());
|
||||
Menu* stream_menu = new Menu(footage->name(), m);
|
||||
m->addMenu(stream_menu);
|
||||
stream_menu->setParent(m);
|
||||
|
||||
foreach (StreamPtr stream, footage->streams()) {
|
||||
QAction* stream_action = stream_menu->addAction(FootageToString(stream.get()));
|
||||
|
||||
@@ -52,7 +52,7 @@ Menu::Menu(const QString &s, QWidget *parent) :
|
||||
|
||||
QAction* Menu::InsertAlphabetically(const QString &s)
|
||||
{
|
||||
QAction* action = new QAction(s);
|
||||
QAction* action = new QAction(s, this);
|
||||
InsertAlphabetically(action);
|
||||
return action;
|
||||
}
|
||||
@@ -73,9 +73,7 @@ void Menu::InsertAlphabetically(QAction *entry)
|
||||
|
||||
void Menu::InsertAlphabetically(Menu *menu)
|
||||
{
|
||||
QAction* action = new QAction(menu->title());
|
||||
action->setMenu(menu);
|
||||
InsertAlphabetically(action);
|
||||
InsertAlphabetically(menu->menuAction());
|
||||
}
|
||||
|
||||
void Menu::ConformItem(QAction *a, const QString &id, const QString &key)
|
||||
|
||||
@@ -305,11 +305,10 @@ void NodeView::ShowContextMenu(const QPoint &pos)
|
||||
|
||||
Menu m;
|
||||
|
||||
Menu* add_menu = NodeFactory::CreateMenu();
|
||||
Menu* add_menu = NodeFactory::CreateMenu(&m);
|
||||
add_menu->setTitle(tr("Add"));
|
||||
connect(add_menu, &Menu::triggered, this, &NodeView::CreateNodeSlot);
|
||||
m.addMenu(add_menu);
|
||||
add_menu->setParent(&m);
|
||||
|
||||
m.exec(mapToGlobal(pos));
|
||||
}
|
||||
|
||||
@@ -523,9 +523,8 @@ void ViewerWidget::ShowContextMenu(const QPoint &pos)
|
||||
{
|
||||
QStringList displays = context_menu_widget_->color_manager()->ListAvailableDisplays();
|
||||
|
||||
Menu* ocio_display_menu = new Menu(tr("Display"));
|
||||
Menu* ocio_display_menu = new Menu(tr("Display"), &menu);
|
||||
menu.addMenu(ocio_display_menu);
|
||||
ocio_display_menu->setParent(&menu);
|
||||
|
||||
connect(ocio_display_menu, &QMenu::triggered, this, &ViewerWidget::ContextMenuOCIODisplay);
|
||||
foreach (const QString& d, displays) {
|
||||
@@ -539,9 +538,8 @@ void ViewerWidget::ShowContextMenu(const QPoint &pos)
|
||||
{
|
||||
QStringList views = context_menu_widget_->color_manager()->ListAvailableViews(context_menu_widget_->ocio_display());
|
||||
|
||||
Menu* ocio_view_menu = new Menu(tr("View"));
|
||||
Menu* ocio_view_menu = new Menu(tr("View"), &menu);
|
||||
menu.addMenu(ocio_view_menu);
|
||||
ocio_view_menu->setParent(&menu);
|
||||
|
||||
connect(ocio_view_menu, &QMenu::triggered, this, &ViewerWidget::ContextMenuOCIOView);
|
||||
foreach (const QString& v, views) {
|
||||
@@ -555,9 +553,8 @@ void ViewerWidget::ShowContextMenu(const QPoint &pos)
|
||||
{
|
||||
QStringList looks = context_menu_widget_->color_manager()->ListAvailableLooks();
|
||||
|
||||
Menu* ocio_look_menu = new Menu(tr("Look"));
|
||||
Menu* ocio_look_menu = new Menu(tr("Look"), &menu);
|
||||
menu.addMenu(ocio_look_menu);
|
||||
ocio_look_menu->setParent(&menu);
|
||||
|
||||
connect(ocio_look_menu, &QMenu::triggered, this, &ViewerWidget::ContextMenuOCIOLook);
|
||||
QAction* no_look_action = ocio_look_menu->addAction(tr("(None)"));
|
||||
@@ -576,9 +573,8 @@ void ViewerWidget::ShowContextMenu(const QPoint &pos)
|
||||
|
||||
{
|
||||
// Playback resolution
|
||||
Menu* playback_resolution_menu = new Menu(tr("Resolution"));
|
||||
Menu* playback_resolution_menu = new Menu(tr("Resolution"), &menu);
|
||||
menu.addMenu(playback_resolution_menu);
|
||||
playback_resolution_menu->setParent(&menu);
|
||||
|
||||
playback_resolution_menu->addAction(tr("Full"))->setData(1);
|
||||
int dividers[] = {2, 4, 8, 16};
|
||||
@@ -597,9 +593,8 @@ void ViewerWidget::ShowContextMenu(const QPoint &pos)
|
||||
|
||||
{
|
||||
// Viewer Zoom Level
|
||||
Menu* zoom_menu = new Menu(tr("Zoom"));
|
||||
Menu* zoom_menu = new Menu(tr("Zoom"), &menu);
|
||||
menu.addMenu(zoom_menu);
|
||||
zoom_menu->setParent(&menu);
|
||||
|
||||
int zoom_levels[] = {10, 25, 50, 75, 100, 150, 200, 400};
|
||||
zoom_menu->addAction(tr("Fit"))->setData(0);
|
||||
@@ -612,9 +607,8 @@ void ViewerWidget::ShowContextMenu(const QPoint &pos)
|
||||
|
||||
{
|
||||
// Full Screen Menu
|
||||
Menu* full_screen_menu = new Menu(tr("Full Screen"));
|
||||
Menu* full_screen_menu = new Menu(tr("Full Screen"), &menu);
|
||||
menu.addMenu(full_screen_menu);
|
||||
full_screen_menu->setParent(&menu);
|
||||
|
||||
for (int i=0;i<QGuiApplication::screens().size();i++) {
|
||||
QScreen* s = QGuiApplication::screens().at(i);
|
||||
@@ -633,9 +627,8 @@ void ViewerWidget::ShowContextMenu(const QPoint &pos)
|
||||
|
||||
{
|
||||
// Safe Margins
|
||||
Menu* safe_margin_menu = new Menu(tr("Safe Margins"));
|
||||
Menu* safe_margin_menu = new Menu(tr("Safe Margins"), &menu);
|
||||
menu.addMenu(safe_margin_menu);
|
||||
safe_margin_menu->setParent(&menu);
|
||||
|
||||
QAction* safe_margin_off = safe_margin_menu->addAction(tr("Off"));
|
||||
safe_margin_off->setCheckable(true);
|
||||
|
||||
Reference in New Issue
Block a user