mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-20 11:00:44 -06:00
Copy plot to clipboard
New context menu and shortcut (context restricted to widget) for copying the current plot to the clipboard as a pixmap.
This commit is contained in:
@@ -28,6 +28,28 @@ PlotDock::PlotDock(QWidget* parent)
|
||||
// connect slots that takes care that when an axis is selected, only that direction can be dragged and zoomed:
|
||||
connect(ui->plotWidget, SIGNAL(mousePress(QMouseEvent*)), this, SLOT(mousePress()));
|
||||
connect(ui->plotWidget, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(mouseWheel()));
|
||||
|
||||
QShortcut* shortcutCopy = new QShortcut(QKeySequence::Copy, ui->plotWidget, nullptr, nullptr, Qt::WidgetShortcut);
|
||||
connect(shortcutCopy, SIGNAL(activated()), this, SLOT(copy()));
|
||||
|
||||
ui->plotWidget->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
|
||||
// Set up context menu
|
||||
m_contextMenu = new QMenu(this);
|
||||
QAction* copyAction = new QAction(QIcon(":/icons/copy"), tr("Copy"), m_contextMenu);
|
||||
copyAction->setShortcut(shortcutCopy->key());
|
||||
m_contextMenu->addAction(copyAction);
|
||||
|
||||
connect(copyAction, &QAction::triggered, [&]() {
|
||||
copy();
|
||||
});
|
||||
|
||||
connect(ui->plotWidget, &QTableView::customContextMenuRequested,
|
||||
[=](const QPoint& pos) {
|
||||
// Show menu
|
||||
m_contextMenu->popup(ui->plotWidget->mapToGlobal(pos));
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
PlotDock::~PlotDock()
|
||||
@@ -612,3 +634,8 @@ void PlotDock::mouseWheel()
|
||||
else
|
||||
ui->plotWidget->axisRect()->setRangeZoom(Qt::Horizontal | Qt::Vertical);
|
||||
}
|
||||
|
||||
void PlotDock::copy()
|
||||
{
|
||||
QApplication::clipboard()->setPixmap(ui->plotWidget->toPixmap());
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <QDialog>
|
||||
#include <QVariant>
|
||||
#include <QMenu>
|
||||
|
||||
class SqliteTableModel;
|
||||
class QTreeWidgetItem;
|
||||
@@ -81,6 +82,7 @@ private:
|
||||
|
||||
SqliteTableModel* m_currentPlotModel;
|
||||
BrowseDataTableSettings* m_currentTableSettings;
|
||||
QMenu* m_contextMenu;
|
||||
|
||||
/*!
|
||||
* \brief guessdatatype try to parse the first 10 rows and decide the datatype
|
||||
@@ -99,6 +101,8 @@ private slots:
|
||||
void selectionChanged();
|
||||
void mousePress();
|
||||
void mouseWheel();
|
||||
void copy();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user