some change.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "LogControl.h"
|
||||
#include "LogControl.h"
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QListWidgetItem>
|
||||
#include <QStandardItem>
|
||||
#include <iomanip>
|
||||
#include <sstream>
|
||||
@@ -15,8 +16,6 @@ LogPrint::LogPrint(QWidget* parent) : QWidget(parent), ui(new Ui::LogPrint)
|
||||
|
||||
void LogPrint::InitControl()
|
||||
{
|
||||
model_ = new QStandardItemModel(this);
|
||||
ui->listView->setModel(model_);
|
||||
}
|
||||
|
||||
std::string LogPrint::now_str()
|
||||
@@ -56,8 +55,8 @@ void LogPrint::Debug(const QString& message)
|
||||
void LogPrint::Print(const QString& message, const QBrush& color)
|
||||
{
|
||||
auto timeStr = QString("%1%2").arg(QString::fromStdString(now_str())).arg(message);
|
||||
auto* item = new QStandardItem(timeStr);
|
||||
QListWidgetItem* item = new QListWidgetItem(timeStr);
|
||||
item->setForeground(color);
|
||||
model_->appendRow(item);
|
||||
ui->listView->scrollToBottom();
|
||||
ui->listWidget->addItem(item);
|
||||
ui->listWidget->scrollToBottom();
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QListView" name="listView"/>
|
||||
<widget class="QListWidget" name="listWidget"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
||||
@@ -103,7 +103,7 @@ void TransForm::showEvent(QShowEvent* event)
|
||||
{
|
||||
QDialog::showEvent(event);
|
||||
workTh_ = new TranFromTh(this, this);
|
||||
//fileTrans_->moveToThread(workTh_);
|
||||
fileTrans_->moveToThread(workTh_);
|
||||
connect(workTh_, &QThread::finished, fileTrans_, &QObject::deleteLater);
|
||||
workTh_->start();
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "Control/LogControl.h"
|
||||
|
||||
static LogPrint* logPrint = nullptr;
|
||||
static QMutex logMut;
|
||||
|
||||
frelayGUI::frelayGUI(QWidget* parent) : QMainWindow(parent), ui(new Ui::frelayGUI)
|
||||
{
|
||||
@@ -27,7 +28,9 @@ frelayGUI::frelayGUI(QWidget* parent) : QMainWindow(parent), ui(new Ui::frelayGU
|
||||
|
||||
frelayGUI::~frelayGUI()
|
||||
{
|
||||
QMutexLocker locker(&logMut);
|
||||
delete ui;
|
||||
logPrint = nullptr;
|
||||
}
|
||||
|
||||
void frelayGUI::InitControl()
|
||||
@@ -89,6 +92,9 @@ void frelayGUI::ControlLayout()
|
||||
void frelayGUI::ControlMsgHander(QtMsgType type, const QMessageLogContext& context, const QString& msg)
|
||||
{
|
||||
Q_UNUSED(context);
|
||||
|
||||
QMutexLocker locker(&logMut);
|
||||
|
||||
if (!logPrint) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user