qt6-ukui-platformtheme/ 0000775 0001750 0001750 00000000000 15154306201 014027 5 ustar feng feng qt6-ukui-platformtheme/qt6-ukui-platformtheme/ 0000775 0001750 0001750 00000000000 15154306200 020360 5 ustar feng feng qt6-ukui-platformtheme/qt6-ukui-platformtheme/xatom-helper.cpp 0000664 0001750 0001750 00000015045 15154306200 023476 0 ustar feng feng /*
* KWin Style UKUI
*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: Yue Lan
*
*/
#include "xatom-helper.h"
#include
#include
#include
#include
#include
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include
#endif
static XAtomHelper *global_instance = nullptr;
Display* XAtomHelper::x11Display()
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
return QX11Info::display();
#else
QPlatformNativeInterface *native = QGuiApplication::platformNativeInterface();
return native ? static_cast(native->nativeResourceForWindow("display", nullptr)) : nullptr;
#endif
}
bool XAtomHelper::isPlatformX11()
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
return QX11Info::isPlatformX11();
#else
return QGuiApplication::platformName() == "xcb";
#endif
}
XAtomHelper *XAtomHelper::getInstance()
{
if (!global_instance)
global_instance = new XAtomHelper;
return global_instance;
}
bool XAtomHelper::isFrameLessWindow(int winId)
{
auto hints = getInstance()->getWindowMotifHint(winId);
if (hints.flags == MWM_HINTS_DECORATIONS && hints.functions == 1) {
return true;
}
return false;
}
bool XAtomHelper::isWindowDecorateBorderOnly(int winId)
{
return isWindowMotifHintDecorateBorderOnly(getInstance()->getWindowMotifHint(winId));
}
bool XAtomHelper::isWindowMotifHintDecorateBorderOnly(const MotifWmHints &hint)
{
bool isDeco = false;
if (hint.flags & MWM_HINTS_DECORATIONS && hint.flags != MWM_HINTS_DECORATIONS) {
if (hint.decorations == MWM_DECOR_BORDER)
isDeco = true;
}
return isDeco;
}
bool XAtomHelper::isUKUICsdSupported()
{
// fixme:
return false;
}
bool XAtomHelper::isUKUIDecorationWindow(int winId)
{
if (m_ukuiDecorationAtion == None)
return false;
Atom type;
int format;
ulong nitems;
ulong bytes_after;
uchar *data;
bool isUKUIDecoration = false;
XGetWindowProperty(x11Display(), winId, m_ukuiDecorationAtion,
0, LONG_MAX, false,
m_ukuiDecorationAtion, &type,
&format, &nitems,
&bytes_after, &data);
if (type == m_ukuiDecorationAtion) {
if (nitems == 1) {
isUKUIDecoration = data[0];
}
}
return isUKUIDecoration;
}
UnityCorners XAtomHelper::getWindowBorderRadius(int winId)
{
UnityCorners corners;
Atom type;
int format;
ulong nitems;
ulong bytes_after;
uchar *data;
if (m_unityBorderRadiusAtom != None) {
XGetWindowProperty(x11Display(), winId, m_unityBorderRadiusAtom,
0, LONG_MAX, false,
XA_CARDINAL, &type,
&format, &nitems,
&bytes_after, &data);
if (type == XA_CARDINAL) {
if (nitems == 4) {
corners.topLeft = static_cast(data[0]);
corners.topRight = static_cast(data[1*sizeof (ulong)]);
corners.bottomLeft = static_cast(data[2*sizeof (ulong)]);
corners.bottomRight = static_cast(data[3*sizeof (ulong)]);
}
XFree(data);
}
}
return corners;
}
void XAtomHelper::setWindowBorderRadius(int winId, const UnityCorners &data)
{
if (m_unityBorderRadiusAtom == None)
return;
ulong corners[4] = {data.topLeft, data.topRight, data.bottomLeft, data.bottomRight};
XChangeProperty(x11Display(), winId, m_unityBorderRadiusAtom, XA_CARDINAL,
32, XCB_PROP_MODE_REPLACE, (const unsigned char *) &corners, sizeof (corners)/sizeof (corners[0]));
}
void XAtomHelper::setWindowBorderRadius(int winId, int topLeft, int topRight, int bottomLeft, int bottomRight)
{
if (m_unityBorderRadiusAtom == None)
return;
ulong corners[4] = {(ulong)topLeft, (ulong)topRight, (ulong)bottomLeft, (ulong)bottomRight};
XChangeProperty(x11Display(), winId, m_unityBorderRadiusAtom, XA_CARDINAL,
32, XCB_PROP_MODE_REPLACE, (const unsigned char *) &corners, sizeof (corners)/sizeof (corners[0]));
}
void XAtomHelper::setUKUIDecoraiontHint(int winId, bool set)
{
if (m_ukuiDecorationAtion == None)
return;
XChangeProperty(x11Display(), winId, m_ukuiDecorationAtion, m_ukuiDecorationAtion, 32, XCB_PROP_MODE_REPLACE, (const unsigned char *) &set, 1);
}
void XAtomHelper::setWindowMotifHint(int winId, const MotifWmHints &hints)
{
if (m_unityBorderRadiusAtom == None)
return;
XChangeProperty(x11Display(), winId, m_motifWMHintsAtom, m_motifWMHintsAtom,
32, XCB_PROP_MODE_REPLACE, (const unsigned char *)&hints, sizeof (MotifWmHints)/ sizeof (ulong));
}
MotifWmHints XAtomHelper::getWindowMotifHint(int winId)
{
MotifWmHints hints;
if (m_unityBorderRadiusAtom == None)
return hints;
uchar *data;
Atom type;
int format;
ulong nitems;
ulong bytes_after;
XGetWindowProperty(x11Display(), winId, m_motifWMHintsAtom,
0, sizeof (MotifWmHints)/sizeof (long), false, AnyPropertyType, &type,
&format, &nitems, &bytes_after, &data);
if (type == None) {
return hints;
} else {
hints = *(MotifWmHints *)data;
XFree(data);
}
return hints;
}
XAtomHelper::XAtomHelper(QObject *parent) : QObject(parent)
{
if (!isPlatformX11())
return;
Display *display = x11Display();
if (!display)
return;
m_motifWMHintsAtom = XInternAtom(display, "_MOTIF_WM_HINTS", true);
m_unityBorderRadiusAtom = XInternAtom(display, "_UNITY_GTK_BORDER_RADIUS", false);
m_ukuiDecorationAtion = XInternAtom(display, "_KWIN_UKUI_DECORAION", false);
}
Atom XAtomHelper::registerUKUICsdNetWmSupportAtom()
{
// fixme:
return None;
}
void XAtomHelper::unregisterUKUICsdNetWmSupportAtom()
{
// fixme:
}
qt6-ukui-platformtheme/qt6-ukui-platformtheme/xatom-helper.h 0000664 0001750 0001750 00000006430 15154306200 023141 0 ustar feng feng /*
* KWin Style UKUI
*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: Yue Lan
*
*/
#ifndef XATOMHELPER_H
#define XATOMHELPER_H
#include
#include
#include
struct UnityCorners {
ulong topLeft = 0;
ulong topRight = 0;
ulong bottomLeft = 0;
ulong bottomRight = 0;
};
typedef struct {
ulong flags = 0;
ulong functions = 0;
ulong decorations = 0;
long input_mode = 0;
ulong status = 0;
} MotifWmHints, MwmHints;
#define MWM_HINTS_FUNCTIONS (1L << 0)
#define MWM_HINTS_DECORATIONS (1L << 1)
#define MWM_HINTS_INPUT_MODE (1L << 2)
#define MWM_HINTS_STATUS (1L << 3)
#define MWM_FUNC_ALL (1L << 0)
#define MWM_FUNC_RESIZE (1L << 1)
#define MWM_FUNC_MOVE (1L << 2)
#define MWM_FUNC_MINIMIZE (1L << 3)
#define MWM_FUNC_MAXIMIZE (1L << 4)
#define MWM_FUNC_CLOSE (1L << 5)
#define MWM_DECOR_ALL (1L << 0)
#define MWM_DECOR_BORDER (1L << 1)
#define MWM_DECOR_RESIZEH (1L << 2)
#define MWM_DECOR_TITLE (1L << 3)
#define MWM_DECOR_MENU (1L << 4)
#define MWM_DECOR_MINIMIZE (1L << 5)
#define MWM_DECOR_MAXIMIZE (1L << 6)
#define MWM_INPUT_MODELESS 0
#define MWM_INPUT_PRIMARY_APPLICATION_MODAL 1
#define MWM_INPUT_SYSTEM_MODAL 2
#define MWM_INPUT_FULL_APPLICATION_MODAL 3
#define MWM_INPUT_APPLICATION_MODAL MWM_INPUT_PRIMARY_APPLICATION_MODAL
#define MWM_TEAROFF_WINDOW (1L<<0)
namespace UKUI {
class Decoration;
}
class XAtomHelper : public QObject
{
friend class UKUI::Decoration;
Q_OBJECT
public:
static XAtomHelper *getInstance();
static Display* x11Display();
static bool isPlatformX11();
static bool isFrameLessWindow(int winId);
bool isWindowDecorateBorderOnly(int winId);
bool isWindowMotifHintDecorateBorderOnly(const MotifWmHints &hint);
bool isUKUICsdSupported();
bool isUKUIDecorationWindow(int winId);
UnityCorners getWindowBorderRadius(int winId);
void setWindowBorderRadius(int winId, const UnityCorners &data);
void setWindowBorderRadius(int winId, int topLeft, int topRight, int bottomLeft, int bottomRight);
void setUKUIDecoraiontHint(int winId, bool set = true);
void setWindowMotifHint(int winId, const MotifWmHints &hints);
MotifWmHints getWindowMotifHint(int winId);
private:
explicit XAtomHelper(QObject *parent = nullptr);
ulong registerUKUICsdNetWmSupportAtom();
void unregisterUKUICsdNetWmSupportAtom();
ulong m_motifWMHintsAtom = 0l;
ulong m_unityBorderRadiusAtom = 0l;
ulong m_ukuiDecorationAtion = 0l;
};
#endif // XATOMHELPER_H
qt6-ukui-platformtheme/qt6-ukui-platformtheme/translations/ 0000775 0001750 0001750 00000000000 15154306200 023101 5 ustar feng feng qt6-ukui-platformtheme/qt6-ukui-platformtheme/translations/qt5-ukui-platformtheme_en_US.ts 0000664 0001750 0001750 00000016415 15154306200 031102 0 ustar feng feng
MessageBox
Close
Close
QApplication
Executable '%1' requires Qt %2, found Qt %3.
Executable '%1' requires Qt %2, found Qt %3.
Incompatible Qt Library Error
Incompatible Qt Library Error
QDialogButtonBox
OK
OK
QMessageBox
Show Details...
Show Details...
Hide Details...
Hide Details...
QObject
File Name
File Name
Modified Date
Modified Date
File Type
File Type
File Size
File Size
Original Path
Original Path
Descending
Descending
Ascending
Ascending
Use current sorting for all folders
Use current sorting for all folders
List View
List View
Icon View
Icon View
Close
Close
UKUI::TabWidget::DefaultSlideAnimatorFactory
Default Slide
Let tab widget switch with a slide animation.
UKUIFileDialog::KyFileDialogHelper
Open File
Open File
Save File
Save File
All Files (*)
All Files (*)
UKUIFileDialog::KyNativeFileDialog
Go Back
Go Back
Go Forward
Go Forward
Cd Up
Cd Up
Search
Search
View Type
View Type
Sort Type
Sort Type
Maximize
Maximize
Close
Close
Restore
Restore
Name
Name
Open
Open
Cancel
Cancel
Save as
Save as
New Folder
New Folder
Save
Save
Directories
Directories
Warning
Warning
exist, are you sure replace?
exist, are you sure replace?
NewFolder
NewFolder
Undo
Undo
Redo
Redo
warn
warn
This operation is not supported.
This operation is not supported.
qt6-ukui-platformtheme/qt6-ukui-platformtheme/translations/qt5-ukui-platformtheme_kk.ts 0000664 0001750 0001750 00000017145 15154306200 030477 0 ustar feng feng
MessageBox
Close
تاقاۋ
QApplication
Executable '%1' requires Qt %2, found Qt %3.
اتقار ىستەۋگە بولاتٸن حۇجات 1، مۇقتاجدىق ارگومەنتتٸ 2، ٸزدەپ تاپقان ارگومەنتتٸ 3
Incompatible Qt Library Error
سىغىشمىغانQT قامبادا قاتەلىك كورىلدى
QDialogButtonBox
OK
ماقۇل
QMessageBox
Show Details...
ناقتى مازمۇنىن كورسەتۋ
Hide Details...
ناقتى مازمۇنىن جاسىرۋ
QObject
File Name
文件名称
Modified Date
修改日期
File Type
文件类型
File Size
文件大小
Original Path
原始路径
Descending
降序
Ascending
升序
Use current sorting for all folders
所有目录使用当前排序
List View
列表视图
Icon View
图标视图
Close
تاقاۋ
UKUI::TabWidget::DefaultSlideAnimatorFactory
Default Slide
الدىن بەكٸتٸلگەن slide
Let tab widget switch with a slide animation.
تالدانبا كارتونىن كشكەنە زاپشاستارىن پٸروبيكسيا كارتون فىلىمىگە سايكەستىرۋ
UKUIFileDialog::KyFileDialogHelper
Open File
打开
Save File
保存
All Files (*)
所有(*)
UKUIFileDialog::KyNativeFileDialog
Go Back
后退
Go Forward
前进
Cd Up
向上
Search
搜索
View Type
视图类型
Sort Type
排序类型
Maximize
最大化
Close
关闭
Restore
还原
Name
文件名
Open
打开
Cancel
取消
Save as
另存为
New Folder
新建文件夹
Save
保存
Directories
目录
Warning
警告
exist, are you sure replace?
已存在,是否替换?
NewFolder
新建文件夹
Undo
撤销
Redo
重做
warn
警告
This operation is not supported.
不支持此操作。
qt6-ukui-platformtheme/qt6-ukui-platformtheme/translations/qt5-ukui-platformtheme_tr.ts 0000664 0001750 0001750 00000005250 15154306200 030511 0 ustar feng feng
MessageBox
Close
QApplication
Executable '%1' requires Qt %2, found Qt %3.
Incompatible Qt Library Error
QDialogButtonBox
OK
QMessageBox
Show Details...
Hide Details...
QObject
Close
UKUI::TabWidget::DefaultSlideAnimatorFactory
Default Slide
Let tab widget switch with a slide animation.
qt6-ukui-platformtheme/qt6-ukui-platformtheme/translations/qt5-ukui-platformtheme_bo_CN.ts 0000664 0001750 0001750 00000022600 15154306200 031042 0 ustar feng feng
MessageBox
Close
ཁ་རྒྱག་པ།
QApplication
Executable '%1' requires Qt %2, found Qt %3.
ལག་བསྟར་བྱེད་ཆོག་པའི་'%1'ལ་Qt %2,Qt%3རྙེད་པ་རེད།
Incompatible Qt Library Error
ཕན་ཚུན་མཐུན་ཐབས་མེད་པའི་Qt དཔེ་མཛོད་ཁང་གི་ནོར་འཁྲུལ།
QDialogButtonBox
OK
འགྲིགས།
QMessageBox
Show Details...
ཞིབ་ཕྲའི་གནས་ཚུལ་གསལ་བཤད་བྱ་དགོས།
Hide Details...
གནས་ཚུལ་ཞིབ་ཕྲ་སྦས་སྐུང་བྱེད་
QObject
File Name
ཡིག་ཆའི་མིང་།
Modified Date
བཟོ་བཅོས་བརྒྱབ་པའི་དུས་ཚོད།
File Type
ཡིག་ཆའི་རིགས་གྲས།
File Size
ཡིག་ཆའི་ཆེ་ཆུང་།
Original Path
ཐོག་མའི་འགྲོ་ལམ།
Descending
མར་འབབ་པ།
Ascending
རིམ་པ་ཇེ་མང་དུ་འགྲོ་བཞིན།
Use current sorting for all folders
དཀར་ཆག་ཡོད་ཚད་མིག་སྔའི་གོ་རིམ་བཀོལ་སྤྱོད་བྱེད་བཞིན་ཡོད།
List View
མཐོང་རིས་རེའུ་མིག
Icon View
མཚོན་རྟགས་ལྟ་ཚུལ།
Close
ཁ་རྒྱག་པ།
UKUI::TabWidget::DefaultSlideAnimatorFactory
Default Slide
ཁ་ཆད་བཞག་པའི་སྒྲོན་བརྙན
Let tab widget switch with a slide animation.
སྒྲོན་བརྙན་གྱི་འགུལ་རིས་ལ་བརྟེན་ནས་ཤོག་བྱང་ཆུང་ཆུང་བརྗེ་རེས་བྱེད་དུ་འཇུག་དགོས།
UKUIFileDialog::KyFileDialogHelper
Open File
ཁ་ཕྱེ་བའི་ཡིག་ཆ།
Save File
ཡིག་ཆ་ཉར་ཚགས་བྱེད་པ།
All Files (*)
ཡིག་ཆ་ཡོད་ཚད་(*)
UKUIFileDialog::KyNativeFileDialog
Go Back
ཕྱིར་ལོག
Go Forward
མདུན་སྐྱོད།
Cd Up
གོང་ཕྱོགས།
Search
འཚོལ་ཞིབ།
View Type
མཐོང་རིས་ཀྱི་རིགས།
Sort Type
གོ་རིམ་གྱི་རིགས།
Maximize
ཆེས་ཆེ་བསྒྱུར།
Close
ཁ་རྒྱག་པ།
Restore
སླར་གསོ་བྱེད་པ།
Name
ཡིག་ཆའི་མིང་།
Open
སྒོ་ཕྱེ་བ།
Cancel
ཕྱིར་འཐེན།
Save as
ཉར་ཚགས་གཞན།
New Folder
ཡིག་ཁུག་གསར་འཛུགས།
Save
གྲོན་ཆུང་བྱེད་དགོས།
Directories
དཀར་ཆག
Warning
ཐ་ཚིག་སྒྲོག་པ།
exist, are you sure replace?
གནས་ཡོད་པས། ཁྱོད་ཀྱིས་དངོས་གནས་ཚབ་བྱེད་ཐུབ་བམ།
NewFolder
དཀར་ཆག་གསར་བ།
Undo
ཁ་ཕྱིར་འཐེན་བྱ་དགོས།
Redo
ཡང་བསྐྱར་ལས།
warn
ཉེན་བརྡ་བཏང་བ།
This operation is not supported.
བཀོལ་སྤྱོད་འདི་ལ་རྒྱབ་སྐྱོར་མི་བྱེད།
qt6-ukui-platformtheme/qt6-ukui-platformtheme/translations/qt5-ukui-platformtheme_cs.ts 0000664 0001750 0001750 00000005250 15154306200 030471 0 ustar feng feng
MessageBox
Close
QApplication
Executable '%1' requires Qt %2, found Qt %3.
Incompatible Qt Library Error
QDialogButtonBox
OK
QMessageBox
Show Details...
Hide Details...
QObject
Close
UKUI::TabWidget::DefaultSlideAnimatorFactory
Default Slide
Let tab widget switch with a slide animation.
qt6-ukui-platformtheme/qt6-ukui-platformtheme/translations/qt5-ukui-platformtheme_zh_HK.ts 0000664 0001750 0001750 00000016505 15154306200 031074 0 ustar feng feng
MessageBox
Close
關閉
QApplication
Executable '%1' requires Qt %2, found Qt %3.
可執行檔「%1」 需要數量%2,找到數量%3。
Incompatible Qt Library Error
不相容的Qt庫錯誤
QDialogButtonBox
OK
確認
QMessageBox
Show Details...
顯示細節......
Hide Details...
隱藏細節......
QObject
File Name
檔名稱
Modified Date
修改日期
File Type
檔案類型
File Size
檔大小
Original Path
原始路徑
Descending
降序
Ascending
升序
Use current sorting for all folders
所有資料夾套用目前排序方式
List View
清單檢視
Icon View
圖示檢視
Close
關閉
UKUI::TabWidget::DefaultSlideAnimatorFactory
Default Slide
默認slide
Let tab widget switch with a slide animation.
讓選項卡小部件切換為幻燈片動畫。
UKUIFileDialog::KyFileDialogHelper
Open File
打開
Save File
保存
All Files (*)
所有(*)
UKUIFileDialog::KyNativeFileDialog
Go Back
後退
Go Forward
前進
Cd Up
向上
Search
搜索
View Type
視圖類型
Sort Type
排序類型
Maximize
最大化
Close
關閉
Restore
還原
Name
檔名
Open
打開
Cancel
取消
Save as
另存為
New Folder
新建資料夾
Save
保存
Directories
目錄
Warning
警告
exist, are you sure replace?
已存在,是否替換?
NewFolder
新建資料夾
Undo
撤銷
Redo
重做
warn
警告
This operation is not supported.
不支援此操作。
qt6-ukui-platformtheme/qt6-ukui-platformtheme/translations/qt5-ukui-platformtheme_zh_Hant.ts 0000664 0001750 0001750 00000040515 15154306200 031462 0 ustar feng feng
MainWindow
MainWindow
test open
directory
selected uri
test show
test exec
test save
test static open
PushButton
use auto highlight icon
...
highlightOnly
bothDefaultAndHighlight
RadioButton
style
icon
menu opacity
font
MessageBox
Close
關閉
QApplication
Executable '%1' requires Qt %2, found Qt %3.
可執行檔「%1」 需要數量%2,找到數量%3。
Incompatible Qt Library Error
不相容的Qt庫錯誤
QDialogButtonBox
OK
確認
QMessageBox
Show Details...
顯示細節......
Hide Details...
隱藏細節......
QObject
File Name
檔名稱
Modified Date
修改日期
File Type
檔案類型
File Size
檔大小
Original Path
原始路徑
Descending
降序
Ascending
升序
Use current sorting for all folders
所有資料夾套用目前排序方式
List View
清單檢視
Icon View
圖示檢視
Close
關閉
UKUI::TabWidget::DefaultSlideAnimatorFactory
Default Slide
默認slide
Let tab widget switch with a slide animation.
讓選項卡小部件切換為幻燈片動畫。
UKUIFileDialog::KyFileDialogHelper
Open File
打開
Save File
保存
All Files (*)
所有(*)
UKUIFileDialog::KyNativeFileDialog
Go Back
後退
Go Forward
前進
Cd Up
向上
Search
搜索
View Type
視圖類型
Sort Type
排序類型
Maximize
最大化
Close
關閉
Restore
還原
Name
檔名
Open
打開
Cancel
取消
Save as
另存為
New Folder
新建資料夾
Save
保存
Directories
目錄
Warning
警告
exist, are you sure replace?
已存在,是否替換?
NewFolder
新建資料夾
Undo
撤銷
Redo
重做
warn
警告
This operation is not supported.
不支援此操作。
qt6-ukui-platformtheme/qt6-ukui-platformtheme/translations/qt5-ukui-platformtheme_fa.ts 0000664 0001750 0001750 00000005250 15154306200 030452 0 ustar feng feng
MessageBox
Close
QApplication
Executable '%1' requires Qt %2, found Qt %3.
Incompatible Qt Library Error
QDialogButtonBox
OK
QMessageBox
Show Details...
Hide Details...
QObject
Close
UKUI::TabWidget::DefaultSlideAnimatorFactory
Default Slide
Let tab widget switch with a slide animation.
qt6-ukui-platformtheme/qt6-ukui-platformtheme/translations/qt5-ukui-platformtheme_de.ts 0000664 0001750 0001750 00000035016 15154306200 030457 0 ustar feng feng
MainWindow
MainWindow
test open
directory
selected uri
test show
test exec
test save
test static open
PushButton
use auto highlight icon
...
highlightOnly
bothDefaultAndHighlight
RadioButton
style
icon
menu opacity
font
MessageBox
Close
Schließen
QApplication
Executable '%1' requires Qt %2, found Qt %3.
Die ausführbare Datei '%1' erfordert Qt %2, Qt %3 gefunden.
Incompatible Qt Library Error
Fehler in der inkompatiblen Qt-Bibliothek
QDialogButtonBox
OK
OKAY
QMessageBox
Show Details...
Details anzeigen...
Hide Details...
Details ausblenden...
QObject
File Name
Dateiname
Modified Date
Änderungsdatum
File Type
Dateityp
File Size
Dateigröße
Original Path
Ursprünglicher Pfad
Descending
Absteigend
Ascending
Aufsteigend
Use current sorting for all folders
Globale Sortierung verwenden
List View
Listenansicht
Icon View
Icon-Ansicht
Close
Schließen
UKUI::TabWidget::DefaultSlideAnimatorFactory
Default Slide
Standard-Folie
Let tab widget switch with a slide animation.
Lassen Sie das Tab-Widget mit einer Folienanimation wechseln.
UKUIFileDialog::KyFileDialogHelper
Open File
Offene Linie
Save File
Datei speichern
All Files (*)
Alle Dateien (*)
UKUIFileDialog::KyNativeFileDialog
Go Back
Zurück
Go Forward
Vorwärts gehen
Cd Up
Cd nach oben
Search
Suchen
View Type
Typ der Ansicht
Sort Type
Art der Sortierung
Maximize
Maximieren
Close
Schließen
Restore
Wiederherstellen
Name
Name
Open
Offen
Cancel
Abbrechen
Save as
Speichern unter
New Folder
Neuer Ordner
Save
Retten
Directories
Verzeichnisse
Warning
Warnung
exist, are you sure replace?
existieren, sind Sie sicher, ersetzen?
NewFolder
Neuer Ordner
Undo
Aufmachen
Redo
Noch einmal machen
warn
warnen
This operation is not supported.
Dieser Vorgang wird nicht unterstützt.
qt6-ukui-platformtheme/qt6-ukui-platformtheme/translations/qt5-ukui-platformtheme_mn.ts 0000664 0001750 0001750 00000021275 15154306200 030503 0 ustar feng feng
MessageBox
Close
ᠬᠠᠭᠠᠬᠤ
QApplication
Executable '%1' requires Qt %2, found Qt %3.
ᠭᠦᠢᠴᠡᠳᠬᠡᠵᠦ ᠪᠣᠯᠬᠤ ᠹᠠᠢᠯ '%1' Qt% 2 ᠬᠡᠷᠡᠭᠰᠡᠵᠦ ᠂ Qt% 3 ᠢ᠋/ ᠵᠢ ᠡᠷᠢᠵᠦ ᠣᠯᠬᠤ ᠬᠡᠷᠡᠭᠲᠡᠶ .
Incompatible Qt Library Error
QDialogButtonBox
OK
OK
QMessageBox
Show Details...
Hide Details...
QObject
File Name
ᠹᠠᠢᠯ ᠤ᠋ᠨ ᠨᠡᠷᠡᠢᠳᠦᠯ
Modified Date
ᠵᠠᠰᠠᠭᠰᠠᠨ ᠡᠳᠦᠷ ᠰᠠᠷᠠ
File Type
ᠹᠠᠢᠯ ᠤ᠋ᠨ ᠳᠦᠷᠦᠯ ᠵᠦᠢᠯ
File Size
ᠹᠠᠢᠯ ᠤ᠋ᠨ ᠶᠡᠬᠡ ᠪᠠᠭᠠ
Original Path
ᠤᠭ ᠤ᠋ᠨ ᠵᠠᠮ ᠱᠤᠭᠤᠮ
Descending
ᠪᠠᠭᠠᠰᠬᠠᠬᠤ
Ascending
ᠶᠡᠬᠡᠰᠬᠡᠬᠦ
Use current sorting for all folders
ᠪᠦᠬᠦ ᠪᠠᠢᠳᠠᠯ ᠤ᠋ᠨ ᠳᠠᠷᠠᠭᠠᠯᠠᠯ ᠢ᠋ ᠬᠡᠷᠡᠭᠯᠡᠬᠦ
List View
ᠵᠢᠭᠰᠠᠭᠠᠯᠳᠠ ᠵᠢᠨ ᠬᠠᠷᠠᠭᠠᠨ ᠵᠢᠷᠤᠭ
Icon View
ᠰᠢᠪᠠᠭᠠ ᠵᠢᠨ ᠬᠠᠷᠠᠭᠠᠨ ᠵᠢᠷᠤᠭ
Close
ᠬᠠᠭᠠᠬᠤ
UKUI::TabWidget::DefaultSlideAnimatorFactory
Default Slide
Default Slide
Let tab widget switch with a slide animation.
UKUIFileDialog::KyFileDialogHelper
Open File
ᠨᠡᠬᠡᠬᠡᠬᠦ
Save File
ᠬᠠᠳᠠᠭᠠᠯᠠᠬᠤ
All Files (*)
ᠪᠦᠬᠦᠢᠯᠡ (*)
UKUIFileDialog::KyNativeFileDialog
Go Back
ᠤᠬᠤᠷᠢᠬᠤ
Go Forward
ᠤᠷᠤᠭᠰᠢᠯᠠᠬᠤ
Cd Up
ᠳᠡᠭᠡᠭᠰᠢ
Search
ᠬᠠᠢᠯᠳᠠ
View Type
ᠬᠠᠷᠠᠭᠠᠨ ᠵᠢᠷᠤᠭ ᠤ᠋ᠨ ᠳᠦᠷᠦᠯ ᠵᠦᠢᠯ
Sort Type
ᠳᠠᠷᠠᠭᠠᠯᠠᠯ ᠤ᠋ᠨ ᠳᠦᠷᠦᠯ ᠵᠦᠢᠯ
Maximize
ᠬᠠᠮᠤᠭ ᠤ᠋ᠨ ᠶᠡᠬᠡᠴᠢᠯᠡᠯ
Close
ᠬᠠᠭᠠᠬᠤ
Restore
ᠡᠬᠡᠬᠦᠯᠬᠦ
Name
ᠹᠠᠢᠯ ᠤ᠋ᠨ ᠨᠡᠷᠡ
Open
ᠨᠡᠬᠡᠬᠡᠬᠦ
Cancel
ᠦᠬᠡᠢᠰᠭᠡᠬᠦ᠌
Save as
ᠦᠭᠡᠷᠡ ᠭᠠᠵᠠᠷ ᠬᠠᠳᠠᠭᠠᠯᠠᠬᠤ
New Folder
ᠰᠢᠨᠡ ᠪᠡᠷ ᠪᠠᠢᠭᠤᠯᠤᠭᠰᠠᠨ ᠹᠠᠢᠯ ᠤ᠋ᠨ ᠬᠠᠪᠳᠠᠰᠤ
Save
ᠬᠠᠳᠠᠭᠠᠯᠠᠬᠤ
Directories
ᠭᠠᠷᠴᠠᠭ
Warning
ᠰᠡᠷᠡᠮᠵᠢᠯᠡᠬᠦᠯᠦᠯ
exist, are you sure replace?
ᠪᠠᠢᠨᠠ᠂ ᠰᠤᠯᠢᠬᠤ ᠤᠤ?
NewFolder
ᠰᠢᠨᠡ ᠪᠡᠷ ᠪᠠᠢᠭᠤᠯᠤᠭᠰᠠᠨ ᠹᠠᠢᠯ ᠤ᠋ᠨ ᠬᠠᠪᠳᠠᠰᠤ
Undo
ᠬᠦᠴᠦᠨ ᠦᠬᠡᠢ ᠪᠤᠯᠭᠠᠬᠤ
Redo
ᠳᠠᠬᠢᠵᠤ ᠬᠢᠬᠦ
warn
ᠰᠡᠷᠡᠮᠵᠢᠯᠡᠬᠦᠯᠬᠦ
This operation is not supported.
ᠳᠤᠰ ᠠᠵᠢᠯᠯᠠᠬᠤᠢ ᠵᠢ ᠳᠡᠮᠵᠢᠬᠦ ᠦᠬᠡᠢ.
qt6-ukui-platformtheme/qt6-ukui-platformtheme/translations/qt5-ukui-platformtheme_ug.ts 0000664 0001750 0001750 00000017127 15154306200 030505 0 ustar feng feng
MessageBox
Close
تاقاش
QApplication
Executable '%1' requires Qt %2, found Qt %3.
ئىجرا قىلىشقا بولىدىغان ھۆججەت 1، ئىھتىياجلىق سان 2، ئىزدەپ تاپقان سان 3
Incompatible Qt Library Error
سىغىشمىغانQT ئامبىرىدا خاتالىق كۆرۈلدى
QDialogButtonBox
OK
ماقۇل
QMessageBox
Show Details...
تەپسىلاتىنى كۆرسىتىش
Hide Details...
تەپسىلاتىنى يوشۇرۇش
QObject
File Name
文件名称
Modified Date
修改日期
File Type
文件类型
File Size
文件大小
Original Path
原始路径
Descending
降序
Ascending
升序
Use current sorting for all folders
所有目录使用当前排序
List View
列表视图
Icon View
图标视图
Close
تاقاش
UKUI::TabWidget::DefaultSlideAnimatorFactory
Default Slide
ئالدىن بىكىتىلگەن slide
Let tab widget switch with a slide animation.
تاللانما كارتىدىكى كىچىك زاپچاسلارنى پرويېكسىيە كارتون فىلىمىگە ئالماشتۇرۇش
UKUIFileDialog::KyFileDialogHelper
Open File
打开
Save File
保存
All Files (*)
所有(*)
UKUIFileDialog::KyNativeFileDialog
Go Back
后退
Go Forward
前进
Cd Up
向上
Search
搜索
View Type
视图类型
Sort Type
排序类型
Maximize
最大化
Close
关闭
Restore
还原
Name
文件名
Open
打开
Cancel
取消
Save as
另存为
New Folder
新建文件夹
Save
保存
Directories
目录
Warning
警告
exist, are you sure replace?
已存在,是否替换?
NewFolder
新建文件夹
Undo
撤销
Redo
重做
warn
警告
This operation is not supported.
不支持此操作。
qt6-ukui-platformtheme/qt6-ukui-platformtheme/translations/qt5-ukui-platformtheme_fr.ts 0000664 0001750 0001750 00000017055 15154306200 030501 0 ustar feng feng
MessageBox
Close
Fermer
QApplication
Executable '%1' requires Qt %2, found Qt %3.
L’exécutable '%1' nécessite Qt %2, trouvé Qt %3.
Incompatible Qt Library Error
Erreur de bibliothèque Qt incompatible
QDialogButtonBox
OK
D’ACCORD
QMessageBox
Show Details...
Afficher les détails...
Hide Details...
Masquer les détails...
QObject
File Name
Nom du fichier
Modified Date
Date de modification
File Type
Type de fichier
File Size
Taille du fichier
Original Path
Chemin d’accès d’origine
Descending
Descendant
Ascending
Ascendant
Use current sorting for all folders
Utiliser le tri global
List View
Affichage en liste
Icon View
Affichage de l’icône
Close
Fermer
UKUI::TabWidget::DefaultSlideAnimatorFactory
Default Slide
Diapositive par défaut
Let tab widget switch with a slide animation.
Laissez le widget d’onglet basculer avec une animation de diapositive.
UKUIFileDialog::KyFileDialogHelper
Open File
Ouvrir un fichier
Save File
Enregistrer le fichier
All Files (*)
Tous les fichiers (*)
UKUIFileDialog::KyNativeFileDialog
Go Back
Retour
Go Forward
Avancer
Cd Up
Cd Up
Search
Rechercher
View Type
Type de vue
Sort Type
Type de tri
Maximize
Maximiser
Close
Fermer
Restore
Restaurer
Name
Nom
Open
Ouvrir
Cancel
Annuler
Save as
Enregistrer sous
New Folder
Nouveau dossier
Save
Sauvegarder
Directories
Téléphonique
Warning
Avertissement
exist, are you sure replace?
exister, êtes-vous sûr de remplacer ?
NewFolder
NouveauDossier
Undo
Défaire
Redo
Refaire
warn
avertir
This operation is not supported.
Cette opération n’est pas prise en charge.
qt6-ukui-platformtheme/qt6-ukui-platformtheme/translations/qt5-ukui-platformtheme_es.ts 0000664 0001750 0001750 00000035133 15154306200 030476 0 ustar feng feng
MainWindow
MainWindow
test open
directory
selected uri
test show
test exec
test save
test static open
PushButton
use auto highlight icon
...
highlightOnly
bothDefaultAndHighlight
RadioButton
style
icon
menu opacity
font
MessageBox
Close
QApplication
Executable '%1' requires Qt %2, found Qt %3.
Incompatible Qt Library Error
QDialogButtonBox
OK
QMessageBox
Show Details...
Hide Details...
QObject
File Name
Modified Date
File Type
File Size
Original Path
Descending
Ascending
Use current sorting for all folders
List View
Icon View
Close
UKUI::TabWidget::DefaultSlideAnimatorFactory
Default Slide
Let tab widget switch with a slide animation.
UKUIFileDialog::KyFileDialogHelper
Open File
Save File
All Files (*)
UKUIFileDialog::KyNativeFileDialog
Go Back
Go Forward
Cd Up
Search
View Type
Sort Type
Maximize
Close
Restore
Name
Open
Cancel
Save as
New Folder
Save
Directories
Warning
exist, are you sure replace?
NewFolder
Undo
Redo
warn
This operation is not supported.
qt6-ukui-platformtheme/qt6-ukui-platformtheme/translations/qt5-ukui-platformtheme_zh_CN.ts 0000664 0001750 0001750 00000016461 15154306200 031073 0 ustar feng feng
MessageBox
Close
关闭
QApplication
Executable '%1' requires Qt %2, found Qt %3.
可执行文件“%1”需要数量%2,找到数量%3。
Incompatible Qt Library Error
不兼容的Qt库错误
QDialogButtonBox
OK
确认
QMessageBox
Show Details...
显示细节……
Hide Details...
隐藏细节……
QObject
File Name
文件名称
Modified Date
修改日期
File Type
文件类型
File Size
文件大小
Original Path
原始路径
Descending
降序
Ascending
升序
Use current sorting for all folders
所有目录使用当前排序
List View
列表视图
Icon View
图标视图
Close
关闭
UKUI::TabWidget::DefaultSlideAnimatorFactory
Default Slide
默认slide
Let tab widget switch with a slide animation.
让选项卡小部件切换为幻灯片动画。
UKUIFileDialog::KyFileDialogHelper
Open File
打开
Save File
保存
All Files (*)
所有(*)
UKUIFileDialog::KyNativeFileDialog
Go Back
后退
Go Forward
前进
Cd Up
向上
Search
搜索
View Type
视图类型
Sort Type
排序类型
Maximize
最大化
Close
关闭
Restore
还原
Name
文件名
Open
打开
Cancel
取消
Save as
另存为
New Folder
新建文件夹
Save
保存
Directories
目录
Warning
警告
exist, are you sure replace?
已存在,是否替换?
NewFolder
新建文件夹
Undo
撤销
Redo
重做
warn
警告
This operation is not supported.
不支持此操作。
qt6-ukui-platformtheme/qt6-ukui-platformtheme/translations/qt5-ukui-platformtheme_ky.ts 0000664 0001750 0001750 00000017125 15154306200 030513 0 ustar feng feng
MessageBox
Close
بەكىتىش
QApplication
Executable '%1' requires Qt %2, found Qt %3.
اتقارماق جاسووعو بولوتۇرعان ۅجۅت 1، كەرەكتۉۉ سان 2، ىزدەپ تاپقان سان 3
Incompatible Qt Library Error
سىغىشمىغانQT قامپادا قاتاالىق كۅرۉلدۉ
QDialogButtonBox
OK
ماقۇل
QMessageBox
Show Details...
جۅن جايىن كۅرسۅتۉۉ
Hide Details...
جۅن جايىن جاشىرۇۇ
QObject
File Name
文件名称
Modified Date
修改日期
File Type
文件类型
File Size
文件大小
Original Path
原始路径
Descending
降序
Ascending
升序
Use current sorting for all folders
所有目录使用当前排序
List View
列表视图
Icon View
图标视图
Close
بەكىتىش
UKUI::TabWidget::DefaultSlideAnimatorFactory
Default Slide
الدىن بەكىتىلگەن slide
Let tab widget switch with a slide animation.
تاندالما كارتاداقى كىچىك شايمانداردى پرويەكسىيە كارتون فىلىمىگە الماشتىرۇۇ
UKUIFileDialog::KyFileDialogHelper
Open File
打开
Save File
保存
All Files (*)
所有(*)
UKUIFileDialog::KyNativeFileDialog
Go Back
后退
Go Forward
前进
Cd Up
向上
Search
搜索
View Type
视图类型
Sort Type
排序类型
Maximize
最大化
Close
关闭
Restore
还原
Name
文件名
Open
打开
Cancel
取消
Save as
另存为
New Folder
新建文件夹
Save
保存
Directories
目录
Warning
警告
exist, are you sure replace?
已存在,是否替换?
NewFolder
新建文件夹
Undo
撤销
Redo
重做
warn
警告
This operation is not supported.
不支持此操作。
qt6-ukui-platformtheme/qt6-ukui-platformtheme/ukui.json 0000664 0001750 0001750 00000000033 15154306200 022224 0 ustar feng feng {
"Keys": [ "ukui" ]
}
qt6-ukui-platformtheme/qt6-ukui-platformtheme/qt5-ukui-platformtheme_global.h 0000664 0001750 0001750 00000002120 15154306200 026375 0 ustar feng feng /*
* Qt5-UKUI's Library
*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library. If not, see .
*
* Authors: Yue Lan
*
*/
#ifndef QT5UKUIPLATFORMTHEME_GLOBAL_H
#define QT5UKUIPLATFORMTHEME_GLOBAL_H
#include
#if defined(QT5UKUIPLATFORMTHEME_LIBRARY)
# define QT5UKUIPLATFORMTHEMESHARED_EXPORT Q_DECL_EXPORT
#else
# define QT5UKUIPLATFORMTHEMESHARED_EXPORT Q_DECL_IMPORT
#endif
#endif // QT5UKUIPLATFORMTHEME_GLOBAL_H
qt6-ukui-platformtheme/qt6-ukui-platformtheme/widget/ 0000775 0001750 0001750 00000000000 15154306200 021643 5 ustar feng feng qt6-ukui-platformtheme/qt6-ukui-platformtheme/widget/messagebox/ 0000775 0001750 0001750 00000000000 15154306200 024000 5 ustar feng feng qt6-ukui-platformtheme/qt6-ukui-platformtheme/widget/messagebox/message-box.cpp 0000664 0001750 0001750 00000135373 15154306200 026732 0 ustar feng feng /*
* KWin Style UKUI
*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: xibowen
*
*/
#include "message-box.h"
#include "../../xatom-helper.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "private/qlabel_p.h"
#include "private/qdialog_p.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
enum Button
{
Old_Ok = 1, Old_Cancel = 2, Old_Yes = 3, Old_No = 4, Old_Abort = 5, Old_Retry = 6,
Old_Ignore = 7, Old_YesAll = 8, Old_NoAll = 9, Old_ButtonMask = 0xFF, NewButtonMask = 0xFFFFFC00
};
static QMessageBox::StandardButton newButton(int button);
static QMessageDialogOptions::StandardIcon helperIcon(QMessageBox::Icon i);
static QPlatformDialogHelper::StandardButtons helperStandardButtons(MessageBox * q);
MessageBox::MessageBox(QWidget *parent) : QDialog(*new MessageBoxPrivate, parent, Qt::MSWindowsFixedSizeDialogHint /*| Qt::WindowTitleHint*/ | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint)
{
Q_D(MessageBox);
const QString locale = QLocale::system().name();
QTranslator *translator = new QTranslator(this);
if (translator->load("/usr/share/qt5-ukui-platformtheme/qt5-ukui-platformtheme_" + locale)) {
//Fix:BUG176598,block QMessagebox translation for xca before commit patch to upstream
if (qAppName() != "xca") {
if(!QApplication::installTranslator(translator))
qWarning() << "Install translator failed!" << locale;
}
}
else
qWarning() << "Load translations file failed!" << locale;
setProperty("useStyleWindowManager", true);
setBackgroundRole(QPalette::Base);
setAutoFillBackground(true);
d->init();
d->mCloseButtton->setToolTip(tr("Close"));
setContentsMargins(0, 0, 0, 0);
setAttribute(Qt::WA_TranslucentBackground);
// m_windowHelper = new UkuiWindowHelper(this);
// m_windowHelper->removeTitleBar();
// m_windowHelper->setSkipTaskBar(true);
// m_windowHelper->setSkipSwitcher(true);
// QDBusInterface *interFace = new QDBusInterface("com.kylin.statusmanager.interface",
// "/",
// "com.kylin.statusmanager.interface",
// QDBusConnection::sessionBus());
// if(interFace->isValid()){
// connect(interFace, SIGNAL(mode_change_signal(bool)), this, SLOT(d->tableModeChanged(bool)));
// }
}
MessageBox::~MessageBox()
{
// if (m_windowHelper) {
// delete m_windowHelper;
// m_windowHelper = nullptr;
// }
}
void MessageBox::setCheckBox(QCheckBox *cb)
{
Q_D(MessageBox);
if (cb == d->mCheckbox) {
return;
}
d->mCheckbox = cb;
}
QMessageBox::Icon MessageBox::icon()
{
Q_D(const MessageBox);
return d->mIcon;
}
void MessageBox::setIcon(QMessageBox::Icon icon)
{
Q_D(MessageBox);
setIconPixmap(MessageBoxPrivate::standardIcon((QMessageBox::Icon)icon, this));
d->mIcon = icon;
}
QPixmap MessageBox::iconPixmap() const
{
Q_D(const MessageBox);
if (d->mIconLabel && !d->mIconLabel->pixmap().isNull())
return d->mIconLabel->pixmap();
return QPixmap();
}
void MessageBox::setIconPixmap(const QPixmap &pixmap)
{
Q_D(MessageBox);
if (!pixmap.isNull()){
d->mIconLabel->setAlignment(Qt::AlignVCenter);
d->mIconLabel->setPixmap(pixmap);
}
d->mIcon = QMessageBox::NoIcon;
}
QString MessageBox::text()
{
Q_D(const MessageBox);
return d->mLabel->text();
}
void MessageBox::setText(const QString& text)
{
Q_D(MessageBox);
d->mLabel->setText(text);
}
Qt::TextFormat MessageBox::textFormat() const
{
Q_D(const MessageBox);
return d->mLabel->textFormat();
}
void MessageBox::setTextFormat(Qt::TextFormat format)
{
Q_D(MessageBox);
d->mLabel->setTextFormat(format);
}
Qt::TextInteractionFlags MessageBox::textInteractionFlags() const
{
Q_D(const MessageBox);
return d->mLabel->textInteractionFlags();
}
void MessageBox::setTextInteractionFlags(Qt::TextInteractionFlags flags)
{
Q_D(MessageBox);
d->mLabel->setTextInteractionFlags(flags);
}
void MessageBox::addButton(QAbstractButton *button, QMessageBox::ButtonRole role)
{
Q_D(MessageBox);
if (!button) {
return;
}
if (d->mButtonBox->buttons().contains(button))
return;
removeButton(button);
d->mOptions->addButton(button->text(), static_cast(role), button);
d->mButtonBox->addButton(button, (QDialogButtonBox::ButtonRole)role);
d->mCustomButtonList.append(button);
d->mAutoAddOkButton = false;
}
QPushButton* MessageBox::addButton(const QString &text, QMessageBox::ButtonRole role)
{
Q_D(MessageBox);
QPushButton* pushButton = new QPushButton(text);
addButton(pushButton, role);
return pushButton;
}
QPushButton *MessageBox::addButton(QMessageBox::StandardButton button)
{
Q_D(MessageBox);
if (d->mButtonBox->standardButtons() & button) {
return nullptr;
}
QPushButton *pushButton = d->mButtonBox->addButton((QDialogButtonBox::StandardButton)button);
if (pushButton) {
d->mAutoAddOkButton = false;
}
pushButton->setIcon(QIcon());
return pushButton;
}
void MessageBox::removeButton(QAbstractButton *button)
{
Q_D(MessageBox);
d->mCustomButtonList.removeAll(button);
if (d->mEscapeButton == button) {
d->mEscapeButton = nullptr;
}
if (d->mDefaultButton == button) {
d->mDefaultButton = nullptr;
}
d->mButtonBox->removeButton(button);
}
QAbstractButton *MessageBox::button(QMessageBox::StandardButton which) const
{
Q_D(const MessageBox);
return d->mButtonBox->button(QDialogButtonBox::StandardButton(which));
}
QList MessageBox::buttons() const
{
Q_D(const MessageBox);
return d->mButtonBox->buttons();
}
QMessageBox::ButtonRole MessageBox::buttonRole(QAbstractButton *button) const
{
Q_D(const MessageBox);
return QMessageBox::ButtonRole(d->mButtonBox->buttonRole(button));
}
void MessageBox::setStandardButtons(QMessageBox::StandardButtons buttons)
{
Q_D(MessageBox);
d->mButtonBox->setStandardButtons(QDialogButtonBox::StandardButtons(int(buttons)));
QList buttonList = d->mButtonBox->buttons();
if (!buttonList.contains(d->mEscapeButton)) {
d->mEscapeButton = nullptr;
}
if (!buttonList.contains(d->mDefaultButton)) {
d->mDefaultButton = nullptr;
}
d->mAutoAddOkButton = false;
}
QMessageBox::StandardButtons MessageBox::standardButtons() const
{
Q_D(const MessageBox);
return QMessageBox::StandardButtons(int(d->mButtonBox->standardButtons()));
}
QMessageBox::StandardButton MessageBox::standardButton(QAbstractButton *button) const
{
Q_D(const MessageBox);
return (QMessageBox::StandardButton)d->mButtonBox->standardButton(button);
}
QPushButton *MessageBox::defaultButton() const
{
Q_D(const MessageBox);
return d->mDefaultButton;
}
void MessageBox::setDefaultButton(QPushButton *button)
{
Q_D(MessageBox);
if (!d->mButtonBox->buttons().contains(button)) {
return;
}
d->mDefaultButton = button;
button->setDefault(true);
button->setFocus();
}
void MessageBox::setDefaultButton(QMessageBox::StandardButton button)
{
Q_D(MessageBox);
setDefaultButton(d->mButtonBox->button(QDialogButtonBox::StandardButton(button)));
}
QAbstractButton* MessageBox::escapeButton() const
{
Q_D(const MessageBox);
return d->mEscapeButton;
}
void MessageBox::setEscapeButton(QAbstractButton *button)
{
Q_D(MessageBox);
if (d->mButtonBox->buttons().contains(button)) {
d->mEscapeButton = button;
}
}
void MessageBox::setEscapeButton(QMessageBox::StandardButton button)
{
Q_D(MessageBox);
setEscapeButton(d->mButtonBox->button(QDialogButtonBox::StandardButton(button)));
}
QAbstractButton* MessageBox::clickedButton() const
{
Q_D(const MessageBox);
return d->mClickedButton;
}
QString MessageBox::buttonText(int button) const
{
Q_D(const MessageBox);
if (QAbstractButton *abstractButton = d->abstractButtonForId(button)) {
return abstractButton->text();
} else if (d->mButtonBox->buttons().isEmpty() && (button == QMessageBox::Ok || button == Old_Ok)) {
return QDialogButtonBox::tr("OK");
}
return QString();
}
void MessageBox::setButtonText(int button, const QString &text)
{
Q_D(MessageBox);
if (QAbstractButton *abstractButton = d->abstractButtonForId(button)) {
abstractButton->setText(text);
} else if (d->mButtonBox->buttons().isEmpty() && (button == QMessageBox::Ok || button == Old_Ok)) {
addButton(QMessageBox::Ok)->setText(text);
}
}
QString MessageBox::informativeText() const
{
Q_D(const MessageBox);
return d->mInformativeLabel ? d->mInformativeLabel->text() : QString();
}
void MessageBox::setInformativeText(const QString &text)
{
Q_D(MessageBox);
if (text.isEmpty()) {
if (d->mInformativeLabel) {
d->mInformativeLabel->hide();
d->mInformativeLabel->deleteLater();
}
d->mInformativeLabel = nullptr;
} else {
if (!d->mInformativeLabel) {
QLabel *label = new QLabel;
label->setObjectName(QLatin1String("ukui_msgbox_informativelabel"));
label->setTextInteractionFlags(Qt::TextInteractionFlags(style()->styleHint(QStyle::SH_MessageBox_TextInteractionFlags, nullptr, this)));
label->setAlignment(Qt::AlignTop | Qt::AlignLeft);
label->setOpenExternalLinks(true);
QPalette palette = label->palette();
palette.setColor(QPalette::Text, palette.color(QPalette::Disabled, QPalette::Text));
label->setPalette(palette);
d->mInformativeLabel = label;
}
d->mInformativeLabel->setText(text);
}
}
void MessageBox::setDetailedText(const QString &text)
{
Q_D(MessageBox);
if (!text.isEmpty()) {
d->mDetail = new TextEdit;
d->mDetail->setText(text);
d->mDetail->hide();
if (!d->mDetailButton) {
d->mDetailButton = new QPushButton(this);
d->mDetailButton->setText(QMessageBox::tr("Show Details..."));
}
} else {
d->mDetail = nullptr;
d->mDefaultButton = nullptr;
}
}
void MessageBox::setWindowTitle(const QString &title)
{
Q_D(MessageBox);
// d->mTitleText->setText(title);
d->mTitleText->setText("");
QDialog::setWindowTitle(title);
}
void MessageBox::setWindowModality(Qt::WindowModality windowModality)
{
QDialog::setWindowModality(windowModality);
// if (parentWidget() && windowModality == Qt::WindowModal) {
// setParent(parentWidget(), Qt::Sheet);
// } else {
// setParent(parentWidget(), Qt::Dialog);
// }
setDefaultButton(d_func()->mDefaultButton);
}
QPixmap MessageBox::standardIcon(QMessageBox::Icon icon)
{
return MessageBoxPrivate::standardIcon(icon, nullptr);
}
void MessageBox::setWindowIcon(const QIcon &icon)
{
Q_D(MessageBox);
// d->mTitleIcon->setPixmap(icon.pixmap(QSize(22, 22)));
QDialog::setWindowIcon(icon);
}
bool MessageBox::event(QEvent *e)
{
Q_D(MessageBox);
bool result = QDialog::event(e);
switch (e->type()) {
case QEvent::ApplicationWindowIconChange:
if(icon() != QMessageBox::NoIcon)
setIcon(icon());
if(!windowIcon().isNull())
setWindowIcon(windowIcon());
break;
case QEvent::LayoutRequest:
{
d->updateSize();
break;
}
case QEvent::FontChange:
d->updateSize();
break;
case QEvent::ApplicationPaletteChange:
{
if (d->mInformativeLabel) {
QPalette palette = QGuiApplication::palette();
palette.setColor(QPalette::Text, palette.color(QPalette::Disabled, QPalette::Text));
d->mInformativeLabel->setPalette(palette);
}
}
default:
break;
}
return result;
}
void MessageBox::changeEvent(QEvent *event)
{
Q_D(MessageBox);
switch (event->type()) {
case QEvent::StyleChange:
{
if (d->mIcon != QMessageBox::NoIcon)
setIcon(d->mIcon);
Qt::TextInteractionFlags flags(style()->styleHint(QStyle::SH_MessageBox_TextInteractionFlags, nullptr, this));
d->mLabel->setTextInteractionFlags(flags);
d->mButtonBox->setCenterButtons(style()->styleHint(QStyle::SH_MessageBox_CenterButtons, nullptr, this));
if (d->mInformativeLabel)
d->mInformativeLabel->setTextInteractionFlags(flags);
Q_FALLTHROUGH();
}
case QEvent::FontChange:
case QEvent::ApplicationFontChange:
Q_FALLTHROUGH();
default:
break;
}
QDialog::changeEvent(event);
}
void MessageBox::showEvent(QShowEvent *event)
{
Q_D(MessageBox);
if (d->mAutoAddOkButton) {
addButton(QMessageBox::Ok);
}
if (d->mDetailButton) {
addButton(d->mDetailButton, QMessageBox::ActionRole);
}
d->detectEscapeButton();
d->updateSize();
#ifndef QT_NO_ACCESSIBILITY
QAccessibleEvent e(this, QAccessible::Alert);
QAccessible::updateAccessibility(&e);
#endif
QDialog::showEvent(event);
}
void MessageBox::closeEvent(QCloseEvent *event)
{
Q_D(MessageBox);
if (!d->mDetectedEscapeButton) {
event->ignore();
return;
}
QDialog::closeEvent(event);
d->mClickedButton = d->mDetectedEscapeButton;
setResult(d->execReturnCode(d->mDetectedEscapeButton));
}
void MessageBox::keyPressEvent(QKeyEvent* e)
{
#if QT_CONFIG(shortcut)
Q_D(MessageBox);
if (e->matches(QKeySequence::Cancel)) {
if (d->mDetectedEscapeButton) {
d->mDetectedEscapeButton->click();
}
return;
}
#endif // QT_CONFIG(shortcut)
#if !defined(QT_NO_CLIPBOARD) && !defined(QT_NO_SHORTCUT)
//#if QT_CONFIG(textedit)
// if (e == QKeySequence::Copy) {
// if (d->detailsText && d->detailsText->isVisible() && d->detailsText->copy()) {
// e->setAccepted(true);
// return;
// }
// } else if (e == QKeySequence::SelectAll && d->detailsText && d->detailsText->isVisible()) {
// d->detailsText->selectAll();
// e->setAccepted(true);
// return;
// }
//#endif // QT_CONFIG(textedit)
#ifndef QT_NO_SHORTCUT
#endif
#endif // !QT_NO_CLIPBOARD && !QT_NO_SHORTCUT
#ifndef QT_NO_SHORTCUT
if (!(e->modifiers() & (Qt::AltModifier | Qt::ControlModifier | Qt::MetaModifier))) {
int key = e->key() & ~Qt::MODIFIER_MASK;
if (key) {
const QList buttons = d->mButtonBox->buttons();
for (auto *pb : buttons) {
QKeySequence shortcut = pb->shortcut();
if (!shortcut.isEmpty() && key == int(shortcut[0] & ~Qt::MODIFIER_MASK)) {
pb->animateClick();
return;
}
}
}
}
#endif
QDialog::keyPressEvent(e);
}
void MessageBox::paintEvent(QPaintEvent *event)
{
Q_D(MessageBox);
QPainter painter (this);
QPalette palette;
painter.save();
painter.setRenderHint(QPainter::Antialiasing);
painter.setPen(Qt::NoPen);
painter.setBrush(palette.brush(QPalette::Base));
painter.drawRoundedRect(rect(), d->mRadius, d->mRadius);
painter.restore();
Q_UNUSED(event);
QDialog::paintEvent(event);
}
void MessageBox::resizeEvent(QResizeEvent *event)
{
QDialog::resizeEvent(event);
Q_UNUSED(event);
}
void MessageBox::initHelper(QPlatformMessageDialogHelper* h)
{
Q_D(MessageBox);
d->initHelper(h);
}
void MessageBox::setuplayout()
{
Q_D(MessageBox);
d->setupLayout();
}
void MessageBox::tableModeChanged(bool tableMode)
{
Q_D(MessageBox);
if(tableMode)
d->mCloseButtton->setFixedSize(48, 48);
else
d->mCloseButtton->setFixedSize(32, 32);
}
MessageBoxPrivate::MessageBoxPrivate() : mCheckbox(nullptr), mEscapeButton(nullptr), mDefaultButton(nullptr), mClickedButton(nullptr), mCompatMode(false), mAutoAddOkButton(true),
mDetectedEscapeButton(nullptr), mInformativeLabel(nullptr), mDetail(nullptr), mDetailButton(nullptr), mOptions(QMessageDialogOptions::create())
{
}
MessageBoxPrivate::~MessageBoxPrivate()
{
/*
if (nullptr != mLabel) {
delete mLabel;
}
if (nullptr != mIconLabel) {
delete mIconLabel;
}
if (nullptr != mButtonBox) {
delete mButtonBox;
}
if (nullptr != mDetail) {
delete mDetail;
}
if (nullptr != mDetailButton) {
delete mDetailButton;
}
*/
}
void MessageBoxPrivate::init(const QString &title, const QString &text)
{
Q_Q(MessageBox);
mLabel = new QLabel;
mLabel->setObjectName(QLatin1String("ukui_msgbox_label"));
mLabel->setTextInteractionFlags(Qt::TextInteractionFlags(q->style()->styleHint(QStyle::SH_MessageBox_TextInteractionFlags, 0, q)));
mLabel->setAlignment(Qt::AlignVCenter | Qt::AlignLeft);
mLabel->setOpenExternalLinks(true);
mIconLabel = new QLabel;
mIconLabel->setObjectName(QLatin1String("ukui_msgbox_icon_label"));
mIconLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
mIconLabel->setContentsMargins(0, 0, 0, 0);
mButtonBox = new QDialogButtonBox;
mButtonBox->setObjectName(QLatin1String("ukui_msgbox_buttonbox"));
mButtonBox->setCenterButtons(q->style()->styleHint(QStyle::SH_MessageBox_CenterButtons, nullptr, q));
QObject::connect(mButtonBox, SIGNAL(clicked(QAbstractButton*)), q, SLOT(_q_buttonClicked(QAbstractButton*)));
// bool isTableMode = false;
// QDBusMessage message = QDBusMessage::createMethodCall("com.kylin.statusmanager.interface",
// "/",
// "com.kylin.statusmanager.interface",
// "get_current_tabletmode");
// QDBusMessage ret = QDBusConnection::sessionBus().call(message);
// if (ret.type() != QDBusMessage::ReplyMessage)
// {
// //从返回参数获取返回值
// qDebug() << "complex type failed!";
// }
// else
// {
// isTableMode = ret.arguments()[0].value();
// }
mCloseButtton = new QPushButton();
mCloseButtton->setFlat(true);
mCloseButtton->setFocusPolicy(Qt::NoFocus);
mCloseButtton->setProperty("isWindowButton", 0x2);
mCloseButtton->setIcon(QIcon::fromTheme("window-close-symbolic"));
mCloseButtton->setIconSize(QSize(16, 16));
mCloseButtton->setToolTip(QObject::tr("Close"));
// if(isTableMode)//styleName == "ukui-dark"){//
// mCloseButtton->setFixedSize(48, 48);
// else
mCloseButtton->setFixedSize(32, 32);
QObject::connect(mCloseButtton, &QPushButton::clicked, q, [=]() {
q->close();
});
mTitleText = new QLabel();
// mTitleText->setText(title);
mTitleText->setText("");
// mTitleIcon = new QLabel();
// mTitleIcon->setPixmap(QIcon(qApp->windowIcon()).pixmap(QSize(22, 22)));
//mTitleIcon->setFixedSize(22, 22);
q->setModal(true);
mIcon = QMessageBox::NoIcon;
}
void MessageBoxPrivate::setupLayout()
{
Q_Q(MessageBox);
if (q->layout())
delete q->layout();
bool hasIcon = mIconLabel->pixmap() && !mIconLabel->pixmap()->isNull();
QGridLayout *gridLayout = new QGridLayout;
gridLayout->setContentsMargins(0, 0, 0, 32);
gridLayout->setHorizontalSpacing(8);
gridLayout->setVerticalSpacing(8);
if (hasIcon)
gridLayout->addWidget(mIconLabel, 0, 0, Qt::AlignTop);
gridLayout->addWidget(mLabel, 0, hasIcon ? 1 : 0);
if (mInformativeLabel) {
gridLayout->addWidget(mInformativeLabel, 1, hasIcon ? 1 : 0);
}
QHBoxLayout *buttonLayout = new QHBoxLayout;
buttonLayout->setSpacing(48);
if (mDetail && !mDetail->isHidden()) {
buttonLayout->setContentsMargins(0, 0, 0, 24);
} else {
buttonLayout->setContentsMargins(0, 0, 0, 0);
}
buttonLayout->setSizeConstraint(QLayout::SetNoConstraint);
if (mCheckbox) {
buttonLayout->addWidget(mCheckbox, 0, Qt::AlignLeft | Qt::AlignVCenter);
}
if (mButtonBox->layout()) {
mButtonBox->layout()->setSpacing(8);
}
buttonLayout->addWidget(mButtonBox, 0, Qt::AlignRight | Qt::AlignVCenter);
QVBoxLayout *contentLayout = new QVBoxLayout;
contentLayout->setContentsMargins(20, 0 , 20, 20);
contentLayout->setSpacing(0);
contentLayout->addLayout(gridLayout);
contentLayout->addLayout(buttonLayout);
if (mDetail) {
contentLayout->addWidget(mDetail);
}
QHBoxLayout *titleLayout = new QHBoxLayout;
titleLayout->setContentsMargins(20,0,0,0);
titleLayout->addWidget(mTitleText, Qt::AlignLeft | Qt::AlignVCenter);
titleLayout->addWidget(mCloseButtton, Qt::AlignRight | Qt::AlignVCenter);
QVBoxLayout *layout = new QVBoxLayout;
layout->setContentsMargins(4, 4, 4, 4);
layout->setSpacing(4);
// layout->addWidget(mCloseButtton, 0, Qt::AlignRight);
layout->addLayout(titleLayout);
layout->addSpacing(0);
layout->addLayout(contentLayout);
q->setLayout(layout);
updateSize();
}
void MessageBoxPrivate::updateSize()
{
Q_Q(MessageBox);
if (q->layout() == nullptr)
return;
if (QGuiApplication::screenAt(QCursor::pos()) == nullptr) {
return;
}
q->layout()->activate();
while (mButtonBox->layout()->count() < mButtonBox->buttons().count() + 1) {
QEvent event(QEvent::StyleChange);
QGuiApplication::sendEvent(mButtonBox, &event);
}
QSize minSize(424, 156);
QSize size;
QSize screenSize = QGuiApplication::screenAt(QCursor::pos())->availableGeometry().size();
QSize maxSize(screenSize.width() * 0.8, screenSize.height() * 0.8);
mLabel->setWordWrap(false);
if (mInformativeLabel) {
mInformativeLabel->setWordWrap(false);
}
q->layout()->activate();
if (q->sizeHint().width() > qMax(mButtonBox->sizeHint().width() + 24 + 24, 452)) {
mLabel->setWordWrap(true);
if (mInformativeLabel) {
mInformativeLabel->setWordWrap(true);
}
}
q->layout()->activate();
q->setContentsMargins(0, 0, 0, 0);
q->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
size.setWidth(qMax(qMin(maxSize.width(), q->sizeHint().width()), minSize.width()));
size.setHeight(qMax(qMin(maxSize.height(), q->layout()->hasHeightForWidth() ? q->layout()->totalHeightForWidth(size.width())
: q->layout()->totalMinimumSize().height()), minSize.height()));
q->setFixedSize(size);
QCoreApplication::removePostedEvents(q, QEvent::LayoutRequest);
}
int MessageBoxPrivate::layoutMinimumWidth()
{
layout->activate();
return layout->totalMinimumSize().width();
}
void MessageBoxPrivate::_q_buttonClicked(QAbstractButton* button)
{
Q_Q(MessageBox);
if (mDetailButton && mDetail && button == mDetailButton) {
mDetail->setHidden(!mDetail->isHidden());
mDetailButton->setText(mDetail->isHidden() ? QMessageBox::tr("Show Details...") : QMessageBox::tr("Hide Details..."));
setupLayout();
} else {
setClickedButton(button);
if (mReceiverToDisconnectOnClose) {
QObject::disconnect(q, mSignalToDisconnectOnClose, mReceiverToDisconnectOnClose,
mMemberToDisconnectOnClose);
mReceiverToDisconnectOnClose = nullptr;
}
mSignalToDisconnectOnClose.clear();
mMemberToDisconnectOnClose.clear();
}
}
void MessageBoxPrivate::_q_clicked(QPlatformDialogHelper::StandardButton button, QPlatformDialogHelper::ButtonRole role)
{
Q_Q(MessageBox);
if (button > QPlatformDialogHelper::LastButton) {
mClickedButton = static_cast(mOptions->customButton(button)->button);
Q_ASSERT(mClickedButton);
mClickedButton->click();
q->done(role);
} else {
q->done(button);
}
}
// after click button
void MessageBoxPrivate::setClickedButton(QAbstractButton *button)
{
Q_Q(MessageBox);
mClickedButton = button;
Q_EMIT q->buttonClicked(mClickedButton);
mClickedButton = button;
auto resultCode = execReturnCode(button);
hide(resultCode);
finalize(resultCode, dialogCodeForButton(button));
}
QAbstractButton* MessageBoxPrivate::findButton(int button0, int button1, int button2, int flags)
{
Q_Q(MessageBox);
int button = 0;
if (button0 & flags) {
button = button0;
} else if (button1 & flags) {
button = button1;
} else if (button2 & flags) {
button = button2;
}
return q->button(newButton(button));
}
static bool detectedCompat(int button0, int button1, int button2)
{
if (button0 != 0 && !(button0 & NewButtonMask)) {
return true;
}
if (button1 != 0 && !(button1 & NewButtonMask)) {
return true;
}
if (button2 != 0 && !(button2 & NewButtonMask)) {
return true;
}
return false;
}
void MessageBoxPrivate::addOldButtons(int button0, int button1, int button2)
{
Q_Q(MessageBox);
q->addButton(newButton(button0));
q->addButton(newButton(button1));
q->addButton(newButton(button2));
q->setDefaultButton(static_cast(findButton(button0, button1, button2, QMessageBox::Default)));
q->setEscapeButton(findButton(button0, button1, button2, QMessageBox::Escape));
mCompatMode = detectedCompat(button0, button1, button2);
}
QAbstractButton* MessageBoxPrivate::abstractButtonForId(int id) const
{
Q_Q(const MessageBox);
QAbstractButton *result = mCustomButtonList.value(id);
if (result) {
return result;
}
if (id & QMessageBox::FlagMask) {
return nullptr;
}
return q->button(newButton(id));
}
int MessageBoxPrivate::execReturnCode(QAbstractButton *button)
{
int ret = mButtonBox->standardButton(button);
if (ret == QMessageBox::NoButton) {
ret = mCustomButtonList.indexOf(button);
} else if (mCompatMode) {
ret = -1;
}
return ret;
}
int MessageBoxPrivate::dialogCodeForButton(QAbstractButton *button) const
{
Q_Q(const MessageBox);
switch (q->buttonRole(button)) {
case QMessageBox::AcceptRole:
case QMessageBox::YesRole:
return QDialog::Accepted;
case QMessageBox::RejectRole:
case QMessageBox::NoRole:
return QDialog::Rejected;
default:
return -1;
}
}
void MessageBoxPrivate::detectEscapeButton()
{
if (mEscapeButton) {
mDetectedEscapeButton = mEscapeButton;
return;
}
mDetectedEscapeButton = mButtonBox->button(QDialogButtonBox::Cancel);
if (mDetectedEscapeButton) {
return;
}
const QList buttons = mButtonBox->buttons();
if (buttons.count() == 1) {
mDetectedEscapeButton = buttons.first();
return;
}
if (buttons.count() == 2 && mDetailButton) {
auto idx = buttons.indexOf(mDetailButton);
if (idx != -1) {
mDetectedEscapeButton = buttons.at(1 - idx);
return;
}
}
for (auto *button : buttons) {
if (mButtonBox->buttonRole(button) == QDialogButtonBox::RejectRole) {
if (mDetectedEscapeButton) { // already detected!
mDetectedEscapeButton = nullptr;
break;
}
mDetectedEscapeButton = button;
}
}
if (mDetectedEscapeButton) {
return;
}
for (auto *button : buttons) {
if (mButtonBox->buttonRole(button) == QDialogButtonBox::NoRole) {
if (mDetectedEscapeButton) { // already detected!
mDetectedEscapeButton = nullptr;
break;
}
mDetectedEscapeButton = button;
}
}
}
QMessageBox::StandardButton MessageBoxPrivate::newButton(int button)
{
if (button == QMessageBox::NoButton) {
return QMessageBox::StandardButton(button & QMessageBox::ButtonMask);
}
return QMessageBox::NoButton;
}
int MessageBoxPrivate::showOldMessageBox(QWidget *parent, QMessageBox::Icon icon, const QString &title, const QString &text, int button0, int button1, int button2)
{
MessageBox messageBox;
messageBox.setIcon(icon);
messageBox.setText(text);
messageBox.setWindowTitle(title);
messageBox.d_func()->addOldButtons(button0, button1, button2);
Q_UNUSED(parent);
return messageBox.exec();
}
int MessageBoxPrivate::showOldMessageBox(QWidget *parent, QMessageBox::Icon icon, const QString &title, const QString &text, const QString &button0Text, const QString &button1Text, const QString &button2Text, int defaultButtonNumber, int escapeButtonNumber)
{
MessageBox messageBox;
messageBox.setIcon(icon);
messageBox.setText(text);
messageBox.setWindowTitle(title);
QString myButton0Text = button0Text;
if (myButton0Text.isEmpty()) {
myButton0Text = QDialogButtonBox::tr("OK");
}
messageBox.addButton(myButton0Text, QMessageBox::ActionRole);
if (!button1Text.isEmpty()) {
messageBox.addButton(button1Text, QMessageBox::ActionRole);
}
if (!button2Text.isEmpty()) {
messageBox.addButton(button2Text, QMessageBox::ActionRole);
}
const QList &buttonList = messageBox.d_func()->mCustomButtonList;
messageBox.setDefaultButton(static_cast(buttonList.value(defaultButtonNumber)));
messageBox.setEscapeButton(buttonList.value(escapeButtonNumber));
Q_UNUSED(parent);
return messageBox.exec();
}
QMessageBox::StandardButton MessageBoxPrivate::showNewMessageBox(QWidget *parent, QMessageBox::Icon icon, const QString &title, const QString &text, QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton)
{
if (defaultButton && !(buttons & defaultButton)) {
return (QMessageBox::StandardButton) MessageBoxPrivate::showOldMessageBox(parent, icon, title, text, int(buttons), int(defaultButton), 0);
}
MessageBox messageBox;
messageBox.setIcon(icon);
messageBox.setText(text);
messageBox.setWindowTitle(title);
QDialogButtonBox *buttonBox = messageBox.findChild();
Q_ASSERT(buttonBox != nullptr);
uint mask = QMessageBox::FirstButton;
while (mask <= QMessageBox::LastButton) {
uint sb = buttons & mask;
mask <<= 1;
if (!sb) {
continue;
}
QPushButton *button = messageBox.addButton((QMessageBox::StandardButton)sb);
if (messageBox.defaultButton()) {
continue;
}
if ((defaultButton == QMessageBox::NoButton && buttonBox->buttonRole(button) == QDialogButtonBox::AcceptRole) || (defaultButton != QMessageBox::NoButton && sb == uint(defaultButton))) {
messageBox.setDefaultButton(button);
}
}
if (messageBox.exec() == -1) {
return QMessageBox::Cancel;
}
return messageBox.standardButton(messageBox.clickedButton());
}
QPixmap MessageBoxPrivate::standardIcon(QMessageBox::Icon icon, MessageBox *mb)
{
QStyle *style = mb ? mb->style() : QApplication::style();
int iconSize = style->pixelMetric(QStyle::PM_MessageBoxIconSize, nullptr, mb);
QIcon tmpIcon;
switch (icon) {
case QMessageBox::Information:
tmpIcon = style->standardIcon(QStyle::SP_MessageBoxInformation, nullptr, mb);
break;
case QMessageBox::Warning:
tmpIcon = style->standardIcon(QStyle::SP_MessageBoxWarning, nullptr, mb);
break;
case QMessageBox::Critical:
tmpIcon = style->standardIcon(QStyle::SP_MessageBoxCritical, nullptr, mb);
break;
case QMessageBox::Question:
tmpIcon = style->standardIcon(QStyle::SP_MessageBoxQuestion, nullptr, mb);
default:
break;
}
if (!tmpIcon.isNull()) {
return tmpIcon.pixmap (QSize(iconSize, iconSize));
}
return QPixmap();
}
void MessageBoxPrivate::initHelper(QPlatformDialogHelper* h)
{
Q_Q(MessageBox);
QObject::connect(h, SIGNAL(clicked(QPlatformDialogHelper::StandardButton,QPlatformDialogHelper::ButtonRole)), q, SLOT(_q_clicked(QPlatformDialogHelper::StandardButton,QPlatformDialogHelper::ButtonRole)));
static_cast(h)->setOptions(mOptions);
}
void MessageBoxPrivate::helperPrepareShow(QPlatformDialogHelper*)
{
Q_Q(MessageBox);
mOptions->setWindowTitle(q->windowTitle());
mOptions->setText(q->text());
mOptions->setInformativeText(q->informativeText());
//#if QT_CONFIG(textedit)
// mOptions->setDetailedText(q->detailedText());
//#endif
mOptions->setIcon(helperIcon(q->icon()));
mOptions->setStandardButtons(helperStandardButtons(q));
}
void MessageBoxPrivate::helperDone(QDialog::DialogCode code, QPlatformDialogHelper*)
{
Q_Q(MessageBox);
QAbstractButton *button = q->button(QMessageBox::StandardButton(code));
if (button) {
mClickedButton = button;
}
}
static QPlatformDialogHelper::StandardButtons helperStandardButtons(MessageBox * q)
{
QPlatformDialogHelper::StandardButtons buttons(int(q->standardButtons()));
return buttons;
}
static QMessageDialogOptions::Icon helperIcon(QMessageBox::Icon i)
{
switch (i) {
case QMessageBox::NoIcon:
return QMessageDialogOptions::NoIcon;
case QMessageBox::Information:
return QMessageDialogOptions::Information;
case QMessageBox::Warning:
return QMessageDialogOptions::Warning;
case QMessageBox::Critical:
return QMessageDialogOptions::Critical;
case QMessageBox::Question:
return QMessageDialogOptions::Question;
}
return QMessageDialogOptions::NoIcon;
}
static QMessageBox::StandardButton newButton(int button)
{
// this is needed for source compatibility with Qt 4.0 and 4.1
if (button == QMessageBox::NoButton || (button & NewButtonMask))
return QMessageBox::StandardButton(button & QMessageBox::ButtonMask);
#if QT_VERSION < 0x050000
// this is needed for binary compatibility with Qt 4.0 and 4.1
switch (button & Old_ButtonMask) {
case Old_Ok:
return QMessageBox::Ok;
case Old_Cancel:
return QMessageBox::Cancel;
case Old_Yes:
return QMessageBox::Yes;
case Old_No:
return QMessageBox::No;
case Old_Abort:
return QMessageBox::Abort;
case Old_Retry:
return QMessageBox::Retry;
case Old_Ignore:
return QMessageBox::Ignore;
case Old_YesAll:
return QMessageBox::YesToAll;
case Old_NoAll:
return QMessageBox::NoToAll;
default:
return QMessageBox::NoButton;
}
#else
return QMessageBox::NoButton;
#endif
}
class MessageBoxOptionsPrivate : public QSharedData
{
public:
MessageBoxOptionsPrivate() :
icon(QMessageDialogOptions::NoIcon),
buttons(QPlatformDialogHelper::Ok),
nextCustomButtonId(QPlatformDialogHelper::LastButton + 1)
{
}
QString windowTitle;
QMessageDialogOptions::Icon icon;
QString text;
QString informativeText;
QString detailedText;
QPlatformDialogHelper::StandardButtons buttons;
QList customButtons;
int nextCustomButtonId;
};
MessageBoxHelper::MessageBoxHelper() : QPlatformMessageDialogHelper(), mMessageBox(new MessageBox)
{
connect(mMessageBox, &QDialog::accepted, this, &MessageBoxHelper::accept);
connect(mMessageBox, &QDialog::rejected, this, &MessageBoxHelper::reject);
}
MessageBoxHelper::~MessageBoxHelper()
{
if(mMessageBox){
mMessageBox->deleteLater();
mMessageBox = nullptr;
}
}
void MessageBoxHelper::exec()
{
int ret = mMessageBox->exec();
int role = mMessageBox->buttonRole(mMessageBox->clickedButton());
mMessageBox->done(ret);
Q_EMIT clicked((QPlatformDialogHelper::StandardButton)ret, QPlatformDialogHelper::ButtonRole(role));
}
void MessageBoxHelper::hide()
{
mMessageBox->hide();
}
bool MessageBoxHelper::show(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent)
{
initDialog(windowFlags, windowModality, parent);
if (parent && mMessageBox->find(parent->winId())) {
if (QWidget *p = mMessageBox->find(parent->winId())) {
for(QMessageBox *mb : p->findChildren())
{
if (mb->icon() == options()->icon() && mb->windowTitle() == options()->windowTitle() && mb->text() == options()->text()
&& mb->informativeText() == options()->informativeText() && mb->detailedText() == options()->detailedText()) {
if(!mb->windowIcon().isNull()){
mMessageBox->setWindowIcon(mb->windowIcon());
break;
}
}
}
//QMessageBox checkbox
if (p->findChild()) {
for (QMessageBox *mb : p->findChildren()) {
if (mb->icon() == options()->icon() && mb->windowTitle() == options()->windowTitle() && mb->text() == options()->text()
&& mb->informativeText() == options()->informativeText() && mb->detailedText() == options()->detailedText()) {
if (QCheckBox *cb = mb->findChild()) {
if (mb->layout() && (mb->layout()->indexOf(cb) != -1)) {
mMessageBox->setCheckBox(cb);
}
}
}
}
}
//QMessageBox custom icon
if (mMessageBox->icon() == QMessageBox::NoIcon) {
for (QMessageBox *mb : p->findChildren()) {
if (mb->icon() == options()->icon() && mb->windowTitle() == options()->windowTitle() && mb->text() == options()->text()
&& mb->informativeText() == options()->informativeText() && mb->detailedText() == options()->detailedText()) {
if (!mb->iconPixmap().isNull()) {
mMessageBox->setIconPixmap(mb->iconPixmap());
}
}
}
}
for (QMessageBox *mb : p->findChildren()) {
if (mb->icon() == options()->icon() && mb->windowTitle() == options()->windowTitle() && mb->text() == options()->text()
&& mb->informativeText() == options()->informativeText() && mb->detailedText() == options()->detailedText()) {
if(mb->escapeButton() && mMessageBox->escapeButton() != mb->escapeButton())
mMessageBox->setEscapeButton(mb->escapeButton());
if(mb->defaultButton()){
QString btnText = mb->defaultButton()->text();
foreach (QAbstractButton* btn, mMessageBox->buttons()) {
if(btn->text() == btnText){
mMessageBox->setDefaultButton(dynamic_cast(btn));
break;
}
}
}
}
}
if (windowModality == Qt::WindowModal && mMessageBox->parentWidget() != p) {
///QDialog center in parent
mMessageBox->setParent(p, Qt::Sheet);
}
else if(mMessageBox->parentWidget() != p){
///QDialog center in parent
mMessageBox->setParent(p, Qt::Dialog);
}
}
}
else{
if(windowModality == Qt::WindowModal && mMessageBox->windowFlags() != Qt::Sheet)
mMessageBox->setWindowFlag(Qt::Sheet);
else if(mMessageBox->windowFlags() != Qt::Dialog)
mMessageBox->setWindowFlag(Qt::Dialog);
}
if(parent == nullptr || mMessageBox->find(parent->winId()) == nullptr)
{
QList widgets = QApplication::allWidgets();
foreach (QWidget *w, widgets) {
if(QMessageBox *mb = qobject_cast(w)) {
if (mb->icon() == options()->icon() && mb->windowTitle() == options()->windowTitle() && mb->text() == options()->text()
&& mb->informativeText() == options()->informativeText() && mb->detailedText() == options()->detailedText()) {
if(mb->escapeButton() && mMessageBox->escapeButton() != mb->escapeButton())
mMessageBox->setEscapeButton(mb->escapeButton());
if(mb->defaultButton() == nullptr)
break;
QString btnText = mb->defaultButton()->text();
foreach (QAbstractButton* btn, mMessageBox->buttons()) {
if(btn->text() == btnText){
mMessageBox->setDefaultButton(dynamic_cast(btn));
break;
}
}
break;
}
}
}
}
mMessageBox->setuplayout();
/*
if (!mMessageBox->isVisible()) {
if(parent){
QWidget *p = mMessageBox->find(parent->winId());
int x = (p->width() - mMessageBox->width()) > 0 ? (p->width() - mMessageBox->width()) / 2 : 0;
int y = (p->height() - mMessageBox->height()) > 0 ? (p->height() - mMessageBox->height()) / 2 : 0;
QPoint gloabP = QPoint(x, y) + p->mapToGlobal(p->pos());
qDebug() << "gloabP...." << gloabP;
QPoint point = p->mapFromGlobal(gloabP);
qDebug() << "point....." << point;
if (windowModality == Qt::WindowModal) {
qDebug() << "WindowModal............";
mMessageBox->setParent(p, Qt::Sheet);
}
else{
qDebug() << "Dialog............";
mMessageBox->setParent(p, Qt::Dialog);
}
// mMessageBox->move(point);
qDebug() << "mMessageBox parent......" << p << p->geometry() << p->mapToGlobal(p->pos());
qDebug() << "mMessageBox ....." << mMessageBox << mMessageBox->geometry();
}
else{
int number = QApplication::desktop()->screenNumber(QCursor::pos());
if(number<0){
number=0;
}
QSize size = QApplication::screens().at(number)->availableGeometry().size();
// qDebug() << "availableGeometry......" << size << QApplication::screens().at(number)->availableSize();
mMessageBox->move(QPoint((size.width() - mMessageBox->width()) / 2, (size.height() - mMessageBox->height()) / 2));
}
// if (QWidget *p = mMessageBox->find(parent->winId())) {
// qDebug() << "isvisible....." << mMessageBox->isVisible();
// qDebug() << "p geometry1231233333......" << p << p->geometry() << p->mapToGlobal(QPoint(0,0));
// qDebug() << "parent geometry1231233333......" << parent << parent->geometry() << parent->mapToGlobal(QPoint(0,0));
// mMessageBox->move(QPoint((p->width() - mMessageBox->width()) / 2, (p->height() - mMessageBox->height()) / 2)
// + p->mapToGlobal(QPoint(0,0)));
// mMessageBox->move(QPoint((parent->width() - mMessageBox->width()) / 2, (parent->height() - mMessageBox->height()) / 2)
// + QPoint(parent->x(), parent->y()));
// qDebug() << "parent11111111............" << mMessageBox->geometry() << parent->geometry() << p->geometry();
// }
}
*/
//remove windows header
// QString platform = QGuiApplication::platformName();
// if(platform.startsWith(QLatin1String("wayland"),Qt::CaseInsensitive))
// {
// kdk::UkuiStyleHelper::self()->removeHeader(mMessageBox);
// } else {
// MotifWmHints hints;
// hints.flags = MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS;
// hints.functions = MWM_FUNC_ALL;
// hints.decorations = MWM_DECOR_BORDER;
// XAtomHelper::getInstance()->setWindowMotifHint(mMessageBox->winId(), hints);
// }
// UkuiWindowHelper *windowHelper = new UkuiWindowHelper(mMessageBox);
// windowHelper->removeTitleBar();
// windowHelper->setSkipTaskBar(true);
foreach (QAbstractButton *ab, mMessageBox->buttons()) {
if (QPushButton *pb = qobject_cast(ab)) {
if (pb->isDefault()) {
pb->setProperty("isImportant", true);
mMessageBox->setDefaultButton(pb);
} else {
pb->setProperty("isImportant", false);
}
}
}
mMessageBox->show();
return true;
}
void MessageBoxHelper::initDialog(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent)
{
if(!mMessageBox->isVisible())
mMessageBox->setWindowModality(windowModality);
mMessageBox->setIcon((QMessageBox::Icon)options()->icon());
mMessageBox->setText(options()->text());
mMessageBox->setInformativeText(options()->informativeText());
mMessageBox->setDetailedText(options()->detailedText());
mMessageBox->setWindowTitle(options()->windowTitle());
QPlatformDialogHelper::StandardButtons btns = options()->standardButtons();
uint mask = QMessageBox::FirstButton;
while (mask <= QMessageBox::LastButton) {
uint sb = btns & mask;
mask <<= 1;
if (!sb) {
continue;
}
mMessageBox->addButton((QMessageBox::StandardButton)sb);
}
for (QMessageDialogOptions::CustomButton button : options()->customButtons()) {
QAbstractButton *ab = static_cast(button.button);
if (ab) {
if (!ab->text().isEmpty() && ab->text() == QMessageBox::tr("Show Details...") || ab->text() == QMessageBox::tr("Hide Details..."))
continue;
ab->setIcon(QIcon());
}
mMessageBox->addButton(ab, QMessageBox::ButtonRole(button.role));
}
}
qt6-ukui-platformtheme/qt6-ukui-platformtheme/widget/messagebox/message-box.h 0000664 0001750 0001750 00000023714 15154306200 026372 0 ustar feng feng /*
* KWin Style UKUI
*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* Authors: xibowen
*
*/
#ifndef MESSAGEBOX_H
#define MESSAGEBOX_H
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "private/qdialog_p.h"
#include
// #include "ukuiwindowhelper.h"
class QLabel;
class QAbstractButton;
class MessageBoxHelper;
class MessageBoxPrivate;
class MessageBoxOptionsPrivate;
typedef QMessageBox::Icon Icon;
typedef QMessageBox::StandardButtons StandardButtons;
class MessageBox : public QDialog
{
Q_OBJECT
Q_PROPERTY(Icon mIcon READ icon WRITE setIcon)
Q_PROPERTY(QString mText READ text WRITE setText)
Q_PROPERTY(Qt::TextFormat textFormat READ textFormat WRITE setTextFormat)
Q_PROPERTY(QPixmap mIconPixmap READ iconPixmap WRITE setIconPixmap)
Q_PROPERTY(QString mInformativeText READ informativeText WRITE setInformativeText)
Q_PROPERTY(StandardButtons mStandardButtons READ standardButtons WRITE setStandardButtons)
Q_PROPERTY(Qt::TextInteractionFlags textInteractionFlags READ textInteractionFlags WRITE setTextInteractionFlags)
friend class MessageBoxHelper;
public:
explicit MessageBox(QWidget *parent = nullptr);
~MessageBox();
void setCheckBox(QCheckBox *cb);
QCheckBox* checkBox() const;
QMessageBox::Icon icon ();
void setIcon (QMessageBox::Icon icon);
QPixmap iconPixmap() const;
void setIconPixmap(const QPixmap &pixmap);
QString text();
void setText (const QString& text);
QString informativeText() const;
void setInformativeText(const QString &text);
QString detailedText() const;
void setDetailedText(const QString &text);
QString buttonText(int button) const;
void setButtonText(int button, const QString &text);
Qt::TextFormat textFormat() const;
void setTextFormat(Qt::TextFormat format);
void setTextInteractionFlags(Qt::TextInteractionFlags flags);
Qt::TextInteractionFlags textInteractionFlags() const;
void addButton(QAbstractButton *button, QMessageBox::ButtonRole role);
QPushButton* addButton(const QString &text, QMessageBox::ButtonRole role);
QPushButton* addButton(QMessageBox::StandardButton button);
void removeButton(QAbstractButton *button);
QAbstractButton* button (QMessageBox::StandardButton which) const;
QList buttons() const;
QMessageBox::ButtonRole buttonRole(QAbstractButton *button) const;
QMessageBox::StandardButtons standardButtons() const;
void setStandardButtons(QMessageBox::StandardButtons buttons);
QMessageBox::StandardButton standardButton(QAbstractButton *button) const;
QPushButton* defaultButton() const;
void setDefaultButton(QPushButton *button);
void setDefaultButton(QMessageBox::StandardButton button);
QAbstractButton* escapeButton() const;
void setEscapeButton(QAbstractButton *button);
void setEscapeButton(QMessageBox::StandardButton button);
QAbstractButton* clickedButton() const;
void setWindowTitle(const QString &title);
void setWindowModality(Qt::WindowModality windowModality);
static QPixmap standardIcon(QMessageBox::Icon icon);
void setWindowIcon(const QIcon &icon);
protected:
bool event(QEvent *e) override;
void changeEvent(QEvent *event) override;
void showEvent(QShowEvent *event) override;
virtual void closeEvent(QCloseEvent *event) override;
void keyPressEvent(QKeyEvent *event) override;
void paintEvent (QPaintEvent *event) override;
void resizeEvent(QResizeEvent *event) override;
private:
void initHelper(QPlatformMessageDialogHelper*);
void setuplayout();
public slots:
void tableModeChanged(bool isTableMode);
Q_SIGNALS:
void buttonClicked(QAbstractButton* button);
private:
Q_DISABLE_COPY(MessageBox)
Q_DECLARE_PRIVATE(MessageBox)
Q_PRIVATE_SLOT(d_func(), void _q_buttonClicked(QAbstractButton*))
Q_PRIVATE_SLOT(d_func(), void _q_clicked(QPlatformDialogHelper::StandardButton, QPlatformDialogHelper::ButtonRole))
// UkuiWindowHelper *m_windowHelper;
};
class MessageBoxHelper : public QPlatformMessageDialogHelper
{
Q_OBJECT
public:
explicit MessageBoxHelper();
~MessageBoxHelper() override;
virtual void exec() override;
virtual void hide() override;
virtual bool show(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent) override;
Q_SIGNALS:
void clicked(QPlatformDialogHelper::StandardButton button, QPlatformDialogHelper::ButtonRole role);
private:
void initDialog (Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent);
private:
MessageBox* mMessageBox = nullptr;
};
class TextEdit : public QTextEdit
{
public:
TextEdit(QWidget *parent=0) : QTextEdit(parent) { }
void contextMenuEvent(QContextMenuEvent * e) override
{
QMenu *menu = createStandardContextMenu();
menu->setAttribute(Qt::WA_DeleteOnClose);
menu->popup(e->globalPos());
}
};
class MessageBoxPrivate : public QDialogPrivate
{
Q_DECLARE_PUBLIC(MessageBox)
public:
MessageBoxPrivate ();
~MessageBoxPrivate ();
void init (const QString &title = QString(), const QString &text = QString());
void setupLayout ();
void _q_buttonClicked(QAbstractButton*);
void _q_clicked(QPlatformDialogHelper::StandardButton button, QPlatformDialogHelper::ButtonRole role);
void setClickedButton(QAbstractButton *button);
QAbstractButton* findButton(int button0, int button1, int button2, int flags);
void addOldButtons(int button0, int button1, int button2);
QAbstractButton *abstractButtonForId(int id) const;
int execReturnCode(QAbstractButton *button);
int dialogCodeForButton(QAbstractButton *button) const;
void updateSize();
int layoutMinimumWidth();
void detectEscapeButton();
static QMessageBox::StandardButton newButton(int button);
static int showOldMessageBox(QWidget *parent, QMessageBox::Icon icon, const QString &title, const QString &text, int button0, int button1, int button2);
static int showOldMessageBox(QWidget *parent, QMessageBox::Icon icon, const QString &title, const QString &text, const QString &btn0Text, const QString &btn1Text, const QString &btn2Text, int defBtnNum, int espBtnNum);
static QPixmap standardIcon(QMessageBox::Icon icon, MessageBox *mb);
static QMessageBox::StandardButton showNewMessageBox(QWidget *parent, QMessageBox::Icon icon, const QString& title, const QString& text, QMessageBox::StandardButtons btn, QMessageBox::StandardButton defBtn);
private:
void initHelper(QPlatformDialogHelper*) override;
void helperPrepareShow(QPlatformDialogHelper*) override;
void helperDone(QDialog::DialogCode, QPlatformDialogHelper*) override;
public:
QLabel* mLabel = nullptr;
QLabel* mInformativeLabel = nullptr;
TextEdit* mDetail = nullptr; // qt 显示 label 暂定使用富文本框
QCheckBox* mCheckbox = nullptr; // qt checkbox
QLabel* mIconLabel = nullptr; // qt 显示图标
QDialogButtonBox* mButtonBox = nullptr; // qt 按钮框
QPushButton* mDetailButton = nullptr; // 详细情况按钮
QPushButton* mCloseButtton = nullptr; //标题栏关闭按钮
QLabel* mTitleText = nullptr; //标题文本
QLabel* mTitleIcon = nullptr; //标题icon
QByteArray mMemberToDisconnectOnClose;
QByteArray mSignalToDisconnectOnClose;
QPointer mReceiverToDisconnectOnClose;
QString mTipString; // 原始的需要展示的文本
QMessageBox::Icon mIcon;
QList mCustomButtonList; // 自定义按钮
QAbstractButton* mEscapeButton = nullptr;
QPushButton* mDefaultButton = nullptr;
QAbstractButton* mClickedButton = nullptr; // 复选框按钮
bool mCompatMode;
bool mShowDetail; // 是否显示详细信息
bool mAutoAddOkButton;
// QTextEdit* informativeTextEdit;
QAbstractButton* mDetectedEscapeButton = nullptr;
QSharedPointer mOptions;
private:
int mRadius = 0;
int mIconSize = 24;
};
#endif // MESSAGEBOX_H
qt6-ukui-platformtheme/qt6-ukui-platformtheme/widget/filedialog/ 0000775 0001750 0001750 00000000000 15154306200 023742 5 ustar feng feng qt6-ukui-platformtheme/qt6-ukui-platformtheme/widget/filedialog/xdgdesktopportalfiledialog.cpp 0000664 0001750 0001750 00000044622 15154306200 032074 0 ustar feng feng /****************************************************************************
**
** Copyright (C) 2017-2018 Red Hat, Inc
** Contact: https://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 3 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL3 included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 3 requirements
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 2.0 or (at your option) the GNU General
** Public license version 3 or any later version approved by the KDE Free
** Qt Foundation. The licenses are as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
** https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
** Modified by: Tan Jing on 2025-04-02
****************************************************************************/
#include "xdgdesktopportalfiledialog_p.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
QT_BEGIN_NAMESPACE
QDBusArgument &operator <<(QDBusArgument &arg, const XdgDesktopPortalFileDialog::FilterCondition &filterCondition)
{
arg.beginStructure();
arg << filterCondition.type << filterCondition.pattern;
arg.endStructure();
return arg;
}
const QDBusArgument &operator >>(const QDBusArgument &arg, XdgDesktopPortalFileDialog::FilterCondition &filterCondition)
{
uint type;
QString filterPattern;
arg.beginStructure();
arg >> type >> filterPattern;
filterCondition.type = (XdgDesktopPortalFileDialog::ConditionType)type;
filterCondition.pattern = filterPattern;
arg.endStructure();
return arg;
}
QDBusArgument &operator <<(QDBusArgument &arg, const XdgDesktopPortalFileDialog::Filter filter)
{
arg.beginStructure();
arg << filter.name << filter.filterConditions;
arg.endStructure();
return arg;
}
const QDBusArgument &operator >>(const QDBusArgument &arg, XdgDesktopPortalFileDialog::Filter &filter)
{
QString name;
XdgDesktopPortalFileDialog::FilterConditionList filterConditions;
arg.beginStructure();
arg >> name >> filterConditions;
filter.name = name;
filter.filterConditions = filterConditions;
arg.endStructure();
return arg;
}
class XdgDesktopPortalFileDialogPrivate
{
public:
XdgDesktopPortalFileDialogPrivate(QPlatformFileDialogHelper *nativeFileDialog)
: nativeFileDialog(nativeFileDialog)
{ }
WId winId = 0;
bool directoryMode = false;
bool modal = false;
bool multipleFiles = false;
bool saveFile = false;
QString acceptLabel;
QString directory;
QString title;
QStringList nameFilters;
QStringList mimeTypesFilters;
// maps user-visible name for portal to full name filter
QMap userVisibleToNameFilter;
QString selectedMimeTypeFilter;
QString selectedNameFilter;
QStringList selectedFiles;
QPlatformFileDialogHelper *nativeFileDialog = nullptr;
};
XdgDesktopPortalFileDialog::XdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog)
: QPlatformFileDialogHelper()
, d_ptr(new XdgDesktopPortalFileDialogPrivate(nativeFileDialog))
{
Q_D(XdgDesktopPortalFileDialog);
if (d->nativeFileDialog) {
connect(d->nativeFileDialog, SIGNAL(accept()), this, SIGNAL(accept()));
connect(d->nativeFileDialog, SIGNAL(reject()), this, SIGNAL(reject()));
}
}
XdgDesktopPortalFileDialog::~XdgDesktopPortalFileDialog()
{
}
void XdgDesktopPortalFileDialog::initializeDialog()
{
Q_D(XdgDesktopPortalFileDialog);
if (d->nativeFileDialog)
d->nativeFileDialog->setOptions(options());
if (options()->fileMode() == QFileDialogOptions::ExistingFiles)
d->multipleFiles = true;
if (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly)
d->directoryMode = true;
if (options()->isLabelExplicitlySet(QFileDialogOptions::Accept))
d->acceptLabel = options()->labelText(QFileDialogOptions::Accept);
if (!options()->windowTitle().isEmpty())
d->title = options()->windowTitle();
if (options()->acceptMode() == QFileDialogOptions::AcceptSave)
d->saveFile = true;
if (!options()->nameFilters().isEmpty())
d->nameFilters = options()->nameFilters();
if (!options()->mimeTypeFilters().isEmpty())
d->mimeTypesFilters = options()->mimeTypeFilters();
if (!options()->initiallySelectedMimeTypeFilter().isEmpty())
d->selectedMimeTypeFilter = options()->initiallySelectedMimeTypeFilter();
if (!options()->initiallySelectedNameFilter().isEmpty())
d->selectedNameFilter = options()->initiallySelectedNameFilter();
setDirectory(options()->initialDirectory());
}
void XdgDesktopPortalFileDialog::openPortal()
{
Q_D(XdgDesktopPortalFileDialog);
// qDebug() << "openPortal 11111111............" << d->saveFile ;
QDBusMessage message = QDBusMessage::createMethodCall(QLatin1String("org.freedesktop.portal.Desktop"),
QLatin1String("/org/freedesktop/portal/desktop"),
QLatin1String("org.freedesktop.portal.FileChooser"),
d->saveFile ? QLatin1String("SaveFile") : QLatin1String("OpenFile"));
QString parentWindowId;
QString platform = QGuiApplication::platformName();
if(platform.startsWith(QLatin1String("wayland"),Qt::CaseInsensitive))
{
parentWindowId = QLatin1String("wayland:") + QString::number(d->winId);
} else {
parentWindowId = QLatin1String("x11:") + QString::number(d->winId);
}
QVariantMap options;
if (!d->acceptLabel.isEmpty())
options.insert(QLatin1String("accept_label"), d->acceptLabel);
options.insert(QLatin1String("modal"), d->modal);
options.insert(QLatin1String("multiple"), d->multipleFiles);
options.insert(QLatin1String("directory"), d->directoryMode);
options.insert(QLatin1String("current_folder"), QFile::encodeName(m_initialPath).append('\0'));
if (d->saveFile) {
if (!m_initialSelectFiles.isEmpty()){
options.insert(QLatin1String("current_file"), QFile::encodeName(m_initialSelectFiles.first().path()).append('\0'));
if(!m_initialSelectFiles.first().path().endsWith("/")){
QString name = m_initialSelectFiles.first().path().split("/").last();
options.insert(QLatin1String("current_name"), name);
}
}
}
// Insert filters
qDBusRegisterMetaType();
qDBusRegisterMetaType();
qDBusRegisterMetaType();
qDBusRegisterMetaType();
FilterList filterList;
auto selectedFilterIndex = filterList.size() - 1;
d->userVisibleToNameFilter.clear();
// qDebug() << "mimeTypesFilters..." << d->mimeTypesFilters << d->nameFilters;
if (!d->mimeTypesFilters.isEmpty()) {
for (const QString &mimeTypefilter : d->mimeTypesFilters) {
QMimeDatabase mimeDatabase;
QMimeType mimeType = mimeDatabase.mimeTypeForName(mimeTypefilter);
// Creates e.g. (1, "image/png")
FilterCondition filterCondition;
filterCondition.type = MimeType;
filterCondition.pattern = mimeTypefilter;
// Creates e.g. [((1, "image/png"))]
FilterConditionList filterConditions;
filterConditions << filterCondition;
// Creates e.g. [("Images", [((1, "image/png"))])]
Filter filter;
filter.name = mimeType.comment();
filter.filterConditions = filterConditions;
filterList << filter;
if (!d->selectedMimeTypeFilter.isEmpty() && d->selectedMimeTypeFilter == mimeTypefilter)
selectedFilterIndex = filterList.size() - 1;
}
} else if (!d->nameFilters.isEmpty()) {
for (const QString &nameFilter : d->nameFilters) {
// Do parsing:
// Supported format is ("Images (*.png *.jpg)")
QRegularExpression regexp(QPlatformFileDialogHelper::filterRegExp);
QRegularExpressionMatch match = regexp.match(nameFilter);
if (match.hasMatch()) {
QString userVisibleName = match.captured(1);
QStringList filterStrings = match.captured(2).split(QLatin1Char(' '), Qt::SkipEmptyParts);
if (filterStrings.isEmpty()) {
qWarning() << "Filter " << userVisibleName << " is empty and will be ignored.";
continue;
}
FilterConditionList filterConditions;
for (const QString &filterString : filterStrings) {
FilterCondition filterCondition;
filterCondition.type = GlobalPattern;
filterCondition.pattern = filterString;
filterConditions << filterCondition;
}
if(userVisibleName.isEmpty())
userVisibleName = " ";
Filter filter;
filter.name = userVisibleName;
filter.filterConditions = filterConditions;
filterList << filter;
d->userVisibleToNameFilter.insert(userVisibleName, nameFilter);
if (!d->selectedNameFilter.isEmpty() && d->selectedNameFilter == nameFilter)
selectedFilterIndex = filterList.size() - 1;
}
}
}
// "[('Images', [(0, '*ico'), (1, 'image/png')]), ('Text', [(0, '*.txt')])]";
if (!filterList.isEmpty())
options.insert(QLatin1String("filters"), QVariant::fromValue(filterList));
if (selectedFilterIndex != -1)
options.insert(QLatin1String("current_filter"), QVariant::fromValue(filterList[selectedFilterIndex]));
options.insert(QLatin1String("handle_token"), QStringLiteral("qt%1").arg(QRandomGenerator::global()->generate()));
// TODO choices a(ssa(ss)s)
// List of serialized combo boxes to add to the file chooser.
message << parentWindowId << d->title << options;
QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingCall);
connect(watcher, &QDBusPendingCallWatcher::finished, this, [this] (QDBusPendingCallWatcher *watcher) {
QDBusPendingReply reply = *watcher;
if (reply.isError()) {
qWarning() << "reply error......" << reply.error();
Q_EMIT reject();
} else {
QDBusConnection::sessionBus().connect(nullptr,
reply.value().path(),
QLatin1String("org.freedesktop.portal.Request"),
QLatin1String("Response"),
this,
SLOT(gotResponse(uint,QVariantMap)));
}
});
}
bool XdgDesktopPortalFileDialog::defaultNameFilterDisables() const
{
return false;
}
void XdgDesktopPortalFileDialog::setDirectory(const QUrl &directory)
{
Q_D(XdgDesktopPortalFileDialog);
if (d->nativeFileDialog) {
d->nativeFileDialog->setOptions(options());
d->nativeFileDialog->setDirectory(directory);
}
d->directory = directory.path();
}
QUrl XdgDesktopPortalFileDialog::directory() const
{
Q_D(const XdgDesktopPortalFileDialog);
if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
return d->nativeFileDialog->directory();
return d->directory;
}
void XdgDesktopPortalFileDialog::selectFile(const QUrl &filename)
{
Q_D(XdgDesktopPortalFileDialog);
if (d->nativeFileDialog) {
d->nativeFileDialog->setOptions(options());
d->nativeFileDialog->selectFile(filename);
}
d->selectedFiles << filename.path();
}
QList XdgDesktopPortalFileDialog::selectedFiles() const
{
Q_D(const XdgDesktopPortalFileDialog);
if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
return d->nativeFileDialog->selectedFiles();
QList files;
for (const QString &file : d->selectedFiles) {
files << QUrl(file);
}
return files;
}
void XdgDesktopPortalFileDialog::setFilter()
{
Q_D(XdgDesktopPortalFileDialog);
if (d->nativeFileDialog) {
d->nativeFileDialog->setOptions(options());
d->nativeFileDialog->setFilter();
}
}
void XdgDesktopPortalFileDialog::selectMimeTypeFilter(const QString &filter)
{
Q_D(XdgDesktopPortalFileDialog);
if (d->nativeFileDialog) {
d->nativeFileDialog->setOptions(options());
d->nativeFileDialog->selectMimeTypeFilter(filter);
}
}
QString XdgDesktopPortalFileDialog::selectedMimeTypeFilter() const
{
Q_D(const XdgDesktopPortalFileDialog);
return d->selectedMimeTypeFilter;
}
void XdgDesktopPortalFileDialog::selectNameFilter(const QString &filter)
{
Q_D(XdgDesktopPortalFileDialog);
if (d->nativeFileDialog) {
d->nativeFileDialog->setOptions(options());
d->nativeFileDialog->selectNameFilter(filter);
}
}
QString XdgDesktopPortalFileDialog::selectedNameFilter() const
{
Q_D(const XdgDesktopPortalFileDialog);
return d->selectedNameFilter;
}
void XdgDesktopPortalFileDialog::exec()
{
Q_D(XdgDesktopPortalFileDialog);
if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly)) {
d->nativeFileDialog->exec();
return;
}
// HACK we have to avoid returning until we emit that the dialog was accepted or rejected
QEventLoop loop;
loop.connect(this, SIGNAL(accept()), SLOT(quit()));
loop.connect(this, SIGNAL(reject()), SLOT(quit()));
loop.exec();
}
void XdgDesktopPortalFileDialog::hide()
{
Q_D(XdgDesktopPortalFileDialog);
if (d->nativeFileDialog)
d->nativeFileDialog->hide();
}
bool XdgDesktopPortalFileDialog::show(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent)
{
Q_D(XdgDesktopPortalFileDialog);
// qDebug() << "show 2222222222222";
m_initialDirectory = options()->initialDirectory();
m_initialSelectFiles = options()->initiallySelectedFiles();
initializeDialog();
d->modal = windowModality != Qt::NonModal;
d->winId = 0;
if (d->nativeFileDialog && (options()->fileMode() == QFileDialogOptions::Directory || options()->fileMode() == QFileDialogOptions::DirectoryOnly))
return d->nativeFileDialog->show(windowFlags, windowModality, parent);
for(QWidget *widget : qApp->allWidgets()){
if(QFileDialog *fd = qobject_cast(widget)){
if(options()->windowTitle() == fd->windowTitle()){
// qDebug() << "parent us null filedoalog set parent...." << fd->geometry() << options()->windowTitle() << fd->objectName();
d->winId = fd->winId();
// qDebug() << "parent us null filedoalog directory...." << fd->directory();
// qDebug() << "parent us null filedoalog selectedFiles11111111...." << fd->selectedFiles();
if(m_initialSelectFiles.length() > 0 && QFile::exists(m_initialSelectFiles.value(0).path())){
QDir dir(m_initialSelectFiles.value(0).path());
dir.cdUp();
// qDebug() <<"dirrrrr..." << dir.path();
m_initialPath = dir.absolutePath();
}
else if(fd->directory().exists() /*|| Peony::FileUtils::isFileExsit(fd->directory().path())*/){
// qDebug() << "updatePath........." << fd->directory();
m_initialPath = fd->directory().absolutePath();
}
break;
}
}
}
openPortal();
// qDebug() << "show 1111111111111111111";
return true;
}
void XdgDesktopPortalFileDialog::gotResponse(uint response, const QVariantMap &results)
{
Q_D(XdgDesktopPortalFileDialog);
if (!response) {
if (results.contains(QLatin1String("uris")))
d->selectedFiles = results.value(QLatin1String("uris")).toStringList();
if (results.contains(QLatin1String("current_filter"))) {
const Filter selectedFilter = qdbus_cast(results.value(QStringLiteral("current_filter")));
if (!selectedFilter.filterConditions.empty() && selectedFilter.filterConditions[0].type == MimeType) {
// s.a. XdgDesktopPortalFileDialog::openPortal which basically does the inverse
d->selectedMimeTypeFilter = selectedFilter.filterConditions[0].pattern;
d->selectedNameFilter.clear();
} else {
d->selectedNameFilter = d->userVisibleToNameFilter.value(selectedFilter.name);
d->selectedMimeTypeFilter.clear();
}
}
Q_EMIT accept();
} else {
Q_EMIT reject();
}
}
QT_END_NAMESPACE
qt6-ukui-platformtheme/qt6-ukui-platformtheme/widget/filedialog/xdgdesktopportalfiledialog_p.h 0000664 0001750 0001750 00000010314 15154306200 032047 0 ustar feng feng /****************************************************************************
**
** Copyright (C) 2017-2018 Red Hat, Inc
** Contact: https://www.qt.io/licensing/
**
** This file is part of the plugins of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 3 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL3 included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 3 requirements
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 2.0 or (at your option) the GNU General
** Public license version 3 or any later version approved by the KDE Free
** Qt Foundation. The licenses are as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
** https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
** Modified by: Tan Jing on 2025-04-02
****************************************************************************/
#ifndef XDGDESKTOPPORTALFILEDIALOG_P_H
#define XDGDESKTOPPORTALFILEDIALOG_P_H
#include
#include
QT_BEGIN_NAMESPACE
class XdgDesktopPortalFileDialogPrivate;
class XdgDesktopPortalFileDialog : public QPlatformFileDialogHelper
{
Q_OBJECT
Q_DECLARE_PRIVATE(XdgDesktopPortalFileDialog)
public:
enum ConditionType : uint {
GlobalPattern = 0,
MimeType = 1
};
// Filters a(sa(us))
// Example: [('Images', [(0, '*.ico'), (1, 'image/png')]), ('Text', [(0, '*.txt')])]
struct FilterCondition {
ConditionType type;
QString pattern; // E.g. '*ico' or 'image/png'
};
typedef QVector FilterConditionList;
struct Filter {
QString name; // E.g. 'Images' or 'Text
FilterConditionList filterConditions;; // E.g. [(0, '*.ico'), (1, 'image/png')] or [(0, '*.txt')]
};
typedef QVector FilterList;
XdgDesktopPortalFileDialog(QPlatformFileDialogHelper *nativeFileDialog = nullptr);
~XdgDesktopPortalFileDialog();
bool defaultNameFilterDisables() const override;
QUrl directory() const override;
void setDirectory(const QUrl &directory) override;
void selectFile(const QUrl &filename) override;
QList selectedFiles() const override;
void setFilter() override;
void selectNameFilter(const QString &filter) override;
QString selectedNameFilter() const override;
void selectMimeTypeFilter(const QString &filter) override;
QString selectedMimeTypeFilter() const override;
void exec() override;
bool show(Qt::WindowFlags windowFlags, Qt::WindowModality windowModality, QWindow *parent) override;
void hide() override;
private Q_SLOTS:
void gotResponse(uint response, const QVariantMap &results);
private:
void initializeDialog();
void openPortal();
private:
QUrl m_initialDirectory;
QList m_initialSelectFiles;
QString m_initialPath;
QScopedPointer d_ptr;
};
QT_END_NAMESPACE
Q_DECLARE_METATYPE(XdgDesktopPortalFileDialog::FilterCondition);
Q_DECLARE_METATYPE(XdgDesktopPortalFileDialog::FilterConditionList);
Q_DECLARE_METATYPE(XdgDesktopPortalFileDialog::Filter);
Q_DECLARE_METATYPE(XdgDesktopPortalFileDialog::FilterList);
#endif // XDGDESKTOPPORTALFILEDIALOG_P_H
qt6-ukui-platformtheme/qt6-ukui-platformtheme/CMakeLists.txt 0000664 0001750 0001750 00000011566 15154306200 023131 0 ustar feng feng cmake_minimum_required(VERSION 3.16)
project(qt6-ukui-platformtheme)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(QT_MIN_VERSION "6.2.0")
set(KF5_MIN_VERSION "5.66.0")
find_package(Qt6 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS
DBus
Widgets
Gui
Quick
QuickControls2
LinguistTools
# 移除私有模块的直接 find_package 引用,改为通过目标属性获取
)
# 显式查找 Qt6 私有模块(Qt6 正确的私有模块引用方式)
find_package(Qt6 REQUIRED COMPONENTS GuiPrivate WidgetsPrivate)
message("Qt6Widgets_INCLUDE: ${Qt6Widgets_INCLUDE_DIRS}")
# 修正变量名:Qt6Widgets_PRIVATE_INCLUDE → Qt6Widgets_PRIVATE_INCLUDES
get_target_property(Qt6Gui_PRIVATE_INCLUDES Qt6::Gui INTERFACE_INCLUDE_DIRECTORIES)
get_target_property(Qt6Widgets_PRIVATE_INCLUDES Qt6::Widgets INTERFACE_INCLUDE_DIRECTORIES)
foreach(_dir ${Qt6Gui_PRIVATE_INCLUDES})
message(${_dir})
string(REGEX MATCHALL "QtGui" matches "${_dir}")
list(LENGTH matches match_count)
if(${match_count} EQUAL 2)
string(REPLACE "QtGui" "QtThemeSupport" ThemeSupport_string "${_dir}")
endif()
endforeach()
include_directories(${ThemeSupport_string})
# 修正变量名:Qt6Widgets_PRIVATE_INCLUDE → Qt6Widgets_PRIVATE_INCLUDES
include_directories(${Qt6Widgets_PRIVATE_INCLUDES})
include_directories(${Qt6Gui_PRIVATE_INCLUDES})
# 修正变量名输出
message("Qt6Widgets_PRIVATE_INCLUDES: ${Qt6Widgets_PRIVATE_INCLUDES}")
message("Qt6Gui_PRIVATE_INCLUDES: ${Qt6Gui_PRIVATE_INCLUDES}")
find_package(X11)
find_package(PkgConfig)
pkg_check_modules(QGSETTINGS REQUIRED gsettings-qt6)
pkg_check_modules(FONTCONFIG REQUIRED fontconfig)
pkg_check_modules(FREETYPE2 REQUIRED freetype2)
pkg_check_modules(GLIB2 REQUIRED glib-2.0 gio-2.0)
include_directories(
${QGSETTINGS_INCLUDE_DIRS}
${GLIB2_INCLUDE_DIRS}
../libqt6-ukui-style/
../ukui-styles/
)
if (FONTCONFIG_FOUND)
include_directories(${FONTCONFIG_INCLUDE_DIRS})
link_directories(${FONTCONFIG_LIBRARY_DIRS})
endif()
if (FREETYPE2_FOUND)
include_directories(${FREETYPE2_INCLUDE_DIRS})
link_directories(${FREETYPE2_LIBRARY_DIRS})
endif()
if (KYSDKWAYLANDHELPER_FOUND)
include_directories(${KYSDKWAYLANDHELPER_INCLUDE_DIRS})
link_directories(${KYSDKWAYLANDHELPER_LIBRARY_DIRS})
endif()
if (QGSETTINGS_FOUND)
include_directories(${QGSETTINGS_INCLUDE_DIRS})
link_directories(${QGSETTINGS_LIBRARY_DIRS})
endif()
if (UKUIWINDOWHELPER_FOUND)
include_directories(${UKUIWINDOWHELPER_INCLUDE_DIRS})
link_directories(${UKUIWINDOWHELPER_LIBRARY_DIRS})
endif()
file(GLOB_RECURSE ConfigSources
../ukui-styles/readconfig.cpp
)
file(GLOB_RECURSE ConfigHeaders
../ukui-styles/readconfig.h
)
set(sources
main.cpp
platform-theme-fontdata.cpp
platform-theme-fontdata.h
qt5-ukui-platform-theme.cpp
qt5-ukui-platformtheme_global.h
qt5-ukui-platform-theme.h
xatom-helper.cpp
xatom-helper.h
widget/filedialog/xdgdesktopportalfiledialog.cpp
widget/filedialog/xdgdesktopportalfiledialog_p.h
)
set(Json
ukui.json
)
file(GLOB TS_FILES "${CMAKE_CURRENT_SOURCE_DIR}/translations/*.ts")
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${sources} ${Json} ${TS_FILES})
set(UKUI_TRANSLATIONS_DIR "/usr/share/qt6-ukui-platformtheme")
add_definitions(-DUKUI_TRANSLATIONS_DIR="${UKUI_TRANSLATIONS_DIR}")
if (NOT DEFINED UPDATE_TRANSLATIONS)
set(UPDATE_TRANSLATIONS "No")
endif()
if (UPDATE_TRANSLATIONS)
qt6_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
else()
qt6_add_translation(QM_FILES ${TS_FILES})
endif()
add_custom_target(themetranslations ALL DEPENDS ${QM_FILES})
add_library(qt6-ukui-platformtheme MODULE
${sources}
${Json}
${TS_FILES}
${ConfigSources} ${ConfigHeaders}
)
target_link_libraries(qt6-ukui-platformtheme PRIVATE
Qt6::Widgets
Qt6::DBus
Qt6::Gui
Qt6::Quick
Qt6::QuickControls2
${UKUIWINDOWHELPER_LIBRARIES}
${QGSETTINGS_LIBRARIES}
xcb
glib-2.0
${X11_LIBRARIES}
qt6-ukui-style
${FONTCONFIG_LIBRARIES}
${FREETYPE2_LIBRARIES}
${KYSDKWAYLANDHELPER_LIBRARIES}
# 确保私有模块正确链接
Qt6::GuiPrivate
Qt6::WidgetsPrivate
)
target_compile_definitions(qt6-ukui-platformtheme PRIVATE
-DQT5UKUIPLATFORMTHEME_LIBRARY
-DQT_DEPRECATED_WARNINGS
-DQT_MESSAGELOGCONTEXT
-DQT_DISABLE_DEPRECATED_BEFORE=0x060000
)
set(TARGET_PATH "/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}/qt6/plugins")
set(UKUIPLATFORMTHEME_DIR ${TARGET_PATH})
target_compile_definitions(qt6-ukui-platformtheme PRIVATE
UKUIPLATFORMTHEME_DIR="${UKUIPLATFORMTHEME_DIR}"
)
if(UNIX)
MESSAGE("libqt6-ukui-platformtheme TARGET_PATH: ${TARGET_PATH}")
install(TARGETS ${PROJECT_NAME} DESTINATION ${TARGET_PATH}/platformthemes/)
install(FILES ${QM_FILES} DESTINATION "${UKUI_TRANSLATIONS_DIR}")
endif()
qt6-ukui-platformtheme/qt6-ukui-platformtheme/main.cpp 0000664 0001750 0001750 00000002535 15154306200 022015 0 ustar feng feng /*
* Qt5-UKUI's Library
*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library. If not, see .
*
* Authors: Yue Lan
*
*/
#include
#include "qt5-ukui-platform-theme.h"
#include
#include
#define UKUI_PLATFORMTHEME
QT_BEGIN_NAMESPACE
class Qt5UKUIPlatformThemePlugin : public QPlatformThemePlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID QPlatformThemeFactoryInterface_iid FILE "ukui.json")
public:
virtual QPlatformTheme *create(const QString &key, const QStringList ¶ms) {
if (key.toLower() == "ukui") {
return new Qt5UKUIPlatformTheme(params);
}
return nullptr;
}
};
QT_END_NAMESPACE
#include "main.moc"
qt6-ukui-platformtheme/qt6-ukui-platformtheme/qt5-ukui-platform-theme.h 0000664 0001750 0001750 00000007142 15154306200 025143 0 ustar feng feng /*
* Qt5-UKUI's Library
*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library. If not, see .
*
* Authors: Yue Lan
*
*/
#ifndef QT5UKUIPLATFORMTHEME_H
#define QT5UKUIPLATFORMTHEME_H
#include "qt5-ukui-platformtheme_global.h"
#include
#include
#include
#include
#include "../ukui-styles/qt5-config-style-ukui/ukui-config-style-parameters.h"
#include "../ukui-styles/readconfig.h"
#if !defined(QT_NO_DBUS) && defined(QT_DBUS_LIB)
#if (QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)) && !defined(QT_NO_SYSTEMTRAYICON)
#define DBUS_TRAY
#endif
#if (QT_VERSION >= QT_VERSION_CHECK(5, 7, 0))
#define GLOBAL_MENU
#endif
#endif
class QPalette;
#ifdef DBUS_TRAY
class QPlatformSystemTrayIcon;
#endif
#ifdef GLOBAL_MENU
class QPlatformMenuBar;
#endif
using namespace UKUIConfigStyleSpace;
using namespace UKUIGlobalDTConfig;
/*!
* \brief The Qt5UKUIPlatformTheme class
* \details
* In UKUI desktop environment, we have our own platform to manage the qt applications' style.
* This class is used to take over the theme and preferences of those applications.
* The platform theme will effect globally.
*/
class QT5UKUIPLATFORMTHEMESHARED_EXPORT Qt5UKUIPlatformTheme : public QObject, public QPlatformTheme
{
Q_OBJECT
public:
Qt5UKUIPlatformTheme(const QStringList &args);
~Qt5UKUIPlatformTheme();
virtual const QPalette *palette(Palette type = SystemPalette) const;
virtual const QFont *font(Font type = SystemFont) const;
virtual QVariant themeHint(ThemeHint hint) const;
virtual QIconEngine *createIconEngine(const QString &iconName) const;
#if (QT_VERSION >= QT_VERSION_CHECK(5, 9, 0))
virtual bool usePlatformNativeDialog(DialogType type) const;
virtual QPlatformDialogHelper *createPlatformDialogHelper(DialogType type) const;
#endif
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
// virtual QIcon fileIcon(const QFileInfo &fileInfo, QPlatformTheme::IconOptions iconOptions = 0) const;
// virtual QIcon fileIcon(const QFileInfo &fileInfo, QPlatformTheme::IconOptions iconOptions = QPlatformTheme::IconOption::noOptions) const;
// virtual QIcon fileIcon(const QFileInfo &fileInfo, QPlatformTheme::IconOptions iconOptions = QPlatformTheme::IconOption::NoOptions) const;
virtual QIcon fileIcon(const QFileInfo &fileInfo, QPlatformTheme::IconOptions iconOptions = static_cast(0)) const;
#endif
#ifdef GLOBAL_MENU
virtual QPlatformMenuBar* createPlatformMenuBar() const;
#endif
#if !defined(QT_NO_DBUS) && !defined(QT_NO_SYSTEMTRAYICON)
QPlatformSystemTrayIcon *createPlatformSystemTrayIcon() const override;
#endif
public Q_SLOTS:
void slotChangeStyle(const QString& key);
private:
QStringList xdgIconThemePaths() const;
private:
QFont m_system_font;
QFont m_fixed_font;
QPluginLoader *m_loader = nullptr;
int m_portalVersion = 0;
GlobalDTConfig *m_dtConfig = nullptr;
QPalette *m_palette = nullptr;
};
#endif // QT5UKUIPLATFORMTHEME_H
qt6-ukui-platformtheme/qt6-ukui-platformtheme/qt5-ukui-platform-theme.cpp 0000664 0001750 0001750 00000035101 15154306200 025472 0 ustar feng feng /*
* Qt5-UKUI's Library
*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library. If not, see .
*
* Authors: Yue Lan
*
*/
#include
#include
#include "qt5-ukui-platform-theme.h"
#include "settings/ukui-style-settings.h"
#include "effects/highlight-effect.h"
#include "settings/black-list.h"
#include
#include
#include
#include
#include
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
#include
#include
#endif
#include
#include
#include
//#include
#include
#include
#include
#include
#include
//#include "widget/messagebox/message-box.h"
//#include "widget/filedialog/kyfiledialog.h"
#include "platform-theme-fontdata.h"
// #include "../qt5-ukui-filedialog/filedialoginterface.h"
// #include "widget/filedialog/xdgdesktopportalfiledialog_p.h"
#include
#include
#include
#if !defined(QT_NO_DBUS) && !defined(QT_NO_SYSTEMTRAYICON)
static bool isDBusTrayAvailable() {
static bool dbusTrayAvailable = false;
static bool dbusTrayAvailableKnown = false;
if (!dbusTrayAvailableKnown) {
// 使用 DBus 连接直接检查状态栏服务
QDBusConnection bus = QDBusConnection::sessionBus();
if (bus.isConnected()) {
// 检查是否有 StatusNotifierHost 服务注册
QStringList services = bus.interface()->registeredServiceNames();
for (const QString &service : services) {
if (service.startsWith("org.kde.StatusNotifierHost")) {
dbusTrayAvailable = true;
break;
}
}
}
dbusTrayAvailableKnown = true;
}
return dbusTrayAvailable;
}
#endif
void Qt5UKUIPlatformTheme::slotChangeStyle(const QString& key)
{
auto settings = UKUIStyleSettings::globalInstance();
if (key == "iconThemeName" || key == "icon-theme-name") {
QString icontheme = settings->get("icon-theme-name").toString();
QIcon::setThemeName(icontheme);
if(qApp){
QIcon icon = qApp->windowIcon();
qApp->setWindowIcon(QIcon::fromTheme(icon.name()));
}
// update all widgets for repaint new themed icons.
for (auto widget : QApplication::allWidgets()) {
widget->update();
}
}
if (key == "systemFont" || key == "system-font") {
//Skip QGuiApplication avoid it crash when we setfont
auto *app = qobject_cast(qApp);
if(app == nullptr)
return;
QString font = settings->get("system-font").toString();
// QFontDatabase db;
// QFontDatabase *db = QFontDatabase::instance();
int id = 0;
if (!QFontDatabase::families().contains(font)) {
PlatformThemeFontData fontData;
QMap fontMap = fontData.getAllFontInformation();
if(fontMap.contains(font)){
auto iter = fontMap.find(font);
id = QFontDatabase::addApplicationFont(iter.value());
}
}
// QFontDatabase *newDb = QFontDatabase::instance();
if (QFontDatabase::families().contains(font)) {
QFont oldFont = QApplication::font();
m_system_font.setFamily(font);
m_fixed_font.setFamily(font);
oldFont.setFamily(font);
QApplication::setFont(oldFont);
}
}
if (key == "systemFontSize" || key == "system-font-size") {
//Skip QGuiApplication avoid it crash when we setfont
auto *app = qobject_cast(qApp);
if(app == nullptr || qApp == nullptr)
return;
if (qApp->property("noChangeSystemFontSize").isValid() && qApp->property("noChangeSystemFontSize").toBool())
return;
double fontSize = settings->get("system-font-size").toString().toDouble();
if (fontSize > 0) {
QFont oldFont = QApplication::font();
m_system_font.setPointSize(fontSize);
m_fixed_font.setPointSize(fontSize*1.2);
oldFont.setPointSizeF(fontSize);
QApplication::setFont(oldFont);
}
}
}
Qt5UKUIPlatformTheme::Qt5UKUIPlatformTheme(const QStringList &args)
{
//FIXME:
Q_UNUSED(args)
if (QGSettings::isSchemaInstalled("org.ukui.style")) {
auto settings = UKUIStyleSettings::globalInstance();
//set font
auto fontName = settings->get("systemFont").toString();
auto fontSize = settings->get("systemFontSize").toString().toDouble();
if (qApp && qApp->property("noChangeSystemFontSize").isValid() && qApp->property("noChangeSystemFontSize").toBool())
fontSize = 11;
m_system_font.setFamily(fontName);
m_system_font.setPointSizeF(fontSize);
m_fixed_font.setFamily(fontName);
m_fixed_font.setPointSizeF(fontSize*1.2);
/*!
* \bug
* if we set app font, qwizard title's font will
* become very small. I handle the wizard title
* in ProxyStyle::polish().
*/
//Skip QGuiApplication avoid it crash when we setfont
auto *app = qobject_cast(qApp);
if(app != nullptr) {
QApplication::setFont(m_system_font);
}
if (app->applicationName().toLower().contains(QLatin1String("kwin"))) {
QDBusConnection::sessionBus().connect(QString(),
QStringLiteral("/UKUIPlatformTheme"),
QStringLiteral("org.ukui.UKUIPlatformTheme"),
QStringLiteral("refreshFonts"),
this,
SLOT(slotChangeStyle(QString)));
}
connect(settings, &QGSettings::changed, this, &Qt5UKUIPlatformTheme::slotChangeStyle);
}
// // add qqc2 style
// if (QFile::exists(QString("%1/kf5/kirigami/org.kylin.style.so").arg(QT_PLUGIN_INSTALL_DIRS))) {
// QQuickStyle::setStyle("org.kylin.style");
// }
// if(qApp && (qApp->inherits("QApplication") == true || qApp->inherits("QGuiApplication") == true) && qAppName() != "cura") {
// QQuickStyle::setStyle("org.ukui.style");
// }
QString systemLang = QLocale::system().name();
if(systemLang == "ug_CN" || systemLang == "ky_KG" || systemLang == "kk_KZ"){
QGuiApplication::setLayoutDirection(Qt::RightToLeft);
} else {
QGuiApplication::setLayoutDirection(Qt::LeftToRight);
}
const char* c = UKUIPLATFORMTHEME_DIR;
QString path = QString::fromUtf8(c);
if (QFile::exists(QString("%1/platformthemes/libqt5-ukui-filedialog.so").arg(path))) {
m_loader = new QPluginLoader(QString("%1/platformthemes/libqt5-ukui-filedialog.so").arg(path));
}
// Get information about portal version
QDBusMessage message = QDBusMessage::createMethodCall(QLatin1String("org.freedesktop.portal.Desktop"),
QLatin1String("/org/freedesktop/portal/desktop"),
QLatin1String("org.freedesktop.DBus.Properties"),
QLatin1String("Get"));
message << QLatin1String("org.freedesktop.portal.FileChooser") << QLatin1String("version");
QDBusPendingCall pendingCall = QDBusConnection::sessionBus().asyncCall(message);
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingCall);
QObject::connect(watcher, &QDBusPendingCallWatcher::finished, [&] (QDBusPendingCallWatcher *watcher) {
if (watcher->isError()) {
// 错误处理
QDBusError error = watcher->error();
qWarning() << "D-Bus 调用失败:" << error.message();
} else {
QDBusPendingReply reply = *watcher;
if (reply.isValid()) {
//qDebug() << "FileChooserPortalVersion......." << reply.value().toUInt();
m_portalVersion = reply.value().toUInt();
}
}
watcher->deleteLater();
});
m_dtConfig = new GlobalDTConfig();
m_palette = new QPalette(m_dtConfig->appPalette());
}
Qt5UKUIPlatformTheme::~Qt5UKUIPlatformTheme()
{
if(m_loader){
m_loader->unload();
delete m_loader;
m_loader = nullptr;
}
if(m_dtConfig){
delete m_dtConfig;
m_dtConfig = nullptr;
}
if(m_palette){
delete m_palette;
m_palette = nullptr;
}
}
const QPalette *Qt5UKUIPlatformTheme::palette(Palette type) const
{
//FIXME:
if (type == QPlatformTheme::SystemPalette && m_palette) {
return m_palette;
}
return QPlatformTheme::palette(type);
}
const QFont *Qt5UKUIPlatformTheme::font(Font type) const
{
//FIXME:
if (type == FixedFont)
return &m_fixed_font;
return &m_system_font;
switch (type) {
case SystemFont:
return &m_system_font;
case TitleBarFont:
case FixedFont:
case GroupBoxTitleFont:
return &m_fixed_font;
default:
return &m_system_font;
}
return QPlatformTheme::font(type);
}
QVariant Qt5UKUIPlatformTheme::themeHint(ThemeHint hint) const
{
if(qAppName() == "cura")
return QPlatformTheme::themeHint(hint);
switch (hint) {
case QPlatformTheme::StyleNames:{
// qDebug() << "Qt5UKUIPlatformTheme....";
// if (UKUIStyleSettings::isSchemaInstalled("org.ukui.style")) {
// if (auto settings = UKUIStyleSettings::globalInstance()) {
// QString themeName = settings->get("widget-theme-name").toString();
// if(themeName == "classical")
// return QStringList()<< "ukui-default";
// }
// }
return QStringList()<< "ukui";
}
case QPlatformTheme::SystemIconThemeName: {
if (UKUIStyleSettings::isSchemaInstalled("org.ukui.style")) {
if (auto settings = UKUIStyleSettings::globalInstance()) {
QString icontheme = settings->get("icon-theme-name").toString();
return QStringList()<(l.instance());
// auto engine = p->create();
// qDebug()<<"use my engine";
// return engine;
// } else {
// qDebug()<<"use common engine";
// return QPlatformTheme::createIconEngine(iconName);
// }
// //return new XdgIconLoaderEngine(iconName);
return QPlatformTheme::createIconEngine(iconName);
}
#if (QT_VERSION >= QT_VERSION_CHECK(5, 9, 0))
bool Qt5UKUIPlatformTheme::usePlatformNativeDialog(DialogType type) const
{
switch (type) {
case QPlatformTheme::FileDialog:
if (ukuiFiledialogBlackList().contains(qAppName()))
return false;
else
return false;
case QPlatformTheme::FontDialog:
case QPlatformTheme::ColorDialog:
return false;
case QPlatformTheme::MessageDialog:
if(qApp && qApp->inherits("QApplication"))
return true;
// if (qAppName() == "ukui-control-center")
// return false;
default:
break;
}
return false;
}
QPlatformDialogHelper *Qt5UKUIPlatformTheme::createPlatformDialogHelper(DialogType type) const
{
switch (type) {
case QPlatformTheme::FileDialog:
// if (!ukuiFiledialogBlackList().contains(qAppName())) {
// if (qApp && qApp->inherits("QApplication") && (m_loader && m_loader->instance())) {
// return qobject_cast(m_loader->instance())->create();
// } else if (qApp && qApp->inherits("QGuiApplication") && m_portalVersion >= 3) {
// return new XdgDesktopPortalFileDialog;
// }
// }
case QPlatformTheme::FontDialog:
case QPlatformTheme::ColorDialog:
return QPlatformTheme::createPlatformDialogHelper(type);
case QPlatformTheme::MessageDialog:
return QPlatformTheme::createPlatformDialogHelper(type);
default:
break;
}
return nullptr;
}
#endif
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
QIcon Qt5UKUIPlatformTheme::fileIcon(const QFileInfo &fileInfo, QPlatformTheme::IconOptions iconOptions) const
{
//FIXME:
return QPlatformTheme::fileIcon(fileInfo, iconOptions);
}
#endif
#ifdef GLOBAL_MENU
QPlatformMenuBar *Qt5UKUIPlatformTheme::createPlatformMenuBar() const
{
return QPlatformTheme::createPlatformMenuBar();
}
#endif
#if !defined(QT_NO_DBUS) && !defined(QT_NO_SYSTEMTRAYICON)
QPlatformSystemTrayIcon *Qt5UKUIPlatformTheme::createPlatformSystemTrayIcon() const
{
// if (isDBusTrayAvailable())
// return new QDBusTrayIcon();
return nullptr;
}
#endif
qt6-ukui-platformtheme/qt6-ukui-platformtheme/platform-theme-fontdata.cpp 0000664 0001750 0001750 00000012420 15154306200 025605 0 ustar feng feng /*
* Qt5-UKUI's Library
*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library. If not, see .
*
* Authors: Yue Lan
*
*/
#include "platform-theme-fontdata.h"
#include
#undef signals
#undef slots
#undef emit
#include
PlatformThemeFontData::PlatformThemeFontData()
{
}
PlatformThemeFontData::~PlatformThemeFontData()
{
}
bool PlatformThemeFontData::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;
}
QMap PlatformThemeFontData::getAllFontInformation()
{
QMap fontMap;
QList ret;
ret.clear();
FT_Library ft_library;
FT_Error err = FT_Init_FreeType(&ft_library);
if (err != FT_Err_Ok) {
qCritical() << "Error : LibFun , getAllFontInformation , init freetype fail";
return fontMap;
}
if (!FcInitReinitialize()) {
qCritical() << "Error : LibFun , getAllFontInformation , init font list fail";
return fontMap;
}
FcConfig *config = FcInitLoadConfigAndFonts();
FcPattern *pat = FcPatternCreate();
FcObjectSet *os = FcObjectSetBuild(FC_FILE , FC_FAMILY , FC_STYLE , FC_INDEX , NULL);
FcFontSet *fs = FcFontList(config , pat , os);
qInfo() << "Info : LibFun , getAllFontInformation , total matching fonts is " << fs->nfont;
for (int i = 0 ; i < fs->nfont && fs != NULL ; i++) {
FontInformation item;
FcChar8 *path = NULL;
FcChar8 *family = NULL;
// FcChar8 *style = NULL;
int index;
FcPattern *font = fs->fonts[i];
if (FcPatternGetString(font , FC_FILE , 0 , &path) == FcResultMatch &&
FcPatternGetString(font , FC_FAMILY , 0 , &family) == FcResultMatch &&
// FcPatternGetString(font , FC_STYLE , 0 , &style) == FcResultMatch &&
FcPatternGetInteger(font , FC_INDEX , 0 , &index) == FcResultMatch)
{
item.path = QString((char *)path);
item.family = QString((char *)family);
// item.style = QString((char *)style);
}
/* 对字体文件进行判断(判断后缀名是否为.ttf .otf)*/
if (!chooseFontFile(item.path)) {
continue;
}
gchar *fontData = NULL;
gsize fontDataLenth;
g_autoptr(GError) error = NULL;
GFile *fd = g_file_new_for_path((const gchar *)path);
if (!g_file_load_contents(fd , NULL , &fontData , &fontDataLenth , NULL , &error)) {
qWarning() << "Waring : LibFun , getAllFontInformation , load font file fail , Path is [ " << path << " ]" << " error is [ " << error->message << " ]";
ret << item;
continue;
}
FT_Error ft_error;
FT_Face ft_retval;
ft_error = FT_New_Memory_Face(ft_library , (const FT_Byte *)fontData , (FT_Long)fontDataLenth , index , &ft_retval);
if (ft_error != FT_Err_Ok) {
qWarning() << "Waring : LibFun , getAllFontInformation , read font data fail , Path is [ " << path << " ]";
ret << item;
continue;
}
/*
///名字
if (ft_retval->family_name) {
item.name = QString((char *)ft_retval->family_name);
}
///样式
if (ft_retval->style_name) {
item.style = QString((char *)ft_retval->style_name);
}
///路径
g_autofree gchar *location = NULL;
location = g_file_get_path(fd);
item.path = QString((char *)location);
///种类
g_autoptr(GFileInfo) fileInfo;
fileInfo = g_file_query_info(fd , G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE "," G_FILE_ATTRIBUTE_STANDARD_SIZE , G_FILE_QUERY_INFO_NONE , NULL , NULL);
if (fileInfo != NULL) {
g_autofree gchar *fileType = g_content_type_get_description(g_file_info_get_content_type(fileInfo));
item.type = QString((char *)fileType);
}
qDebug() << "name:" << item.name << "style:" << item.style << "path:" << item.path << "family:" << item.family;
*/
ret << item;
fontMap.insert(item.family, item.path);
FT_Done_Face(ft_retval);
g_object_unref(fd);
g_free(fontData);
}
if (pat) {
FcPatternDestroy(pat);
}
if (os) {
FcObjectSetDestroy(os);
}
if (fs) {
FcFontSetDestroy(fs);
}
return fontMap;
}
qt6-ukui-platformtheme/qt6-ukui-platformtheme/platform-theme-fontdata.h 0000664 0001750 0001750 00000003470 15154306200 025257 0 ustar feng feng /*
* Qt5-UKUI's Library
*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library. If not, see .
*
* Authors: Yue Lan
*
*/
#ifndef PLATFORMTHEMEFONTDATA_H
#define PLATFORMTHEMEFONTDATA_H
#include
#include
#include
#include
#include
typedef struct _FontInformation
{
QString path; /* 路径 */
QString family; /* 系列 */
QString style; /* 样式 */
// QString name; /* 名称 */
// QString type; /* 种类 */
// QString version; /* 版本 */
// QString copyright; /* 版权 */
// QString manufacturer; /* 商标 */
// QString description; /* 描述 */
// QString designer; /* 设计师 */
// QString license; /* 许可证 */
} FontInformation;
class PlatformThemeFontData : public QObject
{
Q_OBJECT
public:
PlatformThemeFontData();
~PlatformThemeFontData();
public:
QMap getAllFontInformation();
bool chooseFontFile(QString path);
};
#endif // PLATFORMTHEMEFONTDATA_H
qt6-ukui-platformtheme/translations/ 0000775 0001750 0001750 00000000000 15154306200 016547 5 ustar feng feng qt6-ukui-platformtheme/translations/qt5-ukui-platformtheme_en_US.ts 0000664 0001750 0001750 00000034427 15154306200 024553 0 ustar feng feng
MainWindow
MainWindow
test open
directory
selected uri
test show
test exec
test save
test static open
PushButton
use auto highlight icon
...
highlightOnly
bothDefaultAndHighlight
RadioButton
style
icon
menu opacity
font
MessageBox
Close
Close
QApplication
Executable '%1' requires Qt %2, found Qt %3.
Executable '%1' requires Qt %2, found Qt %3.
Incompatible Qt Library Error
Incompatible Qt Library Error
QDialogButtonBox
OK
OK
QMessageBox
Show Details...
Show Details...
Hide Details...
Hide Details...
QObject
File Name
File Name
Modified Date
Modified Date
File Type
File Type
File Size
File Size
Original Path
Original Path
Descending
Descending
Ascending
Ascending
Use global sorting
Use global sorting
List View
List View
Icon View
Icon View
Close
Close
UKUI::TabWidget::DefaultSlideAnimatorFactory
Default Slide
Let tab widget switch with a slide animation.
UKUIFileDialog::KyFileDialogHelper
Open File
Open File
Save File
Save File
All Files (*)
All Files (*)
UKUIFileDialog::KyNativeFileDialog
Go Back
Go Back
Go Forward
Go Forward
Cd Up
Cd Up
Search
Search
View Type
View Type
Sort Type
Sort Type
Maximize
Maximize
Close
Close
Restore
Restore
Name
Name
Open
Open
Cancel
Cancel
Save as
Save as
New Folder
New Folder
Save
Save
Directories
Directories
Warning
Warning
exist, are you sure replace?
exist, are you sure replace?
NewFolder
NewFolder
Undo
Undo
Redo
Redo
warn
warn
This operation is not supported.
This operation is not supported.
qt6-ukui-platformtheme/translations/qt5-ukui-platformtheme_kk.ts 0000664 0001750 0001750 00000036706 15154306200 024151 0 ustar feng feng
MainWindow
MainWindow
نەگٸزگٸ كوز بەك
test open
سېناقنى ٸشٸۋ
directory
باس مازمۇن
selected uri
تالدانعان uri
test show
سىناقتى كورسەتۋ
test exec
اتقار ورىنداۋدى ولشەۋ
test save
سىناقتى ساقتاۋ
test static open
تىنىش كۇيدە اشۋدٸ سىناۋ
PushButton
تالداۋ كىنوپكاسى
use auto highlight icon
اۆتوماتتى جارقىن كورسەتۋ سىن بەلگىسىن ٸستەتڭٸز
...
...
highlightOnly
تەك جوعارعى جارقتا كورسەتىلدى.
bothDefaultAndHighlight
كوڭىلدەگى ۋا ەرەكشە كورسەتۋ
RadioButton
تاق تالداۋ كىنوپكاسى
style
سلوب
icon
ئايكون
menu opacity
تاماق تىزىمدىگنىڭ تۇنىقتىق دارەجەسى جوق
font
ٴارىپ نۇسقاسى
MessageBox
Close
تاقاۋ
QApplication
Executable '%1' requires Qt %2, found Qt %3.
اتقار ىستەۋگە بولاتٸن حۇجات 1، مۇقتاجدىق ارگومەنتتٸ 2، ٸزدەپ تاپقان ارگومەنتتٸ 3
Incompatible Qt Library Error
سىغىشمىغانQT قامبادا قاتەلىك كورىلدى
QDialogButtonBox
OK
ماقۇل
QMessageBox
Show Details...
ناقتى مازمۇنىن كورسەتۋ
Hide Details...
ناقتى مازمۇنىن جاسىرۋ
QObject
File Name
حۇجات مى
Modified Date
وزگەرتىلگەن ۋاقىتى
File Type
حۇجات تۇرى
File Size
حۇجات ۇلكەندىگى
Original Path
وڭ جول
Descending
چوڭدىن كىچىككە قاراتىپ تىزۋ
Ascending
كىشىدەن ۇلكەنگە قاراتىپ تىزۋ
Use global sorting
ئومومىيلىق مەنەن تىزۋدى ٸستەتۋ
List View
تٸزٸمدٸك كورىنۋى
Icon View
پىشىن كورىنۋى
Close
تاقاۋ
UKUI::TabWidget::DefaultSlideAnimatorFactory
Default Slide
الدىن بەكٸتٸلگەن slide
Let tab widget switch with a slide animation.
تالدانبا كارتونىن كشكەنە زاپشاستارىن پٸروبيكسيا كارتون فىلىمىگە سايكەستىرۋ
UKUIFileDialog::KyFileDialogHelper
Open File
حۇجاتتى ٸشٸۋ
Save File
حۇجاتتى ساقتاۋ
All Files (*)
بارلٸق حۇجاتتار (*)
UKUIFileDialog::KyNativeFileDialog
Go Back
قايتۋ
Go Forward
ىلگەرلەۋ
Cd Up
Cd نىڭ ٷستٸن
Search
ٸزدەۋ
View Type
كورىنۋ تيپى
Sort Type
رەتتەلگەن تيپ
Maximize
ۇلكەيتۋ
Close
تاقاۋ
Restore
قالپىنا كەلتىرىلگەن
Name
ەسىمى
Open
ٸشٸۋ
Cancel
كۇشىنەن قالدىرۋ
Save as
تەجەۋ
New Folder
جاڭا حۇجات قىسقىش
Save
ساقتاۋ
Directories
مازمۇندار
Warning
ەسكەرتۋ
exist, are you sure replace?
ساقتالعان، الماستٸرۋدٸ تۇراقتاستىراسىزبا؟
NewFolder
جاڭا قاتتاعىش
Undo
ٸشٸۋ
Redo
قاتە-قاتە سىناۋ
warn
ەسكەرتۋ
This operation is not supported.
نۇ جوبالاۋدى قولدامايدى.
qt6-ukui-platformtheme/translations/qt5-ukui-platformtheme_tr.ts 0000664 0001750 0001750 00000035115 15154306200 024162 0 ustar feng feng
MainWindow
MainWindow
test open
directory
selected uri
test show
test exec
test save
test static open
PushButton
use auto highlight icon
...
highlightOnly
bothDefaultAndHighlight
RadioButton
style
icon
menu opacity
font
MessageBox
Close
QApplication
Executable '%1' requires Qt %2, found Qt %3.
Incompatible Qt Library Error
QDialogButtonBox
OK
QMessageBox
Show Details...
Hide Details...
QObject
File Name
Modified Date
File Type
File Size
Original Path
Descending
Ascending
Use global sorting
List View
Icon View
Close
UKUI::TabWidget::DefaultSlideAnimatorFactory
Default Slide
Let tab widget switch with a slide animation.
UKUIFileDialog::KyFileDialogHelper
Open File
Save File
All Files (*)
UKUIFileDialog::KyNativeFileDialog
Go Back
Go Forward
Cd Up
Search
View Type
Sort Type
Maximize
Close
Restore
Name
Open
Cancel
Save as
New Folder
Save
Directories
Warning
exist, are you sure replace?
NewFolder
Undo
Redo
warn
This operation is not supported.
qt6-ukui-platformtheme/translations/qt5-ukui-platformtheme_bo_CN.ts 0000664 0001750 0001750 00000040523 15154306200 024514 0 ustar feng feng
MainWindow
MainWindow
test open
directory
selected uri
test show
test exec
test save
test static open
PushButton
use auto highlight icon
...
highlightOnly
bothDefaultAndHighlight
RadioButton
style
icon
menu opacity
font
MessageBox
Close
ཁ་རྒྱག་པ།
QApplication
Executable '%1' requires Qt %2, found Qt %3.
ལག་བསྟར་བྱེད་ཆོག་པའི་'%1'ལ་Qt %2,Qt%3རྙེད་པ་རེད།
Incompatible Qt Library Error
ཕན་ཚུན་མཐུན་ཐབས་མེད་པའི་Qt དཔེ་མཛོད་ཁང་གི་ནོར་འཁྲུལ།
QDialogButtonBox
OK
འགྲིགས།
QMessageBox
Show Details...
ཞིབ་ཕྲའི་གནས་ཚུལ་གསལ་བཤད་བྱ་དགོས།
Hide Details...
གནས་ཚུལ་ཞིབ་ཕྲ་སྦས་སྐུང་བྱེད་
QObject
File Name
ཡིག་ཆའི་མིང་།
Modified Date
བཟོ་བཅོས་བརྒྱབ་པའི་དུས་ཚོད།
File Type
ཡིག་ཆའི་རིགས་གྲས།
File Size
ཡིག་ཆའི་ཆེ་ཆུང་།
Original Path
ཐོག་མའི་འགྲོ་ལམ།
Descending
མར་འབབ་པ།
Ascending
རིམ་པ་ཇེ་མང་དུ་འགྲོ་བཞིན།
Use global sorting
ཁྱོན་ཡོངས་ཀྱི་གོ་རིམ་བེད་སྤྱོད།
List View
མཐོང་རིས་རེའུ་མིག
Icon View
མཚོན་རྟགས་ལྟ་ཚུལ།
Close
ཁ་རྒྱག་པ།
UKUI::TabWidget::DefaultSlideAnimatorFactory
Default Slide
ཁ་ཆད་བཞག་པའི་སྒྲོན་བརྙན
Let tab widget switch with a slide animation.
སྒྲོན་བརྙན་གྱི་འགུལ་རིས་ལ་བརྟེན་ནས་ཤོག་བྱང་ཆུང་ཆུང་བརྗེ་རེས་བྱེད་དུ་འཇུག་དགོས།
UKUIFileDialog::KyFileDialogHelper
Open File
ཁ་ཕྱེ་བའི་ཡིག་ཆ།
Save File
ཡིག་ཆ་ཉར་ཚགས་བྱེད་པ།
All Files (*)
ཡིག་ཆ་ཡོད་ཚད་(*)
UKUIFileDialog::KyNativeFileDialog
Go Back
ཕྱིར་ལོག
Go Forward
མདུན་སྐྱོད།
Cd Up
གོང་ཕྱོགས།
Search
འཚོལ་ཞིབ།
View Type
མཐོང་རིས་ཀྱི་རིགས།
Sort Type
གོ་རིམ་གྱི་རིགས།
Maximize
ཆེས་ཆེ་བསྒྱུར།
Close
ཁ་རྒྱག་པ།
Restore
སླར་གསོ་བྱེད་པ།
Name
ཡིག་ཆའི་མིང་།
Open
སྒོ་ཕྱེ་བ།
Cancel
ཕྱིར་འཐེན།
Save as
ཉར་ཚགས་གཞན།
New Folder
ཡིག་ཁུག་གསར་འཛུགས།
Save
གྲོན་ཆུང་བྱེད་དགོས།
Directories
དཀར་ཆག
Warning
ཐ་ཚིག་སྒྲོག་པ།
exist, are you sure replace?
གནས་ཡོད་པས། ཁྱོད་ཀྱིས་དངོས་གནས་ཚབ་བྱེད་ཐུབ་བམ།
NewFolder
དཀར་ཆག་གསར་བ།
Undo
ཁ་ཕྱིར་འཐེན་བྱ་དགོས།
Redo
ཡང་བསྐྱར་ལས།
warn
ཉེན་བརྡ་བཏང་བ།
This operation is not supported.
བཀོལ་སྤྱོད་འདི་ལ་རྒྱབ་སྐྱོར་མི་བྱེད།
qt6-ukui-platformtheme/translations/qt5-ukui-platformtheme_cs.ts 0000664 0001750 0001750 00000035115 15154306200 024142 0 ustar feng feng
MainWindow
MainWindow
test open
directory
selected uri
test show
test exec
test save
test static open
PushButton
use auto highlight icon
...
highlightOnly
bothDefaultAndHighlight
RadioButton
style
icon
menu opacity
font
MessageBox
Close
QApplication
Executable '%1' requires Qt %2, found Qt %3.
Incompatible Qt Library Error
QDialogButtonBox
OK
QMessageBox
Show Details...
Hide Details...
QObject
File Name
Modified Date
File Type
File Size
Original Path
Descending
Ascending
Use global sorting
List View
Icon View
Close
UKUI::TabWidget::DefaultSlideAnimatorFactory
Default Slide
Let tab widget switch with a slide animation.
UKUIFileDialog::KyFileDialogHelper
Open File
Save File
All Files (*)
UKUIFileDialog::KyNativeFileDialog
Go Back
Go Forward
Cd Up
Search
View Type
Sort Type
Maximize
Close
Restore
Name
Open
Cancel
Save as
New Folder
Save
Directories
Warning
exist, are you sure replace?
NewFolder
Undo
Redo
warn
This operation is not supported.
qt6-ukui-platformtheme/translations/qt5-ukui-platformtheme_zh_HK.ts 0000664 0001750 0001750 00000035437 15154306200 024547 0 ustar feng feng
MainWindow
MainWindow
test open
directory
selected uri
test show
test exec
test save
test static open
PushButton
use auto highlight icon
...
highlightOnly
bothDefaultAndHighlight
RadioButton
style
icon
menu opacity
font
MessageBox
Close
關閉
QApplication
Executable '%1' requires Qt %2, found Qt %3.
可執行檔「%1」 需要數量%2,找到數量%3。
Incompatible Qt Library Error
不相容的Qt庫錯誤
QDialogButtonBox
OK
確認
QMessageBox
Show Details...
顯示細節......
Hide Details...
隱藏細節......
QObject
File Name
檔名稱
Modified Date
修改日期
File Type
檔案類型
File Size
檔大小
Original Path
原始路徑
Descending
降序
Ascending
升序
Use global sorting
使用全域排序
List View
清單檢視
Icon View
圖示檢視
Close
關閉
UKUI::TabWidget::DefaultSlideAnimatorFactory
Default Slide
默認slide
Let tab widget switch with a slide animation.
讓選項卡小部件切換為幻燈片動畫。
UKUIFileDialog::KyFileDialogHelper
Open File
打開
Save File
保存
All Files (*)
所有(*)
UKUIFileDialog::KyNativeFileDialog
Go Back
後退
Go Forward
前進
Cd Up
向上
Search
搜索
View Type
視圖類型
Sort Type
排序類型
Maximize
最大化
Close
關閉
Restore
還原
Name
檔名
Open
打開
Cancel
取消
Save as
另存為
New Folder
新建資料夾
Save
保存
Directories
目錄
Warning
警告
exist, are you sure replace?
已存在,是否替換?
NewFolder
新建資料夾
Undo
撤銷
Redo
重做
warn
警告
This operation is not supported.
不支援此操作。
qt6-ukui-platformtheme/translations/qt5-ukui-platformtheme_zh_Hant.ts 0000664 0001750 0001750 00000040447 15154306200 025134 0 ustar feng feng
MainWindow
MainWindow
test open
directory
selected uri
test show
test exec
test save
test static open
PushButton
use auto highlight icon
...
highlightOnly
bothDefaultAndHighlight
RadioButton
style
icon
menu opacity
font
MessageBox
Close
關閉
QApplication
Executable '%1' requires Qt %2, found Qt %3.
可執行檔「%1」 需要數量%2,找到數量%3。
Incompatible Qt Library Error
不相容的Qt庫錯誤
QDialogButtonBox
OK
確認
QMessageBox
Show Details...
顯示細節......
Hide Details...
隱藏細節......
QObject
File Name
檔名稱
Modified Date
修改日期
File Type
檔案類型
File Size
檔大小
Original Path
原始路徑
Descending
降序
Ascending
升序
Use global sorting
使用全域排序
List View
清單檢視
Icon View
圖示檢視
Close
關閉
UKUI::TabWidget::DefaultSlideAnimatorFactory
Default Slide
默認slide
Let tab widget switch with a slide animation.
讓選項卡小部件切換為幻燈片動畫。
UKUIFileDialog::KyFileDialogHelper
Open File
打開
Save File
保存
All Files (*)
所有(*)
UKUIFileDialog::KyNativeFileDialog
Go Back
後退
Go Forward
前進
Cd Up
向上
Search
搜索
View Type
視圖類型
Sort Type
排序類型
Maximize
最大化
Close
關閉
Restore
還原
Name
檔名
Open
打開
Cancel
取消
Save as
另存為
New Folder
新建資料夾
Save
保存
Directories
目錄
Warning
警告
exist, are you sure replace?
已存在,是否替換?
NewFolder
新建資料夾
Undo
撤銷
Redo
重做
warn
警告
This operation is not supported.
不支援此操作。
qt6-ukui-platformtheme/translations/qt5-ukui-platformtheme_fa.ts 0000664 0001750 0001750 00000035115 15154306200 024123 0 ustar feng feng
MainWindow
MainWindow
test open
directory
selected uri
test show
test exec
test save
test static open
PushButton
use auto highlight icon
...
highlightOnly
bothDefaultAndHighlight
RadioButton
style
icon
menu opacity
font
MessageBox
Close
QApplication
Executable '%1' requires Qt %2, found Qt %3.
Incompatible Qt Library Error
QDialogButtonBox
OK
QMessageBox
Show Details...
Hide Details...
QObject
File Name
Modified Date
File Type
File Size
Original Path
Descending
Ascending
Use global sorting
List View
Icon View
Close
UKUI::TabWidget::DefaultSlideAnimatorFactory
Default Slide
Let tab widget switch with a slide animation.
UKUIFileDialog::KyFileDialogHelper
Open File
Save File
All Files (*)
UKUIFileDialog::KyNativeFileDialog
Go Back
Go Forward
Cd Up
Search
View Type
Sort Type
Maximize
Close
Restore
Name
Open
Cancel
Save as
New Folder
Save
Directories
Warning
exist, are you sure replace?
NewFolder
Undo
Redo
warn
This operation is not supported.
qt6-ukui-platformtheme/translations/qt5-ukui-platformtheme_de.ts 0000664 0001750 0001750 00000034775 15154306200 024140 0 ustar feng feng
MainWindow
MainWindow
test open
directory
selected uri
test show
test exec
test save
test static open
PushButton
use auto highlight icon
...
highlightOnly
bothDefaultAndHighlight
RadioButton
style
icon
menu opacity
font
MessageBox
Close
Schließen
QApplication
Executable '%1' requires Qt %2, found Qt %3.
Die ausführbare Datei '%1' erfordert Qt %2, Qt %3 gefunden.
Incompatible Qt Library Error
Fehler in der inkompatiblen Qt-Bibliothek
QDialogButtonBox
OK
OKAY
QMessageBox
Show Details...
Details anzeigen...
Hide Details...
Details ausblenden...
QObject
File Name
Dateiname
Modified Date
Änderungsdatum
File Type
Dateityp
File Size
Dateigröße
Original Path
Ursprünglicher Pfad
Descending
Absteigend
Ascending
Aufsteigend
Use global sorting
Globale Sortierung verwenden
List View
Listenansicht
Icon View
Icon-Ansicht
Close
Schließen
UKUI::TabWidget::DefaultSlideAnimatorFactory
Default Slide
Standard-Folie
Let tab widget switch with a slide animation.
Lassen Sie das Tab-Widget mit einer Folienanimation wechseln.
UKUIFileDialog::KyFileDialogHelper
Open File
Offene Linie
Save File
Datei speichern
All Files (*)
Alle Dateien (*)
UKUIFileDialog::KyNativeFileDialog
Go Back
Zurück
Go Forward
Vorwärts gehen
Cd Up
Cd nach oben
Search
Suchen
View Type
Typ der Ansicht
Sort Type
Art der Sortierung
Maximize
Maximieren
Close
Schließen
Restore
Wiederherstellen
Name
Name
Open
Offen
Cancel
Abbrechen
Save as
Speichern unter
New Folder
Neuer Ordner
Save
Retten
Directories
Verzeichnisse
Warning
Warnung
exist, are you sure replace?
existieren, sind Sie sicher, ersetzen?
NewFolder
Neuer Ordner
Undo
Aufmachen
Redo
Noch einmal machen
warn
warnen
This operation is not supported.
Dieser Vorgang wird nicht unterstützt.
qt6-ukui-platformtheme/translations/qt5-ukui-platformtheme_mn.ts 0000664 0001750 0001750 00000037330 15154306200 024150 0 ustar feng feng
MainWindow
MainWindow
test open
directory
selected uri
test show
test exec
test save
test static open
PushButton
use auto highlight icon
...
highlightOnly
bothDefaultAndHighlight
RadioButton
style
icon
menu opacity
font
MessageBox
Close
ᠬᠠᠭᠠᠬᠤ
QApplication
Executable '%1' requires Qt %2, found Qt %3.
ᠭᠦᠢᠴᠡᠳᠬᠡᠵᠦ ᠪᠣᠯᠬᠤ ᠹᠠᠢᠯ '%1' Qt% 2 ᠬᠡᠷᠡᠭᠰᠡᠵᠦ ᠂ Qt% 3 ᠢ᠋/ ᠵᠢ ᠡᠷᠢᠵᠦ ᠣᠯᠬᠤ ᠬᠡᠷᠡᠭᠲᠡᠶ .
Incompatible Qt Library Error
QDialogButtonBox
OK
OK
QMessageBox
Show Details...
Hide Details...
QObject
File Name
ᠹᠠᠢᠯ ᠤ᠋ᠨ ᠨᠡᠷᠡᠢᠳᠦᠯ
Modified Date
ᠵᠠᠰᠠᠭᠰᠠᠨ ᠡᠳᠦᠷ ᠰᠠᠷᠠ
File Type
ᠹᠠᠢᠯ ᠤ᠋ᠨ ᠳᠦᠷᠦᠯ ᠵᠦᠢᠯ
File Size
ᠹᠠᠢᠯ ᠤ᠋ᠨ ᠶᠡᠬᠡ ᠪᠠᠭᠠ
Original Path
ᠤᠭ ᠤ᠋ᠨ ᠵᠠᠮ ᠱᠤᠭᠤᠮ
Descending
ᠪᠠᠭᠠᠰᠬᠠᠬᠤ
Ascending
ᠶᠡᠬᠡᠰᠬᠡᠬᠦ
Use global sorting
ᠪᠦᠬᠦ ᠪᠠᠢᠳᠠᠯ ᠤ᠋ᠨ ᠳᠠᠷᠠᠭᠠᠯᠠᠯ ᠢ᠋ ᠬᠡᠷᠡᠭᠯᠡᠬᠦ
List View
ᠵᠢᠭᠰᠠᠭᠠᠯᠳᠠ ᠵᠢᠨ ᠬᠠᠷᠠᠭᠠᠨ ᠵᠢᠷᠤᠭ
Icon View
ᠰᠢᠪᠠᠭᠠ ᠵᠢᠨ ᠬᠠᠷᠠᠭᠠᠨ ᠵᠢᠷᠤᠭ
Close
ᠬᠠᠭᠠᠬᠤ
UKUI::TabWidget::DefaultSlideAnimatorFactory
Default Slide
Default Slide
Let tab widget switch with a slide animation.
UKUIFileDialog::KyFileDialogHelper
Open File
ᠨᠡᠬᠡᠬᠡᠬᠦ
Save File
ᠬᠠᠳᠠᠭᠠᠯᠠᠬᠤ
All Files (*)
ᠪᠦᠬᠦᠢᠯᠡ (*)
UKUIFileDialog::KyNativeFileDialog
Go Back
ᠤᠬᠤᠷᠢᠬᠤ
Go Forward
ᠤᠷᠤᠭᠰᠢᠯᠠᠬᠤ
Cd Up
ᠳᠡᠭᠡᠭᠰᠢ
Search
ᠬᠠᠢᠯᠳᠠ
View Type
ᠬᠠᠷᠠᠭᠠᠨ ᠵᠢᠷᠤᠭ ᠤ᠋ᠨ ᠳᠦᠷᠦᠯ ᠵᠦᠢᠯ
Sort Type
ᠳᠠᠷᠠᠭᠠᠯᠠᠯ ᠤ᠋ᠨ ᠳᠦᠷᠦᠯ ᠵᠦᠢᠯ
Maximize
ᠬᠠᠮᠤᠭ ᠤ᠋ᠨ ᠶᠡᠬᠡᠴᠢᠯᠡᠯ
Close
ᠬᠠᠭᠠᠬᠤ
Restore
ᠡᠬᠡᠬᠦᠯᠬᠦ
Name
ᠹᠠᠢᠯ ᠤ᠋ᠨ ᠨᠡᠷᠡ
Open
ᠨᠡᠬᠡᠬᠡᠬᠦ
Cancel
ᠦᠬᠡᠢᠰᠭᠡᠬᠦ᠌
Save as
ᠦᠭᠡᠷᠡ ᠭᠠᠵᠠᠷ ᠬᠠᠳᠠᠭᠠᠯᠠᠬᠤ
New Folder
ᠰᠢᠨᠡ ᠪᠡᠷ ᠪᠠᠢᠭᠤᠯᠤᠭᠰᠠᠨ ᠹᠠᠢᠯ ᠤ᠋ᠨ ᠬᠠᠪᠳᠠᠰᠤ
Save
ᠬᠠᠳᠠᠭᠠᠯᠠᠬᠤ
Directories
ᠭᠠᠷᠴᠠᠭ
Warning
ᠰᠡᠷᠡᠮᠵᠢᠯᠡᠬᠦᠯᠦᠯ
exist, are you sure replace?
ᠪᠠᠢᠨᠠ᠂ ᠰᠤᠯᠢᠬᠤ ᠤᠤ?
NewFolder
ᠰᠢᠨᠡ ᠪᠡᠷ ᠪᠠᠢᠭᠤᠯᠤᠭᠰᠠᠨ ᠹᠠᠢᠯ ᠤ᠋ᠨ ᠬᠠᠪᠳᠠᠰᠤ
Undo
ᠬᠦᠴᠦᠨ ᠦᠬᠡᠢ ᠪᠤᠯᠭᠠᠬᠤ
Redo
ᠳᠠᠬᠢᠵᠤ ᠬᠢᠬᠦ
warn
ᠰᠡᠷᠡᠮᠵᠢᠯᠡᠬᠦᠯᠬᠦ
This operation is not supported.
ᠳᠤᠰ ᠠᠵᠢᠯᠯᠠᠬᠤᠢ ᠵᠢ ᠳᠡᠮᠵᠢᠬᠦ ᠦᠬᠡᠢ.
qt6-ukui-platformtheme/translations/qt5-ukui-platformtheme_ug.ts 0000664 0001750 0001750 00000037002 15154306200 024145 0 ustar feng feng
MainWindow
MainWindow
MainWindow
test open
سېناقنى ئېچىش
directory
مۇندەرىجە
selected uri
تاللانغان uri
test show
سىناقنى كۆرسىتىش
test exec
ئىجرا قىلغۇچنى ئۆلچەش
test save
سىناقنى ساقلاش
test static open
تىنچ ھالەتتە ئېچىشنى سىناش
PushButton
PushButton
use auto highlight icon
ئاپتوماتىك يارقىن كۆرسىتىش سىنبەلگىسىنى ئىشلىتىڭ
...
...
highlightOnly
پەقەت يۇقىرى يورۇقلۇقتا كۆرسىتىلىدۇ.
bothDefaultAndHighlight
كۆڭۈلدىكى ۋە گەۋدىلىك كۆرسىتىش
RadioButton
تاق تاللاش كۇنۇپكىسى
style
ئۇسلۇب
icon
ئايكون
menu opacity
تاماق تىزىملىكىنىڭ سۈزۈكلۈك دەرىجىسى يوق
font
خەت نۇسخىسى
MessageBox
Close
تاقاش
QApplication
Executable '%1' requires Qt %2, found Qt %3.
ئىجرا قىلىشقا بولىدىغان ھۆججەت 1، ئىھتىياجلىق سان 2، ئىزدەپ تاپقان سان 3
Incompatible Qt Library Error
سىغىشمىغانQT ئامبىرىدا خاتالىق كۆرۈلدى
QDialogButtonBox
OK
ماقۇل
QMessageBox
Show Details...
تەپسىلاتىنى كۆرسىتىش
Hide Details...
تەپسىلاتىنى يوشۇرۇش
QObject
File Name
ھۆججەت نامى
Modified Date
ئۆزگەرتىلگەن ۋاقتى
File Type
ھۆججەت تۈرى
File Size
ھۆججەت چوڭلۇقى
Original Path
ئەسلى يول
Descending
چوڭدىن كىچىككە قارىتىپ تىزىش
Ascending
كىچىكتىن چوڭغا قارىتىپ تىزىش
Use global sorting
ئومومىيلىق بىلەن تىزىشنى ئىشلىتىش
List View
تىزىملىك كۆرۈنۈشى
Icon View
شەكىل كۆرۈنۈشى
Close
تاقاش
UKUI::TabWidget::DefaultSlideAnimatorFactory
Default Slide
ئالدىن بىكىتىلگەن slide
Let tab widget switch with a slide animation.
تاللانما كارتىدىكى كىچىك زاپچاسلارنى پرويېكسىيە كارتون فىلىمىگە ئالماشتۇرۇش
UKUIFileDialog::KyFileDialogHelper
Open File
ھۆججەتنى ئېچىش
Save File
ھۆججەتنى ساقلاش
All Files (*)
بارلىق ھۆججەتلەر (*)
UKUIFileDialog::KyNativeFileDialog
Go Back
قايت
Go Forward
ئالدىغا ماڭ
Cd Up
Cd نىڭ ئۈستى
Search
ئىزدە
View Type
كۆرۈنۈش تىپى
Sort Type
رەتلەنگەن تىپ
Maximize
چوڭايتىش
Close
تاقاش
Restore
ئەسلىگە كەلتۈرۈش
Name
ئىسىم-فامىلىسى
Open
ئېچىش
Cancel
ئەمەلدىن قالدۇرۇش
Save as
تېجەش
New Folder
يېڭى ھۆججەت قىسقۇچ
Save
ساقلاش
Directories
مۇندەرىجىلەر
Warning
ئاگاھلاندۇرۇش
exist, are you sure replace?
مەۋجۇت، ئالماشتۇرۇشنى جەزىملەشتۈرەلەمسىز؟
NewFolder
يېڭى قاتلىغۇچ
Undo
Undo
Redo
قايتا-قايتا
warn
ئاگاھلاندۇرۇش
This operation is not supported.
بۇ مەشغۇلاتنى قوللىمايدۇ.
qt6-ukui-platformtheme/translations/qt5-ukui-platformtheme_fr.ts 0000664 0001750 0001750 00000035110 15154306200 024137 0 ustar feng feng
MainWindow
MainWindow
test open
directory
selected uri
test show
test exec
test save
test static open
PushButton
use auto highlight icon
...
highlightOnly
bothDefaultAndHighlight
RadioButton
style
icon
menu opacity
font
MessageBox
Close
Fermer
QApplication
Executable '%1' requires Qt %2, found Qt %3.
L’exécutable '%1' nécessite Qt %2, trouvé Qt %3.
Incompatible Qt Library Error
Erreur de bibliothèque Qt incompatible
QDialogButtonBox
OK
D’ACCORD
QMessageBox
Show Details...
Afficher les détails...
Hide Details...
Masquer les détails...
QObject
File Name
Nom du fichier
Modified Date
Date de modification
File Type
Type de fichier
File Size
Taille du fichier
Original Path
Chemin d’accès d’origine
Descending
Descendant
Ascending
Ascendant
Use global sorting
Utiliser le tri global
List View
Affichage en liste
Icon View
Affichage de l’icône
Close
Fermer
UKUI::TabWidget::DefaultSlideAnimatorFactory
Default Slide
Diapositive par défaut
Let tab widget switch with a slide animation.
Laissez le widget d’onglet basculer avec une animation de diapositive.
UKUIFileDialog::KyFileDialogHelper
Open File
Ouvrir un fichier
Save File
Enregistrer le fichier
All Files (*)
Tous les fichiers (*)
UKUIFileDialog::KyNativeFileDialog
Go Back
Retour
Go Forward
Avancer
Cd Up
Cd Up
Search
Rechercher
View Type
Type de vue
Sort Type
Type de tri
Maximize
Maximiser
Close
Fermer
Restore
Restaurer
Name
Nom
Open
Ouvrir
Cancel
Annuler
Save as
Enregistrer sous
New Folder
Nouveau dossier
Save
Sauvegarder
Directories
Téléphonique
Warning
Avertissement
exist, are you sure replace?
exister, êtes-vous sûr de remplacer ?
NewFolder
NouveauDossier
Undo
Défaire
Redo
Refaire
warn
avertir
This operation is not supported.
Cette opération n’est pas prise en charge.
qt6-ukui-platformtheme/translations/qt5-ukui-platformtheme_es.ts 0000664 0001750 0001750 00000035112 15154306200 024141 0 ustar feng feng
MainWindow
MainWindow
test open
directory
selected uri
test show
test exec
test save
test static open
PushButton
use auto highlight icon
...
highlightOnly
bothDefaultAndHighlight
RadioButton
style
icon
menu opacity
font
MessageBox
Close
QApplication
Executable '%1' requires Qt %2, found Qt %3.
Incompatible Qt Library Error
QDialogButtonBox
OK
QMessageBox
Show Details...
Hide Details...
QObject
File Name
Modified Date
File Type
File Size
Original Path
Descending
Ascending
Use global sorting
List View
Icon View
Close
UKUI::TabWidget::DefaultSlideAnimatorFactory
Default Slide
Let tab widget switch with a slide animation.
UKUIFileDialog::KyFileDialogHelper
Open File
Save File
All Files (*)
UKUIFileDialog::KyNativeFileDialog
Go Back
Go Forward
Cd Up
Search
View Type
Sort Type
Maximize
Close
Restore
Name
Open
Cancel
Save as
New Folder
Save
Directories
Warning
exist, are you sure replace?
NewFolder
Undo
Redo
warn
This operation is not supported.
qt6-ukui-platformtheme/translations/qt5-ukui-platformtheme_zh_CN.ts 0000664 0001750 0001750 00000034500 15154306200 024533 0 ustar feng feng
MainWindow
MainWindow
test open
directory
selected uri
test show
test exec
test save
test static open
PushButton
use auto highlight icon
...
highlightOnly
bothDefaultAndHighlight
RadioButton
style
icon
menu opacity
font
MessageBox
Close
关闭
QApplication
Executable '%1' requires Qt %2, found Qt %3.
可执行文件“%1”需要数量%2,找到数量%3。
Incompatible Qt Library Error
不兼容的Qt库错误
QDialogButtonBox
OK
确认
QMessageBox
Show Details...
显示细节……
Hide Details...
隐藏细节……
QObject
File Name
文件名称
Modified Date
修改日期
File Type
文件类型
File Size
文件大小
Original Path
原始路径
Descending
降序
Ascending
升序
Use global sorting
使用全局排序
List View
列表视图
Icon View
图标视图
Close
关闭
UKUI::TabWidget::DefaultSlideAnimatorFactory
Default Slide
默认slide
Let tab widget switch with a slide animation.
让选项卡小部件切换为幻灯片动画。
UKUIFileDialog::KyFileDialogHelper
Open File
打开
Save File
保存
All Files (*)
所有(*)
UKUIFileDialog::KyNativeFileDialog
Go Back
后退
Go Forward
前进
Cd Up
向上
Search
搜索
View Type
视图类型
Sort Type
排序类型
Maximize
最大化
Close
关闭
Restore
还原
Name
文件名
Open
打开
Cancel
取消
Save as
另存为
New Folder
新建文件夹
Save
保存
Directories
目录
Warning
警告
exist, are you sure replace?
已存在,是否替换?
NewFolder
新建文件夹
Undo
撤销
Redo
重做
warn
警告
This operation is not supported.
不支持此操作。
qt6-ukui-platformtheme/translations/qt5-ukui-platformtheme_ky.ts 0000664 0001750 0001750 00000037067 15154306200 024170 0 ustar feng feng
MainWindow
MainWindow
نەگىزگى كۅزۅنۅك
test open
سېناقنى اچۇۇ
directory
تىزىمدىك
selected uri
تاندالعان uri
test show
سىناقتى كۅرسۅتۉۉ
test exec
اتقارماق قىلۇۇچۇنۇ ۅلچۅ
test save
سىناقتى ساقتوو
test static open
تىنچ ، تىم تىرس ابالدا اچۇۇنۇ سىنوو
PushButton
تانداش كونۇپكاسى
use auto highlight icon
اپتوماتتىك يارقىن كۅرسۅتۉۉ سىن بەلگىسىن ىشتەتىڭ
...
...
highlightOnly
جالاڭ عانا جوعورۇ يورۇقلۇقتا كۅرسۅتۉلۅت .
bothDefaultAndHighlight
ويۇنداقى جانا ورقويۇپ چىعۇۇ كۅرسۅتۉۉ
RadioButton
تاق تانداش كونۇپكاسى
style
ۇسلۇپ
icon
ايكون
menu opacity
تاماق ، اش تىزىمدىگىنىن تۇنۇقتۇق داراجاسى جوق
font
قات ۉلگۉسۉ
MessageBox
Close
بەكىتىش
QApplication
Executable '%1' requires Qt %2, found Qt %3.
اتقارماق جاسووعو بولوتۇرعان ۅجۅت 1، كەرەكتۉۉ سان 2، ىزدەپ تاپقان سان 3
Incompatible Qt Library Error
سىغىشمىغانQT قامپادا قاتاالىق كۅرۉلدۉ
QDialogButtonBox
OK
ماقۇل
QMessageBox
Show Details...
جۅن جايىن كۅرسۅتۉۉ
Hide Details...
جۅن جايىن جاشىرۇۇ
QObject
File Name
ۅجۅت ناامى
Modified Date
ۅزگۅرتۉلگۅن ۇباقتى
File Type
ۅجۅت تۉرۉ
File Size
ۅجۅت چوڭدۇعۇ
Original Path
العاچى جول
Descending
چوڭدىن كىچىككە قاراتىپ تىزۉۉ
Ascending
كىچىكتەن چوڭعو قاراتىپ تىزۉۉ
Use global sorting
ئومومىيلىق مەنەن تىزۉۉنۉ ىشتەتىش
List View
تىزىمدىك گۅرۉنۉشۉ
Icon View
تۉر گۅرۉنۉشۉ
Close
بەكىتىش
UKUI::TabWidget::DefaultSlideAnimatorFactory
Default Slide
الدىن بەكىتىلگەن slide
Let tab widget switch with a slide animation.
تاندالما كارتاداقى كىچىك شايمانداردى پرويەكسىيە كارتون فىلىمىگە الماشتىرۇۇ
UKUIFileDialog::KyFileDialogHelper
Open File
ۅجۅتۉن اچۇۇ
Save File
ۅجۅتۉن ساقتوو
All Files (*)
باردىق ۅجۅتتۅر (*)
UKUIFileDialog::KyNativeFileDialog
Go Back
قايتۇۇ
Go Forward
ىلگەرلۅۅ
Cd Up
Cd نىڭ ۉستۉ
Search
ىزدۅۅ
View Type
كۅرۉنۉش تۉرۉ
Sort Type
ىرەتتەلگەن تىپ
Maximize
چوڭويتۇش
Close
بەكىتىش
Restore
العاچىنا كەلتىرۉۉ
Name
اتى
Open
اچۇۇ
Cancel
ارعادان قالتىرىش
Save as
تەجۅۅ
New Folder
جاڭى ۅجۅت قىپچىعىچ
Save
ساقتوو
Directories
مازمۇۇندار
Warning
ەسكەرتۉۉ
exist, are you sure replace?
باربولۇۇسۇ ، الماشتىرۇۇنۇ تۇراقتاندىرا الاسىزبى؟
NewFolder
جاڭى قاتتاعىچ
Undo
اچۇۇ
Redo
قايرا-قايرا سىنوو
warn
ەسكەرتۉۉ
This operation is not supported.
بۇل ماشقۇلدانۇۇنۇ قولدوبويت.
qt6-ukui-platformtheme/README.md 0000664 0001750 0001750 00000003613 15154306200 015310 0 ustar feng feng # qt5-ukui-platformtheme
The UKUI platform theme for qt5 QPA.
## Wiki on Gitee
[Wiki](https://gitee.com/openkylin/qt5-ukui-platformtheme/wikis/Home)
# Introduction
[zh_CN](https://gitee.com/openkylin/qt5-ukui-platformtheme/wikis/%E9%A1%B9%E7%9B%AE%E7%AE%80%E4%BB%8B)
[安装和测试](https://gitee.com/openkylin/qt5-ukui-platformtheme/wikis/%E5%AE%89%E8%A3%85%26%E6%B5%8B%E8%AF%95%E6%B5%81%E7%A8%8B)
## Document
See [doxygen/README.md](doxygen/README.md).
## Description
In the early development of the UKUI 3.0, we used qt5-gtk2-platformtheme to ensure the unity of the UKUI desktop style. However, it has many limitations for our new desgin.
This project is intend to provide a common resolution of desktop application development with qt5 in UKUI3.0. We hope provide a platform theme to unify and beautify all qt applications according to the design of UKUI3.0, not only our own applications. We are also committed to building our applications that can adapt to different styles. This project is first step to archive those objectives.
qt5-ukui-platformtheme's route brings us closer to the upstream communities. It is not a division, but a desire for fusion and individuality in a compatible way.
## Build and Test
### Build Depends (reference debian/contorl)
- pkg-config
- qt5-default
- qtbase5-private-dev
- libkf5windowsystem-dev
- libgsettings-qt-dev
- libglib2.0-dev
### Testing
To test the project, you should first install it into system and make sure that the current qpa platform is ukui.
You can export the QT_QPA_PLATFORMTHEME in terminal.
> export QT_QPA_PLATFORMTHEME=ukui
One more important job,
> sudo glib-compile-schemas /usr/share/glib-2.0/schemas
That will let the gsettings used by qt5-ukui-platformtheme worked.
Then you can run the test in project, or run any qt5 program for testing with ukui platformtheme.
### ToDoList
- change style's details through configuration file
- animations
qt6-ukui-platformtheme/ukui-qml-style-helper/ 0000775 0001750 0001750 00000000000 15154306200 020205 5 ustar feng feng qt6-ukui-platformtheme/ukui-qml-style-helper/KyIcon.h 0000664 0001750 0001750 00000007052 15154306200 021556 0 ustar feng feng /*
* Qt5-UKUI's Library
*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library. If not, see .
*
* Authors: Yan Wang
*
*/
#ifndef KYICON_H
#define KYICON_H
#include
#include
#include
#include
#include "styleparameter/imageprovider.h"
class QStyle;
class KyIcon : public QQuickPaintedItem
{
Q_OBJECT
Q_PROPERTY(QString iconName READ iconName WRITE setIconName NOTIFY iconNameChanged)
Q_PROPERTY(QIcon icon READ icon WRITE setIcon)
Q_PROPERTY( bool hover READ hover WRITE setHover NOTIFY hoverChanged)
Q_PROPERTY( bool selected READ selected WRITE setSelected NOTIFY selectedChanged)
Q_PROPERTY( bool hasFocus READ hasFocus WRITE sethasFocus NOTIFY hasFocusChanged)
Q_PROPERTY( bool active READ active WRITE setActive NOTIFY activeChanged)
Q_PROPERTY( bool sunken READ sunken WRITE setSunken NOTIFY sunkenChanged)
Q_PROPERTY( bool on READ on WRITE setOn NOTIFY onChanged)
Q_PROPERTY( QString icontype READ icontype WRITE seticontype NOTIFY icontypeChanged)
public:
KyIcon(QQuickPaintedItem *parent = nullptr);
QIcon icon() { return m_icon; }
void setIcon(const QIcon &icon);
QString iconName(){ return m_iconName; }
void setIconName(const QString &iconName);
bool hover() const { return m_hover; }
void setHover(bool hover) { if (m_hover != hover) {m_hover = hover ; emit hoverChanged();}}
bool selected() const { return m_selected; }
void setSelected(bool selected) {
if (m_selected!= selected) {
m_selected = selected;
emit selectedChanged();
}
}
bool hasFocus() const { return m_focus; }
void sethasFocus(bool focus) { if (m_focus != focus) {m_focus = focus; emit hasFocusChanged();}}
bool active() const { return m_active; }
void setActive(bool active) { if (m_active!= active) {m_active = active; emit activeChanged();}}
bool sunken() const { return m_sunken; }
void setSunken(bool sunken) { if (m_sunken != sunken) {m_sunken = sunken; emit sunkenChanged();}}
bool on() const { return m_on; }
void setOn(bool on) { if (m_on != on) {m_on = on ; emit onChanged();}}
QString icontype() const { return m_icontype;}
void seticontype(QString icontype) {
m_icontype = icontype ;
emit icontypeChanged();
}
void paint(QPainter *painter);
static QStyle *style();
public Q_SLOTS:
void updateItem(){update();}
Q_SIGNALS:
void hoverChanged();
void selectedChanged();
void hasFocusChanged();
void activeChanged();
void sunkenChanged();
void onChanged();
void icontypeChanged();
void iconNameChanged();
protected:
bool m_hover;
bool m_selected;
bool m_focus;
bool m_active;
bool m_sunken;
bool m_on;
QString m_icontype;
private:
QIcon m_icon;
QString m_iconName;
UKUIQQC2Style::IconHelper m_iconHelper;
};
#endif // KYICON_H
qt6-ukui-platformtheme/ukui-qml-style-helper/kystylehelper.cpp 0000664 0001750 0001750 00000003207 15154306200 023617 0 ustar feng feng /*
* Qt5-UKUI's Library
*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library. If not, see .
*
* Authors: Yan Wang
*
*/
#include "kystylehelper.h"
#include
#include
#include
KyStyleHelper::KyStyleHelper(QQuickItem *parent)
: QQuickItem(parent)
{
if (QGSettings::isSchemaInstalled("org.ukui.style")) {
QGSettings* styleSettings = new QGSettings("org.ukui.style", QByteArray(), this);
connect(styleSettings, &QGSettings::changed, this, [&](const QString &key){
if (key == "styleName" || key == "themeColor") {
emit paletteChanged();
emit qcolorChanged();
}
if (key == "systemFontSize" || key == "systemFont") {
emit fontChanged();
}
});
}
}
KyStyleHelper::~KyStyleHelper() {}
KyStyleHelper* KyStyleHelper::qmlAttachedProperties(QObject *parent)
{
auto p = qobject_cast(parent);
return new KyStyleHelper(p);
}
qt6-ukui-platformtheme/ukui-qml-style-helper/qmldir 0000664 0001750 0001750 00000000077 15154306200 021424 0 ustar feng feng module org.ukui.qqc2style.private
plugin ukui-qml-style-helper
qt6-ukui-platformtheme/ukui-qml-style-helper/kyquickstyleitem.cpp 0000664 0001750 0001750 00000227023 15154306200 024337 0 ustar feng feng /*
* Qt5-UKUI's Library
*
* Copyright (C) 2023, KylinSoft Co., Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library. If not, see .
*
* Authors: Yan Wang
*
*/
#include "kyquickstyleitem.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
//#include
//#include
#include
#include
QStyle *KyQuickStyleItem::s_style = nullptr;
QStyle *KyQuickStyleItem::style()
{
auto style = qApp->style();
return style ? style : s_style;
}
KyQuickStyleItem::KyQuickStyleItem(QQuickItem *parent)
: QQuickItem(parent),
m_styleoption(nullptr),
m_itemType(Undefined),
m_sunken(false),
m_raised(false),
m_active(true),
m_selected(false),
m_focus(false),
m_hover(false),
m_on(false),
m_horizontal(true),
m_transient(false),
m_sharedWidget(false),
m_minimum(0),
m_maximum(100),
m_value(0),
m_step(0),
m_paintMargins(0),
m_contentWidth(0),
m_contentHeight(0),
m_textureWidth(0),
m_textureHeight(0),
m_lastFocusReason(Qt::NoFocusReason)
{
// There is no styleChanged signal and QApplication sends QEvent::StyleChange only to all QWidgets
if (qApp->style()) {
connect(qApp->style(), &QObject::destroyed, this, &KyQuickStyleItem::styleChanged);
} else {
// KSharedConfig::Ptr kdeglobals = KSharedConfig::openConfig();
// KConfigGroup cg(kdeglobals, "KDE");
// auto style = s_style;
// s_style = QStyleFactory::create(cg.readEntry("widgetStyle", QStringLiteral("Fusion")));
// if (style) {
// delete style;
// }
}
if (QGSettings::isSchemaInstalled("org.ukui.style")) {
QGSettings* styleSettings = new QGSettings("org.ukui.style", QByteArray(), this);
connect(styleSettings, &QGSettings::changed, this, [&](const QString &key){
if (key == "systemFontSize" || key == "systemFont") {
emit fontChanged();
updatePolish();
}
if (key == "iconThemeName"){
polish();
}
});
}
m_font = qApp->font();
setFlag(QQuickItem::ItemHasContents, true);
setSmooth(false);
connect(this, &KyQuickStyleItem::visibleChanged, this, &KyQuickStyleItem::updateItem);
connect(this, &KyQuickStyleItem::widthChanged, this, &KyQuickStyleItem::updateItem);
connect(this, &KyQuickStyleItem::heightChanged, this, &KyQuickStyleItem::updateItem);
connect(this, &KyQuickStyleItem::enabledChanged, this, &KyQuickStyleItem::updateItem);
connect(this, &KyQuickStyleItem::infoChanged, this, &KyQuickStyleItem::updateItem);
connect(this, &KyQuickStyleItem::onChanged, this, &KyQuickStyleItem::updateItem);
connect(this, &KyQuickStyleItem::selectedChanged, this, &KyQuickStyleItem::updateItem);
connect(this, &KyQuickStyleItem::activeChanged, this, &KyQuickStyleItem::updateItem);
connect(this, &KyQuickStyleItem::textChanged, this, &KyQuickStyleItem::updateSizeHint);
connect(this, &KyQuickStyleItem::textChanged, this, &KyQuickStyleItem::updateItem);
connect(this, &KyQuickStyleItem::activeChanged, this, &KyQuickStyleItem::updateItem);
connect(this, &KyQuickStyleItem::raisedChanged, this, &KyQuickStyleItem::updateItem);
connect(this, &KyQuickStyleItem::sunkenChanged, this, &KyQuickStyleItem::updateItem);
connect(this, &KyQuickStyleItem::hoverChanged, this, &KyQuickStyleItem::updateItem);
connect(this, &KyQuickStyleItem::maximumChanged, this, &KyQuickStyleItem::updateItem);
connect(this, &KyQuickStyleItem::minimumChanged, this, &KyQuickStyleItem::updateItem);
connect(this, &KyQuickStyleItem::valueChanged, this, &KyQuickStyleItem::updateItem);
connect(this, &KyQuickStyleItem::horizontalChanged, this, &KyQuickStyleItem::updateItem);
connect(this, &KyQuickStyleItem::transientChanged, this, &KyQuickStyleItem::updateItem);
connect(this, &KyQuickStyleItem::activeControlChanged, this, &KyQuickStyleItem::updateItem);
connect(this, &KyQuickStyleItem::hasFocusChanged, this, &KyQuickStyleItem::updateItem);
connect(this, &KyQuickStyleItem::activeControlChanged, this, &KyQuickStyleItem::updateItem);
connect(this, &KyQuickStyleItem::hintChanged, this, &KyQuickStyleItem::updateItem);
connect(this, &KyQuickStyleItem::propertiesChanged, this, &KyQuickStyleItem::updateSizeHint);
connect(this, &KyQuickStyleItem::propertiesChanged, this, &KyQuickStyleItem::updateItem);
connect(this, &KyQuickStyleItem::elementTypeChanged, this, &KyQuickStyleItem::updateItem);
connect(this, &KyQuickStyleItem::contentWidthChanged, this, &KyQuickStyleItem::updateSizeHint);
connect(this, &KyQuickStyleItem::contentHeightChanged, this, &KyQuickStyleItem::updateSizeHint);
connect(this, &KyQuickStyleItem::widthChanged, this, &KyQuickStyleItem::updateRect);
connect(this, &KyQuickStyleItem::heightChanged, this, &KyQuickStyleItem::updateRect);
connect(this, &KyQuickStyleItem::heightChanged, this, &KyQuickStyleItem::updateBaselineOffset);
connect(this, &KyQuickStyleItem::contentHeightChanged, this, &KyQuickStyleItem::updateBaselineOffset);
connect(qApp, &QApplication::fontChanged, this, &KyQuickStyleItem::updateSizeHint, Qt::QueuedConnection);
}
KyQuickStyleItem::~KyQuickStyleItem()
{
if (const QStyleOptionButton *aux = qstyleoption_cast(m_styleoption))
delete aux;
else if (const QStyleOptionViewItem *aux = qstyleoption_cast(m_styleoption))
delete aux;
else if (const QStyleOptionHeader *aux = qstyleoption_cast(m_styleoption))
delete aux;
else if (const QStyleOptionToolButton *aux = qstyleoption_cast(m_styleoption))
delete aux;
else if (const QStyleOptionToolBar *aux = qstyleoption_cast(m_styleoption))
delete aux;
else if (const QStyleOptionTab *aux = qstyleoption_cast(m_styleoption))
delete aux;
else if (const QStyleOptionFrame *aux = qstyleoption_cast(m_styleoption))
delete aux;
else if (const QStyleOptionFocusRect *aux = qstyleoption_cast(m_styleoption))
delete aux;
else if (const QStyleOptionTabWidgetFrame *aux = qstyleoption_cast(m_styleoption))
delete aux;
else if (const QStyleOptionMenuItem *aux = qstyleoption_cast(m_styleoption))
delete aux;
else if (const QStyleOptionComboBox *aux = qstyleoption_cast(m_styleoption))
delete aux;
else if (const QStyleOptionSpinBox *aux = qstyleoption_cast(m_styleoption))
delete aux;
else if (const QStyleOptionSlider *aux = qstyleoption_cast(m_styleoption))
delete aux;
else if (const QStyleOptionProgressBar *aux = qstyleoption_cast(m_styleoption))
delete aux;
else if (const QStyleOptionGroupBox *aux = qstyleoption_cast(m_styleoption))
delete aux;
else
delete m_styleoption;
m_styleoption = nullptr;
}
void KyQuickStyleItem::initStyleOption()
{
if (m_styleoption)
m_styleoption->state = {};
QString sizeHint = m_hints.value(QStringLiteral("size")).toString();
bool needsResolvePalette = true;
update();
switch (m_itemType) {
case Button: {
if (!m_styleoption)
m_styleoption = new QStyleOptionButton();
QStyleOptionButton *opt = qstyleoption_cast(m_styleoption);
opt->text = text();
const QVariant icon = m_properties[QStringLiteral("icon")];
if (icon.canConvert()) {
opt->icon = icon.value();
} else if (icon.canConvert() && icon.value().isLocalFile()) {
opt->icon = QIcon(icon.value().toLocalFile());
} else if (icon.canConvert()) {
opt->icon = QIcon::fromTheme(icon.value());
}
auto iconSize = QSize(m_properties[QStringLiteral("iconWidth")].toInt(),
m_properties[QStringLiteral("iconHeight")].toInt());
if (iconSize.isEmpty()) {
int e = KyQuickStyleItem::style()->pixelMetric(QStyle::PM_ButtonIconSize, m_styleoption, nullptr);
if (iconSize.width() <= 0) {
iconSize.setWidth(e);
}
if (iconSize.height() <= 0) {
iconSize.setHeight(e);
}
}
opt->iconSize = iconSize;
opt->features = activeControl() == QLatin1String("default") ?
QStyleOptionButton::DefaultButton :
QStyleOptionButton::None;
if (m_properties[QStringLiteral("flat")].toBool()) {
opt->features |= QStyleOptionButton::Flat;
}
const QFont font = qApp->font("QPushButton");
opt->fontMetrics = QFontMetrics(font);
QObject * menu = m_properties[QStringLiteral("menu")].value();
if (menu) {
opt->features |= QStyleOptionButton::HasMenu;
}
}
break;
case ItemRow: {
if (!m_styleoption)
m_styleoption = new QStyleOptionViewItem();
QStyleOptionViewItem *opt = qstyleoption_cast(m_styleoption);
opt->features = {};
if (activeControl() == QLatin1String("alternate"))
opt->features |= QStyleOptionViewItem::Alternate;
}
break;
case Splitter: {
if (!m_styleoption) {
m_styleoption = new QStyleOption;
}
}
break;
case Item: {
if (!m_styleoption) {
m_styleoption = new QStyleOptionViewItem();
}
QStyleOptionViewItem *opt = qstyleoption_cast(m_styleoption);
opt->features = QStyleOptionViewItem::HasDisplay;
opt->text = text();
opt->textElideMode = Qt::ElideRight;
opt->displayAlignment = Qt::AlignLeft | Qt::AlignVCenter;
opt->decorationAlignment = Qt::AlignCenter;
resolvePalette();
needsResolvePalette = false;
QPalette pal = m_styleoption->palette;
pal.setBrush(QPalette::Base, Qt::NoBrush);
m_styleoption->palette = pal;
const QFont font = qApp->font("QAbstractItemView");
opt->font = font;
opt->fontMetrics = QFontMetrics(font);
break;
}
case ItemBranchIndicator: {
if (!m_styleoption)
m_styleoption = new QStyleOption;
m_styleoption->state = QStyle::State_Item; // We don't want to fully support Win 95
if (m_properties.value(QStringLiteral("hasChildren")).toBool())
m_styleoption->state |= QStyle::State_Children;
if (m_properties.value(QStringLiteral("hasSibling")).toBool()) // Even this one could go away
m_styleoption->state |= QStyle::State_Sibling;
if (m_on)
m_styleoption->state |= QStyle::State_Open;
}
break;
case Header: {
if (!m_styleoption)
m_styleoption = new QStyleOptionHeader();
QStyleOptionHeader *opt = qstyleoption_cast(m_styleoption);
opt->text = text();
opt->textAlignment = static_cast(m_properties.value(QStringLiteral("textalignment")).toInt());
opt->sortIndicator = activeControl() == QLatin1String("down") ?
QStyleOptionHeader::SortDown
: activeControl() == QLatin1String("up") ?
QStyleOptionHeader::SortUp : QStyleOptionHeader::None;
QString headerpos = m_properties.value(QStringLiteral("headerpos")).toString();
if (headerpos == QLatin1String("beginning"))
opt->position = QStyleOptionHeader::Beginning;
else if (headerpos == QLatin1String("end"))
opt->position = QStyleOptionHeader::End;
else if (headerpos == QLatin1String("only"))
opt->position = QStyleOptionHeader::OnlyOneSection;
else
opt->position = QStyleOptionHeader::Middle;
const QFont font = qApp->font("QHeaderView");
opt->fontMetrics = QFontMetrics(font);
}
break;
case ToolButton: {
if (!m_styleoption)
m_styleoption = new QStyleOptionToolButton();
QStyleOptionToolButton *opt =
qstyleoption_cast(m_styleoption);
opt->subControls = QStyle::SC_ToolButton;
opt->state |= QStyle::State_AutoRaise;
opt->activeSubControls = QStyle::SC_ToolButton;
opt->text = text();
const QVariant icon = m_properties[QStringLiteral("icon")];
if (icon.canConvert()) {
opt->icon = icon.value();
} else if (icon.canConvert() && icon.value().isLocalFile()) {
opt->icon = QIcon(icon.value().toLocalFile());
} else if (icon.canConvert()) {
opt->icon = QIcon::fromTheme(icon.value());
}
auto iconSize = QSize(m_properties[QStringLiteral("iconWidth")].toInt(),
m_properties[QStringLiteral("iconHeight")].toInt());
if (iconSize.isEmpty()) {
int e = KyQuickStyleItem::style()->pixelMetric(QStyle::PM_ToolBarIconSize, m_styleoption, nullptr);
if (iconSize.width() <= 0) {
iconSize.setWidth(e);
}
if (iconSize.height() <= 0) {
iconSize.setHeight(e);
}
}
opt->iconSize = iconSize;
if (m_properties.value(QStringLiteral("menu")).toBool()) {
opt->subControls |= QStyle::SC_ToolButtonMenu;
opt->features = QStyleOptionToolButton::HasMenu;
}
const int toolButtonStyle = m_properties.value(QStringLiteral("toolButtonStyle")).toInt();
switch (toolButtonStyle) {
case Qt::ToolButtonIconOnly:
case Qt::ToolButtonTextOnly:
case Qt::ToolButtonTextBesideIcon:
case Qt::ToolButtonTextUnderIcon:
case Qt::ToolButtonFollowStyle:
opt->toolButtonStyle = (Qt::ToolButtonStyle)toolButtonStyle;
break;
default:
opt->toolButtonStyle = Qt::ToolButtonFollowStyle;
}
const QFont font = qApp->font("QToolButton");
opt->font = font;
opt->fontMetrics = QFontMetrics(font);
}
break;
case ToolBar: {
if (!m_styleoption)
m_styleoption = new QStyleOptionToolBar();
}
break;
case Tab: {
if (!m_styleoption)
m_styleoption = new QStyleOptionTab();
QStyleOptionTab *opt = qstyleoption_cast(m_styleoption);
opt->text = text();
const QVariant icon = m_properties[QStringLiteral("icon")];
if (icon.canConvert()) {
opt->icon = icon.value();
} else if (icon.canConvert() && icon.value().isLocalFile()) {
opt->icon = QIcon(icon.value().toLocalFile());
} else if (icon.canConvert()) {
opt->icon = QIcon::fromTheme(icon.value());
}
auto iconSize = QSize(m_properties[QStringLiteral("iconWidth")].toInt(),
m_properties[QStringLiteral("iconHeight")].toInt());
if (iconSize.isEmpty()) {
int e = KyQuickStyleItem::style()->pixelMetric(QStyle::PM_ButtonIconSize, m_styleoption, nullptr);
if (iconSize.width() <= 0) {
iconSize.setWidth(e);
}
if (iconSize.height() <= 0) {
iconSize.setHeight(e);
}
}
opt->iconSize = iconSize;
if (m_properties.value(QStringLiteral("hasFrame")).toBool())
opt->features |= QStyleOptionTab::HasFrame;
QString orientation = m_properties.value(QStringLiteral("orientation")).toString();
QString position = m_properties.value(QStringLiteral("tabpos")).toString();
QString selectedPosition = m_properties.value(QStringLiteral("selectedpos")).toString();
opt->shape = orientation == QLatin1String("Bottom") ? QTabBar::RoundedSouth : QTabBar::RoundedNorth;
if (position == QLatin1String("beginning"))
opt->position = QStyleOptionTab::Beginning;
else if (position == QLatin1String("end"))
opt->position = QStyleOptionTab::End;
else if (position == QLatin1String("only"))
opt->position = QStyleOptionTab::OnlyOneTab;
else
opt->position = QStyleOptionTab::Middle;
if (selectedPosition == QLatin1String("next"))
opt->selectedPosition = QStyleOptionTab::NextIsSelected;
else if (selectedPosition == QLatin1String("previous"))
opt->selectedPosition = QStyleOptionTab::PreviousIsSelected;
else
opt->selectedPosition = QStyleOptionTab::NotAdjacent;
} break;
case Frame: {
if (!m_styleoption)
m_styleoption = new QStyleOptionFrame();
QStyleOptionFrame *opt = qstyleoption_cast(m_styleoption);
opt->frameShape = QFrame::StyledPanel;
opt->lineWidth = KyQuickStyleItem::style()->pixelMetric(QStyle::PM_DefaultFrameWidth, m_styleoption, nullptr);
opt->midLineWidth = KyQuickStyleItem::style()->pixelMetric(QStyle::PM_DefaultFrameWidth, m_styleoption, nullptr);
}
break;
case FocusRect: {
if (!m_styleoption)
m_styleoption = new QStyleOptionFocusRect();
// Needed on windows
m_styleoption->state |= QStyle::State_KeyboardFocusChange;
}
break;
case TabFrame: {
if (!m_styleoption)
m_styleoption = new QStyleOptionTabWidgetFrame();
QStyleOptionTabWidgetFrame *opt = qstyleoption_cast(m_styleoption);
opt->selectedTabRect = m_properties[QStringLiteral("selectedTabRect")].toRect();
opt->shape = m_properties[QStringLiteral("orientation")] == Qt::BottomEdge ? QTabBar::RoundedSouth : QTabBar::RoundedNorth;
if (minimum())
opt->selectedTabRect = QRect(value(), 0, minimum(), height());
opt->tabBarSize = QSize(minimum() , height());
// oxygen style needs this hack
opt->leftCornerWidgetSize = QSize(value(), 0);
}
break;
case MenuBar:
if (!m_styleoption) {
QStyleOptionMenuItem *menuOpt = new QStyleOptionMenuItem();
menuOpt->menuItemType = QStyleOptionMenuItem::EmptyArea;
m_styleoption = menuOpt;
}
break;
case MenuBarItem:
{
if (!m_styleoption)
m_styleoption = new QStyleOptionMenuItem();
QStyleOptionMenuItem *opt = qstyleoption_cast(m_styleoption);
opt->text = text();
opt->menuItemType = QStyleOptionMenuItem::Normal;
setProperty("_q_showUnderlined", m_hints[QStringLiteral("showUnderlined")].toBool());
const QFont font = qApp->font("QMenuBar");
opt->font = font;
opt->fontMetrics = QFontMetrics(font);
m_font = opt->font;
}
break;
case Menu: {
if (!m_styleoption)
m_styleoption = new QStyleOptionMenuItem();
}
break;
case MenuItem:
case ComboBoxItem:
{
if (!m_styleoption)
m_styleoption = new QStyleOptionMenuItem();
QStyleOptionMenuItem *opt = qstyleoption_cast(m_styleoption);
// For GTK style. See below, in setElementType()
setProperty("_q_isComboBoxPopupItem", m_itemType == ComboBoxItem);
KyQuickStyleItem::MenuItemType type =
static_cast(m_properties[QStringLiteral("type")].toInt());
if (type == KyQuickStyleItem::ScrollIndicatorType) {
int scrollerDirection = m_properties[QStringLiteral("scrollerDirection")].toInt();
opt->menuItemType = QStyleOptionMenuItem::Scroller;
opt->state |= scrollerDirection == Qt::UpArrow ?
QStyle::State_UpArrow : QStyle::State_DownArrow;
} else if (type == KyQuickStyleItem::SeparatorType) {
opt->menuItemType = QStyleOptionMenuItem::Separator;
} else {
opt->text = text();
if (type == KyQuickStyleItem::MenuType) {
opt->menuItemType = QStyleOptionMenuItem::SubMenu;
} else {
opt->menuItemType = QStyleOptionMenuItem::Normal;
QString shortcut = m_properties[QStringLiteral("shortcut")].toString();
if (!shortcut.isEmpty()) {
opt->text += QLatin1Char('\t') + shortcut;
// opt->tabWidth = qMax(opt->tabWidth, qRound(textWidth(shortcut)));
static qreal maxShortcutWidth = 0;
maxShortcutWidth = qMax(maxShortcutWidth, static_cast(qRound(textWidth(shortcut))));
qreal actualTabWidth = maxShortcutWidth + 8;
}
if (m_properties[QStringLiteral("checkable")].toBool()) {
opt->checked = on();
QVariant exclusive = m_properties[QStringLiteral("exclusive")];
opt->checkType = exclusive.toBool() ? QStyleOptionMenuItem::Exclusive :
QStyleOptionMenuItem::NonExclusive;
}
}
if (m_properties[QStringLiteral("icon")].canConvert())
opt->icon = m_properties[QStringLiteral("icon")].value();
setProperty("_q_showUnderlined", m_hints[QStringLiteral("showUnderlined")].toBool());
const QFont font = qApp->font(m_itemType == ComboBoxItem ?"QComboMenuItem" : "QMenu");
opt->font = font;
opt->fontMetrics = QFontMetrics(font);
m_font = opt->font;
}
}
break;
case CheckBox:
case RadioButton:
{
if (!m_styleoption)
m_styleoption = new QStyleOptionButton();
QStyleOptionButton *opt = qstyleoption_cast(m_styleoption);
if (!on())
opt->state |= QStyle::State_Off;
if (m_properties.value(QStringLiteral("partiallyChecked")).toBool())
opt->state |= QStyle::State_NoChange;
opt->text = text();
}
break;
case Edit: {
if (!m_styleoption)
m_styleoption = new QStyleOptionFrame();
QStyleOptionFrame *opt = qstyleoption_cast(m_styleoption);
opt->lineWidth = qMax(1, KyQuickStyleItem::style()->pixelMetric(QStyle::PM_DefaultFrameWidth, m_styleoption, nullptr)); //this must be non zero
}
break;
case ComboBox :{
if (!m_styleoption)
m_styleoption = new QStyleOptionComboBox();
QStyleOptionComboBox *opt = qstyleoption_cast