Skip to content

Commit 639c8da

Browse files
Merge branch 'startDirectoryFix' of git://github.com/romankurbatov/trikRuntime
2 parents d64c4f9 + abef47b commit 639c8da

File tree

23 files changed

+59
-38
lines changed

23 files changed

+59
-38
lines changed

trikCommunicator/include/trikCommunicator/trikCommunicator.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ class TrikCommunicator : public QTcpServer
4141
public:
4242
/// Constructor that creates its own instance of a script runner.
4343
/// @param configPath - path to config file for trikControl, for example, /home/root/trik/.
44-
explicit TrikCommunicator(QString const &configFilePath);
44+
/// @param startDirPath - path to the directory from which the application was executed.
45+
explicit TrikCommunicator(QString const &configFilePath, QString const &startDirPath);
4546

4647
/// Constructor that accepts external script runner and issues commands to it.
4748
explicit TrikCommunicator(trikScriptRunner::TrikScriptRunner &runner);

trikCommunicator/src/scriptRunnerWrapper.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818

1919
using namespace trikCommunicator;
2020

21-
ScriptRunnerWrapper::ScriptRunnerWrapper(QString const &configFilePath)
22-
: mRunner(new trikScriptRunner::TrikScriptRunner(configFilePath))
21+
ScriptRunnerWrapper::ScriptRunnerWrapper(QString const &configFilePath, QString const &startDirPath)
22+
: mRunner(new trikScriptRunner::TrikScriptRunner(configFilePath, startDirPath))
2323
, mOwnsRunner(true)
2424
, mExecutionState(idle)
2525
{

trikCommunicator/src/scriptRunnerWrapper.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ class ScriptRunnerWrapper : public QObject {
2929
public:
3030
/// Constructor that creates its own instance of a script runner.
3131
/// @param configPath - path to config file for trikControl, for example, /home/root/trik/.
32-
explicit ScriptRunnerWrapper(QString const &configFilePath);
32+
/// @param startDirPath - path to the directory from which the application was executed.
33+
explicit ScriptRunnerWrapper(QString const &configFilePath, QString const &startDirPath);
3334

3435
/// Constructor that accepts external script runner and issues commands to it.
3536
explicit ScriptRunnerWrapper(trikScriptRunner::TrikScriptRunner &runner);

trikCommunicator/src/trikCommunicator.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323

2424
using namespace trikCommunicator;
2525

26-
TrikCommunicator::TrikCommunicator(QString const &configFilePath)
27-
: mScriptRunnerWrapper(new ScriptRunnerWrapper(configFilePath))
26+
TrikCommunicator::TrikCommunicator(QString const &configFilePath, const QString &startDirPath)
27+
: mScriptRunnerWrapper(new ScriptRunnerWrapper(configFilePath, startDirPath))
2828
{
2929
init();
3030
}

trikControl/include/trikControl/brick.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ class TRIKCONTROL_EXPORT Brick : public QObject
5454
/// @param guiThread - thread in which an application has started. Can be obtaned in main() by code like
5555
/// QApplication app; app.thread();
5656
/// @param configFilePath - path to config.xml
57-
Brick(QThread &guiThread, QString const &configFilePath);
57+
/// @param startDirPath - path to the directory from which the application was executed.
58+
Brick(QThread &guiThread, QString const &configFilePath, QString const &startDirPath);
5859

5960
~Brick();
6061

trikControl/include/trikControl/display.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#pragma once
1616

1717
#include <QtCore/QThread>
18+
#include <QtCore/QString>
1819

1920
#include "declSpec.h"
2021

@@ -30,7 +31,8 @@ class TRIKCONTROL_EXPORT Display : public QObject
3031
public:
3132
/// Constructor.
3233
/// @param guiThread - GUI thread of an application.
33-
explicit Display(QThread &guiThread);
34+
/// @param startDirPath - path to the directory from which the application was executed.
35+
explicit Display(QThread &guiThread, QString const &startDirPath);
3436

3537
~Display();
3638

@@ -77,6 +79,7 @@ public slots:
7779

7880
private:
7981
QThread &mGuiThread;
82+
QString const mStartDirPath;
8083
GuiWorker *mGuiWorker; // Has ownership.
8184
};
8285

trikControl/src/brick.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@
2828

2929
using namespace trikControl;
3030

31-
Brick::Brick(QThread &guiThread, QString const &configFilePath)
31+
Brick::Brick(QThread &guiThread, QString const &configFilePath, const QString &startDirPath)
3232
: mConfigurer(new Configurer(configFilePath))
3333
, mI2cCommunicator(NULL)
34-
, mDisplay(guiThread)
34+
, mDisplay(guiThread, startDirPath)
3535
, mInEventDrivenMode(false)
3636
{
3737
if (::system(mConfigurer->initScript().toStdString().c_str()) != 0) {

trikControl/src/display.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@
2727

2828
using namespace trikControl;
2929

30-
Display::Display(QThread &guiThread)
30+
Display::Display(QThread &guiThread, const QString &startDirPath)
3131
: mGuiThread(guiThread)
32+
, mStartDirPath(startDirPath)
3233
{
3334
mGuiWorker = new GuiWorker();
3435
mGuiWorker->moveToThread(&guiThread);
@@ -65,12 +66,12 @@ void Display::removeLabels()
6566

6667
void Display::smile()
6768
{
68-
showImage("media/trik_smile_normal.png");
69+
showImage(mStartDirPath + "/media/trik_smile_normal.png");
6970
}
7071

7172
void Display::sadSmile()
7273
{
73-
showImage("media/trik_smile_sad.png");
74+
showImage(mStartDirPath + "/media/trik_smile_sad.png");
7475
}
7576

7677
void Display::setBackground(QString const &color)

trikGui/controller.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ using namespace trikGui;
2424

2525
int const communicatorPort = 8888;
2626

27-
Controller::Controller(QString const &configPath)
28-
: mScriptRunner(configPath)
27+
Controller::Controller(QString const &configPath, QString const &startDirPath)
28+
: mScriptRunner(configPath, startDirPath)
2929
, mCommunicator(mScriptRunner)
3030
, mRunningWidget(NULL)
3131
, mExecutionState(idle)

trikGui/controller.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ class Controller : public QObject
3030
public:
3131
/// Constructor.
3232
/// @param configPath - path to config file for trikControl, for example, /home/root/trik/.
33-
Controller(QString const &configPath);
33+
/// @param startDirPath - path to the directory from which the application was executed.
34+
Controller(QString const &configPath, QString const &startDirPath);
3435

3536
~Controller();
3637

0 commit comments

Comments
 (0)