按键扫描工具托盘增加退出功能,并适配国产系统

This commit is contained in:
yangjiaxuan 2024-08-09 20:15:00 +08:00
parent dd569e9f61
commit 69265401cf
5 changed files with 111 additions and 14 deletions

View File

@ -1,4 +1,4 @@
#include "form_deviceconfig.h"
#include "form_deviceconfig.h"
#include <QTabWidget>
#include <QScrollArea>
#include <QFormLayout>
@ -12,7 +12,14 @@
#include <QSpacerItem>
#include <QPushButton>
#include <QEvent>
#if !defined(HG_CMP_MSC)
#include <math.h>
#endif
#include "lang/app_language.h"
#include "log/log.h"
extern HLOG g_hLog;
Form_DeviceConfig::Form_DeviceConfig(SANE_Handle devHandle, const std::vector<DeviceConfig>& deviceConfigs, QWidget *parent)
: QWidget(parent)
@ -99,6 +106,7 @@ void Form_DeviceConfig::Init(const std::vector<DeviceConfig>& deviceConfigs)
}
// 2.恢复默认
InfoLog(g_hLog, "Init button id is: %d", m_defButtonId);
assert(-1 != m_defButtonId);
sane_control_option(m_devHandle, m_defButtonId, SANE_ACTION_SET_VALUE, NULL, NULL);
@ -856,7 +864,7 @@ void Form_DeviceConfig::on_defaultBtn_clicked()
void Form_DeviceConfig::on_string_list_comboBoxClicked()
{
QComboBox *comboBox = qobject_cast<QComboBox*>(sender());
std::string currentText = comboBox->currentText().toUtf8();
std::string currentText = comboBox->currentText().toUtf8().toStdString();
SANE_Int id = comboBox->property("config_id").toInt();
DeviceConfigEx *deviceConfigEx = qvariant_cast<DeviceConfigEx*>(comboBox->property("configex_ptr"));
@ -1036,7 +1044,7 @@ void Form_DeviceConfig::on_relate_doubleSpinboxClicked(double value)
void Form_DeviceConfig::on_string_comboBoxClicked()
{
QComboBox *comboBox = qobject_cast<QComboBox*>(sender());
std::string currentText = comboBox->currentText().toUtf8();
std::string currentText = comboBox->currentText().toUtf8().toStdString();
SANE_Int id = comboBox->property("config_id").toInt();
DeviceConfigEx *deviceConfigEx = qvariant_cast<DeviceConfigEx*>(comboBox->property("configex_ptr"));

View File

@ -2,11 +2,33 @@
#include <QApplication>
#include "base/HGDef.h"
#include <QTranslator>
#include "log/log.h"
HLOG g_hLog = nullptr;
#if defined(OEM_HANWANG)
const char* oem = "HanvonScan";
#elif defined(OEM_LISICHENG)
const char* oem = "LanxumScan";
#elif defined(OEM_CANGTIAN)
const char* oem = "CumtennScan";
#elif defined(OEM_ZHONGJING)
const char* oem = "MicrotekScan";
#elif defined(OEM_ZIGUANG)
const char* oem = "UniScan";
#elif defined(OEM_NEUTRAL)
const char* oem = "NeuScan";
#elif defined(OEM_DELI)
const char* oem = "DeliScan";
#else
const char* oem = "HuaGoScan";
#endif
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
g_hLog = EnableLog(nullptr, oem, "app");
#ifdef HG_CMP_MSC
HANDLE hMutex = CreateMutexW(NULL, FALSE, L"{A8856E3B-3B67-43e4-82AD-154258C0FD37}");
assert(NULL != hMutex);
@ -28,6 +50,9 @@ int main(int argc, char *argv[])
//w.show();
int ret = a.exec();
DisableLog(g_hLog);
g_hLog = nullptr;
#ifdef HG_CMP_MSC
CloseHandle(hMutex);
#endif

View File

@ -56,8 +56,8 @@ MainWindow::MainWindow(QWidget *parent)
//创建菜单,添加菜单项
m_trayIconMenu = new QMenu(this);
m_trayIconMenu->addAction(m_showAction);
//m_trayIconMenu->addSeparator(); //分割线
//m_trayIconMenu->addAction(m_quitAction);
m_trayIconMenu->addSeparator(); //分割线
m_trayIconMenu->addAction(m_quitAction);
//给系统托盘添加右键菜单
m_trayIcon->setContextMenu(m_trayIconMenu);
@ -105,14 +105,14 @@ MainWindow::MainWindow(QWidget *parent)
m_dlgScanInfo = new Dialog_ScanInfo(this);
connect(this, SIGNAL(deviceArrive(QString)), this, SLOT(on_deviceArrive(QString)));
connect(this, SIGNAL(deviceRemove(QString)), this, SLOT(on_deviceRemove(QString)));
connect(this, SIGNAL(keyPress(unsigned int)), this, SLOT(on_keyPress(unsigned int)));
connect(this, SIGNAL(scanWorking()), this, SLOT(on_scanWorking()));
connect(this, SIGNAL(scanInfo(QString, bool)), this, SLOT(on_scanInfo(QString, bool)));
connect(this, SIGNAL(deviceArrive(QString)), this, SLOT(on_deviceArrive(QString)), Qt::QueuedConnection);
connect(this, SIGNAL(deviceRemove(QString)), this, SLOT(on_deviceRemove(QString)), Qt::QueuedConnection);
connect(this, SIGNAL(keyPress(unsigned int)), this, SLOT(on_keyPress(unsigned int)), Qt::QueuedConnection);
connect(this, SIGNAL(scanWorking()), this, SLOT(on_scanWorking()), Qt::QueuedConnection);
connect(this, SIGNAL(scanInfo(QString, bool)), this, SLOT(on_scanInfo(QString, bool)), Qt::QueuedConnection);
connect(this, SIGNAL(scanImage(unsigned int)), this, SLOT(on_scanImage(unsigned int)));
connect(this, SIGNAL(scanFinish()), this, SLOT(on_scanFinish()));
connect(this, SIGNAL(saneEventCloseDevice(void*, bool)), this, SLOT(on_saneEventCloseDevice(void*, bool)));
connect(this, SIGNAL(scanFinish()), this, SLOT(on_scanFinish()), Qt::QueuedConnection);
connect(this, SIGNAL(saneEventCloseDevice(void*, bool)), this, SLOT(on_saneEventCloseDevice(void*, bool)), Qt::QueuedConnection);
SANE_Int version_code = 0;
sane_init_ex(&version_code, sane_ex_callback, this);

View File

@ -52,8 +52,53 @@ win32 {
LIBS += -L$$PWD/../../build/$${MY_OS}/$${OEM_NAME}/$${MY_ARCH}/$${MY_CONFIGURE} -l$${OEM_PREFIX}Base -l$${OEM_PREFIX}ImgFmt -l$${OEM_PREFIX}ImgProc
LIBS += -L$$PWD/../../../../sdk/lib/win/$${MY_ARCH}/OEM/$${OEM_NAME} -lsanexy
# sane.dll
LIBS += -L$$PWD/../../../../release/win/$${MY_ARCH}/OEM/$${OEM_NAME}
LIBS += -L$$PWD/../../../../release/$${MY_OS}/$${MY_ARCH2} -lyuyanbao
LIBS += -L$$PWD/../../../../release/$${MY_OS}/$${MY_ARCH2} -lcommonlog
}
unix {
DEFINES += _GLIBCXX_USE_CXX11_ABI=0
DISTRIBUTION = $$system(cat /etc/issue | cut -d\' \' -f1)
contains(DISTRIBUTION, UnionTech) {
MY_OS = uos
} else {
MY_OS = kylin
}
TARGET = $${OEM_PREFIX2}ScanTool
contains(QT_ARCH, x86_64) {
MY_ARCH = amd64
MY_ARCH2 = x86_64
}
contains(QT_ARCH, arm64) {
MY_ARCH = aarch64
MY_ARCH2 = aarch64
}
contains(QT_ARCH, mips64) {
MY_ARCH = mips64
MY_ARCH2 = mips64
}
contains(QT_ARCH, loongarch64) {
MY_ARCH = loongarch64
MY_ARCH2 = loongarch64
}
contains(QT_ARCH, sw_64) {
MY_ARCH = sw_64
MY_ARCH2 = sw_64
}
CONFIG += unversioned_libname unversioned_soname
QMAKE_CXXFLAGS += -fvisibility=hidden
QMAKE_LFLAGS += -Wl,-rpath,\'\$\$ORIGIN\' -Wl,--exclude-libs,ALL
QMAKE_LFLAGS += -z defs -B direct
LIBS += -lpthread -ldl
LIBS += -L$$PWD/../../build/$${MY_OS}/$${OEM_NAME}/$${MY_ARCH}/$${MY_CONFIGURE} -l$${OEM_PREFIX2}Base -l$${OEM_PREFIX2}ImgFmt -l$${OEM_PREFIX}ImgProc
LIBS += -L$$PWD/../../../../release/$${MY_OS}/$${MY_ARCH2} -lsane-$${OEM_PREFIX3}sane
LIBS += -L$$PWD/../../../../release/$${MY_OS}/$${MY_ARCH2} -lyuyanbao
LIBS += -L$$PWD/../../../../release/$${MY_OS}/$${MY_ARCH2} -lcommonlog
}
INCLUDEPATH += $$PWD/../../../modules
@ -100,6 +145,19 @@ win32 {
}
}
unix {
CONFIG(release, debug|release) {
DESTEXE_PATH = $$PWD/../../../../release/$${MY_OS}/$${MY_ARCH2}/
message(DESTEXE_PATH: $$DESTEXE_PATH)
SRCEXE_FILE = $${DESTDIR}/$${TARGET}
message(SRCEXE_FILE: $$SRCEXE_FILE)
QMAKE_POST_LINK += cp $$SRCEXE_FILE $$DESTEXE_PATH
}
}
SOURCES += \
../../../app/scantool/dialog_add.cpp \
../../../app/scantool/dialog_scaninfo.cpp \

View File

@ -11,7 +11,8 @@ SUBDIRS += \
HGWebService \
HGUpgrade \
HGFWUpgrade \
HGScanner2
HGScanner2 \
HGScanTool
HGImgFmt.depends = \
HGBase
@ -56,3 +57,8 @@ HGScanner2.depends = \
HGImgProc \
HGVersion \
HGSaneUser
HGScanTool.depends = \
HGBase \
HGImgFmt \
HGImgProc