diff --git a/firsttimesetup.cpp b/firsttimesetup.cpp new file mode 100644 index 0000000..9273931 --- /dev/null +++ b/firsttimesetup.cpp @@ -0,0 +1,107 @@ +#include "firsttimesetup.h" +#include "ui_firsttimesetup.h" + +FirstTimeSetup::FirstTimeSetup(QWidget *parent) : + QDialog(parent), + ui(new Ui::FirstTimeSetup) +{ + ui->setupUi(this); + + setWindowFlags(Qt::Dialog + | Qt::FramelessWindowHint); + + this->setupState = setupInitial; + ui->step2GroupBox->setHidden(true); + ui->backBtn->setHidden(true); + + serialText1 = QString("Serial Port Name"); + serialText2 = QString("Baud Rate"); + serialText3 = QString(""); + + networkText1 = QString("Radio IP address, UDP Port Numbers"); + networkText2 = QString("Radio Username, Radio Password"); + networkText2 = QString("Mic and Speaker on THIS PC"); +} + +FirstTimeSetup::~FirstTimeSetup() +{ + delete ui; +} + +void FirstTimeSetup::on_exitProgramBtn_clicked() +{ + emit exitProgram(); + this->close(); +} + + +void FirstTimeSetup::on_nextBtn_clicked() +{ + switch (setupState) { + case setupInitial: + // go to step 2: + ui->nextBtn->setText("Finish"); + ui->step1GroupBox->setHidden(true); + ui->step2GroupBox->setHidden(false); + if(isNetwork) { + ui->neededDetailsLabel1->setText(networkText1); + ui->neededDetailsLabel2->setText(networkText2); + ui->neededDetailsLabel3->setText(networkText3); + } else { + ui->neededDetailsLabel1->setText(serialText1); + ui->neededDetailsLabel2->setText(serialText2); + ui->neededDetailsLabel3->setText(serialText3); + } + ui->backBtn->setHidden(false); + setupState = setupStep2; + break; + case setupStep2: + // Done + emit showSettings(isNetwork); + this->close(); + break; + default: + break; + } +} + +void FirstTimeSetup::on_onMyOwnBtn_clicked() +{ + emit skipSetup(); + this->close(); +} + + +void FirstTimeSetup::on_ethernetNetwork_clicked(bool checked) +{ + this->isNetwork = checked; +} + + +void FirstTimeSetup::on_WiFiNetwork_clicked(bool checked) +{ + this->isNetwork = checked; +} + + +void FirstTimeSetup::on_USBPortThisPC_clicked(bool checked) +{ + this->isNetwork = !checked; +} + + +void FirstTimeSetup::on_serialPortThisPC_clicked(bool checked) +{ + this->isNetwork = !checked; +} + + +void FirstTimeSetup::on_backBtn_clicked() +{ + setupState = setupInitial; + ui->nextBtn->setText("Next"); + ui->step1GroupBox->setHidden(false); + ui->step2GroupBox->setHidden(true); + ui->backBtn->setHidden(true); +} + diff --git a/firsttimesetup.h b/firsttimesetup.h new file mode 100644 index 0000000..b1c16ac --- /dev/null +++ b/firsttimesetup.h @@ -0,0 +1,50 @@ +#ifndef FIRSTTIMESETUP_H +#define FIRSTTIMESETUP_H + +// include +#include + +namespace Ui { +class FirstTimeSetup; +} + +class FirstTimeSetup : public QDialog +{ + Q_OBJECT + +public: + explicit FirstTimeSetup(QWidget *parent = nullptr); + ~FirstTimeSetup(); + +private: + Ui::FirstTimeSetup *ui; + + enum setupState_t { + setupInitial, + setupStep2 + } setupState; + bool isNetwork = true; + QString serialText1; + QString serialText2; + QString serialText3; + + QString networkText1; + QString networkText2; + QString networkText3; + +signals: + void exitProgram(); + void showSettings(bool isNetwork); + void skipSetup(); +private slots: + void on_exitProgramBtn_clicked(); + void on_nextBtn_clicked(); + void on_onMyOwnBtn_clicked(); + void on_ethernetNetwork_clicked(bool checked); + void on_WiFiNetwork_clicked(bool checked); + void on_USBPortThisPC_clicked(bool checked); + void on_serialPortThisPC_clicked(bool checked); + void on_backBtn_clicked(); +}; + +#endif // FIRSTTIMESETUP_H diff --git a/firsttimesetup.ui b/firsttimesetup.ui new file mode 100644 index 0000000..0092142 --- /dev/null +++ b/firsttimesetup.ui @@ -0,0 +1,260 @@ + + + FirstTimeSetup + + + + 0 + 0 + 518 + 421 + + + + + 0 + 0 + + + + Form + + + + + + + 0 + 0 + + + + + 24 + + + + Welcome to wfview! + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + How is your radio connected? + + + + + + Serial Port on this PC + + + buttonGroup + + + + + + + USB Port on This PC + + + buttonGroup + + + + + + + Ethernet Network + + + buttonGroup + + + + + + + WiFi Network + + + true + + + buttonGroup + + + + + + + + + + + 0 + 0 + + + + Next Steps: + + + + + + You will now be taken to the Radio Access page under Settings. + + + + + + + Please fill in the relevent details for this connection type: + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + + 1 + + + + + + + 2 + + + + + + + 3 + + + + + + + + + + + Note: If you do not have this information, press Exit Program, and return later. + + + + + + + + + + + 0 + 0 + + + + Even if you have run wfview before, please take a moment to review your settings. + + + + + + + + + Press to exit the program. +You will see this dialog box the next time you open wfview. + + + Exit Program + + + + + + + Press to skip the setup. + + + Skip + + + + + + + Press to go back to the prior step. + + + Back + + + + + + + Press for the next step. + + + Next + + + + + + + + + + + + + diff --git a/prefs.h b/prefs.h index dbf4b4d..dac3544 100644 --- a/prefs.h +++ b/prefs.h @@ -155,6 +155,7 @@ struct preferences { int majorVersion = 0; int minorVersion = 0; QString gitShort; + bool hasRunSetup = false; bool settingsChanged = false; // Interface: diff --git a/repeatersetup.cpp b/repeatersetup.cpp index a50ddad..c912a62 100644 --- a/repeatersetup.cpp +++ b/repeatersetup.cpp @@ -373,11 +373,12 @@ void repeaterSetup::handleTransmitStatus(bool amTransmitting) void repeaterSetup::showEvent(QShowEvent *event) { - - queue->add(priorityImmediate,funcSplitStatus,false,false); - if(rigCaps->commands.contains(funcToneSquelchType)) - queue->add(priorityImmediate,funcReadFreqOffset,false,false); - QMainWindow::showEvent(event); + if(haveRig) { + queue->add(priorityImmediate,funcSplitStatus,false,false); + if(rigCaps->commands.contains(funcToneSquelchType)) + queue->add(priorityImmediate,funcReadFreqOffset,false,false); + QMainWindow::showEvent(event); + } (void)event; } diff --git a/settingswidget.cpp b/settingswidget.cpp index c152864..2286d1c 100644 --- a/settingswidget.cpp +++ b/settingswidget.cpp @@ -818,6 +818,10 @@ void settingswidget::updateLanPref(prefLanItem plan) case l_enableLAN: quietlyUpdateRadiobutton(ui->lanEnableBtn, prefs->enableLAN); quietlyUpdateRadiobutton(ui->serialEnableBtn, !prefs->enableLAN); + if(!connectedStatus) { + ui->groupNetwork->setEnabled(prefs->enableLAN); + ui->groupSerial->setEnabled(!prefs->enableLAN); + } break; case l_enableRigCtlD: quietlyUpdateCheckbox(ui->enableRigctldChk, prefs->enableRigCtlD); @@ -2701,6 +2705,7 @@ void settingswidget::onServerUserFieldChanged() // This is a slot that receives a signal from wfmain when we are connecting/disconnected void settingswidget::connectionStatus(bool conn) { + connectedStatus = conn; ui->groupConnection->setEnabled(!conn); ui->audioInputCombo->setEnabled(!conn); ui->audioOutputCombo->setEnabled(!conn); diff --git a/settingswidget.h b/settingswidget.h index c256794..3e20578 100644 --- a/settingswidget.h +++ b/settingswidget.h @@ -302,7 +302,7 @@ private: bool haveServerAudioOutputs = false; bool haveClusterList = false; bool updatingUIFromPrefs = false; - + bool connectedStatus = false; audioDevices* audioDev = Q_NULLPTR; }; diff --git a/tciserver.cpp b/tciserver.cpp index ac3fbd3..6b0c310 100644 --- a/tciserver.cpp +++ b/tciserver.cpp @@ -91,7 +91,7 @@ static const tciCommandStruct tci_commands[] = { "digl_offset", funcNone, typeUChar, typeBinary, typeNone}, { "digu_offset", funcNone, typeUChar, typeBinary, typeNone}, { "rx_smeter", funcSMeter, typeUChar, typeUChar, typedB}, - { "", funcNone, typeNone, typeNone, typeNone }, + { 0x0, funcNone, typeNone, typeNone, typeNone }, }; #define MAXNAMESIZE 32 diff --git a/wfmain.cpp b/wfmain.cpp index cd9f021..3fff177 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -243,8 +243,38 @@ wfmain::wfmain(const QString settingsFile, const QString logFile, bool debugMode qDebug(logSystem()) << "Running setInititalTiming()"; setInitialTiming(); - qDebug(logSystem()) << "Running openRig()"; - openRig(); + fts = new FirstTimeSetup(); + + if(prefs.hasRunSetup) { + qDebug(logSystem()) << "Running openRig()"; + openRig(); + } else { + qInfo(logSystem()) << "Detected first-time run. Showing the First Time Setup widget."; + + connect(fts, &FirstTimeSetup::exitProgram, [=]() { + qInfo(logSystem()) << "User elected exit program."; + prefs.settingsChanged = false; + prefs.confirmExit = false; + QTimer::singleShot(10, [&](){ + on_exitBtn_clicked(); + }); + }); + connect(fts, &FirstTimeSetup::showSettings, [=](const bool networkEnabled) { + qInfo(logSystem()) << "User elected to visit the Settings UI."; + prefs.enableLAN = networkEnabled; + setupui->updateLanPrefs((int)l_all); + showAndRaiseWidget(setupui); + prefs.settingsChanged = true; + prefs.hasRunSetup = true; + }); + connect(fts, &FirstTimeSetup::skipSetup, [=]() { + qInfo(logSystem()) << "User elected to skip the setup. Marking setup complete."; + prefs.settingsChanged = true; + prefs.hasRunSetup = true; + }); + + fts->exec(); + } cluster = new dxClusterClient(); @@ -329,9 +359,9 @@ wfmain::wfmain(const QString settingsFile, const QString logFile, bool debugMode qInfo(logUsbControl()) << "Cannot register udev_monitor, hotplug of USB devices is not available"; return; } - int fd = udev_monitor_get_fd(uDevMonitor); + int fd = udev_monitor_get_fd(uDevMonitor); uDevNotifier = new QSocketNotifier(fd, QSocketNotifier::Read,this); - connect(uDevNotifier, SIGNAL(activated(int)), this, SLOT(uDevEvent())); + connect(uDevNotifier, SIGNAL(activated(int)), this, SLOT(uDevEvent())); udev_monitor_enable_receiving(uDevMonitor); #endif #endif @@ -1496,6 +1526,7 @@ void wfmain::changeFrequency(int value) { void wfmain::setDefPrefs() { + defPrefs.hasRunSetup = false; defPrefs.useFullScreen = false; defPrefs.useSystemTheme = false; defPrefs.drawPeaks = true; @@ -1574,6 +1605,7 @@ void wfmain::loadSettings() prefs.version = priorVersionString; prefs.majorVersion = settings->value("majorVersion", defPrefs.majorVersion).toInt(); prefs.minorVersion = settings->value("minorVersion", defPrefs.minorVersion).toInt(); + prefs.hasRunSetup = settings->value("hasRunSetup", defPrefs.hasRunSetup).toBool(); settings->endGroup(); // UI: (full screen, dark theme, draw peaks, colors, etc) @@ -2747,6 +2779,7 @@ void wfmain::saveSettings() settings->setValue("majorVersion", int(majorVersion.toInt())); settings->setValue("minorVersion", int(minorVersion.toInt())); settings->setValue("gitShort", QString(GITSHORT)); + settings->setValue("hasRunSetup", prefs.hasRunSetup); settings->endGroup(); // UI: (full screen, dark theme, draw peaks, colors, etc) diff --git a/wfmain.h b/wfmain.h index 2d52fa5..97deeb9 100644 --- a/wfmain.h +++ b/wfmain.h @@ -30,6 +30,7 @@ #include "rigidentities.h" #include "repeaterattributes.h" #include "memories.h" +#include "firsttimesetup.h" #include "packettypes.h" #include "calibrationwindow.h" @@ -532,6 +533,7 @@ private: void showButton(QPushButton *btn); void hideButton(QPushButton *btn); + FirstTimeSetup *fts = Q_NULLPTR; void openRig(); void powerRigOff(); void powerRigOn(); diff --git a/wfview.pro b/wfview.pro index 224fc96..0899dbc 100644 --- a/wfview.pro +++ b/wfview.pro @@ -249,6 +249,7 @@ SOURCES += main.cpp\ bandbuttons.cpp \ cachingqueue.cpp \ cwsender.cpp \ + firsttimesetup.cpp \ freqctrl.cpp \ frequencyinputwidget.cpp \ cwsidetone.cpp \ @@ -301,6 +302,7 @@ HEADERS += wfmain.h \ colorprefs.h \ commhandler.h \ cwsender.h \ + firsttimesetup.h \ freqctrl.h \ frequencyinputwidget.h \ cwsidetone.h \ @@ -359,6 +361,7 @@ FORMS += wfmain.ui \ bandbuttons.ui \ calibrationwindow.ui \ cwsender.ui \ + firsttimesetup.ui \ frequencyinputwidget.ui \ debugwindow.ui \ loggingwindow.ui \