Added FirstTimeSetup

Also fixed a bug in the repeater setup if we had not encountered a radio
yet.
creator-widgets
Elliott Liggett 2024-04-14 15:59:16 -07:00
rodzic 7cb3cbd59b
commit e9ebaef9e7
11 zmienionych plików z 473 dodań i 11 usunięć

107
firsttimesetup.cpp 100644
Wyświetl plik

@ -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);
}

50
firsttimesetup.h 100644
Wyświetl plik

@ -0,0 +1,50 @@
#ifndef FIRSTTIMESETUP_H
#define FIRSTTIMESETUP_H
// include <QWidget>
#include <QDialog>
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

260
firsttimesetup.ui 100644
Wyświetl plik

@ -0,0 +1,260 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>FirstTimeSetup</class>
<widget class="QWidget" name="FirstTimeSetup">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>518</width>
<height>421</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>24</pointsize>
</font>
</property>
<property name="text">
<string>Welcome to wfview!</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="step1GroupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>How is your radio connected?</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QRadioButton" name="serialPortThisPC">
<property name="text">
<string>Serial Port on this PC</string>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroup</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="USBPortThisPC">
<property name="text">
<string>USB Port on This PC</string>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroup</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="ethernetNetwork">
<property name="text">
<string>Ethernet Network</string>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroup</string>
</attribute>
</widget>
</item>
<item>
<widget class="QRadioButton" name="WiFiNetwork">
<property name="text">
<string>WiFi Network</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<attribute name="buttonGroup">
<string notr="true">buttonGroup</string>
</attribute>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="step2GroupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Next Steps:</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>You will now be taken to the Radio Access page under Settings.</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Please fill in the relevent details for this connection type:</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QLabel" name="neededDetailsLabel1">
<property name="text">
<string>1</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="neededDetailsLabel2">
<property name="text">
<string>2</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="neededDetailsLabel3">
<property name="text">
<string>3</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Note: If you do not have this information, press Exit Program, and return later.</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QLabel" name="label_5">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Even if you have run wfview before, please take a moment to review your settings.</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="exitProgramBtn">
<property name="toolTip">
<string>Press to exit the program.
You will see this dialog box the next time you open wfview.</string>
</property>
<property name="text">
<string>Exit Program</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="onMyOwnBtn">
<property name="toolTip">
<string>Press to skip the setup.</string>
</property>
<property name="text">
<string>Skip</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="backBtn">
<property name="toolTip">
<string>Press to go back to the prior step. </string>
</property>
<property name="text">
<string>Back</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="nextBtn">
<property name="toolTip">
<string>Press for the next step.</string>
</property>
<property name="text">
<string>Next</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
<buttongroups>
<buttongroup name="buttonGroup"/>
</buttongroups>
</ui>

Wyświetl plik

@ -155,6 +155,7 @@ struct preferences {
int majorVersion = 0;
int minorVersion = 0;
QString gitShort;
bool hasRunSetup = false;
bool settingsChanged = false;
// Interface:

Wyświetl plik

@ -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;
}

Wyświetl plik

@ -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);

Wyświetl plik

@ -302,7 +302,7 @@ private:
bool haveServerAudioOutputs = false;
bool haveClusterList = false;
bool updatingUIFromPrefs = false;
bool connectedStatus = false;
audioDevices* audioDev = Q_NULLPTR;
};

Wyświetl plik

@ -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

Wyświetl plik

@ -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)

Wyświetl plik

@ -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();

Wyświetl plik

@ -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 \