forked from Ivasoft/DSView
fix: can't load unicode file path on window
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user