HGGitLab

Commit 403c2bed authored by luoliangyi's avatar luoliangyi

将HGUIGlobal中的字符串函数独立出来

parent d31a1c09
#include "app_cfg.h" #include "app_cfg.h"
#include "base/HGDef.h" #include "base/HGDef.h"
#include "base/HGInc.h" #include "base/HGInc.h"
#include "base/HGUtility.h" #include "base/HGUtility.h"
#include "HGUIGlobal.h" #include "HGUIGlobal.h"
#include "../../utility/HGString.h"
QString getCfgValue(const char *appName, const char *key, const QString &def) QString getCfgValue(const char *appName, const char *key, const QString &def)
{ {
......
#ifndef __APP_CFG_H__ #ifndef __APP_CFG_H__
#define __APP_CFG_H__ #define __APP_CFG_H__
#include <QString> #include <QString>
......
/* /*
Copyright (c) 2009 Dave Gamble Copyright (c) 2009 Dave Gamble
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
......
/* /*
Copyright (c) 2009 Dave Gamble Copyright (c) 2009 Dave Gamble
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
......
#include "config.h" #include "config.h"
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include <stdio.h> #include <stdio.h>
......
#pragma once #pragma once
#include <vector> #include <vector>
#include <string> #include <string>
#include <qsettings.h> #include <qsettings.h>
......
#ifndef DEVICE_MENU_H #ifndef DEVICE_MENU_H
#define DEVICE_MENU_H #define DEVICE_MENU_H
#include <QMenu> #include <QMenu>
......
#include "dialog_admin.h" #include "dialog_admin.h"
#include "ui_dialog_admin.h" #include "ui_dialog_admin.h"
#include <QMessageBox> #include <QMessageBox>
......
#ifndef DIALOG_ADMIN_H #ifndef DIALOG_ADMIN_H
#define DIALOG_ADMIN_H #define DIALOG_ADMIN_H
#include <QDialog> #include <QDialog>
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "base/HGInc.h" #include "base/HGInc.h"
#include "base/HGUtility.h" #include "base/HGUtility.h"
#include "HGUIGlobal.h" #include "HGUIGlobal.h"
#include "../../utility/HGString.h"
#include "app_cfg.h" #include "app_cfg.h"
Dialog_AquireInto::Dialog_AquireInto(QWidget* parent) : Dialog_AquireInto::Dialog_AquireInto(QWidget* parent) :
......
#ifndef DIALOG_AQUIREINTO_H #ifndef DIALOG_AQUIREINTO_H
#define DIALOG_AQUIREINTO_H #define DIALOG_AQUIREINTO_H
#include <QDialog> #include <QDialog>
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <QKeyEvent> #include <QKeyEvent>
#include "base/HGUtility.h" #include "base/HGUtility.h"
#include "HGUIGlobal.h" #include "HGUIGlobal.h"
#include "../../utility/HGString.h"
Dialog_ClrCache::Dialog_ClrCache(QWidget *parent) : Dialog_ClrCache::Dialog_ClrCache(QWidget *parent) :
QDialog(parent), QDialog(parent),
......
#ifndef DIALOG_CLRCACHE_H #ifndef DIALOG_CLRCACHE_H
#define DIALOG_CLRCACHE_H #define DIALOG_CLRCACHE_H
#include <QDialog> #include <QDialog>
......
#ifndef DIALOG_EXPORT_H #ifndef DIALOG_EXPORT_H
#define DIALOG_EXPORT_H #define DIALOG_EXPORT_H
#include <QDialog> #include <QDialog>
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#include "ui_dialog_exportimagefile.h" #include "ui_dialog_exportimagefile.h"
#include "imgfmt/HGImgFmt.h" #include "imgfmt/HGImgFmt.h"
#include "HGUIGlobal.h" #include "HGUIGlobal.h"
#include "../../utility/HGString.h"
Dialog_ExportImageFile::Dialog_ExportImageFile(const QString &destPath, const QString &destName, const QString &destExt, Dialog_ExportImageFile::Dialog_ExportImageFile(const QString &destPath, const QString &destName, const QString &destExt,
bool isSaveAsMulti, int saveQuality, const QStringList &srcFiles, QWidget *parent) bool isSaveAsMulti, int saveQuality, const QStringList &srcFiles, QWidget *parent)
......
#ifndef DIALOG_EXPORTIMAGEFILE_H #ifndef DIALOG_EXPORTIMAGEFILE_H
#define DIALOG_EXPORTIMAGEFILE_H #define DIALOG_EXPORTIMAGEFILE_H
#include <QDialog> #include <QDialog>
......
#ifndef DIALOG_FULLSCREEN_H #ifndef DIALOG_FULLSCREEN_H
#define DIALOG_FULLSCREEN_H #define DIALOG_FULLSCREEN_H
#include <QDialog> #include <QDialog>
......
#ifndef DIALOG_IMAGEEDITOR_H #ifndef DIALOG_IMAGEEDITOR_H
#define DIALOG_IMAGEEDITOR_H #define DIALOG_IMAGEEDITOR_H
#include <QDialog> #include <QDialog>
......
#ifndef DIALOG_IMAGEINFO_H #ifndef DIALOG_IMAGEINFO_H
#define DIALOG_IMAGEINFO_H #define DIALOG_IMAGEINFO_H
#include <QDialog> #include <QDialog>
......
#ifndef DIALOG_IMGPROC_ADJUST_H #ifndef DIALOG_IMGPROC_ADJUST_H
#define DIALOG_IMGPROC_ADJUST_H #define DIALOG_IMGPROC_ADJUST_H
#include <QDialog> #include <QDialog>
......
#ifndef DIALOG_IMGPROC_AUTOCROP_H #ifndef DIALOG_IMGPROC_AUTOCROP_H
#define DIALOG_IMGPROC_AUTOCROP_H #define DIALOG_IMGPROC_AUTOCROP_H
#include <QDialog> #include <QDialog>
......
#ifndef DIALOG_INSERTINDEX_H #ifndef DIALOG_INSERTINDEX_H
#define DIALOG_INSERTINDEX_H #define DIALOG_INSERTINDEX_H
#include <QDialog> #include <QDialog>
......
#ifndef DIALOG_SCANNERLOG_H #ifndef DIALOG_SCANNERLOG_H
#define DIALOG_SCANNERLOG_H #define DIALOG_SCANNERLOG_H
#include <QDialog> #include <QDialog>
......
#ifndef DIALOG_LOGMANAGER_H #ifndef DIALOG_LOGMANAGER_H
#define DIALOG_LOGMANAGER_H #define DIALOG_LOGMANAGER_H
#include <QDialog> #include <QDialog>
......
#ifndef DIALOG_MOVETO_H #ifndef DIALOG_MOVETO_H
#define DIALOG_MOVETO_H #define DIALOG_MOVETO_H
#include <QDialog> #include <QDialog>
......
#ifndef DIALOG_MULTIROTATE_H #ifndef DIALOG_MULTIROTATE_H
#define DIALOG_MULTIROTATE_H #define DIALOG_MULTIROTATE_H
#include <QDialog> #include <QDialog>
......
#ifndef DIALOG_MULTIROTATEIMAGEFILE_H #ifndef DIALOG_MULTIROTATEIMAGEFILE_H
#define DIALOG_MULTIROTATEIMAGEFILE_H #define DIALOG_MULTIROTATEIMAGEFILE_H
#include <QDialog> #include <QDialog>
......
#ifndef DIALOG_OPENIMAGEINDEX_H #ifndef DIALOG_OPENIMAGEINDEX_H
#define DIALOG_OPENIMAGEINDEX_H #define DIALOG_OPENIMAGEINDEX_H
#include <QDialog> #include <QDialog>
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "imgproc/HGImgProc.h" #include "imgproc/HGImgProc.h"
#include "base/HGUtility.h" #include "base/HGUtility.h"
#include "HGUIGlobal.h" #include "HGUIGlobal.h"
#include "../../utility/HGString.h"
#include "app_cfg.h" #include "app_cfg.h"
#define PASSWORD_KEY 4 #define PASSWORD_KEY 4
...@@ -738,11 +739,11 @@ void MainWindow::on_new_image(void *img) ...@@ -738,11 +739,11 @@ void MainWindow::on_new_image(void *img)
HGUInt dpi = 96; HGUInt dpi = 96;
SANE_Int num_dev_options = 0; SANE_Int num_dev_options = 0;
sane_control_option(cur_dev_.handle(), 0, SANE_ACTION_GET_VALUE, &num_dev_options, NULL); sane_control_option(cur_dev_.handle(), 0, SANE_ACTION_GET_VALUE, &num_dev_options, nullptr);
for (int i = 1; i < num_dev_options; ++i) for (int i = 1; i < num_dev_options; ++i)
{ {
const SANE_Option_Descriptor* desp = sane_get_option_descriptor(cur_dev_.handle(), i); const SANE_Option_Descriptor* desp = sane_get_option_descriptor(cur_dev_.handle(), i);
if (NULL == desp) if (nullptr == desp)
continue; continue;
std::string title = Utf8ToStdString(desp->title); std::string title = Utf8ToStdString(desp->title);
...@@ -752,7 +753,7 @@ void MainWindow::on_new_image(void *img) ...@@ -752,7 +753,7 @@ void MainWindow::on_new_image(void *img)
if (SANE_TYPE_INT == desp->type) if (SANE_TYPE_INT == desp->type)
{ {
SANE_Int value = 0; SANE_Int value = 0;
sane_control_option(cur_dev_.handle(), i, SANE_ACTION_GET_VALUE, &value, NULL); sane_control_option(cur_dev_.handle(), i, SANE_ACTION_GET_VALUE, &value, nullptr);
HGBase_WriteInfo(HGBASE_INFOTYPE_DESC, " valueType=INT, value=%d", value); HGBase_WriteInfo(HGBASE_INFOTYPE_DESC, " valueType=INT, value=%d", value);
if (0 == strcmp(title.c_str(), "分辨率")) if (0 == strcmp(title.c_str(), "分辨率"))
......
...@@ -79,7 +79,8 @@ SOURCES += \ ...@@ -79,7 +79,8 @@ SOURCES += \
../../../app/scanner/cJSON.c \ ../../../app/scanner/cJSON.c \
../../../ui/HGImgThumb.cpp \ ../../../ui/HGImgThumb.cpp \
../../../ui/HGImgView.cpp \ ../../../ui/HGImgView.cpp \
../../../ui/HGUIGlobal.cpp ../../../ui/HGUIGlobal.cpp \
../../../utility/HGString.cpp
HEADERS += \ HEADERS += \
../../../app/scanner/app_cfg.h \ ../../../app/scanner/app_cfg.h \
...@@ -115,7 +116,8 @@ HEADERS += \ ...@@ -115,7 +116,8 @@ HEADERS += \
../../../app/scanner/cJSON.h \ ../../../app/scanner/cJSON.h \
../../../ui/HGImgThumb.h \ ../../../ui/HGImgThumb.h \
../../../ui/HGImgView.h \ ../../../ui/HGImgView.h \
../../../ui/HGUIGlobal.h ../../../ui/HGUIGlobal.h \
../../../utility/HGString.h
FORMS += \ FORMS += \
../../../app/scanner/dialog_admin.ui \ ../../../app/scanner/dialog_admin.ui \
......
...@@ -18,57 +18,3 @@ std::string getStdString(const QString &str) ...@@ -18,57 +18,3 @@ std::string getStdString(const QString &str)
return str.toStdString(); return str.toStdString();
#endif #endif
} }
#if defined(HG_CMP_MSC)
static std::string AnsiToUtf8(const char* text)
{
int wlen = ::MultiByteToWideChar(CP_ACP, 0, text, -1, NULL, 0);
WCHAR* pUnicode = new WCHAR[wlen];
::MultiByteToWideChar(CP_ACP, 0, text, -1, pUnicode, wlen);
int len = ::WideCharToMultiByte(CP_UTF8, 0, pUnicode, -1, NULL, 0, NULL, NULL);
CHAR* pUTF8 = new CHAR[len];
::WideCharToMultiByte(CP_UTF8, 0, pUnicode, -1, pUTF8, len, NULL, NULL);
delete[] pUnicode;
std::string ret = pUTF8;
delete[] pUTF8;
return ret;
}
static std::string Utf8ToAnsi(const char* text)
{
int wlen = ::MultiByteToWideChar(CP_UTF8, 0, text, -1, NULL, 0);
WCHAR* pUnicode = new WCHAR[wlen];
::MultiByteToWideChar(CP_UTF8, 0, text, -1, pUnicode, wlen);
int len = ::WideCharToMultiByte(CP_ACP, 0, pUnicode, -1, NULL, 0, NULL, NULL);
CHAR* pAnsi = new CHAR[len];
::WideCharToMultiByte(CP_ACP, 0, pUnicode, -1, pAnsi, len, NULL, NULL);
delete[] pUnicode;
std::string ret = pAnsi;
delete[] pAnsi;
return ret;
}
#endif
std::string Utf8ToStdString(const char* utf8)
{
#if defined(HG_CMP_MSC)
return Utf8ToAnsi(utf8);
#else
return utf8;
#endif
}
std::string StdStringToUtf8(const char* str)
{
#if defined(HG_CMP_MSC)
return AnsiToUtf8(str);
#else
return str;
#endif
}
void TrimString(std::string& str)
{
int s = (int)str.find_first_not_of(" ");
int e = (int)str.find_last_not_of(" ");
str = str.substr(s, e - s + 1);
}
...@@ -7,10 +7,4 @@ QString getStdFileName(const QString &fileName); ...@@ -7,10 +7,4 @@ QString getStdFileName(const QString &fileName);
std::string getStdString(const QString &str); std::string getStdString(const QString &str);
std::string Utf8ToStdString(const char* utf8);
std::string StdStringToUtf8(const char* str);
void TrimString(std::string& str);
#endif /* __HGUIGLOBAL_H__ */ #endif /* __HGUIGLOBAL_H__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment