Skip to content

Commit

Permalink
Merge pull request #125 from trikset/remove-file
Browse files Browse the repository at this point in the history
Reworked file deletion UI (now it uses Right button), removed trikRun…
  • Loading branch information
yurii-litvinov committed Aug 14, 2015
2 parents d1f385f + 8eb6e90 commit 448a474
Show file tree
Hide file tree
Showing 14 changed files with 56 additions and 392 deletions.
32 changes: 21 additions & 11 deletions translations/fr/trikGui_fr.ts
Expand Up @@ -42,7 +42,7 @@
<context>
<name>trikGui::Controller</name>
<message>
<location filename="../../trikGui/controller.cpp" line="145"/>
<location filename="../../trikGui/controller.cpp" line="143"/>
<source>direct command</source>
<translation type="unfinished"></translation>
</message>
Expand Down Expand Up @@ -72,6 +72,16 @@
<source>File Manager</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../trikGui/fileManagerWidget.cpp" line="102"/>
<source>Confirm deletion</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../trikGui/fileManagerWidget.cpp" line="103"/>
<source>Are you sure you want to delete file?</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>trikGui::InformationWidget</name>
Expand Down Expand Up @@ -119,54 +129,54 @@
<context>
<name>trikGui::LanguageSelectionWidget</name>
<message>
<location filename="../../trikGui/languageSelectionWidget.cpp" line="36"/>
<location filename="../../trikGui/languageSelectionWidget.cpp" line="38"/>
<source>Select language:</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../trikGui/languageSelectionWidget.cpp" line="42"/>
<location filename="../../trikGui/languageSelectionWidget.cpp" line="44"/>
<source>English</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../trikGui/languageSelectionWidget.cpp" line="71"/>
<location filename="../../trikGui/languageSelectionWidget.cpp" line="75"/>
<source>Language</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../trikGui/languageSelectionWidget.cpp" line="87"/>
<location filename="../../trikGui/languageSelectionWidget.cpp" line="92"/>
<source>Warning</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../trikGui/languageSelectionWidget.cpp" line="88"/>
<location filename="../../trikGui/languageSelectionWidget.cpp" line="93"/>
<source>GUI will now restart</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>trikGui::MotorLever</name>
<message>
<location filename="../../trikGui/motorLever.cpp" line="41"/>
<location filename="../../trikGui/motorLever.cpp" line="132"/>
<location filename="../../trikGui/motorLever.cpp" line="40"/>
<location filename="../../trikGui/motorLever.cpp" line="127"/>
<source>off</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../trikGui/motorLever.cpp" line="129"/>
<location filename="../../trikGui/motorLever.cpp" line="124"/>
<source>on</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>trikGui::MotorsWidget</name>
<message>
<location filename="../../trikGui/motorsWidget.cpp" line="53"/>
<location filename="../../trikGui/motorsWidget.cpp" line="79"/>
<source>Test power motors</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../trikGui/motorsWidget.cpp" line="56"/>
<location filename="../../trikGui/motorsWidget.cpp" line="82"/>
<source>Test servo motors</source>
<translation type="unfinished"></translation>
</message>
Expand Down
Binary file modified translations/ru/trikGui_ru.qm
Binary file not shown.
8 changes: 8 additions & 0 deletions translations/ru/trikGui_ru.ts
Expand Up @@ -64,6 +64,14 @@
<source>File Manager</source>
<translation>Файлы</translation>
</message>
<message>
<source>Confirm deletion</source>
<translation>Удаление</translation>
</message>
<message>
<source>Are you sure you want to delete file?</source>
<translation>Вы уверены, что хотите удалить файл?</translation>
</message>
</context>
<context>
<name>trikGui::InformationWidget</name>
Expand Down
4 changes: 1 addition & 3 deletions trikGui/controller.cpp
Expand Up @@ -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);
}
Expand Down
92 changes: 0 additions & 92 deletions trikGui/fileManagerMessageBox.cpp

This file was deleted.

67 changes: 0 additions & 67 deletions trikGui/fileManagerMessageBox.h

This file was deleted.

35 changes: 25 additions & 10 deletions trikGui/fileManagerWidget.cpp
Expand Up @@ -22,6 +22,14 @@
#include <QtGui/QKeyEvent>
#include <QtCore/QSettings>

#include <QtCore/qglobal.h>

#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
#include <QtGui/QMessageBox>
#else
#include <QtWidgets/QMessageBox>
#endif

using namespace trikGui;

FileManagerWidget::FileManagerWidget(Controller &controller, MainWidget::FileManagerRootType fileManagerRoot
Expand Down Expand Up @@ -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;
}
}
}
Expand All @@ -113,6 +124,10 @@ void FileManagerWidget::keyPressEvent(QKeyEvent *event)
open();
break;
}
case Qt::Key_Right: {
remove();
break;
}
default: {
TrikGuiDialog::keyPressEvent(event);
break;
Expand Down
4 changes: 1 addition & 3 deletions trikGui/fileManagerWidget.h
Expand Up @@ -35,7 +35,6 @@

#include "controller.h"
#include "trikGuiDialog.h"
#include "fileManagerMessageBox.h"

namespace trikGui {

Expand Down Expand Up @@ -70,6 +69,7 @@ private slots:
private:
void showCurrentDir();
void open();
void remove();
QString currentPath();

QVBoxLayout mLayout;
Expand All @@ -79,8 +79,6 @@ private slots:
Controller &mController;
QString mRootDirPath;
QString mLastSelectedFile;

FileManagerMessageBox mOpenDeleteBox;
};

}
2 changes: 0 additions & 2 deletions trikGui/trikGui.pro
Expand Up @@ -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 \
Expand Down Expand Up @@ -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 \
Expand Down
2 changes: 0 additions & 2 deletions trikRuntime.pro
Expand Up @@ -26,7 +26,6 @@ SUBDIRS = \
trikServer \
trikTelemetry \
trikWiFi \
trikRuntimeKiller \
translations \

qslog.file = qslog/QsLogSharedLibrary.pro
Expand All @@ -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

0 comments on commit 448a474

Please sign in to comment.