-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add deepin-web-screensaver subroutine. Support users to use custom web pages as screensavers. Log: Add web page screensaver options
- Loading branch information
Showing
31 changed files
with
1,419 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
TEMPLATE = subdirs | ||
SUBDIRS += \ | ||
saverpic \ | ||
deepin-custom-screensaver | ||
deepin-custom-screensaver \ | ||
deepin-web-screensaver |
181 changes: 181 additions & 0 deletions
181
customscreensaver/deepin-web-screensaver/data/deepin-screensaver-config.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions
5
customscreensaver/deepin-web-screensaver/data/deepin-web-screensaver.desktop
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,5 @@ | ||
[Desktop Entry] | ||
Type=Application | ||
Exec=/usr/lib/deepin-screensaver/modules/deepin-web-screensaver --config | ||
Terminal=false | ||
Name=deepin-web-screensaver-config |
17 changes: 17 additions & 0 deletions
17
customscreensaver/deepin-web-screensaver/data/org.deepin.webscreensaver.json
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,17 @@ | ||
{ | ||
"magic": "dsg.config.meta", | ||
"version": "1.0", | ||
"contents": { | ||
"slideshowPath": { | ||
"value": "", | ||
"serial": 0, | ||
"flags": ["global"], | ||
"name": "Web url", | ||
"name[zh_CN]": "网页地址", | ||
"description[zh_CN]":"自定义屏保网页地址", | ||
"description": "Custom screensaver web url", | ||
"permissions": "readwrite", | ||
"visibility": "public" | ||
} | ||
} | ||
} |
85 changes: 85 additions & 0 deletions
85
customscreensaver/deepin-web-screensaver/deepin-web-screensaver.pro
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,85 @@ | ||
#------------------------------------------------- | ||
# | ||
# Project created by QtCreator 2021-05-14T10:44:28 | ||
# | ||
#------------------------------------------------- | ||
|
||
QT += core gui dtkcore webenginewidgets network | ||
|
||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets | ||
|
||
TARGET = deepin-web-screensaver | ||
TEMPLATE = app | ||
|
||
# The following define makes your compiler emit warnings if you use | ||
# any feature of Qt which has been marked as deprecated (the exact warnings | ||
# depend on your compiler). Please consult the documentation of the | ||
# deprecated API in order to know how to port your code away from it. | ||
DEFINES += QT_DEPRECATED_WARNINGS | ||
|
||
# You can also make your code fail to compile if you use deprecated APIs. | ||
# In order to do so, uncomment the following line. | ||
# You can also select to disable deprecated APIs only up to a certain version of Qt. | ||
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 | ||
|
||
CONFIG += c++11 link_pkgconfig | ||
|
||
PKGCONFIG += x11 dtkwidget | ||
|
||
SOURCES += \ | ||
src/main.cpp \ | ||
src/slideshowscreensaver.cpp \ | ||
src/commandlinemanager.cpp \ | ||
src/slideshowconfig.cpp \ | ||
src/slideshowconfigdialog.cpp \ | ||
src/config/contenttitle.cpp \ | ||
src/config/selectpathwidget.cpp \ | ||
src/singleinstance.cpp | ||
|
||
HEADERS += \ | ||
src/slideshowscreensaver.h \ | ||
src/commandlinemanager.h \ | ||
src/slideshowconfig.h \ | ||
src/slideshowconfigdialog.h \ | ||
src/config/contenttitle.h \ | ||
src/config/selectpathwidget.h \ | ||
src/singleinstance.h | ||
|
||
|
||
#!! 放开注释来更新json配置文件所生成的ts文件 | ||
#DTK_SETTINGS = $${QT.dtkcore.tools}/dtk-settings | ||
#system($$DTK_SETTINGS -o deepin-custom-screensaver_translation.cpp $$PWD/data/deepin-custom-screensaver.json) | ||
#SOURCES += deepin-custom-screensaver_translation.cpp | ||
|
||
TRANSLATIONS += $$PWD/translations/$${TARGET}.ts \ | ||
$$PWD/translations/$${TARGET}_zh_CN.ts \ | ||
$$PWD/translations/$${TARGET}_zh_HK.ts \ | ||
|
||
CONFIG(release, debug|release) { | ||
!system($$PWD/generate_translations.sh): error("Failed to generate translation") | ||
} | ||
|
||
target.path = /usr/lib/deepin-screensaver/modules/ | ||
|
||
translations.path = /usr/share/$${TARGET}/translations | ||
translations.files = translations/*.qm | ||
|
||
desktop.path = /etc/deepin-screensaver/$${TARGET}/ | ||
desktop.files = data/deepin-web-screensaver.desktop | ||
|
||
icons.path = /usr/lib/deepin-screensaver/modules/cover/ | ||
icons.files = src/icons/*.jpg | ||
|
||
INSTALLS += target translations desktop icons | ||
|
||
# DConfig | ||
meta_file.files += \ | ||
$$PWD/data/org.deepin.webscreensaver.json | ||
meta_file.base = $$PWD/data | ||
meta_file.appid = org.deepin.screensaver | ||
|
||
DCONFIG_META_FILES += meta_file | ||
load(dtk_install_dconfig) | ||
|
||
RESOURCES += \ | ||
icon.qrc |
16 changes: 16 additions & 0 deletions
16
customscreensaver/deepin-web-screensaver/generate_translations.sh
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,16 @@ | ||
#!/bin/bash | ||
|
||
# SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. | ||
# | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
# this file is used to auto-generate .qm file from .ts file. | ||
# author: shibowen at linuxdeepin.com | ||
|
||
ts_list=(`ls translations/*.ts`) | ||
|
||
for ts in "${ts_list[@]}" | ||
do | ||
printf "\nprocess ${ts}\n" | ||
lrelease "${ts}" | ||
done |
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,5 @@ | ||
<RCC> | ||
<qresource prefix="/"> | ||
<file>data/deepin-screensaver-config.svg</file> | ||
</qresource> | ||
</RCC> |
66 changes: 66 additions & 0 deletions
66
customscreensaver/deepin-web-screensaver/src/commandlinemanager.cpp
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,66 @@ | ||
// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. | ||
// | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
#include "commandlinemanager.h" | ||
|
||
#include <QCommandLineOption> | ||
|
||
class CommandLineManagerGlobal : public CommandLineManager {}; | ||
Q_GLOBAL_STATIC(CommandLineManagerGlobal, commandLineManagerGlobal); | ||
|
||
CommandLineManager::CommandLineManager() | ||
: m_commandParser(new QCommandLineParser) | ||
{ | ||
// 必须设置为长选项模式,否则解析时 -window-id 将识别错误 | ||
m_commandParser->setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions); | ||
|
||
initOptions(); | ||
} | ||
|
||
CommandLineManager *CommandLineManager::instance() | ||
{ | ||
return commandLineManagerGlobal; | ||
} | ||
|
||
CommandLineManager::~CommandLineManager() | ||
{ | ||
|
||
} | ||
|
||
void CommandLineManager::initOptions() | ||
{ | ||
QCommandLineOption subWindowOption("window-id", "displays as a child of the given ID window.\nNOTE:is '-window-id',not '--window-id'", "ID"); | ||
QCommandLineOption pathOption(QStringList() << "p" << "path", "set the path of web page.", "PATH"); | ||
QCommandLineOption config(QStringList() << "config", "show config user Interface"); | ||
|
||
m_commandParser->addOption(subWindowOption); | ||
m_commandParser->addOption(pathOption); | ||
m_commandParser->addOption(config); | ||
} | ||
|
||
void CommandLineManager::process(const QStringList &arguments) | ||
{ | ||
m_commandParser->process(arguments); | ||
} | ||
|
||
bool CommandLineManager::isSet(const QString &name) const | ||
{ | ||
return m_commandParser->isSet(name); | ||
} | ||
|
||
QString CommandLineManager::value(const QString &name) const | ||
{ | ||
return m_commandParser->value(name); | ||
} | ||
|
||
QStringList CommandLineManager::positionalArguments() | ||
{ | ||
return m_commandParser->positionalArguments(); | ||
} | ||
|
||
QStringList CommandLineManager::unknownOptionNames() | ||
{ | ||
return m_commandParser->unknownOptionNames(); | ||
} | ||
|
41 changes: 41 additions & 0 deletions
41
customscreensaver/deepin-web-screensaver/src/commandlinemanager.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. | ||
// | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
#ifndef COMMANDLINEMANAGER_H | ||
#define COMMANDLINEMANAGER_H | ||
|
||
#include <QCommandLineOption> | ||
#include <QCommandLineParser> | ||
#include <QScopedPointer> | ||
|
||
class CommandLineManager | ||
{ | ||
public: | ||
static CommandLineManager *instance(); | ||
|
||
~CommandLineManager(); | ||
|
||
void process(const QStringList &arguments); | ||
|
||
bool isSet(const QString &name) const; | ||
QString value(const QString &name) const; | ||
|
||
QStringList positionalArguments(); | ||
QStringList unknownOptionNames(); | ||
|
||
protected: | ||
explicit CommandLineManager(); | ||
|
||
private: | ||
void initOptions(); | ||
|
||
private: | ||
CommandLineManager(CommandLineManager &) = delete; | ||
CommandLineManager &operator=(CommandLineManager &) = delete; | ||
|
||
private: | ||
QScopedPointer<QCommandLineParser> m_commandParser; | ||
}; | ||
|
||
#endif // COMMANDLINEMANAGER_H |
31 changes: 31 additions & 0 deletions
31
customscreensaver/deepin-web-screensaver/src/config/contenttitle.cpp
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,31 @@ | ||
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. | ||
// | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
#include "contenttitle.h" | ||
|
||
#include <QHBoxLayout> | ||
|
||
ContentTitle::ContentTitle(QWidget *parent) : QWidget(parent) | ||
{ | ||
auto layout = new QHBoxLayout(this); | ||
layout->setContentsMargins(0, 0, 0, 0); | ||
layout->setSpacing(10); | ||
|
||
titleLabel = new QLabel; | ||
layout->addWidget(titleLabel, 0, Qt::AlignLeft); | ||
|
||
auto lineLabel = new QLabel; | ||
layout->addWidget(lineLabel); | ||
lineLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); | ||
} | ||
|
||
QLabel *ContentTitle::label() const | ||
{ | ||
return titleLabel; | ||
} | ||
|
||
void ContentTitle::setTitle(const QString &title) | ||
{ | ||
titleLabel->setText(title); | ||
} |
25 changes: 25 additions & 0 deletions
25
customscreensaver/deepin-web-screensaver/src/config/contenttitle.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. | ||
// | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
#ifndef CONTENTTITLE_H | ||
#define CONTENTTITLE_H | ||
|
||
#include <QWidget> | ||
#include <QLabel> | ||
|
||
class ContentTitle : public QWidget | ||
{ | ||
Q_OBJECT | ||
public: | ||
explicit ContentTitle(QWidget *parent = nullptr); | ||
QLabel *label() const; | ||
|
||
public : | ||
void setTitle(const QString &title); | ||
|
||
protected: | ||
QLabel *titleLabel = nullptr; | ||
}; | ||
|
||
#endif // CONTENTTITLE_H |
48 changes: 48 additions & 0 deletions
48
customscreensaver/deepin-web-screensaver/src/config/selectpathwidget.cpp
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,48 @@ | ||
// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. | ||
// | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
#include "selectpathwidget.h" | ||
#include "../slideshowconfig.h" | ||
|
||
#include <DFileDialog> | ||
|
||
#include <QHBoxLayout> | ||
#include <QEvent> | ||
|
||
DWIDGET_USE_NAMESPACE | ||
DCORE_USE_NAMESPACE | ||
|
||
SelectPathWidget::SelectPathWidget(QWidget *parent) | ||
: DWidget(parent) | ||
{ | ||
initOption(); | ||
} | ||
|
||
QString SelectPathWidget::getPath() | ||
{ | ||
return m_selectLineEdit->text(); | ||
} | ||
|
||
void SelectPathWidget::initOption() | ||
{ | ||
QString valueText; | ||
// 路径转换 | ||
if (valueText.startsWith(QStringLiteral("~"))) | ||
valueText.replace(QStringLiteral("~"), QDir::homePath()); | ||
|
||
m_selectTips = new DLabel(tr("Enter web url"), this); | ||
m_selectLineEdit = new DLineEdit(this); | ||
m_selectBtn = new DPushButton(tr("apply"), this); | ||
m_selectBtn->setFocusPolicy(Qt::NoFocus); | ||
|
||
m_url = SlideshowConfig::instance()->slideshowPath(); | ||
m_selectLineEdit->setPlaceholderText(m_url); | ||
|
||
QHBoxLayout *layout = new QHBoxLayout(this); | ||
layout->addWidget(m_selectTips); | ||
layout->addWidget(m_selectLineEdit); | ||
layout->addWidget(m_selectBtn); | ||
|
||
connect(m_selectBtn, &DPushButton::clicked, this, &SelectPathWidget::requsetSetPath); | ||
} |
36 changes: 36 additions & 0 deletions
36
customscreensaver/deepin-web-screensaver/src/config/selectpathwidget.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd. | ||
// | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
#ifndef SELECTPATHWIDGET_H | ||
#define SELECTPATHWIDGET_H | ||
|
||
#include <DLabel> | ||
#include <DPushButton> | ||
#include <DWidget> | ||
#include <DSettingsOption> | ||
#include <DLineEdit> | ||
|
||
#include <QScopedPointer> | ||
|
||
class TruncateLineEdit; | ||
|
||
class SelectPathWidget : public Dtk::Widget::DWidget | ||
{ | ||
Q_OBJECT | ||
public: | ||
explicit SelectPathWidget(QWidget *parent = nullptr); | ||
QString getPath(); | ||
signals: | ||
void requsetSetPath(); | ||
|
||
private: | ||
void initOption(); | ||
private: | ||
Dtk::Widget::DLabel *m_selectTips = nullptr; | ||
Dtk::Widget::DLineEdit *m_selectLineEdit = nullptr; | ||
Dtk::Widget::DPushButton *m_selectBtn = nullptr; | ||
QString m_url; | ||
}; | ||
|
||
#endif // SELECTPATHWIDGET_H |
Binary file added
BIN
+6.09 KB
customscreensaver/deepin-web-screensaver/src/icons/deepin-web-screensaver.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.