Skip to content

Commit

Permalink
Startup Progress for Remote Connections
Browse files Browse the repository at this point in the history
  • Loading branch information
Fishwaldo committed Feb 22, 2020
1 parent 4b02193 commit e91c64e
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 7 deletions.
9 changes: 7 additions & 2 deletions ozwadmin-main/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ void MainWindow::OpenConnection() {
server.setScheme("ws");
qCDebug(ozwadmin) << "Connecting to " << server;
startupprogress *sup = new startupprogress(true, this);
sup->setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint);
sup->setQTOZWManager(this->m_qtozwmanager);
sup->show();
this->m_qtozwmanager->setClientAuth(su.getauthKey());
Expand All @@ -363,8 +364,12 @@ void MainWindow::OpenConnection() {
this->settings.setValue("connection/startserver", su.getstartServer());
return;
}
}
qCDebug(ozwadmin) << "Open Dialog was Canceled" << ret;
} else {
qCDebug(ozwadmin) << "Open Dialog was Canceled" << ret;
this->ui->actionOpen->setEnabled(true);
this->ui->action_Close->setEnabled(false);

}

}
void MainWindow::CloseConnection() {
Expand Down
16 changes: 11 additions & 5 deletions ozwadmin-main/startupprogress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@


startupprogress::startupprogress(bool remote, QWidget *parent) :
m_remote(remote),
QDialog(parent),
ui(new Ui::startupprogress)
ui(new Ui::startupprogress),
m_remote(remote)
{
ui->setupUi(this);
ui->progressBar->setValue(0);
Expand All @@ -34,16 +34,22 @@ void startupprogress::setQTOZWManager(QTOZWManager *qtozw)
QObject::connect(this->m_qtozwmanager, &QTOZWManager::driverAwakeNodesQueried, this, &startupprogress::driverAwakeNodesQueried);
QObject::connect(this->m_qtozwmanager, &QTOZWManager::ozwNotification, this, &startupprogress::ozwNotification);
QObject::connect(this->m_qtozwmanager, &QTOZWManager::remoteConnectionStatus, this, &startupprogress::remoteConnectionStatus);
QObject::connect(this->ui->cancelbtn, &QPushButton::clicked, this, &startupprogress::clicked);
}

void startupprogress::clicked(bool checked) {
Q_UNUSED(checked);
emit this->cancel();
this->close();
}
void startupprogress::manufacturerSpecificDBReady() {
ui->progressBar->setValue(ui->progressBar->value() + 5);
ui->label->setText("Manufacturer Specific Database Ready");
}

void startupprogress::ready() {
ui->progressBar->setValue(ui->progressBar->value() + 5);
ui->label->setText("OpenZWave Ready");
this->close();
}

void startupprogress::starting() {
Expand Down Expand Up @@ -99,11 +105,11 @@ void startupprogress::remoteConnectionStatus(QTOZWManager::connectionStatus stat
QMetaEnum metaEnum = QMetaEnum::fromType<QTOZWManager::connectionStatus>();
ui->label->setText(metaEnum.valueToKey(status));
if ((status >= QTOZWManager::connectionStatus::GotManagerData) && (status <= QTOZWManager::connectionStatus::GotLogData)) {
ui->progressBar->setValue(ui->progressBar->value()+5);
ui->progressBar->setValue(ui->progressBar->value()+16);
qCDebug(ozwadmin) << ui->progressBar->value();
}
} else {
QMetaEnum metaEnum = QMetaEnum::fromType<QAbstractSocket::SocketError>();
ui->label->setText(QString("Error: ").append(metaEnum.valueToKey(error)));

}
}
5 changes: 5 additions & 0 deletions ozwadmin-main/startupprogress.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ class startupprogress : public QDialog
~startupprogress();
void setQTOZWManager(QTOZWManager *);

Q_SIGNALS:
void cancel();

public Q_SLOTS:
void manufacturerSpecificDBReady();
void ready();
Expand All @@ -33,6 +36,8 @@ public Q_SLOTS:
void driverAwakeNodesQueried();
void ozwNotification(quint8 node, NotificationTypes::QTOZW_Notification_Code event);
void remoteConnectionStatus(QTOZWManager::connectionStatus status, QAbstractSocket::SocketError error);
private Q_SLOTS:
void clicked(bool checked);

private:
Ui::startupprogress *ui;
Expand Down
18 changes: 18 additions & 0 deletions ozwadmin-main/startupprogress.ui
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
<property name="windowModality">
<enum>Qt::ApplicationModal</enum>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>119</width>
<height>64</height>
</rect>
</property>
<property name="windowTitle">
<string>Progress</string>
</property>
Expand All @@ -14,6 +22,9 @@
<property name="text">
<string>TextLabel</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
Expand All @@ -23,6 +34,13 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cancelbtn">
<property name="text">
<string>&amp;Cancel</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
Expand Down

0 comments on commit e91c64e

Please sign in to comment.