forked from Ivasoft/DSView
Merge branch 'master' of https://github.com/DreamSourceLab/DSView
This commit is contained in:
@@ -299,16 +299,6 @@ std::string AppConfig::GetProtocolFormat(const std::string &protocolName)
|
||||
}
|
||||
|
||||
//-------------api
|
||||
QString GetDirectoryName(QString path)
|
||||
{
|
||||
int lstdex = path.lastIndexOf('/');
|
||||
if (lstdex != -1)
|
||||
{
|
||||
return path.left(lstdex);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
QString GetIconPath()
|
||||
{
|
||||
QString style = AppConfig::Instance()._frameOptions.style;
|
||||
|
||||
@@ -35,8 +35,6 @@
|
||||
#define APP_NAME "DSView"
|
||||
|
||||
//--------------------api---
|
||||
|
||||
QString GetDirectoryName(QString path);
|
||||
QString GetIconPath();
|
||||
QString GetAppDataDir();
|
||||
QString GetResourceDir();
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include "../config/appconfig.h"
|
||||
#include "../dsvdef.h"
|
||||
#include "../utility/encoding.h"
|
||||
#include "../utility/path.h"
|
||||
|
||||
using namespace boost;
|
||||
using namespace std;
|
||||
@@ -140,7 +141,7 @@ void ProtocolExp::accept()
|
||||
if(f.suffix().compare(ext))
|
||||
file_name+=tr(".")+ext;
|
||||
|
||||
QString fname = GetDirectoryName(file_name);
|
||||
QString fname = path::GetDirectoryName(file_name);
|
||||
if (fname != app._userHistory.openDir)
|
||||
{
|
||||
app._userHistory.protocolExportPath = fname;
|
||||
|
||||
@@ -94,6 +94,7 @@
|
||||
#include "dsvdef.h"
|
||||
#include "appcontrol.h"
|
||||
#include "utility/encoding.h"
|
||||
#include "utility/path.h"
|
||||
|
||||
#define BASE_SESSION_VERSION 2
|
||||
|
||||
@@ -439,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -920,7 +920,7 @@ void MainWindow::on_screenShot()
|
||||
|
||||
pixmap.save(fileName, suffix.toLatin1());
|
||||
|
||||
fileName = GetDirectoryName(fileName);
|
||||
fileName = path::GetDirectoryName(fileName);
|
||||
|
||||
if (app._userHistory.screenShotPath != fileName){
|
||||
app._userHistory.screenShotPath = fileName;
|
||||
|
||||
@@ -1189,7 +1189,7 @@ QString StoreSession::MakeSaveFile(bool bDlg)
|
||||
return ""; //no select file
|
||||
}
|
||||
|
||||
QString _dir_path = GetDirectoryName(default_name);
|
||||
QString _dir_path = path::GetDirectoryName(default_name);
|
||||
|
||||
if (_dir_path != app._userHistory.saveDir)
|
||||
{
|
||||
@@ -1261,7 +1261,7 @@ QString StoreSession::MakeExportFile(bool bDlg)
|
||||
}
|
||||
|
||||
bool bChange = false;
|
||||
QString _dir_path = GetDirectoryName(default_name);
|
||||
QString _dir_path = path::GetDirectoryName(default_name);
|
||||
if (_dir_path != app._userHistory.exportDir)
|
||||
{
|
||||
app._userHistory.exportDir = _dir_path;
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "../device/devinst.h"
|
||||
#include "../ui/msgbox.h"
|
||||
#include "../config/appconfig.h"
|
||||
#include "../utility/path.h"
|
||||
|
||||
namespace pv {
|
||||
namespace toolbars {
|
||||
@@ -143,7 +144,7 @@ void FileBar::on_actionOpen_triggered()
|
||||
tr("DSView Data (*.dsl)"));
|
||||
|
||||
if (!file_name.isEmpty()) {
|
||||
QString fname = GetDirectoryName(file_name);
|
||||
QString fname = path::GetDirectoryName(file_name);
|
||||
if (fname != app._userHistory.openDir){
|
||||
app._userHistory.openDir = fname;
|
||||
app.SaveHistory();
|
||||
@@ -180,7 +181,7 @@ void FileBar::on_actionLoad_triggered()
|
||||
tr("DSView Session (*.dsc)"));
|
||||
|
||||
if (!file_name.isEmpty()) {
|
||||
QString fname = GetDirectoryName(file_name);
|
||||
QString fname = path::GetDirectoryName(file_name);
|
||||
if (fname != app._userHistory.sessionDir){
|
||||
app._userHistory.sessionDir = fname;
|
||||
app.SaveHistory();
|
||||
@@ -229,7 +230,7 @@ void FileBar::on_actionStore_triggered()
|
||||
if(f.suffix().compare("dsc"))
|
||||
file_name.append(tr(".dsc"));
|
||||
|
||||
QString fname = GetDirectoryName(file_name);
|
||||
QString fname = path::GetDirectoryName(file_name);
|
||||
if (fname != app._userHistory.sessionDir){
|
||||
app._userHistory.sessionDir = fname;
|
||||
app.SaveHistory();
|
||||
|
||||
@@ -21,21 +21,20 @@
|
||||
|
||||
#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();
|
||||
}
|
||||
|
||||
QString GetDirectoryName(QString path)
|
||||
{
|
||||
int lstdex = path.lastIndexOf('/');
|
||||
if (lstdex != -1)
|
||||
{
|
||||
return path.left(lstdex);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,8 @@
|
||||
namespace pv::path
|
||||
{
|
||||
std::string ConvertPath(QString fileName);
|
||||
|
||||
QString GetDirectoryName(QString path);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -28,6 +28,10 @@
|
||||
|
||||
#include "ioapi.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode)
|
||||
{
|
||||
if (pfilefunc->zfile_func64.zopen64_file != NULL)
|
||||
@@ -112,6 +116,34 @@ static voidpf ZCALLBACK fopen_file_func (voidpf opaque, const char* filename, in
|
||||
|
||||
static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* filename, int mode)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
FILE* file = NULL;
|
||||
const wchar_t* mode_fopen = NULL;
|
||||
if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
|
||||
mode_fopen = L"rb";
|
||||
else
|
||||
if (mode & ZLIB_FILEFUNC_MODE_EXISTING)
|
||||
mode_fopen = L"r+b";
|
||||
else
|
||||
if (mode & ZLIB_FILEFUNC_MODE_CREATE)
|
||||
mode_fopen = L"wb";
|
||||
|
||||
int wcSize = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, filename, -1, NULL, 0);
|
||||
if (wcSize == 0) {
|
||||
return NULL;
|
||||
}
|
||||
wchar_t *wcName = (wchar_t *)malloc(sizeof(wchar_t) * wcSize + 8);
|
||||
if (wcName == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, filename, -1, wcName, wcSize);
|
||||
|
||||
if ((filename!=NULL) && (mode_fopen != NULL))
|
||||
file = _wfopen((const wchar_t*)wcName, mode_fopen);
|
||||
free(wcName);
|
||||
|
||||
return file;
|
||||
#else
|
||||
FILE* file = NULL;
|
||||
const char* mode_fopen = NULL;
|
||||
if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ)
|
||||
@@ -126,6 +158,7 @@ static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* filename,
|
||||
if ((filename!=NULL) && (mode_fopen != NULL))
|
||||
file = FOPEN_FUNC((const char*)filename, mode_fopen);
|
||||
return file;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user