!2 适配wayland双标题栏,窗口居中;合并主线已解决的bug

* Merge branch 'openkylin/yangtze' of gitee.com:openkylin/kylin-photo-vi…
* fix(添加调用的kabase文件): 添加调用的kabas
* feat(适配wayland双标题栏和窗口居中;合并近期主线bug): 适配wayland双标题栏和窗口居中;合并近期主线bug
* fix(仅bug修复,无其他影响): 添加判断,不影响
* fix(仅bug修复,无其他影响): 将x11相关的部分暂时注释掉,解决纯wayland环境应用启动不了的问题
This commit is contained in:
zoujunnan0613 2022-07-15 09:52:41 +00:00 committed by 邹畅
parent 4825f94fde
commit f55b3e707f
15 changed files with 674 additions and 61 deletions

6
debian/changelog vendored
View File

@ -1,3 +1,9 @@
kylin-photo-viewer (1.3.0.3-ok3) yangtze; urgency=medium
* 适配wayland标题栏和窗口居中合并主线代码
-- Xie Wei <xiewei@kylinos.cn> Fri, 15 Jul 2022 18:43:28 +0800
kylin-photo-viewer (1.3.0.3-ok2) yangtze; urgency=medium
* 解决应用启动不了的问题

53
kabase/Qt/log.hpp Normal file
View File

@ -0,0 +1,53 @@
/*
* Log Qt kysdk-log Qt库 kysdk-log
*/
#ifndef LOG_HPP_
#define LOG_HPP_
#include <qapplication.h>
#include <libkylog.h>
#include <QString>
#include <QByteArray>
namespace kabase
{
class Log
{
public:
Log() = default;
~Log() = default;
static void logOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg)
{
QByteArray localMsg = msg.toLocal8Bit();
const char *message = localMsg.constData();
const char *file = context.file ? context.file : "";
const char *function = context.function ? context.function : "";
switch (type) {
case QtDebugMsg:
klog_debug("%s (%s:%u,%s)\n", message, file, context.line, function);
break;
case QtInfoMsg:
klog_info("%s (%s:%u,%s)\n", message, file, context.line, function);
break;
case QtWarningMsg:
klog_warning("%s (%s:%u,%s)\n", message, file, context.line, function);
break;
case QtCriticalMsg:
klog_err("%s (%s:%u,%s)\n", message, file, context.line, function);
break;
case QtFatalMsg:
klog_emerg("%s (%s:%u,%s)\n", message, file, context.line, function);
break;
}
return;
};
};
}
#endif

View File

@ -0,0 +1,88 @@
#ifndef QT_WINDOWMANAGE_HPP_
#define QT_WINDOWMANAGE_HPP_
/*
* windowmanage 使 kysdk-waylandhelper 使 kysdk-waylandhelper
*/
#include <unistd.h>
#include <QApplication>
#include <QScreen>
#include <QWidget>
#include <QRect>
#include <windowmanager/windowmanager.h>
#include <ukuistylehelper/ukuistylehelper.h>
namespace kabase
{
class WindowManage : public QObject
{
Q_OBJECT
public:
WindowManage() = default;
~WindowManage() = default;
static void setScalingProperties(void)
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
#endif
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
#endif
return;
};
static void setMiddleOfScreen(QWidget *w) {
int sw = QGuiApplication::primaryScreen()->availableGeometry().width();
int sh = QGuiApplication::primaryScreen()->availableGeometry().height();
kdk::WindowManager::setGeometry(w->windowHandle(), QRect((sw - w->width()) / 2, (sh - w->height()) / 2, w->width(), w->height()));
return;
};
static void removeHeader(QWidget *w) {
kdk::UkuiStyleHelper::self()->removeHeader(w);
return;
};
/* id 的初始值必须为 0 */
static void getWindowId(quint32 *id) {
connect(kdk::WindowManager::self(), &kdk::WindowManager::windowAdded, [=](const kdk::WindowId &windowId) {
if (getpid() == (int)kdk::WindowManager::getPid(windowId) && *id == 0) {
*id = windowId.toLongLong();
}
});
return;
};
static void keepWindowAbove(const quint32 id) {
kdk::WindowManager::keepWindowAbove(id);
return;
};
static void activateWindow(const quint32 id) {
kdk::WindowManager::activateWindow(id);
return;
}
};
}
/*
* wayland 使 desktop
* 1. : X-KDE-Wayland-Interfaces=org_kde_plasma_window_management,org_kde_plasma_activation_feedback,org_kde_kwin_keystate,org_kde_kwin_fake_input,zkde_screencast_unstable_v1
* 2. Exec字段需要为绝对路径并且不能携带参数
*/
#endif

306
kabase/buriedpoint.hpp Normal file
View File

