Browse Source

Disable illegal menu options when there are no sockets.

master
Andrius Štikonas 1 year ago
parent
commit
3ba16bef75
1 changed files with 15 additions and 9 deletions
  1. 15
    9
      consolereader.cpp

+ 15
- 9
consolereader.cpp View File

@@ -134,15 +134,21 @@ void ConsoleReader::listSockets()
134 134
     }
135 135
     std::cout << "a - add unpaired socket (WiFi needed)\n";
136 136
     std::cout << "A - add unpaired socket (no WiFi needed)\n";
137
-    std::cout << "d - update table data\n";
138
-    std::cout << "D - resend discovery packet to the current socket\n";
139
-    std::cout << "n - change socket name (max 16 characters)\n";
140
-    std::cout << "o - set switch off timer\n";
141
-    std::cout << "O - enable/disable switch off timer\n";
142
-    std::cout << "p - toggle power state (there are also \"on\" and \"off\" commands)\n";
143
-    std::cout << "P - change remote password (max 12 characters)\nq - quit\ns - select another socket (default is 1)\n";
144
-    std::cout << "t - change timezone" << std::endl;
145
-    std::cout << "Enter command: " << std::endl;
137
+    if (sockets->size() > 0) {
138
+        std::cout << "d - update table data\n";
139
+        std::cout << "D - resend discovery packet to the current socket\n";
140
+        std::cout << "n - change socket name (max 16 characters)\n";
141
+        std::cout << "o - set switch off timer\n";
142
+        std::cout << "O - enable/disable switch off timer\n";
143
+        std::cout << "p - toggle power state (there are also \"on\" and \"off\" commands)\n";
144
+        std::cout << "P - change remote password (max 12 characters)\n";
145
+    }
146
+    std::cout << "q - quit\n";
147
+    if (sockets->size() > 0) {
148
+        std::cout << "s - select another socket (default is 1)\n";
149
+        std::cout << "t - change timezone" << std::endl;
150
+    }
151
+        std::cout << "Enter command: " << std::endl;
146 152
 }
147 153
 
148 154
 void ConsoleReader::connectSignals()

Loading…
Cancel
Save