瀏覽代碼

GUI clear selection implemented

Cyamond 5 年之前
父節點
當前提交
e696d467d6
共有 3 個文件被更改,包括 28 次插入1 次删除
  1. 9 0
      gui/src/SendingForm.ui.qml
  2. 13 1
      gui/src/qmlhandler.cpp
  3. 6 0
      gui/src/qmlhandler.h

+ 9 - 0
gui/src/SendingForm.ui.qml

@@ -17,6 +17,9 @@ Page {
         onSendingEnableSendButton: {
             sendingSendFileButton.enabled = true
         }
+        onSendingDisableSendButton: {
+            sendingSendFileButton.enabled = false
+        }
     }
 
     Button {
@@ -26,7 +29,13 @@ Page {
         width: 260
         height: 90
         text: qsTr("Clear Selection")
+        enabled: sendingSendFileButton.enabled
         font.pointSize: 16
+        // @disable-check M223
+        onClicked: {
+            // @disable-check M222
+            _qmlHandler.onSendingClearSelectionButton()
+        }
     }
 
     Button {

+ 13 - 1
gui/src/qmlhandler.cpp

@@ -25,6 +25,8 @@ QUrl sendFileUrl = QUrl("");
 
 bool programActive = true;
 
+QMLHandler::QMLHandler(QObject *parent) : QObject(parent) {}
+
 void QMLHandler::onExit() {
   write(outpipefd[1], "disconnect\n", strlen("disconnect\n"));
 }
@@ -89,7 +91,10 @@ void QMLHandler::readPipeLoop() {
   }
 }
 
-QMLHandler::QMLHandler(QObject *parent) : QObject(parent) {}
+
+
+// ### QML Handlers ###
+
 
 // Sending
 void QMLHandler::onSendingSelectFileButton(QUrl url) {
@@ -105,6 +110,13 @@ void QMLHandler::onSendingSendFileButton() {
         strlen(command.toUtf8().constData()));
 }
 
+void QMLHandler::onSendingClearSelectionButton() {
+  sendFileUrl = QUrl("");
+  emit log("Cleared Selection");
+  emit sendingSetFileUrlText("Selected File: None");
+  emit sendingDisableSendButton();
+}
+
 // Receiving
 void QMLHandler::onReceivingGetFileButton(QString fileName) {
   QString command = "get " + fileName + "\n";

+ 6 - 0
gui/src/qmlhandler.h

@@ -18,10 +18,13 @@ public:
   explicit QMLHandler(QObject *parent = 0);
   void onExit();
 
+
+// C++ -> QML
 signals:
   // Sending
   void sendingSetFileUrlText(QString signalText);
   void sendingEnableSendButton();
+  void sendingDisableSendButton();
 
   // Receiving
 
@@ -39,10 +42,13 @@ signals:
   void log(QString logText);
   void footerSetStatus(QString status);
 
+
+// QML -> C++
 public slots:
   // Sending
   void onSendingSelectFileButton(QUrl url);
   void onSendingSendFileButton();
+  void onSendingClearSelectionButton();
 
   // Receiving
   void onReceivingGetFileButton(QString fileName);