Skip to content

Commit

Permalink
Fixed bug with script stopping, some minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
yurii-litvinov committed May 30, 2016
1 parent 6757be9 commit 5211b38
Show file tree
Hide file tree
Showing 13 changed files with 82 additions and 94 deletions.
92 changes: 33 additions & 59 deletions translations/fr/trikGui_fr.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.0" language="fr_FR">
<TS version="2.1" language="fr_FR">
<context>
<name>QObject</name>
<message>
Expand All @@ -17,7 +17,7 @@
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../trikGui/commandSettingsWidget.cpp" line="48"/>
<location filename="../../trikGui/commandSettingsWidget.cpp" line="47"/>
<source>Command Settings</source>
<translation type="unfinished"></translation>
</message>
Expand All @@ -30,100 +30,82 @@
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../trikGui/commandsListWidget.cpp" line="35"/>
<location filename="../../trikGui/commandsListWidget.cpp" line="72"/>
<location filename="../../trikGui/commandsListWidget.cpp" line="36"/>
<source>Play Tone</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../trikGui/commandsListWidget.cpp" line="36"/>
<location filename="../../trikGui/commandsListWidget.cpp" line="76"/>
<location filename="../../trikGui/commandsListWidget.cpp" line="37"/>
<source>Smile</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../trikGui/commandsListWidget.cpp" line="37"/>
<location filename="../../trikGui/commandsListWidget.cpp" line="80"/>
<location filename="../../trikGui/commandsListWidget.cpp" line="38"/>
<source>Sad Smile</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../trikGui/commandsListWidget.cpp" line="38"/>
<location filename="../../trikGui/commandsListWidget.cpp" line="84"/>
<location filename="../../trikGui/commandsListWidget.cpp" line="39"/>
<source>Timer</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../trikGui/commandsListWidget.cpp" line="39"/>
<location filename="../../trikGui/commandsListWidget.cpp" line="40"/>
<source>Motor Forward</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../trikGui/commandsListWidget.cpp" line="40"/>
<location filename="../../trikGui/commandsListWidget.cpp" line="156"/>
<location filename="../../trikGui/commandsListWidget.cpp" line="41"/>
<source>Motor Backward</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../trikGui/commandsListWidget.cpp" line="41"/>
<location filename="../../trikGui/commandsListWidget.cpp" line="94"/>
<location filename="../../trikGui/commandsListWidget.cpp" line="42"/>
<source>Motors Stop</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../trikGui/commandsListWidget.cpp" line="42"/>
<location filename="../../trikGui/commandsListWidget.cpp" line="43"/>
<source>Wait for Light</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../trikGui/commandsListWidget.cpp" line="43"/>
<location filename="../../trikGui/commandsListWidget.cpp" line="109"/>
<location filename="../../trikGui/commandsListWidget.cpp" line="44"/>
<source>Wait for Ultrasonic Distance</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../trikGui/commandsListWidget.cpp" line="44"/>
<location filename="../../trikGui/commandsListWidget.cpp" line="45"/>
<source>Wait for Infrared Distance</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../trikGui/commandsListWidget.cpp" line="45"/>
<location filename="../../trikGui/commandsListWidget.cpp" line="111"/>
<location filename="../../trikGui/commandsListWidget.cpp" line="46"/>
<source>Wait for Encoder</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../trikGui/commandsListWidget.cpp" line="60"/>
<location filename="../../trikGui/commandsListWidget.cpp" line="66"/>
<source>Commands List</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../trikGui/commandsListWidget.cpp" line="85"/>
<location filename="../../trikGui/commandsListWidget.cpp" line="97"/>
<source>Choose waiting time (ms):</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../trikGui/commandsListWidget.cpp" line="91"/>
<location filename="../../trikGui/commandsListWidget.cpp" line="103"/>
<source>Delay %1 ms</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../trikGui/commandsListWidget.cpp" line="102"/>
<source>Motor</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../trikGui/commandsListWidget.cpp" line="105"/>
<source>Wait</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../trikGui/commandsListWidget.cpp" line="124"/>
<location filename="../../trikGui/commandsListWidget.cpp" line="143"/>
<source>&lt; add command &gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../trikGui/commandsListWidget.cpp" line="148"/>
<location filename="../../trikGui/commandsListWidget.cpp" line="170"/>
<source>Choose motors power (%): </source>
<translation type="unfinished"></translation>
</message>
Expand Down Expand Up @@ -298,19 +280,25 @@
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../trikGui/programmingWidget.cpp" line="35"/>
<location filename="../../trikGui/programmingWidget.cpp" line="101"/>
<location filename="../../trikGui/programmingWidget.cpp" line="106"/>
<location filename="../../trikGui/programmingWidget.cpp" line="40"/>
<location filename="../../trikGui/programmingWidget.cpp" line="125"/>
<source>&lt; add command &gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../trikGui/programmingWidget.cpp" line="43"/>
<location filename="../../trikGui/programmingWidget.cpp" line="45"/>
<location filename="../../trikGui/programmingWidget.cpp" line="127"/>
<source>Run program</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../trikGui/programmingWidget.cpp" line="52"/>
<location filename="../../trikGui/programmingWidget.cpp" line="47"/>
<location filename="../../trikGui/programmingWidget.cpp" line="129"/>
<source>Clear list</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../trikGui/programmingWidget.cpp" line="57"/>
<source>Programming</source>
<translation type="unfinished"></translation>
</message>
Expand All @@ -328,41 +316,27 @@
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>trikGui::SensorLever</name>
<message>
<location filename="../../trikGui/sensorLever.cpp" line="38"/>
<location filename="../../trikGui/sensorLever.cpp" line="112"/>
<source>&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../trikGui/sensorLever.cpp" line="114"/>
<source>&lt;</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>trikGui::SensorSettingsWidget</name>
<message>
<location filename="../../trikGui/sensorSettingsWidget.cpp" line="35"/>
<location filename="../../trikGui/sensorSettingsWidget.cpp" line="34"/>
<source>Select distance:
</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../trikGui/sensorSettingsWidget.cpp" line="37"/>
<location filename="../../trikGui/sensorSettingsWidget.cpp" line="34"/>
<source>Select tacho limit:
</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../trikGui/sensorSettingsWidget.cpp" line="47"/>
<location filename="../../trikGui/sensorSettingsWidget.cpp" line="44"/>
<source>Continue</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../trikGui/sensorSettingsWidget.cpp" line="61"/>
<location filename="../../trikGui/sensorSettingsWidget.cpp" line="56"/>
<source>Sensor Settings</source>
<translation type="unfinished"></translation>
</message>
Expand Down
Binary file modified translations/ru/trikGui_ru.qm
Binary file not shown.
15 changes: 9 additions & 6 deletions translations/ru/trikGui_ru.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.0" language="ru_RU">
<TS version="2.1" language="ru_RU">
<context>
<name>QObject</name>
<message>
Expand Down Expand Up @@ -75,7 +75,8 @@
</message>
<message>
<source>Choose waiting time (ms):</source>
<translation>Выберите время ожидания
<translation>Выберите время
ожидания
(в миллисекундах):</translation>
</message>
<message>
Expand All @@ -96,7 +97,8 @@
</message>
<message>
<source>Choose motors power (%): </source>
<translation>Выберите мощность моторов
<translation>Выберите мощность
моторов
(в процентах):</translation>
</message>
<message>
Expand Down Expand Up @@ -260,7 +262,8 @@
<name>trikGui::ProgrammingWidget</name>
<message>
<source>Add commands to list</source>
<translation>Добавьте команду в список</translation>
<translation>Добавьте команду
в список</translation>
</message>
<message>
<source>&lt; add command &gt;</source>
Expand Down Expand Up @@ -304,11 +307,11 @@
<name>trikGui::SensorLever</name>
<message>
<source>&gt;</source>
<translation>&gt;</translation>
<translation type="vanished">&gt;</translation>
</message>
<message>
<source>&lt;</source>
<translation>&lt;</translation>
<translation type="vanished">&lt;</translation>
</message>
</context>
<context>
Expand Down
1 change: 1 addition & 0 deletions trikGui/commandSettingsWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "commandSettingsWidget.h"

