[rkward-cvs] SF.net SVN: rkward:[3707] trunk/rkward
tfry at users.sourceforge.net
tfry at users.sourceforge.net
Mon Aug 1 11:42:25 UTC 2011
Revision: 3707
http://rkward.svn.sourceforge.net/rkward/?rev=3707&view=rev
Author: tfry
Date: 2011-08-01 11:42:25 +0000 (Mon, 01 Aug 2011)
Log Message:
-----------
Fix graphics device printing.
Since this removes the UI to options('printcmd'), this commit also adds a new free text input field for arbitrary option commands, as a replacement.
Modified Paths:
--------------
trunk/rkward/ChangeLog
trunk/rkward/rkward/agents/CMakeLists.txt
trunk/rkward/rkward/rbackend/rinterface.cpp
trunk/rkward/rkward/rbackend/rpackages/rkward/R/help.R
trunk/rkward/rkward/rbackend/rpackages/rkward/R/internal_graphics.R
trunk/rkward/rkward/rbackend/rpackages/rkward/R/public_graphics.R
trunk/rkward/rkward/rkward.cpp
trunk/rkward/rkward/settings/rksettingsmodulegraphics.cpp
trunk/rkward/rkward/settings/rksettingsmodulegraphics.h
trunk/rkward/rkward/settings/rksettingsmoduler.cpp
trunk/rkward/rkward/settings/rksettingsmoduler.h
trunk/rkward/rkward/windows/rkwindowcatcher.cpp
Added Paths:
-----------
trunk/rkward/rkward/agents/rkprintagent.cpp
trunk/rkward/rkward/agents/rkprintagent.h
trunk/rkward/rkward/rbackend/rpackages/rkward/man/rk.printer.device.Rd
Modified: trunk/rkward/ChangeLog
===================================================================
--- trunk/rkward/ChangeLog 2011-07-31 14:33:08 UTC (rev 3706)
+++ trunk/rkward/ChangeLog 2011-08-01 11:42:25 UTC (rev 3707)
@@ -1,3 +1,7 @@
+- Removed option to set options("printcmd")
+- New option to run arbitrary (setup) commands in each session
+- Added new pseudo graphics device "rk.printer.device" to provide printing via the KDE printer dialog
+- Fixed: Printing was broken when kprinter is not available
- Support the results list new help.search() in R 2.14.x, which includes vignettes and demos # TODO: actually test this with R 2.14!
- rk.edit.files() and rk.show.files() gain parameter "prompt", which can be used to suppress user prompt
- Added function rk.demo(), which is similar to demo(), but opens the example script in a script editor window
Modified: trunk/rkward/rkward/agents/CMakeLists.txt
===================================================================
--- trunk/rkward/rkward/agents/CMakeLists.txt 2011-07-31 14:33:08 UTC (rev 3706)
+++ trunk/rkward/rkward/agents/CMakeLists.txt 2011-08-01 11:42:25 UTC (rev 3707)
@@ -4,27 +4,14 @@
########### next target ###############
SET(agents_STAT_SRCS
- rksaveagent.cpp
+ rkeditobjectagent.cpp
rkloadagent.cpp
- showedittextfileagent.cpp
+ rkprintagent.cpp
rkquitagent.cpp
- rkeditobjectagent.cpp
+ rksaveagent.cpp
+ showedittextfileagent.cpp
)
QT4_AUTOMOC(${agents_STAT_SRCS})
ADD_LIBRARY(agents STATIC ${agents_STAT_SRCS})
-
-
-########### install files ###############
-
-
-
-
-#original Makefile.am contents follow:
-
-#INCLUDES = $(all_includes)
-#METASOURCES = AUTO
-#noinst_LIBRARIES = libagents.a
-#noinst_HEADERS = rksaveagent.h rkloadagent.h showedittextfileagent.h rkquitagent.h rkeditobjectagent.h
-#libagents_a_SOURCES = rksaveagent.cpp rkloadagent.cpp showedittextfileagent.cpp rkquitagent.cpp rkeditobjectagent.cpp
Added: trunk/rkward/rkward/agents/rkprintagent.cpp
===================================================================
--- trunk/rkward/rkward/agents/rkprintagent.cpp (rev 0)
+++ trunk/rkward/rkward/agents/rkprintagent.cpp 2011-08-01 11:42:25 UTC (rev 3707)
@@ -0,0 +1,92 @@
+/***************************************************************************
+ rkprintagent - description
+ -------------------
+ begin : Mon Aug 01 2011
+ copyright : (C) 2011 by Thomas Friedrichsmeier
+ email : tfry at users.sourceforge.net
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#include "rkprintagent.h"
+
+#include <QFile>
+#include <QTimer>
+#include <QDateTime>
+
+#include <krun.h>
+#include <kservice.h>
+#include <kmessagebox.h>
+#include <klocale.h>
+
+#include "../rkward.h"
+
+#include "../debug.h"
+
+RKPrintAgent::RKPrintAgent () : QObject () {
+ RK_TRACE (APP)
+}
+
+RKPrintAgent::~RKPrintAgent () {
+ RK_TRACE (APP)
+
+ if (delete_file) QFile (file).remove ();
+ if (provider) provider->deleteLater ();
+}
+
+void RKPrintAgent::printPostscript (const QString &file, bool delete_file) {
+ RK_TRACE (APP)
+
+ KService::Ptr service = KService::serviceByDesktopPath ("okular_part.desktop");
+ if (!service) service = KService::serviceByDesktopPath ("kpdf_part.desktop");
+ if (!service) RK_DO (qDebug ("No KDE service found for postscript printing"), APP, DL_WARNING);
+
+ KParts::ReadOnlyPart *provider = service->createInstance<KParts::ReadOnlyPart> (0);
+ QAction *printaction = 0;
+ if (provider) {
+ printaction = provider->action ("print");
+ if (!printaction) printaction = provider->action ("file_print");
+ if (!printaction) {
+ QAction *a = new QAction (provider);
+ bool ok = connect (a, SIGNAL (triggered()), provider, SLOT (slotPrint()));
+ if (ok) printaction = a;
+ }
+ if (!(printaction && provider->openUrl (KUrl::fromLocalFile (file)))) {
+ RK_DO (qDebug ("No print action in postscript provider"), APP, DL_WARNING);
+ delete provider;
+ provider = 0;
+ }
+ }
+
+ if (!provider) {
+ RK_DO (qDebug ("No valid postscript postscript provider was found"), APP, DL_WARNING);
+ KMessageBox::sorry (RKWardMainWindow::getMain (), i18n ("No service was found to provide a KDE print dialog for postscript files. We will try to open a generic postscript viewer (if any), instead.<br><br>Consider installing 'okular', or configure RKWard not to attempt to print using a KDE print dialog."), i18n ("Unable to open KDE print dialog"));
+ // fallback: If we can't find a proper part, try to invoke a standalone PS reader, instead
+ KRun::runUrl (KUrl::fromLocalFile (file), "appication/postscript", RKWardMainWindow::getMain ());
+ return;
+ }
+
+ RKPrintAgent *agent = new RKPrintAgent ();
+ agent->file = file;
+ agent->delete_file = delete_file;
+ agent->provider = provider;
+
+ // very hacky heuristic to try to find out, whether the print action is synchronous or asnchronous. If the latter, delete after half an hour. If the former delete after printing.
+ QTime ts;
+ ts.start ();
+ printaction->trigger ();
+ if (ts.elapsed () < 5000) {
+ QTimer::singleShot (1800000, agent, SLOT (deleteLater ()));
+ } else {
+ agent->deleteLater ();
+ }
+}
+
+#include "rkprintagent.moc"
Added: trunk/rkward/rkward/agents/rkprintagent.h
===================================================================
--- trunk/rkward/rkward/agents/rkprintagent.h (rev 0)
+++ trunk/rkward/rkward/agents/rkprintagent.h 2011-08-01 11:42:25 UTC (rev 3707)
@@ -0,0 +1,41 @@
+/***************************************************************************
+ rkprintagent - description
+ -------------------
+ begin : Mon Aug 01 2011
+ copyright : (C) 2011 by Thomas Friedrichsmeier
+ email : tfry at users.sourceforge.net
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef RKPRINTAGENT_H
+#define RKPRINTAGENT_H
+
+#include <QObject>
+#include <kparts/part.h>
+
+/** The main purpose of this class is to cope with the lack of kprinter in KDE 4. Tries
+ * to offer a KDE print dialog for an existing postscript file. */
+class RKPrintAgent : public QObject {
+ Q_OBJECT
+public:
+ /** print the given postscript file.
+ * @param delete_file : Try to delete the file after printing. Note: This is not guaranteed to work. */
+ static void printPostscript (const QString &file, bool delete_file=false);
+protected:
+ RKPrintAgent ();
+ ~RKPrintAgent ();
+
+ QString file;
+ KParts::ReadOnlyPart *provider;
+ bool delete_file;
+};
+
+#endif
Modified: trunk/rkward/rkward/rbackend/rinterface.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rinterface.cpp 2011-07-31 14:33:08 UTC (rev 3706)
+++ trunk/rkward/rkward/rbackend/rinterface.cpp 2011-08-01 11:42:25 UTC (rev 3707)
@@ -34,6 +34,7 @@
#include "../dialogs/rkreadlinedialog.h"
#include "../agents/showedittextfileagent.h"
#include "../agents/rkeditobjectagent.h"
+#include "../agents/rkprintagent.h"
#include "../windows/rcontrolwindow.h"
#include "../windows/rkworkplace.h"
#include "../windows/rkcommandlog.h"
@@ -591,6 +592,8 @@
} else {
++num_active_output_record_requests;
}
+ } else if (call == "printPreview") {
+ RKPrintAgent::printPostscript (calllist.value (1), true);
} else {
return (QStringList ("Error: unrecognized request '" + call + "'."));
}
Modified: trunk/rkward/rkward/rbackend/rpackages/rkward/R/help.R
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkward/R/help.R 2011-07-31 14:33:08 UTC (rev 3706)
+++ trunk/rkward/rkward/rbackend/rpackages/rkward/R/help.R 2011-08-01 11:42:25 UTC (rev 3707)
@@ -55,6 +55,7 @@
# Simple wrapper around help.search. Concatenates the relevant fields of the results in order for passing to the frontend.
".rk.get.search.results" <- function (pattern, ...) {
H=as.data.frame (help.search(pattern, ...)$matches)
+ # NOTE: The field "Type" was added in R 2.14.0. For earlier versions of R, only help pages were returned as results of help.search()
if (is.null (H$Type)) H$Type <- "help"
c (as.character (H$topic), as.character (H$title), as.character(H$Package), as.character(H$Type))
}
Modified: trunk/rkward/rkward/rbackend/rpackages/rkward/R/internal_graphics.R
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkward/R/internal_graphics.R 2011-07-31 14:33:08 UTC (rev 3706)
+++ trunk/rkward/rkward/rbackend/rpackages/rkward/R/internal_graphics.R 2011-08-01 11:42:25 UTC (rev 3707)
@@ -71,6 +71,8 @@
}
}
+".rk.printer.devices" <- list ()
+
# see .rk.fix.assignmetns () in internal.R
".rk.fix.assignments.graphics" <- function ()
{
@@ -89,6 +91,13 @@
.rk.do.call ("killDevice", as.character (which))
ret <- eval (body (.rk.dev.off.default))
+
+ printfile <- .rk.printer.devices[[as.character (which)]]
+ if (!is.null (printfile)) {
+ .rk.do.plain.call ("printPreview", printfile, FALSE)
+ .rk.printer.devices[[as.character (which)]] <<- NULL
+ }
+
return (ret)
})
Modified: trunk/rkward/rkward/rbackend/rpackages/rkward/R/public_graphics.R
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkward/R/public_graphics.R 2011-07-31 14:33:08 UTC (rev 3706)
+++ trunk/rkward/rkward/rbackend/rpackages/rkward/R/public_graphics.R 2011-08-01 11:42:25 UTC (rev 3707)
@@ -55,6 +55,15 @@
ret
}
+# Produces a temporary postscript file and opens a print dialog for it
+# Parameters are passed to postscript(), but typically this is simply used as
+# dev.print(rk.print.preview)
+"rk.printer.device" <- function(...) {
+ tf <- tempfile (fileext=".ps")
+ postscript (file = tf, ...)
+ .rk.printer.devices[[as.character (dev.cur ())]] <<- tf
+}
+
"rk.duplicate.device" <- function (devId = dev.cur ())
{
dev.set (devId)
Added: trunk/rkward/rkward/rbackend/rpackages/rkward/man/rk.printer.device.Rd
===================================================================
--- trunk/rkward/rkward/rbackend/rpackages/rkward/man/rk.printer.device.Rd (rev 0)
+++ trunk/rkward/rkward/rbackend/rpackages/rkward/man/rk.printer.device.Rd 2011-08-01 11:42:25 UTC (rev 3707)
@@ -0,0 +1,39 @@
+\name{rk.printer.device}
+\alias{rk.printer.device}
+
+\title{Device for printing using the KDE print dialog}
+
+\description{
+Creates a device operating on a temporary file (internally a \code{\link{postscript}}() device). When the device is closed, it is printed, automatically, using the KDE print dialog (if installed).
+}
+
+\usage{
+rk.printer.device(...)
+}
+
+\arguments{
+\item{...}{arguments are passed to \code{\link{postscript}}}
+}
+
+\details{
+Typically this device is used with \code{\link{dev.print}}, as shown in the example, below.
+}
+
+\value{
+Returns the name of the underlying temporary file, invisibly.
+}
+
+\author{Thomas Friedrichsmeier \email{rkward-devel at lists.sourceforge.net}}
+
+\examples{
+## Not run:
+plot (rnorm (10))
+dev.print (rk.printer.device)
+}
+
+\seealso{
+ \code{\link{postscript}}, \code{\link{dev.print}}, \code{\link{rk.graph.on}}
+}
+
+\keyword{utilities}
+\keyword{device}
Modified: trunk/rkward/rkward/rkward.cpp
===================================================================
--- trunk/rkward/rkward/rkward.cpp 2011-07-31 14:33:08 UTC (rev 3706)
+++ trunk/rkward/rkward/rkward.cpp 2011-08-01 11:42:25 UTC (rev 3707)
@@ -92,6 +92,7 @@
#include "windows/detachedwindowcontainer.h" // TODO: see below: needed purely for linking!
#include "dataeditor/rkeditordataframe.h" // TODO: see below: needed purely for linking!
#include "agents/rkeditobjectagent.h" // TODO: see below: needed purely for linking!
+#include "agents/rkprintagent.h" // TODO: see below: needed purely for linking!
// This nevers gets called. It's needed to trick ld into linking correctly. Nothing else.
void bogusCalls () {
@@ -102,6 +103,7 @@
DetachedWindowContainer (0);
new RKWorkplaceView (0);
new RKEditObjectAgent (QStringList (), 0);
+ RKPrintAgent::printPostscript (QString (), false);
}
/** Main window **/
Modified: trunk/rkward/rkward/settings/rksettingsmodulegraphics.cpp
===================================================================
--- trunk/rkward/rkward/settings/rksettingsmodulegraphics.cpp 2011-07-31 14:33:08 UTC (rev 3706)
+++ trunk/rkward/rkward/settings/rksettingsmodulegraphics.cpp 2011-08-01 11:42:25 UTC (rev 3707)
@@ -38,6 +38,7 @@
bool RKSettingsModuleGraphics::graphics_hist_enable;
int RKSettingsModuleGraphics::graphics_hist_max_length;
int RKSettingsModuleGraphics::graphics_hist_max_plotsize;
+bool RKSettingsModuleGraphics::options_kde_printing;
RKSettingsModuleGraphics::RKSettingsModuleGraphics (RKSettings *gui, QWidget *parent) : RKSettingsModule(gui, parent) {
RK_TRACE (SETTINGS);
@@ -57,7 +58,10 @@
connect (graphics_height_box, SIGNAL (valueChanged (int)), this, SLOT (boxChanged ()));
main_vbox->addWidget (group);
- main_vbox->addWidget (group);
+ kde_printing_box = new QCheckBox (i18n ("Use KDE printer dialog for printing devices (if available)"), this);
+ kde_printing_box->setChecked (options_kde_printing);
+ connect (kde_printing_box, SIGNAL (stateChanged(int)), this, SLOT (boxChanged()));
+ main_vbox->addWidget (kde_printing_box);
graphics_hist_box = new QGroupBox (i18n ("Screen device history"), this);
graphics_hist_box->setCheckable (true);
@@ -109,6 +113,8 @@
graphics_hist_max_length = graphics_hist_max_length_box->value ();
graphics_hist_max_plotsize = graphics_hist_max_plotsize_box->value ();
+ options_kde_printing = kde_printing_box->isChecked ();
+
QStringList commands = makeRRunTimeOptionCommands ();
for (QStringList::const_iterator it = commands.begin (); it != commands.end (); ++it) {
RKGlobals::rInterface ()->issueCommand (*it, RCommand::App, QString::null, 0, 0, commandChain ());
@@ -130,6 +136,7 @@
cg.writeEntry ("graphics_hist_enable", graphics_hist_enable);
cg.writeEntry ("graphics_hist_max_length", graphics_hist_max_length);
cg.writeEntry ("graphics_hist_max_plotsize", graphics_hist_max_plotsize);
+ cg.writeEntry ("kde printing", options_kde_printing);
}
void RKSettingsModuleGraphics::loadSettings (KConfig *config) {
@@ -141,6 +148,7 @@
graphics_hist_enable = cg.readEntry ("graphics_hist_enable", true);
graphics_hist_max_length = cg.readEntry ("graphics_hist_max_length", 20);
graphics_hist_max_plotsize = cg.readEntry ("graphics_hist_max_plotsize", 1024);
+ options_kde_printing = cg.readEntry ("kde printing", true);
}
//static
Modified: trunk/rkward/rkward/settings/rksettingsmodulegraphics.h
===================================================================
--- trunk/rkward/rkward/settings/rksettingsmodulegraphics.h 2011-07-31 14:33:08 UTC (rev 3706)
+++ trunk/rkward/rkward/settings/rksettingsmodulegraphics.h 2011-08-01 11:42:25 UTC (rev 3707)
@@ -24,6 +24,7 @@
class QGroupBox;
class RKSpinBox;
class KIntSpinBox;
+class QCheckBox;
/**
@author Thomas Friedrichsmeier
@@ -40,7 +41,10 @@
/** generate the commands needed to set the R run time options */
static QStringList makeRRunTimeOptionCommands ();
-
+
+/** Configured to (attempt to) use KDE printing dialog? */
+ static bool kdePrintingEnabled () { return options_kde_printing; };
+
static void saveSettings (KConfig *config);
static void loadSettings (KConfig *config);
@@ -58,12 +62,16 @@
RKSpinBox *graphics_height_box;
RKSpinBox *graphics_width_box;
+ QCheckBox *kde_printing_box;
+
static bool graphics_hist_enable;
static int graphics_hist_max_length;
static int graphics_hist_max_plotsize;
static double graphics_height;
static double graphics_width;
+
+ static bool options_kde_printing;
};
#endif
Modified: trunk/rkward/rkward/settings/rksettingsmoduler.cpp
===================================================================
--- trunk/rkward/rkward/settings/rksettingsmoduler.cpp 2011-07-31 14:33:08 UTC (rev 3706)
+++ trunk/rkward/rkward/settings/rksettingsmoduler.cpp 2011-08-01 11:42:25 UTC (rev 3707)
@@ -2,7 +2,7 @@
rksettingsmoduler - description
-------------------
begin : Wed Jul 28 2004
- copyright : (C) 2004, 2007, 2009, 2010 by Thomas Friedrichsmeier
+ copyright : (C) 2004, 2007, 2009, 2010, 2011 by Thomas Friedrichsmeier
email : tfry at users.sourceforge.net
***************************************************************************/
@@ -30,6 +30,7 @@
#include <QVBoxLayout>
#include <QGridLayout>
#include <QPushButton>
+#include <QTextEdit>
#include "../core/robject.h"
#include "../misc/multistringselector.h"
@@ -49,9 +50,9 @@
int RKSettingsModuleR::options_expressions;
int RKSettingsModuleR::options_digits;
bool RKSettingsModuleR::options_checkbounds;
-QString RKSettingsModuleR::options_printcmd;
QString RKSettingsModuleR::options_editor;
QString RKSettingsModuleR::options_pager;
+QString RKSettingsModuleR::options_further;
// static constants
QString RKSettingsModuleR::builtin_editor = "<rkward>";
// session constants
@@ -81,32 +82,32 @@
warn_input->insertItem (2, i18n ("Print warnings immediately"));
warn_input->insertItem (3, i18n ("Convert warnings to errors"));
warn_input->setCurrentIndex (options_warn + 1);
- connect (warn_input, SIGNAL (activated (int)), this, SLOT (boxChanged (int)));
+ connect (warn_input, SIGNAL (activated (int)), this, SLOT (settingChanged()));
grid->addWidget (warn_input, row, 1);
// options (OutDec)
grid->addWidget (new QLabel (i18n ("Decimal character (only for printing)"), this), ++row, 0);
outdec_input = new QLineEdit (options_outdec, this);
outdec_input->setMaxLength (1);
- connect (outdec_input, SIGNAL (textChanged (const QString &)), this, SLOT (textChanged (const QString &)));
+ connect (outdec_input, SIGNAL (textChanged (const QString &)), this, SLOT (settingChanged()));
grid->addWidget (outdec_input, row, 1);
// options (width)
grid->addWidget (new QLabel (i18n ("Output width (characters)"), this), ++row, 0);
width_input = new KIntSpinBox (10, 10000, 1, options_width, this);
- connect (width_input, SIGNAL (valueChanged (int)), this, SLOT (boxChanged (int)));
+ connect (width_input, SIGNAL (valueChanged (int)), this, SLOT (settingChanged()));
grid->addWidget (width_input, row, 1);
// options (max.print)
grid->addWidget (new QLabel (i18n ("Maximum number of elements shown in print"), this), ++row, 0);
maxprint_input = new KIntSpinBox (100, INT_MAX, 1, options_maxprint, this);
- connect (maxprint_input, SIGNAL (valueChanged (int)), this, SLOT (boxChanged (int)));
+ connect (maxprint_input, SIGNAL (valueChanged (int)), this, SLOT (settingChanged()));
grid->addWidget (maxprint_input, row, 1);
// options (warnings.length)
grid->addWidget (new QLabel (i18n ("Maximum length of warnings/errors to print"), this), ++row, 0);
warningslength_input = new KIntSpinBox (100, 8192, 1, options_warningslength, this);
- connect (warningslength_input, SIGNAL (valueChanged (int)), this, SLOT (boxChanged (int)));
+ connect (warningslength_input, SIGNAL (valueChanged (int)), this, SLOT (settingChanged()));
grid->addWidget (warningslength_input, row, 1);
// options (keep.source)
@@ -116,7 +117,7 @@
keepsource_input->addItem (i18n ("TRUE (default)"), true);
keepsource_input->addItem (i18n ("FALSE"), false);
keepsource_input->setCurrentIndex (options_keepsource ? 0 : 1);
- connect (keepsource_input, SIGNAL (activated (int)), this, SLOT (boxChanged (int)));
+ connect (keepsource_input, SIGNAL (activated (int)), this, SLOT (settingChanged()));
grid->addWidget (keepsource_input, row, 1);
// options (keep.source.pkgs)
@@ -126,19 +127,19 @@
keepsourcepkgs_input->addItem (i18n ("TRUE"), true);
keepsourcepkgs_input->addItem (i18n ("FALSE (default)"), false);
keepsourcepkgs_input->setCurrentIndex (options_keepsourcepkgs ? 0 : 1);
- connect (keepsourcepkgs_input, SIGNAL (activated (int)), this, SLOT (boxChanged (int)));
+ connect (keepsourcepkgs_input, SIGNAL (activated (int)), this, SLOT (settingChanged()));
grid->addWidget (keepsourcepkgs_input, row, 1);
// options (expressions)
grid->addWidget (new QLabel (i18n ("Maximum level of nested expressions"), this), ++row, 0);
expressions_input = new KIntSpinBox (25, 500000, 1, options_expressions, this);
- connect (expressions_input, SIGNAL (valueChanged (int)), this, SLOT (boxChanged (int)));
+ connect (expressions_input, SIGNAL (valueChanged (int)), this, SLOT (settingChanged()));
grid->addWidget (expressions_input, row, 1);
// options (digits)
grid->addWidget (new QLabel (i18n ("Default decimal precision in print ()"), this), ++row, 0);
digits_input = new KIntSpinBox (1, 22, 1, options_digits, this);
- connect (digits_input, SIGNAL (valueChanged (int)), this, SLOT (boxChanged (int)));
+ connect (digits_input, SIGNAL (valueChanged (int)), this, SLOT (settingChanged()));
grid->addWidget (digits_input, row, 1);
// options (check.bounds)
@@ -148,14 +149,9 @@
checkbounds_input->addItem (i18n ("TRUE"), true);
checkbounds_input->addItem (i18n ("FALSE (default)"), false);
checkbounds_input->setCurrentIndex (options_checkbounds ? 0 : 1);
- connect (checkbounds_input, SIGNAL (activated (int)), this, SLOT (boxChanged (int)));
+ connect (checkbounds_input, SIGNAL (activated (int)), this, SLOT (settingChanged()));
grid->addWidget (checkbounds_input, row, 1);
- grid->addWidget (new QLabel (i18n ("Command used to send files to printer"), this), ++row, 0);
- printcmd_input = new QLineEdit (options_printcmd, this);
- connect (printcmd_input, SIGNAL (textChanged (const QString &)), this, SLOT (textChanged (const QString &)));
- grid->addWidget (printcmd_input, row, 1);
-
grid->addWidget (new QLabel (i18n ("Editor command"), this), ++row, 0);
editor_input = new QComboBox (this);
editor_input->setEditable (true);
@@ -164,7 +160,7 @@
editor_input->addItem (options_editor);
editor_input->setCurrentIndex (1);
}
- connect (editor_input, SIGNAL (editTextChanged (const QString &)), this, SLOT (textChanged (const QString &)));
+ connect (editor_input, SIGNAL (editTextChanged (const QString &)), this, SLOT (settingChanged()));
grid->addWidget (editor_input, row, 1);
grid->addWidget (new QLabel (i18n ("Pager command"), this), ++row, 0);
@@ -175,9 +171,17 @@
pager_input->addItem (options_pager);
pager_input->setCurrentIndex (1);
}
- connect (pager_input, SIGNAL (editTextChanged (const QString &)), this, SLOT (textChanged (const QString &)));
+ connect (pager_input, SIGNAL (editTextChanged (const QString &)), this, SLOT (settingChanged()));
grid->addWidget (pager_input, row, 1);
+ grid->addWidget (new QLabel (i18n ("Further (option) commands to run in each session"), this), ++row, 0, 1, 2);
+ further_input = new QTextEdit (this);
+ further_input->setWordWrapMode (QTextOption::NoWrap);
+ further_input->setAcceptRichText (false);
+ further_input->setPlainText (options_further);
+ connect (further_input, SIGNAL (textChanged()), this, SLOT (settingChanged()));
+ grid->addWidget (further_input, ++row, 0, 1, 2);
+
main_vbox->addStretch ();
}
@@ -185,21 +189,11 @@
RK_TRACE (SETTINGS);
}
-void RKSettingsModuleR::boxChanged (int) {
+void RKSettingsModuleR::settingChanged () {
RK_TRACE (SETTINGS);
change ();
}
-void RKSettingsModuleR::pathChanged () {
- RK_TRACE (SETTINGS);
- change ();
-}
-
-void RKSettingsModuleR::textChanged (const QString &) {
- RK_TRACE (SETTINGS);
- change ();
-}
-
QString RKSettingsModuleR::caption () {
RK_TRACE (SETTINGS);
return (i18n ("R-Backend"));
@@ -223,9 +217,9 @@
options_expressions = expressions_input->value ();
options_digits = digits_input->value ();
options_checkbounds = checkbounds_input->itemData (checkbounds_input->currentIndex ()).toBool ();
- options_printcmd = printcmd_input->text ();
options_editor = editor_input->currentText ();
options_pager = pager_input->currentText ();
+ options_further = further_input->toPlainText ();
// apply run time options in R
QStringList commands = makeRRunTimeOptionCommands ();
@@ -252,11 +246,11 @@
list.append ("options (digits=" + QString::number (options_digits) + ")\n");
if (options_checkbounds) tf = "TRUE"; else tf = "FALSE";
list.append ("options (checkbounds=" + tf + ")\n");
- list.append ("options (printcmd=\"" + options_printcmd + "\")\n");
if (options_editor == builtin_editor) list.append ("options (editor=rk.edit.files)\n");
else list.append ("options (editor=\"" + options_editor + "\")\n");
if (options_pager == builtin_editor) list.append ("options (pager=rk.show.files)\n");
else list.append ("options (pager=\"" + options_pager + "\")\n");
+ if (!options_further.isEmpty ()) list.append (options_further + "\n");
#warning TODO make the following options configurable
list.append ("options (device=\"rk.screen.device\")\n");
@@ -289,9 +283,9 @@
cg.writeEntry ("expressions", options_expressions);
cg.writeEntry ("digits", options_digits);
cg.writeEntry ("check.bounds", options_checkbounds);
- cg.writeEntry ("printcmd", options_printcmd);
cg.writeEntry ("editor", options_editor);
cg.writeEntry ("pager", options_pager);
+ cg.writeEntry ("further init commands", options_further);
}
void RKSettingsModuleR::loadSettings (KConfig *config) {
@@ -308,9 +302,9 @@
options_expressions = cg.readEntry ("expressions", 5000);
options_digits = cg.readEntry ("digits", 7);
options_checkbounds = cg.readEntry ("check.bounds", false);
- options_printcmd = cg.readEntry ("printcmd", "kprinter");
options_editor = cg.readEntry ("editor", builtin_editor);
options_pager = cg.readEntry ("pager", builtin_editor);
+ options_further = cg.readEntry ("further init commands", QString ());
}
//#################################################
Modified: trunk/rkward/rkward/settings/rksettingsmoduler.h
===================================================================
--- trunk/rkward/rkward/settings/rksettingsmoduler.h 2011-07-31 14:33:08 UTC (rev 3706)
+++ trunk/rkward/rkward/settings/rksettingsmoduler.h 2011-08-01 11:42:25 UTC (rev 3707)
@@ -2,7 +2,7 @@
rksettingsmoduler - description
-------------------
begin : Wed Jul 28 2004
- copyright : (C) 2004, 2007, 2009, 2010 by Thomas Friedrichsmeier
+ copyright : (C) 2004, 2007, 2009, 2010, 2011 by Thomas Friedrichsmeier
email : tfry at users.sourceforge.net
***************************************************************************/
@@ -27,6 +27,7 @@
class QLineEdit;
class MultiStringSelector;
class KIntSpinBox;
+class QTextEdit;
/**
Configure the R-backend
@@ -57,9 +58,7 @@
static int getDefaultWidth () { return options_width; };
public slots:
- void boxChanged (int);
- void pathChanged ();
- void textChanged (const QString &);
+ void settingChanged ();
private:
QLineEdit *outdec_input;
KIntSpinBox *width_input;
@@ -71,9 +70,9 @@
KIntSpinBox *expressions_input;
KIntSpinBox *digits_input;
QComboBox *checkbounds_input;
- QLineEdit *printcmd_input;
QComboBox *editor_input;
QComboBox *pager_input;
+ QTextEdit *further_input;
static QString options_outdec;
static int options_width;
@@ -85,9 +84,9 @@
static int options_expressions;
static int options_digits;
static bool options_checkbounds;
- static QString options_printcmd;
static QString options_editor;
static QString options_pager;
+ static QString options_further;
// constants
static QString builtin_editor;
Modified: trunk/rkward/rkward/windows/rkwindowcatcher.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkwindowcatcher.cpp 2011-07-31 14:33:08 UTC (rev 3706)
+++ trunk/rkward/rkward/windows/rkwindowcatcher.cpp 2011-08-01 11:42:25 UTC (rev 3707)
@@ -341,11 +341,11 @@
KVBox *page = new KVBox (dialog);
dialog->setMainWidget (page);
- QLabel *label = new QLabel (i18n ("Width"), page);
+ new QLabel (i18n ("Width"), page);
KIntSpinBox *width = new KIntSpinBox (5, 32767, 1, xembed_container->width (), page, 10);
width->setEditFocus (true);
- label = new QLabel (i18n ("Height"), page);
+ new QLabel (i18n ("Height"), page);
KIntSpinBox *height = new KIntSpinBox (5, 32767, 1, xembed_container->height (), page, 10);
dialog->exec ();
@@ -375,7 +375,9 @@
void RKCaughtX11Window::printDevice () {
RK_TRACE (MISC);
- RKGlobals::rInterface ()->issueCommand ("dev.set (" + QString::number (device_number) + ")\ndev.print ()", RCommand::App, i18n ("Print contents of graphics device number %1", device_number), error_dialog);
+ QString printer_device;
+ if (RKSettingsModuleGraphics::kdePrintingEnabled ()) printer_device = "rk.printer.device";
+ RKGlobals::rInterface ()->issueCommand ("dev.set (" + QString::number (device_number) + ")\ndev.print (" + printer_device + ")", RCommand::App, i18n ("Print contents of graphics device number %1", device_number), error_dialog);
}
void RKCaughtX11Window::copyDeviceToRObject () {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the rkward-tracker
mailing list