@ -0,0 +1,306 @@
/*
* BuriedPoint 使 kysdk-log kysdk-diagnostics kysdk-log kysdk-diagnostics
*/
#ifndef BURIEDPOINT_HPP_
#define BURIEDPOINT_HPP_
#include <sstream>
#include <iostream>
#include <string.h>
#include <map>
#include <libkydiagnostics.h>
#include <libkylog.h>
#include "utils.hpp"
namespace kabase
{
class BuriedPoint
{
public:
BuriedPoint() = default;
~BuriedPoint() = default;
/* 埋点类型 */
enum BuriedPointType {
FunctionType = 0, /* 功能性打点 */
PerformanceType, /* 性能型打点 */
StabilityType, /* 稳定型打点 */
TestType /* 测试预留 */
};
/* 点位 */
/* 规则说明 */
/* 0x 00 0 000
* | | |
*
*/
enum PT {
KylinIpmsgNicknameModify = 0x010001, /* 昵称修改 */
KylinIpmsgOpenSaveDir = 0x010002, /* 打开文件保存目录(主界面入口) */
KylinIpmsgMainSearch = 0x010003, /* 主界面搜索 */
KylinIpmsgHistorySearch = 0x010004, /* 历史记录搜索 */
KylinIpmsgSetTop = 0x010005, /* 设置置顶 */
KylinIpmsgModifyFriendNotes = 0x010006, /* 修改好友备注 */
KylinIpmsgViewInformation = 0x010007, /* 查看资料 */
KylinIpmsgChangeDir = 0x010008, /* 更改目录 */
KylinIpmsgCleanCache = 0x010009, /* 清空缓存 */
KylinIpmsgClearChatRecord = 0x010010, /* 清空聊天记录 */
KylinIpmsgClearSingleChatRecord = 0x010011, /* 清空单人聊天记录 */
KylinIpmsgDeleteRecord = 0x010012, /* 删除记录 */
KylinIpmsgBatchDelete = 0x010013, /* 批量删除 */
KylinIpmsgSendMessage = 0x010014, /* 发送消息 */
KylinIpmsgSendFiles = 0x010015, /* 发送文件 */
KylinIpmsgSendDir = 0x010016, /* 发送目录 */
KylinIpmsgSendScreenshot = 0x010017, /* 发送截屏 */
KylinIpmsgResend = 0x010018, /* 重新发送 */
KylinIpmsgCopy = 0x010019, /* 复制 */
KylinIpmsgOpen = 0x010020, /* 打开 */
KylinIpmsgOpenDir = 0x010021, /* 打开目录 */
KylinIpmsgSaveAs = 0x010022, /* 另存为 */
KylinIpmsgTray = 0x010023, /* 托盘 */
KylinFontViewInstallFont = 0x020001, /* 安装字体 */
KylinFontViewUninstallFont = 0x020002, /* 卸载字体 */
KylinFontViewSearchFont = 0x020003, /* 搜索字体 */
KylinFontViewApplyFont = 0x020004, /* 应用字体 */
KylinFontViewExportFont = 0x020005, /* 导出字体 */
KylinFontViewCollectionFont = 0x020006, /* 收藏字体 */
KylinFontViewCancelCollectionFont = 0x020007, /* 取消收藏字体 */
KylinFontViewFontInformation = 0x020008, /* 字体信息 */
KylinFontViewCopywritingChange = 0x020009, /* 文案更改 */
KylinFontViewFontSizeChange = 0x020010, /* 预览字号调整 */
KylinCalaulatorStandardMode = 0x030001, /* 标准模式 */
KylinCalaulatorScientificMode = 0x030002, /* 科学模式 */
KylinCalaulatorRateMode = 0x030003, /* 汇率模式 */
KylinCalaulatorProgrammerMode = 0x030004, /* 程序员模式 */
KylinWeatherCollection = 0x040001, /* 收藏 */
KylinWeatherChangeCity = 0x040002, /* 切换城市 */
KylinWeatherCitySearch = 0x040003, /* 城市搜索 */
KylinWeatherFullScreen = 0x040004, /* 全屏 */
KylinPhotoViewerOpenPicture = 0x050001, /* 打开图片 */
KylinPhotoViewerSwitchPicture = 0x050002, /* 切换图片 */
KylinPhotoViewerFlip = 0x050003, /* 翻转 */
KylinPhotoViewerRotate = 0x050004, /* 旋转 */
KylinPhotoViewerAddPicture = 0x050005, /* 添加图片 */
KylinPhotoViewerZoomInandOut = 0x050006, /* 放大缩小 */
KylinPhotoViewerPictureDetails = 0x050007, /* 图片详情 */
KylinPhotoViewerCutting = 0x050008, /* 裁剪 */
KylinPhotoViewerCoyp = 0x050009, /* 复制 */
KylinPhotoViewerPrint = 0x050010, /* 打印 */
KylinPhotoViewerDelete = 0x050011, /* 删除 */
KylinPhotoViewerSaveAs = 0x050012, /* 另存为 */
KylinPhotoViewerRename = 0x050013, /* 重命名 */
KylinPhotoViewerSetAsDesktopWallpaper = 0x050014, /* 设置为桌面壁纸 */
KylinPhotoViewerShowInFolder = 0x050015, /* 在文件夹中显示 */
KylinPhotoViewerPicturePreview = 0x050016, /* 图片预览 */
KylinPhotoViewerCurrentPointZoom = 0x050017, /* 当前点缩放 */
KylinServiceSupportFileUpload = 0x060001, /* 文件上传 */
KylinServiceSupportVideoape = 0x060002, /* 录像 */
KylinServiceSupportFileCopy = 0x060003, /* 文件拷贝 */
KylinServiceSupportJumpOfficicalWebsite = 0x060004, /* 跳转官网主页 */
KylinServiceSupportJumpOnlineService = 0x060005, /* 跳转在线客服 */
KylinPrinterManuallyInstallPrinter = 0x070001, /* 手动安装打印机 */
KylinPrinterSetResolution = 0x070002, /* 设置分辨率 */
KylinPrinterSetPaperSize = 0x070003, /* 设置纸张大小 */
KylinPrinterSetPaperType = 0x070004, /* 设置纸张类型 */
KylinPrinterSetCationSource = 0x070005, /* 设置纸盒来源 */
KylinPrinterSetDuplexPrint = 0x070006, /* 设置双面打印 */
KylinPrinterSetInkType = 0x070007, /* 设置墨水类型 */
KylinPrinterADDRemovePrinter = 0x070008, /* 添加删除打印机 */
KylinPrinterSetShareStartup = 0x070009, /* 设置共享启动 */
KylinPrintTestPage = 0x070010, /* 打印测试页 */
KylinPrinterCancelPrintJob = 0x070011, /* 取消打印任务 */
KylinPrinterDeletePrintJob = 0x070012, /* 删除打印任务 */
KylinPrinterRePrint = 0x070013, /* 重新打印 */
KylinPrinterManualyModifyDrive = 0x070014, /* 手动修改驱动 */
KylinPrinterRename = 0x070015, /* 重命名 */
KylinRecorderRecording = 0x080001, /* 录音 */
KylinRecorderPlayPause = 0x080002, /* 播放暂停 */
KylinRecorderClip = 0x080003, /* 剪辑 */
KylinRecorderSign = 0x080004, /* 标记 */
KylinRecorderDelete = 0x080005, /* 删除 */
KylinRecorderBluetoothRecord = 0x080006, /* 蓝牙录音 */
KylinRecorderSaveAs = 0x080007, /* 另存为 */
KylinRecorderOpenFileLocation = 0x080008, /* 打开文件位置 */
KylinRecorderTopicSwitch = 0x080009, /* 主题切换 */
KylinCameraPreviewMonitor = 0x090001, /* 预览画面 */
KylinCameraSingleShot = 0x090002, /* 单拍 */
KylinCameraContinuousShot = 0x090003, /* 连拍 */
KylinCameraDelay = 0x090004, /* 延时拍照 */
KylinCameraVideotape = 0x090005, /* 录像 */
KylinCameraCameraSelection = 0x090006, /* 摄像头选用 */
KylinCameraResolutionSelection = 0x090007, /* 分辨率选用 */
KylinCameraVideoFormatSelection = 0x090008, /* 视频格式选用 */
KylinCameraPictureFormatSelection = 0x090009, /* 图片格式选用 */
KylinCameraChangeSavePath = 0x090010, /* 更改存储路径 */
KylinCameraThumbnail = 0x090011, /* 缩略图 */
KylinCameraGridLine = 0x090012, /* 网格线 */
KylinCameraMirrorFun = 0x090013, /* 镜像功能 */
KylinNotebookOrderList = 0x100001, /* 有序列表 */
KylinNotebookUnorderList = 0x100002, /* 无序列表 */
KylinNotebookBold = 0x100003, /* 加粗 */
KylinNotebookItalics = 0x100004, /* 斜体 */
KylinNotebookUnderline = 0x100005, /* 下划线 */
KylinNotebookDeleteline = 0x100006, /* 删除线 */
KylinNotebookFontSize = 0x100007, /* 字号 */
KylinNotebookFontColor = 0x100008, /* 字体颜色 */
KylinNotebookInsertPicture = 0x100009, /* 插入图片 */
KylinNotebookInterfaceColor = 0x100010, /* 界面配色 */
KylinNotebookDeleteCurrent = 0x100011, /* 删除当前 */
KylinNotebookUiTop = 0x100012, /* UI 置顶 */
KylinNotebookListMode = 0x100013, /* 列表模式 */
KylinNotebookIconMode = 0x100014, /* 图标模式 */
KylinNotebookNewNote = 0x100015, /* 新建便签 */
KylinNotebookSearch = 0x100016, /* 搜索 */
KylinNotebookDelete = 0x100017, /* 删除 */
KylinNotebookModeChange = 0x100018, /* 模式切换 */
KylinOsManagerGarbageClean = 0x110001, /* 垃圾清理 */
KylinOsManagerFileShredding = 0x110002, /* 文件粉碎 */
KylinGpuControllerBaseInfo = 0x120001, /* 基本信息 */
KylinGpuControllerRunState = 0x120002, /* 运行状态 */
KylinGpuControllerDriveInfo = 0x120003, /* 驱动信息 */
KylinGpuControllerSwitch = 0x120003, /* 显卡切换 */
KylinNetworkCheckStartCheck = 0x130001, /* 开始检测 */
KylinGallerySwitchFolder = 0x140001, /* 切换目录 */
KylinGalleryOpenViewer = 0x140002, /* 打开麒麟看图 */
KylinMobileAssistantAndroidConn = 0x150001, /* 安卓链接 */
KylinMobileAssistantPcConn = 0x150002, /* PC链接 */
KylinMobileAssistantUsbConn = 0x150003, /* Usb链接 */
KylinMobileAssistantWifiConn = 0x150004, /* Wifi链接 */
KylinMobileAssistantDeviceDiscovery = 0x150005, /* 设备发现 */
KylinMobileAssistantDisconnect = 0x150006, /* 断开链接 */
KylinMobileAssistantMobileScreen = 0x150007, /* 手机投屏 */
KylinMobileAssistantPcScreen = 0x150008, /* PC 投屏 */
KylinMobileAssistantPictureList = 0x150009, /* 图片列表 */
KylinMobileAssistantVideoList = 0x150010, /* 视频列表 */
KylinMobileAssistantAudioList = 0x150011, /* 音频列表 */
KylinMobileAssistantDocList = 0x150012, /* 文档列表 */
KylinMobileAssistantQQFileList = 0x150013, /* QQ 文件列表 */
KylinMobileAssistantWechatFileList = 0x150014, /* 微信文件列表 */
KylinMobileAssistantMobileStorage = 0x150015, /* 手机存储 */
KylinMobileAssistantSwitchView = 0x150016, /* 切换视图 */
KylinMobileAssistantRefreshList = 0x150017, /* 刷新列表 */
KylinMobileAssistantUploadFile = 0x150018, /* 上传文件 */
KylinMobileAssistantDownloadFile = 0x150019, /* 下载文件 */
KylinMobileAssistantOpenFile = 0x150020, /* 打开文件 */
KylinScannerOneClickBeautification = 0x160001, /* 一键美化 */
KylinScannerRectification = 0x160002, /* 自动纠偏 */
KylinScannerTextRecognition = 0x160003, /* 文本识别 */
KylinScannerCutting = 0x160004, /* 裁剪 */
KylinScannerRotate = 0x160005, /* 旋转 */
KylinScannerImage = 0x160006, /* 镜像 */
KylinScannerAddWatermark = 0x160007, /* 加水印 */
KylinScannerSendMail = 0x160008, /* 发送邮件 */
KylinScannerSaveAs = 0x160009, /* 另存为 */
KylinScannerSinglePageScan = 0x160010, /* 单页扫描 */
KylinScannerMultiPageScan = 0x160011, /* 多页扫描 */
KylinCalendarMonthDetails = 0x170001, /* 查看月详情 */
KylinCalendarMonthSwitch = 0x170002, /* 月切换 */
KylinCalendarDoday = 0x170003, /* 定位到今天 */
TestFunPoint = 0x999999 /* 测试预留 */
};
static bool functionBuriedPoint(AppName packageName, PT point)
{
static char *messageType = (char *)"FunctionType";
char *appName = strdup(Utils::getAppName(packageName).c_str());
std::string hex;
std::stringstream ss;
ss << std::hex << point;
ss >> hex;
KBuriedPoint pt;
pt.key = "FunctionName";
pt.value = hex.c_str();
if (kdk_buried_point(appName, messageType, &pt, 1)) {
free(appName);
klog_err("kabase: buried point fail !\n");
return false;
}
free(appName);
return true;
};
static bool buriedPoint(AppName packageName, BuriedPointType buriedPointType, std::map<std::string, std::string> data)
{
char *appName = strdup(Utils::getAppName(packageName).c_str());
char type[128];
memset(type, '\0', sizeof(type));
switch (buriedPointType) {
case BuriedPointType::FunctionType:
strcpy(type, "FunctionType");
break;
case BuriedPointType::PerformanceType:
strcpy(type, "PerformanceType");
break;
case BuriedPointType::StabilityType:
strcpy(type, "StabilityType");
break;
default:
break;
}
if (!strlen(type)) {
klog_err("kabase: buried point type is empty !\n");
return false;
}
int size = data.size();
if (size == 0) {
klog_err("kabase: buried point data is empty !\n");
return false;
}
KBuriedPoint *pt = (KBuriedPoint *)malloc(sizeof(KBuriedPoint) * size);
{
int i;
std::map<std::string, std::string>::iterator it;
for (i = 0, it = data.begin(); it != data.end() && i < size; it++, i++) {
pt[i].key = it->first.c_str();
pt[i].value = it->second.c_str();
}
}
if (kdk_buried_point(appName, type, pt, size)) {
free(appName);
free(pt);
klog_err("kabase: buried point fail !\n");
return false;
}
free(appName);
free(pt);
return true;
};
};
}
#endif

