18 changes: 13 additions & 5 deletions docbook/kst/tutorial.docbook
Original file line number Diff line number Diff line change
Expand Up @@ -742,13 +742,13 @@ Then, from the <guimenu>Create</guimenu> menu select

<para>
It is hard to see any details in this plot - a log-log plot would be
much easier. To convert the Y axis to log hit <keycap>L</keycap> and
to convert the X axis to log hit <keycap>G</keycap>. (These options
much easier. To toggle the Y axis to log hit <keycap>L</keycap> and
to toggle the X axis to log hit <keycap>G</keycap>. (These options
are also available in the context menu under the
<guimenuitem>Zoom</guimenuitem> submenu in case you forget the keyboard
commands). The plot will now be log-log, as shown:
</para>

<screenshot>
<screeninfo>Spectrum</screeninfo>
<mediaobject>
Expand All @@ -762,8 +762,16 @@ Then, from the <guimenu>Create</guimenu> menu select
</screenshot>

<para>
From the <guimenu>Create</guimenu> you can similarly create histograms, spectograms,
and equations of fields you have loaded.
Hitting <keycap>L</keycap> and <keycap>G</keycap> will toggle back to linear axis.
</para>

<para>
From the <guimenu>Create</guimenu> you can similarly create histograms, spectrograms and equations
of fields you have loaded.
</para>

<para>
Save your session - we will be using it again in the next section of the tutorial.
</para>
</sect1>

Expand Down
1 change: 1 addition & 0 deletions src/kst/x-kst.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<comment xml:lang="ca@valencia">Fitxer de sessió del Kst</comment>
<comment xml:lang="cs">Soubor sezení Kst</comment>
<comment xml:lang="de">Kst-Sitzungsdatei</comment>
<comment xml:lang="en_GB">Kst Session File</comment>
<comment xml:lang="es">Archivo de sesión de Kst</comment>
<comment xml:lang="it">File di sessione Kst</comment>
<comment xml:lang="nl">Sessiebestand in Kst</comment>
Expand Down
8 changes: 5 additions & 3 deletions src/libkstapp/commandlineparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ namespace Kst {
static const char *usageMessage =
"KST Command Line Usage\n"
"************************\n"
"*** Load a kst file: ***\n"
"kst [OPTIONS] kstfile\n"
"*** Load a kst session: ***\n"
"kst [OPTIONS] <kstfile>\n"
"\n"
"[OPTIONS] will override the datasource parameters for all data sources in the kst file:\n"
" -F <datasource>\n"
Expand All @@ -56,7 +56,7 @@ namespace Kst {

static const char *usageDetailsMessage =
"*** Read a data file ***\n"
"kst datasource OPTIONS [datasource OPTIONS []]\n"
"kst [<datasource> [OPTIONS]]\n"
"\n"
"OPTIONS are read and interpreted in order. Except for data object options, all are applied to all future data objects, unless later overridden.\n"
"Output Options:\n"
Expand Down Expand Up @@ -107,6 +107,8 @@ namespace Kst {
" -p <field> plot the spectrum of field.\n"
" -h <field> plot a histogram of field.\n"
" -z <field> plot an image of matrix field.\n"
"Misc:\n"
" --clientName=<client name> Set the client name for connecting with a script.\n"
"\n"
"****************\n"
"*** Examples ***\n"
Expand Down
8 changes: 8 additions & 0 deletions src/libkstapp/document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ bool Document::save(const QString& to) {
} else {
xml.writeAttribute("version", objectStore()->sessionVersionString);
}
if (_win->scriptServerNameSet()) {
xml.writeAttribute("clientName", _win->scriptServerName());
}

xml.writeStartElement("data");
foreach (DataSourcePtr s, objectStore()->dataSourceList()) {
Expand Down Expand Up @@ -271,6 +274,11 @@ bool Document::open(const QString& file) {
if (version.size()>2) {
objectStore()->sessionVersion += version[2].toInt();
}
QString server_name = attrs.value("clientName").toString();
if (!server_name.isEmpty()) {
_win->setScriptServerName(server_name);
}

//qDebug() << "version" << version << objectStore()->sessionVersion;
} else if (n == "data") {
if (state != Unknown) {
Expand Down
41 changes: 36 additions & 5 deletions src/libkstapp/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ MainWindow::MainWindow() :
_ae_display(2),
_ae_export_all(false),
_ae_autosave_period(0),
_ae_Timer(0)
_ae_Timer(0),
_sessionFileName(QString())
{
_doc = new Document(this);
_scriptServer = new ScriptServer(_doc->objectStore());
Expand All @@ -122,7 +123,7 @@ MainWindow::MainWindow() :
_debugDialog = new DebugDialog(this);
Debug::self()->setHandler(_debugDialog);

setWindowTitle("Kst");
setKstWindowTitle();

createActions();
createMenus();
Expand Down Expand Up @@ -300,7 +301,8 @@ void MainWindow::saveAs() {
//QString currentP = QDir::currentPath();
_doc->save(fn);
QDir::setCurrent(restorePath);
setWindowTitle("Kst - " + fn);
_sessionFileName = fn;
setKstWindowTitle();
updateRecentKstFiles(fn);
}

Expand Down Expand Up @@ -366,6 +368,33 @@ void MainWindow::updateRecentKstFiles(const QString& filename)
updateRecentFiles("recentKstFileList", _fileMenu, _bottomRecentKstActions, _recentKstFilesMenu, filename, SLOT(openRecentKstFile()));
}

void MainWindow::setKstWindowTitle()
{
QString title = "Kst";

if (!_sessionFileName.isEmpty()) {
title += " - " + _sessionFileName;
}
title += " -- " + _scriptServer->serverName;
setWindowTitle(title);
}

QString MainWindow::scriptServerName()
{
return _scriptServer->serverName;
}

bool MainWindow::scriptServerNameSet()
{
return _scriptServer->serverNameSet;
}

void MainWindow::setScriptServerName(QString server_name)
{
_scriptServer->setScriptServerName(server_name);
setKstWindowTitle();
}

void MainWindow::copyTab()
{
View *view = _tabWidget->currentView();
Expand Down Expand Up @@ -526,7 +555,8 @@ bool MainWindow::initFromCommandLine() {
ok = false;
}
if (!P.kstFileName().isEmpty()) {
setWindowTitle("Kst - " + P.kstFileName());
_sessionFileName = P.kstFileName();
setKstWindowTitle();
}
_doc->setChanged(false);
return ok;
Expand All @@ -547,7 +577,8 @@ void MainWindow::openFile(const QString &file) {
QMessageBox::critical(this, tr("Kst"),tr("Error opening document:\n '%1'\n%2\n").arg(file, lastError));
}

setWindowTitle("Kst - " + file);
_sessionFileName = file;
setKstWindowTitle();
updateRecentKstFiles(file);
}

Expand Down
5 changes: 5 additions & 0 deletions src/libkstapp/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ class MainWindow : public QMainWindow
static void setWidgetFlags(QWidget*);
void updateRecentKstFiles(const QString& newfilename = QString());

void setKstWindowTitle();
QString scriptServerName();
bool scriptServerNameSet();
void setScriptServerName(QString server_name);

public Q_SLOTS:
void copyTab();
Expand Down Expand Up @@ -365,6 +369,7 @@ class MainWindow : public QMainWindow
bool _ae_export_all;
int _ae_autosave_period;
QTimer *_ae_Timer;
QString _sessionFileName;

friend class ScriptServer;
};
Expand Down
65 changes: 55 additions & 10 deletions src/libkstapp/scriptserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,31 +72,54 @@ namespace Kst {

ScriptServer::ScriptServer(ObjectStore *obj) : _server(new QLocalServer(this)), _store(obj),_interface(0) {

QString initial="kstScript";
QString initial;

// get the Username from the OS. On windows this is USERNAME and on linux, USER.
#ifdef Q_OS_WIN
initial = qgetenv("USERNAME");
if (initial.isEmpty()) {// hmmm... something odd.
initial = qgetenv("USER");
}
#else
initial = qgetenv("USER");
if (initial.isEmpty()) { // hmmm... something odd.
initial = qgetenv("USERNAME");
}
#endif
if (initial.isEmpty()) {
initial = "KstScript";
}

serverName = false;
// The command line hasn't been parsed yet, so
// we can't rely on that to get the server name.
QStringList args= qApp->arguments();
for(int i=0;i<args.size();i++) {
if(args.at(i).startsWith("--serverName=")) {
if(args.at(i).startsWith("--clientName=")) {
initial=args.at(i);
initial.remove("--serverName=");
}
initial.remove("--clientName=");
serverNameSet = true;
} else if(args.at(i).startsWith("--serverName=")) {
initial=args.at(i);
initial.remove("--serverName=");
serverNameSet = true;
}
}

QString connectTo=initial;
serverName=initial;

int j = 1;
while(1) {
QLocalSocket socket;
socket.connectToServer(connectTo);
socket.connectToServer(serverName);
socket.waitForConnected(300);
if(socket.state()!=QLocalSocket::ConnectedState) {
_server->removeServer(connectTo);
_server->listen(connectTo);
_server->removeServer(serverName);
_server->listen(serverName);
break;
}
socket.disconnectFromServer();
connectTo=initial+QString::number(connectTo.remove(initial).toInt()+1);
serverName=initial+"-"+QString::number(j++);
}
connect(_server,SIGNAL(newConnection()),this,SLOT(procConnection()));

Expand Down Expand Up @@ -241,7 +264,29 @@ ScriptServer::ScriptServer(ObjectStore *obj) : _server(new QLocalServer(this)),
ScriptServer::~ScriptServer()
{
delete _server;
delete _interface;
delete _interface;
}

void ScriptServer::setScriptServerName(QString initial)
{
int j = 1;

_server->close();
serverName = initial;
while(1) {
QLocalSocket socket;
socket.connectToServer(serverName);
socket.waitForConnected(300);
if(socket.state()!=QLocalSocket::ConnectedState) {
_server->removeServer(serverName);
_server->listen(serverName);
break;
}
socket.disconnectFromServer();
serverName=initial+"-"+QString::number(j++);
}
serverNameSet = true;
//connect(_server,SIGNAL(newConnection()),this,SLOT(procConnection()));
}

/** Conv. function which takes a response, and executes if 'if' statement is unexistant or true. */
Expand Down
5 changes: 4 additions & 1 deletion src/libkstapp/scriptserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,11 @@ class ScriptServer : public QObject
public:
explicit ScriptServer(ObjectStore*obj);
~ScriptServer();
//QByteArray checkPrimatives(QByteArray&command,QLocalSocket* s);
void setStore(ObjectStore *obj) { _store = obj; vi.clear();}
QString serverName;
bool serverNameSet;
void setScriptServerName(QString server_name);

public slots:
void procConnection();
void readSomething();
Expand Down