Questionable reference to q. pointer
This commit is contained in:
+10
-10
@@ -76,8 +76,8 @@ ContextMenu::fill_items(const QUrl &url)
|
||||
if (apps_sep && !added)
|
||||
apps->add_sep();
|
||||
added = true;
|
||||
auto &item = apps->add_item(app.name.isEmpty() ? app.id : app.name);
|
||||
item.on_click = [app, path](Kit &) {
|
||||
auto *item = apps->add_item(app.name.isEmpty() ? app.id : app.name);
|
||||
item->on_click = [app, path](Kit &) {
|
||||
launch(app, path);
|
||||
set_last_used(app, path);
|
||||
};
|
||||
@@ -90,31 +90,31 @@ ContextMenu::fill_items(const QUrl &url)
|
||||
add_apps(rec);
|
||||
add_apps(fall);
|
||||
|
||||
auto &new_win = add_item_with_mnemonic("Open in New _Window");
|
||||
new_win.on_click = [this, url](Kit &) {
|
||||
auto *new_win = add_item_with_mnemonic("Open in New _Window");
|
||||
new_win->on_click = [this, url](Kit &) {
|
||||
if (this->on_new_window)
|
||||
this->on_new_window(url);
|
||||
};
|
||||
if (apps_sep) {
|
||||
add_item_with_mnemonic("Open _With").sub = apps.get();
|
||||
add_item_with_mnemonic("Open _With")->sub = apps.get();
|
||||
this->subs_.push_back(std::move(apps));
|
||||
}
|
||||
if (QFileInfo(path).isDir() && this->on_bookmarked &&
|
||||
this->on_toggle_bookmark) {
|
||||
add_sep();
|
||||
auto &bookmark = add_item_with_mnemonic(this->on_bookmarked(url)
|
||||
auto *bookmark = add_item_with_mnemonic(this->on_bookmarked(url)
|
||||
? "Remove from _Bookmarks"
|
||||
: "Add to _Bookmarks");
|
||||
bookmark.on_click = [this, url](Kit &) {
|
||||
bookmark->on_click = [this, url](Kit &) {
|
||||
if (this->on_toggle_bookmark)
|
||||
this->on_toggle_bookmark(url);
|
||||
};
|
||||
}
|
||||
if (QFileInfo(path).isFile() && this->on_trash) {
|
||||
add_sep();
|
||||
auto &trash = add_item_with_mnemonic("Move to _Trash");
|
||||
trash.accel = action_accel(action_def(Action::Trash));
|
||||
trash.on_click = [this, url](Kit &) {
|
||||
auto *trash = add_item_with_mnemonic("Move to _Trash");
|
||||
trash->accel = action_accel(action_def(Action::Trash));
|
||||
trash->on_click = [this, url](Kit &) {
|
||||
if (this->on_trash)
|
||||
this->on_trash(url);
|
||||
};
|
||||
|
||||
+11
-11
@@ -2690,23 +2690,23 @@ Menu::Menu()
|
||||
add_child(std::move(c));
|
||||
}
|
||||
|
||||
MenuItem &
|
||||
MenuItem *
|
||||
Menu::add_item(const QString &text)
|
||||
{
|
||||
auto item = make_unique<MenuItem>();
|
||||
item->text = text;
|
||||
MenuItem &ref = *item;
|
||||
MenuItem *ref = item.get();
|
||||
if (this->col)
|
||||
this->col->add_child(std::move(item));
|
||||
return ref;
|
||||
}
|
||||
|
||||
MenuItem &
|
||||
MenuItem *
|
||||
Menu::add_item_with_mnemonic(const QString &text)
|
||||
{
|
||||
auto item = make_unique<MenuItem>();
|
||||
item->text = menu_label(text.toStdString().c_str(), &item->mnemonic);
|
||||
MenuItem &ref = *item;
|
||||
MenuItem *ref = item.get();
|
||||
if (this->col)
|
||||
this->col->add_child(std::move(item));
|
||||
return ref;
|
||||
@@ -2740,8 +2740,8 @@ Menu::build(span<const MenuNode> nodes, const Actor &a)
|
||||
if (!node.items.empty()) {
|
||||
auto child = make_unique<Menu>();
|
||||
child->build(node.items, this->actor);
|
||||
auto &item = add_item_with_mnemonic(node.title);
|
||||
item.sub = child.get();
|
||||
auto *item = add_item_with_mnemonic(node.title);
|
||||
item->sub = child.get();
|
||||
this->subs_.push_back(std::move(child));
|
||||
continue;
|
||||
}
|
||||
@@ -2751,11 +2751,11 @@ Menu::build(span<const MenuNode> nodes, const Actor &a)
|
||||
}
|
||||
const Action action = node.action;
|
||||
const ActionDef &def = action_def(action);
|
||||
auto &item = add_item_with_mnemonic(action_label(def, false));
|
||||
item.action = action;
|
||||
item.accel = accel_label(def);
|
||||
item.checkable = (def.flags & ActionToggle) && !def.label[1];
|
||||
item.on_click = [this, action](Kit &) {
|
||||
auto *item = add_item_with_mnemonic(action_label(def, false));
|
||||
item->action = action;
|
||||
item->accel = accel_label(def);
|
||||
item->checkable = (def.flags & ActionToggle) && !def.label[1];
|
||||
item->on_click = [this, action](Kit &) {
|
||||
if (this->actor.apply)
|
||||
this->actor.apply(action);
|
||||
};
|
||||
|
||||
+2
-2
@@ -544,8 +544,8 @@ struct Menu : MenuPopup {
|
||||
Menu();
|
||||
void build(std::span<const MenuNode> nodes, const Actor &actor);
|
||||
void sync();
|
||||
MenuItem &add_item(const QString &text);
|
||||
MenuItem &add_item_with_mnemonic(const QString &text);
|
||||
MenuItem *add_item(const QString &text);
|
||||
MenuItem *add_item_with_mnemonic(const QString &text);
|
||||
void add_sep();
|
||||
void clear();
|
||||
void measure(Kit &kit, int max_w, int max_h) override;
|
||||
|
||||
Reference in New Issue
Block a user