88
kabase/utils.hpp Normal file
View File

@ -0,0 +1,88 @@
#ifndef UTILS_HPP_
#define UTILS_HPP_
#include <string>
namespace kabase
{
/* 应用名 */
enum AppName {
KylinIpmsg = 0, /* 传书 */
KylinFontViewer, /* 字体管理器 */
KylinCalculator, /* 麒麟计算器 */
KylinGpuController, /* 显卡控制器 */
KylinMusic, /* 音乐 */
KylinWeather, /* 天气 */
KylinPhotoViewer, /* 看图 */
KylinServiceSupport, /* 服务与支持 */
KylinPrinter, /* 麒麟打印 */
KylinCalendar, /* 日历 */
KylinRecorder, /* 录音 */
KylinCamera, /* 摄像头 */
KylinNotebook, /* 便签 */
KylinOsManager, /* 麒麟管家 */
KylinNetworkCheck, /* 网络检测工具 */
KylinGallery, /* 相册 */
KylinScanner, /* 扫描 */
KylinMobileAssistant, /* 多端协同 */
KylinTest /* 测试预留 */
};
class Utils
{
public:
Utils() = default;
~Utils() = default;
static std::string getAppName(AppName appName)
{
switch (appName) {
case AppName::KylinCalculator:
return "kylin-calaulator";
case AppName::KylinCalendar:
return "kylin-calendar";
case AppName::KylinCamera:
return "kylin-camera";
case AppName::KylinFontViewer:
return "kylin-font-viewer";
case AppName::KylinGpuController:
return "kylin-gpu-controller";
case AppName::KylinIpmsg:
return "kylin-ipmsg";
case AppName::KylinMusic:
return "kylin-music";
case AppName::KylinPhotoViewer:
return "kylin-photo-viewer";
case AppName::KylinPrinter:
return "kylin-printer";
case AppName::KylinRecorder:
return "kylin-recorder";
case AppName::KylinServiceSupport:
return "kylin-service-support";
case AppName::KylinWeather:
return "kylin-weather";
case AppName::KylinNotebook:
return "kylin-notebook";
case AppName::KylinOsManager:
return "kylin-os-manager";
case AppName::KylinNetworkCheck:
return "kylin-network-check-tools";
case AppName::KylinGallery:
return "kylin-gallery";
case AppName::KylinScanner:
return "kylin-scanner";
case AppName::KylinMobileAssistant:
return "kylin-mobile-assistant";
default:
return "";
}
/* 不应该被执行 */
return "";
};
};
}
#endif

View File

@ -818,16 +818,30 @@ void Core::changeImageShowSize(ImageShowStatus::ChangeShowSizeType type, QPoint
m_imageNeedUpdate = false;
m_zoomFocus = focus;
int resizeKey;
if (m_proportion < 150) {
resizeKey = Variable::RESIZE_KEY;
} else if (m_proportion < 300) {
resizeKey = Variable::RESIZE_KEY_SECOND;
} else if (m_proportion < 500) {
resizeKey = Variable::RESIZE_KEY_THIRD;
} else {
resizeKey = Variable::RESIZE_KEY_FOURTH;
//只判断缩放,其他情况无需修改,不涉及使用缩放阈值
if (type == ImageShowStatus::BIG) {
if (m_proportion < 150) {
resizeKey = Variable::RESIZE_KEY;
} else if (m_proportion < 300) {
resizeKey = Variable::RESIZE_KEY_SECOND;
} else if (m_proportion < 500) {
resizeKey = Variable::RESIZE_KEY_THIRD;
} else {
resizeKey = Variable::RESIZE_KEY_FOURTH;
}
} else if (type == ImageShowStatus::SMALL) {
if (m_proportion <= 150) {
resizeKey = Variable::RESIZE_KEY;
} else if (m_proportion <= 300) {
resizeKey = Variable::RESIZE_KEY_SECOND;
} else if (m_proportion <= 500) {
resizeKey = Variable::RESIZE_KEY_THIRD;
} else {
resizeKey = Variable::RESIZE_KEY_FOURTH;
}
}
int tmpProportion = 0;
switch (type) {

View File

@ -21,13 +21,14 @@
#include <QLoggingCategory>
#include "view/openimage.h"
#include <window_management.hpp>
#include <log.hpp>
#include "log.hpp"
#include "windowmanage.hpp"
int main(int argc, char *argv[])
{
//适配4K屏以及分数缩放
kdk::kabase::WindowManagement::setScalingProperties();
//日志输出
qInstallMessageHandler(kdk::kabase::Log::logOutput);
qInstallMessageHandler(::kabase::Log::logOutput);
QApplication a(argc, argv);
qApp->setWindowIcon(QIcon::fromTheme("kylin-photo-viewer", QIcon(":/res/res/kyview_logo.png")));
QLoggingCategory::setFilterRules(QStringLiteral("qt.qml.binding.removal.info=true"));
@ -66,7 +67,7 @@ int main(int argc, char *argv[])
a.setApplicationName(QApplication::tr("Pictures"));
//主题框架
KyView w(a.arguments());
kdk::kabase::WindowManagement::setWindowMotifHint(w.winId());
::kabase::WindowManage::removeHeader(&w);
Interaction::getInstance()->initUiFinish();
return a.exec();
}

View File

@ -17,6 +17,8 @@ LIBS += -lpeony \
LIBS += -lX11
#适配sdk
PKGCONFIG += kysdk-qtwidgets
PKGCONFIG += kysdk-waylandhelper
PKGCONFIG += kysdk-log
#kysdk
PKGCONFIG += kysdk-kabase
LIBS += -L/usr/lib/kysdk/kysdk-base -lkylog -lkyconf
@ -26,6 +28,9 @@ INCLUDEPATH += /usr/include/kysdk/applications/kabase/kylin_system/
INCLUDEPATH += /usr/include/kabase/kylin_system/
INCLUDEPATH += /usr/include/kysdk/applications/kabase/
INCLUDEPATH += ../kabase/
INCLUDEPATH += ../kabase/Qt
CONFIG += c++11

View File

@ -2,6 +2,7 @@
#include "sizedate.h"
#include "X11/Xlib.h"
#include <QX11Info>
#include "windowmanage.hpp"
KyView *KyView::mutual = nullptr;
KyView::KyView(const QStringList &args)
{
@ -37,10 +38,6 @@ KyView::KyView(const QStringList &args)
//响应拖拽事件
this->setAcceptDrops(true);
//应用居中
QScreen *screen = QGuiApplication::primaryScreen();
this->move((screen->geometry().width() - this->width()) / 2, (screen->geometry().height() - this->height()) / 2);
m_titlebar->move(0, 0);
m_titlebar->show();
@ -91,11 +88,16 @@ KyView::KyView(const QStringList &args)
m_timer = new QTimer(this);
m_timernavi = new QTimer(this);
m_timeNomove = new QTimer(this);
m_aboutDialog = new KAboutDialog();
// m_aboutDialog->setParent(this);
m_aboutDialog->hide();
m_aboutDialog->setBodyTextVisiable(true);
this->initAboutDialog();
//应用居中
if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive)) {
::kabase::WindowManage::setMiddleOfScreen(this);
} else {
QScreen *screen = QGuiApplication::primaryScreen();
this->move((screen->geometry().width() - this->width()) / 2,
(screen->geometry().height() - this->height()) / 2);
}
this->setMinimumSize(m_miniSize);
this->initconnect();
//要判断打开状态,是否隐藏主界面--打开按钮widget
@ -109,8 +111,6 @@ KyView::~KyView()
{
delete hOrVMode;
hOrVMode = nullptr;
delete m_aboutDialog;
m_aboutDialog = nullptr;
}
void KyView::slotIntelHVModeChanged(deviceMode sig)
{
@ -124,7 +124,6 @@ void KyView::initInteraction()
connect(Interaction::getInstance(), &Interaction::fullScreen, this, &KyView::fullScreen);
}
//信号和槽
void KyView::initconnect()
{
@ -203,6 +202,7 @@ void KyView::initconnect()
});
connect(m_showImageWidget, &ShowImageWidget::startWayToSetTitleStyle, m_titlebar, &TitleBar::setLeftUpBtnStyle);
connect(m_titlebar, &TitleBar::updateImageWidName, m_showImageWidget, &ShowImageWidget::updateImagePath);
connect(m_showImageWidget, &ShowImageWidget::sendSuffixToToolbar, m_toolbar, &ToolBar::getSuffix);
}
//打开首先检测是否需要展示工具栏
void KyView::openState()
@ -224,6 +224,12 @@ void KyView::aboutShow()
m_information->move(this->width() - m_information->width(), 0);
}
}
m_aboutDialog = new KAboutDialog();
m_aboutDialog->setAttribute(Qt::WA_DeleteOnClose);
m_aboutDialog->setBodyTextVisiable(true);
this->initAboutDialog();
m_aboutDialog->move(this->geometry().center().x() - m_aboutDialog->width() / 2,
this->geometry().center().y() - m_aboutDialog->height() / 2);
m_aboutDialog->exec();

