[Kst] branches/work/kst/portto4/kst/src
Barth Netterfield
netterfield at astro.utoronto.ca
Fri Oct 29 23:30:51 CEST 2010
SVN commit 1191186 by netterfield:
Add a log dialog:
-saves a message and an image of the current plot to a (user specified) local directory.
-executes a script that can be used to upload these to elog, a wordpress blog, or whatever.
M +5 -1 libkstapp/libkstapp.pro
A libkstapp/logdialog.cpp [License: GPL (v2+)]
A libkstapp/logdialog.h [License: GPL (v2+)]
A libkstapp/logdialog.ui
M +71 -0 libkstapp/mainwindow.cpp
M +7 -0 libkstapp/mainwindow.h
M +2 -0 widgets/filerequester.cpp
--- branches/work/kst/portto4/kst/src/libkstapp/libkstapp.pro #1191185:1191186
@@ -89,6 +89,7 @@
legenditemdialog.cpp \
legendtab.cpp \
lineitem.cpp \
+ logdialog.cpp \
logwidget.cpp \
mainwindow.cpp \
markerstab.cpp \
@@ -195,6 +196,7 @@
legenditemdialog.h \
legendtab.h \
lineitem.h \
+ logdialog.cpp\
logwidget.h \
mainwindow.h \
markerstab.h \
@@ -233,7 +235,8 @@
viewmatrixdialog.h \
viewprimitivedialog.h \
viewvectordialog.h \
- pluginmenuitemaction.h
+ pluginmenuitemaction.h \
+ logdialog.h
FORMS += aboutdialog.ui \
arrowpropertiestab.ui \
axistab.ui \
@@ -272,6 +275,7 @@
labelpropertiestab.ui \
layouttab.ui \
legendtab.ui \
+ logdialog.ui \
markerstab.ui \
matrixtab.ui \
powerspectrumtab.ui \
--- branches/work/kst/portto4/kst/src/libkstapp/mainwindow.cpp #1191185:1191186
@@ -18,6 +18,7 @@
#include "document.h"
#include "ellipseitem.h"
#include "exportgraphicsdialog.h"
+#include "logdialog.h"
#include "application.h"
#include "debug.h"
#include "labelitem.h"
@@ -64,6 +65,7 @@
MainWindow::MainWindow() :
_dataManager(0),
_exportGraphics(0),
+ _logDialog(0),
_differentiateCurvesDialog(0),
_chooseColorDialog(0),
_changeDataSampleDialog(0),
@@ -359,6 +361,54 @@
}
}
+void MainWindow::exportLog(const QString &imagename, QString &msgfilename, const QString &format, int x_size, int y_size,
+ int size_option_index, const QString &message) {
+ View *view = _tabWidget->currentView();
+
+ QSize size;
+ if (size_option_index == 0) {
+ size.setWidth(x_size);
+ size.setHeight(y_size);
+ } else if (size_option_index == 1) {
+ size.setWidth(x_size);
+ size.setHeight(y_size);
+ } else if (size_option_index == 2) {
+ QSize sizeWindow(view->geometry().size());
+
+ size.setWidth(x_size);
+ size.setHeight((int)((double)x_size * (double)sizeWindow.height() / (double)sizeWindow.width()));
+ } else {
+ QSize sizeWindow(view->geometry().size());
+
+ size.setHeight(y_size);
+ size.setWidth((int)((double)y_size * (double)sizeWindow.width() / (double)sizeWindow.height()));
+ }
+
+ QImage image(size, QImage::Format_ARGB32);
+
+ QPainter painter(&image);
+ QSize currentSize(view->size());
+ view->resize(size);
+ view->processResize(size);
+ view->setPrinting(true);
+ view->render(&painter);
+ view->setPrinting(false);
+ view->resize(currentSize);
+ view->processResize(currentSize);
+
+ QImageWriter imageWriter(imagename, format.toLatin1());
+ imageWriter.write(image);
+
+ QFile file(msgfilename);
+
+ if (file.open(QIODevice::WriteOnly | QIODevice::Text)) {
+ QTextStream out(&file);
+ out << message;
+ file.close();
+ }
+
+}
+
void MainWindow::printToPrinter(QPrinter *printer) {
QPainter painter(printer);
@@ -717,6 +767,11 @@
_exportGraphicsAct->setIcon(QPixmap(":document-export.png"));
connect(_exportGraphicsAct, SIGNAL(triggered()), this, SLOT(showExportGraphicsDialog()));
+ _logAct = new QAction(tr("&Log Entry..."), this);
+ _logAct->setStatusTip(tr("Commit a log entry"));
+ _logAct->setIcon(QPixmap(":document-export.png"));
+ connect(_logAct, SIGNAL(triggered()), this, SLOT(showLogDialog()));
+
_newTabAct = new QAction(tr("&New Tab"), this);
_newTabAct->setStatusTip(tr("Create a new tab"));
_newTabAct->setIcon(QPixmap(":tab-new.png"));
@@ -1009,6 +1064,7 @@
// Print/export
_fileMenu->addAction(_printAct);
_fileMenu->addAction(_exportGraphicsAct);
+ _fileMenu->addAction(_logAct);
_fileMenu->addSeparator();
// Tabs
_fileMenu->addAction(_newTabAct);
@@ -1132,6 +1188,7 @@
_fileToolBar->addAction(_saveAct);
_fileToolBar->addAction(_reloadAct);
_fileToolBar->addAction(_printAct);
+ _fileToolBar->addAction(_logAct);
_editToolBar = addToolBar(tr("Edit"));
_editToolBar->setObjectName("Edit Toolbar");
@@ -1407,6 +1464,20 @@
}
+void MainWindow::showLogDialog() {
+ if (!_logDialog) {
+ _logDialog = new LogDialog(this);
+ //connect(_logDialog, SIGNAL(exportLog(const QString &, time_t, const QString &, int, int, int, const QString &)),
+ // this, SLOT(exportLog(const QString &, time_t, const QString &, int, int, int, const QString &)));
+ }
+ if (_logDialog->isVisible()) {
+ _logDialog->raise();
+ _logDialog->activateWindow();
+ }
+ _logDialog->show();
+}
+
+
void MainWindow::showSettingsDialog() {
if (!_applicationSettingsDialog) {
_applicationSettingsDialog = new ApplicationSettingsDialog(this);
--- branches/work/kst/portto4/kst/src/libkstapp/mainwindow.h #1191185:1191186
@@ -29,6 +29,7 @@
class DebugDialog;
class Document;
class ExportGraphicsDialog;
+class LogDialog;
class DifferentiateCurvesDialog;
class ChooseColorDialog;
class ChangeDataSampleDialog;
@@ -59,6 +60,7 @@
void showDataManager();
void showDebugDialog();
void showExportGraphicsDialog();
+ void showLogDialog();
void showVectorEditor();
void showScalarEditor();
void showMatrixEditor();
@@ -91,7 +93,10 @@
void printToPrinter(QPrinter *printer);
void printFromCommandLine(const QString &printFileName);
void exportGraphicsFile(const QString &filename, const QString &format, int w, int h, int display);
+ void exportLog(const QString &imagename, QString &msgfilename, const QString &_format, int x_size, int y_size,
+ int size_option_index, const QString &message);
+
void clearDrawingMarker();
void tiedZoomRemoved();
void allPlotsTiedZoom();
@@ -155,6 +160,7 @@
DataManager *_dataManager;
DebugDialog *_debugDialog;
ExportGraphicsDialog *_exportGraphics;
+ LogDialog *_logDialog;
DifferentiateCurvesDialog *_differentiateCurvesDialog;
ChooseColorDialog *_chooseColorDialog;
ChangeDataSampleDialog *_changeDataSampleDialog;
@@ -208,6 +214,7 @@
QAction *_debugDialogAct;
QAction *_exitAct;
QAction *_exportGraphicsAct;
+ QAction *_logAct;
QAction *_openAct;
QAction *_saveAct;
QAction *_saveAsAct;
--- branches/work/kst/portto4/kst/src/widgets/filerequester.cpp #1191185:1191186
@@ -86,6 +86,8 @@
QString file;
if (_mode == QFileDialog::ExistingFile) {
file = QFileDialog::getOpenFileName(this, tr("Open File"), _file, tr("All Files (*)"));
+ } else if (_mode == QFileDialog::Directory) {
+ file = QFileDialog::getExistingDirectory(this, tr("Logfile Directory"), _file);
} else {
file = QFileDialog::getSaveFileName(this, tr("Save File"), _file, tr("All Files (*)"));
}
More information about the Kst
mailing list