2
0
forked from Ivasoft/DSView

fix: can't load unicode file path on window

This commit is contained in:
dreamsourcelabTAI
2022-06-23 19:02:34 +08:00
parent ea94e901dd
commit f8e1aa1844
3 changed files with 42 additions and 21 deletions

View File

@@ -440,20 +440,19 @@ void MainWindow::update_device_list()
//load specified file name from application startup param
if (_bFirstLoad){
_bFirstLoad = false;
if (AppControl::Instance()->_open_file_name != ""){
QString opf(QString::fromUtf8(AppControl::Instance()->_open_file_name.c_str()));
QFile fpath;
QString ldFileName(AppControl::Instance()->_open_file_name.c_str());
if (fpath.exists(opf)){
qDebug()<<"auto load file:"<<opf;
on_load_file(opf);
if (ldFileName != ""){
if (QFile::exists(ldFileName)){
qDebug()<<"auto load file:"<<ldFileName;
on_load_file(ldFileName);
}
else{
qDebug()<<"file is not exists:"<<opf;
MsgBox::Show(tr("Open file error!"), opf.toStdString().c_str());
qDebug()<<"file is not exists:"<<ldFileName;
MsgBox::Show(tr("Open file error!"), ldFileName, NULL);
}
}
}
}
}

View File

@@ -21,21 +21,10 @@
#include "path.h"
#ifdef _WIN32
#include <QTextCodec>
#endif
namespace pv::path
{
std::string ConvertPath(QString fileName)
{
#ifdef _WIN32
QTextCodec *code = QTextCodec::codecForName("GB2312");
if (code != NULL)
{
return code->fromUnicode(fileName).data();
}
#endif
return fileName.toUtf8().toStdString();
}