diff --git a/data/guide/kylin-font-viewer/zh_CN/index.md b/data/guide/kylin-font-viewer/zh_CN/index.md
index 085303e..9dfa0e0 100644
--- a/data/guide/kylin-font-viewer/zh_CN/index.md
+++ b/data/guide/kylin-font-viewer/zh_CN/index.md
@@ -29,9 +29,9 @@
右击“我的字体”的字体列表会弹出菜单可以对字体进行添加字体、应用字体、卸载字体、导出字体、收藏字体、查看字体信息的操作。对于“系统字体”右键只可以进行添加字体、应用字体、收藏字体、查看字体信息的操作。
-![图 5 “我的字体”右键功能-big](image/5.png)
+![图 4 “我的字体”右键功能-big](image/5.png)
-![图 6 “系统字体”右键功能-big](image/6.png)
+![图 5 “系统字体”右键功能-big](image/6.png)
### 帮助和关于
diff --git a/data/translations/kylin-font-viewer_bo_CN.ts b/data/translations/kylin-font-viewer_bo_CN.ts
index 1440695..535bf37 100644
--- a/data/translations/kylin-font-viewer_bo_CN.ts
+++ b/data/translations/kylin-font-viewer_bo_CN.ts
@@ -32,6 +32,10 @@
གནས་སྐབས་མེད་པའི་ཡིག་གཟུགས།
+
+
+ བཤེར་འཚོལ་འབྲས་བུ་མེད་།
+
FontListView
@@ -206,6 +210,21 @@
款字体!
+
+ PopupMessage
+
+
+
+
+
+
+
+
+
+
+
+
+
PopupRemove
@@ -236,6 +255,21 @@
མི་འཆར་བ་
+
+ PopupMessage
+
+
+ བདམས་པའི་ཡིག་ཆ་སྒྲིག་སྦྱོར་བྱ་དགོས་མིན་?
+
+
+
+ རེད།
+
+
+
+ མེད།
+
+
TitleBar
@@ -251,8 +285,8 @@
སྒོ་རྒྱག་པ།
-
- ཟས་ཐོ།
+
+ འདེམས་ཚན་
diff --git a/data/translations/kylin-font-viewer_zh_CN.ts b/data/translations/kylin-font-viewer_zh_CN.ts
index 6772142..d9f67d2 100644
--- a/data/translations/kylin-font-viewer_zh_CN.ts
+++ b/data/translations/kylin-font-viewer_zh_CN.ts
@@ -233,6 +233,21 @@
不再显示
+
+ PopupMessage
+
+
+ 是否要安装所选文件?
+
+
+
+ 是
+
+
+
+ 否
+
+
TitleBar
@@ -248,8 +263,8 @@
关闭
-
- 菜单
+
+ 选项
@@ -290,5 +305,9 @@
暂无字体
+
+
+ 无搜索结果
+
diff --git a/include/core.h b/include/core.h
index 68da952..bcdfd3a 100644
--- a/include/core.h
+++ b/include/core.h
@@ -24,7 +24,7 @@ public:
bool uninstallFont(QString path, QString fontName); /* 卸载字体 */
bool copyFont(QString srcPath , QString dstPath); /* 复制字体 */
bool isSystemFont(QString path); /* 判断是否为系统字体 */
- bool applyFont(QString family); /* 应用字体 */
+ bool applyFont(QString family, QString path); /* 应用字体 */
QString ControlUsingFont(); /* 获取正在使用的字体名称 */
void updateFontList(); /* 更新字体列表 */
diff --git a/include/external.h b/include/external.h
index a768907..e3455bb 100644
--- a/include/external.h
+++ b/include/external.h
@@ -29,6 +29,7 @@ private:
QGSettings *m_gsettings = nullptr;
QGSettings *m_themeGsettings = nullptr;
QGSettings *m_contolGsettings = nullptr;
+ QGSettings *m_gtkGsettings = nullptr;
// QProcess *m_process = nullptr;
};
diff --git a/include/libfun.h b/include/libfun.h
index 73b3f9b..192c7e7 100644
--- a/include/libfun.h
+++ b/include/libfun.h
@@ -16,6 +16,7 @@ typedef struct _FontInformation
QString family; /* 系列 */
QString style; /* 样式 */
QString type; /* 种类 */
+ QString foundry; /* 铸造商 */
QString version; /* 版本 */
QString copyright; /* 版权 */
QString manufacturer; /* 商标 */
diff --git a/kylin-font-viewer.pro b/kylin-font-viewer.pro
index ec1948e..98c3e65 100644
--- a/kylin-font-viewer.pro
+++ b/kylin-font-viewer.pro
@@ -54,7 +54,8 @@ SOURCES += $$PWD/src/main.cc \
$$PWD/src/view/getfontthread.cc \
$$PWD/src/view/popuptips.cc \
$$PWD/src/view/blankpage.cc \
- $$PWD/src/view/rotatechangeinfo.cc
+ $$PWD/src/view/rotatechangeinfo.cc \
+ $$PWD/src/view/popupmessage.cc
HEADERS += $$PWD/include/core.h \
$$PWD/include/libfun.h \
@@ -80,7 +81,8 @@ HEADERS += $$PWD/include/core.h \
$$PWD/src/view/getfontthread.h \
$$PWD/src/view/popuptips.h \
$$PWD/src/view/blankpage.h \
- $$PWD/src/view/rotatechangeinfo.h
+ $$PWD/src/view/rotatechangeinfo.h \
+ $$PWD/src/view/popupmessage.h
# 翻译
TRANSLATIONS = data/translations/kylin-font-viewer_zh_CN.ts
diff --git a/src/core.cc b/src/core.cc
index 945e427..9515b0b 100644
--- a/src/core.cc
+++ b/src/core.cc
@@ -260,9 +260,47 @@ bool Core::isSystemFont(QString path)
return false;
}
-bool Core::applyFont(QString family)
+bool Core::applyFont(QString family, QString path)
{
- return this->m_external.applyFont(family);
+ QString foundryLast = ""; // 上个字体铸造商
+ QString foundryCurrent = ""; // 当前字体铸造商
+ QString foundryTarget = ""; // 目标字体铸造商
+ bool firstFont = true;
+
+ QString fontFamily = "";
+ bool isDiffFontExist = false; // 存在名字相同,铸造厂商不同的字体(默认为false)
+ // bool isSameFontExist = false; // 存在名字相同,铸造厂商相同的字体 (默认为false)
+
+ // 循环查找列表
+ for (int i = 0 ; i < this->m_fontData.count() ; i++) {
+ FontInformation item = this->m_fontData.at(i);
+
+ // 寻找目标字体,判断铸造商是否存在不同
+ if (item.family == family) {
+ qDebug() << item.foundry << item.family << item.path;
+ foundryCurrent = item.foundry;
+ // 判断当前是否为第一个被找到的字体文件
+ if (firstFont) {
+ firstFont = false;
+ foundryLast = item.foundry;
+ }
+ // 比较上一个字体和当前的字体的铸造商是否存在不同
+ if (QString::compare(foundryLast, foundryCurrent) != 0) {
+ isDiffFontExist = true;
+ }
+ if (item.path == path) {
+ foundryTarget = item.foundry;
+ }
+ foundryLast = foundryLast;
+ }
+ }
+ if (!isDiffFontExist) {
+ fontFamily = family;
+ } else {
+ fontFamily = family + " [" + foundryTarget + "]";
+ }
+
+ return this->m_external.applyFont(fontFamily);
}
void Core::slotStart(void)
@@ -331,4 +369,4 @@ bool Core::settingFontTips(bool state)
{
bool setTips = m_external.setFontIntoList(state);
return setTips;
-}
\ No newline at end of file
+}
diff --git a/src/external.cc b/src/external.cc
index 6ab6a46..1a6fe4c 100644
--- a/src/external.cc
+++ b/src/external.cc
@@ -2,6 +2,7 @@
#include
#include "include/external.h"
+#include "src/view/globalsizedata.h"
#define KYLIN_FONT_VIEWER_GSETTINGS "org.kylin.font.viewer.gsettings"
#define COLLECT_FONT_KEY "collect-font"
@@ -10,6 +11,9 @@
#define APPLY_FONT_KEY "system-font"
#define KYLIN_CONTROL_CENTER_GSETTINGS "org.ukui.control-center"
#define FONTS_LIST "fonts-list"
+#define KYLIN_GTK_GSTTINGS "org.mate.interface"
+#define FONT_NAME "font-name"
+#define DOC_FONT_KEY "document-font-name"
External::External()
{
@@ -28,7 +32,13 @@ External::External()
if (QGSettings::isSchemaInstalled(KYLIN_CONTROL_CENTER_GSETTINGS)) {
this->m_contolGsettings = new QGSettings(KYLIN_CONTROL_CENTER_GSETTINGS);
} else {
- qCritical() << "Error : External , External , create theme gsettings fail";
+ qCritical() << "Error : External , External , create control gsettings fail";
+ }
+
+ if (QGSettings::isSchemaInstalled(KYLIN_GTK_GSTTINGS)) {
+ this->m_gtkGsettings = new QGSettings(KYLIN_GTK_GSTTINGS);
+ } else {
+ qCritical() << "Error : External , External , create GTK gsettings fail";
}
// m_process = new QProcess(this);
}
@@ -44,6 +54,9 @@ External::~External()
if (this->m_contolGsettings != nullptr) {
delete this->m_contolGsettings;
}
+ if (this->m_gtkGsettings != nullptr) {
+ delete this->m_gtkGsettings;
+ }
// if (this->m_process != nullptr) {
// delete this->m_process;
// }
@@ -120,8 +133,22 @@ bool External::applyFont(QString family)
if (setFontIntoList(family) != true) {
return false;
}
-
- this->m_themeGsettings->set(APPLY_FONT_KEY, family);
+
+ QString fontStyle = family + " " + QString::number(GlobalSizeData::getInstance()->g_fontSize, 'f', 1);
+
+ this->m_themeGsettings->set(APPLY_FONT_KEY, family);// 改变主题字体
+ this->m_gtkGsettings->set(FONT_NAME, fontStyle); // 改变GTK的字体
+ this->m_gtkGsettings->set(DOC_FONT_KEY, fontStyle); // 改变GTK的文档字体
+
+ const int fontSize = GlobalSizeData::getInstance()->g_fontSize;
+ qDebug() << fontSize;
+ QDBusMessage message =QDBusMessage::createSignal("/KGlobalSettings", "org.kde.KGlobalSettings", "slotFontChange");
+ QList args;
+ args.append(fontSize);
+ args.append(family);
+ message.setArguments(args);
+ QDBusConnection::sessionBus().send(message); // 使用dbus改变GTK标题栏的字体
+
// QString cmd = "ukui-control-center -m fonts";
// m_process->startDetached(cmd);
@@ -211,4 +238,4 @@ bool External::setFontIntoList(bool state)
this->m_gsettings->set(TIPS_FONT_KEY , state);
return true;
-}
\ No newline at end of file
+}
diff --git a/src/libfun.cc b/src/libfun.cc
index 374e14f..5882f91 100644
--- a/src/libfun.cc
+++ b/src/libfun.cc
@@ -95,7 +95,8 @@ QList LibFun::getAllFontInformation(void)
FcConfig *config = FcInitLoadConfigAndFonts();
FcPattern *pat = FcPatternCreate();
- FcObjectSet *os = FcObjectSetBuild(FC_FILE , FC_FAMILY , FC_STYLE , FC_INDEX , NULL);
+// FcObjectSet *os = FcObjectSetBuild(FC_FILE , FC_FAMILY , FC_STYLE , FC_INDEX , NULL);
+ FcObjectSet *os = FcObjectSetBuild(FC_FILE , FC_FAMILY , FC_STYLE, FC_FOUNDRY, FC_INDEX , NULL); // 构建对象(字体文件路径,字体名,类别,字体铸造商)
FcFontSet *fs = FcFontList(config , pat , os);
@@ -106,6 +107,7 @@ QList LibFun::getAllFontInformation(void)
FcChar8 *path = NULL;
FcChar8 *family = NULL;
FcChar8 *style = NULL;
+ FcChar8 *foundry = NULL;
int index;
FcPattern *font = fs->fonts[i];
@@ -113,17 +115,19 @@ QList LibFun::getAllFontInformation(void)
if (FcPatternGetString(font , FC_FILE , 0 , &path) == FcResultMatch &&
FcPatternGetString(font , FC_FAMILY , 0 , &family) == FcResultMatch &&
FcPatternGetString(font , FC_STYLE , 0 , &style) == FcResultMatch &&
+ FcPatternGetString(font , FC_FOUNDRY , 0 , &foundry) == FcResultMatch &&
FcPatternGetInteger(font , FC_INDEX , 0 , &index) == FcResultMatch)
{
item.path = QString((char *)path);
item.family = QString((char *)family);
item.style = QString((char *)style);
+ item.foundry = QString((char *)foundry);
}
/* 对字体文件进行判断(判断后缀名是否为.ttf .otf)*/
- if (!chooseFontFile(item.path)) {
- continue;
- }
+ // if (!chooseFontFile(item.path)) {
+ // continue;
+ // }
gchar *fontData = NULL;
gsize fontDataLenth;
@@ -406,19 +410,19 @@ QString LibFun::getFontInfo(QString path)
QString ret;
ret.clear();
- // 判断后缀
- if (!chooseFontFile(path)) {
- qDebug() << "判断字体文件后缀,字体文件损坏:" <<__FILE__<< ","<<__FUNCTION__<<","<<__LINE__;
- ret = path;
- return ret;
- }
+ // // 判断后缀
+ // if (!chooseFontFile(path)) {
+ // qDebug() << "判断字体文件后缀,字体文件损坏:" <<__FILE__<< ","<<__FUNCTION__<<","<<__LINE__;
+ // ret = path;
+ // return ret;
+ // }
// 判断文件type类型
- if (isFontFile(path) != true) {
- qDebug() << "判断字体文件type类型,字体文件损坏:" <<__FILE__<< ","<<__FUNCTION__<<","<<__LINE__;
- ret = path;
- return ret;
- }
+ // if (isFontFile(path) != true) {
+ // qDebug() << "判断字体文件type类型,字体文件损坏:" <<__FILE__<< ","<<__FUNCTION__<<","<<__LINE__;
+ // ret = path;
+ // return ret;
+ // }
std::string str = path.toStdString();
FcChar8* file = (FcChar8*)(str.c_str());
@@ -456,4 +460,4 @@ bool LibFun::isFontFile(QString path)
}
return false;
-}
\ No newline at end of file
+}
diff --git a/src/main.cc b/src/main.cc
index dfeb0a3..f2ef181 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -6,6 +6,7 @@
#include
#include
#include
+#include
/* 适配SDK */
#include
@@ -23,10 +24,21 @@ int main(int argc , char *argv[])
::kabase::WindowManage::setScalingProperties();
//加在最上面的原因:防止QApplication将(-title)参数吞掉,导致拿不到
- QString fontFileName;
+ QString fontFileName = "";
if (argc > 1) {
- fontFileName = argv[1];
+ for(int i=1; i= QT_VERSION_CHECK(5, 12, 0))
diff --git a/src/view/basepreviewarea.cc b/src/view/basepreviewarea.cc
index a003cda..de483cb 100644
--- a/src/view/basepreviewarea.cc
+++ b/src/view/basepreviewarea.cc
@@ -28,7 +28,7 @@ BasePreviewArea::~BasePreviewArea()
void BasePreviewArea::init()
{
this->setMinimumWidth(m_width);
- this->setMinimumHeight(m_height);
+ // this->setMinimumHeight(m_height);
this->setFocusPolicy(Qt::ClickFocus);
m_previewEdit = new QLineEdit(this); /* 预览编辑框 */
@@ -63,9 +63,25 @@ void BasePreviewArea::init()
m_fontSizeSlider->installEventFilter(this);
+ switch (GlobalSizeData::getInstance()->m_currentMode)
+ {
+ case CurrentMode::PCMode:
+ slotChangePCSize();
+ break;
+ case CurrentMode::HMode:
+ slotChangeFaltSize();
+ break;
+ case CurrentMode::VMode:
+ slotChangeFaltSize();
+ break;
+ }
+
connect(m_fontSizeSlider, &QSlider::valueChanged, this, &BasePreviewArea::slotChangSize);
connect(m_previewEdit, &QLineEdit::textChanged, this, &BasePreviewArea::slotPreviewValue);
connect(GlobalSizeData::getInstance(), &GlobalSizeData::sigFontNameChange, this, &BasePreviewArea::slotChangeFontName);
+ connect(GlobalSizeData::getInstance(), &GlobalSizeData::sigPCMode, this, &BasePreviewArea::slotChangePCSize);
+ connect(GlobalSizeData::getInstance(), &GlobalSizeData::sigHFlatMode, this, &BasePreviewArea::slotChangeFaltSize);
+ connect(GlobalSizeData::getInstance(), &GlobalSizeData::sigVFlatMode, this, &BasePreviewArea::slotChangeFaltSize);
return;
}
@@ -146,4 +162,18 @@ void BasePreviewArea::paintEvent(QPaintEvent *event)
p.drawRoundedRect(opt.rect, 0, 0);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
p.fillPath(rectPath, brush);
-}
\ No newline at end of file
+}
+
+void BasePreviewArea::slotChangeFaltSize()
+{
+ this->setFixedHeight(80);
+ m_previewEdit->setFixedHeight(60);
+ return;
+}
+
+void BasePreviewArea::slotChangePCSize()
+{
+ this->setFixedHeight(50);
+ m_previewEdit->setFixedHeight(40);
+ return;
+}
diff --git a/src/view/basepreviewarea.h b/src/view/basepreviewarea.h
index 8bc8282..9a8e18f 100644
--- a/src/view/basepreviewarea.h
+++ b/src/view/basepreviewarea.h
@@ -49,6 +49,8 @@ private slots:
public slots:
void slotChangFont(QString fontName); /* 改变字体 */
void slotChangeFontName(); /* 改变字体名称 */
+ void slotChangeFaltSize();
+ void slotChangePCSize();
};
diff --git a/src/view/blankpage.cc b/src/view/blankpage.cc
index fa57134..2f566a7 100644
--- a/src/view/blankpage.cc
+++ b/src/view/blankpage.cc
@@ -108,4 +108,14 @@ void BlankPage::changeTheme()
QIcon blankIcon = QIcon(":/data/image/dark.svg");
m_blankLabel->setPixmap(blankIcon.pixmap(blankIcon.actualSize(IMAGESIZE)));
}
-}
\ No newline at end of file
+}
+
+void BlankPage::changeSearchText()
+{
+ m_blankTextLabel->setText(tr("No Search Results"));
+}
+
+void BlankPage::changeBlankText()
+{
+ m_blankTextLabel->setText(tr("No Font"));
+}
diff --git a/src/view/blankpage.h b/src/view/blankpage.h
index 25b7308..d1660a1 100644
--- a/src/view/blankpage.h
+++ b/src/view/blankpage.h
@@ -22,6 +22,8 @@ public:
void initLayout(); /* 设置组件样式 */
void initGsetting();
void changeTheme();
+ void changeSearchText(); /* 更改文案 */
+ void changeBlankText(); /* 更改文案 */
protected:
void paintEvent(QPaintEvent *event) override; /* 绘制事件 */
diff --git a/src/view/fontlistdelegate.cc b/src/view/fontlistdelegate.cc
index 924c458..0b99299 100644
--- a/src/view/fontlistdelegate.cc
+++ b/src/view/fontlistdelegate.cc
@@ -12,6 +12,10 @@
QPoint FontListDelegate::m_collectPoint = QPoint(0, 0);
QSize FontListDelegate::m_collectSize = QSize(0, 0);
+const QString COLLECT_ICON_W = QString(":/data/image/ukui-play-love-symbolic-w.svg");
+const QString COLLECT_ICON_B = QString(":/data/image/ukui-play-love-symbolic-b.svg");
+const QString COLLECT_ICON_R = QString(":/data/image/ukui-play-love-red.svg");
+
FontListDelegate::FontListDelegate(FontListView *fontList)
{
m_fontList = fontList;
@@ -159,6 +163,8 @@ void FontListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
painter->drawText(displayRect, fontDisplay, optionText);
painter->restore();
+ painter->setRenderHints(QPainter::Antialiasing|QPainter::SmoothPixmapTransform);
+
// 收藏图标
QPoint collectPoint = QPoint(itemRect.right() - 35, itemRect.top() + 15);
QSize collectSize = QSize(18, 16);
@@ -170,26 +176,68 @@ void FontListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
/* 深浅主题控件样式 */
if (GlobalSizeData::THEME_COLOR == GlobalSizeData::UKUILight) {
collectePixmap =
- QPixmap(QIcon(":/data/image/ukui-play-love-symbolic-b.svg").pixmap(collecteRect.size()));
+ QPixmap(QIcon(COLLECT_ICON_B).pixmap(collecteRect.size()));
} else {
collectePixmap =
- QPixmap(QIcon(":/data/image/ukui-play-love-symbolic-w.svg").pixmap(collecteRect.size()));
+ QPixmap(QIcon(COLLECT_ICON_W).pixmap(collecteRect.size()));
}
} else {
- collectePixmap = QPixmap(QIcon(":/data/image/ukui-play-love-red.svg").pixmap(collecteRect.size()));
+ collectePixmap = QPixmap(QIcon(COLLECT_ICON_R).pixmap(collecteRect.size()));
}
painter->drawPixmap(collecteRect, collectePixmap);
QColor highLightColor = QApplication::palette().highlight().color();
+ QColor lightHoverColor = QColor("#EBEBEB");
+ QColor darkHoverColor = QColor("#333333");
// 鼠标悬停/选中,改变背景颜色
- if (option.state.testFlag(QStyle::State_MouseOver)) {
+ if (option.state.testFlag(QStyle::State_HasFocus) || fontInstall) {
+ FontListDelegate::m_collectPoint = collecteRectF.topLeft().toPoint();
+ FontListDelegate::m_collectSize = collecteRectF.size().toSize();
+ painter->fillPath(path, QBrush(highLightColor));
+ painter->setPen(QPen(Qt::white));
+
+ painter->setFont(QFont(painter->fontInfo().family(), 14));
+ optionText.setAlignment(Qt::AlignLeft | Qt::AlignBottom);
+ painter->drawText(infomationRect, fontInformation, optionText);
+
+ painter->setFont(textFont);
+ optionText.setAlignment(Qt::AlignLeft | Qt::AlignTop);
+ painter->drawText(displayRect, fontDisplay, optionText);
+
+ if (fontCollect == GlobalSizeData::CollectType::NotCollected) {
+ collectePixmap =
+ QPixmap(QIcon(COLLECT_ICON_W).pixmap(collecteRect.size()));
+ } else {
+ collectePixmap = QPixmap(QIcon(COLLECT_ICON_R).pixmap(collecteRect.size()));
+ }
+ painter->drawPixmap(collecteRect, collectePixmap);
+
+ path.setFillRule(Qt::WindingFill);
+ path.addRoundedRect(itemRect, 0, 0);
+ } else if (option.state.testFlag(QStyle::State_MouseOver)) {
FontListDelegate::m_collectPoint = collecteRectF.topLeft().toPoint();
FontListDelegate::m_collectSize = collecteRectF.size().toSize();
- painter->fillPath(path, QBrush(highLightColor));
- painter->setPen(QPen(Qt::white));
+ if (GlobalSizeData::getInstance()->THEME_COLOR == GlobalSizeData::ThemeColor::UKUILight) {
+ painter->fillPath(path, QBrush(lightHoverColor));
+ painter->setPen(QPen(Qt::black));
+ if (fontCollect == GlobalSizeData::CollectType::NotCollected) {
+ collectePixmap = QPixmap(QIcon(COLLECT_ICON_B).pixmap(collecteRect.size()));
+ } else {
+ collectePixmap = QPixmap(QIcon(COLLECT_ICON_R).pixmap(collecteRect.size()));
+ }
+ } else {
+ painter->fillPath(path, QBrush(darkHoverColor));
+ painter->setPen(QPen(Qt::white));
+ if (fontCollect == GlobalSizeData::CollectType::NotCollected) {
+ collectePixmap = QPixmap(QIcon(COLLECT_ICON_W).pixmap(collecteRect.size()));
+ } else {
+ collectePixmap = QPixmap(QIcon(COLLECT_ICON_R).pixmap(collecteRect.size()));
+ }
+ }
+ painter->drawPixmap(collecteRect, collectePixmap);
painter->setFont(QFont(painter->fontInfo().family(), 14));
optionText.setAlignment(Qt::AlignLeft | Qt::AlignBottom);
@@ -199,39 +247,9 @@ void FontListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
optionText.setAlignment(Qt::AlignLeft | Qt::AlignTop);
painter->drawText(displayRect, fontDisplay, optionText);
- if (fontCollect == GlobalSizeData::CollectType::NotCollected) {
- collectePixmap =
- QPixmap(QIcon(":/data/image/ukui-play-love-symbolic-w.svg").pixmap(collecteRect.size()));
- } else {
- collectePixmap = QPixmap(QIcon(":/data/image/ukui-play-love-red.svg").pixmap(collecteRect.size()));
- }
- painter->drawPixmap(collecteRect, collectePixmap);
-
path.setFillRule(Qt::WindingFill);
path.addRoundedRect(itemRect, 0, 0);
- } else if (option.state.testFlag(QStyle::State_HasFocus) || fontInstall) {
- painter->fillPath(path, QBrush(highLightColor));
- painter->setPen(QPen(Qt::white));
-
- painter->setFont(QFont(painter->fontInfo().family(), 14));
- optionText.setAlignment(Qt::AlignLeft | Qt::AlignBottom);
- painter->drawText(infomationRect, fontInformation, optionText);
-
- painter->setFont(textFont);
- optionText.setAlignment(Qt::AlignLeft | Qt::AlignTop);
- painter->drawText(displayRect, fontDisplay, optionText);
-
- if (fontCollect == GlobalSizeData::CollectType::NotCollected) {
- collectePixmap =
- QPixmap(QIcon(":/data/image/ukui-play-love-symbolic-w.svg").pixmap(collecteRect.size()));
- } else {
- collectePixmap = QPixmap(QIcon(":/data/image/ukui-play-love-red.svg").pixmap(collecteRect.size()));
- }
- painter->drawPixmap(collecteRect, collectePixmap);
-
- path.setFillRule(Qt::WindingFill);
- path.addRoundedRect(itemRect, 0, 0);
}
painter->restore();
}
diff --git a/src/view/fontlistview.cc b/src/view/fontlistview.cc
index d98a39f..75e2a9b 100644
--- a/src/view/fontlistview.cc
+++ b/src/view/fontlistview.cc
@@ -67,6 +67,9 @@ void FontListView::setSlotConnet()
connect(m_exportFontAction, &QAction::triggered, this, &FontListView::slotExportFont);
connect(m_collectFontAction, &QAction::triggered, this, &FontListView::slotCollectFont);
connect(m_checkFontAction, &QAction::triggered, this, &FontListView::slotCheckFont);
+ connect(m_fontModel, &FontListModel::sigGetAllFontOver, this, [=](){
+ m_firstOpen = false;
+ });
return;
}
@@ -186,7 +189,11 @@ void FontListView::slotFilterFontByReg(QString fontSearch)
m_fontFilter->setFilterRegExp(QRegExp(fontSearch, Qt::CaseInsensitive, QRegExp::FixedString));
if (m_fontFilter->rowCount() == 0) {
- emit sigBlankPage();
+ if (m_fontSearch == "") {
+ emit sigBlankPage();
+ } else {
+ emit sigSearchFontBlankPage();
+ }
} else {
emit sigFontPage();
}
@@ -230,7 +237,8 @@ void FontListView::slotApplyFont()
// 将过滤index转换为model的index
QModelIndex fontIndex = m_fontFilter->mapToSource(this->currentIndex());
QString fontName = fontIndex.data(GlobalSizeData::FontName).toString(); /* 获取字体Path */
- Core::getInstance()->applyFont(fontName);
+ QString fontPath = fontIndex.data(GlobalSizeData::FontPath).toString();
+ Core::getInstance()->applyFont(fontName, fontPath);
this->update();
@@ -276,7 +284,11 @@ void FontListView::slotCollectFont()
QString fontPath = fontIndex.data(GlobalSizeData::FontPath).toString(); /* 获取字体path */
m_fontModel->collectFont(fontPath);
if (m_fontFilter->rowCount() == 0) {
- emit sigBlankPage();
+ if (m_fontSearch == "") {
+ emit sigBlankPage();
+ } else {
+ emit sigSearchFontBlankPage();
+ }
} else {
emit sigFontPage();
}
@@ -360,9 +372,10 @@ bool FontListView::isControlApplyFont()
void FontListView::clickFontFileInstall(QStringList fontList)
{
- m_fontList = fontList;
+ addFontByOtherWay(fontList);
+
+ // connect(m_fontModel, &FontListModel::sigGetAllFontOver,this, &FontListView::slotClickFontFile);
- connect(m_fontModel, &FontListModel::sigGetAllFontOver,this, &FontListView::slotClickFontFile);
return;
}
@@ -475,17 +488,53 @@ void FontListView::showFontTips()
void FontListView::addFontByOtherWay(QStringList list)
{
- if (Core::getInstance()->getSettingFontTips()) {
- if (m_popupTips == nullptr) {
- m_popupTips = new PopupTips(this);
- }
- m_popupTips->show();
- m_popupTips->disconnect();
- connect(m_popupTips, &PopupTips::signalWidgetClose, [=](){
- checkFontFile(list);
+ for (int i = 0; i < list.size(); i++) {
+ m_fontList<show();
+ m_popupBox->disconnect();
+ connect(m_popupBox, &PopupMessage::signalClickYes, [=](){
+
+ if (Core::getInstance()->getSettingFontTips()) {
+ if (m_popupTips == nullptr) {
+ m_popupTips = new PopupTips(this);
+ }
+ m_popupTips->show();
+ m_popupTips->disconnect();
+ connect(m_popupTips, &PopupTips::signalWidgetClose, [=](){
+ slotClickFontFile();
+ });
+ } else {
+ slotClickFontFile();
+ }
+ if (m_popupBox != nullptr) {
+ delete m_popupBox;
+ m_popupBox = nullptr;
+ }
+ });
+ connect(m_popupBox, &PopupMessage::signalClickNo, [=](){
+ m_fontList.clear();
+ if (m_popupBox != nullptr) {
+ delete m_popupBox;
+ m_popupBox = nullptr;
+ }
+ });
+ return;
+}
diff --git a/src/view/fontlistview.h b/src/view/fontlistview.h
index b22d36d..3e4b403 100644
--- a/src/view/fontlistview.h
+++ b/src/view/fontlistview.h
@@ -16,6 +16,7 @@
#include "popupinstallfail.h"
#include "popupfontinfo.h"
#include "popuptips.h"
+#include "popupmessage.h"
class FontListDelegate;
class FontListView : public QListView
@@ -44,6 +45,7 @@ public:
void showFontTips();
void setFontTips(QStringList list);
void addFontByOtherWay(QStringList list);
+ void showTipsByClickFontFile();
private:
QMenu *m_funcMenu = nullptr; /* 右键菜单 */
@@ -63,6 +65,7 @@ private:
PopupInstallFail *m_popupInstallFail = nullptr; /* 安装失败 */
PopupFontInfo *m_popupFontInfo = nullptr; /* 字体信息 */
PopupTips *m_popupTips = nullptr; /* 字体提示 */
+ PopupMessage *m_popupBox = nullptr; /* 安装字体提示 */
int m_fontSize = 24; /* 预览初始字号 */
QString m_previewValue = tr("Build the core strength of Chinese operating system");
@@ -71,12 +74,14 @@ private:
QStringList m_fontList;
QStringList m_fontInstallList;
+ bool m_firstOpen = true;
signals:
void sigGetAllFont();
void sigChangeFont(QString fontName);
void sigBlankPage();
void sigFontPage();
+ void sigSearchFontBlankPage();
public slots:
void slotFilterFontByReg(QString fontSearch); /* 根据字符串过滤字体 */
diff --git a/src/view/fontwid.cc b/src/view/fontwid.cc
index 852f0a4..8e8b3e8 100644
--- a/src/view/fontwid.cc
+++ b/src/view/fontwid.cc
@@ -30,6 +30,7 @@ void FontWidget::setWidgetUi()
// 堆栈窗口
m_stackedWid = new QStackedWidget(this);
m_blankPage = new BlankPage(this);
+ m_searchBlankPage = new BlankPage(this);
m_fontView = new FontListView();
@@ -42,6 +43,7 @@ void FontWidget::setWidgetUi()
m_stackedWid->addWidget(m_blankPage);
m_stackedWid->addWidget(m_fontView);
+ m_stackedWid->addWidget(m_searchBlankPage);
m_stackedWid->setCurrentIndex(1);
@@ -86,6 +88,7 @@ void FontWidget::setSlotConnet()
/* 应用字体 */
connect(m_fontView, &FontListView::sigChangeFont, m_previewArea, &BasePreviewArea::slotChangFont);
connect(m_fontView, &FontListView::sigBlankPage, this, &FontWidget::slotShowBlankPage);
+ connect(m_fontView, &FontListView::sigSearchFontBlankPage, this, &FontWidget::slotShowSearchBlankPage);
connect(m_fontView, &FontListView::sigFontPage, this, &FontWidget::slotShowFontPage);
return;
}
@@ -182,40 +185,20 @@ void FontWidget::slotWindowState(QString state)
void FontWidget::useFontFileOpen(QString fontFile)
{
qDebug() << "使用字体文件打开:" <<__FILE__<< ","<<__FUNCTION__<<","<<__LINE__;
- /* 添加 安装字体 SDK的打点 */
- GlobalSizeData::getInstance()->addFontSDKPoint();
+ QStringList installFontList;
+ installFontList = fontFile.split("/n/n");
QStringList fontList;
- fontList.clear();
- QStringList unFontList;
- unFontList.clear();
- int num = 0;
-
- if (fontFile.isEmpty()) {
+ for (int i = 0; i < installFontList.size(); i++) {
+ if (getFontFile(installFontList[i])) {
+ fontList << installFontList[i];
+ }
+ }
+ if (fontList.size() == 0) {
return;
}
+ m_fontView->clickFontFileInstall(fontList);
- QFileInfo fileinfo;
- fileinfo = QFileInfo(fontFile);
- QString fileName = fileinfo.fileName(); /* 文件名 */
-
- if (getFontFile(fontFile)) {
- if (Core::getInstance()->judgeBadFontFile(fontFile)) {
- unFontList.insert(num, fileName);
- } else {
- fontList.insert(num, fontFile);
- }
- } else {
- unFontList.insert(num, fileName);
- }
-
- if (unFontList.size() != 0) {
- PopupInstallFail *m_popupInstallFail = new PopupInstallFail(unFontList, this);
- m_popupInstallFail->show();
- } else {
- m_fontView->clickFontFileInstall(fontList);
- }
-
return;
}
@@ -228,9 +211,7 @@ bool FontWidget::getFontFile(QString fileName)
if (fileInfo.exists()) {
if (fileInfo.isFile()) {
- if (isFontFile(fileName)) {
- return true;
- }
+ return true;
}
}
return false;
@@ -238,25 +219,25 @@ bool FontWidget::getFontFile(QString fileName)
void FontWidget::cilckFontFile(QString fontFile)
{
- qDebug() << "点击字体文件安装" <<__FILE__<< ","<<__FUNCTION__<<","<<__LINE__;
+ qDebug() << "点击字体文件安装 fontFile ==" << fontFile <<__FILE__<< ","<<__FUNCTION__<<","<<__LINE__;
/* 添加 安装字体 SDK的打点 */
- GlobalSizeData::getInstance()->addFontSDKPoint();
+ // GlobalSizeData::getInstance()->addFontSDKPoint();
+ QStringList installFontList;
+ installFontList = fontFile.split("/n/n");
QStringList fontList;
- fontList.clear();
- QStringList unFontList;
- unFontList.clear();
- int num = 0;
-
- if (fontFile.isEmpty()) {
+ for (int i = 0; i < installFontList.size(); i++) {
+ if (getFontFile(installFontList[i])) {
+ fontList << installFontList[i];
+ }
+ }
+ if (fontList.size() == 0) {
return;
}
- QStringList installFontList;
- installFontList.insert(num, fontFile);
// m_fontView->checkFontFile(installFontList);
- m_fontView->addFontByOtherWay(installFontList);
+ m_fontView->clickFontFileInstall(fontList);
return;
}
@@ -264,6 +245,7 @@ void FontWidget::cilckFontFile(QString fontFile)
void FontWidget::slotShowBlankPage()
{
m_stackedWid->setCurrentIndex(0);
+ m_blankPage->changeBlankText();
return;
}
@@ -271,4 +253,11 @@ void FontWidget::slotShowFontPage()
{
m_stackedWid->setCurrentIndex(1);
return;
-}
\ No newline at end of file
+}
+
+void FontWidget::slotShowSearchBlankPage()
+{
+ m_stackedWid->setCurrentIndex(2);
+ m_searchBlankPage->changeSearchText();
+ return;
+}
diff --git a/src/view/fontwid.h b/src/view/fontwid.h
index 6224a41..3751922 100644
--- a/src/view/fontwid.h
+++ b/src/view/fontwid.h
@@ -45,6 +45,7 @@ private:
//堆栈窗体
QStackedWidget *m_stackedWid;
BlankPage *m_blankPage = nullptr;
+ BlankPage *m_searchBlankPage = nullptr;
int m_fontSize;
@@ -56,5 +57,6 @@ public slots:
void slotWindowState(QString state);
void slotShowBlankPage();
void slotShowFontPage();
+ void slotShowSearchBlankPage();
};
#endif // FONTWIDGET_H
diff --git a/src/view/getfontthread.cc b/src/view/getfontthread.cc
index f20afd5..5eb38c7 100644
--- a/src/view/getfontthread.cc
+++ b/src/view/getfontthread.cc
@@ -16,6 +16,9 @@ GetFontThread::GetFontThread(QList allFontData, QList collec
void GetFontThread::run()
{
for (int i = 0; i < m_allFontData.size(); i++) {
+ if (!chooseFontFile(m_allFontData[i].path)) {
+ continue;
+ }
if (m_fontItemsHash.contains(m_allFontData[i].path)) {
continue;
@@ -48,4 +51,20 @@ void GetFontThread::run()
emit sigCreatItem(m_allFontData[i].path, newItem);
}
return;
-}
\ No newline at end of file
+}
+
+bool GetFontThread::chooseFontFile(QString path)
+{
+ QStringList list = path.split(".");
+ QString fontTypeTTF = "ttf";
+ QString fontTypeOTF = "otf";
+ QString fontType = list.at(list.size()-1);
+
+ if (fontType.compare(fontTypeTTF, Qt::CaseInsensitive) == 0) {
+ return true;
+ } else if (fontType.compare(fontTypeOTF, Qt::CaseInsensitive) == 0) {
+ return true;
+ }
+
+ return false;
+}
diff --git a/src/view/getfontthread.h b/src/view/getfontthread.h
index aae08c0..e9f5f44 100644
--- a/src/view/getfontthread.h
+++ b/src/view/getfontthread.h
@@ -18,6 +18,8 @@ private:
QList m_collectFontData; /* 收藏字体 */
QHash m_fontItemsHash; /* 字体hash <字体path, list的item>*/
int m_fontSize;
+
+ bool chooseFontFile(QString path);
signals:
void sigCreatItem(QString path, QStandardItem *newItem);
diff --git a/src/view/globalsizedata.cc b/src/view/globalsizedata.cc
index 1dfd100..395e5e5 100644
--- a/src/view/globalsizedata.cc
+++ b/src/view/globalsizedata.cc
@@ -81,12 +81,12 @@ void GlobalSizeData::getSystemTheme()
void GlobalSizeData::getSystemFontSize()
{
/* 获取系统初始字体 */
- double systemFontSize = kdk::GsettingMonitor::getSystemFontSize().toDouble();
- qInfo() << "system systemFontSize : " << systemFontSize;
+ g_fontSize = kdk::GsettingMonitor::getSystemFontSize().toDouble();
+ qInfo() << "system systemFontSize : " << g_fontSize;
- g_font14pxToPt = (systemFontSize * (14.00 / 11)) - 3;
- g_font16pxToPt = (systemFontSize * (16.00 / 11)) - 3;
- g_font18pxToPt = (systemFontSize * (18.00 / 11)) - 3;
+ g_font14pxToPt = (g_fontSize * (14.00 / 11)) - 3;
+ g_font16pxToPt = (g_fontSize * (16.00 / 11)) - 3;
+ g_font18pxToPt = (g_fontSize * (18.00 / 11)) - 3;
qDebug() << "Info : system init font : 14 ---> " << g_font14pxToPt << "16 ---> " << g_font16pxToPt << "18 ---> " << g_font16pxToPt;
@@ -217,6 +217,7 @@ void GlobalSizeData::getSystemDBusInfo()
{
m_rotateChange = new RotateChangeInfo(this);
connect(m_rotateChange, &RotateChangeInfo::sigRotationChanged, this, &GlobalSizeData::slotChangeModel);
+ getCurrentMode();
return;
}
@@ -254,4 +255,4 @@ CurrentMode GlobalSizeData::getCurrentMode()
}
}
return m_currentMode;
-}
\ No newline at end of file
+}
diff --git a/src/view/globalsizedata.h b/src/view/globalsizedata.h
index 4aaa8f7..0ce76f4 100644
--- a/src/view/globalsizedata.h
+++ b/src/view/globalsizedata.h
@@ -62,7 +62,7 @@ public:
};
double g_transparency; /* 毛玻璃透明度 */
- int g_fontSize; /* 字号 */
+ double g_fontSize; /* 字号 */
/* 字体监控 */
double g_font14pxToPt;
diff --git a/src/view/popupfontinfo.cc b/src/view/popupfontinfo.cc
index edc86f2..1a2b1ab 100644
--- a/src/view/popupfontinfo.cc
+++ b/src/view/popupfontinfo.cc
@@ -189,11 +189,17 @@ void PopupFontInfo::setWidegtUi()
m_cancelBtn->setFixedHeight(36);
m_cancelBtn->setText(tr("Cancel"));
+ initWidgetStyle();
+
connect(m_cancelBtn, &QPushButton::clicked, this, &PopupFontInfo::slotCancelClick);
connect(m_continueBtn, &QPushButton::clicked, this, &PopupFontInfo::slotContinueClick);
connect(GlobalSizeData::getInstance(), &GlobalSizeData::sigFontChange, this, &PopupFontInfo::changeFontSize);
connect(GlobalSizeData::getInstance(), &GlobalSizeData::sigFontNameChange, this, &PopupFontInfo::slotChangeFontName);
+ connect(GlobalSizeData::getInstance(), &GlobalSizeData::sigPCMode, this, &PopupFontInfo::slotChangePCSize);
+ connect(GlobalSizeData::getInstance(), &GlobalSizeData::sigHFlatMode, this, &PopupFontInfo::slotChangeFaltSize);
+ connect(GlobalSizeData::getInstance(), &GlobalSizeData::sigVFlatMode, this, &PopupFontInfo::slotChangeFaltSize);
+
return;
}
@@ -241,7 +247,8 @@ void PopupFontInfo::setWidLayout()
m_widget->setLayout(m_vGridLayout);
m_scrollArea = new QScrollArea(this);
- m_scrollArea->setFixedSize(370, 300);
+ m_scrollArea->setFixedHeight( 300);
+ // m_scrollArea->setFixedSize(370, 300);
m_scrollArea->setWidget(m_widget);
m_scrollArea->setWidgetResizable(true);
m_scrollArea->setFrameShape(QFrame::NoFrame);
@@ -257,6 +264,7 @@ void PopupFontInfo::setWidLayout()
m_hBtnLayout->addSpacing(10);
m_hBtnLayout->addWidget(m_continueBtn);
m_hBtnLayout->setMargin(0);
+ m_hBtnLayout->setContentsMargins(0, 0, 24, 0);
/* 按钮和组件纵向布局 */
m_vLayout = new QVBoxLayout();
@@ -272,7 +280,6 @@ void PopupFontInfo::setWidLayout()
m_hMainLayout = new QHBoxLayout();
m_hMainLayout->addSpacing(24);
m_hMainLayout->addLayout(m_vLayout);
- m_hMainLayout->addSpacing(24);
/* 整个窗体布局 */
m_vMainLayout = new QVBoxLayout();
@@ -282,6 +289,8 @@ void PopupFontInfo::setWidLayout()
m_vMainLayout->addLayout(m_hMainLayout);
m_vMainLayout->addStretch();
m_vMainLayout->setMargin(0);
+ m_vMainLayout->setContentsMargins(0, 0, 0, 20); // 设置外间距
+
this->setLayout(m_vMainLayout);
/* 应用内居中 */
@@ -340,4 +349,33 @@ void PopupFontInfo::slotChangeFontName()
{
this->update();
return;
-}
\ No newline at end of file
+}
+
+void PopupFontInfo::initWidgetStyle()
+{
+ switch (GlobalSizeData::getInstance()->m_currentMode)
+ {
+ case CurrentMode::PCMode:
+ slotChangePCSize();
+ break;
+ case CurrentMode::HMode:
+ slotChangeFaltSize();
+ break;
+ case CurrentMode::VMode:
+ slotChangeFaltSize();
+ break;
+ }
+ return;
+}
+
+void PopupFontInfo::slotChangeFaltSize()
+{
+ this->setFixedSize(410, 500);
+ return;
+}
+
+void PopupFontInfo::slotChangePCSize()
+{
+ this->setFixedSize(410, 470);
+ return;
+}
diff --git a/src/view/popupfontinfo.h b/src/view/popupfontinfo.h
index ef7ec45..332fd55 100644
--- a/src/view/popupfontinfo.h
+++ b/src/view/popupfontinfo.h
@@ -22,6 +22,7 @@ public:
void setWidegtUi();
void setWidLayout();
void changeFontSize();
+ void initWidgetStyle();
private:
BasePopupTitle *m_titleBar = nullptr;
@@ -70,6 +71,8 @@ public slots:
void slotContinueClick();
void slotCancelClick();
void slotChangeFontName();
+ void slotChangeFaltSize();
+ void slotChangePCSize();
};
#endif // POPUPFONTINFO_H
diff --git a/src/view/popupinstallfail.cc b/src/view/popupinstallfail.cc
index 1940be3..59bfe5d 100644
--- a/src/view/popupinstallfail.cc
+++ b/src/view/popupinstallfail.cc
@@ -48,7 +48,8 @@ void PopupInstallFail::setWidgetUi()
"QPushButton:Pressed{border:0px;border-radius:4px;background:transparent;}";
m_tipIcon->setStyleSheet(btnStyle);
- m_tipText->setFixedSize(300, 55);
+ // m_tipText->setFixedSize(300, 55);
+ m_tipText->setFixedWidth(300);
m_tipText->setText(tr("There is a problem with the font file. Installation failed!"));
m_tipText->adjustSize();
m_tipText->setWordWrap(true);
@@ -104,7 +105,7 @@ void PopupInstallFail::setWidgetUi()
m_fontListWid->setDragEnabled(false);
this->setFixedWidth(380);
- this->setFixedHeight(200 + m_fontListWid->height());
+ this->setFixedHeight(150 + m_fontListWid->height() + m_tipText->height());
connect(m_continueBtn, &QPushButton::clicked, this, &PopupInstallFail::slotContinueClick);
connect(GlobalSizeData::getInstance(), &GlobalSizeData::sigFontChange, this, &PopupInstallFail::changeFontSize);
@@ -118,10 +119,17 @@ void PopupInstallFail::setWidLayout()
m_hMainLayout = new QHBoxLayout();
m_hBtnLayout = new QHBoxLayout();
m_hTipLayout = new QHBoxLayout();
+ m_vIconLayout = new QVBoxLayout();
m_vLayout = new QVBoxLayout();
+ // m_vIconLayout->setMargin(0);
+ // m_vIconLayout->setSpacing(0);
+ m_vIconLayout->addWidget(m_tipIcon);
+ m_vIconLayout->addStretch();
+
/* 提示横向布局 */
- m_hTipLayout->addWidget(m_tipIcon);
+ // m_hTipLayout->addWidget(m_tipIcon);
+ m_hTipLayout->addLayout(m_vIconLayout);
m_hTipLayout->addSpacing(10);
m_hTipLayout->addWidget(m_tipText);
m_hTipLayout->addStretch();
@@ -130,10 +138,11 @@ void PopupInstallFail::setWidLayout()
m_hBtnLayout->addStretch();
m_hBtnLayout->addWidget(m_continueBtn);
m_hBtnLayout->setMargin(0);
+ m_hBtnLayout->setSpacing(0);
/* 按钮和组件纵向布局 */
m_vLayout->addLayout(m_hTipLayout);
- m_vLayout->addSpacing(7);
+ m_vLayout->addSpacing(10);
m_vLayout->addWidget(m_fontListWid);
m_vLayout->addSpacing(24);
m_vLayout->addLayout(m_hBtnLayout);
@@ -166,6 +175,7 @@ void PopupInstallFail::changeFontSize()
font14.setPointSizeF(GlobalSizeData::getInstance()->g_font14pxToPt);
m_tipText->setFont(font14);
m_continueBtn->setFont(font14);
+ this->setFixedHeight(150 + m_fontListWid->height() + m_tipText->height());
return;
}
@@ -182,4 +192,4 @@ void PopupInstallFail::closeEvent(QCloseEvent *event)
emit signalWidgetClose();
event->ignore(); // 忽略不结束进程
return;
-}
\ No newline at end of file
+}
diff --git a/src/view/popupinstallfail.h b/src/view/popupinstallfail.h
index 96de6bf..20103fd 100644
--- a/src/view/popupinstallfail.h
+++ b/src/view/popupinstallfail.h
@@ -33,6 +33,7 @@ private:
QPushButton *m_continueBtn = nullptr;
QVBoxLayout *m_vLayout = nullptr;
+ QVBoxLayout *m_vIconLayout = nullptr;
QHBoxLayout *m_hTipLayout = nullptr;
QHBoxLayout *m_hBtnLayout = nullptr;
QVBoxLayout *m_vMainLayout = nullptr;
diff --git a/src/view/popupmessage.cc b/src/view/popupmessage.cc
new file mode 100644
index 0000000..572f6cc
--- /dev/null
+++ b/src/view/popupmessage.cc
@@ -0,0 +1,135 @@
+/* 适配组内SDK */
+#include "windowmanage.hpp"
+
+#include "popupmessage.h"
+#include "globalsizedata.h"
+#include "mainview.h"
+
+PopupMessage::PopupMessage(QWidget *parent) : QWidget(parent)
+{
+ setWidgetUi();
+ changeFontSize();
+}
+
+PopupMessage::~PopupMessage()
+{
+ if (m_titleBar != nullptr) {
+ delete m_titleBar;
+ m_titleBar = nullptr;
+ }
+}
+
+void PopupMessage::setWidgetUi()
+{
+ this->setFixedSize(400, 200);
+ this->setWindowFlag(Qt::Tool);
+ this->setWindowModality(Qt::WindowModal);
+ this->setWindowModality(Qt::ApplicationModal);
+ this->setAutoFillBackground(true);
+ this->setBackgroundRole(QPalette::Base);
+ this->setAttribute(Qt::WA_DeleteOnClose,true);
+
+ /* 适配kysdk的窗管 */
+ ::kabase::WindowManage::removeHeader(this);
+
+ m_titleBar = new BasePopupTitle();
+ m_tipText = new QLabel(this);
+ m_noBtn = new QPushButton(this);
+ m_yesBtn = new QPushButton(this);
+ m_vMainLayout = new QVBoxLayout();
+ m_hMainLayout = new QHBoxLayout();
+ m_vLayout = new QVBoxLayout();
+ m_hLayout = new QHBoxLayout();
+
+ /* 按钮横向布局 */
+ m_hLayout->addStretch();
+ m_hLayout->addWidget(m_yesBtn);
+ m_hLayout->addWidget(m_noBtn);
+
+ /* 按钮和组件纵向布局 */
+ m_vLayout->addWidget(m_tipText);
+ m_vLayout->addStretch();
+ m_vLayout->addLayout(m_hLayout);
+ m_vLayout->setSpacing(20);
+ m_vLayout->setMargin(0);
+
+ /* 组件居中 */
+ m_hMainLayout->addStretch();
+ m_hMainLayout->addLayout(m_vLayout);
+ m_hMainLayout->addStretch();
+
+ /* 整个窗体布局 */
+ m_vMainLayout->setSpacing(0);
+ m_vMainLayout->addWidget(m_titleBar);
+ m_vMainLayout->addSpacing(16);
+ m_vMainLayout->addLayout(m_hMainLayout);
+ m_vMainLayout->addSpacing(16);
+ // m_vMainLayout->addStretch();
+ m_vMainLayout->setMargin(0);
+ this->setLayout(m_vMainLayout);
+
+ m_tips = tr("Do you want to install the selected files?");
+ m_tipText->setFixedWidth(332);
+ m_tipText->setText(m_tips);
+ m_tipText->setMargin(0);
+ m_tipText->setAlignment(Qt::AlignTop);
+ m_tipText->adjustSize();
+ m_tipText->setWordWrap(true);
+
+ m_yesBtn->setFixedHeight(45);
+ m_yesBtn->setText(tr("Yes"));
+ m_yesBtn->setProperty("isImportant", true);
+ m_noBtn->setFixedHeight(45);
+ m_noBtn->setText(tr("No"));
+
+ // 应用内居中
+ this->move(MainView::getInstance()->geometry().center() - this->rect().center());
+
+ connect(m_yesBtn, &QPushButton::clicked, this, &PopupMessage::slotSureClick);
+ connect(m_noBtn, &QPushButton::clicked, this, &PopupMessage::slotNoClick);
+ connect(GlobalSizeData::getInstance(), &GlobalSizeData::sigFontChange, this, &PopupMessage::changeFontSize);
+
+ changeFontSize();
+ return;
+}
+
+void PopupMessage::changeFontSize()
+{
+ QFont font14;
+ font14.setPointSizeF(GlobalSizeData::getInstance()->g_font14pxToPt);
+ m_tipText->setFont(font14);
+ m_yesBtn->setFont(font14);
+ m_noBtn->setFont(font14);
+
+ // QFontMetrics fontmts = QFontMetrics(font14);
+ // QString text = m_tips;
+ // if (fontmts.width(m_tips) > m_tipText->width()) {
+ // m_tipText->setToolTip(m_tips);
+ // text = fontmts.elidedText(text, Qt::ElideRight, m_tipText->width());
+ // }
+ // m_tipText->setText(text);
+
+ return;
+}
+
+void PopupMessage::slotSureClick()
+{
+ this->hide();
+ emit signalClickYes();
+ return;
+}
+
+void PopupMessage::slotNoClick()
+{
+ this->window()->close();
+ return;
+}
+
+void PopupMessage::closeEvent(QCloseEvent *event)
+{
+ this->hide();
+ emit signalClickNo();
+ event->ignore(); // 忽略不结束进程
+
+ return;
+}
diff --git a/src/view/popupmessage.h b/src/view/popupmessage.h
new file mode 100644
index 0000000..0ddd10a
--- /dev/null
+++ b/src/view/popupmessage.h
@@ -0,0 +1,49 @@
+#ifndef POPUPMESSAGE_H
+#define POPUPMESSAGE_H
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "basepopuptitle.h"
+#include "include/core.h"
+
+/* 字体提示弹窗 */
+class PopupMessage: public QWidget
+{
+ Q_OBJECT
+public:
+ PopupMessage(QWidget *parent = nullptr);
+ ~PopupMessage();
+ void setWidgetUi();
+ void changeFontSize();
+
+private:
+ BasePopupTitle *m_titleBar = nullptr; /* 标题栏 */
+ QLabel *m_tipText = nullptr; /* 提示信息 */
+ QPushButton *m_yesBtn = nullptr; /* 确认按钮 */
+ QPushButton *m_noBtn = nullptr; /* 确认按钮 */
+ QVBoxLayout *m_vMainLayout = nullptr;
+ QHBoxLayout *m_hMainLayout = nullptr;
+ QVBoxLayout *m_vLayout = nullptr;
+ QHBoxLayout *m_hLayout = nullptr;
+
+ QString m_tips;
+
+protected:
+ void closeEvent(QCloseEvent *event) override;
+
+signals:
+ void signalWidgetClose();
+ void signalClickYes();
+ void signalClickNo();
+
+public slots:
+ void slotSureClick();
+ void slotNoClick();
+};
+
+#endif
diff --git a/src/view/titlebar.cc b/src/view/titlebar.cc
index 6e24cf4..f81838e 100644
--- a/src/view/titlebar.cc
+++ b/src/view/titlebar.cc
@@ -22,7 +22,7 @@ TitleBar::~TitleBar() {}
void TitleBar::init()
{
- this->setMinimumHeight(46);
+ // this->setMinimumHeight(40);
m_addFontBtn = new QPushButton(this);
// m_searchArea = new BaseSearchEdit();
@@ -103,7 +103,6 @@ void TitleBar::initWidgetStyle()
void TitleBar::initMenu()
{
// 菜单按钮
- m_menuBtn->setFixedSize(BTN_SIZE);
m_menuBtn->setIcon(QIcon::fromTheme("open-menu-symbolic"));
m_menuBtn->setIconSize(QSize(16, 16));
m_menuBtn->setProperty("isWindowButton", 0x1);
@@ -111,7 +110,7 @@ void TitleBar::initMenu()
m_menuBtn->setPopupMode(QToolButton::InstantPopup);
m_menuBtn->setAutoRaise(true);
m_menuBtn->setContentsMargins(4, 0, 4, 0);
- m_menuBtn->setToolTip(tr("Menu"));
+ m_menuBtn->setToolTip(tr("Options"));
// 创建Action
QAction *actionHelp = new QAction(m_menu);
@@ -133,9 +132,7 @@ void TitleBar::initLayout()
{
// 整体布局
m_hlayout = new QHBoxLayout();
- m_hlayout->setContentsMargins(4, 4, 4, 4);
m_hlayout->setSpacing(0);
- m_hlayout->addSpacing(6);
m_hlayout->addWidget(m_addFontBtn);
m_hlayout->addStretch();
m_hlayout->addWidget(m_searchArea);
@@ -144,6 +141,7 @@ void TitleBar::initLayout()
m_hlayout->addWidget(m_minBtn);
m_hlayout->addWidget(m_maxBtn);
m_hlayout->addWidget(m_closeBtn);
+ m_hlayout->setContentsMargins(10, 4, 5, 4);
this->setLayout(m_hlayout);
return;
@@ -318,4 +316,4 @@ void TitleBar::slotChangePCSize()
m_searchArea->setFixedSize(SEARCH_SIZE);
m_maxBtn->show();
return;
-}
\ No newline at end of file
+}