Skip to content

Commit

Permalink
Merge branch 'scriptsDir' of git://github.com/Anna-/trikRuntime
Browse files Browse the repository at this point in the history
  • Loading branch information
yurii-litvinov committed Sep 26, 2014
2 parents 9cb8950 + 1d8ff82 commit 3a4d540
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
6 changes: 6 additions & 0 deletions trikGui/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Controller::Controller(QString const &configPath, QString const &startDirPath)
, mScriptRunner(mBrick, startDirPath)
, mCommunicator(mScriptRunner)
, mRunningWidget(NULL)
, mStartDirPath(startDirPath)
{
connect(&mScriptRunner, SIGNAL(completed(QString)), this, SLOT(scriptExecutionCompleted(QString)));

Expand Down Expand Up @@ -77,6 +78,11 @@ trikControl::Brick &Controller::brick()
return mBrick;
}

QString Controller::startDirPath()
{
return mStartDirPath;
}

void Controller::scriptExecutionCompleted(QString const &error)
{
if (mRunningWidget && error.isEmpty()) {
Expand Down
3 changes: 3 additions & 0 deletions trikGui/controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ class Controller : public QObject
/// Returns reference to Brick object, which provides access to low-level robot functionality.
trikControl::Brick &brick();

QString startDirPath();

private slots:
void scriptExecutionCompleted(QString const &error);

Expand All @@ -57,6 +59,7 @@ private slots:
trikCommunicator::TrikCommunicator mCommunicator;

RunningWidget *mRunningWidget; // Has ownership.
QString const &mStartDirPath;
};

}
12 changes: 10 additions & 2 deletions trikGui/fileManagerWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,20 @@
#include <QtGui/QKeyEvent>

using namespace trikGui;
QString const scriptsDirName = "scripts";

FileManagerWidget::FileManagerWidget(Controller &controller, QWidget *parent)
: TrikGuiDialog(parent)
, mController(controller)
{
mFileSystemModel.setRootPath(QDir::rootPath());
mRootDirPath = mController.startDirPath() + scriptsDirName;

QDir::setCurrent(mController.startDirPath());
QDir dir;
dir.mkdir(scriptsDirName);
QDir::setCurrent(mRootDirPath);

mFileSystemModel.setRootPath(mRootDirPath);
mFileSystemModel.setFilter(QDir::AllEntries | QDir::Hidden | QDir::System | QDir::NoDot);

connect(&mFileSystemModel
Expand Down Expand Up @@ -93,7 +101,7 @@ void FileManagerWidget::showCurrentDir()
mCurrentPathLabel.setText(QDir::currentPath());

QDir::Filters filters = mFileSystemModel.filter();
if (QDir::currentPath() == QDir::rootPath()) {
if (QDir::currentPath() == mRootDirPath) {
filters |= QDir::NoDotDot;
} else {
filters &= ~QDir::NoDotDot;
Expand Down
1 change: 1 addition & 0 deletions trikGui/fileManagerWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ private slots:
QListView mFileSystemView;
QFileSystemModel mFileSystemModel;
Controller &mController;
QString mRootDirPath;
};

}

0 comments on commit 3a4d540

Please sign in to comment.