Skip to content

Commit

Permalink
Mark invalid commands as broken instead of hiding them.
Browse files Browse the repository at this point in the history
  • Loading branch information
0xb8 committed May 7, 2023
1 parent a7ce011 commit e6d147f
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1010,7 +1010,6 @@ void Window::processNewVersion(QNetworkReply *r)

void Window::createCommands()
{
menu_commands.setDisabled(true);
QSettings settings;
auto size = settings.beginReadArray(SETT_COMMANDS_KEY);
for(auto i{0}; i < size; ++i) {
Expand All @@ -1030,13 +1029,17 @@ void Window::createCommands()
}

auto binary = cmd.first();
cmd.removeFirst();

auto action = menu_commands.addAction(name);
if(!QFile::exists(binary)) {
pwarn << "Invalid command: executable does not exist";
pwarn << "Invalid command: executable does not exist:" << binary;
action->setText(QStringLiteral("! %1").arg(action->text()));
action->setToolTip(tr("Executable \"%1\" does not exist!").arg(binary));
action->setEnabled(false);
continue;
}
cmd.removeFirst();

auto action = menu_commands.addAction(name);
this->addAction(action); // NOTE: to make hotkeys work when menubar is hidden, does not take ownership
action->setIcon(util::get_icon_from_executable(binary));
if(!hkey.isEmpty()) {
Expand Down Expand Up @@ -1152,7 +1155,6 @@ void Window::createCommands()

}
});
menu_commands.setEnabled(true);
}
settings.endArray();
}
Expand Down Expand Up @@ -1405,7 +1407,7 @@ void Window::createActions()
{
QSettings settings; settings.setValue(SETT_FORCE_AUTHOR_FIRST, checked);
});
connect(&a_navigate_by_wheel, &QAction::triggered, [this](bool checked)
connect(&a_navigate_by_wheel, &QAction::triggered, [](bool checked)
{
QSettings settings; settings.setValue(SETT_NAVIGATE_BY_WHEEL, checked);
});
Expand Down Expand Up @@ -1825,6 +1827,7 @@ void Window::createMenus()
menuBar()->addMenu(&menu_navigation);
menuBar()->addMenu(&menu_view);
a_menu_commands_action = menuBar()->addMenu(&menu_commands);
menu_commands.setToolTipsVisible(true);
menuBar()->addMenu(&menu_options);
menuBar()->addMenu(&menu_help);
menuBar()->addSeparator();
Expand Down Expand Up @@ -1871,9 +1874,7 @@ void Window::updateMenus()
a_save_session.setDisabled(val);
a_go_to_number.setDisabled(val);
a_edit_temp_tags.setDisabled(val);
for(auto action : menu_commands.actions()) {
action->setDisabled(val);
}
menu_commands.setDisabled(val);

bool is_playable = m_tagger.mediaIsVideo() || m_tagger.mediaIsAnimatedImage();
if (is_playable) {
Expand Down

0 comments on commit e6d147f

Please sign in to comment.