View File

@ -56,7 +56,6 @@ public:
~KyView();
static KyView *mutual; //指针类型静态成员变量
private:
int toolbarHeightValue;
int titlebarHeightValue;

View File

@ -121,6 +121,7 @@ ShowImageWidget::ShowImageWidget(QWidget *parent) : QWidget(parent)
m_ocrExportToTxt->setFlat(true);
m_ocrExportToTxt->setFixedSize(60, 24);
m_ocrExportToTxt->move(64, 8);
m_ocrExportToTxt->setEnabled(false);
ocrBtnWidStyle();
//绘制阴影
@ -443,17 +444,19 @@ void ShowImageWidget::startGetText()
ocrMode();
m_ocrWid->show();
m_ocrBtnWid->show();
m_ocrExportToTxt->setEnabled(false);
QVector<QString> result;
result.append(tr("OCR recognition..."));
m_ocrWid->setFormatedText(result);
}
void ShowImageWidget::setGetTextResult(QVector<QString> result)
{
m_ocrWid->setFormatedText(result);
m_ocrExportToTxt->setEnabled(true);
if (result.isEmpty()) {
m_ocrExportToTxt->setEnabled(false);
} else {
m_ocrExportToTxt->setEnabled(true);
}
}
//结束OCR
void ShowImageWidget::exitGetText()
@ -647,10 +650,8 @@ void ShowImageWidget::setMenuEnable()
m_print->setEnabled(m_isOpenSuccess);
if (m_movieImage || m_paperFormat == "svg") {
m_saveAs->setEnabled(false);
m_signImage->setEnabled(false);
} else {
m_saveAs->setEnabled(m_isOpenSuccess);
m_signImage->setEnabled(m_isOpenSuccess);
}
if (m_delOrNot == false) {
@ -660,6 +661,11 @@ void ShowImageWidget::setMenuEnable()
m_reName->setEnabled(m_isOpenSuccess);
m_deleteImage->setEnabled(m_isOpenSuccess);
}
if (SIGN_APP_NOT_SUPPORT.contains(m_paperFormat.toLower())) {
m_signImage->setEnabled(false);
} else {
m_signImage->setEnabled(true);
}
}
void ShowImageWidget::initInteraction()
@ -774,20 +780,29 @@ void ShowImageWidget::openFinish(QVariant var)
QString num;
int number = package.imageNumber; //在队列中的标签
m_movieImage = package.movieImage;
if (MOVIE_IMAGE_FORMAT.contains(m_paperFormat)) {
m_movieImage = true;
}
m_imageNeedUpdate = package.imageNeedUpdate;
m_imageShowWay = package.imageShowWay;
m_zoomFocus = package.zoomFocus;
m_leftUpPos = package.leftUpPos;
//根据number决定界面显示
if (imageNum(number)) {
return;
}
num = QString("%1").arg(proportion) + "%";
m_path = info.absolutePath(); //图片的路径
m_imagePath = info.absoluteFilePath();
m_paperFormat = info.suffix().toLower();
m_typeNum = number;
Q_EMIT sendSuffixToToolbar(m_paperFormat);
//根据number决定界面显示
if (imageNum(number)) {
return;
}
//重置ocr导出文本按钮的状态
if (m_ocrExportToTxt->isEnabled()) {
m_ocrExportToTxt->setEnabled(false);
}
//使用返回的信息进行设置界面
Q_EMIT toShowImage(); //给主界面--展示图片
//根据图片是否为空决定是否显示转圈圈

View File

@ -188,6 +188,7 @@ Q_SIGNALS:
void sendImageToProvider(QImage image); //给qml图片提供引擎图片
void viewExitOCRMode();
void startWayToSetTitleStyle(); //从相册打开看图
void sendSuffixToToolbar(QString suffix);
};
#endif // SHOWIMAGEWIDGET_H

View File

@ -68,5 +68,8 @@ static QStringList platForm = {"V10SP1-edu"}; //当前平台
static const QStringList EXTERNAL_START_APP = {"kylin-gallery"}; //外部启动的应用名
static const QString SIGN_APP_NAME = "kolourpaint";
static int recordCurrentProportion = 100; //记录当前图片缩放比例默认为100
#endif // SIZEDATE_H
static const QStringList SIGN_APP_NOT_SUPPORT = {"ras", "tga", "sr", "jng",
"jp2", "psd", "j2k", "apng"}; //画图软件不支持的格式
static const QStringList MOVIE_IMAGE_FORMAT = {"apng", "gif"}; //动图
static const QStringList OCR_SUPPORT = {"png", "jpg"}; // ocr支持的格式
#endif // SIZEDATE_H

View File

@ -444,20 +444,31 @@ void ToolBar::changeStyle()
"QCheckBox::indicator:checked{border:0px;border-radius:4px;background:transparent;"
"image: url(:/res/res/"
+ normalIconPath + "/1information_hover.png);}");
m_ocr->setStyleSheet("QPushButton{border:0px;border-radius:4px;background:transparent;background-image: "
"url(:/res/res/"
+ normalIconPath
+ "/1ocr.png);}"
"QPushButton::hover{border:0px;border-radius:4px;background:transparent;background-"
"image: url(:/res/res/"
+ normalIconPath
+ "/1ocr_hover.png);}"
"QPushButton::pressed{border:0px;border-radius:4px;background:transparent;background-"
"image: url(:/res/res/"
+ normalIconPath + "/1ocr_hover.png);}");
if (!m_isOpenSuccess) {
btnState();
} else {
if (m_imageSuffix != "" && OCR_SUPPORT.contains(m_imageSuffix)) {
m_ocr->setEnabled(true);
m_ocr->setStyleSheet(
"QPushButton{border:0px;border-radius:4px;background:transparent;background-image: "
"url(:/res/res/"
+ normalIconPath
+ "/1ocr.png);}"
"QPushButton::hover{border:0px;border-radius:4px;background:transparent;background-"
"image: url(:/res/res/"
+ normalIconPath
+ "/1ocr_hover.png);}"
"QPushButton::pressed{border:0px;border-radius:4px;background:transparent;background-"
"image: url(:/res/res/"
+ normalIconPath + "/1ocr_hover.png);}");
} else {
QString head = "url(:/res/res/" + damagedIconPath + "/";
QString num = "1";
QString headStyle = head + num;
m_ocr->setStyleSheet(btnStyle(headStyle + "ocr_damaged.png)"));
m_ocr->setEnabled(false);
}
m_reduce->setStyleSheet(
"QPushButton{border:0px;border-radius:4px;background:transparent;background-image: "
"url(:/res/res/"
@ -563,12 +574,11 @@ void ToolBar::changeStyle()
} else {
btnState();
}
if (!m_cutImage->isEnabled()) {
getImageType(false);
return;
}
m_cutImage->setStyleSheet(
"QPushButton{background:transparent;border:0px;border-radius:4px;background-image: "
"url(:/res/res/"
@ -633,21 +643,30 @@ void ToolBar::changeStyle()
"QCheckBox::indicator:checked{border:0px;border-radius:4px;background:transparent;"
"image: url(:/res/res/"
+ normalIconPath + "/information_hover.png);}");
m_ocr->setStyleSheet("QPushButton{border:0px;border-radius:4px;background:transparent;background-image: "
"url(:/res/res/"
+ normalIconPath
+ "/ocr.png);}"
"QPushButton::hover{border:0px;border-radius:4px;background:transparent;background-"
"image: url(:/res/res/"
+ normalIconPath
+ "/ocr_hover.png);}"
"QPushButton::pressed{border:0px;border-radius:4px;background:transparent;background-"
"image: url(:/res/res/"
+ normalIconPath + "/ocr_hover.png);}");
if (!m_isOpenSuccess) {
btnState();
} else {
if (m_imageSuffix != "" && OCR_SUPPORT.contains(m_imageSuffix)) {
m_ocr->setEnabled(true);
m_ocr->setStyleSheet(
"QPushButton{border:0px;border-radius:4px;background:transparent;background-image: "
"url(:/res/res/"
+ normalIconPath
+ "/ocr.png);}"
"QPushButton::hover{border:0px;border-radius:4px;background:transparent;background-"
"image: url(:/res/res/"
+ normalIconPath
+ "/ocr_hover.png);}"
"QPushButton::pressed{border:0px;border-radius:4px;background:transparent;background-"
"image: url(:/res/res/"
+ normalIconPath + "/ocr_hover.png);}");
} else {
QString head = "url(:/res/res/" + damagedIconPath + "/";
m_ocr->setStyleSheet(btnStyle(head + "ocr_damaged.png)"));
m_ocr->setEnabled(false);
}
m_reduce->setStyleSheet(
"QPushButton{border:0px;border-radius:4px;background:transparent;background-image: "
"url(:/res/res/"
@ -812,13 +831,14 @@ void ToolBar::getImageType(bool canCut)
QString head = "url(:/res/res/" + damagedIconPath + "/";
QString num = "1";
QString headStyle = head;
// m_ocr->setStyleSheet(btnStyle(headStyle + "ocr_damaged.png)"));
//判断是否能进行裁剪
if (m_isOpenSuccess) {
m_cutImage->setEnabled(canCut);
m_ocr->setEnabled(canCut);
// m_ocr->setEnabled(canCut);
} else {
m_cutImage->setEnabled(m_isOpenSuccess);
m_ocr->setEnabled(m_isOpenSuccess);
// m_ocr->setEnabled(m_isOpenSuccess);
}
if (!canCut) {
if ("ukui-dark" == nowThemeStyle || "ukui-black" == nowThemeStyle) {
@ -832,6 +852,11 @@ void ToolBar::getImageType(bool canCut)
}
}
void ToolBar::getSuffix(QString suffix)
{
m_imageSuffix = suffix;
}
void ToolBar::btnState()
{
QString head = "url(:/res/res/" + damagedIconPath + "/";

View File

@ -32,6 +32,7 @@ public:
void setButtonState(bool isOpenSuccess, bool isCanOperate); //设置工具栏按钮是否可点击--图片是否打开成功
QFrame *g_tooleWid; //布局
void getImageType(bool canCut);
void getSuffix(QString suffix); //拿图片的格式
private:
QString widRadius = QString("6px");
@ -64,6 +65,7 @@ private:
QString m_imagePath;
bool m_isOpenSuccess = false; //默认图片不进行操作,不是成功打开的状态
bool m_isCanOperate = false; //默认无权限,不能删除,不能操作
QString m_imageSuffix = ""; //图片后缀
void originalSize(); //原始尺寸
void adaptiveWidget(); //适应窗口
void rotate(); //旋转
@ -87,6 +89,7 @@ private:
void buttonSize(QSize acturalSize);
void platformType();
private Q_SLOTS: