customized context menu of info web view (to show "Copy" action only)
This commit is contained in:
parent
75803d91c7
commit
7067320673
|
@ -101,6 +101,8 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
#endif
|
||||
m_infoWebView->setObjectName(QStringLiteral("infoWebView"));
|
||||
m_infoWebView->setAcceptDrops(false);
|
||||
m_infoWebView->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(m_infoWebView, &QWidget::customContextMenuRequested, this, &MainWindow::showInfoWebViewContextMenu);
|
||||
m_ui->tagSplitter->addWidget(m_infoWebView);
|
||||
#ifdef Q_OS_WIN32
|
||||
setStyleSheet(QStringLiteral("* { font: 9pt \"Segoe UI\"; } #fileNameLabel, #optionsLabel { font-size: 12pt; color: #003399; } #rightWidget, #rightWidget QSplitter::handle { background-color: white; }"));
|
||||
|
@ -620,6 +622,27 @@ void MainWindow::updateInfoWebView()
|
|||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Shows the context menu for the info web view.
|
||||
*/
|
||||
void MainWindow::showInfoWebViewContextMenu(const QPoint &)
|
||||
{
|
||||
QAction copyAction(QIcon::fromTheme(QStringLiteral("edit-copy")), tr("Copy"), nullptr);
|
||||
copyAction.setDisabled(m_infoWebView->selectedText().isEmpty());
|
||||
connect(©Action, &QAction::triggered, this, &MainWindow::copyInfoWebViewSelection);
|
||||
QMenu menu;
|
||||
menu.addAction(©Action);
|
||||
menu.exec(QCursor::pos());
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Copies the current selection of the info web view.
|
||||
*/
|
||||
void MainWindow::copyInfoWebViewSelection()
|
||||
{
|
||||
QApplication::clipboard()->setText(m_infoWebView->selectedText());
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Calls the specified \a function for each of the currently present tag edits.
|
||||
*/
|
||||
|
|
|
@ -95,6 +95,8 @@ private slots:
|
|||
void showSettingsDlg();
|
||||
void showRenameFilesDlg();
|
||||
void updateInfoWebView();
|
||||
void showInfoWebViewContextMenu(const QPoint &);
|
||||
void copyInfoWebViewSelection();
|
||||
|
||||
private:
|
||||
void updateTagEditsAndAttachmentEdits(bool updateUi = true, PreviousValueHandling previousValueHandling = PreviousValueHandling::Auto);
|
||||
|
|
Loading…
Reference in New Issue