mirror of https://github.com/tp4a/teleport
部分解决win下播放器中文乱码问题。
parent
6aa5c046df
commit
28909f376e
|
@ -1,21 +0,0 @@
|
||||||
#include "dlgmessage.h"
|
|
||||||
#include "ui_dlgmessage.h"
|
|
||||||
|
|
||||||
DlgMessage::DlgMessage(QWidget *parent) :
|
|
||||||
QDialog(parent),
|
|
||||||
ui(new Ui::DlgMessage)
|
|
||||||
{
|
|
||||||
ui->setupUi(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
DlgMessage::~DlgMessage()
|
|
||||||
{
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
void DlgMessage::set_text(const QString& text) {
|
|
||||||
// TODO: 根据文字长度,父窗口宽度,调节对话框宽度,最大不超过父窗口宽度的 2/3。
|
|
||||||
// 调节label的宽度和高度,并调节对话框高度,最后将对话框调整到父窗口居中的位置。
|
|
||||||
|
|
||||||
ui->label->setText(text);
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
#ifndef DLGMESSAGE_H
|
|
||||||
#define DLGMESSAGE_H
|
|
||||||
|
|
||||||
#include <QDialog>
|
|
||||||
|
|
||||||
namespace Ui {
|
|
||||||
class DlgMessage;
|
|
||||||
}
|
|
||||||
|
|
||||||
class DlgMessage : public QDialog
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit DlgMessage(QWidget *parent = nullptr);
|
|
||||||
~DlgMessage();
|
|
||||||
|
|
||||||
void set_text(const QString& text);
|
|
||||||
|
|
||||||
private:
|
|
||||||
Ui::DlgMessage *ui;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // DLGMESSAGE_H
|
|
|
@ -1,32 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>DlgMessage</class>
|
|
||||||
<widget class="QDialog" name="DlgMessage">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>400</width>
|
|
||||||
<height>120</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<widget class="QLabel" name="label">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>10</x>
|
|
||||||
<y>10</y>
|
|
||||||
<width>59</width>
|
|
||||||
<height>16</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</widget>
|
|
||||||
<resources/>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include <QCommandLineParser>
|
#include <QCommandLineParser>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QTextCodec>
|
||||||
|
|
||||||
// 编译出来的可执行程序复制到单独目录,然后执行 windeployqt 应用程序文件名
|
// 编译出来的可执行程序复制到单独目录,然后执行 windeployqt 应用程序文件名
|
||||||
// 即可自动将依赖的动态库等复制到此目录中。有些文件是多余的,可以酌情删除。
|
// 即可自动将依赖的动态库等复制到此目录中。有些文件是多余的,可以酌情删除。
|
||||||
|
@ -47,6 +48,11 @@ int main(int argc, char *argv[])
|
||||||
QString resource = args.at(0);
|
QString resource = args.at(0);
|
||||||
qDebug() << resource;
|
qDebug() << resource;
|
||||||
|
|
||||||
|
|
||||||
|
// QTextCodec::setCodecForTr(QTextCodec::codecForName("GB2312"));
|
||||||
|
// QTextCodec::setCodecForLocale(QTextCodec::codecForName("GBK"));
|
||||||
|
// QTextCodec::setCodecForCStrings(QTextCodec::codecForName("GB2312"));
|
||||||
|
|
||||||
MainWindow w;
|
MainWindow w;
|
||||||
w.set_resource(resource);
|
w.set_resource(resource);
|
||||||
w.show();
|
w.show();
|
||||||
|
|
|
@ -87,8 +87,6 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||||
m_thr_play = nullptr;
|
m_thr_play = nullptr;
|
||||||
m_play_state = PLAY_STATE_UNKNOWN;
|
m_play_state = PLAY_STATE_UNKNOWN;
|
||||||
|
|
||||||
m_msg_box = nullptr;
|
|
||||||
|
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
ui->centralWidget->setMouseTracking(true);
|
ui->centralWidget->setMouseTracking(true);
|
||||||
|
@ -135,10 +133,6 @@ MainWindow::~MainWindow()
|
||||||
m_thr_play = nullptr;
|
m_thr_play = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_msg_box) {
|
|
||||||
delete m_msg_box;
|
|
||||||
}
|
|
||||||
|
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,7 +184,7 @@ void MainWindow::paintEvent(QPaintEvent *e)
|
||||||
|
|
||||||
{
|
{
|
||||||
QRect rc_draw = e->rect();
|
QRect rc_draw = e->rect();
|
||||||
QRect rc(100, 100, m_img_message.width(), m_img_message.height());
|
QRect rc(m_rc_message);
|
||||||
//rc.moveTo(m_rc.left()+rc.left(), m_rc.top() + rc.top());
|
//rc.moveTo(m_rc.left()+rc.left(), m_rc.top() + rc.top());
|
||||||
|
|
||||||
int from_x = max(rc_draw.left(), rc.left()) - rc.left();
|
int from_x = max(rc_draw.left(), rc.left()) - rc.left();
|
||||||
|
@ -243,9 +237,6 @@ void MainWindow::_do_update_data(update_data* dat) {
|
||||||
UpdateDataHelper data_helper(dat);
|
UpdateDataHelper data_helper(dat);
|
||||||
|
|
||||||
if(dat->data_type() == TYPE_DATA) {
|
if(dat->data_type() == TYPE_DATA) {
|
||||||
if(m_msg_box) {
|
|
||||||
m_msg_box->hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(dat->data_len() <= sizeof(TS_RECORD_PKG)) {
|
if(dat->data_len() <= sizeof(TS_RECORD_PKG)) {
|
||||||
qDebug() << "invalid record package(1).";
|
qDebug() << "invalid record package(1).";
|
||||||
|
@ -303,20 +294,28 @@ void MainWindow::_do_update_data(update_data* dat) {
|
||||||
|
|
||||||
else if(dat->data_type() == TYPE_MESSAGE) {
|
else if(dat->data_type() == TYPE_MESSAGE) {
|
||||||
QPainter pp(&m_canvas);
|
QPainter pp(&m_canvas);
|
||||||
QFontMetrics fm = pp.fontMetrics();
|
|
||||||
QRect rcWin(0, 0, m_canvas.width(), m_canvas.height());
|
QRect rcWin(0, 0, m_canvas.width(), m_canvas.height());
|
||||||
QRect rc = fm.boundingRect(rcWin, Qt::AlignLeft|Qt::TextWordWrap, dat->message());
|
pp.drawText(rcWin, Qt::AlignLeft|Qt::TextDontPrint, dat->message(), &m_rc_message);
|
||||||
qDebug("message, w=%d, h=%d", rc.width(), rc.height());
|
|
||||||
// int w = fm.width(dat->message());
|
|
||||||
// int h = fm.height();
|
|
||||||
// qDebug("message, w=%d, h=%d", w, h);
|
|
||||||
|
|
||||||
m_img_message = QPixmap(rc.width() + 30, rc.height() + 30);
|
qDebug("message, w=%d, h=%d", m_rc_message.width(), m_rc_message.height());
|
||||||
|
m_rc_message.setWidth(m_rc_message.width()+60);
|
||||||
|
m_rc_message.setHeight(m_rc_message.height()+60);
|
||||||
|
|
||||||
|
m_img_message = QPixmap(m_rc_message.width(), m_rc_message.height());
|
||||||
m_img_message.fill(Qt::transparent);
|
m_img_message.fill(Qt::transparent);
|
||||||
QPainter pm(&m_img_message);
|
QPainter pm(&m_img_message);
|
||||||
pm.setPen(QColor(255,255,255,153));
|
pm.setPen(QColor(255,255,255,153));
|
||||||
pm.fillRect(rc, QColor(0,0,0,190));
|
pm.fillRect(m_rc_message, QColor(0,0,0,190));
|
||||||
pm.drawText(rc, Qt::AlignLeft|Qt::TextWordWrap, dat->message());
|
|
||||||
|
QRect rcText(m_rc_message);
|
||||||
|
rcText.setLeft(30);
|
||||||
|
rcText.setTop(30);
|
||||||
|
pm.drawText(rcText, Qt::AlignLeft, dat->message());
|
||||||
|
m_rc_message.moveTo(
|
||||||
|
(m_canvas.width() - m_rc_message.width())/2,
|
||||||
|
(m_canvas.height() - m_rc_message.height())/2
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
#include "thr_play.h"
|
#include "thr_play.h"
|
||||||
#include "update_data.h"
|
#include "update_data.h"
|
||||||
#include "record_format.h"
|
#include "record_format.h"
|
||||||
#include "dlgmessage.h"
|
|
||||||
|
|
||||||
#define PLAY_STATE_UNKNOWN 0
|
#define PLAY_STATE_UNKNOWN 0
|
||||||
#define PLAY_STATE_RUNNING 1
|
#define PLAY_STATE_RUNNING 1
|
||||||
|
@ -76,10 +75,8 @@ private:
|
||||||
|
|
||||||
int m_play_state;
|
int m_play_state;
|
||||||
|
|
||||||
//QMessageBox* m_msg_box;
|
|
||||||
DlgMessage* m_msg_box;
|
|
||||||
|
|
||||||
QPixmap m_img_message;
|
QPixmap m_img_message;
|
||||||
|
QRect m_rc_message;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
|
|
@ -10,6 +10,11 @@
|
||||||
<height>360</height>
|
<height>360</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<family>微软雅黑 Light</family>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Teleport Replayer</string>
|
<string>Teleport Replayer</string>
|
||||||
</property>
|
</property>
|
||||||
|
|
|
@ -75,6 +75,7 @@ void ThreadPlay::run() {
|
||||||
qDebug() << "DOWNLOAD";
|
qDebug() << "DOWNLOAD";
|
||||||
m_need_download = true;
|
m_need_download = true;
|
||||||
|
|
||||||
|
// "正在缓存录像数据,请稍候..."
|
||||||
_notify_message("正在缓存录像数据,请稍候...");
|
_notify_message("正在缓存录像数据,请稍候...");
|
||||||
|
|
||||||
m_thr_download = new ThreadDownload(m_res);
|
m_thr_download = new ThreadDownload(m_res);
|
||||||
|
@ -207,7 +208,9 @@ void ThreadPlay::run() {
|
||||||
tpd_filename.sprintf("%stp-rdp-%d.tpd", path_base.toStdString().c_str(), fidx+1);
|
tpd_filename.sprintf("%stp-rdp-%d.tpd", path_base.toStdString().c_str(), fidx+1);
|
||||||
|
|
||||||
// for test.
|
// for test.
|
||||||
msg.sprintf("无法打开录像数据文件!\n\n%s", tpd_filename.toStdString().c_str());
|
msg = QString::fromLocal8Bit("无法打开录像数据文件!\n\n");
|
||||||
|
//msg.sprintf("无法打开录像数据文件!\n\n%s", tpd_filename.toStdString().c_str());
|
||||||
|
msg += tpd_filename.toStdString().c_str();
|
||||||
_notify_message(msg);
|
_notify_message(msg);
|
||||||
|
|
||||||
QFile f_dat(tpd_filename);
|
QFile f_dat(tpd_filename);
|
||||||
|
|
|
@ -1,34 +1,31 @@
|
||||||
TEMPLATE = app
|
TEMPLATE = app
|
||||||
TARGET = tp-player
|
TARGET = tp-player
|
||||||
|
|
||||||
QT += core gui widgets
|
QT += core gui widgets
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
dlgmessage.h \
|
mainwindow.h \
|
||||||
mainwindow.h \
|
bar.h \
|
||||||
bar.h \
|
thr_download.h \
|
||||||
thr_download.h \
|
thr_play.h \
|
||||||
thr_play.h \
|
update_data.h \
|
||||||
update_data.h \
|
record_format.h \
|
||||||
record_format.h \
|
rle.h
|
||||||
rle.h
|
|
||||||
|
SOURCES += \
|
||||||
SOURCES += \
|
main.cpp \
|
||||||
dlgmessage.cpp \
|
mainwindow.cpp \
|
||||||
main.cpp \
|
bar.cpp \
|
||||||
mainwindow.cpp \
|
thr_download.cpp \
|
||||||
bar.cpp \
|
thr_play.cpp \
|
||||||
thr_download.cpp \
|
update_data.cpp \
|
||||||
thr_play.cpp \
|
rle.c
|
||||||
update_data.cpp \
|
|
||||||
rle.c
|
RESOURCES += \
|
||||||
|
tp-player.qrc
|
||||||
RESOURCES += \
|
|
||||||
tp-player.qrc
|
RC_FILE += \
|
||||||
|
tp-player.rc
|
||||||
RC_FILE += \
|
|
||||||
tp-player.rc
|
FORMS += \
|
||||||
|
mainwindow.ui
|
||||||
FORMS += \
|
|
||||||
dlgmessage.ui \
|
|
||||||
mainwindow.ui
|
|
||||||
|
|
Loading…
Reference in New Issue