mirror of
https://github.com/Fishwaldo/ozw-admin.git
synced 2025-03-15 19:31:38 +00:00
Fix up Node Values/System/Config for Remote Connections and only run QTOZWManager methods if OZW is setup. Additionally, delay creation of Windows till we are connected to avoid outdated models being passed to the Windows
This commit is contained in:
parent
77f911a83d
commit
638437b271
7 changed files with 104 additions and 85 deletions
|
@ -48,29 +48,22 @@
|
|||
|
||||
MainWindow::MainWindow(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::MainWindow)
|
||||
ui(new Ui::MainWindow),
|
||||
m_WindowsSetup(false)
|
||||
{
|
||||
|
||||
this->ui->setupUi(this);
|
||||
this->statusBar()->showMessage(tr("Starting..."));
|
||||
this->connected(false);
|
||||
|
||||
connect(OZWCore::get(), &OZWCore::raiseCriticalError, this, &MainWindow::openCriticalDialog, Qt::DirectConnection);
|
||||
OZWCore::get()->initilize();
|
||||
|
||||
this->sbMsg = new statusBarMessages(this);
|
||||
connect(this->sbMsg, &statusBarMessages::newMessage, this, &MainWindow::setStatusBarMsg);
|
||||
|
||||
|
||||
this->ui->setupUi(this);
|
||||
this->m_DockManager = new ads::CDockManager(this);
|
||||
this->m_controllerCommands = new ControllerCommands(this);
|
||||
this->connected(false);
|
||||
|
||||
DeviceInfo *di = new DeviceInfo(this);
|
||||
NodeStatus *ni = new NodeStatus(this);
|
||||
EventWindow *ew = new EventWindow(this);
|
||||
LogWindow *lw = new LogWindow(this);
|
||||
connect(this->sbMsg, &statusBarMessages::newMessage, ew, &EventWindow::newEvent);
|
||||
|
||||
|
||||
statusBar()->showMessage(tr("Starting..."));
|
||||
this->ui->action_Close->setEnabled(false);
|
||||
|
||||
connect(ui->actionOpen, SIGNAL(triggered()), this, SLOT(OpenConnection()));
|
||||
connect(ui->action_Close, SIGNAL(triggered()), this, SLOT(CloseConnection()));
|
||||
|
@ -80,76 +73,15 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
connect(ui->action_AddNode, SIGNAL(triggered()), this, SLOT(addNode()));
|
||||
connect(ui->action_Delete_Node, SIGNAL(triggered()), this, SLOT(delNode()));
|
||||
connect(ui->action_Heal_Network, SIGNAL(triggered()), this, SLOT(healNetwork()));
|
||||
|
||||
|
||||
connect(di, &DeviceInfo::openMetaDataWindow, this, &MainWindow::openMetaDataWindow);
|
||||
|
||||
connect(this->sbMsg, &statusBarMessages::newMessage, this, &MainWindow::setStatusBarMsg);
|
||||
connect(OZWCore::get()->getQTOZWManager(), &QTOZWManager::remoteConnectionStatus, this, &MainWindow::remoteConnectionStatus);
|
||||
|
||||
this->ntw = new nodeTableWidget(this);
|
||||
connect(this->ntw, &nodeTableWidget::currentRowChanged, this, &MainWindow::NodeSelected);
|
||||
connect(this->ntw, &nodeTableWidget::currentRowChanged, di, &DeviceInfo::NodeSelected);
|
||||
connect(this->ntw, &nodeTableWidget::currentRowChanged, ni, &NodeStatus::NodeSelected);
|
||||
connect(OZWCore::get()->getQTOZWManager(), &QTOZWManager::ready, this, &MainWindow::QTOZW_Ready);
|
||||
|
||||
|
||||
ads::CDockWidget* NodeListDW = new ads::CDockWidget("Node List");
|
||||
NodeListDW->setWidget(this->ntw);
|
||||
this->m_DockManager->addDockWidget(ads::LeftDockWidgetArea, NodeListDW);
|
||||
|
||||
ads::CDockWidget* DeviceInfoDW = new ads::CDockWidget("Node Info");
|
||||
DeviceInfoDW->setWidget(di);
|
||||
auto RightDockWidget = this->m_DockManager->addDockWidget(ads::RightDockWidgetArea, DeviceInfoDW);
|
||||
|
||||
ads::CDockWidget* DeviceStatusDW = new ads::CDockWidget("Node Status");
|
||||
DeviceStatusDW->setWidget(ni);
|
||||
this->m_DockManager->addDockWidget(ads::CenterDockWidgetArea, DeviceStatusDW, RightDockWidget);
|
||||
|
||||
ValueTable *userValues = new ValueTable(QTOZW_ValueIds::ValueIdGenres::User, this);
|
||||
ads::CDockWidget* userValueDW = new ads::CDockWidget("User Values");
|
||||
userValueDW->setWidget(userValues);
|
||||
this->m_DockManager->addDockWidget(ads::CenterDockWidgetArea, userValueDW, RightDockWidget);
|
||||
|
||||
ValueTable *systemValues = new ValueTable(QTOZW_ValueIds::ValueIdGenres::System, this);
|
||||
ads::CDockWidget *systemValueDW = new ads::CDockWidget("System Values");
|
||||
systemValueDW->setWidget(systemValues);
|
||||
this->m_DockManager->addDockWidget(ads::CenterDockWidgetArea, systemValueDW, RightDockWidget);
|
||||
|
||||
ValueTable *configValues = new ValueTable(QTOZW_ValueIds::ValueIdGenres::Config, this);
|
||||
ads::CDockWidget *configValueDW = new ads::CDockWidget("Config Values");
|
||||
configValueDW->setWidget(configValues);
|
||||
this->m_DockManager->addDockWidget(ads::CenterDockWidgetArea, configValueDW, RightDockWidget);
|
||||
|
||||
RightDockWidget->setCurrentDockWidget(DeviceInfoDW);
|
||||
|
||||
ads::CDockWidget *eventViewDW = new ads::CDockWidget("Event List");
|
||||
eventViewDW->setWidget(ew);
|
||||
auto BottomDockWidget = this->m_DockManager->addDockWidget(ads::BottomDockWidgetArea, eventViewDW);
|
||||
|
||||
ads::CDockWidget *logWindowDW = new ads::CDockWidget("OZW Logs");
|
||||
logWindowDW->setWidget(lw);
|
||||
this->m_DockManager->addDockWidget(ads::CenterDockWidgetArea, logWindowDW, BottomDockWidget);
|
||||
BottomDockWidget->setCurrentDockWidget(eventViewDW);
|
||||
|
||||
|
||||
QObject::connect(OZWCore::get()->getQTOZWManager(), &QTOZWManager::ready, this, &MainWindow::QTOZW_Ready);
|
||||
|
||||
OZWCore::get()->getQTOZWManager()->initilizeSource(OZWCore::get()->settings.value("StartServer").toBool());
|
||||
|
||||
userValues->setModel(OZWCore::get()->getQTOZWManager()->getValueModel(), this->ntw->selectionModel());
|
||||
systemValues->setModel(OZWCore::get()->getQTOZWManager()->getValueModel(), this->ntw->selectionModel());
|
||||
configValues->setModel(OZWCore::get()->getQTOZWManager()->getValueModel(), this->ntw->selectionModel());
|
||||
lw->setModel(OZWCore::get()->getQTOZWManager()->getLogModel());
|
||||
|
||||
di->setQTOZWManager(OZWCore::get()->getQTOZWManager());
|
||||
ni->setQTOZWManager(OZWCore::get()->getQTOZWManager());
|
||||
|
||||
SplashDialog *sw = new SplashDialog(OZWCore::get()->getQTOZW(), this);
|
||||
SplashDialog *sw = new SplashDialog(this);
|
||||
sw->show();
|
||||
sw->move(this->geometry().center() - sw->rect().center());
|
||||
|
||||
QTimer::singleShot(5000, sw, SLOT(close()));
|
||||
|
||||
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
|
@ -180,7 +112,74 @@ void MainWindow::QTOZW_Ready() {
|
|||
}
|
||||
OZWCore::get()->settings.endGroup();
|
||||
|
||||
openDefaultWindows();
|
||||
|
||||
|
||||
}
|
||||
void MainWindow::openDefaultWindows() {
|
||||
|
||||
this->ntw = new nodeTableWidget(this);
|
||||
DeviceInfo *di = new DeviceInfo(this);
|
||||
NodeStatus *ni = new NodeStatus(this);
|
||||
EventWindow *ew = new EventWindow(this);
|
||||
LogWindow *lw = new LogWindow(this);
|
||||
ValueTable *userValues = new ValueTable(QTOZW_ValueIds::ValueIdGenres::User, this);
|
||||
ValueTable *systemValues = new ValueTable(QTOZW_ValueIds::ValueIdGenres::System, this);
|
||||
ValueTable *configValues = new ValueTable(QTOZW_ValueIds::ValueIdGenres::Config, this);
|
||||
|
||||
|
||||
connect(this->ntw, &nodeTableWidget::currentRowChanged, this, &MainWindow::NodeSelected);
|
||||
connect(this->ntw, &nodeTableWidget::currentRowChanged, di, &DeviceInfo::NodeSelected);
|
||||
connect(this->ntw, &nodeTableWidget::currentRowChanged, ni, &NodeStatus::NodeSelected);
|
||||
connect(this->sbMsg, &statusBarMessages::newMessage, ew, &EventWindow::newEvent);
|
||||
connect(di, &DeviceInfo::openMetaDataWindow, this, &MainWindow::openMetaDataWindow);
|
||||
|
||||
/* Create Dock Widgets/Panels */
|
||||
ads::CDockWidget* NodeListDW = new ads::CDockWidget("Node List");
|
||||
NodeListDW->setWidget(this->ntw);
|
||||
this->m_DockManager->addDockWidget(ads::LeftDockWidgetArea, NodeListDW);
|
||||
|
||||
ads::CDockWidget* DeviceInfoDW = new ads::CDockWidget("Node Info");
|
||||
DeviceInfoDW->setWidget(di);
|
||||
auto RightDockWidget = this->m_DockManager->addDockWidget(ads::RightDockWidgetArea, DeviceInfoDW);
|
||||
|
||||
ads::CDockWidget* DeviceStatusDW = new ads::CDockWidget("Node Status");
|
||||
DeviceStatusDW->setWidget(ni);
|
||||
this->m_DockManager->addDockWidget(ads::CenterDockWidgetArea, DeviceStatusDW, RightDockWidget);
|
||||
|
||||
ads::CDockWidget* userValueDW = new ads::CDockWidget("User Values");
|
||||
userValueDW->setWidget(userValues);
|
||||
this->m_DockManager->addDockWidget(ads::CenterDockWidgetArea, userValueDW, RightDockWidget);
|
||||
|
||||
ads::CDockWidget *systemValueDW = new ads::CDockWidget("System Values");
|
||||
systemValueDW->setWidget(systemValues);
|
||||
this->m_DockManager->addDockWidget(ads::CenterDockWidgetArea, systemValueDW, RightDockWidget);
|
||||
|
||||
ads::CDockWidget *configValueDW = new ads::CDockWidget("Config Values");
|
||||
configValueDW->setWidget(configValues);
|
||||
this->m_DockManager->addDockWidget(ads::CenterDockWidgetArea, configValueDW, RightDockWidget);
|
||||
|
||||
ads::CDockWidget *eventViewDW = new ads::CDockWidget("Event List");
|
||||
eventViewDW->setWidget(ew);
|
||||
auto BottomDockWidget = this->m_DockManager->addDockWidget(ads::BottomDockWidgetArea, eventViewDW);
|
||||
|
||||
ads::CDockWidget *logWindowDW = new ads::CDockWidget("OZW Logs");
|
||||
logWindowDW->setWidget(lw);
|
||||
this->m_DockManager->addDockWidget(ads::CenterDockWidgetArea, logWindowDW, BottomDockWidget);
|
||||
|
||||
/* set Active Tabs */
|
||||
RightDockWidget->setCurrentDockWidget(DeviceInfoDW);
|
||||
BottomDockWidget->setCurrentDockWidget(eventViewDW);
|
||||
|
||||
this->ntw->setModel(OZWCore::get()->getQTOZWManager()->getNodeModel());
|
||||
userValues->setModel(OZWCore::get()->getQTOZWManager()->getValueModel(), this->ntw->selectionModel());
|
||||
systemValues->setModel(OZWCore::get()->getQTOZWManager()->getValueModel(), this->ntw->selectionModel());
|
||||
configValues->setModel(OZWCore::get()->getQTOZWManager()->getValueModel(), this->ntw->selectionModel());
|
||||
lw->setModel(OZWCore::get()->getQTOZWManager()->getLogModel());
|
||||
|
||||
di->setQTOZWManager(OZWCore::get()->getQTOZWManager());
|
||||
ni->setQTOZWManager(OZWCore::get()->getQTOZWManager());
|
||||
this->m_WindowsSetup = true;
|
||||
}
|
||||
|
||||
void MainWindow::OpenConnection() {
|
||||
|
@ -215,6 +214,7 @@ void MainWindow::OpenConnection() {
|
|||
startupprogress *sup = new startupprogress(false, this);
|
||||
sup->setQTOZWManager(OZWCore::get()->getQTOZWManager());
|
||||
sup->show();
|
||||
OZWCore::get()->getQTOZWManager()->initilizeSource(OZWCore::get()->settings.value("StartServer").toBool());
|
||||
OZWCore::get()->getQTOZWManager()->open(su.getserialPort());
|
||||
OZWCore::get()->settings.setValue("connection/serialport", su.getserialPort());
|
||||
OZWCore::get()->settings.setValue("connection/startserver", su.getstartServer());
|
||||
|
@ -282,7 +282,7 @@ void MainWindow::openConfigWindow() {
|
|||
}
|
||||
|
||||
void MainWindow::openAboutWindow() {
|
||||
SplashDialog *sw = new SplashDialog(OZWCore::get()->getQTOZW(), this);
|
||||
SplashDialog *sw = new SplashDialog(this);
|
||||
sw->show();
|
||||
sw->move(this->geometry().center() - sw->rect().center());
|
||||
}
|
||||
|
|
|
@ -61,12 +61,14 @@ public slots:
|
|||
|
||||
private:
|
||||
void connected(bool);
|
||||
void openDefaultWindows();
|
||||
ControllerCommands *m_controllerCommands;
|
||||
|
||||
Ui::MainWindow *ui;
|
||||
statusBarMessages *sbMsg;
|
||||
nodeTableWidget *ntw;
|
||||
ads::CDockManager* m_DockManager;
|
||||
bool m_WindowsSetup;
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
|
|
|
@ -2,8 +2,9 @@
|
|||
#include <qt-openzwave/qtozwmanager.h>
|
||||
#include "splashdialog.h"
|
||||
#include "ui_splashdialog.h"
|
||||
#include "ozwcore.h"
|
||||
|
||||
SplashDialog::SplashDialog(QTOpenZwave *qtozw, QWidget *parent) :
|
||||
SplashDialog::SplashDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::SplashDialog)
|
||||
{
|
||||
|
@ -23,7 +24,12 @@ SplashDialog::SplashDialog(QTOpenZwave *qtozw, QWidget *parent) :
|
|||
"<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p></body></html>");
|
||||
|
||||
|
||||
ui->InfoText->setText(info.arg(qtozw->GetManager()->getVersionAsString()).arg(qtozw->getVersion()).arg(qVersion()));
|
||||
if (OZWCore::get()->getQTOZWManager()->isReady()) {
|
||||
ui->InfoText->setText(info.arg(OZWCore::get()->getQTOZWManager()->getVersionAsString()).arg(OZWCore::get()->getQTOZW()->getVersion()).arg(qVersion()));
|
||||
} else {
|
||||
/* GetManager() will only be valid after either connecting to a local or remote port */
|
||||
ui->InfoText->setText(info.arg("Unknown").arg(OZWCore::get()->getQTOZW()->getVersion()).arg(qVersion()));
|
||||
}
|
||||
setWindowFlags(Qt::SplashScreen|Qt::WindowStaysOnTopHint);
|
||||
QString ozwadminversion("Version %1");
|
||||
this->ui->OZWAdminVersionLbl->setText(ozwadminversion.arg(QCoreApplication::applicationVersion()));
|
||||
|
|
|
@ -13,7 +13,7 @@ class SplashDialog : public QDialog
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SplashDialog(QTOpenZwave *qtozw, QWidget *parent = nullptr);
|
||||
explicit SplashDialog(QWidget *parent = nullptr);
|
||||
~SplashDialog();
|
||||
|
||||
private:
|
||||
|
|
|
@ -137,8 +137,16 @@ void statusBarMessages::stopped(quint32 homeID) {
|
|||
void statusBarMessages::remoteConnectionStatus(QTOZWManager::connectionStatus status, QAbstractSocket::SocketError error) {
|
||||
QMetaEnum statusEnum = QMetaEnum::fromType<QTOZWManager::connectionStatus>();
|
||||
QMetaEnum socketEnum = QMetaEnum::fromType<QAbstractSocket::SocketError>();
|
||||
QString message(QString("Remote Connection Status: %1 (Socket State: %2)").arg(statusEnum.valueToKey(status)).arg(socketEnum.valueToKey(error)));
|
||||
emit newMessage(message);
|
||||
if (error != QAbstractSocket::SocketError::UnknownSocketError) {
|
||||
QString message(QString("Remote Connection Status: %1 (Socket State: %2)").arg(statusEnum.valueToKey(status)).arg(socketEnum.valueToKey(error)));
|
||||
emit newMessage(message);
|
||||
}
|
||||
else
|
||||
{
|
||||
QString message(QString("Remote Connection Status: %1").arg(statusEnum.valueToKey(status)));
|
||||
emit newMessage(message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
QString statusBarMessages::vidKeyDetails(quint64 key) {
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
|
||||
#include "valuetable.h"
|
||||
#include "value_delegate.h"
|
||||
#include "ozwcore.h"
|
||||
#include "util.h"
|
||||
|
||||
ValueTable::ValueTable(QTOZW_ValueIds::ValueIdGenres genre, QWidget *parent) :
|
||||
QTableView(parent)
|
||||
|
@ -21,7 +23,7 @@ ValueTable::ValueTable(QTOZW_ValueIds::ValueIdGenres genre, QWidget *parent) :
|
|||
this->setSelectionMode(QAbstractItemView::SingleSelection);
|
||||
this->setSortingEnabled(true);
|
||||
this->horizontalHeader()->setSectionsMovable(true);
|
||||
// this->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||
this->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||
// this->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||
this->resizeColumnsToContents();
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ public:
|
|||
ValueTable(QTOZW_ValueIds::ValueIdGenres genre, QWidget *parent = nullptr);
|
||||
|
||||
void setModel(QAbstractItemModel *model, QItemSelectionModel *selectionModel);
|
||||
public slots:
|
||||
|
||||
private:
|
||||
QTOZW_proxyValueModel *m_proxyModel;
|
||||
|
|
Loading…
Add table
Reference in a new issue