[Kst] branches/work/kst/portto4/kst/src/libkstapp
Barth Netterfield
netterfield at astro.utoronto.ca
Sat Dec 22 09:28:36 UTC 2012
SVN commit 1329457 by netterfield:
Add feature to copy parts of the window status bar:
X copies the X coordinate into the system clipboard
Y copies the Y coordinate into the system clipboard
^c copies the window statusMessage into the system clipboard.
M +4 -0 mainwindow.cpp
M +1 -0 mainwindow.h
M +50 -0 plotitem.cpp
M +10 -0 plotitem.h
--- branches/work/kst/portto4/kst/src/libkstapp/mainwindow.cpp #1329456:1329457
@@ -1527,6 +1527,10 @@
_messageLabel->setText(message);
}
+QString MainWindow::statusMessage() {
+ return _messageLabel->text();
+}
+
QProgressBar *MainWindow::progressBar() const {
return _progressBar;
}
--- branches/work/kst/portto4/kst/src/libkstapp/mainwindow.h #1329456:1329457
@@ -63,6 +63,7 @@
bool isHighlightPoint() { return _highlightPoint; }
bool isTiedTabs();
void setStatusMessage(QString message);
+ QString statusMessage();
static void setWidgetFlags(QWidget*);
void updateRecentKstFiles(const QString& newfilename = QString());
--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.cpp #1329456:1329457
@@ -44,6 +44,7 @@
#include <QMenu>
#include <QDebug>
#include <QGraphicsSceneMouseEvent>
+#include <QClipboard>
// Benchmark drawing
// undefined = None, 1 = PlotItem, 2 = More Details
@@ -530,9 +531,39 @@
_breakSharedBox->setShortcut(Qt::Key_B);
registerShortcut(_breakSharedBox);
connect(_breakSharedBox, SIGNAL(triggered()), this, SIGNAL(breakShareTriggered()));
+
+ _copyStatus = new QAction(tr("Copy Coordinates"), this);
+ _copyStatus->setShortcut(Qt::CTRL + Qt::Key_C);
+ registerShortcut(_copyStatus);
+ connect(_copyStatus, SIGNAL(triggered()), this, SLOT(copyStatus()));
+
+ _copyXCoord = new QAction(tr("Copy X Coordinate"), this);
+ _copyXCoord->setShortcut(Qt::Key_X);
+ registerShortcut(_copyXCoord);
+ connect(_copyXCoord, SIGNAL(triggered()), this, SLOT(copyXCoord()));
+
+ _copyYCoord = new QAction(tr("Copy Y Coordinate"), this);
+ _copyYCoord->setShortcut(Qt::Key_Y);
+ registerShortcut(_copyYCoord);
+ connect(_copyYCoord, SIGNAL(triggered()), this, SLOT(copyYCoord()));
+
+ createCopyMenu();
}
+void PlotItem::createCopyMenu() {
+ if (_copyMenu) {
+ delete _copyMenu;
+ }
+ _copyMenu = new QMenu;
+ _copyMenu->setTitle(tr("Copy"));
+
+ _copyMenu->addAction(_copyStatus);
+ _copyMenu->addAction(_copyXCoord);
+ _copyMenu->addAction(_copyYCoord);
+
+}
+
void PlotItem::createZoomMenu() {
if (_zoomMenu) {
delete _zoomMenu;
@@ -707,6 +738,8 @@
createEditMenu();
menu.addMenu(_editMenu);
}
+ menu.addMenu(_copyMenu);
+
}
@@ -3288,7 +3321,24 @@
}
}
+void PlotItem::copyStatus() {
+ kstApp->clipboard()->setText(kstApp->mainWindow()->statusMessage().remove('(').remove(')'));
+}
+void PlotItem::copyXCoord() {
+ QStringList args = kstApp->mainWindow()->statusMessage().remove('(').split(',');
+ if (args.size()>0) {
+ kstApp->clipboard()->setText(args.at(0));
+ }
+}
+
+void PlotItem::copyYCoord() {
+ QStringList args = kstApp->mainWindow()->statusMessage().remove(')').replace('[',',').split(',');
+ if (args.size()>1) {
+ kstApp->clipboard()->setText(args.at(1));
+ }
+}
+
QString PlotItem::descriptionTip() const {
QString contents;
foreach (PlotRenderItem *renderer, renderItems()) {
--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.h #1329456:1329457
@@ -335,6 +335,10 @@
void zoomNormalizeYtoX(bool force = false);
void zoomLogY(bool force = false, bool autoLog = true, bool enableLog = false);
+ void copyStatus();
+ void copyXCoord();
+ void copyYCoord();
+
void setPlotBordersDirty(bool dirty = true);
virtual void edit(PlotClickEditRegion region);
@@ -359,6 +363,7 @@
private:
void createActions();
void createZoomMenu();
+ void createCopyMenu();
void createFilterMenu();
void createFitMenu();
void createEditMenu();
@@ -543,6 +548,11 @@
QAction *_shareBoxShareY;
QAction *_breakSharedBox;
+ QMenu *_copyMenu;
+ QAction *_copyStatus;
+ QAction *_copyXCoord;
+ QAction *_copyYCoord;
+
SharedAxisBoxItem * _sharedBox;
bool _axisLabelsDirty;
More information about the Kst
mailing list