#include <QtGui/QKeyEvent>

#include <trikKernel/paths.h>
#include <QsLog.h>

Expand Down
4 changes: 2 additions & 2 deletions trikGui/commandsListWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ CommandsListWidget::CommandsListWidget(Controller &controller, const QString &na
<< tr("Wait for Encoder");

for (int i = 0; i < commandsList.size(); ++i) {
mCommands.addItem(commandsList.at(i).toLocal8Bit().constData());
mCommands.addItem(commandsList.at(i));
mCommands.item(i)->setData(Qt::UserRole, i);
}

Expand Down Expand Up @@ -77,7 +77,7 @@ void CommandsListWidget::keyPressEvent(QKeyEvent *event)
case Qt::Key_Return: {
const QVariant data = mCommands.currentItem()->data(Qt::UserRole);

switch(data.toInt()) {
switch (data.toInt()) {
case 0: {
mValue = mCommands.currentItem()->text();
mScript = QString(" brick.playSound(\"media/beep.wav\");\n");
Expand Down
2 changes: 1 addition & 1 deletion trikGui/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Controller::~Controller()

void Controller::runFile(const QString &filePath)
{
QFileInfo const fileInfo(filePath);
const QFileInfo fileInfo(filePath);
if (fileInfo.suffix() == "qts" || fileInfo.suffix() == "js") {
mScriptRunner->run(trikKernel::FileUtils::readFromFile(fileInfo.canonicalFilePath()), fileInfo.baseName());
} else if (fileInfo.suffix() == "wav" || fileInfo.suffix() == "mp3") {
Expand Down
4 changes: 2 additions & 2 deletions trikGui/programmingWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ ProgrammingWidget::ProgrammingWidget(Controller &controller, QWidget *parent)
{
mLayout.addWidget(&mTitle);

ScriptHolder* holder = ScriptHolder::instance();
const ScriptHolder * const holder = ScriptHolder::instance();
for (int i = 0; i < holder->size(); ++i) {
mCommands.addItem(tr(holder->titles().at(i).toLocal8Bit().constData()));
mCommands.item(i)->setData(Qt::UserRole, holder->commands().at(i));
Expand Down Expand Up @@ -64,7 +64,7 @@ void ProgrammingWidget::renewFocus()

void ProgrammingWidget::keyPressEvent(QKeyEvent *event)
{
ScriptHolder* holder = ScriptHolder::instance();
ScriptHolder * const holder = ScriptHolder::instance();

switch (event->key()) {
case Qt::Key_PowerDown: {
Expand Down
6 changes: 3 additions & 3 deletions trikGui/scriptHolder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ ScriptHolder* ScriptHolder::instance()
return holder;
}

QStringList ScriptHolder::titles() const
const QStringList &ScriptHolder::titles() const
{
return mTitles;
}

QStringList ScriptHolder::commands() const
const QStringList &ScriptHolder::commands() const
{
return mCommands;
}
Expand All @@ -40,7 +40,7 @@ int ScriptHolder::size() const
return mTitles.length();
}

void ScriptHolder::setData(const QString& title, const QString& command)
void ScriptHolder::setData(const QString &title, const QString &command)
{
mTitles.push_back(title);
mCommands.push_back(command);
Expand Down
6 changes: 3 additions & 3 deletions trikGui/scriptHolder.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@ class ScriptHolder
static ScriptHolder* instance();

/// Returns list which contains titles of commands.
QStringList titles() const;
const QStringList &titles() const;

/// Returns list which contains scripts for commands.
QStringList commands() const;
const QStringList &commands() const;

/// Returns number of stored commands.
int size() const;

/// Adds given strings to appropriate list.
/// @param title - new string for titles list.
/// @param command - new string for commands list.
void setData(const QString& title, const QString& command);
void setData(const QString &title, const QString &command);

/// Clears all stored data.
void clear();
Expand Down
Loading

0 comments on commit 5211b38

Please sign in to comment.