-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: modify accessdialog to dtk style
modify accessdialog to dtk style
- Loading branch information
Showing
13 changed files
with
246 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# SPDX-FileCopyrightText: None | ||
# | ||
# SPDX-License-Identifier: CC0-1.0 | ||
add_subdirectory(translations) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# generate qm | ||
execute_process(COMMAND bash "misc/translations/translate_generation.sh" | ||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) | ||
|
||
file(GLOB QM_FILES "translations/*.qm") | ||
install(FILES ${QM_FILES} DESTINATION share/${PROJECT_NAME}/translations) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
|
||
CURRENT_DIR=$(pwd) | ||
PROJECT_DIR=$(dirname $(realpath $(dirname $(realpath $(dirname $(realpath $0)))))) | ||
cd ${PROJECT_DIR} | ||
echo 当前目录:${CURRENT_DIR} | ||
echo 工程目录:${PROJECT_DIR} | ||
# 执行目录会切换到工程目录 | ||
|
||
# xdg-desktop-portal-dde | ||
lupdate ${PROJECT_DIR}/src -no-obsolete -no-ui-lines -locations none -ts ${PROJECT_DIR}/misc/translations/translations/xdg-desktop-portal-dde_en.ts | ||
|
||
# 推送翻译 | ||
tx push -s --branch m23 | ||
cd ${CURRENT_DIR} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
# this file is used to auto-generate .qm file from .ts file. | ||
# author: shibowen at linuxdeepin.com | ||
CURRENT_DIR=$(pwd) | ||
PROJECT_DIR=$CURRENT_DIR/misc/translations | ||
cd ${PROJECT_DIR} | ||
echo 当前目录:${CURRENT_DIR} | ||
echo 工程目录:${PROJECT_DIR} | ||
|
||
ts_list=(`ls translations/*.ts`) | ||
|
||
for ts in "${ts_list[@]}" | ||
do | ||
printf "\nprocess ${ts}\n" | ||
lrelease "${ts}" | ||
done | ||
|
||
cd ${CURRENT_DIR} |
30 changes: 30 additions & 0 deletions
30
misc/translations/translations/xdg-desktop-portal-dde_en.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!DOCTYPE TS> | ||
<TS version="2.1" language="en_US"> | ||
<context> | ||
<name>AppChooserDialog</name> | ||
<message> | ||
<location filename="../../../src/appchooserdialog.cpp" line="18"/> | ||
<source>Cancel</source> | ||
<translation>Cancel</translation> | ||
</message> | ||
<message> | ||
<location filename="../../../src/appchooserdialog.cpp" line="19"/> | ||
<source>Confirm</source> | ||
<translation>Confirm</translation> | ||
</message> | ||
</context> | ||
<context> | ||
<name>accessDialog</name> | ||
<message> | ||
<location filename="../../../src/accessdialog.cpp" line="73"/> | ||
<source>Deny Access</source> | ||
<translation>Deny Access</translation> | ||
</message> | ||
<message> | ||
<location filename="../../../src/accessdialog.cpp" line="81"/> | ||
<source>Grant Access</source> | ||
<translation>Grant Access</translation> | ||
</message> | ||
</context> | ||
</TS> |
30 changes: 30 additions & 0 deletions
30
misc/translations/translations/xdg-desktop-portal-dde_zh_CN.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!DOCTYPE TS> | ||
<TS version="2.1" language="zh_CN"> | ||
<context> | ||
<name>AppChooserDialog</name> | ||
<message> | ||
<location filename="../../../src/appchooserdialog.cpp" line="18"/> | ||
<source>Cancel</source> | ||
<translation>取消</translation> | ||
</message> | ||
<message> | ||
<location filename="../../../src/appchooserdialog.cpp" line="19"/> | ||
<source>Confirm</source> | ||
<translation>确认</translation> | ||
</message> | ||
</context> | ||
<context> | ||
<name>accessDialog</name> | ||
<message> | ||
<location filename="../../../src/accessdialog.cpp" line="73"/> | ||
<source>Deny Access</source> | ||
<translation>拒绝</translation> | ||
</message> | ||
<message> | ||
<location filename="../../../src/accessdialog.cpp" line="81"/> | ||
<source>Grant Access</source> | ||
<translation>授权</translation> | ||
</message> | ||
</context> | ||
</TS> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. | ||
// | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
// | ||
// Created by uos on 24-9-9. | ||
// | ||
|
||
#include "accessdialog.h" | ||
#include <QWindow> | ||
#include <QMessageBox> | ||
// X11的声明放在下面,防止编译报错 | ||
#include <X11/Xlib.h> | ||
|
||
Display* getX11Display() { | ||
// 使用 XOpenDisplay 获取 X11 Display | ||
Display *display = XOpenDisplay(nullptr); // 使用默认的 Display | ||
if (!display) { | ||
qWarning() << "Failed to open X11 display"; | ||
} | ||
return display; | ||
} | ||
|
||
// 从 X11 Display 获取屏幕几何信息 | ||
QRect getScreenGeometryFromX11(Display *display, Window screenNumber) { | ||
if (!display) { | ||
return QRect(); | ||
} | ||
QRect geometry; | ||
geometry.setLeft(0); | ||
geometry.setTop(0); | ||
geometry.setWidth(DisplayWidth(display, screenNumber)); | ||
geometry.setHeight(DisplayHeight(display, screenNumber)); | ||
return geometry; | ||
} | ||
|
||
accessDialog::accessDialog(const QString &app_id, const QString &parent_window, const QString &title, const QString &subtitle, const QString &body, const QVariantMap &options) : | ||
DDialog(), | ||
m_titleLabel(new QLabel(this)), | ||
m_subtitleLabel(new QLabel(this)), | ||
m_bodyLabel(new QLabel(this)) | ||
{ | ||
setAccessibleName("AccessDialog"); | ||
setIcon(QIcon::fromTheme("dialog-warning")); | ||
setAttribute(Qt::WA_QuitOnClose); | ||
// 设置tittle | ||
m_titleLabel->setObjectName("TitileText"); | ||
m_titleLabel->setAccessibleName("TitileText"); | ||
addContent(m_titleLabel, Qt::AlignTop | Qt::AlignHCenter); | ||
QFont font = m_titleLabel->font(); | ||
font.setBold(true); | ||
font.setPixelSize(16); | ||
m_titleLabel->setFont(font); | ||
m_titleLabel->setText(title); | ||
// 设置subtitle | ||
m_subtitleLabel->setObjectName("SubtitleText"); | ||
m_subtitleLabel->setAccessibleName("SubtitleText"); | ||
addContent(m_subtitleLabel, Qt::AlignTop | Qt::AlignHCenter); | ||
m_subtitleLabel->setText(subtitle+"\n"); | ||
// 设置body | ||
m_bodyLabel->setObjectName("BodyText"); | ||
m_bodyLabel->setAccessibleName("BodyText"); | ||
addContent(m_bodyLabel, Qt::AlignTop | Qt::AlignHCenter); | ||
m_bodyLabel->setText(body); | ||
|
||
if (options.contains(QStringLiteral("modal"))) { | ||
setModal(options.value(QStringLiteral("modal")).toBool()); | ||
} | ||
|
||
if (options.contains(QStringLiteral("deny_label"))) { | ||
addButton(options.value(QStringLiteral("deny_label")).toString(), QMessageBox::RejectRole); | ||
} else { | ||
addButton(tr("Deny Access"), QMessageBox::RejectRole); | ||
} | ||
|
||
|
||
int allowButton; | ||
if (options.contains(QStringLiteral("grant_label"))) { | ||
addButton(options.value(QStringLiteral("grant_label")).toString(), QMessageBox::AcceptRole); | ||
} else { | ||
addButton(tr("Grant Access"), QMessageBox::AcceptRole); | ||
} | ||
|
||
setWindowFlag(Qt::WindowStaysOnTopHint); | ||
} | ||
|
||
accessDialog::~accessDialog(){ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. | ||
// | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
// | ||
// Created by uos on 24-9-9. | ||
// | ||
|
||
#ifndef XDG_DESKTOP_PORTAL_DDE_ACCESSDIALOG_H | ||
#define XDG_DESKTOP_PORTAL_DDE_ACCESSDIALOG_H | ||
|
||
#include <ddialog.h> | ||
#include <DWidget> | ||
#include <QLabel> | ||
#include <QVBoxLayout> | ||
#include <QDialogButtonBox> | ||
|
||
DWIDGET_USE_NAMESPACE | ||
class LargeLabel; | ||
|
||
class accessDialog : public DDialog | ||
{ | ||
Q_OBJECT | ||
public: | ||
explicit accessDialog(const QString &app_id,const QString &parent_window,const QString &title,const QString &subtitle,const QString &body, const QVariantMap &options); | ||
~accessDialog(); | ||
private: | ||
QLabel *m_titleLabel; | ||
QLabel *m_subtitleLabel; | ||
QLabel *m_bodyLabel; | ||
}; | ||
|
||
#endif // XDG_DESKTOP_PORTAL_DDE_ACCESSDIALOG_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters