diff --git a/translations/fr/trikGui_fr.ts b/translations/fr/trikGui_fr.ts
index fdd855daf..870219398 100644
--- a/translations/fr/trikGui_fr.ts
+++ b/translations/fr/trikGui_fr.ts
@@ -42,7 +42,7 @@
trikGui::Controller
-
+
@@ -72,6 +72,16 @@
+
+
+
+
+
+
+
+
+
+
trikGui::InformationWidget
@@ -119,27 +129,27 @@
trikGui::LanguageSelectionWidget
-
+
-
+
-
+
-
+
-
+
@@ -147,13 +157,13 @@
trikGui::MotorLever
-
-
+
+
-
+
@@ -161,12 +171,12 @@
trikGui::MotorsWidget
-
+
-
+
diff --git a/translations/ru/trikGui_ru.qm b/translations/ru/trikGui_ru.qm
index f26746924..a573b581c 100644
Binary files a/translations/ru/trikGui_ru.qm and b/translations/ru/trikGui_ru.qm differ
diff --git a/translations/ru/trikGui_ru.ts b/translations/ru/trikGui_ru.ts
index c66f35451..5785e05b3 100644
--- a/translations/ru/trikGui_ru.ts
+++ b/translations/ru/trikGui_ru.ts
@@ -64,6 +64,14 @@
Файлы
+
+
+ Удаление
+
+
+
+ Вы уверены, что хотите удалить файл?
+
trikGui::InformationWidget
diff --git a/trikGui/controller.cpp b/trikGui/controller.cpp
index f95b3ca67..76c724c4b 100644
--- a/trikGui/controller.cpp
+++ b/trikGui/controller.cpp
@@ -83,9 +83,7 @@ void Controller::runFile(const QString &filePath)
} else if (fileInfo.suffix() == "wav" || fileInfo.suffix() == "mp3") {
mScriptRunner->run("brick.playSound(\"" + fileInfo.canonicalFilePath() + "\");", fileInfo.baseName());
} else if (fileInfo.suffix() == "sh") {
- QStringList args;
- args << filePath;
- QProcess::startDetached("sh", args);
+ QProcess::startDetached("sh", {filePath});
} else if (fileInfo.isExecutable()) {
QProcess::startDetached(filePath);
}
diff --git a/trikGui/fileManagerMessageBox.cpp b/trikGui/fileManagerMessageBox.cpp
deleted file mode 100644
index 0b4551df3..000000000
--- a/trikGui/fileManagerMessageBox.cpp
+++ /dev/null
@@ -1,92 +0,0 @@
-/* Copyright 2014 CyberTech Labs Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. */
-
-#include "fileManagerMessageBox.h"
-
-#include
-
-using namespace trikGui;
-
-FileManagerMessageBox::FileManagerMessageBox(QWidget *parent)
- : QMessageBox(parent)
-{
- init();
-}
-
-FileManagerMessageBox::~FileManagerMessageBox()
-{
- delete mDeleteButton;
- delete mOpenButton;
-}
-
-void FileManagerMessageBox::init()
-{
- setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint);
- setIcon(QMessageBox::Question);
- setText(tr("Do you want to open or delete the file?"));
-
- mOpenButton = addButton(tr("Open"), QMessageBox::AcceptRole);
- mDeleteButton = addButton(tr("Delete"), QMessageBox::DestructiveRole);
-}
-
-void FileManagerMessageBox::showMessage()
-{
- mEscStatus = false;
- setDefaultButton(mOpenButton);
- exec();
-}
-
-FileManagerMessageBox::FileState FileManagerMessageBox::userAnswer() const
-{
- if (!mEscStatus) {
- QAbstractButton const* const button = clickedButton();
- if (button == mOpenButton) {
- return FileState::Open;
- } else if (button == mDeleteButton) {
- return FileState::Delete;
- }
- }
-
- return FileState::None;
-}
-
-void FileManagerMessageBox::keyPressEvent(QKeyEvent *event)
-{
- switch (event->key()) {
- case Qt::Key_Escape: {
- mEscStatus = true;
- reject();
- break;
- }
- case Qt::Key_Left:
- case Qt::Key_Right: {
- changeDefaultButton();
- break;
- }
- default: {
- QMessageBox::keyPressEvent(event);
- break;
- }
- }
-}
-
-void FileManagerMessageBox::changeDefaultButton()
-{
- QPushButton const* const current = defaultButton();
- if (current == mOpenButton) {
- setDefaultButton(mDeleteButton);
- } else {
- setDefaultButton(mOpenButton);
- }
-}
diff --git a/trikGui/fileManagerMessageBox.h b/trikGui/fileManagerMessageBox.h
deleted file mode 100644
index f31ee8b36..000000000
--- a/trikGui/fileManagerMessageBox.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/* Copyright 2014 CyberTech Labs Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. */
-
-#pragma once
-
-#include
-
-#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
- #include
- #include
-#else
- #include
- #include
-#endif
-
-#include
-
-namespace trikGui {
-
-/// Message box that asks user if he/she wants to open or delete a file.
-class FileManagerMessageBox : public QMessageBox
-{
- Q_OBJECT
-public:
- enum class FileState {
- None,
- Open,
- Delete
- };
-
- /// Constructor.
- /// @param parent - parent of this widget in terms of Qt parent-child widget relations.
- explicit FileManagerMessageBox(QWidget *parent = 0);
-
- ~FileManagerMessageBox() override;
-
- /// Shows a widget as modal dialog.
- void showMessage();
-
- /// Returns user selection after dialog is closed.
- FileState userAnswer() const;
-
-protected:
- void keyPressEvent(QKeyEvent *event) override;
-
-private:
- void init();
- void changeDefaultButton();
-
- QPushButton *mOpenButton; // Has ownership
- QPushButton *mDeleteButton; // Has ownership
- bool mEscStatus = false;
-};
-
-}
-
diff --git a/trikGui/fileManagerWidget.cpp b/trikGui/fileManagerWidget.cpp
index 4a8392765..96b0f1a59 100644
--- a/trikGui/fileManagerWidget.cpp
+++ b/trikGui/fileManagerWidget.cpp
@@ -22,6 +22,14 @@
#include
#include
+#include
+
+#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
+ #include
+#else
+ #include
+#endif
+
using namespace trikGui;
FileManagerWidget::FileManagerWidget(Controller &controller, MainWidget::FileManagerRootType fileManagerRoot
@@ -91,17 +99,20 @@ void FileManagerWidget::open()
showCurrentDir();
}
} else {
- mOpenDeleteBox.showMessage();
- FileManagerMessageBox::FileState const choice = mOpenDeleteBox.userAnswer();
- switch (choice) {
- case FileManagerMessageBox::FileState::Open:
- mController.runFile(mFileSystemModel.filePath(index));
- break;
- case FileManagerMessageBox::FileState::Delete:
+ mController.runFile(mFileSystemModel.filePath(index));
+ }
+}
+
+void FileManagerWidget::remove()
+{
+ const QModelIndex &index = mFileSystemView.currentIndex();
+ if (!mFileSystemModel.isDir(index)) {
+ QMessageBox confirmMessageBox(QMessageBox::Warning, tr("Confirm deletion")
+ , tr("Are you sure you want to delete file?"), QMessageBox::Yes | QMessageBox::No);
+ confirmMessageBox.setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint);
+ const int result = confirmMessageBox.exec();
+ if (result == QMessageBox::Yes) {
mFileSystemModel.remove(index);
- break;
- default:
- break;
}
}
}
@@ -113,6 +124,10 @@ void FileManagerWidget::keyPressEvent(QKeyEvent *event)
open();
break;
}
+ case Qt::Key_Right: {
+ remove();
+ break;
+ }
default: {
TrikGuiDialog::keyPressEvent(event);
break;
diff --git a/trikGui/fileManagerWidget.h b/trikGui/fileManagerWidget.h
index 41a605840..e38b7e194 100644
--- a/trikGui/fileManagerWidget.h
+++ b/trikGui/fileManagerWidget.h
@@ -35,7 +35,6 @@
#include "controller.h"
#include "trikGuiDialog.h"
-#include "fileManagerMessageBox.h"
namespace trikGui {
@@ -70,6 +69,7 @@ private slots:
private:
void showCurrentDir();
void open();
+ void remove();
QString currentPath();
QVBoxLayout mLayout;
@@ -79,8 +79,6 @@ private slots:
Controller &mController;
QString mRootDirPath;
QString mLastSelectedFile;
-
- FileManagerMessageBox mOpenDeleteBox;
};
}
diff --git a/trikGui/trikGui.pro b/trikGui/trikGui.pro
index 4ec3c3de7..39ddb91f7 100644
--- a/trikGui/trikGui.pro
+++ b/trikGui/trikGui.pro
@@ -22,7 +22,6 @@ HEADERS += \
$$PWD/controller.h \
$$PWD/digitSelector.h \
$$PWD/encoderIndicator.h \
- $$PWD/fileManagerMessageBox.h \
$$PWD/fileManagerWidget.h \
$$PWD/informationWidget.h \
$$PWD/languageSelectionWidget.h \
@@ -57,7 +56,6 @@ SOURCES += \
$$PWD/controller.cpp \
$$PWD/digitSelector.cpp \
$$PWD/encoderIndicator.cpp \
- $$PWD/fileManagerMessageBox.cpp \
$$PWD/fileManagerWidget.cpp \
$$PWD/informationWidget.cpp \
$$PWD/languageSelectionWidget.cpp \
diff --git a/trikRuntime.pro b/trikRuntime.pro
index a091e55d4..6f3b7ca67 100644
--- a/trikRuntime.pro
+++ b/trikRuntime.pro
@@ -26,7 +26,6 @@ SUBDIRS = \
trikServer \
trikTelemetry \
trikWiFi \
- trikRuntimeKiller \
translations \
qslog.file = qslog/QsLogSharedLibrary.pro
@@ -41,4 +40,3 @@ trikScriptRunner.depends = trikControl trikKernel trikNetwork qslog
trikServer.depends = trikCommunicator qslog
trikTelemetry.depends = trikControl trikNetwork trikKernel qslog
trikWiFi.depends = qslog
-trikRuntimeKiller.depends = qslog
diff --git a/trikRuntimeKiller/keys.cpp b/trikRuntimeKiller/keys.cpp
deleted file mode 100644
index 7cfea3dea..000000000
--- a/trikRuntimeKiller/keys.cpp
+++ /dev/null
@@ -1,84 +0,0 @@
-/* Copyright 2015 CyberTech Labs Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. */
-
-#include "keys.h"
-
-#include
-#include
-#include
-
-#include
-#include
-#include
-
-using namespace trikRuntimeKiller;
-
-Keys::Keys()
-{
- mKeysFileDescriptor = open("/dev/input/by-path/platform-gpio-keys-event", O_SYNC, O_RDONLY);
- if (mKeysFileDescriptor == -1) {
- qDebug() << "cannot open keys input file";
- return;
- }
-
- mSocketNotifier.reset(new QSocketNotifier(mKeysFileDescriptor, QSocketNotifier::Read, this));
-
- connect(mSocketNotifier.data(), SIGNAL(activated(int)), this, SLOT(readKeysEvent()));
- mSocketNotifier->setEnabled(true);
-}
-
-Keys::~Keys()
-{
-}
-
-void Keys::readKeysEvent()
-{
- struct input_event event;
-
- if (read(mKeysFileDescriptor, reinterpret_cast(&event), sizeof(event)) != sizeof(event)) {
- return;
- }
-
- switch (event.type)
- {
- case EV_KEY: {
- mButtonCode = static_cast(event.code);
- mButtonValue = static_cast(event.value);
- break;
- }
- case EV_SYN: {
- switch (mButtonCode) {
- case 108: {
- mDownPressed = mButtonValue == 1;
- break;
- }
- case 28: {
- mEnterPressed = mButtonValue == 1;
- break;
- }
- case 1: {
- mEscapePressed = mButtonValue == 1;
- break;
- }
- default: {
- break;
- }
- }
-
- if (mEnterPressed && mDownPressed && mEscapePressed) {
- QProcess::startDetached("/usr/bin/killall", {"trikGui"});
- }
- }
- }
-}
diff --git a/trikRuntimeKiller/keys.h b/trikRuntimeKiller/keys.h
deleted file mode 100644
index 50c27f897..000000000
--- a/trikRuntimeKiller/keys.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/* Copyright 2015 CyberTech Labs Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. */
-
-#pragma once
-
-#include
-#include
-
-class QSocketNotifier;
-
-namespace trikRuntimeKiller {
-
-/// Application class, to intercept key presses.
-class Keys : public QObject
-{
- Q_OBJECT
-
-public:
- Keys();
- ~Keys() override;
-
-private slots:
- void readKeysEvent();
-
-private:
- bool mEnterPressed = false;
- bool mDownPressed = false;
- bool mEscapePressed = false;
-
- QScopedPointer mSocketNotifier;
- int mKeysFileDescriptor = 0;
-
- int mButtonCode = 0;
- int mButtonValue = 0;
-};
-
-}
diff --git a/trikRuntimeKiller/main.cpp b/trikRuntimeKiller/main.cpp
deleted file mode 100644
index 80a970ffc..000000000
--- a/trikRuntimeKiller/main.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-/* Copyright 2015 CyberTech Labs Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. */
-
-#include
-#include
-#include
-
-#include "keys.h"
-
-using namespace trikRuntimeKiller;
-
-void printUsage()
-{
- qDebug() << "Usage: trikRuntimeKiller";
- qDebug() << "Kills trikGui process when 'Down', 'Enter' and 'Escape' buttons are pressed simultaneously";
-}
-
-int main(int argc, char *argv[])
-{
- QCoreApplication app(argc, argv);
- const QStringList args = app.arguments();
-
- if (args.count() > 1) {
- printUsage();
- return 1;
- }
-
- Keys keys;
- Q_UNUSED(keys)
-
- return app.exec();
-}
diff --git a/trikRuntimeKiller/trikRuntimeKiller.pro b/trikRuntimeKiller/trikRuntimeKiller.pro
deleted file mode 100644
index dd60a0131..000000000
--- a/trikRuntimeKiller/trikRuntimeKiller.pro
+++ /dev/null
@@ -1,27 +0,0 @@
-# Copyright 2015 CyberTech Labs Ltd.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-include(../global.pri)
-
-QT += gui
-
-HEADERS += \
- $$PWD/keys.h \
-
-SOURCES += \
- $$PWD/main.cpp \
- $$PWD/keys.cpp \
-
-TEMPLATE = app
-CONFIG += console