Only Sync Remote Logs when the Log Replica is ready

This commit is contained in:
Justin Hammond 2020-06-08 15:39:42 +08:00
parent cfba9838ed
commit 6eb844ab71
3 changed files with 12 additions and 5 deletions

View file

@ -12,12 +12,9 @@ LogWindow::LogWindow(QWidget *parent) :
ui->setupUi(this);
this->ui->logview->verticalHeader()->hide();
this->ui->logview->horizontalHeader()->setStretchLastSection(true);
// this->ui->logview->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
// this->ui->logview->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
this->m_log = OZWCore::get()->getQTOZWManager()->getLog();
connect(this->m_log, &QTOZWLog::newLogLine, this, &LogWindow::newMsg);
this->m_log->syncroniseLogs();
this->m_scrollTimer.setInterval(500);
connect(&this->m_scrollTimer, &QTimer::timeout, this, &LogWindow::scrollWindow);
@ -49,4 +46,13 @@ void LogWindow::scrollWindow()
void LogWindow::init() {
this->m_logModel = new QTOZWLogModel(this->m_log, this);
this->ui->logview->setModel(this->m_logModel);
connect(this->m_log, &QTOZWLog::readyChanged, this, &LogWindow::logsReady);
if (this->m_log->isReady())
this->logsReady(true);
}
void LogWindow::logsReady(bool ready) {
if (ready) {
this->m_log->syncroniseLogs();
}
}

View file

@ -20,6 +20,7 @@ public:
private slots:
void newMsg(QDateTime time, LogLevels::Level level, quint8 s_node, QString s_msg);
void scrollWindow();
void logsReady(bool ready);
private:
Ui::LogWindow *ui;
bool viewAtBottom = true;

View file

@ -247,8 +247,8 @@ void MainWindow::CloseConnection() {
if (OZWCore::get()->getQTOZWManager()->getConnectionType() == ConnectionType::Type::Local) {
OZWCore::get()->getQTOZWManager()->close();
} else if (OZWCore::get()->getQTOZWManager()->getConnectionType() == ConnectionType::Type::Remote) {
//QMessageBox::critical(this, "Close Connection", "TODO: Please restart the application for now");
//exit(1);
QMessageBox::critical(this, "Close Connection", "TODO: Please restart the application for now");
QCoreApplication::exit(0);
} else {
//QMessageBox::critical(this, "Unknown Connection Type", "Unknown Connection Type");
}