Improve context menu of db query widget
This commit is contained in:
parent
015dc06c17
commit
76ba02c3c0
|
@ -151,6 +151,7 @@ set(REQUIRED_ICONS
|
||||||
object-locked
|
object-locked
|
||||||
object-unlocked
|
object-unlocked
|
||||||
preferences-other
|
preferences-other
|
||||||
|
view-refresh
|
||||||
view-preview
|
view-preview
|
||||||
document-open-recent
|
document-open-recent
|
||||||
tag-add
|
tag-add
|
||||||
|
@ -180,6 +181,7 @@ set(REQUIRED_ICONS
|
||||||
view-list-tree
|
view-list-tree
|
||||||
document-edit
|
document-edit
|
||||||
edit-delete
|
edit-delete
|
||||||
|
search
|
||||||
system-search
|
system-search
|
||||||
document-revert
|
document-revert
|
||||||
dialog-ok
|
dialog-ok
|
||||||
|
|
|
@ -76,6 +76,8 @@ DbQueryWidget::DbQueryWidget(TagEditorWidget *tagEditorWidget, QWidget *parent)
|
||||||
|
|
||||||
// setup menu
|
// setup menu
|
||||||
const auto searchIcon = QIcon::fromTheme(QStringLiteral("search"));
|
const auto searchIcon = QIcon::fromTheme(QStringLiteral("search"));
|
||||||
|
m_menu->setTitle(tr("New search"));
|
||||||
|
m_menu->setIcon(searchIcon);
|
||||||
m_searchMusicBrainzAction = m_lastSearchAction = m_menu->addAction(tr("Query MusicBrainz"));
|
m_searchMusicBrainzAction = m_lastSearchAction = m_menu->addAction(tr("Query MusicBrainz"));
|
||||||
m_searchMusicBrainzAction->setIcon(searchIcon);
|
m_searchMusicBrainzAction->setIcon(searchIcon);
|
||||||
m_searchMusicBrainzAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M));
|
m_searchMusicBrainzAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M));
|
||||||
|
@ -513,25 +515,21 @@ void DbQueryWidget::insertSearchTermsFromActiveTagEdit()
|
||||||
void DbQueryWidget::showResultsContextMenu(const QPoint &pos)
|
void DbQueryWidget::showResultsContextMenu(const QPoint &pos)
|
||||||
{
|
{
|
||||||
const auto *const selectionModel = m_ui->resultsTreeView->selectionModel();
|
const auto *const selectionModel = m_ui->resultsTreeView->selectionModel();
|
||||||
if (!selectionModel) {
|
const auto hasSelection = selectionModel && !selectionModel->selection().isEmpty();
|
||||||
return;
|
|
||||||
}
|
|
||||||
const auto selection = selectionModel->selection().indexes();
|
|
||||||
if (selection.isEmpty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
QMenu contextMenu;
|
QMenu contextMenu;
|
||||||
if (m_ui->applyPushButton->isEnabled()) {
|
if (hasSelection && m_ui->applyPushButton->isEnabled()) {
|
||||||
contextMenu.addAction(m_ui->applyPushButton->icon(), tr("Use selected row"), this,
|
contextMenu.addAction(m_ui->applyPushButton->icon(), tr("Use selected row"), this,
|
||||||
static_cast<void (DbQueryWidget::*)(void)>(&DbQueryWidget::applySelectedResults));
|
static_cast<void (DbQueryWidget::*)(void)>(&DbQueryWidget::applySelectedResults));
|
||||||
}
|
}
|
||||||
if (m_model && m_model->areResultsAvailable()) {
|
|
||||||
#ifndef QT_NO_CLIPBOARD
|
#ifndef QT_NO_CLIPBOARD
|
||||||
|
if (hasSelection) {
|
||||||
contextMenu.addAction(QIcon::fromTheme(QStringLiteral("edit-copy")), tr("Copy value"), this, &DbQueryWidget::copySelectedResult);
|
contextMenu.addAction(QIcon::fromTheme(QStringLiteral("edit-copy")), tr("Copy value"), this, &DbQueryWidget::copySelectedResult);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
if (!contextMenu.isEmpty()) {
|
contextMenu.addAction(QIcon::fromTheme(QStringLiteral("view-refresh")), tr("Refresh results"), m_lastSearchAction, &QAction::trigger);
|
||||||
contextMenu.addSeparator();
|
if (hasSelection) {
|
||||||
}
|
contextMenu.addSeparator();
|
||||||
contextMenu.addAction(
|
contextMenu.addAction(
|
||||||
QIcon::fromTheme(QStringLiteral("view-preview")), tr("Show cover"), this, &DbQueryWidget::fetchAndShowCoverForSelection);
|
QIcon::fromTheme(QStringLiteral("view-preview")), tr("Show cover"), this, &DbQueryWidget::fetchAndShowCoverForSelection);
|
||||||
contextMenu.addAction(
|
contextMenu.addAction(
|
||||||
|
@ -539,6 +537,10 @@ void DbQueryWidget::showResultsContextMenu(const QPoint &pos)
|
||||||
contextMenu.addAction(
|
contextMenu.addAction(
|
||||||
QIcon::fromTheme(QStringLiteral("internet-web-browser")), tr("Show in browser"), this, &DbQueryWidget::openSelectionInBrowser);
|
QIcon::fromTheme(QStringLiteral("internet-web-browser")), tr("Show in browser"), this, &DbQueryWidget::openSelectionInBrowser);
|
||||||
}
|
}
|
||||||
|
if (!contextMenu.isEmpty()) {
|
||||||
|
contextMenu.addSeparator();
|
||||||
|
}
|
||||||
|
contextMenu.addMenu(m_menu);
|
||||||
m_contextMenuPos = m_ui->resultsTreeView->viewport()->mapToGlobal(pos);
|
m_contextMenuPos = m_ui->resultsTreeView->viewport()->mapToGlobal(pos);
|
||||||
contextMenu.exec(m_contextMenuPos);
|
contextMenu.exec(m_contextMenuPos);
|
||||||
}
|
}
|
||||||
|
@ -631,7 +633,7 @@ void DbQueryWidget::openSelectionInBrowser()
|
||||||
}
|
}
|
||||||
const auto url = m_model->webUrl(selectedIndex);
|
const auto url = m_model->webUrl(selectedIndex);
|
||||||
if (url.isEmpty()) {
|
if (url.isEmpty()) {
|
||||||
m_ui->notificationLabel->appendLine(tr("No web URL available."));
|
m_ui->notificationLabel->appendLine(tr("No web URL available"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!QDesktopServices::openUrl(url)) {
|
if (!QDesktopServices::openUrl(url)) {
|
||||||
|
|
Loading…
Reference in New Issue