179 changes: 98 additions & 81 deletions pyKst/pykst.py

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions src/libkstapp/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,24 @@ Application::Application(int &argc, char **argv)
QCoreApplication::setApplicationName("Kst");
setWindowIcon(KstGetIcon("kst"));


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


Builtins::initPrimitives(); //libkst
Builtins::initDataSources(); //libkstapp
Builtins::initObjects(); //libkstmath
Expand Down
2 changes: 2 additions & 0 deletions src/libkstapp/application.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ class Application : public QApplication
MainWindow *mainWindow() const;

void initMainWindow();
QString userName() {return _userName;}
private:
QPointer<MainWindow> _mainWindow;
QString _userName;
};

}
Expand Down
13 changes: 12 additions & 1 deletion src/libkstapp/document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,14 @@ bool Document::save(const QString& to) {
xml.writeAttribute("version", objectStore()->sessionVersionString);
}
if (_win->scriptServerNameSet()) {
xml.writeAttribute("scriptServerName", _win->scriptServerName());
QString server_name = _win->scriptServerName();
QString user_name = "--"+kstApp->userName();
if (server_name.endsWith(user_name)) {
server_name.remove(server_name.lastIndexOf(user_name),10000);
xml.writeAttribute("scriptServerNameHasUserName", QVariant(true).toString());
}

xml.writeAttribute("scriptServerName", server_name);
}

xml.writeStartElement("data");
Expand Down Expand Up @@ -275,6 +282,10 @@ bool Document::open(const QString& file) {
objectStore()->sessionVersion += version[2].toInt();
}
QString server_name = attrs.value("scriptServerName").toString();
if (attrs.value("scriptServerNameHasUserName").toString() == "true") {
server_name += "--" + kstApp->userName();
}

if (!server_name.isEmpty()) {
_win->setScriptServerName(server_name);
}
Expand Down
11 changes: 10 additions & 1 deletion src/libkstapp/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ MainWindow::MainWindow() :
_tabWidget = new TabWidget(this);
_undoGroup = new QUndoGroup(this);
_debugDialog = new DebugDialog(this);

Debug::self()->setHandler(_debugDialog);

setKstWindowTitle();
Expand Down Expand Up @@ -371,11 +372,19 @@ void MainWindow::updateRecentKstFiles(const QString& filename)
void MainWindow::setKstWindowTitle()
{
QString title = "Kst";
QString server_name = _scriptServer->serverName;
QString user_name = "--"+kstApp->userName();

if (server_name.endsWith(user_name)) {
server_name.remove(server_name.lastIndexOf(user_name),10000);
}

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

Expand Down
2 changes: 1 addition & 1 deletion src/libkstapp/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class MainWindow : public QMainWindow
bool scriptServerNameSet();
void setScriptServerName(QString server_name);

public Q_SLOTS:
public Q_SLOTS:
void copyTab();
void showDataManager();
void showDebugDialog();
Expand Down
16 changes: 1 addition & 15 deletions src/libkstapp/scriptserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,21 +74,7 @@ ScriptServer::ScriptServer(ObjectStore *obj) : _server(new QLocalServer(this)),

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";
}
initial = kstApp->userName();

serverNameSet = false;

Expand Down
2 changes: 1 addition & 1 deletion src/libkstapp/vectordialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ void VectorTab::updateTypeActivated(int idx)
_updateBox->setEnabled(false);
return;
}
//_updateBox->setEnabled(true);
switch (idx) {
_updateBox->setEnabled(true);
case 0: _dataSource->startUpdating(DataSource::Timer); break;
case 1: _dataSource->startUpdating(DataSource::File); break;
case 2: _dataSource->startUpdating(DataSource::None); break;
Expand Down