Index: denali.qrc
===================================================================
diff -u -r174d5078531f9dfbe9cdc45274b852984bb72647 -rfbeafa0714f065bce0403e2e8ce68f6d8fbea6bd
--- denali.qrc (.../denali.qrc) (revision 174d5078531f9dfbe9cdc45274b852984bb72647)
+++ denali.qrc (.../denali.qrc) (revision fbeafa0714f065bce0403e2e8ce68f6d8fbea6bd)
@@ -28,6 +28,7 @@
sources/gui/qml/components/StackItem.qml
sources/gui/qml/components/ModalDialog.qml
sources/gui/qml/components/BackButton.qml
+ sources/gui/qml/components/USBButton.qml
qtquickcontrols2.conf
Index: main.cpp
===================================================================
diff -u -r2fdeb1c461dde1b7b8bffcc5b814736190f98988 -rfbeafa0714f065bce0403e2e8ce68f6d8fbea6bd
--- main.cpp (.../main.cpp) (revision 2fdeb1c461dde1b7b8bffcc5b814736190f98988)
+++ main.cpp (.../main.cpp) (revision fbeafa0714f065bce0403e2e8ce68f6d8fbea6bd)
@@ -86,6 +86,9 @@
app.installTranslator(&translator);
}
+ //! - Initializing File Handler
+ _FileHandler->init();
+
//! - Initializing Main Timer
_MainTimer->init();
Index: sources/applicationcontroller.cpp
===================================================================
diff -u -r4b9619614f0a9deb0438a803c057918b94aacbec -rfbeafa0714f065bce0403e2e8ce68f6d8fbea6bd
--- sources/applicationcontroller.cpp (.../applicationcontroller.cpp) (revision 4b9619614f0a9deb0438a803c057918b94aacbec)
+++ sources/applicationcontroller.cpp (.../applicationcontroller.cpp) (revision fbeafa0714f065bce0403e2e8ce68f6d8fbea6bd)
@@ -30,17 +30,14 @@
*/
ApplicationController::ApplicationController(QObject *parent) : QObject(parent)
{
- _fileHandler = new Storage::FileHandler (this);
_applicationPost = new ApplicationPost(this);
-
}
/*!
* \brief ApplicationController initializer
*/
bool ApplicationController::init()
{
- if (!_fileHandler ->init()) return false;
if (!_applicationPost->init()) return false;
initConnections();
return true;
@@ -58,9 +55,19 @@
// From GUI
connect(_GuiController , SIGNAL(didActionTransmit(GuiActionType, const QVariantList &)),
this , SLOT( onActionTransmit(GuiActionType, const QVariantList &)));
+
// From HD/DG
connect(_MessageDispatcher, SIGNAL(didActionReceive(GuiActionType, const QVariantList &)),
this , SLOT( onActionReceive(GuiActionType, const QVariantList &)));
+
+ connect(_GuiController , SIGNAL(didUSBDriveUmount()),
+ this , SLOT( onUSBDriveUmount()));
+ connect(_FileHandler , SIGNAL(didUSBDriveMount ()),
+ this , SLOT( onUSBDriveMount ()));
+ connect(_FileHandler , SIGNAL(didUSBDriveRemove()),
+ this , SLOT( onUSBDriveRemove()));
+
+
}
/*!
@@ -95,6 +102,21 @@
keepAlive();
}
+void ApplicationController::onUSBDriveMount ()
+{
+ emit didUSBDriveMount();
+}
+
+void ApplicationController::onUSBDriveUmount()
+{
+ _FileHandler->umounted(true);
+}
+
+void ApplicationController::onUSBDriveRemove()
+{
+ emit didUSBDriveRemove();
+}
+
/*!
* \brief ApplicationController::keepAlive
* \details This is the message which has to be send over the CANBUS
Index: sources/applicationcontroller.h
===================================================================
diff -u -r4b9619614f0a9deb0438a803c057918b94aacbec -rfbeafa0714f065bce0403e2e8ce68f6d8fbea6bd
--- sources/applicationcontroller.h (.../applicationcontroller.h) (revision 4b9619614f0a9deb0438a803c057918b94aacbec)
+++ sources/applicationcontroller.h (.../applicationcontroller.h) (revision fbeafa0714f065bce0403e2e8ce68f6d8fbea6bd)
@@ -37,7 +37,6 @@
{
Q_OBJECT
- FileHandler *_fileHandler = nullptr;
ApplicationPost *_applicationPost = nullptr;
SINGLETON_DECL(ApplicationController)
@@ -54,10 +53,17 @@
void onMainTimerTimeout();
+ void onUSBDriveMount ();
+ void onUSBDriveUmount();
+ void onUSBDriveRemove();
+
signals:
void didActionReceive (GuiActionType vAction, const QVariantList &vData); // UI <= HD/DG
void didActionTransmit(GuiActionType vAction, const QVariantList &vData); // UI => HD/DG
+ void didUSBDriveMount ();
+ void didUSBDriveRemove();
+
void quit(int retcode=0);
};
Index: sources/gui/guicontroller.cpp
===================================================================
diff -u -rfee7fabf49befb065c89248c19e15efc9ca194e4 -rfbeafa0714f065bce0403e2e8ce68f6d8fbea6bd
--- sources/gui/guicontroller.cpp (.../guicontroller.cpp) (revision fee7fabf49befb065c89248c19e15efc9ca194e4)
+++ sources/gui/guicontroller.cpp (.../guicontroller.cpp) (revision fbeafa0714f065bce0403e2e8ce68f6d8fbea6bd)
@@ -39,6 +39,12 @@
// From HD/DG
connect(_ApplicationController, SIGNAL(didActionReceive (GuiActionType, const QVariantList &)),
this , SLOT( onActionReceive (GuiActionType, const QVariantList &)));
+
+ // From OS : USB Drive has been removed physically.
+ connect(_ApplicationController, SIGNAL(didUSBDriveMount ()),
+ this , SLOT( onUSBDriveMount ()));
+ connect(_ApplicationController, SIGNAL(didUSBDriveRemove()),
+ this , SLOT( onUSBDriveRemove()));
}
/*!
@@ -103,3 +109,18 @@
// Process ...
emit didActionReceive (vAction, vData);
}
+
+void GuiController::onUSBDriveMount()
+{
+ emit didUSBDriveMount();
+}
+
+void GuiController::doUSBDriveUmount()
+{
+ emit didUSBDriveUmount();
+}
+
+void GuiController::onUSBDriveRemove()
+{
+ emit didUSBDriveRemove();
+}
Index: sources/gui/guicontroller.h
===================================================================
diff -u -rfee7fabf49befb065c89248c19e15efc9ca194e4 -rfbeafa0714f065bce0403e2e8ce68f6d8fbea6bd
--- sources/gui/guicontroller.h (.../guicontroller.h) (revision fee7fabf49befb065c89248c19e15efc9ca194e4)
+++ sources/gui/guicontroller.h (.../guicontroller.h) (revision fbeafa0714f065bce0403e2e8ce68f6d8fbea6bd)
@@ -42,12 +42,22 @@
public slots:
void doActionTransmit(GuiActionType vAction, const QVariantList &vData); // UI => HD/DG
+ void doUSBDriveUmount(); // UI => OS
+
+
private slots: // Should be private for thread safety and is connected internally.
void onActionReceive (GuiActionType vAction, const QVariantList &vData); // UI <= HD/DG
+ void onUSBDriveMount (); // OS => UI
+ void onUSBDriveRemove(); // OS => UI
+
signals:
void didActionReceive (GuiActionType vAction, const QVariantList &vData); // UI <= HD/DG
void didActionTransmit(GuiActionType vAction, const QVariantList &vData); // UI => HD/DG
+
+ void didUSBDriveMount ();
+ void didUSBDriveUmount();
+ void didUSBDriveRemove();
};
}
Index: sources/gui/guiview.cpp
===================================================================
diff -u -rfee7fabf49befb065c89248c19e15efc9ca194e4 -rfbeafa0714f065bce0403e2e8ce68f6d8fbea6bd
--- sources/gui/guiview.cpp (.../guiview.cpp) (revision fee7fabf49befb065c89248c19e15efc9ca194e4)
+++ sources/gui/guiview.cpp (.../guiview.cpp) (revision fbeafa0714f065bce0403e2e8ce68f6d8fbea6bd)
@@ -41,6 +41,14 @@
connect(this , SIGNAL(didActionTransmit(GuiActionType,const QVariantList &)),
_GuiController, SLOT( doActionTransmit(GuiActionType,const QVariantList &)));
+ // From UI : USB drive umount
+ connect(this , SIGNAL(didUSBDriveUmount()),
+ _GuiController, SLOT( doUSBDriveUmount()));
+ // From OS : USB drive removed
+ connect(_GuiController, SIGNAL(didUSBDriveMount ()),
+ this , SLOT( doUSBDriveMount ()));
+ connect(_GuiController, SIGNAL(didUSBDriveRemove()),
+ this , SLOT( doUSBDriveRemove()));
}
void GuiView::onActionReceive (GuiActionType vAction, const QVariantList &vData)
@@ -50,6 +58,16 @@
emit didActionReceive (vAction, vData);
}
+void GuiView::doUSBDriveMount ()
+{
+ emit didUSBDriveMount ();
+}
+
+void GuiView::doUSBDriveRemove()
+{
+ emit didUSBDriveRemove();
+}
+
void GuiView::doActionTransmit(GuiActionType vAction, const QVariantList &vData)
{
emit didActionTransmit(vAction, vData);
@@ -61,3 +79,8 @@
mData += vData;
emit didActionTransmit(vAction, mData);
}
+
+void GuiView::doUSBDriveUmount()
+{
+ emit didUSBDriveUmount();
+}
Index: sources/gui/guiview.h
===================================================================
diff -u -rfee7fabf49befb065c89248c19e15efc9ca194e4 -rfbeafa0714f065bce0403e2e8ce68f6d8fbea6bd
--- sources/gui/guiview.h (.../guiview.h) (revision fee7fabf49befb065c89248c19e15efc9ca194e4)
+++ sources/gui/guiview.h (.../guiview.h) (revision fbeafa0714f065bce0403e2e8ce68f6d8fbea6bd)
@@ -38,13 +38,20 @@
private slots:
void onActionReceive (GuiActionType vAction, const QVariantList &vData); // UI <= HD/DG
+ void doUSBDriveMount ();
+ void doUSBDriveRemove();
+
public slots: // is public since will be used in the UI and is in the same thread.
void doActionTransmit(GuiActionType vAction, const QVariantList &vData); // UI => HD/DG
void doActionTransmit(GuiActionType vAction, const QVariant &vData); // UI => HD/DG
+ void doUSBDriveUmount();
signals:
void didActionReceive (GuiActionType vAction, const QVariantList &vData); // UI <= HD/DG
void didActionTransmit(GuiActionType vAction, const QVariantList &vData); // UI => HD/DG
+ void didUSBDriveMount ();
+ void didUSBDriveUmount();
+ void didUSBDriveRemove();
};
}
Index: sources/gui/qml/components/MainMenu.qml
===================================================================
diff -u -r781e62c996e81897517fbdb1bc79fe3bbcf165c1 -rfbeafa0714f065bce0403e2e8ce68f6d8fbea6bd
--- sources/gui/qml/components/MainMenu.qml (.../MainMenu.qml) (revision 781e62c996e81897517fbdb1bc79fe3bbcf165c1)
+++ sources/gui/qml/components/MainMenu.qml (.../MainMenu.qml) (revision fbeafa0714f065bce0403e2e8ce68f6d8fbea6bd)
@@ -75,7 +75,7 @@
}
Rectangle { id : _highlightRect
- color: Colors.backgroundButton
+ color: Colors.backgroundButtonSelect
width: partitionWidth
x : partitionWidth
height: 10
Index: sources/gui/qml/components/TouchRect.qml
===================================================================
diff -u -rfee7fabf49befb065c89248c19e15efc9ca194e4 -rfbeafa0714f065bce0403e2e8ce68f6d8fbea6bd
--- sources/gui/qml/components/TouchRect.qml (.../TouchRect.qml) (revision fee7fabf49befb065c89248c19e15efc9ca194e4)
+++ sources/gui/qml/components/TouchRect.qml (.../TouchRect.qml) (revision fbeafa0714f065bce0403e2e8ce68f6d8fbea6bd)
@@ -25,15 +25,54 @@
* which is used a general default round rect button
*/
Rectangle { id : _root
- property alias text : _text
- property alias button : _mouseArea
+ property alias text : _text
+ property alias button : _mouseArea
- property bool animate : false
+ property bool animated : false
+ property alias loops : _clickAnimation.loops
+ property int duration : 200
+ property bool disabled : false
+
+ property color textColor : Colors.textButton
+ property color borderColor : Colors.borderButton
+ property color backgroungColor : Colors.backgroundButtonNormal
+
+ onDurationChanged: {
+ _colorAnimationOn .duration = duration;
+ _colorAnimationOff.duration = duration;
+ }
+
+ function animate(vAnimate) {
+ if (vAnimate) {
+ if ( disabled ) { return }
+ if ( animated ) {
+ _clickAnimation.restart()
+ }
+ } else {
+ _clickAnimation.stop()
+ _root.color = backgroungColor
+ }
+ }
+
+ onBackgroungColorChanged: {
+ _root.color = backgroungColor
+ }
+
+ onDisabledChanged: {
+ if (disabled) {
+ text.color = Colors.textDisableButton
+ border.color = Colors.borderDisableButton
+ } else {
+ text.color = textColor
+ border.color = borderColor
+ }
+ }
+
width : Variables.touchRectWidth
height : Variables.touchRectHeight
radius : Variables.touchRectRadius
- color : "Transparent"
+ color : backgroungColor
border {
color: Colors.borderButton
width: Variables.borderWidth
@@ -46,15 +85,20 @@
MouseArea { id: _mouseArea
anchors.fill: parent
onPressed: {
- if ( animate ) {
- _clickAnimation.running = true
- }
+ if ( disabled ) { return }
+ animate(true)
}
}
SequentialAnimation { id: _clickAnimation
running: false
- PropertyAnimation { target: _root; property: "color"; to: _root.border.color; duration: 50; }
- PropertyAnimation { target: _root; property: "color"; to: _root.color ; duration: 50; }
+ onStopped: {
+ _root.color = backgroungColor
+ }
+ onFinished: {
+ _root.color = backgroungColor
+ }
+ PropertyAnimation { id: _colorAnimationOn ; target: _root; property: "color"; to: _root.border.color; duration: duration; }
+ PropertyAnimation { id: _colorAnimationOff; target: _root; property: "color"; to: _root.color ; duration: duration; }
}
}
Index: sources/gui/qml/components/USBButton.qml
===================================================================
diff -u
--- sources/gui/qml/components/USBButton.qml (revision 0)
+++ sources/gui/qml/components/USBButton.qml (revision fbeafa0714f065bce0403e2e8ce68f6d8fbea6bd)
@@ -0,0 +1,51 @@
+/*!
+ *
+ * Copyright (c) 2019-2019 Diality Inc. - All Rights Reserved.
+ * \copyright \n
+ * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, \n
+ * IN PART OR IN WHOLE, \n
+ * WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. \n
+ *
+ * \file USBButton.qml
+ * \date 2019/12/23
+ * \author Behrouz NematiPour
+ *
+ */
+
+// Qt
+import QtQuick 2.12
+
+// Qml imports
+import "qrc:/globals"
+import "qrc:/components"
+
+TouchRect { id : _root
+ width: 50
+ height: width
+ x: width - 10
+ animated: true
+ loops: Animation.Infinite
+ duration: 1000 // 1 sec
+
+ anchors {
+ top : parent.top
+ topMargin : (Variables.headerHeight - Variables.logoHeight) / 2
+ rightMargin : (Variables.headerHeight - Variables.logoHeight) / 2
+ }
+ text.text: qsTr("USB")
+ text.font.pixelSize: Fonts.fontPixelButton * 0.75
+ button.onPressed: {
+ _GuiView.doUSBDriveUmount()
+ animate(true)
+ }
+
+ Connections { target: _GuiView
+ onDidUSBDriveRemove: {
+ _root.animate(false)
+ _root.disabled = true
+ }
+ onDidUSBDriveMount: {
+ _root.disabled = false
+ }
+ }
+}
Index: sources/gui/qml/globals/Colors.qml
===================================================================
diff -u -r781e62c996e81897517fbdb1bc79fe3bbcf165c1 -rfbeafa0714f065bce0403e2e8ce68f6d8fbea6bd
--- sources/gui/qml/globals/Colors.qml (.../Colors.qml) (revision 781e62c996e81897517fbdb1bc79fe3bbcf165c1)
+++ sources/gui/qml/globals/Colors.qml (.../Colors.qml) (revision fbeafa0714f065bce0403e2e8ce68f6d8fbea6bd)
@@ -22,22 +22,23 @@
* whcih is going to be used in the project
*/
QtObject {
- readonly property color backgroundMain : "#1A344D"
- readonly property color backgroundButton : "#438FEB"
- readonly property color backgroundDialog : "#254670"
- readonly property color backgroundMenu : "#14314C"
- readonly property color backgroundMainMenu : "#0D2639"
- readonly property color backgroundDottedMenu: "#64809D"
- readonly property color backgroundSlider : "#195187"
+ readonly property color backgroundMain : "#1A344D"
+ readonly property color backgroundButtonNormal : "Transparent"
+ readonly property color backgroundButtonSelect : "#438FEB"
+ readonly property color backgroundDialog : "#254670"
+ readonly property color backgroundMenu : "#14314C"
+ readonly property color backgroundMainMenu : "#0D2639"
+ readonly property color backgroundDottedMenu : "#64809D"
+ readonly property color backgroundSlider : "#195187"
- readonly property color textMain : "#FCFCFC"
- readonly property color textButton : "#E8E8E8"
- readonly property color textTickMark : "#438FEB"
- readonly property color textDisableButton : "#607A91"
+ readonly property color textMain : "#FCFCFC"
+ readonly property color textButton : "#E8E8E8"
+ readonly property color textDisableButton : "#607A91"
+ readonly property color textTickMark : "#438FEB"
- readonly property color borderButton : "#4290EC" //K:D //"#438FEB"
- readonly property color borderDisableButton : "#607A91"
- readonly property color boderSeparatorLine : "#476982"
- readonly property color borderDialog : "#F51A344D"
+ readonly property color borderButton : "#4290EC" //K:D //"#438FEB"
+ readonly property color borderDisableButton : "#607A91"
+ readonly property color boderSeparatorLine : "#476982"
+ readonly property color borderDialog : "#F51A344D"
}
Index: sources/gui/qml/pages/SettingsHome.qml
===================================================================
diff -u -rfee7fabf49befb065c89248c19e15efc9ca194e4 -rfbeafa0714f065bce0403e2e8ce68f6d8fbea6bd
--- sources/gui/qml/pages/SettingsHome.qml (.../SettingsHome.qml) (revision fee7fabf49befb065c89248c19e15efc9ca194e4)
+++ sources/gui/qml/pages/SettingsHome.qml (.../SettingsHome.qml) (revision fbeafa0714f065bce0403e2e8ce68f6d8fbea6bd)
@@ -31,7 +31,7 @@
TouchRect { id : _poweroff
width: 150
height: Variables.logoHeight
- animate: true
+ animated: true
anchors {
top : parent.top
right : parent.right
Index: sources/gui/qml/pages/TreatmentHome.qml
===================================================================
diff -u -r781e62c996e81897517fbdb1bc79fe3bbcf165c1 -rfbeafa0714f065bce0403e2e8ce68f6d8fbea6bd
--- sources/gui/qml/pages/TreatmentHome.qml (.../TreatmentHome.qml) (revision 781e62c996e81897517fbdb1bc79fe3bbcf165c1)
+++ sources/gui/qml/pages/TreatmentHome.qml (.../TreatmentHome.qml) (revision fbeafa0714f065bce0403e2e8ce68f6d8fbea6bd)
@@ -35,6 +35,8 @@
// exported properties
//
+ USBButton { }
+
TreatmentStart { id : _treatmentStart
onBackPressed: {
_treatmentStack.pop()
Index: sources/storage/filehandler.cpp
===================================================================
diff -u -r90d3f5b31186834168c9ad869f8d2d038200dfcf -rfbeafa0714f065bce0403e2e8ce68f6d8fbea6bd
--- sources/storage/filehandler.cpp (.../filehandler.cpp) (revision 90d3f5b31186834168c9ad869f8d2d038200dfcf)
+++ sources/storage/filehandler.cpp (.../filehandler.cpp) (revision fbeafa0714f065bce0403e2e8ce68f6d8fbea6bd)
@@ -13,66 +13,126 @@
*/
#include "filehandler.h"
+// Linux
#include
+#include
+//#include
+
//Qt
#include
#include
// Project
+#include "maintimer.h"
+// namespace
using namespace Storage;
-FileHandler::FileHandler(QObject *parent) : QObject(parent)
+
+// Singleton
+SINGLETON_INIT(FileHandler)
+
+FileHandler::FileHandler(QObject *parent) : QObject(parent) { }
+
+bool FileHandler::umounted() const
{
- connect(&fsWatcher, SIGNAL(directoryChanged(QString)),
- this , SLOT(directoryChanged(QString)));
+ return _umounted;
}
+void FileHandler::umounted(bool vUmounted)
+{
+ _umounted = vUmounted;
+}
+
bool FileHandler::init()
{
- fsWatcher.addPath("/dev/");
+ initConnections();
return true;
}
-void FileHandler::directoryChanged(const QString &vPath)
+void FileHandler::initConnections()
{
- Q_UNUSED(vPath)
- bool available = false;
+ connect(_MainTimer , SIGNAL( didTimeout()),
+ this , SLOT(onMainTimerTimeout()));
+}
+
+bool FileHandler::usbSeek(QString &vDevice) {
QString device = "";
- if ( ! _mounted ) {
- for (int a = 'a'; a <= 'z'; a++) {
- device = QString("/dev/sd%1%2").arg(QChar(a)).arg(QChar('1'));
- if (QFileInfo::exists(device)) {
- available = true;
- break;
- }
- umount(device.toLatin1().constData());
+ for (char a = 'a'; a <= 'z'; a++) {
+ device = QString("/dev/sd%1%2").arg(a).arg('1');
+ if (QFileInfo::exists(device)) {
+ vDevice = device;
+ return true; // application is deciding on the first existing drive
}
}
- if (available) {
- if ( ! _mounted ) {
- if ( mountUsb(device) ) {
- _mounted = true;
- } else {
- qDebug() << tr("1 - USB drive %1 can't be mounted").arg(_usbMount);
- }
+ vDevice = device;
+ return false;
+}
+
+void FileHandler::doUSBDriveMount()
+{
+ QString device = "";
+ if (usbSeek(device)) {
+ if (! umounted()) {
+ usbMount(device);
+ } else {
+ usbUmount(_usbMount); // release
+ qDebug() << tr("USB drive umounted");
}
} else {
- umount(_usbMount);
+ usbRemove();
+ }
+}
+
+void FileHandler::usbError(const QString &vDevice)
+{
+ switch (errno) {
+ case EBUSY:
+ qDebug() << tr("%1 - Device or resource busy (%2)").arg(errno).arg(vDevice);
+ break;
+ default:
+ qDebug() << tr("%1 - %2 (%3 , %4)").arg(errno).arg(strerror(errno)).arg(vDevice).arg(_usbMount);
+ break;
+ }
+}
+
+bool FileHandler::usbMount(const QString &vDevice)
+{
+ bool ok;
+ _usbDrive = vDevice.toLatin1().constData();
+ ok = mount(_usbDrive, _usbMount, _usbfsys, 0, "") == 0;
+ if (ok) {
_mounted = false;
- qDebug() << tr("2 - USB drive %1 can't be mounted").arg(_usbMount);
- return;
+ qDebug() << tr("USB flash drive %1 has been mounted on %2").arg(vDevice).arg(_usbMount);
+ emit didUSBDriveMount();
+ } else {
+ usbError(vDevice);
}
- emit usbStatusChanged(available);
+ return ok;
}
-bool FileHandler::mountUsb(QString device)
+bool FileHandler::usbUmount(const QString &vDevice)
{
- int result = mount(device.toLatin1().constData(), _usbMount, _usbfsys, 0, "");
- if (result == 0) {
- qDebug() << tr("USB flash drive %1 has been mounted to %2").arg(device).arg(_usbMount);
+ bool ok;
+ ok = umount(vDevice.toLatin1().constData()) == 0;
+ if (ok) {
+ emit didUSBDriveUmount();
} else {
- return false;
+ // the error is irrelevant, commented out for now
+ //usbError(vDevice);
}
- return true;
+ return ok;
}
+void FileHandler::usbRemove()
+{
+ usbUmount(_usbMount);
+ umounted(false);
+ emit didUSBDriveRemove();
+ qDebug() << tr("USB drive removed");
+}
+
+void FileHandler::onMainTimerTimeout()
+{
+ doUSBDriveMount();
+}
+
Index: sources/storage/filehandler.h
===================================================================
diff -u -r90d3f5b31186834168c9ad869f8d2d038200dfcf -rfbeafa0714f065bce0403e2e8ce68f6d8fbea6bd
--- sources/storage/filehandler.h (.../filehandler.h) (revision 90d3f5b31186834168c9ad869f8d2d038200dfcf)
+++ sources/storage/filehandler.h (.../filehandler.h) (revision fbeafa0714f065bce0403e2e8ce68f6d8fbea6bd)
@@ -16,8 +16,13 @@
// Qt
#include
#include
+
// Project
+#include "main.h"
+// Define
+#define _FileHandler FileHandler::I()
+
namespace Storage {
class FileHandler : public QObject
@@ -27,22 +32,41 @@
const char *_usbMount = "/media/usb/";
const char *_usbfsys = "vfat";
bool _mounted = false;
+ bool _umounted = false;
+ const char *_usbDrive = "";
- QFileSystemWatcher fsWatcher;
-
+ // Singleton
+ SINGLETON_DECL(FileHandler)
public:
- explicit FileHandler(QObject *parent = nullptr);
-
bool init();
+ void quit();
+
bool doExport();
bool doImport();
+ bool umounted( ) const;
+ void umounted(bool vUmounted);
+
+private:
+ void initConnections();
+
+ bool usbSeek(QString &vDevice);
+
signals:
- void usbStatusChanged(bool available);
+ void didUSBDriveMount ();
+ void didUSBDriveUmount();
+ void didUSBDriveRemove();
+public slots:
+ void doUSBDriveMount ();
+
private slots:
- void directoryChanged(const QString &vPath);
- bool mountUsb(QString device);
+ bool usbMount (const QString &vDevice);
+ bool usbUmount(const QString &vDevice);
+ void usbRemove();
+ void usbError (const QString &vDevice);
+
+ void onMainTimerTimeout();
};
}