Import Upstream version 3.1.4.0.0k0

This commit is contained in:
谢炜 2022-06-08 13:42:09 +08:00
commit 776de99075
195 changed files with 30172 additions and 0 deletions

4343
CJsonObject.cpp Normal file

File diff suppressed because it is too large Load Diff

235
CJsonObject.hpp Normal file
View File

@ -0,0 +1,235 @@
/*
* Copyright (C) 2020, Tianjin KYLIN Information Technology 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, 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 <http://www.gnu.org/licenses/&gt;.
*
*/
#ifndef CJSONOBJECT_HPP_
#define CJSONOBJECT_HPP_
#include <stdio.h>
#include <stddef.h>
#include <errno.h>
#include <malloc.h>
#include <limits.h>
#include <math.h>
#include <string>
#include <list>
#if __cplusplus < 201101L
#include <map>
#else
#include <unordered_map>
#endif
#ifdef __cplusplus
extern "C" {
#endif
#include "cJSON.h"
#ifdef __cplusplus
}
#endif
namespace neb
{
class CJsonObject
{
public: // method of ordinary json object or json array
CJsonObject();
CJsonObject(const std::string& strJson);
CJsonObject(const CJsonObject* pJsonObject);
CJsonObject(const CJsonObject& oJsonObject);
#if __cplusplus >= 201101L
CJsonObject(CJsonObject&& oJsonObject);
#endif
virtual ~CJsonObject();
CJsonObject& operator=(const CJsonObject& oJsonObject);
#if __cplusplus >= 201101L
CJsonObject& operator=(CJsonObject&& oJsonObject);
#endif
bool operator==(const CJsonObject& oJsonObject) const;
bool Parse(const std::string& strJson);
void Clear();
bool IsEmpty() const;
bool IsArray() const;
std::string ToString() const;
std::string ToFormattedString() const;
const std::string& GetErrMsg() const
{
return(m_strErrMsg);
}
public: // method of ordinary json object
bool AddEmptySubObject(const std::string& strKey);
bool AddEmptySubArray(const std::string& strKey);
bool GetKey(std::string& strKey);
void ResetTraversing();
CJsonObject& operator[](const std::string& strKey);
std::string operator()(const std::string& strKey) const;
bool KeyExist(const std::string& strKey) const;
bool Get(const std::string& strKey, CJsonObject& oJsonObject) const;
bool Get(const std::string& strKey, std::string& strValue) const;
bool Get(const std::string& strKey, int32& iValue) const;
bool Get(const std::string& strKey, uint32& uiValue) const;
bool Get(const std::string& strKey, int64& llValue) const;
bool Get(const std::string& strKey, uint64& ullValue) const;
bool Get(const std::string& strKey, bool& bValue) const;
bool Get(const std::string& strKey, float& fValue) const;
bool Get(const std::string& strKey, double& dValue) const;
int GetValueType(const std::string& strKey) const;
bool IsNull(const std::string& strKey) const;
bool Add(const std::string& strKey, const CJsonObject& oJsonObject);
#if __cplusplus < 201101L
bool AddWithMove(const std::string& strKey, CJsonObject& oJsonObject);
#else
bool Add(const std::string& strKey, CJsonObject&& oJsonObject);
#endif
bool Add(const std::string& strKey, const std::string& strValue);
bool Add(const std::string& strKey, int32 iValue);
bool Add(const std::string& strKey, uint32 uiValue);
bool Add(const std::string& strKey, int64 llValue);
bool Add(const std::string& strKey, uint64 ullValue);
bool Add(const std::string& strKey, bool bValue, bool bValueAgain);
bool Add(const std::string& strKey, float fValue);
bool Add(const std::string& strKey, double dValue);
bool AddNull(const std::string& strKey); // add null like this: "key":null
bool Delete(const std::string& strKey);
bool Replace(const std::string& strKey, const CJsonObject& oJsonObject);
#if __cplusplus < 201101L
bool ReplaceWithMove(const std::string& strKey, CJsonObject& oJsonObject);
#else
bool Replace(const std::string& strKey, CJsonObject&& oJsonObject);
#endif
bool Replace(const std::string& strKey, const std::string& strValue);
bool Replace(const std::string& strKey, int32 iValue);
bool Replace(const std::string& strKey, uint32 uiValue);
bool Replace(const std::string& strKey, int64 llValue);
bool Replace(const std::string& strKey, uint64 ullValue);
bool Replace(const std::string& strKey, bool bValue, bool bValueAgain);
bool Replace(const std::string& strKey, float fValue);
bool Replace(const std::string& strKey, double dValue);
bool ReplaceWithNull(const std::string& strKey); // replace value with null
#if __cplusplus < 201101L
bool ReplaceAdd(const std::string& strKey, const CJsonObject& oJsonObject);
bool ReplaceAdd(const std::string& strKey, const std::string& strValue);
template <typename T>
bool ReplaceAdd(const std::string& strKey, T value)
{
if (KeyExist(strKey))
{
return(Replace(strKey, value));
}
return(Add(strKey, value));
}
#else
template <typename T>
bool ReplaceAdd(const std::string& strKey, T&& value)
{
if (KeyExist(strKey))
{
return(Replace(strKey, std::forward<T>(value)));
}
return(Add(strKey, std::forward<T>(value)));
}
#endif
public: // method of json array
int GetArraySize() const;
CJsonObject& operator[](unsigned int uiWhich);
std::string operator()(unsigned int uiWhich) const;
bool Get(int iWhich, CJsonObject& oJsonObject) const;
bool Get(int iWhich, std::string& strValue) const;
bool Get(int iWhich, int32& iValue) const;
bool Get(int iWhich, uint32& uiValue) const;
bool Get(int iWhich, int64& llValue) const;
bool Get(int iWhich, uint64& ullValue) const;
bool Get(int iWhich, bool& bValue) const;
bool Get(int iWhich, float& fValue) const;
bool Get(int iWhich, double& dValue) const;
int GetValueType(int iWhich) const;
bool IsNull(int iWhich) const;
bool Add(const CJsonObject& oJsonObject);
#if __cplusplus < 201101L
bool AddWithMove(CJsonObject& oJsonObject);
#else
bool Add(CJsonObject&& oJsonObject);
#endif
bool Add(const std::string& strValue);
bool Add(int32 iValue);
bool Add(uint32 uiValue);
bool Add(int64 llValue);
bool Add(uint64 ullValue);
bool Add(int iAnywhere, bool bValue);
bool Add(float fValue);
bool Add(double dValue);
bool AddNull(); // add a null value
bool AddAsFirst(const CJsonObject& oJsonObject);
#if __cplusplus < 201101L
bool AddAsFirstWithMove(CJsonObject& oJsonObject);
#else
bool AddAsFirst(CJsonObject&& oJsonObject);
#endif
bool AddAsFirst(const std::string& strValue);
bool AddAsFirst(int32 iValue);
bool AddAsFirst(uint32 uiValue);
bool AddAsFirst(int64 llValue);
bool AddAsFirst(uint64 ullValue);
bool AddAsFirst(int iAnywhere, bool bValue);
bool AddAsFirst(float fValue);
bool AddAsFirst(double dValue);
bool AddNullAsFirst(); // add a null value
bool Delete(int iWhich);
bool Replace(int iWhich, const CJsonObject& oJsonObject);
#if __cplusplus < 201101L
bool ReplaceWithMove(int iWhich, CJsonObject& oJsonObject);
#else
bool Replace(int iWhich, CJsonObject&& oJsonObject);
#endif
bool Replace(int iWhich, const std::string& strValue);
bool Replace(int iWhich, int32 iValue);
bool Replace(int iWhich, uint32 uiValue);
bool Replace(int iWhich, int64 llValue);
bool Replace(int iWhich, uint64 ullValue);
bool Replace(int iWhich, bool bValue, bool bValueAgain);
bool Replace(int iWhich, float fValue);
bool Replace(int iWhich, double dValue);
bool ReplaceWithNull(int iWhich); // replace with a null value
private:
CJsonObject(cJSON* pJsonData);
private:
cJSON* m_pJsonData;
cJSON* m_pExternJsonDataRef;
cJSON* m_pKeyTravers;
const char* mc_pError;
std::string m_strErrMsg;
#if __cplusplus < 201101L
std::map<unsigned int, CJsonObject*> m_mapJsonArrayRef;
std::map<unsigned int, CJsonObject*>::iterator m_array_iter;
std::map<std::string, CJsonObject*> m_mapJsonObjectRef;
std::map<std::string, CJsonObject*>::iterator m_object_iter;
#else
std::unordered_map<unsigned int, CJsonObject*> m_mapJsonArrayRef;
std::unordered_map<std::string, CJsonObject*>::iterator m_object_iter;
std::unordered_map<std::string, CJsonObject*> m_mapJsonObjectRef;
std::unordered_map<unsigned int, CJsonObject*>::iterator m_array_iter;
#endif
};
}
#endif /* CJSONHELPER_HPP_ */

3
Clock.json Normal file
View File

@ -0,0 +1,3 @@
{
"Keys" : [ ]
}

44
ClockInterface.h Normal file
View File

@ -0,0 +1,44 @@
/*
* Copyright (C) 2020, Tianjin KYLIN Information Technology 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, 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 <http://www.gnu.org/licenses/&gt;.
*
*/
#ifndef CLOCKINTERFACE_H
#define CLOCKINTERFACE_H
#include <string>
#include <QString>
#define CLOCK_DBUS_SERVICE_NAME "org.kylin.dbus.ukuiclock"
#define CLOCK_DBUS_SERVICE_PATH "/org/kylin/dbus/ukuiclock"
#define CLOCK_DBUS_UPDATE_CLOCK_BY_ID_PATH "/org/kylin/dbus/ukuiclock/updateClockById"
#define CLOCK_DBUS_SELECT_CLOCK_BY_ID_PATH "/org/kylin/dbus/ukuiclock/selectClockById"
#define CLOCK_DBUS_DELETE_CLOCK_BY_ID_PATH "/org/kylin/dbus/ukuiclock/deleteClockById"
namespace clockInterface {
struct ReturnMsg{
unsigned status = 0;
QString msg;
};
struct RequestParams{
QString clockName;
unsigned hour = 0;
unsigned minute = 0;
};
enum STATUS_CODE{
SUCCESS = 0,
FAIL = 1,
};
}
#endif // CLOCKINTERFACE_H

144
CustomButton.cpp Normal file
View File

@ -0,0 +1,144 @@
#include "CustomButton.h"
#include <QDebug>
#include "theme.h"
CustomButton::CustomButton(QWidget *parent,int width, int height, int status) : QPushButton(parent),m_width(width),m_height(height),position(0),Status(status)
{
max = qMax(m_width,m_height);
min = m_width>m_height?m_height:m_width;
length = max - min;
init(status);
}
CustomButton::~CustomButton()
{
}
//开
void CustomButton::openSlot()
{
//滑动动画
animation1 = new QPropertyAnimation(myLabel, "geometry");
animation1->setDuration(100);
animation1->setKeyValueAt(0, QRect(2, 2, 20, 20));
animation1->setEndValue(QRect(31, 2, 20, 20));
animation1->start();
this->setStyleSheet(openBcack);
myLabel->setStyleSheet(openbtn);
Status = 1;
}
//关
void CustomButton::closeSlot()
{
animation1 = new QPropertyAnimation(myLabel, "geometry");
animation1->setDuration(100);
animation1->setKeyValueAt(0, QRect(31, 2, 20, 20));
animation1->setEndValue(QRect(2, 2, 20, 20));
animation1->start();
this->setStyleSheet(closeBcack);
myLabel->setStyleSheet(closeBtn);
Status = 0;
}
void CustomButton::colorUpdate()
{
switch(Status)
{
case 0:
this->setStyleSheet(closeBcack);
myLabel->setStyleSheet(closeBtn);
break;
case 1:
this->setStyleSheet(openBcack );
myLabel->setStyleSheet(openbtn);
break;
}
}
void CustomButton::init(int status)
{
this->resize(m_width,m_height);
myLabel = new QLabel(this);
myLabel->setObjectName("myLabel");
myLabel->resize(20,20);
this->setStyleSheet(openBcack);
myLabel->setStyleSheet(openbtn);
this->setFixedSize(m_width,m_height);
settingsStyle();
}
void CustomButton::initClose()
{
this->setStyleSheet(closeBcack);
myLabel->setStyleSheet(closeBtn);
Status = 0;
myLabel->move(2,2);
}
void CustomButton::initOpen()
{
Status = 1;
myLabel->move(31,2);
this->setStyleSheet(openBcack);
myLabel->setStyleSheet(openbtn);
}
/*
*
*/
void CustomButton::settingsStyle()
{
GsettingSubject * subject = GsettingSubject::getInstance();
connect(subject,&GsettingSubject::blackStyle, this,[=](){
this->blackStyle();
});
connect(subject,&GsettingSubject::whiteStyle, this,[=](){
this->whiteStyle();
});
subject->iniWidgetStyle();
}
QColor BACK_COLOR = QColor(220, 220, 220, 255);
//黑色主题
void CustomButton::blackStyle()
{
closeBcack = QString("CustomButton{background-color:rgba(240, 247, 255, 0.2);border-radius:%1px;}").arg(min/2);
QColor b1 = QColor(70, 70, 70, 255);
QString btnColor=theme::getColorStr(b1);
QColor btnHover=QColor(100, 100, 100, 255);
QString btnHoverColor=theme::getColorStr(btnHover);
closeBcack = QString("CustomButton{background-color:"+btnColor+";border-radius:%1px;}CustomButton:pressed{background-color:"+btnHoverColor+";}CustomButton:hover{background-color:"+btnHoverColor+";}").arg(min/2);
closeBtn = QString("#myLabel{background-color:rgba(235, 244, 255, 0.55);border-radius:%1px}").arg(20/2);
QColor deepHigh=theme::highLight_Hover();
QString deepHiColor=theme::getColorStr(deepHigh);
QColor h1 = this->palette().color(QPalette::Inactive,QPalette::Highlight);
QString hiColor=theme::getColorStr(h1);
openBcack = QString("CustomButton{background-color:"+hiColor+";border-radius:%1px;}CustomButton:pressed{background-color:"+deepHiColor+";}CustomButton:hover{background-color:"+deepHiColor+";}").arg(min/2);
openbtn = QString("#myLabel{background-color:rgba(255, 255, 255, 0.88);border-radius:%1px}").arg(20/2);
colorUpdate();
}
//白色主题
void CustomButton::whiteStyle()
{
closeBcack = QString("CustomButton{background-color:rgba(180, 195, 212, 1);border-radius:%1px;}").arg(min/2);
QString btnColor=theme::getColorStr(BACK_COLOR);
QColor btnClick=theme::button_Click();
QString btnClickColor=theme::getColorStr(btnClick);
closeBcack = QString("CustomButton{background-color:"+btnColor+";border-radius:%1px;}CustomButton:pressed{background-color:"+btnClickColor+";}CustomButton:hover{background-color:"+btnClickColor+";}").arg(min/2);
closeBtn = QString("#myLabel{background-color: rgb(240, 245, 250);border-radius:%1px}").arg(20/2);
QColor deepHigh=theme::highLight_Click();
QString deepHiColor=theme::getColorStr(deepHigh);
QColor h1 = this->palette().color(QPalette::Inactive,QPalette::Highlight);
QString hiColor=theme::getColorStr(h1);
openBcack = QString("CustomButton{background-color:"+hiColor+";border-radius:%1px;}CustomButton:pressed{background-color:"+deepHiColor+";}CustomButton:hover{background-color:"+deepHiColor+";}").arg(min/2);
openbtn = QString("#myLabel{background-color: rgba(255, 255, 255, 0.88);border-radius:%1px}").arg(20/2);
colorUpdate();
}

72
CustomButton.h Normal file
View File

@ -0,0 +1,72 @@
/*
* Copyright (C) 2020, Tianjin KYLIN Information Technology 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, 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 <http://www.gnu.org/licenses/&gt;.
*
*/
#ifndef CUSTOMBUTTON_H
#define CUSTOMBUTTON_H
#include <QLabel>
#include <QTimer>
#include <QMouseEvent>
#include <QStyleOption>
#include <QPainter>
#include <QGSettings>
#include <QPushButton>
#include <QPropertyAnimation>
#include "constant_class.h"
#include "gsettingsubject.h"
/**
* @brief
*/
class CustomButton : public QPushButton
{
Q_OBJECT
public:
explicit CustomButton(QWidget *parent = nullptr, int width=50, int height=24, int status = 1);
~CustomButton();
private:
QTimer timer;
int m_width;
int m_height;
int dir;
int position;
int max;
int min;
int length;
int Status;
QString closeBcack;
QString openBcack;
QString closeBtn;
QString openbtn;
QPropertyAnimation *animation1;
QPropertyAnimation *animation2;
public:
void init(int status);
void whiteStyle();
void blackStyle();
void settingsStyle();
void colorUpdate();
void openSlot();
void closeSlot();
void initOpen();
void initClose();
QLabel* myLabel;
};
#endif // CUSTOMBUTTON_H

1
README.md Normal file
View File

@ -0,0 +1 @@
闹钟项目

138
about.cpp Normal file
View File

@ -0,0 +1,138 @@
/*
* Copyright (C) 2020, Tianjin KYLIN Information Technology 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, 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 <http://www.gnu.org/licenses/&gt;.
*
*/
#include "about.h"
#include "ui_about.h"
#include <X11/Xlib.h>
#include "xatom-helper.h"
#include "configutil.h"
extern void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed);
About::About(QWidget *parent) :
QDialog(parent),
ui(new Ui::About)
{
ui->setupUi(this);
// 添加窗管协议
XAtomHelper::setStandardWindowHint(this->winId());
setWindowTitle(tr("About"));
//当小部件接受了关闭事件时使Qt删除此小部件请参阅QWidget :: closeEvent
setAttribute(Qt::WA_DeleteOnClose);
//左上角闹钟图标
ui->titleIcon->setPixmap(QIcon::fromTheme("kylin-alarm-clock").pixmap(24,24));
//右上角关闭X
ui->closeBtn->setIcon(QIcon::fromTheme("window-close-symbolic"));
ui->closeBtn->setProperty("isWindowButton", 0x2);
ui->closeBtn->setProperty("useIconHighlightEffect", 0x8);
//按钮边框是否凸起 默认false
ui->closeBtn->setFlat(true);
connect(ui->closeBtn, &QPushButton::clicked, this, [=](){
this->close();
});
//in order to use the same world in English
ui->titlename->setText(tr(CLOCK_TITLE_NAME));
//麒麟闹钟
ui->appnameLabel->setText(tr(KYLIN_CLOCK_APP_NAME));
ui->appnameLabel->setStyleSheet("QLabel{ font-size: 18px; color: palette(windowText);}"
"QLabel{font-family: NotoSansCJKsc-Medium, NotoSansCJKsc;}");
QString version = ConfigUtil().Get("common","version").toString();
ui->versionLabel->setText(tr("Version: ")+version);
settingsStyle();
//中间大图标
ui->appiconLabel->setPixmap(QIcon::fromTheme("kylin-alarm-clock").pixmap(96,96));
//介绍的超链接 url 时text里的a标签
connect(ui->introduceLabel, &QLabel::linkActivated, this, [=](const QString url){
QDesktopServices::openUrl(QUrl(url));
});
//该窗口小部件不具有上下文菜单,上下文菜单的处理将延迟到该窗口小部件的父级。
ui->introduceLabel->setContextMenuPolicy(Qt::NoContextMenu);
// 主题框架1.0.6-5kylin2
//关闭按钮去掉聚焦状态
ui->closeBtn->setFocusPolicy(Qt::NoFocus);
}
About::~About()
{
delete ui;
}
#define SYSTEM_FONT_EKY "system-font-size"
/*
*
*/
void About::settingsStyle()
{
GsettingSubject * subject = GsettingSubject::getInstance();;
connect(subject,&GsettingSubject::blackStyle, this,[=](){
this->blackStyle();
});
connect(subject,&GsettingSubject::whiteStyle, this,[=](){
this->whiteStyle();
});
connect(subject,&GsettingSubject::iconChnaged, this,[=](){
ui->titleIcon->setPixmap(QIcon::fromTheme("kylin-alarm-clock").pixmap(24,24));
ui->appiconLabel->setPixmap(QIcon::fromTheme("kylin-alarm-clock").pixmap(96,96));
});
connect(subject,&GsettingSubject::fontChanged, this,[=](int size){
this->CURRENT_FONT_SIZE=size;
this->updateLabelFront(ui->appnameLabel,round(size*1.63));
});
subject->iniWidgetStyle();
subject->iniFontSize();
}
void About::paintEvent(QPaintEvent *event) {
Q_UNUSED(event);
QPainter p(this);
p.setRenderHint(QPainter::Antialiasing); // 反锯齿;
//绘制器路径
QPainterPath rectPath;
rectPath.addRect(this->rect());
p.fillPath(rectPath,palette().color(QPalette::Base));
}
//黑色主题
void About::blackStyle()
{
ui->introduceLabel->setText(tr("Service & Support: ") +
"<a href=\"mailto://support@kylinos.cn\""
"style=\"color:white\">"
"support@kylinos.cn</a>");
}
//白色主题
void About::whiteStyle()
{
ui->introduceLabel->setText(tr("Service & Support: ") +
"<a href=\"mailto://support@kylinos.cn\""
"style=\"color:black\">"
"support@kylinos.cn</a>");
}
/**
* @brief
*/
void About::updateLabelFront(QLabel *label, int size)
{
QString styleSheet = "QLabel{ font-size: ";
styleSheet.append(QString::number(size)).append("px;");
styleSheet.append("color: palette(windowText);}""QLabel{font-family: NotoSansCJKsc-Medium, NotoSansCJKsc;}");
label->setStyleSheet(styleSheet);
}

62
about.h Normal file
View File

@ -0,0 +1,62 @@
/*
* Copyright (C) 2020, Tianjin KYLIN Information Technology 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, 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 <http://www.gnu.org/licenses/&gt;.
*
*/
#ifndef ABOUT_H
#define ABOUT_H
#include <QDialog>
#include <QPainter>
#include <QPainterPath>
#include <QDesktopServices>
#include <QUrl>
#include <QGSettings>
#include "constant_class.h"
#include <QLabel>
#include <math.h>
#include "gsettingsubject.h"
namespace Ui {
class About;
}
class About : public QDialog
{
Q_OBJECT
public:
explicit About(QWidget *parent = nullptr);
~About();
protected:
void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
private:
void settingsStyle(); //监听主题
void blackStyle(); //黑色主题
void whiteStyle(); //白色主题
void updateLabelFront(QLabel *label, int size);
int CURRENT_FONT_SIZE;
Ui::About *ui;
};
#endif // ABOUT_H

221
about.ui Normal file
View File

@ -0,0 +1,221 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>About</class>
<widget class="QDialog" name="About">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>420</width>
<height>334</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>5</number>
</property>
<property name="topMargin">
<number>5</number>
</property>
<property name="rightMargin">
<number>5</number>
</property>
<property name="bottomMargin">
<number>8</number>
</property>
<item>
<widget class="QLabel" name="titleIcon">
<property name="minimumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>5</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="titlename">
<property name="text">
<string>Alarm</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="closeBtn">
<property name="minimumSize">
<size>
<width>30</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>30</width>
<height>30</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="appiconLabel">
<property name="minimumSize">
<size>
<width>96</width>
<height>96</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>96</width>
<height>96</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>16</number>
</property>
<property name="topMargin">
<number>16</number>
</property>
<item>
<widget class="QLabel" name="appnameLabel">
<property name="text">
<string>Alarm</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="versionLabel">
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="introduceLabel">
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>12</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

103
adaptscreeninfo.cpp Normal file
View File

@ -0,0 +1,103 @@
/*
* Copyright (C) 2020, 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 <https://www.gnu.org/licenses/>.
*/
#include "adaptscreeninfo.h"
adaptScreenInfo::adaptScreenInfo(QObject *parent) : QObject(parent)
{
//返回桌面小部件(也称为根窗口)。
//桌面可能由多个屏幕组成,因此尝试在窗口的几何图形中居中某个窗口小部件是不正确的
m_pDeskWgt = QApplication::desktop();
//初始化主屏坐标
InitializeHomeScreenGeometry();
//初始化屏幕宽高
initScreenSize();
//当改变屏幕分辨率时 重新计算 主屏坐标 屏幕宽高
connect(QApplication::primaryScreen(), &QScreen::geometryChanged, this, &adaptScreenInfo::onResolutionChanged);
//主屏发生变化槽函数 重新计算 主屏坐标 屏幕宽高
connect(m_pDeskWgt, &QDesktopWidget::primaryScreenChanged, this, &adaptScreenInfo::primaryScreenChangedSlot);
//屏幕数量改变时 重新计算 主屏坐标 屏幕宽高
connect(m_pDeskWgt, &QDesktopWidget::screenCountChanged, this, &adaptScreenInfo::screenCountChangedSlots);
//屏幕list
m_pListScreen = QGuiApplication::screens();
}
/* 当屏幕数量发生改变时重新赋值m_pListScreen 未发现调用 */
void adaptScreenInfo::screenNumChange()
{
m_pListScreen = QGuiApplication::screens();
}
/* 初始化屏幕高度, 宽度 */
void adaptScreenInfo::initScreenSize()
{
QList<QScreen*> screen = QGuiApplication::screens();
int count = m_pDeskWgt->screenCount();
if (count > 1) {
m_screenWidth = screen[0]->geometry().width() + m_nScreen_x;
m_screenHeight = screen[0]->geometry().height() + m_nScreen_y;
} else {
m_screenWidth = m_pDeskWgt->width() + m_nScreen_x;
m_screenHeight = m_pDeskWgt->height() + m_nScreen_y;
}
qDebug() << "屏幕高度m_screenWidth" << m_screenWidth;
qDebug() << "屏幕宽度m_screenHeight" << m_screenHeight;
return;
}
/* 初始化主屏坐标 */
void adaptScreenInfo::InitializeHomeScreenGeometry()
{
QList<QScreen*> screen = QGuiApplication::screens();
int count = m_pDeskWgt->screenCount();
if (count > 1) {
m_nScreen_x = screen[0]->geometry().x();
m_nScreen_y = screen[0]->geometry().y();
} else {
m_nScreen_x = 0;
m_nScreen_y = 0;
}
qDebug() << "偏移的x坐标" << m_nScreen_x;
qDebug() << "偏移的Y坐标" << m_nScreen_y;
}
//当改变屏幕分辨率时重新获取屏幕分辨率
void adaptScreenInfo::onResolutionChanged(const QRect argc)
{
Q_UNUSED(argc);
initScreenSize(); //获取屏幕可用高度区域
InitializeHomeScreenGeometry();
return;
}
/* 主屏发生变化槽函数 */
void adaptScreenInfo::primaryScreenChangedSlot()
{
InitializeHomeScreenGeometry();
initScreenSize();
return;
}
/* 屏幕数量改变时对应槽函数 */
void adaptScreenInfo::screenCountChangedSlots(int count)
{
Q_UNUSED(count);
InitializeHomeScreenGeometry();
initScreenSize();
return;
}

59
adaptscreeninfo.h Normal file
View File

@ -0,0 +1,59 @@
/*
* Copyright (C) 2020, 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 <https://www.gnu.org/licenses/>.
*/
#ifndef ADAPTSCREENINFO_H
#define ADAPTSCREENINFO_H
#include <QObject>
#include <QGuiApplication>
#include <QScreen>
#include <QDebug>
#include <QDesktopWidget>
#include <QApplication>
#include <QRect>
class adaptScreenInfo : public QObject
{
Q_OBJECT
public:
explicit adaptScreenInfo(QObject *parent = nullptr);
void screenNumChange();
void InitializeHomeScreenGeometry();
QDesktopWidget *m_pDeskWgt; // 桌面问题
int m_screenWidth; // 桌面宽度
int m_screenHeight; // 桌面高度
int m_screenNum; // 屏幕数量
int m_nScreen_x; // 主屏起始坐标X
int m_nScreen_y; // 主屏起始坐标Y
signals:
private:
void initScreenSize();
private slots:
void primaryScreenChangedSlot();
void onResolutionChanged(const QRect argc);
void screenCountChangedSlots(int count);
private:
QList<QScreen *> m_pListScreen;
QStringList ScreenName;
};
#endif // ADAPTSCREENINFO_H

203
baseverticalscroll.cpp Normal file
View File

@ -0,0 +1,203 @@
/*
* Copyright (C) 2020, Tianjin KYLIN Information Technology 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, 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 <http://www.gnu.org/licenses/&gt;.
*
*/
#include "baseverticalscroll.h"
#include <QWheelEvent>
#include <QDebug>
#include <QThread>
#include <QStyleOption>
#include "theme.h"
BaseVerticalScroll::BaseVerticalScroll(int currentValue, int minRange, int maxRange, QWidget *parent) : QWidget(parent),
m_currentValue(currentValue),
m_minRange(minRange),
m_maxRange(maxRange),
isDragging(false),
m_deviation(0), //默认偏移量为0 // The default offset is 0
m_numSize(TIME_SCROLL_NUM_SIZE),
interval(1), //间隔默认1 // Interval default 1
devide(4) //默认分成4格 // Divided into 4 grids by default
{
m_priManager = new PrimaryManager();
settingsStyle();
}
void BaseVerticalScroll::setWheelSpeed(int wheelSpeed)
{
m_wheelSpeed = wheelSpeed;
}
void BaseVerticalScroll::settingsStyle()
{
subject = GsettingSubject::getInstance();
connect(subject,&GsettingSubject::mouseWheelChanged, this,[=](int speed){
if(m_priManager->checkWayland()){
this->setWheelSpeed(speed);
}
});
subject->iniMouseWheel();
}
void BaseVerticalScroll::homing()
{
if ( m_deviation > height() / 10) {
homingAni->setStartValue( ( height() - 1 ) / 8 - m_deviation);
homingAni->setEndValue(0);
m_currentValue = calculateCurrentValue(m_currentValue,-interval);
} else if ( m_deviation > -height() / 10 ) {
homingAni->setStartValue(m_deviation);
homingAni->setEndValue(0);
} else if ( m_deviation < -height() / 10 ) {
homingAni->setStartValue(-(height() - 1) / 8 - m_deviation);
homingAni->setEndValue(0);
m_currentValue = calculateCurrentValue(m_currentValue,interval);
}
emit currentValueChanged(m_currentValue);
homingAni->start();
}
int BaseVerticalScroll::calculateCurrentValue(int current,int offsetValue)
{
if ( current == m_minRange && offsetValue<0 ) {
current = m_maxRange+offsetValue+1;
} else if( current == m_maxRange && offsetValue>0 ) {
current = m_minRange+offsetValue-1;
}else{
current+=offsetValue;
}
return current;
}
void BaseVerticalScroll::paintNum(QPainter &painter, int num, int deviation)
{
int Width = width() - 1;
int Height = height() - 1;
int size = (Height - qAbs(deviation)) / (m_numSize*1.5); //偏移量越大,数字越小
//The larger the offset, the smaller the number
int transparency = Utils::handelColorRange(255 - 255 * qAbs(deviation) / Height);
int height = Height / devide;
int y = Height / 2 + deviation - height / 2;
QFont font;
font.setPixelSize(size);
painter.setFont(font);
painter.setPen(QColor(255,255,255,transparency));
QStyleOption opt;
opt.init(this);
//偏移量越大颜色越浅
if(theme::themetype==0)
{
painter.setPen(QColor(Utils::handelColorRange(34+(qAbs(deviation)*2)),
Utils::handelColorRange(34+(qAbs(deviation)*2)),
Utils::handelColorRange(34+(qAbs(deviation)*2)),transparency));
}else{
painter.setPen(QColor(Utils::handelColorRange(255-(qAbs(deviation)*2)),
Utils::handelColorRange(255-(qAbs(deviation)*2)),
Utils::handelColorRange(255-(qAbs(deviation)*2)),transparency));
}
QLinearGradient linearGradient(QPointF(5, 10), QPointF(7, 15));
linearGradient.setColorAt(0.2, Qt::white);
linearGradient.setColorAt(0.6, Qt::green);
linearGradient.setColorAt(1.0, Qt::black);
painter.setBrush(QBrush(linearGradient));
if ( y >= 0 && y + height < Height) {
painter.drawText(QRectF(0, y, Width, height),
Qt::AlignCenter,
change_NUM_to_str(num));
}
}
QString BaseVerticalScroll::change_NUM_to_str(int alarmHour)
{
QString str;
if (alarmHour < 10) {
QString hours_str = QString::number(alarmHour);
str = "0"+hours_str;
} else {
str = QString::number(alarmHour);
}
return str;
}
void BaseVerticalScroll::commonCalcValue(int height)
{
if ( m_deviation >= height / devide ) {
m_mouseSrcPos += height / devide;
m_deviation -= height / devide;
m_currentValue = calculateCurrentValue(m_currentValue,-interval);
}
if ( m_deviation <= -height / devide ) {
m_mouseSrcPos -= height / devide;
m_deviation += height / devide;
m_currentValue = calculateCurrentValue(m_currentValue,interval);
}
}
//鼠标滑轮滚动,数值滚动
// Mouse wheel scrolling, numerical scrolling
void BaseVerticalScroll::wheelEvent(QWheelEvent *event)
{
//wayland下没有初次进入触发两次wheelEvent问题
if(m_priManager->checkWayland()){
m_isFirstFocus=false;
}
if(m_isFirstFocus){
event->ignore();
m_isFirstFocus = false;
}else{
for (int i=0;i<m_wheelSpeed;i++) {
if (event->delta() > 0){
if (m_currentValue <= m_minRange)
m_currentValue = m_maxRange;
else
m_currentValue-=1;
} else {
if (m_currentValue >= m_maxRange)
m_currentValue = m_minRange;
else
m_currentValue+=1;
}
// update();
repaint();
QThread::msleep(20);
}
event->accept();
}
}
void BaseVerticalScroll::mouseMoveEvent(QMouseEvent *e)
{
if (isDragging) {
// if ( m_currentValue == m_minRange && e->pos().y() >= m_mouseSrcPos ) {
// m_currentValue = m_maxRange;
// } else if( m_currentValue == m_maxRange && e->pos().y() <= m_mouseSrcPos ) {
// m_currentValue = m_minRange;
// }
m_deviation = e->pos().y() - m_mouseSrcPos;
//若移动速度过快,则进行限制
// If the movement speed is too fast, limit it
if (m_deviation > (height() - 1) / devide) {
m_deviation = (height() - 1) / devide;
} else if (m_deviation < -(height() - 1) / devide) {
m_deviation = -( height() - 1) / devide;
}
emit deviationChange((int)m_deviation / ((height() - 1) / devide));
repaint();
}
}

66
baseverticalscroll.h Normal file
View File

@ -0,0 +1,66 @@
/*
* Copyright (C) 2020, Tianjin KYLIN Information Technology 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, 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 <http://www.gnu.org/licenses/&gt;.
*
*/
#ifndef BASEVERTICALSCROLL_H
#define BASEVERTICALSCROLL_H
#include <QWidget>
#include "gsettingsubject.h"
#include "primarymanager.h"
#include <QPropertyAnimation>
#include <QPainter>
class BaseVerticalScroll : public QWidget
{
Q_OBJECT
public:
explicit BaseVerticalScroll(int currentValue,int minRange,int maxRange,QWidget *parent = nullptr);
void setWheelSpeed(int wheelSpeed);
int m_currentValue=0;
int m_wheelSpeed = 1;
bool m_isFirstFocus = false;
int m_minRange=0; //最小值 // minimum value
int m_maxRange=0; //最大值 // Maximum
void settingsStyle();
GsettingSubject * subject;
PrimaryManager * m_priManager;
void homing();
int calculateCurrentValue(int current,int offsetValue);
void commonCalcValue(int height);
bool isDragging; //鼠标是否按下 // Muse down
int m_deviation; //偏移量,记录鼠标按下后移动的垂直距离 // Offset, record the vertical distance after mouse is pressed
int m_mouseSrcPos;
int m_numSize;
QPropertyAnimation *homingAni;
const int interval; //间隔大小 // Interval size
const int devide; //分隔数量 // Number of partitions
void paintNum(QPainter &painter, int num, int deviation);
QString change_NUM_to_str(int alarmHour);
signals:
void currentValueChanged(int value);
void deviationChange(int deviation);
protected:
void wheelEvent(QWheelEvent *) override;
void mouseMoveEvent(QMouseEvent *) override;
private:
};
#endif // BASEVERTICALSCROLL_H

121
btnNew.cpp Normal file
View File

@ -0,0 +1,121 @@
/*
* Copyright (C) 2020, Tianjin KYLIN Information Technology 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, 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 <http://www.gnu.org/licenses/&gt;.
*
*/
#include "btnNew.h"
#include <QVBoxLayout>
#include <QDebug>
#include "clock.h"
#include <QPainterPath>
#include "theme.h"
Btn_new::Btn_new(int num, QString name, Btn_new::BTN_NEW_TYPE btnType, QWidget *parent) :
QPushButton(parent),
clock_num(num),
m_btnType(btnType)
{
QPixmap pixmap = QPixmap(":/image/go-bottom-symbolic.png");
nameLabel = new QLabel(this);
textLabel = new QLabel(this);
IconLabel = new QLabel(this);
noName = new QLabel(this);
//num不同name与text的大小配比不同
int lineHeight = 22;
int lineMoveHeight = 13;
int nameWidth = 100;
int editWidth = 200;
nameLabel->setFixedSize(nameWidth-num, lineHeight);
textLabel->setFixedSize(editWidth+num, lineHeight);
IconLabel->setFixedSize(27, 36);
noName->setFixedSize(9, 36);
nameLabel->move(20, lineMoveHeight);
textLabel->move(nameWidth-num, lineMoveHeight);
noName->move(244, 0);
IconLabel->move(309, 6);
nameLabel->setText(name);
textLabel->setText(name);
IconLabel->setPixmap(pixmap);
textLabel->setAlignment(Qt::AlignRight | Qt::AlignCenter);
nameLabel->setStyleSheet("font-size:14px;");
textLabel->setStyleSheet("font-size:14px;");
this->resize(340,48);
QPalette palette;
palette.setColor(QPalette::ButtonText,QColor(148, 148, 148, 255));
textLabel->setPalette(palette);
clockNameLineEdit = new QLineEdit(this);
clockNameLineEdit->move(nameWidth-num, 0);
clockNameLineEdit->setFixedSize(editWidth+num, 48);
clockNameLineEdit->setContextMenuPolicy(Qt::NoContextMenu);
clockNameLineEdit->setAlignment(Qt::AlignRight);
if(m_btnType==SELECT_BTN){
textLabel->show();
IconLabel->show();
clockNameLineEdit->hide();
}else if(m_btnType==LINE_EDIT){
textLabel->hide();
IconLabel->hide();
clockNameLineEdit->show();
}
}
Btn_new::~Btn_new()
{
}
void Btn_new::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event);
QPainter p(this);
p.setRenderHint(QPainter::Antialiasing); // 反锯齿;
QPainterPath rectPath;
rectPath.addRoundedRect(this->rect(), 10, 10); // 左上右下
QPainter painter(this);
QStyleOption opt;
opt.init(this);
painter.setBrush(opt.palette.color(QPalette::Base));
QColor mainColor;
mainColor = theme::selectBtnBackColor;
p.fillPath(rectPath,QBrush(mainColor));
}
void Btn_new::updateWidthForFontChange(int px)
{
//调整一下,不然放大字体会遮挡
int wideth =nameLabel->size().width();
nameLabel->setFixedWidth(wideth+px);
}
/**
* @brief 1 0
* @param status
*/
void Btn_new::updateIconLabel(int status)
{
QPixmap pixmap ;
if(status==1){
pixmap = QPixmap(":/image/go-up-symbolic.png");
}else{
pixmap = QPixmap(":/image/go-bottom-symbolic.png");
}
IconLabel->setPixmap(pixmap);
IconLabel->update();
}

63
btnNew.h Normal file
View File

@ -0,0 +1,63 @@
/*
* Copyright (C) 2020, Tianjin KYLIN Information Technology 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, 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 <http://www.gnu.org/licenses/&gt;.
*
*/
#ifndef BTN_NEW_H
#define BTN_NEW_H
#include <QWidget>
#include <QToolButton>
#include <QLabel>
#include <QPushButton>
#include <QLineEdit>
namespace Ui {
class Btn_new;
}
class Clock;
class Btn_new : public QPushButton
{
Q_OBJECT
public:
enum BTN_NEW_TYPE{
LINE_EDIT=0,
SELECT_BTN=1
};
explicit Btn_new(int num, QString name ,BTN_NEW_TYPE btnType= SELECT_BTN,QWidget *parent = nullptr);
~Btn_new();
QLabel *nameLabel;
QLabel *textLabel;
QLabel *noName;
QLabel *IconLabel;
QLineEdit * clockNameLineEdit;
void paintEvent(QPaintEvent *event);
void updateWidthForFontChange(int px);
void updateIconLabel(int status);
private:
Ui::Btn_new *ui;
Clock * m_pclock;
int clock_num;
int pressflag;
BTN_NEW_TYPE m_btnType;
protected:
};
#endif // BTN_NEW_H

1101
cJSON.c Normal file

File diff suppressed because it is too large Load Diff

141
cJSON.h Normal file
View File

@ -0,0 +1,141 @@
/*
* Copyright (C) 2020, Tianjin KYLIN Information Technology 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, 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 <http://www.gnu.org/licenses/&gt;.
*
*/
#ifndef cJSON__h
#define cJSON__h
#include <stdint.h>
typedef int32_t int32;
typedef uint32_t uint32;
typedef int64_t int64;
typedef uint64_t uint64;
#ifdef __cplusplus
extern "C"
{
#endif
/* cJSON Types: */
#define cJSON_False 0
#define cJSON_True 1
#define cJSON_NULL 2
#define cJSON_Int 3
#define cJSON_Double 4
#define cJSON_String 5
#define cJSON_Array 6
#define cJSON_Object 7
#define cJSON_IsReference 256
/* The cJSON structure: */
typedef struct cJSON
{
struct cJSON *next, *prev; /* next/prev allow you to walk array/object chains. Alternatively, use GetArraySize/GetArrayItem/GetObjectItem */
struct cJSON *child; /* An array or object item will have a child pointer pointing to a chain of the items in the array/object. */
int type; /* The type of the item, as above. */
char *valuestring; /* The item's string, if type==cJSON_String */
int64 valueint; /* The item's number, if type==cJSON_Number */
double valuedouble; /* The item's number, if type==cJSON_Number */
int sign; /* sign of valueint, 1(unsigned), -1(signed) */
char *string; /* The item's name string, if this item is the child of, or is in the list of subitems of an object. */
} cJSON;
typedef struct cJSON_Hooks
{
void *(*malloc_fn)(size_t sz);
void (*free_fn)(void *ptr);
} cJSON_Hooks;
/* Supply malloc, realloc and free functions to cJSON */
extern void cJSON_InitHooks(cJSON_Hooks* hooks);
/* Supply a block of JSON, and this returns a cJSON object you can interrogate. Call cJSON_Delete when finished. */
extern cJSON *cJSON_Parse(const char *value, const char **ep);
/* Render a cJSON entity to text for transfer/storage. Free the char* when finished. */
extern char *cJSON_Print(cJSON *item);
/* Render a cJSON entity to text for transfer/storage without any formatting. Free the char* when finished. */
extern char *cJSON_PrintUnformatted(cJSON *item);
/* Delete a cJSON entity and all subentities. */
extern void cJSON_Delete(cJSON *c);
/* Returns the number of items in an array (or object). */
extern int cJSON_GetArraySize(cJSON *array);
/* Retrieve item number "item" from array "array". Returns NULL if unsuccessful. */
extern cJSON *cJSON_GetArrayItem(cJSON *array, int item);
/* Get item "string" from object. Case insensitive. */
extern cJSON *cJSON_GetObjectItem(cJSON *object, const char *string);
/* remove gloal variable for thread safe. --by Bwar on 2020-11-15 */
/* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */
/* extern const char *cJSON_GetErrorPtr(); */
/* These calls create a cJSON item of the appropriate type. */
extern cJSON *cJSON_CreateNull();
extern cJSON *cJSON_CreateTrue();
extern cJSON *cJSON_CreateFalse();
extern cJSON *cJSON_CreateBool(int b);
extern cJSON *cJSON_CreateDouble(double num, int sign);
extern cJSON *cJSON_CreateInt(uint64 num, int sign);
extern cJSON *cJSON_CreateString(const char *string);
extern cJSON *cJSON_CreateArray();
extern cJSON *cJSON_CreateObject();
/* These utilities create an Array of count items. */
extern cJSON *cJSON_CreateIntArray(int *numbers, int sign, int count);
extern cJSON *cJSON_CreateFloatArray(float *numbers, int count);
extern cJSON *cJSON_CreateDoubleArray(double *numbers, int count);
extern cJSON *cJSON_CreateStringArray(const char **strings, int count);
/* Append item to the specified array/object. */
extern void cJSON_AddItemToArray(cJSON *array, cJSON *item);
extern void cJSON_AddItemToArrayHead(cJSON *array, cJSON *item); /* add by Bwar on 2015-01-28 */
extern void cJSON_AddItemToObject(cJSON *object, const char *string,
cJSON *item);
/* Append reference to item to the specified array/object. Use this when you want to add an existing cJSON to a new cJSON, but don't want to corrupt your existing cJSON. */
extern void cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item);
extern void cJSON_AddItemReferenceToObject(cJSON *object, const char *string,
cJSON *item);
/* Remove/Detatch items from Arrays/Objects. */
extern cJSON *cJSON_DetachItemFromArray(cJSON *array, int which);
extern void cJSON_DeleteItemFromArray(cJSON *array, int which);
extern cJSON *cJSON_DetachItemFromObject(cJSON *object, const char *string);
extern void cJSON_DeleteItemFromObject(cJSON *object, const char *string);
/* Update array items. */
extern void cJSON_ReplaceItemInArray(cJSON *array, int which, cJSON *newitem);
extern void cJSON_ReplaceItemInObject(cJSON *object, const char *string,
cJSON *newitem);
#define cJSON_AddNullToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateNull())
#define cJSON_AddTrueToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateTrue())
#define cJSON_AddFalseToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateFalse())
#define cJSON_AddNumberToObject(object,name,n) cJSON_AddItemToObject(object, name, cJSON_CreateNumber(n))
#define cJSON_AddStringToObject(object,name,s) cJSON_AddItemToObject(object, name, cJSON_CreateString(s))
#ifdef __cplusplus
}
#endif
#endif

35
clickableLabel.cpp Normal file
View File

@ -0,0 +1,35 @@
/*
* Copyright (C) 2019 Tianjin KYLIN Information Technology 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, 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 <http://www.gnu.org/licenses/&gt;.
*
*/
#include "clickableLabel.h"
#include <QDebug>
ClickableLabel::ClickableLabel( QWidget* parent)
: QLabel(parent)
{
}
ClickableLabel::~ClickableLabel()
{
}
//鼠标事件
//Mouse events
void ClickableLabel::mousePressEvent(QMouseEvent* event)
{
emit clicked();
}

37
clickableLabel.h Normal file
View File

@ -0,0 +1,37 @@
/*
* Copyright (C) 2019 Tianjin KYLIN Information Technology 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, 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 <http://www.gnu.org/licenses/&gt;.
*
*/
//避免重复加载,循环引用
#ifndef CLICKABLELABEL_H
#define CLICKABLELABEL_H
#include <QLabel>
class ClickableLabel : public QLabel
{
Q_OBJECT
public:
explicit ClickableLabel( QWidget* parent=0 );
~ClickableLabel();
signals:
void clicked();
protected:
//鼠标事件
//Mouse events
void mousePressEvent(QMouseEvent* event);};
#endif // CLICKABLELABEL_H

3674
clock.cpp Normal file

File diff suppressed because it is too large Load Diff

516
clock.h Normal file
View File

@ -0,0 +1,516 @@
/*
* Copyright (C) 2019 Tianjin KYLIN Information Technology 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, 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 <http://www.gnu.org/licenses/&gt;.
*
*/
#ifndef CLOCK_H
#define CLOCK_H
#include <QPainterPath>
#include <QWidget>
#include <QTimer>
#include <QTime>
#include <QQueue>
#include <QSlider>
#include <QVBoxLayout>
#include <QPushButton>
#include <QPainter>
#include <QMouseEvent>
#include <QLCDNumber>
#include <QMediaPlayer>
#include <QFrame>
#include <itemNew.h>
#include <QListWidgetItem>
#include <QPaintEvent>
#include <QPointF>
#include <QLineEdit>
#include <QPropertyAnimation>
#include <QCloseEvent>
#include <QMenu>
#include <QFontDatabase>
#include <math.h>
#include <QTimerEvent>
#include <QDialog>
#include <QSpinBox>
#include <QComboBox>
#include <QLabel>
#include <QPixmap>
#include <QMatrix>
#include <QFont>
#include <QMediaPlaylist>
#include <QUrl>
#include <QMessageBox>
#include <QSqlTableModel>
#include <QSqlRecord>
#include <QModelIndex>
#include <QSqlQuery>
#include <QFile>
#include <QFileDialog>
#include <QFileInfo>
#include <QDebug>
#include <unistd.h>
#include <QMessageBox>
#include <QBitmap>
#include <QProcess>
#include <QScreen>
#include <QScroller>
#include <QTranslator>
#include <QDesktopWidget>
#include <QGraphicsOpacityEffect>
#include <QDBusInterface>
#include <QToolTip>
#include<QMediaPlayer>
#include <QList>
#include <QMap>
#include "stopwatchItem.h"
#include "verticalScroll24.h"
#include "verticalScroll60.h"
#include "verticalScroll99.h"
#include "dotlineDemo.h"
#include "setAlarmRepeatDialog.h"
#include "adaptscreeninfo.h"
#include "about.h"
#include "debug.h"
#include "connection.h"
#include "noticeAlarm.h"
#include "ui_noticeAlarm.h"
#include "deleteMsg.h"
#include "ui_deleteMsg.h"
#include "selectbtn.h"
#include "closeOrHide.h"
#include "constant_class.h"
#include "utils.h"
#include "primarymanager.h"
#include "tinycountdown.h"
#include "theme.h"
#include <QHash>
#include "ClockInterface.h"
#include <string>
#include "CJsonObject.hpp"
#include "commontooltip.h"
#include "btnNew.h"
#include "selectbtnutil.h"
#include <QPointer>
#include <QSystemTrayIcon>
class QDialog;
class QSpinBox;
class QComboBox;
class QLabel;
class QFont;
class QPushButton;
class QMediaPlaylist;
class QSqlTableModel;
class SelectBtn;
class close_or_hide;
namespace Ui {
class Clock;
}
class Clock : public QWidget
{
Q_OBJECT
public:
explicit Clock(QWidget *parent = nullptr);
~Clock();
void paintEvent(QPaintEvent *event) override;
void keyPressEvent(QKeyEvent * event) override;
void callUserGuide();
bool eventFilter(QObject *watched, QEvent *event) override;
void showPaint();
void showPaint7();
void updateLabelFront(QLabel * label,int size); //修改label字体
void updateQLineEditFront(QLineEdit * lineEdit,int size); //修改QLineEdit字体
void updateAlarmItemFront(int size); //修改闹钟子项字体
void updateStopwatchItemFront(int size); //修改秒表子项字体
int CURRENT_FONT_SIZE=11;
enum ScreenPosition {
SP_LEFT = 1,
SP_CENTER = 2,
SP_RIGHT=3,
UP_LEFT=4,
UP_CENTER=5,
UP_RIGHT=6
};
enum btnType{
count_down=1,
add_clock=2
};
void moveUnderMultiScreen(Clock::ScreenPosition,QWidget * dialog,int hiddenFlag); //多显示器下,位置移动
QString formatX_h(int x_h);
Ui::Clock *ui;
QString m_timeZone;
QSqlTableModel *model_setup;
QString addAlarm(clockInterface::RequestParams param);
QString addAlarmJosn(QString param);
QString updateClockByIdJosn(QString param);
QString selectClockByIdJosn(QString param);
QString deleteClockByIdJosn(QString param);
protected:
void paintEvent1(QPaintEvent *);
void closeEvent(QCloseEvent *event) override;
public slots:
void CountdownPageSwitch(); // 倒计时切换
// Countdown switch
void AlarmPageSwitch(); // 闹钟窗口切换
// Alarm window switching
void StopwatchPageSwitch(); // 秒表窗口切换
// Stopwatch window switc
void settingsStyle(); // 监听主题
void blackStyle(); // 黑色主题
void whiteStyle(); // 白色主题
void updateTinyBtn();
void drawNoAlarmPrompt(); // 绘制无闹钟提示
// Draw no alarm prompt
private slots:
void buttonImageInit(); // 闹钟按钮图片初始化
// Alarm button picture initialization
void CountdownInit(); // 倒计时页初始化
// Countdown page initialization
void stopwatchInit(); // 秒表页初始化
// Stopwatch page initialization
void clockInit(); // 闹钟页初始化
// Alarm page initialization
void setupInit(); // 默认初始设置
void bellIni();
// Default initial settings
void noticeDialogShow(int, int,QString id); // 通知弹窗
// Notification Popup
void modelSetupSet(); // 默认设置数据库数据初始化
// Default setting database data initialization
void CountDown(); // 秒表执行
// Stopwatch execution
void onPushbuttonStartClicked(); // 秒表开始暂停继续
// Stopwatch start pause continue
void onPushbuttonRingClicked(); // 计次
void updateLongestShortLabel();
// times count
void onPushbuttonTimeselectClicked(); // 位
// reset
void windowClosingClicked(); // 窗口关闭
// window closing
void windowMinimizingClicked(); // 窗口最小化
void muteAllBell();
// window minimizing
void timerUpdate(); // 动态监控闹钟与本地时间
// Dynamic monitoring alarm clock and local time
void textTimerupdate(); // 闹钟上方电子表
// Electronic watch above alarm clock
void setAlarmClock(); // 新建闹钟按钮回调
void setMusicSelectDialogListById(QString bellId,QListWidget * temp);
void setRemindLateSelectDialogListByName(QString name,QListWidget * temp);
int getRemindStatusByName(QString name);
// New alarm button callback
void updateAlarmClock(); // 重绘窗口,更新闹钟
// Redraw window, update alarm clock
void OnOffAlarm(); // 闹钟开关
// Alarm switch
void deleteAlarm(); // 闹钟重编辑页面删除闹钟回调
void deleteAlarmDatabase(QString id);
void updateClockDatabase(QString id,QString name,QString hour,QString minute,int onOff);
// Alarm re edit page delete alarm callback
void listdoubleClickslot(); // 双击闹钟打开重编辑页面
QString getClockPkByCurrentNum();
QSqlQuery getClockByPK(QString id);
// Double click the alarm clock to open the re edit page
void stopwatchStartAnimation(); // 倒计时开始动画移动
// Countdown start animation move
void stopwatchStopAnimation(); // 倒计时结束动画移动
// Countdown start animation move
void statCountdown(); // 倒计时执行
void statCountdownMsec();
// Countdown execution
void setcoutdownNumber(int h, int m, int s); // 设置倒计时初始时间
// Set the initial countdown time
void startbtnCountdown(); // 倒计时开始-结束回调
void tinyCountdownFinish();
// Countdown start end callback
void onMin_5btnClicked(); // 倒计时5分钟设置回调
// Countdown 5 minutes set callback
void getCountdownOverTime(); // 获取倒计时结束时间
// Get countdown end time
void onCountPushClicked(); // 倒计时-暂停继续回调
// Countdown - pause resume callback
void stopwatchJg(); // 时间间隔计算执行回调
// Interval calculation execution callback
void changeTimeNum(int Hour, int Minute); // 修改时间单数 为两位数
// Modify time singular to two digits
void countdownSetStartTime(); // 倒计时初始数字转盘
// Countdown initial digital dial
void alarmSetStartTime(); // 闹钟初始化数字转盘绘制
// Alarm clock initialization digital turntable drawing
void alarmCancelSave(); // 闹钟新建界面取消回调
// Cancel callback in alarm new interface
void setAlarmSave(); // 闹钟新建界面保存回调
void saveClockToDatabase(int rowNum);
QString getSelectBellId(set_alarm_repeat_Dialog * tempDialog);
QString addAlarm(QString clockName,int hour,int minute); // 闹钟新建界面保存回调
QString formatReturnMsg(neb::CJsonObject oJson,clockInterface::STATUS_CODE status,std::string msg);
QString formatReturnMsg(clockInterface::STATUS_CODE status,std::string msg);
// Alarm new interface save callback
// Alarm clock new and re edit interface remaining time real-time display callback
void alarmRepeat(); // 闹钟初始化工作日选择界面绘制回调
// Alarm clock initialization workday selection interface drawing callback
void repeatListclickslot(); // 重复选项单击回调
// Repeat option click callback
void selectAlarmMusic(); // 闹钟初始化音乐选择界面回调
void refreshMusicSelectList(set_alarm_repeat_Dialog * tempDialog);
void selectRemindLate();
// Alarm clock initialization music selection interface callback
void musicListclickslot(); // 闹钟初始化单击选择音乐
void remindLateListClickSlot();
QString getRemindLateStrFromNum(int num);
// Alarm initialization Click to select music
// Alarm clock initialization music time selection interface callback
// Click to select music duration callback
// Set page draw callback
// Mute switch callback
// Set volume callback
void countdownMusicSellect(); // 倒计时音乐选择
// Countdown music selection
void countMusicListclickslot(); // 倒计时音乐选择单机回调
void playMusicFromPath(QString path);
void stopHisPlay();
void addDivBell(set_alarm_repeat_Dialog *tempDialog,btnType type);
// Countdown music selection single callback
void countdownNoticeDialogShow(); // 倒计时通知弹窗
// Countdown notification pop-up
void offAlarm(int); // 重复时单独关闭闹钟
// Turn off the alarm separately if it is not repeated
// Calculate the next alarm ring interval
// Calculate the next alarm ring interval
QString changeNumToStr(int alarmHour); // 整型转字符
// Integer to character
void onCustomContextMenuRequested(const QPoint &pos); // 闹钟右键删除事件处理函数
void countStatBtnGray();
QString get12hourStr(int x_h);
void createUserGuideDebusClient();
void onTinyClicked();
void activeWindow();
private:
QPoint m_startPoint;
QTimer *timer = nullptr;
QTimer *countdown_timer = nullptr;
QTimer *timer_2 = nullptr;
int hour, minute, second, pushflag;
int stopwatch_hour, stopwatch_minute, stopwatch_second;
int countdown_hour, countdown_minute, countdown_second, countdown_pushflag;
int countdown_msec=1000;
int alarmHour;
int alarmMinute;
int cPauseTime;
bool isStarted;
/**
* @brief
*/
bool countdown_isStarted;
bool countdown_isStarted_2;
bool stopwatch_isStarted;
QMediaPlayer *player;
QString ring;// 铃声名字
// Ring name
QPixmap pixmap1;
QPixmap pixmap2;
QPixmap pixmap3;
QPixmap pixmap4;
QPixmap pixmap5;
QPixmap pixmap6;
QPixmap pixmap7;
QPixmap pixmap8;
QPixmap pixmap9;
QPixmap pixmap10;
QPixmap pixmap11;
QPixmap bgPixmap;
QPixmap repeat_on_Pixmap;
QPixmap repeat_off_Pixmap;
QPixmap hourPixmap;
QPixmap minutePixmap;
QPixmap secondPixmap;
QPixmap delBtnPixmap;
QPixmap on_pixmap;
QPixmap off_pixmap;
QPixmap clock_icon;
QDialog *dialog;
QFont alarmFont;
QSpinBox *hourBox;
QSpinBox *minuteBox;
QComboBox *pauseTime;
QMediaPlayer *player_alarm;
QMediaPlaylist *mediaList; /*播放列表
playlist*/
QSqlTableModel *model; /*数据库
data base*/
QSqlTableModel *model_Stopwatch;
QString musicPath;
item_new *w1[20];
QListWidgetItem *aItem[20];
stopwatch_item *stopwatch_w[100];
QListWidgetItem *stopwatch_aItem[100];
QString stopwatch_h;
QString stopwatch_m;
QString stopwatch_s;
QString stopwatch_jg_h = "00";
QString stopwatch_jg_m = "00";
QString stopwatch_jg_s = "00";
QString alarmHour_str;
QString alarmMinute_str;
int stopwatch_item_flag = 0;
int clock_num = 0;
int on_off_flag = 0;
int add_change_flag = 0;
int change_alarm_line = 0;
int medel_flag = 0;
int continu_flag = 0;
int alarm_repeat_flag = 0;
int repeat_day[9]; /*重复日选择保存中介
Select and save mediation for duplicate days*/
int repeat_new_or_edit_flag; /*重复日判断 是新建,还是重编辑,两者获取数据库号不同;
Whether to create or re edit the duplicate day is determined. The database numbers obtained by the two methods are different*/
int stopwatch_Animation = 0;
int system_time_flag;
int last_day_ring = 0;
VerticalScroll_99 *hourTimerRing;
VerticalScroll_60 *minuteTimeRing;
VerticalScroll_60 *secondTimeRing;
VerticalScroll_24 *timer_alarm_start24;
VerticalScroll_60 *timer_alarm_start60;
set_alarm_repeat_Dialog *dialog_repeat = nullptr;
set_alarm_repeat_Dialog *dialog_music = nullptr;
set_alarm_repeat_Dialog *dialog_remind_late = nullptr;
QSqlTableModel * m_bellQueryModel = nullptr;
// set_alarm_repeat_Dialog *time_music = nullptr;
set_alarm_repeat_Dialog *count_music_sellect = nullptr;
close_or_hide *close_or_hide_page;
adaptScreenInfo *m_pSreenInfo = nullptr;
PrimaryManager * primaryManager = nullptr;
Utils *utils = nullptr;
QWidget *grand = nullptr;
QString repeat_str;
QString repeat_str_model;
QString remind_late_str_model;
// QString time_music_str_model;
QString clock_name;
QPropertyAnimation *animation1;
QPropertyAnimation *animation2;
QPropertyAnimation *animation3;
QPushButton *startCountSingle;
QWidget *shadow;
QPoint m_dragPosition; /*拖动坐标*/
bool mousePressed; /*鼠标是否按下*/
Btn_new *musicSelectOnCountdownSet;
Btn_new *musicSelectOnCountdownRun;
Btn_new *repeatSelectOnClockNew;
Btn_new *clockEditOnClockNew;
Btn_new *musicSelectOnClockNew;
Btn_new *remindSelectOnClockNew;
// Btn_new *ring_sel;
QMenu *m_menu; /*功能菜单*/
QMenu *popMenu_In_ListWidget_; /*闹钟右键删除菜单*/
QAction *action_Delete_In_ListWidget_;
QAction *action_Clear_In_ListWidget_; /*闹钟右键删除动作*/
QAction *action_edit_In_ListWidget_; /*闹钟右键删除动作*/
Natice_alarm *countdownNoticeDialog = nullptr;
Natice_alarm *alarmNoticeDialog = nullptr;
QDBusInterface *userGuideInterface; // 用户手册
bool refreshCountdownLabel11Flag = false; //是否刷新倒计时上的小闹钟时间的数值。因为秒数的变化如果一直动态计算会出现1分钟的误差
int x_h=0, x_m=0 ;
bool m_selectTinyCountdown = false;
tinyCountdown * tinycountdownDia = nullptr;
void listenToGsettings(); //监听
void updateFront(const int size);
void set24ClockItem(int time_H,int time_M,int time_S,int rowNum);
void set12ClockItem(int time_H,int time_M,int time_S,int rowNum);
void clearClockItem(int rowNum);
void iniSystemTimeFlag();
bool checkSystem24();
void muteBtnStyle();
void minBtnStyle();
void closeBtnStyle();
void menuBtnStyle();
bool checkTinyCountdownDia();
void navigationBtnStyle(QPushButton * btn);
theme * currentTheme;
QHash<int,QString> * indexWeekdayMap = nullptr;
CommonToolTip * m_commonToolTip;
int m_commonToolTipRemainTime = 3;
bool m_muteOn = false;
bool onEditPage = false;
QTimer * m_commonToolTipCloseTimer;
QMap<long,int> * timeSepOrderIndex = nullptr;
QList<int> * hisLongShortIndex = nullptr;
SelectBtnUtil * m_selectBtnUtil = nullptr;
QMediaPlayer *music = nullptr;
void updateClockSelectBtnStyle(SelectBtn * temp,int moveHeight);
void updateCountdownSelectBtnStyle(SelectBtn * temp,int moveWidth,int moveHeight);
void updateClockSelectBtnStyle(Btn_new * temp,int moveHeight);
void updateCountdownSelectBtnStyle(Btn_new * temp,int moveWidth,int moveHeight);
void updateClockSelectBtnLabel(QLabel * temp,int moveHeight,QString text);
void widgetListWhiteStyle(QListWidget * listWidget);
void widgetListBlackStyle(QListWidget * listWidget);
QMediaPlayer * hisPlayer = nullptr;
void updateSwitchBtnStyle();
void setSwitchDefaultColor(QPushButton *btn);
QColor getButtonActive();
QColor getHighlightActive();
void setDefaultIcon(QPushButton *btn);
void setBtnIcon(QPushButton *btn, QString imgUrl, QString localUrl);
void changeIconHeight(QPushButton *btn);
void setSwitchHighlightColor(QPushButton *btn);
QString getDefaultGreyColor();
void updateRepeatStr(QLabel *label);
void updateLabelTextByLength(QLabel *label, int limitSize);
void closeHandel();
QPointer<QSystemTrayIcon> m_trayIcon;
QString m_trayIconTooltip = "";
void enableTrayIcon();
void disableTrayIcon();
QString changeNumToStrWithAm(int alarmHour);
void updateTrayIconTooltip(QString info);
void setDefaultTrayIconTooltip();
};
#endif // CLOCK_H

BIN
clock.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

1
clock.rc Normal file
View File

@ -0,0 +1 @@
IDI_ICON1 ICON DISCARDABLE "clock.ico"

775
clock.ui Normal file
View File

@ -0,0 +1,775 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Clock</class>
<widget class="QWidget" name="Clock">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>390</width>
<height>580</height>
</rect>
</property>
<property name="windowTitle">
<string>Alarm</string>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<item>
<widget class="QWidget" name="titileWidget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>8</number>
</property>
<property name="leftMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="titleIcon">
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="clockTitleLabel">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Alarm</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="muteBtn">
<property name="minimumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="menuBtn">
<property name="minimumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="minmizeBtn">
<property name="minimumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="closeTitleBtn">
<property name="minimumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="switchWidget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="switchClock">
<property name="minimumSize">
<size>
<width>40</width>
<height>40</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>40</width>
<height>40</height>
</size>
</property>
<property name="text">
<string>Alarm</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>26</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="switchCountdown">
<property name="minimumSize">
<size>
<width>40</width>
<height>40</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>40</width>
<height>40</height>
</size>
</property>
<property name="text">
<string>Count down</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>26</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="switchStopwatch">
<property name="minimumSize">
<size>
<width>40</width>
<height>40</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>40</width>
<height>40</height>
</size>
</property>
<property name="text">
<string>Watch</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QStackedWidget" name="mainWidget">
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="countdownPage">
<widget class="QStackedWidget" name="countdownStackedW">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>390</width>
<height>477</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="countdownSetPage"/>
<widget class="Countdown_Animation" name="countdownRunPage">
<widget class="QWidget" name="tinyWidget" native="true">
<property name="geometry">
<rect>
<x>0</x>
<y>180</y>
<width>371</width>
<height>40</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QPushButton" name="tinyWindowBtn">
<property name="minimumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string/>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="timeWidget" native="true">
<property name="geometry">
<rect>
<x>10</x>
<y>100</y>
<width>361</width>
<height>77</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item alignment="Qt::AlignHCenter|Qt::AlignVCenter">
<widget class="QLabel" name="remainTime">
<property name="styleSheet">
<string notr="true">font-size:40px;</string>
</property>
<property name="text">
<string>00:00:00</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="alarmWidget" native="true">
<property name="geometry">
<rect>
<x>10</x>
<y>40</y>
<width>361</width>
<height>70</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<spacer name="horizontalSpacer_7">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="countdownAlarmIcon">
<property name="minimumSize">
<size>
<width>13</width>
<height>16</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>26</width>
<height>26</height>
</size>
</property>
<property name="text">
<string>icon</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="countdownAlarmTime">
<property name="font">
<font>
<pointsize>-1</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(176, 176, 176);
font-size:18px;
</string>
</property>
<property name="text">
<string>PM</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_8">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="btnWidget" native="true">
<property name="geometry">
<rect>
<x>9</x>
<y>386</y>
<width>361</width>
<height>48</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QPushButton" name="startCountdownBtn">
<property name="minimumSize">
<size>
<width>120</width>
<height>34</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>120</width>
<height>16777215</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>start</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="suspendCountdownBtn">
<property name="minimumSize">
<size>
<width>120</width>
<height>34</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>120</width>
<height>16777215</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>suspend</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</widget>
</widget>
<widget class="QWidget" name="alarmPage">
<widget class="QPushButton" name="addAlarmBtn">
<property name="geometry">
<rect>
<x>135</x>
<y>401</y>
<width>120</width>
<height>34</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>120</width>
<height>0</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>add</string>
</property>
</widget>
<widget class="QListWidget" name="alarmListWidget">
<property name="geometry">
<rect>
<x>25</x>
<y>0</y>
<width>340</width>
<height>354</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
</widget>
<widget class="QLabel" name="noAlarmIcon">
<property name="geometry">
<rect>
<x>115</x>
<y>76</y>
<width>149</width>
<height>170</height>
</rect>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="noAlarm">
<property name="geometry">
<rect>
<x>125</x>
<y>262</y>
<width>140</width>
<height>31</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">color: rgba(49, 66, 89, 0.6);
font-size:16px;</string>
</property>
<property name="text">
<string>no alarm</string>
</property>
</widget>
<zorder>noAlarm</zorder>
<zorder>noAlarmIcon</zorder>
<zorder>addAlarmBtn</zorder>
<zorder>alarmListWidget</zorder>
</widget>
<widget class="QWidget" name="stopwatchPage">
<widget class="QPushButton" name="startStopwatch">
<property name="geometry">
<rect>
<x>210</x>
<y>401</y>
<width>120</width>
<height>34</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>120</width>
<height>0</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>start</string>
</property>
</widget>
<widget class="QLabel" name="timeShowSmall">
<property name="geometry">
<rect>
<x>90</x>
<y>55</y>
<width>210</width>
<height>41</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(176, 176, 176);
font: 19pt
</string>
</property>
<property name="text">
<string>00:00:00</string>
</property>
</widget>
<widget class="QLabel" name="timeShowBig">
<property name="geometry">
<rect>
<x>90</x>
<y>0</y>
<width>210</width>
<height>70</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">font: 30pt </string>
</property>
<property name="text">
<string>00:00:00</string>
</property>
</widget>
<widget class="QPushButton" name="ringBtn">
<property name="geometry">
<rect>
<x>65</x>
<y>401</y>
<width>120</width>
<height>34</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>120</width>
<height>0</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>count</string>
</property>
</widget>
<widget class="QListWidget" name="timeListWidget">
<property name="geometry">
<rect>
<x>25</x>
<y>109</y>
<width>340</width>
<height>277</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
</widget>
</widget>
<widget class="QWidget" name="addAlarmPage">
<widget class="QWidget" name="editAlarmPage" native="true">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>390</width>
<height>477</height>
</rect>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<widget class="QPushButton" name="cancelbtnOnEditAlarm">
<property name="geometry">
<rect>
<x>65</x>
<y>425</y>
<width>120</width>
<height>34</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>120</width>
<height>0</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>cancel</string>
</property>
</widget>
<widget class="QPushButton" name="saveBtnOnEditAlarm">
<property name="geometry">
<rect>
<x>210</x>
<y>425</y>
<width>120</width>
<height>34</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>120</width>
<height>0</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>save</string>
</property>
</widget>
<widget class="QLabel" name="timeFormatOnTimeWheel">
<property name="geometry">
<rect>
<x>60</x>
<y>80</y>
<width>41</width>
<height>22</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string/>
</property>
</widget>
</widget>
</widget>
</widget>
</item>
</layout>
<action name="actionOn">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset>
<normaloff>:/Images/Images/NO.png</normaloff>:/Images/Images/NO.png</iconset>
</property>
<property name="text">
<string>On</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
<customwidget>
<class>Countdown_Animation</class>
<extends>QWidget</extends>
<header>countdownAnimation.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

2
clock_conf.ini Normal file
View File

@ -0,0 +1,2 @@
[common]
version=3.1.4.0-0k0

41
clockdbusadaptor.cpp Normal file
View File

@ -0,0 +1,41 @@
/*
* Copyright (C) 2020, Tianjin KYLIN Information Technology 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, 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 <http://www.gnu.org/licenses/&gt;.
*
*/
#include "clockdbusadaptor.h"
#include <QDBusArgument>
ClockDbusAdaptor::ClockDbusAdaptor(QObject *parent, Clock *currentClock) : QDBusAbstractAdaptor(parent),
m_clock(currentClock)
{
}
ClockDbusAdaptor::~ClockDbusAdaptor()
{
}
QString ClockDbusAdaptor::addAlarmRpc(QString param)
{
return m_clock->addAlarmJosn(param);
}

39
clockdbusadaptor.h Normal file
View File

@ -0,0 +1,39 @@
/*
* Copyright (C) 2020, Tianjin KYLIN Information Technology 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, 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 <http://www.gnu.org/licenses/&gt;.
*
*/
#ifndef CLOCKDBUSADAPTOR_H
#define CLOCKDBUSADAPTOR_H
#include <QObject>
#include <QDBusAbstractAdaptor>
#include "clock.h"
class ClockDbusAdaptor : public QDBusAbstractAdaptor
{
Q_OBJECT
//声明它正在导出哪个接口
Q_CLASSINFO("D-Bus Interface", CLOCK_DBUS_SERVICE_NAME)
public:
explicit ClockDbusAdaptor(QObject *parent = nullptr,Clock * currentClock = nullptr);
~ClockDbusAdaptor();
signals:
public slots:
QString addAlarmRpc(QString param);
private:
Clock * m_clock;
};
#endif // CLOCKDBUSADAPTOR_H

41
clockentitydao.cpp Normal file
View File

@ -0,0 +1,41 @@
/*
* Copyright (C) 2020, Tianjin KYLIN Information Technology 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, 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 <http://www.gnu.org/licenses/&gt;.
*
*/
#include "clockentitydao.h"
#include "fieldvalidutil.h"
ClockEntityDao::ClockEntityDao(QObject *parent) : QObject(parent)
{
}
QSqlQuery ClockEntityDao::getClockByPK(QString id)
{
auto sqlQuery = clock_sql::getQSqlQuery();
sqlQuery.prepare("select * from clock where id=:id");
sqlQuery.bindValue(":id",id);
sqlQuery.exec();
sqlQuery.next();
return sqlQuery;
}
bool ClockEntityDao::checkClockExist(QString id)
{
auto sqlQuery = getClockByPK(id);
QString queryId = sqlQuery.value(14).toString();
return FieldValidUtil::isNotNull(queryId);
}

35
clockentitydao.h Normal file
View File

@ -0,0 +1,35 @@
/*
* Copyright (C) 2020, Tianjin KYLIN Information Technology 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, 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 <http://www.gnu.org/licenses/&gt;.
*
*/
#ifndef CLOCKENTITYDAO_H
#define CLOCKENTITYDAO_H
#include <QObject>
#include "connection.h"
class ClockEntityDao : public QObject
{
Q_OBJECT
public:
explicit ClockEntityDao(QObject *parent = nullptr);
static QSqlQuery getClockByPK(QString id);
static bool checkClockExist(QString id);
signals:
};
#endif // CLOCKENTITYDAO_H

136
closeOrHide.cpp Normal file
View File

@ -0,0 +1,136 @@
/*
* Copyright (C) 2020, Tianjin KYLIN Information Technology 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, 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 <http://www.gnu.org/licenses/&gt;.
*
*/
#include "closeOrHide.h"
#include "ui_closeOrHide.h"
#include "QDebug"
#include <X11/Xlib.h>
#include "xatom-helper.h"
#include "constant_class.h"
extern void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed);
close_or_hide::close_or_hide(QWidget *parent) :
QDialog(parent),
ui(new Ui::close_or_hide)
{
ui->setupUi(this);
// this->setProperty("blurRegion", QRegion(QRect(1, 1, 1, 1)));
// setAttribute(Qt::WA_TranslucentBackground);
// this->setWindowFlags(Qt::FramelessWindowHint | Qt::Dialog);
ui->backrunRadio->setChecked(1);
// 添加窗管协议
XAtomHelper::setStandardWindowHint(this->winId());
XAtomHelper::setStandardWindowRadius(this->winId(),WINDOWN_RADIUS);
ui->closeInfoLabel->setText(tr("Please select the state after closing:"));
ui->closeInfoLabel->setWordWrap(true);
ui->closeInfoLabel->setAlignment(Qt::AlignTop);
//调色板
QPalette palette = ui->surebtn->palette();
palette.setColor(QPalette::Button,QColor(61,107,229,255));
palette.setBrush(QPalette::ButtonText, QBrush(Qt::white));
//保留按钮
ui->surebtn->setPalette(palette);
//退出按钮
QPalette palette1 = ui->closebtn->palette();
QColor ColorPlaceholderText1(255,255,255,0);
QBrush brush;
brush.setColor(ColorPlaceholderText1);
palette.setBrush(QPalette::Button, brush);
ui->closebtn->setPalette(palette1);
ui->closebtn->setIcon(QIcon::fromTheme("window-close-symbolic"));
ui->closebtn->setProperty("isWindowButton", 0x2);
ui->closebtn->setProperty("useIconHighlightEffect", 0x8);
ui->closebtn->setFlat(true);
// 主题框架1.0.6-5kylin2
//配置重要按钮
ui->surebtn->setProperty("isImportant", true);
ui->cancelbtn->setProperty("useButtonPalette", true);
//关闭按钮去掉聚焦状态
ui->closebtn->setFocusPolicy(Qt::NoFocus);
}
close_or_hide::~close_or_hide()
{
delete ui;
}
void close_or_hide::on_closebtn_clicked()
{
this->hide();
close_flag = 0;
}
void close_or_hide::on_surebtn_clicked()
{
if(ui->backrunRadio->isChecked()==true){
this->hide();
close_flag = 1;
}else{
this->hide();
close_flag = 2;
}
}
void close_or_hide::on_cancelbtn_clicked()
{
this->hide();
}
void close_or_hide::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event);
QPainter p(this);
p.setRenderHint(QPainter::Antialiasing); // 反锯齿;
QPainterPath rectPath;
rectPath.addRect(this->rect());
p.fillPath(rectPath,palette().color(QPalette::Base));
}
void close_or_hide::mousePressEvent(QMouseEvent *event)
{
if (event->button() == Qt::LeftButton) {
this->dragPosition = event->globalPos() - frameGeometry().topLeft();
this->mousePressed = true;
}
QWidget::mousePressEvent(event);
}
void close_or_hide::mouseReleaseEvent(QMouseEvent *event)
{
if (event->button() == Qt::LeftButton) {
this->mousePressed = false;
this->setCursor(Qt::ArrowCursor);
}
QWidget::mouseReleaseEvent(event);
}
void close_or_hide::mouseMoveEvent(QMouseEvent *event)
{
if (this->mousePressed) {
move(event->globalPos() - this->dragPosition);
this->setCursor(Qt::ClosedHandCursor);
}
QWidget::mouseMoveEvent(event);
}

62
closeOrHide.h Normal file
View File

@ -0,0 +1,62 @@
/*
* Copyright (C) 2020, Tianjin KYLIN Information Technology 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, 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 <http://www.gnu.org/licenses/&gt;.
*
*/
#ifndef CLOSE_OR_HIDE_H
#define CLOSE_OR_HIDE_H
#include <QDialog>
#include <QStyleOption>
#include <QPainter>
#include <QPainterPath>
#include <QMouseEvent>
#include <QGSettings/qgsettings.h>
namespace Ui {
class close_or_hide;
}
class Clock;
class close_or_hide : public QDialog
{
Q_OBJECT
public:
explicit close_or_hide(QWidget *parent = nullptr);
~close_or_hide();
//绘制底部阴影
// Draw bottom shadow
void paintEvent(QPaintEvent *event);
void mousePressEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
int close_flag;
private slots:
void on_closebtn_clicked();
void on_surebtn_clicked();
void on_cancelbtn_clicked();
private:
Ui::close_or_hide *ui;
QPoint dragPosition; //拖动坐标
bool mousePressed; //鼠标是否按下
};
#endif // CLOSE_OR_HIDE_H

419
closeOrHide.ui Normal file
View File

@ -0,0 +1,419 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>close_or_hide</class>
<widget class="QDialog" name="close_or_hide">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>350</width>
<height>174</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<widget class="QWidget" name="widget" native="true">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>350</width>
<height>174</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<widget class="QWidget" name="verticalLayoutWidget">
<property name="geometry">
<rect>
<x>310</x>
<y>0</y>
<width>40</width>
<height>36</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="leftMargin">
<number>5</number>
</property>
<property name="topMargin">
<number>5</number>
</property>
<property name="rightMargin">
<number>5</number>
</property>
<item>
<widget class="QPushButton" name="closebtn">
<property name="minimumSize">
<size>
<width>30</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>30</width>
<height>30</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="verticalLayoutWidget_2">
<property name="geometry">
<rect>
<x>0</x>
<y>60</y>
<width>351</width>
<height>40</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>57</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QRadioButton" name="backrunRadio">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string> backstage</string>
</property>
<property name="iconSize">
<size>
<width>14</width>
<height>14</height>
</size>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QRadioButton" name="exitRadio">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>120</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>120</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string> Exit program </string>
</property>
<property name="iconSize">
<size>
<width>14</width>
<height>14</height>
</size>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>80</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="widget_2" native="true">
<property name="geometry">
<rect>
<x>0</x>
<y>120</y>
<width>351</width>
<height>31</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>156</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="cancelbtn">
<property name="minimumSize">
<size>
<width>80</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>80</width>
<height>30</height>
</size>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>cancel</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>10</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="surebtn">
<property name="minimumSize">
<size>
<width>80</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>80</width>
<height>30</height>
</size>
</property>
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>sure</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>24</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="widget_3" native="true">
<property name="geometry">
<rect>
<x>0</x>
<y>20</y>
<width>351</width>
<height>41</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<spacer name="horizontalSpacer_7">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>24</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item alignment="Qt::AlignVCenter">
<widget class="QLabel" name="questionIconLabel">
<property name="minimumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">border-image: url(:/image/warning-24x24.png);</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item alignment="Qt::AlignVCenter">
<widget class="QLabel" name="closeInfoLabel">
<property name="font">
<font>
<pointsize>11</pointsize>
</font>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>请选择关闭后的状态</string>
</property>
<property name="margin">
<number>0</number>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</widget>
<resources/>
<connections/>
</ui>

78
commontooltip.cpp Normal file
View File

@ -0,0 +1,78 @@
/*
* Copyright (C) 2020, Tianjin KYLIN Information Technology 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, 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 <http://www.gnu.org/licenses/&gt;.
*
*/
#include "commontooltip.h"
#include <QBitmap>
#include <QPainter>
#include "theme.h"
#include <QVBoxLayout>
CommonToolTip::CommonToolTip(QWidget *parent) : QDialog(parent)
{
this->setAttribute(Qt::WA_TranslucentBackground);//设置窗口背景透明
this->setWindowFlags(Qt::FramelessWindowHint|Qt::ToolTip); //设置无边框窗口
setRoundStyle();
setMsgLabelStyle();
}
void CommonToolTip::setMsgText(QString msg)
{
m_msgLabel->setText(msg);
}
void CommonToolTip::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event);
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing); // 反锯齿;
//底色
painter.setBrush(theme::backcolcr);
painter.setPen(theme::boderColor);
QRect rect = this->rect();
rect.setWidth(rect.width() - 1);
rect.setHeight(rect.height() - 1);
//圆角
painter.drawRoundedRect(rect, 6, 6);
QWidget::paintEvent(event);
}
void CommonToolTip::setRoundStyle()
{
//圆角
QBitmap bmp(this->size());
bmp.fill();
QPainter p(&bmp);
p.setRenderHint(QPainter::Antialiasing); // 反锯齿;
p.setPen(Qt::NoPen);
p.setBrush(palette().color(QPalette::Base));
p.drawRoundedRect(bmp.rect(),6,6);
setMask(bmp);
}
void CommonToolTip::setMsgLabelStyle()
{
QSize size = QSize(50,32);
this->setMinimumSize(size);
QVBoxLayout *mainvbox=new QVBoxLayout(this);
this->setLayout(mainvbox);
m_msgLabel = new QLabel(this);
m_msgLabel->setMinimumSize(size);
mainvbox->addWidget(m_msgLabel);
}

43
commontooltip.h Normal file
View File

@ -0,0 +1,43 @@
/*
* Copyright (C) 2020, Tianjin KYLIN Information Technology 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, 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 <http://www.gnu.org/licenses/&gt;.
*
*/
#ifndef COMMONTOOLTIP_H
#define COMMONTOOLTIP_H
#include <QWidget>
#include <QLabel>
#include <QDialog>
class CommonToolTip : public QDialog
{
Q_OBJECT
public:
explicit CommonToolTip(QWidget *parent = nullptr);
void setMsgText(QString msg);
protected:
void paintEvent(QPaintEvent * event) override;
void setRoundStyle();
void setMsgLabelStyle();
signals:
private:
QLabel * m_msgLabel;
};
#endif // COMMONTOOLTIP_H

43
configutil.cpp Normal file
View File

@ -0,0 +1,43 @@
/*
* Copyright (C) 2020, Tianjin KYLIN Information Technology 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, 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 <http://www.gnu.org/licenses/&gt;.
*
*/
#include "configutil.h"
#include <QtCore/QtCore>
#include <QDebug>
ConfigUtil::ConfigUtil(QString qstrfilename, QObject *parent) : QObject(parent),m_qstrFileName(qstrfilename)
{
if (qstrfilename.isEmpty()){
// m_qstrFileName = QStandardPaths::writableLocation(QStandardPaths::HomeLocation) +"/.config/ukui-clock/clock_conf.ini";
m_qstrFileName = ":/clock_conf.ini";
}else{
m_qstrFileName = qstrfilename;
}
m_psetting = new QSettings(m_qstrFileName, QSettings::IniFormat);
qDebug() << m_qstrFileName;
}
void ConfigUtil::Set(QString qstrnodename,QString qstrkeyname,QVariant qvarvalue)
{
m_psetting->setValue(QString("/%1/%2").arg(qstrnodename).arg(qstrkeyname), qvarvalue);
}
QVariant ConfigUtil::Get(QString qstrnodename,QString qstrkeyname)
{
QVariant qvar = m_psetting->value(QString("/%1/%2").arg(qstrnodename).arg(qstrkeyname));
return qvar;
}

42
configutil.h Normal file
View File

@ -0,0 +1,42 @@
/*
* Copyright (C) 2020, Tianjin KYLIN Information Technology 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, 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 <http://www.gnu.org/licenses/&gt;.
*
*/
#ifndef CONFIGUTIL_H
#define CONFIGUTIL_H
#include <QObject>
#include <QVariant>
#include <QSettings>
class ConfigUtil : public QObject
{
Q_OBJECT
public:
explicit ConfigUtil(QString qstrfilename = "",QObject *parent = nullptr);
void Set(QString,QString,QVariant);
QVariant Get(QString,QString);
signals:
private:
QString m_qstrFileName;
QSettings *m_psetting;
};
#endif // CONFIGUTIL_H

85
connection.h Normal file
View File

@ -0,0 +1,85 @@
/*
* Copyright (C) 2019 Tianjin KYLIN Information Technology 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, 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 <http://www.gnu.org/licenses/&gt;.
*
*/
#ifndef CONNECTION_H
#define CONNECTION_H
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QStandardPaths>
#include <QDebug>
#include <QSqlTableModel>
#include <QLocale>
//创建或打开数据库
//Create or open database
namespace clock_sql {
static QSqlDatabase db;
static bool createConnection()
{
QString lan = QLocale().name();
QString url_filepath = QStandardPaths::writableLocation(QStandardPaths::HomeLocation) +"/.config/Clock_database_"+lan+"_sp2.db";
//SQLite是一款轻量级的开源的嵌入式数据库
db = QSqlDatabase::addDatabase("QSQLITE");
db.setDatabaseName(url_filepath);
if(!db.open()) return false;
//建表语句
QSqlQuery query;
query.exec(QString(
"create table clock (hour int, minute int, bell_id QString, on_or_off int, num int, repeat Qstring,"
"monday int, tuesday int, wednesday int, thursday int, friday int, saturday int , sunday int, "
"name Qstring, id Qstring,remind_status Qstring)"));
query.clear();
query.exec(QString("create table setup (mute_on int, bell_id QString)"));
query.clear();
query.exec(QString("create table bell (id QString, bell_cn QString,bell_en QString,"
"bell_path QString,create_time int,bell_type int)"));
return true;
}
static QSqlQuery getQSqlQuery(){
QSqlQuery query(db);
query.clear();
return query;
}
static QSqlTableModel * getTableByName(QObject *parent,QString name){
QSqlDatabase db = QSqlDatabase::database();
QSqlTableModel * model = new QSqlTableModel(parent,db);
model->setTable(name);
model->setEditStrategy(QSqlTableModel::OnManualSubmit);
model->select();
return model;
}
static QSqlTableModel * getClockTable(QObject *parent){
QSqlTableModel * model = getTableByName(parent,"clock");
return model;
}
static QSqlTableModel * getSetupTable(QObject *parent){
QSqlTableModel * model = getTableByName(parent,"setup");
return model;
}
static QSqlTableModel * getBellTable(QObject *parent){
QSqlTableModel * model = getTableByName(parent,"bell");
return model;
}
}
#endif // CONNECTION_H

61
constant_class.h Normal file
View File

@ -0,0 +1,61 @@
/*
* Copyright (C) 2020, Tianjin KYLIN Information Technology 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, 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 <http://www.gnu.org/licenses/&gt;.
*
*/
#ifndef CONSTANTCLASS_H
#define CONSTANTCLASS_H
#include <QDebug>
#include "utils.h"
//声明一些必须的宏
#define ORG_UKUI_STYLE "org.ukui.style"
#define STYLE_NAME "styleName"
#define STYLE_NAME_KEY_DARK "ukui-dark"
#define STYLE_NAME_KEY_DEFAULT "ukui-default"
#define STYLE_NAME_KEY_BLACK "ukui-black"
#define STYLE_NAME_KEY_LIGHT "ukui-light"
#define STYLE_NAME_KEY_WHITE "ukui-white"
#define STYLE_ICON "icon-theme-name"
#define STYLE_ICON_NAME "iconThemeName"
#define TIME_SEPARATOR ":"
#define TIME_SEPARATOR_CN ""
#define APPLICATION_NAME "ukui-clock"
#define CLOCK_TITLE_NAME "Alarm"
#define KYLIN_CLOCK_APP_NAME "Alarm"
const static QString chooseColor = "61,107,229,255";
const static QString hoverColor = "55,144,250,255";
#define SYSTEM_FONT_EKY "system-font-size"
/*!
*
*/
#define FORMAT_SCHEMA "org.ukui.control-center.panel.plugins"
#define TIME_FORMAT_KEY "hoursystem"
#define SYSTEM_FONT_SIZE "systemFontSize"
#define HOUR_SYSTEM "hoursystem"
#define DEFAULT_BELL_SAVE_PATH "/usr/share/ukui-clock/"
#define DIY_BELL_SAVE_PATH "/kylindata/ukui-clock/"
#define WHEEL_KEY_HW "wheel-speed"
#define WHEEL_KEY_SP "wheelSpeed"
#define MOUSE_SCHEMA "org.ukui.peripherals-mouse"
const static int TIME_SCROLL_NUM_SIZE = 3;
const static int ITEM_RADIUS=6;
const static int WINDOWN_RADIUS=12;
const static int SELECT_DIA_RADIUS=8;
const static int SELECT_ITEM_RADIUS=6;
const static int COUNTDOWN_TIME=6;
#endif // CONSTANTCLASS_H

327
coreplayer/mmediaplayer.cpp Normal file
View File

@ -0,0 +1,327 @@
/*
* Copyright (C) 2022 Tianjin KYLIN Information Technology 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, 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 <http://www.gnu.org/licenses/&gt;.
*
*/
#include "mmediaplayer.h"
#include <QDBusMessage>
#include <QDBusConnection>
#include <ukui-log4qt.h>
MMediaPlayer::MMediaPlayer(QObject *parent)
: QObject(parent)
{
createMvpplayer();
}
void MMediaPlayer::setPlaylist(MMediaPlaylist *playlist)
{
//异常情况:空指针
if (playlist == nullptr) {
return;
}
m_playList = playlist;
connect(this,&MMediaPlayer::playFinish,m_playList,&MMediaPlaylist::palyFinish,Qt::UniqueConnection);
connect(this,&MMediaPlayer::playError,m_playList,&MMediaPlaylist::playError,Qt::UniqueConnection);
connect(m_playList,&MMediaPlaylist::autoPlay,this,&MMediaPlayer::autoPlay,Qt::UniqueConnection);
connect(m_playList,&MMediaPlaylist::stop,this,&MMediaPlayer::stop,Qt::UniqueConnection);
connect(this,&MMediaPlayer::playErrorMsg,m_playList,&MMediaPlaylist::playErrorMsg,Qt::UniqueConnection);
}
void MMediaPlayer::truePlay(QString startTime)
{
//异常情况:入参不合法
if (startTime.isEmpty()) {
return;
}
//异常情况:播放列表空指针
if (m_playList == nullptr) {
return;
}
QString filePath = m_playList->getPlayFileName();
//异常情况:本地文件不存在
if (!QFileInfo::exists(QUrl(filePath).toLocalFile())) {
Q_EMIT playErrorMsg(NotFound);
Q_EMIT playError();
return;
}
const QByteArray c_filename = filePath.toUtf8();
//如果文件名和上次一样,且不是因为拖动进度条播放,说明上次是暂停
if (c_filename == filenameBack && m_positionChangeed == false) {
if (filenameBack != "") {
//切换播放状态为播放
pause();
}
return;
}
//重置参数
m_position = 0;
m_positionChangeed = false;
setProperty("start",startTime);
const char *args[] = {"loadfile",c_filename, NULL};
mpv_command_async(m_mpvPlayer, 0, args);
//如果不播放任何媒体,则切换状态为停止
if (c_filename == "") {
changeState(StoppedState);
return;
}
//记录到上次播放变量中
filenameBack = c_filename;
//切换播放状态为正在播放
changeState(PlayingState);
}
void MMediaPlayer::play()
{
//从开头开始播放
truePlay("0");
}
void MMediaPlayer::pause()
{
// 获得mpv播放器的"暂停"状态
QString pasued = getProperty("pause");
KyInfo() << "pauseState = " << pasued;
// 根据"暂停"状态来选择暂停还是播放
if(pasued == "no") {
KyInfo() << "set pause yes";
setProperty("pause", "yes");
changeState(PausedState);
} else if(pasued == "yes") {
KyInfo() << "set pause no";
setProperty("pause", "no");
changeState(PlayingState);
}
}
void MMediaPlayer::stop()
{
setProperty("pause", "no");
const char *args[] = {"loadfile", "", NULL};
mpv_command_async(m_mpvPlayer, 0, args);
changeState(StoppedState);
}
MMediaPlayer::State MMediaPlayer::state() const
{
return m_state;
}
qint64 MMediaPlayer::position() const
{
return m_position;
}
void MMediaPlayer::setPosition(qint64 pos)
{
double sec = double(pos)/1000;
m_positionChangeed = true;
//记录拖动进度条之前播放状态是否为暂停
bool restartPlay = false;
if (m_state == PausedState) {
restartPlay = true;
}
//从拖动完成的位置开始播放
truePlay(QString::number(sec));
if (restartPlay) {
//切换播放状态为播放
pause();
}
}
void MMediaPlayer::setVolume(int vol)
{
// setProperty("volume",QString::number(vol));
// Q_EMIT signalVolume(vol);
// 设置音量此音量和系统同步不单独设置mpv音量
QDBusMessage message = QDBusMessage::createSignal("/", "org.kylin.music", "sinkInputVolumeChanged");
message << "kylin-music" << vol << false;
QDBusConnection::sessionBus().send(message);
}
qint64 MMediaPlayer::duration() const
{
return m_duration;
}
void MMediaPlayer::setMedia(const MMediaContent &media)
{
QUrl url =media.canonicalUrl();
//防止内存泄漏
if (m_tmpPlayList != nullptr) {
m_tmpPlayList->deleteLater();
}
//创建新的播放列表并将歌曲录入
m_tmpPlayList = new MMediaPlaylist(this);
m_tmpPlayList->addMedia(url);
setPlaylist(m_tmpPlayList);
//以暂停状态从头开始播放
setProperty("pause", "yes");
play();
}
bool MMediaPlayer::isAvailable() const
{
return true;
}
void MMediaPlayer::onMpvEvents()
{
//处理所有事件,直到事件队列为空
while (m_mpvPlayer)
{
mpv_event *event = mpv_wait_event(m_mpvPlayer, 0);
if (event->event_id == MPV_EVENT_NONE) {
break;
}
handle_mpv_event(event);
}
}
void MMediaPlayer::handle_mpv_event(mpv_event *event)
{
switch (event->event_id) {
case MPV_EVENT_PROPERTY_CHANGE: { //属性改变事件
mpv_event_property *prop = (mpv_event_property *)event->data;
//播放时,时间改变事件
if (strcmp(prop->name, "time-pos") == 0) {
if (prop->format == MPV_FORMAT_DOUBLE) {
//将播放状态设置为播放中
if (m_state == StoppedState) {
changeState(PlayingState);
}
// 获得播放时间
double time = *(double *)prop->data;
//将单位换算为毫秒
m_position = time * 1000;
Q_EMIT positionChanged(m_position);
} else if (prop->format == MPV_FORMAT_NONE) {
//当前时长距离总时长不超过500毫秒判断播放结束
if ( m_duration!=0 && (m_duration - m_position < 500)) {
m_duration = 0;
m_position = 0;
//播放结束
Q_EMIT playFinish();
} else {
//切歌
changeState(StoppedState);
}
}
}
}
break;
case MPV_EVENT_PLAYBACK_RESTART:{ //初始化完成事件
//获取总时长
m_duration = getProperty("duration").toDouble() *1000;//单位换算为毫秒
Q_EMIT durationChanged(m_duration);
}
break;
case MPV_EVENT_IDLE:{ //播放器空闲事件,只有刚启动时、播放完成时、歌曲异常时会进入此分支
QString playlist = getProperty("playlist");
if (!playlist.contains(',')) { //排除播放完成
if (playlist.length() > 2) { //排除刚启动
//歌曲播放异常
Q_EMIT playErrorMsg(Damage);
}
}
}
break;
//MPV会概率错误的发送此信号导致没播放完也跳转到下一首
// case MPV_EVENT_END_FILE:{ //播放结束事件
// if (m_position != 0) {
// //重置参数
// m_duration = 0;
// m_position = 0;
// //播放结束
// Q_EMIT playFinish();
// }
// }
// break;
default: ;
}
}
// 回调函数
static void wakeup(void *ctx)
{
// 此回调可从任何mpv线程调用但也可以从调用mpv API的线程递归地返回
// 只是需要通知要唤醒的Qt GUI线程以便它可以使用mpv_wait_event并尽快返回
MMediaPlayer *mvpPlayer = (MMediaPlayer *)ctx;
Q_EMIT mvpPlayer->mpvEvents();
}
void MMediaPlayer::createMvpplayer()
{
// 创建mpv实例
setlocale(LC_NUMERIC,"C");
m_mpvPlayer = mpv_create();
if (m_mpvPlayer == nullptr) {
qDebug()<<"创建播放模块失败!";
this->deleteLater();
return;
}
//禁用视频流
setProperty("vid", "no");
//接收事件
connect(this, &MMediaPlayer::mpvEvents, this, &MMediaPlayer::onMpvEvents, Qt::QueuedConnection);
mpv_set_wakeup_callback(m_mpvPlayer, wakeup, this);
//绑定事件
mpv_observe_property(m_mpvPlayer, 0, "time-pos", MPV_FORMAT_DOUBLE);
// 判断mpv实例是否成功初始化
if (mpv_initialize(m_mpvPlayer) < 0) {
qDebug()<<"初始化失败!";
this->deleteLater();
}
}
void MMediaPlayer::setProperty(const QString &name, const QString &value)
{
mpv_set_option_string(m_mpvPlayer, name.toLatin1().data(), value.toLatin1().data());
}
QString MMediaPlayer::getProperty(const QString &name) const
{
return (QString)mpv_get_property_string(m_mpvPlayer, name.toLatin1().data());
}
void MMediaPlayer::changeState(MMediaPlayer::State stateNow)
{
//待设置的循环模式和设置之前一致则不处理
if (m_state == stateNow ) {
return;
}
m_state = stateNow;
Q_EMIT stateChanged(m_state);
}
void MMediaPlayer::autoPlay(MMediaPlaylist::PlaybackMode playbackMode)
{
//如果是单曲循环模式
if (playbackMode == MMediaPlaylist::PlaybackMode::CurrentItemInLoop) {
//播放完毕自动切歌(借用播放点改变时间逻辑循环)
m_positionChangeed = true;
}
if(m_state!=StoppedState){
truePlay("0");
}
}

80
coreplayer/mmediaplayer.h Normal file
View File

@ -0,0 +1,80 @@
/*
* Copyright (C) 2020, Tianjin KYLIN Information Technology 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, 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 <http://www.gnu.org/licenses/&gt;.
*
*/
#ifndef MMEDIAPLAYER_H
#define MMEDIAPLAYER_H
#include <QObject>
#include <QDebug>
#include <client.h> // MPV库头文件
#include "mmediaplaylist.h"
class MMediaPlayer : public QObject
{
Q_OBJECT
public:
// 停止播放 播放中 暂停中
enum State{StoppedState=0,PlayingState,PausedState}; //播放状态枚举
enum ErrorMsg{NotFound=-1,Damage=-2}; //播放状态枚举
MMediaPlayer(QObject *parent = nullptr);
void setPlaylist(MMediaPlaylist *playlist); //设置播放列表
void pause(); //暂停或继续
State state() const; //获取状态
qint64 position() const; //获取当前播放点
void setPosition(qint64 pos); //设置播放起始点
bool isAvailable() const; //暂无实际功能
void setVolume(int vol); //设置音量
qint64 duration() const; //获取总时长
void setMedia(const MMediaContent &media); //设置待播放媒体
void play(); //播放
public Q_SLOTS:
void stop(); //停止
void onMpvEvents(); //接收mpv事件
private:
void truePlay(QString startTime = "0"); //实际的播放函数
void handle_mpv_event(mpv_event *event); // 处理mpv事件
void createMvpplayer(); // 创建mvpPlayer
void setProperty(const QString &name, const QString &value); // 设置mpv属性
QString getProperty(const QString &name) const; // 获得mpv属性
void changeState(State stateNow); //改变状态
MMediaPlaylist * m_playList = nullptr; //私有播放列表
MMediaPlaylist * m_tmpPlayList = nullptr; //私有临时播放列表
mpv_handle *m_mpvPlayer = nullptr;//句柄
State m_state = StoppedState;//播放状态
QByteArray filenameBack = ""; //上次播放的媒体名
bool m_positionChangeed = false; //播放进度被设置
qint64 m_position = 0; //播放进度
qint64 m_duration = 0; //总时长
private Q_SLOTS:
void autoPlay(MMediaPlaylist::PlaybackMode playbackMode); //自动播放
Q_SIGNALS:
void mpvEvents(); // 触发onMpvEvents()槽函数的信号
void stateChanged(MMediaPlayer::State); //状态改变信号
void durationChanged(qint64); //切换媒体时,总时长改变信号
void positionChanged(qint64); //播放进度改变信号
void playFinish(); //媒体播放完成信号
void playError(); //媒体播放错误信号
void playErrorMsg(ErrorMsg errorCode);//媒体播放错误信息信号
// void signalVolume(int);
};
#endif // MMEDIAPLAYER_H

View File

@ -0,0 +1,242 @@
/*
* Copyright (C) 2022 Tianjin KYLIN Information Technology 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, 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 <http://www.gnu.org/licenses/&gt;.
*
*/
#include "mmediaplaylist.h"
MMediaPlaylist::MMediaPlaylist(QObject *parent)
: QObject(parent)
{
}
QString MMediaPlaylist::getPlayFileName()
{
//异常情况:播放列表为空
if (m_playerList.isEmpty()) {
return "";
}
//异常情况:当前播放的媒体在列表中的位置超过列表中媒体总数量
if (m_index >= m_playerList.length()) {
m_index = m_playerList.length();
return m_playerList.last().toString();
}
return m_playerList.at(m_index).toString();
}
int MMediaPlaylist::currentIndex() const
{
return m_index;
}
bool MMediaPlaylist::addMedia(const QUrl &items)
{
m_playerList.append(items);
return true;
}
void MMediaPlaylist::next()
{
//异常情况:播放列表为空
if (m_playerList.isEmpty()) {
return;
}
//异常情况:无当前播放媒体
if (m_index < 0) {
return;
}
switch (m_playbackMode) {
case Random:
m_index=randomIndex();
break;
case Sequential:
m_index++;
if (m_index >= m_playerList.length()) {
m_index = m_playerList.length() - 1;
}
break;
default:
m_index++;
if (m_index >= m_playerList.length()) {
m_index = 0;
}
break;
}
Q_EMIT currentIndexChanged(m_index);
Q_EMIT stop();
}
void MMediaPlaylist::previous()
{
//异常情况:播放列表为空
if (m_playerList.isEmpty()) {
return;
}
switch (m_playbackMode) {
case Random:
m_index=randomIndex();
break;
case Sequential:
m_index--;
if (m_index < 0) {
m_index = 0;
}
break;
default:
m_index--;
if (m_index < 0) {
m_index = m_playerList.length() - 1;
}
break;
}
Q_EMIT currentIndexChanged(m_index);
Q_EMIT stop();
}
void MMediaPlaylist::setCurrentIndex(int index)
{
//待设置的数量和设置之前一致则不处理,默认播放第一首除外
// if (index == m_index && index != 0) {
// return;
// }
//异常情况:要设置的媒体位置超过列表总长度
if (index >= m_playerList.length()) {
qDebug()<<"指定位置超过列表元素数量";
return;
}
//统一所有非正常情况
if (index < 0) {
index = -1;
}
m_index = index;
Q_EMIT currentIndexChanged(m_index);
}
void MMediaPlaylist::setPlaybackMode(MMediaPlaylist::PlaybackMode mode)
{
//待设置的循环模式和设置之前一致则不处理
if (mode == m_playbackMode) {
return;
}
m_playbackMode = mode;
Q_EMIT playbackModeChanged(mode);
}
int MMediaPlaylist::mediaCount() const
{
return m_playerList.length();
}
MMediaContent MMediaPlaylist::media(int index) const
{
//异常情况:要设置的媒体位置在列表中不存在
if (index >= m_playerList.length() || index < 0) {
return MMediaContent(QUrl(""));
}
return MMediaContent(m_playerList.at(index));
}
bool MMediaPlaylist::clear()
{
m_playerList.clear();
return true;
}
bool MMediaPlaylist::removeMedia(int pos)
{
//异常情况:要移出的媒体位置在列表中不存在
if (pos >= m_playerList.length() || pos < 0) {
return false;
}
m_playerList.removeAt(pos);
return true;
}
void MMediaPlaylist::playError()
{
//当前仅在存在播放列表中的媒体本地文件被删除时触发
//播放异常时,轮询所有列表中的媒体文件是否存在
for (auto url : m_playerList) {
//如果发现列表中有媒体文件没被删除
if (QFileInfo::exists(url.toLocalFile())) {
//如果是单曲循环则切换下一首
if (m_playbackMode == CurrentItemInLoop) {
next();
}
//按播放完成处理
palyFinish();
return;
}
}
//列表中所有媒体的本地文件全部被删除了
Q_EMIT currentIndexChanged(-1);
}
void MMediaPlaylist::playErrorMsg(int Damage)
{
if (Damage == -2) {
//如果是列表循环则切换下一首
if (m_playbackMode == Loop) {
next();
} else if(m_playbackMode == Random) {
m_index = randomIndex();
Q_EMIT currentIndexChanged(m_index);
Q_EMIT stop();
}
//不知为什么要加自动播放信号
// Q_EMIT autoPlay(m_playbackMode);
}
}
void MMediaPlaylist::palyFinish()
{
//如果没有待播放的媒体则不处理
if (m_index < 0) {
return;
}
if (m_playbackMode == CurrentItemOnce) {
return;
}
//如果循环模式不是单曲循环则切换下一首
if (m_playbackMode != CurrentItemInLoop) {
next();
Q_EMIT currentIndexChanged(m_index);
}
Q_EMIT autoPlay(m_playbackMode);
}
MMediaPlaylist::PlaybackMode MMediaPlaylist::playbackMode() const
{
return m_playbackMode;
}
int MMediaPlaylist::randomIndex()
{
qsrand(QDateTime::currentDateTime().toMSecsSinceEpoch());
return qrand()%(m_playerList.length());
}
MMediaContent::MMediaContent(QUrl url)
{
m_url = url;
}
QUrl MMediaContent::canonicalUrl() const
{
return m_url;
}

View File

@ -0,0 +1,74 @@
/*
* Copyright (C) 2020, Tianjin KYLIN Information Technology 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, 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 <http://www.gnu.org/licenses/&gt;.
*
*/
#ifndef MMediaPlaylist_H
#define MMediaPlaylist_H
#include <QObject>
#include <QDebug>
#include <QFileInfo>
#include <QUrl>
#include <QDateTime>
class MMediaContent
{
public:
MMediaContent(QUrl url);
QUrl canonicalUrl() const; //获取Qurl内容
private:
QUrl m_url; //媒体url路径
};
class MMediaPlaylist : public QObject
{
Q_OBJECT
public:
// 只播放一次 单曲循环 列表播放 列表循环 随机播放
enum PlaybackMode { CurrentItemOnce=0, CurrentItemInLoop, Sequential, Loop, Random }; //播放循环模式枚举
MMediaPlaylist(QObject *parent = nullptr);
QString getPlayFileName(); //获取待播放媒体的文件名
int currentIndex() const; //获取当前播放的歌曲在播放列表中的位置
bool addMedia(const QUrl &items); //添加媒体
void next(); //切换下一首
void previous(); //切换上一首
void setCurrentIndex(int index); //设置选中播放列表中的位置
PlaybackMode playbackMode() const; //获取播放循环模式
void setPlaybackMode(PlaybackMode mode); //设置循环播放模式
int mediaCount() const; //列表中总媒体的数量
MMediaContent media(int index) const; //获取列表中特定位置的媒体
bool clear(); //清空列表
bool removeMedia(int pos); //移出特定位置的歌曲
public Q_SLOTS:
void palyFinish(); //播放完成槽函数
void playError(); //播放异常槽函数
void playErrorMsg(int Damage); //播放错误异常
private:
int randomIndex(); //生成随机数
QList<QUrl> m_playerList; //实际的播放队列
int m_index = 0; //当前播放的歌曲位置
PlaybackMode m_playbackMode = Loop; //当前列表的循环模式
Q_SIGNALS:
void currentIndexChanged(int); //媒体切换信号
void playbackModeChanged(MMediaPlaylist::PlaybackMode mode); //播放循环模式切换信号
void autoPlay(MMediaPlaylist::PlaybackMode playbackMode); //自动播放下一首信号
void stop(); //停止播放信号
};
#endif // MMediaPlaylist_H

View File

@ -0,0 +1,540 @@
/*
* Copyright (C) 2020, Tianjin KYLIN Information Technology 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, 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 <http://www.gnu.org/licenses/&gt;.
*
*/
#include <QDebug>
#include <QDBusConnection>
#include "playcontroller.h"
bool playController::play(QString playlist, int index)
{
if (playlist.compare(m_curList)==0)
{
stop();
setSongIndex(index);
play();
return true;
}
return false;
}
bool playController::play()
{
if (m_player == nullptr) {
return false;
}
if (m_player->isAvailable() == false) { //存疑
return false;
}
if (m_player->state() == MMediaPlayer::State::PlayingState) {
m_player->pause();
} else {
m_player->play();
Q_EMIT curIndexChanged(m_playlist->currentIndex());
}
return true;
}
bool playController::pause()
{
if (m_player == nullptr) {
return false;
}
m_player->pause();
return true;
}
bool playController::stop()
{
if (m_player == nullptr) {
return false;
}
m_player->stop();
return true;
}
void playController::setSongIndex(int index)
{
if (m_playlist == nullptr) {
qDebug() << "m_playlist is null";
return;
}
if(index < 0)
{
return;
}
if (index > m_playlist->mediaCount()) {
return;
}
m_playlist->setCurrentIndex(index);
Q_EMIT curIndexChanged(index);
}
int playController::songIndex()
{
if (m_playlist == nullptr) {
qDebug() << "m_playlist is null";
return -1;
}
return m_playlist->currentIndex();
}
int playController::playmode()
{
if (m_playlist == nullptr) {
qDebug() << "m_playlist is null";
return -1;
}
return static_cast<MMediaPlaylist::PlaybackMode>(m_playlist->playbackMode());
}
void playController::setPlaymode(int mode)
{
if (m_playlist == nullptr || m_player == nullptr) {
return;
}
if (m_playlist == nullptr) {
qDebug() << "m_playlist is null";
return;
}
m_playlist->setPlaybackMode(static_cast<MMediaPlaylist::PlaybackMode>(mode));
}
void playController::curPlaylist()
{
// Print Playlist information
if (m_playlist == nullptr) {
return;
}
for (auto i = 0; i < m_playlist->mediaCount(); i++) {
MMediaContent content = m_playlist->media(i);
// qDebug() << " "
// << "media[" << i << "] is:" << content.canonicalUrl();
}
}
void playController::setCurPlaylist(QString name, QStringList songPaths)
{
if (m_curList.compare(name)==0)
{
// qDebug() << "setCurPlaylist m_curList.compare(name)==0" << m_curList << name;
// return ;
}
if (m_playlist == nullptr || m_player == nullptr) {
return;
}
disconnect(m_playlist,&MMediaPlaylist::currentIndexChanged,this,&playController::slotIndexChange);
m_curList = name;
m_playlist->clear();
for (auto path : songPaths) {
m_playlist->addMedia(QUrl::fromLocalFile(path));
}
m_player->stop();
m_player->setPlaylist(nullptr);
m_player->setPlaylist(m_playlist);
// m_playlist->setCurrentIndex(-1);
connect(m_playlist,&MMediaPlaylist::currentIndexChanged,this,&playController::slotIndexChange);
isInitialed = true;
}
void playController::addSongToCurList(QString name, QString songPath)
{
if (name.compare(m_curList) != 0) {
qDebug() << __FUNCTION__ << " the playlist to add is not Current playlist.";
return;
}
if (m_playlist != nullptr) {
m_playlist->addMedia(QUrl::fromLocalFile(songPath));
}
}
void playController::removeSongFromCurList(QString name, int index)
{
if (name.compare(m_curList) != 0)
{
// qDebug() << __FUNCTION__ << " the playlist to add is not Current playlist.";
return;
}
if (m_playlist != nullptr) {
// m_playlist->removeMedia(index);
//判断删除后 播放歌曲的index 当前只判断了删除正在播放的歌曲 还没做删除正在播放之前的歌曲和之后的歌曲
int count = m_playlist->mediaCount();
int state = m_player->state();
if(m_curIndex == index)
{
stop();
if(m_curIndex == count - 1)
{
m_curIndex = 0;
m_playlist->removeMedia(index);
if(m_playlist->mediaCount() == 0)
{
m_curIndex = -1;
}
setSongIndex(m_curIndex);
}
else
{
m_playlist->removeMedia(index);
if(m_playlist->mediaCount() == 0)
{
m_curIndex = -1;
}
// setSongIndex(m_curIndex);
setSongIndex(m_curIndex);
}
//删除当前播放歌曲不更改播放状态 2021.09.10
if (state == MMediaPlayer::State::PlayingState) {
m_player->play();
} else { //设置进度条归 0
Q_EMIT signalSetValue();
m_player->pause();
}
}
else if(m_curIndex > index)
{
// int position = 0;
// if(m_player->state()==MMediaPlayer::PlayingState)
// {
// position = m_player->position();
// }
// m_player->stop();
m_playlist->removeMedia(index);
m_curIndex = m_curIndex - 1;
//只负责高亮歌曲
setSongIndex(m_curIndex);
// m_player->setPosition(position);
//歌曲删除重新播放(跨函数调用)
// PlaySongArea::getInstance().hSlider->setValue(position);
//MPV setPosition已经设置播放不用再次设置播放
// m_player->play();
}
else if(m_curIndex < index)
{
m_playlist->removeMedia(index);
}
Q_EMIT curIndexChanged(m_curIndex);
Q_EMIT currentIndexAndCurrentList(m_curIndex,m_curList);
slotIndexChange(m_curIndex);
}
}
void playController::removeSongFromLocalList(QString name, int index)
{
if (name.compare(m_curList) != 0)
{
qDebug() << __FUNCTION__ << " the playlist to add is not Current playlist.";
return;
}
if (m_playlist != nullptr)
{
int count = m_playlist->mediaCount();
int state = m_player->state();
if(m_curIndex == index)
{
stop();
if(m_curIndex == count - 1)
{
m_curIndex = 0;
m_playlist->removeMedia(index);
if(m_playlist->mediaCount() == 0)
{
m_curIndex = -1;
}
setSongIndex(m_curIndex);
}
else
{
m_playlist->removeMedia(index);
if(m_playlist->mediaCount() == 0)
{
m_curIndex = -1;
}
setSongIndex(m_curIndex);
}
//删除当前播放歌曲不更改播放状态 2021.09.10
if (state == MMediaPlayer::State::PlayingState) {
m_player->play();
} else { //设置进度条归 0
Q_EMIT signalSetValue();
m_player->pause();
}
}
else if(m_curIndex > index)
{
m_playlist->removeMedia(index);
m_curIndex = m_curIndex - 1;
setSongIndex(m_curIndex);
}
else if(m_curIndex < index)
{
m_playlist->removeMedia(index);
}
Q_EMIT curIndexChanged(m_curIndex);
Q_EMIT currentIndexAndCurrentList(m_curIndex,m_curList);
slotIndexChange(m_curIndex);
}
}
playController::PlayState playController::getState()
{
if(m_player->state() == MMediaPlayer::State::PlayingState)
return PlayState::PLAY_STATE;
else if(m_player->state() == MMediaPlayer::State::PausedState)
return PlayState::PAUSED_STATE;
else if(m_player->state() == MMediaPlayer::State::StoppedState)
return PlayState::STOP_STATE;
else
return PlayState::STOP_STATE;
}
playController::playController()
: m_curList(""),m_curIndex(-1)
{
m_player = new MMediaPlayer(this);
if (m_player == nullptr) {
qDebug() << "failed to create player ";
return;
}
m_playlist = new MMediaPlaylist(m_player);
if (m_playlist == nullptr) {
qDebug() << "failed to create laylist";
return;
}
m_player->setPlaylist(m_playlist);
init();
//绑定铃声音量
// initDbus();
m_playlist->setPlaybackMode(MMediaPlaylist::Loop);
// m_playlist->setCurrentIndex(-1);
connect(m_playlist,&MMediaPlaylist::currentIndexChanged,this,&playController::slotIndexChange);
connect(m_player,&MMediaPlayer::stateChanged,this,&playController::slotStateChanged);
connect(m_playlist,&MMediaPlaylist::playbackModeChanged,this,&playController::slotPlayModeChange);
// connect(m_player,&MMediaPlayer::playErrorMsg,this,&playController::slotPlayErrorMsg);
}
void playController::init()
{
m_volume=100;
m_player->setVolume(100);
m_curList = ALLMUSIC;
m_mode = Loop;
}
void playController::initDbus()
{
QDBusConnection::sessionBus().connect(QString(), "/", "org.ukui.media", "sinkVolumeChanged", this, SLOT(slotVolumeChange(QString,int,bool)));
}
int playController::getVolume()
{
return m_volume;
}
void playController::setVolume(int volume)
{
if(volume > 100) {
volume = 100;
}
if(volume < 0) {
volume = 0;
}
m_volume = volume;
if (!m_receive) {
m_player->setVolume(volume);
} else {
m_receive = false;
}
}
void playController::onCurrentIndexChanged()
{
qDebug() << "onCurrentIndexChanged";
}
void playController::onPositionChanged(double value)
{
qDebug() << "onPositionChanged";
if (m_player == nullptr) {
return;
}
m_player->setPosition(m_player->duration() * value);
}
void playController::onNextSong()
{
if (m_playlist == nullptr || m_player == nullptr) {
qDebug() << "m_playlist or m_player is nullptr";
return;
}
m_playlist->next();
m_player->play();
curPlaylist();
auto index = m_playlist->currentIndex();
Q_EMIT curIndexChanged(index);
}
void playController::onPreviousSong()
{
if (m_playlist == nullptr || m_player == nullptr) {
qDebug() << "m_playlist or m_player is nullptr";
return;
}
m_playlist->previous();
m_player->play();
auto index = m_playlist->currentIndex();
Q_EMIT curIndexChanged(index);
}
void playController::setCurList(QString renameList)
{
m_curList = renameList;
}
void playController::onError()
{
qDebug() << "onError";
}
void playController::onMediaStatusChanged()
{
qDebug() << "onMediaStatusChanged";
}
playController::~playController(/* args */)
{
if (m_playlist != nullptr) {
m_playlist->deleteLater();
}
if (m_player != nullptr) {
m_player->deleteLater();
}
}
void playController::playSingleSong(QString Path, int playMode)
{
QStringList filePaths;
filePaths<<Path;
getInstance().setCurPlaylist(ALLMUSIC,filePaths);
getInstance().setPlaymode(playMode);
getInstance().play(ALLMUSIC,0);
}
void playController::slotStateChanged(MMediaPlayer::State newState)
{
if(newState == MMediaPlayer::State::PlayingState)
Q_EMIT playerStateChange(playController::PlayState::PLAY_STATE);
else if(newState == MMediaPlayer::State::PausedState)
Q_EMIT playerStateChange(playController::PlayState::PAUSED_STATE);
else if(newState == MMediaPlayer::State::StoppedState)
Q_EMIT playerStateChange(playController::PlayState::STOP_STATE);
}
void playController::slotPlayModeChange(MMediaPlaylist::PlaybackMode mode)
{
if(mode == MMediaPlaylist::PlaybackMode::CurrentItemInLoop)
Q_EMIT signalPlayMode(static_cast<MMediaPlaylist::PlaybackMode>(playController::PlayMode::CurrentItemInLoop));
else if(mode == MMediaPlaylist::PlaybackMode::Sequential)
Q_EMIT signalPlayMode(static_cast<MMediaPlaylist::PlaybackMode>(playController::PlayMode::Sequential));
else if(mode == MMediaPlaylist::PlaybackMode::Loop)
Q_EMIT signalPlayMode(static_cast<MMediaPlaylist::PlaybackMode>(playController::PlayMode::Loop));
else if(mode == MMediaPlaylist::PlaybackMode::Random)
Q_EMIT signalPlayMode(static_cast<MMediaPlaylist::PlaybackMode>(playController::PlayMode::Random));
}
void playController::slotIndexChange(int index)
{
if(index == -1)
{
Q_EMIT signalNotPlaying();
//当index == -1时会调用positionChanged导致时长显示错误
Q_EMIT singalChangePath("");
Q_EMIT currentIndexAndCurrentList(-1,m_curList);
return;
}
m_curIndex = index;
MMediaContent content = m_playlist->media(index);
QString path = content.canonicalUrl().toLocalFile();
QFileInfo file(path.remove("file://"));
if(file.exists())
{
x = 0;
Q_EMIT currentIndexAndCurrentList(index,m_curList);
Q_EMIT singalChangePath(path);
}
else
{
x++;
if(x > m_playlist->mediaCount())
{
x = 0;
return;
}
}
}
void playController::setPosition(int position)
{
if (qAbs(m_player->position() - position) > 99)
m_player->setPosition(position);
}
void playController::setPlayListName(QString playListName)
{
m_curList=playListName;
}
QString playController::getPlayListName()
{
return m_curList;
}
QString playController::getPath()
{
return m_path;
}
void playController::setMode(playController::PlayMode mode)
{
m_mode = mode;
}
playController::PlayMode playController::mode() const
{
return m_mode;
}
void playController::slotVolumeChange(QString app, int value, bool mute)
{
if (app == "kylin-music") {
if (value < 0) {
return;
}
if (value != m_volume) {
m_receive = true;
Q_EMIT signalVolume(value);
}
//mute = true静音 mute = false取消静音
Q_EMIT signalMute(mute);
}
}

167
coreplayer/playcontroller.h Normal file
View File

@ -0,0 +1,167 @@
/*
* Copyright (C) 2020, Tianjin KYLIN Information Technology 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, 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 <http://www.gnu.org/licenses/&gt;.
*
*/
#ifndef PLAYCONTROLLER_H
#define PLAYCONTROLLER_H
#include <QObject>
#include <QGSettings>
#include "mmediaplayer.h"
#include "mmediaplaylist.h"
#define KYLINMUSIC "org.kylin-music-data.settings"
const QString ALLMUSIC = "LocalMusic"; //本地总表
class playController : public QObject {
Q_OBJECT
public:
enum PlayState {
STOP_STATE = 0,
PLAY_STATE = 1,
PAUSED_STATE = 2
};
enum PlayMode {
CurrentItemInLoop = 1,
Sequential = 2,
Loop = 3,
Random = 4,
};
public:
static playController& getInstance()
{
static playController instance;
return instance;
}
private:
playController(/* args */);
playController(playController const&);
playController& operator=(playController const&);
~playController();
void init();
void initDbus();
public:
//新增接口 fyf
void playSingleSong(QString Path, int playMode);
bool play(QString playlist, int index);
bool play();
bool pause();
bool stop();
int volume();
void setPlayPosition(int pos);
int playPosition();
void setSongIndex(int index);
int songIndex();
int playmode();
void setPlaymode(int mode);
void curPlaylist();
void setCurPlaylist(QString name, QStringList songPaths);
void addSongToCurList(QString name, QString songPath);
//从歌单删除
void removeSongFromCurList(QString name, int index);
//从本地删除
void removeSongFromLocalList(QString name, int index);
// void removeMedia(QString name, int index);
PlayState getState();
PlayMode mode() const;
MMediaPlayer* getPlayer()
{
return m_player;
}
MMediaPlaylist* getPlaylist()
{
return m_playlist;
}
void setPosition(int position);
//获取音量
int getVolume();
//设置音量
void setVolume(int volume);
//获取歌单名
QString getPlayListName();
//获取歌曲路径
QString getPath();
Q_SIGNALS:
void curPositionChanged(qint64);
void curDurationChanged(qint64);
void curIndexChanged(int index);
void playerError(int error, QString errMsg);
void playerStateChange(playController::PlayState newState);
void singalChangePath(QString path);
void currentIndexAndCurrentList(int index,QString listname);
void signalPlayMode(int playModel);
void signalNotPlaying();
// void playErrorMsg(int errorCode);//媒体播放错误信息信号
//进度条归 0
void signalSetValue();
//系统音乐音量改变
void signalVolume(int value);
//系统音乐音量静音
void signalMute(bool mute);
public Q_SLOTS:
void onCurrentIndexChanged();
void onPositionChanged(double value);
void onNextSong();
void onPreviousSong();
void setCurList(QString renameList);
void setMode(playController::PlayMode mode);
void setPlayListName(QString playListName);
private Q_SLOTS:
void onError();
void onMediaStatusChanged();
//状态改变
void slotStateChanged(MMediaPlayer::State newState);
//播放模式改变
void slotPlayModeChange(MMediaPlaylist::PlaybackMode mode);
//获得当前播放的index
void slotIndexChange(int index);
//媒体播放错误信息槽函数
// void slotPlayErrorMsg(MMediaPlayer::ErrorMsg msg);
//接收系统应用音量变化
void slotVolumeChange(QString app, int value, bool mute);
private:
//当前播放列表名
QString m_curList;
//当前播放的索引
int m_curIndex;
MMediaPlayer* m_player = nullptr;
MMediaPlaylist* m_playlist = nullptr;
bool isInitialed = false;
//在列表里歌曲判断本地歌曲是否存在没有播放的情况下当前函数掉了多少次要是歌曲在播放找到本地路径存在x重新计数
int x = 0;
int m_volume = 100;
QGSettings *playSetting = nullptr;
QString m_path;
PlayMode m_mode = playController::Loop;
// int m_msg = 0;
//标记系统音乐接收状态
bool m_receive = false;
};
#endif // PLAYCONTROLLER_H

172
countdown.ui Normal file
View File

@ -0,0 +1,172 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>countdown</class>
<widget class="QWidget" name="countdown">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1035</width>
<height>682</height>
</rect>
</property>
<property name="windowTitle">
<string>countdown</string>
</property>
<widget class="QPushButton" name="pushButton_Start">
<property name="geometry">
<rect>
<x>20</x>
<y>100</y>
<width>80</width>
<height>26</height>
</rect>
</property>
<property name="text">
<string>开始</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton_ring">
<property name="geometry">
<rect>
<x>20</x>
<y>220</y>
<width>80</width>
<height>26</height>
</rect>
</property>
<property name="text">
<string>铃声</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton_pause">
<property name="geometry">
<rect>
<x>20</x>
<y>140</y>
<width>80</width>
<height>26</height>
</rect>
</property>
<property name="text">
<string>暂停</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton_timeselect">
<property name="geometry">
<rect>
<x>20</x>
<y>180</y>
<width>80</width>
<height>26</height>
</rect>
</property>
<property name="text">
<string>时间选择</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton_Start_2">
<property name="geometry">
<rect>
<x>637</x>
<y>470</y>
<width>80</width>
<height>80</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(255, 255, 255);
background-color: rgb(255, 255, 255);</string>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QTextEdit" name="textEdit">
<property name="geometry">
<rect>
<x>550</x>
<y>210</y>
<width>241</width>
<height>231</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(255, 255, 255);
font: 24pt &quot;Sans Serif&quot;;
background-color: rgb(14, 19, 22);</string>
</property>
</widget>
<widget class="QLabel" name="label_5">
<property name="geometry">
<rect>
<x>630</x>
<y>170</y>
<width>81</width>
<height>20</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(255, 255, 255);
color: rgb(148, 148, 148);
font: 12pt &quot;Sans Serif&quot;;</string>
</property>
<property name="text">
<string>00:00:00</string>
</property>
</widget>
<widget class="QLabel" name="label_4">
<property name="geometry">
<rect>
<x>570</x>
<y>110</y>
<width>191</width>
<height>51</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(255, 255, 255);
text-decoration: underline;
font: 9pt &quot;Sans Serif&quot;;
font: 36pt &quot;Sans Serif&quot;;</string>
</property>
<property name="text">
<string>00:00:00</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton_timeselect_2">
<property name="geometry">
<rect>
<x>760</x>
<y>580</y>
<width>80</width>
<height>26</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(255, 255, 255);</string>
</property>
<property name="text">
<string>复位</string>
</property>
</widget>
<widget class="QPushButton" name="pushButton_ring_2">
<property name="geometry">
<rect>
<x>510</x>
<y>580</y>
<width>80</width>
<height>26</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(255, 255, 255);</string>
</property>
<property name="text">
<string>计次</string>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>

111
countdownAnimation.cpp Normal file
View File

@ -0,0 +1,111 @@
/*
* Copyright (C) 2019 Tianjin KYLIN Information Technology 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, 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 <http://www.gnu.org/licenses/&gt;.
*
*/
#include "countdownAnimation.h"
#include <QTimer>
#include <unistd.h>
#include <QDebug>
#include <qroundProgressBar.h>
#include <QApplication>
Countdown_Animation::Countdown_Animation(QWidget *parent , int value) :
QWidget(parent),
value_max(value)
{
setupUi(this);
//渐变色
QGradientStops gradientPoints;
gradientPoints << QGradientStop(0.5, QColor(255, 160, 90)) << QGradientStop(1, QColor(180, 30, 10)); //渐变起止颜色设置
// Gradient start and stop color settings
countdownRunRoundBar->setDataColors(gradientPoints);
//设置动态光圈转动频率
connectToSlider(countdownRunRoundBar);
}
Countdown_Animation::~Countdown_Animation()
{
delete countdownRunRoundBar;
qDebug()<<"-------Countdown_Animation---------";
}
//设置动态光圈转动频率
// Set dynamic diaphragm rotation frequency
void Countdown_Animation::connectToSlider(QRoundProgressBar *bar)
{
bar->setRange(0, 3600);
bar->setValue(3600);
// timer->start();
}
/**
* @brief UI
* @param TestWidget
* @param
*
* @return
*/
void Countdown_Animation::setupUi(QWidget *TestWidget)
{
if (TestWidget->objectName().isEmpty())
TestWidget->setObjectName(QString::fromUtf8("TestWidget"));
TestWidget->resize(454, 461);
//时间滚轮
countdownRunRoundBar = new QRoundProgressBar(TestWidget);
countdownRunRoundBar->setObjectName(QString::fromUtf8("RoundBar3"));
countdownRunRoundBar->setGeometry(QRect(-12, -4, 454, 461));
//管理着控件或窗体的所有颜色信息
// QPalette palette;
// QBrush brush(QColor(255, 255, 255, 0));
// brush.setStyle(Qt::SolidPattern);
// palette.setBrush(QPalette::Active, QPalette::Base, brush);
// //红色
// QBrush brushRed(QColor(170, 0, 0, 255));
// brushRed.setStyle(Qt::SolidPattern);
// //活跃状态(获得焦点) 高亮背景色
// palette.setBrush(QPalette::Active, QPalette::Highlight, brushRed);
// palette.setBrush(QPalette::Inactive, QPalette::Base, brush);
// //不活跃状态(未获得焦点)
// palette.setBrush(QPalette::Inactive, QPalette::Highlight, brushRed);
// //白色
// QBrush brushWhite(QColor(244, 244, 244, 255));
// brushWhite.setStyle(Qt::SolidPattern);
// palette.setBrush(QPalette::Disabled, QPalette::Base, brushWhite);
// //深蓝
// QBrush brushBlue(QColor(50, 100, 150, 255));
// brushBlue.setStyle(Qt::SolidPattern);
// //不可用状态
// palette.setBrush(QPalette::Disabled, QPalette::Highlight, brushBlue);
// countdownRunRoundBar->setPalette(palette);
retranslateUi(TestWidget);
QMetaObject::connectSlotsByName(TestWidget);
}
/**
* @brief
* @param
* @param
*
* @return
*/
void Countdown_Animation::retranslateUi(QWidget *TestWidget)
{
//翻译标题是个""
TestWidget->setWindowTitle(QApplication::translate("TestWidget", "TestWidget", nullptr));
}

57
countdownAnimation.h Normal file
View File

@ -0,0 +1,57 @@
/*
* Copyright (C) 2019 Tianjin KYLIN Information Technology 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, 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 <http://www.gnu.org/licenses/&gt;.
*
*/
#ifndef TESTWIDGET_H
#define TESTWIDGET_H
#include <QWidget>
#include <qroundProgressBar.h>
namespace Ui {
class Countdown_Animation;
}
class Countdown_Animation : public QWidget
{
Q_OBJECT
public:
Countdown_Animation( QWidget *parent = 0, int value_max = 0);
~Countdown_Animation();
QRoundProgressBar *countdownRunRoundBar;
void setupUi(QWidget *TestWidget);
void retranslateUi(QWidget *TestWidget);
int value_max=100;
private:
//设置动态光圈转动频率
// Set dynamic diaphragm rotation frequency
void connectToSlider(class QRoundProgressBar* bar);
void con();
Ui::Countdown_Animation *ui;
};
#endif // TESTWIDGET_H

View File

@ -0,0 +1,29 @@
/*
* Copyright (C) 2020, Tianjin KYLIN Information Technology 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, 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 <http://www.gnu.org/licenses/&gt;.
*
*/
#include "dbusdeleteclockbyidadaptor.h"
DbusDeleteClockByIdAdaptor::DbusDeleteClockByIdAdaptor(QObject *parent, Clock *currentClock) : QDBusAbstractAdaptor(parent),
m_clock(currentClock)
{
}
QString DbusDeleteClockByIdAdaptor::deleteClockByIdRpc(QString param)
{
return m_clock->deleteClockByIdJosn(param);
}

View File

@ -0,0 +1,39 @@
/*
* Copyright (C) 2020, Tianjin KYLIN Information Technology 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, 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 <http://www.gnu.org/licenses/&gt;.
*
*/
#ifndef DBUSDELETECLOCKBYIDADAPTOR_H
#define DBUSDELETECLOCKBYIDADAPTOR_H
#include <QObject>
#include <QDBusAbstractAdaptor>
#include "clock.h"
class DbusDeleteClockByIdAdaptor : public QDBusAbstractAdaptor
{
Q_OBJECT
//声明它正在导出哪个接口
Q_CLASSINFO("D-Bus Interface", CLOCK_DBUS_SERVICE_NAME)
public:
explicit DbusDeleteClockByIdAdaptor(QObject *parent = nullptr,Clock * currentClock = nullptr);
signals:
public slots:
QString deleteClockByIdRpc(QString param);
private:
Clock * m_clock;
};
#endif // DBUSDELETECLOCKBYIDADAPTOR_H

View File

@ -0,0 +1,29 @@
/*
* Copyright (C) 2020, Tianjin KYLIN Information Technology 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, 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 <http://www.gnu.org/licenses/&gt;.
*
*/
#include "dbusselectclockbyidadaptor.h"
DbusSelectClockByIdAdaptor::DbusSelectClockByIdAdaptor(QObject *parent,Clock * currentClock) : QDBusAbstractAdaptor(parent),
m_clock(currentClock)
{
}
QString DbusSelectClockByIdAdaptor::selectClockByIdRpc(QString param)
{
return m_clock->selectClockByIdJosn(param);
}

View File

@ -0,0 +1,39 @@
/*
* Copyright (C) 2020, Tianjin KYLIN Information Technology 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, 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 <http://www.gnu.org/licenses/&gt;.
*
*/
#ifndef DBUSSELECTCLOCKBYIDADAPTOR_H
#define DBUSSELECTCLOCKBYIDADAPTOR_H
#include <QObject>
#include <QDBusAbstractAdaptor>
#include "clock.h"
class DbusSelectClockByIdAdaptor : public QDBusAbstractAdaptor
{
Q_OBJECT
//声明它正在导出哪个接口
Q_CLASSINFO("D-Bus Interface", CLOCK_DBUS_SERVICE_NAME)
public:
explicit DbusSelectClockByIdAdaptor(QObject *parent = nullptr,Clock * currentClock = nullptr);
signals:
public slots:
QString selectClockByIdRpc(QString param);
private:
Clock * m_clock;
};
#endif // DBUSSELECTCLOCKBYIDADAPTOR_H

View File

@ -0,0 +1,29 @@
/*
* Copyright (C) 2020, Tianjin KYLIN Information Technology 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, 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 <http://www.gnu.org/licenses/&gt;.
*
*/
#include "dbusupdateclockadaptor.h"
DbusUpdateClockAdaptor::DbusUpdateClockAdaptor(QObject *parent,Clock * currentClock) : QDBusAbstractAdaptor(parent),
m_clock(currentClock)
{
}
QString DbusUpdateClockAdaptor::updateClockByIdRpc(QString param)
{
return m_clock->updateClockByIdJosn(param);
}

39
dbusupdateclockadaptor.h Normal file
View File

@ -0,0 +1,39 @@
/*
* Copyright (C) 2020, Tianjin KYLIN Information Technology 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, 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 <http://www.gnu.org/licenses/&gt;.
*
*/
#ifndef DBUSUPDATECLOCKADAPTOR_H
#define DBUSUPDATECLOCKADAPTOR_H
#include <QObject>
#include <QDBusAbstractAdaptor>
#include "clock.h"
class DbusUpdateClockAdaptor : public QDBusAbstractAdaptor
{
Q_OBJECT
//声明它正在导出哪个接口
Q_CLASSINFO("D-Bus Interface", CLOCK_DBUS_SERVICE_NAME)
public:
explicit DbusUpdateClockAdaptor(QObject *parent = nullptr,Clock * currentClock = nullptr);
signals:
public slots:
QString updateClockByIdRpc(QString param);
private:
Clock * m_clock;
};
#endif // DBUSUPDATECLOCKADAPTOR_H

68
debug.h Normal file
View File

@ -0,0 +1,68 @@
/*
* Copyright (C) 2019 Tianjin KYLIN Information Technology 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, 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 <http://www.gnu.org/licenses/&gt;.
*
*/
#ifndef DEBUG_H
#define DEBUG_H
#include <QtDebug>
#include <QFile>
#include <QTextStream>
#include <QMutex>
#include <QTime>
//输出消息
// Output message
static void outputMessage(QtMsgType type, const QMessageLogContext &context, const QString &msg)
{
static QMutex mutex;
mutex.lock();
QString text;
switch(type)
{
case QtDebugMsg:
text = QString("Debug:");
break;
case QtWarningMsg:
text = QString("Warning:");
break;
case QtCriticalMsg:
text = QString("Critical:");
break;
case QtFatalMsg:
text = QString("Fatal:");
}
QString contextInfo = QString("File:(%1) Line:(%2)").arg(QString(context.file)).arg(context.line);
QString cDataTime = QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss ddd");
QString cDate = QString("(%1)").arg(cDataTime);
QString message = QString("%1 %2 %3 %4").arg(text).arg(contextInfo).arg(msg).arg(cDate);
QFile file("log.txt");
file.open(QIODevice::WriteOnly | QIODevice::Append);
QTextStream textStream(&file);
textStream << message << "\r\n";
file.flush();
file.close();
mutex.unlock();
}
#endif // DEBUG_H

128
deleteMsg.cpp Normal file
View File

@ -0,0 +1,128 @@
/*
* Copyright (C) 2019 Tianjin KYLIN Information Technology 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, 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 <http://www.gnu.org/licenses/&gt;.
*
*/
#include "deleteMsg.h"
#include "ui_deleteMsg.h"
#include <X11/Xlib.h>
#include "xatom-helper.h"
extern void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed);
delete_msg::delete_msg(QWidget *parent) :
QDialog(parent),
ui(new Ui::delete_msg)
{
ui->setupUi(this);
// 添加窗管协议
XAtomHelper::setStandardWindowHint(this->winId());
// this->setProperty("blurRegion", QRegion(QRect(1, 1, 1, 1)));
// setAttribute(Qt::WA_TranslucentBackground);
// this->setWindowFlags(Qt::FramelessWindowHint | Qt::Dialog);
QPalette palette = ui->surebtn->palette();
QColor ColorPlaceholderText(61,107,229,255);
QBrush brush2;
brush2.setColor(ColorPlaceholderText);
palette.setColor(QPalette::Button,QColor(61,107,229,255));
palette.setBrush(QPalette::ButtonText, QBrush(Qt::white));
ui->surebtn->setPalette(palette);
QPalette palette1 = ui->closebtn->palette();
QColor ColorPlaceholderText1(255,255,255,0);
QBrush brush;
brush.setColor(ColorPlaceholderText1);
palette.setBrush(QPalette::Button, brush);
ui->closebtn->setPalette(palette1);
ui->closebtn->setIcon(QIcon::fromTheme("window-close-symbolic"));
ui->closebtn->setProperty("isWindowButton", 0x2);
ui->closebtn->setProperty("useIconHighlightEffect", 0x8);
//保存按钮边框是否凸起
ui->closebtn->setFlat(true);
// 主题框架1.0.6-5kylin2
//配置重要按钮
ui->surebtn->setProperty("isImportant", true);
//关闭按钮去掉聚焦状态
ui->closebtn->setFocusPolicy(Qt::NoFocus);
ui->cancelbtn->setProperty("useButtonPalette", true);
}
delete_msg::~delete_msg()
{
delete ui;
}
void delete_msg::on_closebtn_clicked()
{
close_sure = 0;
this->close();
}
void delete_msg::on_surebtn_clicked()
{
close_sure = 1;
this->close();
}
void delete_msg::on_cancelbtn_clicked()
{
close_sure = 0;
this->close();
}
void delete_msg::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event);
QPainter p(this);
p.setRenderHint(QPainter::Antialiasing); // 反锯齿;
QPainterPath rectPath;
rectPath.addRect(this->rect());
p.fillPath(rectPath,palette().color(QPalette::Base));
}
void delete_msg::mousePressEvent(QMouseEvent *event)
{
if (event->button() == Qt::LeftButton) {
this->dragPosition = event->globalPos() - frameGeometry().topLeft();
this->mousePressed = true;
}
QWidget::mousePressEvent(event);
}
void delete_msg::mouseReleaseEvent(QMouseEvent *event)
{
if (event->button() == Qt::LeftButton) {
this->mousePressed = false;
this->setCursor(Qt::ArrowCursor);
}
QWidget::mouseReleaseEvent(event);
}
void delete_msg::mouseMoveEvent(QMouseEvent *event)
{
if (this->mousePressed) {
move(event->globalPos() - this->dragPosition);
this->setCursor(Qt::ClosedHandCursor);
}
QWidget::mouseMoveEvent(event);
}

60
deleteMsg.h Normal file
View File

@ -0,0 +1,60 @@
/*
* Copyright (C) 2019 Tianjin KYLIN Information Technology 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, 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 <http://www.gnu.org/licenses/&gt;.
*
*/
#ifndef DELETE_MSG_H
#define DELETE_MSG_H
#include <QDialog>
#include <QStyleOption>
#include <QPainter>
#include <QMouseEvent>
#include <QPainterPath>
namespace Ui {
class delete_msg;
}
/**
* @brief
*/
class delete_msg : public QDialog
{
Q_OBJECT
public:
explicit delete_msg(QWidget *parent = nullptr);
~delete_msg();
int close_sure;
//绘制底部阴影
// Draw bottom shadow
void paintEvent(QPaintEvent *event);
Ui::delete_msg *ui;
void mousePressEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
private slots:
void on_closebtn_clicked();
void on_surebtn_clicked();
void on_cancelbtn_clicked();
private:
QPoint dragPosition; //拖动坐标
bool mousePressed; //鼠标是否按下
};
#endif // DELETE_MSG_H

267
deleteMsg.ui Normal file
View File

@ -0,0 +1,267 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>delete_msg</class>
<widget class="QDialog" name="delete_msg">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>350</width>
<height>174</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<widget class="QWidget" name="widget" native="true">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>350</width>
<height>174</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<widget class="QWidget" name="widget_2" native="true">
<property name="geometry">
<rect>
<x>0</x>
<y>50</y>
<width>350</width>
<height>46</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>19</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="questionIcon">
<property name="minimumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">border-image: url(:/image/warning-24x24.png);</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="msgInfo">
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>are you sure ?</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="verticalLayoutWidget">
<property name="geometry">
<rect>
<x>310</x>
<y>0</y>
<width>40</width>
<height>40</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="leftMargin">
<number>5</number>
</property>
<property name="topMargin">
<number>5</number>
</property>
<property name="rightMargin">
<number>5</number>
</property>
<property name="bottomMargin">
<number>5</number>
</property>
<item>
<widget class="QPushButton" name="closebtn">
<property name="minimumSize">
<size>
<width>30</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>30</width>
<height>30</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="widget_3" native="true">
<property name="geometry">
<rect>
<x>0</x>
<y>100</y>
<width>350</width>
<height>61</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>156</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="cancelbtn">
<property name="minimumSize">
<size>
<width>80</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>80</width>
<height>30</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>cancel</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>10</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="surebtn">
<property name="minimumSize">
<size>
<width>80</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>80</width>
<height>30</height>
</size>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string>sure</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>24</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</widget>
<resources/>
<connections/>
</ui>

54
dotlineDemo.cpp Normal file
View File

@ -0,0 +1,54 @@
/*
* Copyright (C) 2019 Tianjin KYLIN Information Technology 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, 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 <http://www.gnu.org/licenses/&gt;.
*
*/
#include "dotlineDemo.h"
#include <QDebug>
#include <QStyleOption>
#include <QPainterPath>
#include "theme.h"
DotLineDemo::DotLineDemo(QWidget *parent):
QWidget(parent)
{
this->resize(390, 310);
}
DotLineDemo::~DotLineDemo()
{
}
//绘制虚线圈
// Draw a dashed circle
void DotLineDemo::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event);
QPainter painter(this);
QStyleOption opt;
opt.init(this);
QColor mainColor;
mainColor = theme::countdownRingBackColor;
painter.save();
painter.setPen(mainColor);
painter.setBrush(mainColor);
QPainterPath bigCircle;
bigCircle.addEllipse(65, 13, 266, 266);
QPainterPath path = bigCircle ;
painter.drawPath(path);
painter.restore();
}

45
dotlineDemo.h Normal file
View File

@ -0,0 +1,45 @@
/*
* Copyright (C) 2019 Tianjin KYLIN Information Technology 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, 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 <http://www.gnu.org/licenses/&gt;.
*
*/
#ifndef DOTLINEDEMO_H
#define DOTLINEDEMO_H
#include <QWidget>
#include <QPainter>
#include <QWidget>
class DotLineDemo : public QWidget
{
Q_OBJECT
public:
explicit DotLineDemo(QWidget *parent = nullptr);
~DotLineDemo();
QWidget * widget;
protected:
//绘制虚线圈
// Draw a dashed circle
virtual void paintEvent(QPaintEvent *event);
private:
};
#endif // DOTLINEDEMO_H

437
fieldvalidutil.cpp Normal file
View File

@ -0,0 +1,437 @@
/*
* Copyright (C) 2020, Tianjin KYLIN Information Technology 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, 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 <http://www.gnu.org/licenses/&gt;.
*
*/
#include "fieldvalidutil.h"
FieldValidUtil::FieldValidUtil(QObject *parent) : QObject(parent)
{
}
bool FieldValidUtil::isNull(int value)
{
if(value==0) return true;
return false;
}
bool FieldValidUtil::isNull(QString str)
{
return str.isNull()||str.isEmpty();
}
bool FieldValidUtil::isNull(std::string str)
{
return str.empty();
}
bool FieldValidUtil::isNull(long value)
{
if(value==0) return true;
return false;
}
bool FieldValidUtil::isNull(float value)
{
if(abs(value) <= 1e-6) return true;
return false;
}
bool FieldValidUtil::isNull(double value)
{
if(abs(value) <= 1e-15) return true;
return false;
}
bool FieldValidUtil::isNotNull(int value)
{
return !isNull(value);
}
/**
* @brief
* @param value
* @param small
* @param big
* @return
*/
bool FieldValidUtil::isValueBetweenRange(int value, int small, int big)
{
return value>=small&&value<=big;
}
bool FieldValidUtil::isNotNull(QString value)
{
return !isNull(value);
}
bool FieldValidUtil::isNotNull(long value)
{
return !isNull(value);
}
#define URL_REGEX_STR "^http://([\\w-]+\\.)+[\\w-]+(/[\\w-./?%&=]*)?$"
/**
* @brief URL地址
*/
bool FieldValidUtil::isUrl(QString str)
{
return match(str, URL_REGEX_STR);
}
#define PWD_REGEX_STR "^[a-zA-Z]\\w{6,12}$"
/**
* @brief 6-12线
*/
bool FieldValidUtil::isPwd(QString str)
{
return match(str, PWD_REGEX_STR);
}
#define STRING_CHECK_REGEX_STR "^[a-zA-Z0-9\u4e00-\u9fa5-_]+$"
/**
* @brief 线
*/
bool FieldValidUtil::QStringCheck(QString str)
{
return match(str, STRING_CHECK_REGEX_STR);
}
#define EMAIL_REGEX_STR "^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$"
/**
* @brief Email地址
*/
bool FieldValidUtil::isEmail(QString str)
{
return match(str, EMAIL_REGEX_STR);
}
#define INTEGER_REGEX_STR "^[+]?\\d+$"
/**
* @brief +0
*/
bool FieldValidUtil::isInteger(QString str)
{
return match(str, INTEGER_REGEX_STR);
}
/**
* @brief 
*/
bool FieldValidUtil::isNumeric(QString str)
{
if(isFloat(str) || isInteger(str)) return true;
return false;
}
#define DIGITS_REGEX_STR "^[0-9]*$"
/**
* @brief 
*/
bool FieldValidUtil::isDigits(QString str)
{
return match(str, DIGITS_REGEX_STR);
}
#define FLOAT_REGEX_STR "^[-\\+]?\\d+(\\.\\d+)?$"
/**
* @brief 
*/
bool FieldValidUtil::isFloat(QString str)
{
return match(str, FLOAT_REGEX_STR);
}
/**
* @brief (/)
*/
bool FieldValidUtil::isTel(QString text)
{
if(isMobile(text)||isPhone(text)) return true;
return false;
}
#define PHONE_REGEX_STR "^(\\d{3,4}-?)?\\d{7,9}$"
/**
* @brief 
*/
bool FieldValidUtil::isPhone(QString text)
{
return match(text, PHONE_REGEX_STR);
}
#define MOBILE_REGEX_STR "^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\\d{8})$"
/**
* @brief 
*/
bool FieldValidUtil::isMobile(QString text)
{
if(text.length()!=11) return false;
return match(text, MOBILE_REGEX_STR);
}
#define IDCARD_NO_REGEX_STR "^(\\d{6})()?(\\d{4})(\\d{2})(\\d{2})(\\d{3})(\\w)$"
/**
* @brief 
*/
bool FieldValidUtil::isIdCardNo(QString text)
{
return match(text, IDCARD_NO_REGEX_STR);
}
#define ZIPCODE_REGEX_STR "^[0-9]{6}$"
/**
* @brief 
*/
bool FieldValidUtil::isZipCode(QString text)
{
return match(text, ZIPCODE_REGEX_STR);
}
/**
* @brief num是否等于0
*/
bool FieldValidUtil::isIntEqZero(int num)
{
return num==0;
}
/**
* @brief num是否大于0
*/
bool FieldValidUtil::isIntGtZero(int num)
{
return num>0;
}
/**
* @brief num是否大于或等于0
*/
bool FieldValidUtil::isIntGteZero(int num)
{
return num>=0;
}
/**
* @brief num是否等于0
*/
bool FieldValidUtil::isFloatEqZero(float num)
{
return isNull(num);
}
/**
* @brief num是否大于0
*/
bool FieldValidUtil::isFloatGtZero(float num)
{
return num>1e-6;
}
#define RIGHTFUL_STRING_REGEX_STR "^[A-Za-z0-9_-]+$"
/**
* @brief (a-zA-Z0-9-_)
*/
bool FieldValidUtil::isRightfulQString(QString text)
{
return match(text, RIGHTFUL_STRING_REGEX_STR);
}
#define ENGLISH_REGEX_STR "^[A-Za-z]+$"
/**
* @brief (a-zA-Z)
*/
bool FieldValidUtil::isEnglish(QString text)
{
return match(text, ENGLISH_REGEX_STR);
}
#define CHINESE_CHAR_REGEX_STR "^[\u0391-\uFFE5]+$"
/**
* @brief ()
*/
bool FieldValidUtil::isChineseChar(QString text)
{
return match(text, CHINESE_CHAR_REGEX_STR);
}
#define CHINESE_REGEX_STR "^[\u4e00-\u9fa5]+$"
/**
* @brief
*/
bool FieldValidUtil::isChinese(QString text)
{
return match(text, CHINESE_REGEX_STR);
}
/**
* @brief "-_"
*/
bool FieldValidUtil::isContainsSpecialChar(QString text)
{
if(isNull(text)) return false;
QString chars="[,`,~,!,@,#,$,%,^,&,*,(,),+,=,|,{,},',:,;,',[,],.,<,>,/,?,~,,@,#,¥,%,…,&,*,,,—,+,|,{,},【,】,,,,”,“,,。,,、,,]";
QStringList list =chars.split(",");
list<<","<<"\"";
for(QString ch : list){
if(text.contains(ch)) return true;
}
return false;
}
#define SPECIAL_STRING_FILTER_REGEX_STR "[`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~@#¥%……&*()——+|{}【】‘;:\"\"”“’。,、?]"
/**
* @brief "-_"
*/
QString FieldValidUtil::QStringFilter(QString text)
{
QString regExpr=SPECIAL_STRING_FILTER_REGEX_STR;
return replaceAll(text,regExpr);
}
/**
* @brief "-_"
*/
QString FieldValidUtil::QStringFilter(std::string text)
{
QString regExpr=SPECIAL_STRING_FILTER_REGEX_STR;
return replaceAll(text,regExpr);
}
#define SCRIPT_REGEX_STR "<[\\s]*?script[^>]*?>[\\s\\S]*?<[\\s]*?\\/[\\s]*?script[\\s]*?>"
#define STYLE_REGEX_STR "<[\\s]*?style[^>]*?>[\\s\\S]*?<[\\s]*?\\/[\\s]*?style[\\s]*?>"
#define HTML_REGEX_STR "<[^>]+>"
#define PATTERN_REGEX_STR "\\s+"
/**
* @brief html代码
*/
QString FieldValidUtil::htmlFilter(QString inputQString)
{
// 含html标签的字符串
QString htmlStr = inputQString;
QString textStr = "";
// 定义script的正则表达式{或<script[^>]*?>[\\s\\S]*?<\\/script>
QString regEx_script = SCRIPT_REGEX_STR;
// 定义style的正则表达式{或<style[^>]*?>[\\s\\S]*?<\\/style>
QString regEx_style = STYLE_REGEX_STR;
// 定义HTML标签的正则表达式
QString regEx_html = HTML_REGEX_STR;
//空白
QString patternStr = PATTERN_REGEX_STR;
htmlStr = replaceAll(htmlStr,regEx_script);
htmlStr = replaceAll(htmlStr,regEx_style);
htmlStr = replaceAll(htmlStr,regEx_html);
htmlStr = replaceAll(htmlStr,patternStr);
textStr = htmlStr;
return textStr;
}
/**
* @brief 便
*/
bool FieldValidUtil::match(QString text, QString reg)
{
if (isNull(text) || isNull(reg))
return false;
QRegExp tempRexExp(reg);
return tempRexExp.exactMatch(text);
}
/**
* @brief
*/
QString FieldValidUtil::replaceAll(QString text, QString reg)
{
return text.replace(QRegExp(reg),"");
}
QString FieldValidUtil::replaceAll(std::string text, QString reg)
{
return QString::fromStdString(text).replace(QRegExp(reg),"");
}
void FieldValidUtil::createEntityCode(QString fields)
{
QStringList list = fields.split(";");
foreach (QString var, list) {
QStringList tmp = var.split(",");
QString methodName = makeFirstUpper(tmp.at(1));
qDebug()<<"\t"<<"Q_PROPERTY ("<<tmp.at(0)<< " "<<tmp.at(1)<< " READ "<< tmp.at(1)<<"WRITE " << "set"<<methodName<<");";
}
}
QString FieldValidUtil::makeFirstUpper(QString str)
{
QChar first = str.front().toUpper();
str = str.remove(0,1);
str = first+str;
return str;
}
// 附 常用的正则表达式:
// 匹配特定数字:
// ^[1-9]d*$    //匹配正整数
// ^-[1-9]d*$   //匹配负整数
// ^-?[1-9]d*$   //匹配整数
// ^[1-9]d*|0$  //匹配非负整数(正整数 + 0
// ^-[1-9]d*|0$   //匹配非正整数(负整数 + 0
// ^[1-9]d*.d*|0.d*[1-9]d*$   //匹配正浮点数
// ^-([1-9]d*.d*|0.d*[1-9]d*)$  //匹配负浮点数
// ^-?([1-9]d*.d*|0.d*[1-9]d*|0?.0+|0)$  //匹配浮点数
// ^[1-9]d*.d*|0.d*[1-9]d*|0?.0+|0$   //匹配非负浮点数(正浮点数 + 0
// ^(-([1-9]d*.d*|0.d*[1-9]d*))|0?.0+|0$  //匹配非正浮点数(负浮点数 + 0
// 评注:处理大量数据时有用,具体应用时注意修正
//
// 匹配特定字符串:
// ^[A-Za-z]+$  //匹配由26个英文字母组成的字符串
// ^[A-Z]+$  //匹配由26个英文字母的大写组成的字符串
// ^[a-z]+$  //匹配由26个英文字母的小写组成的字符串
// ^[A-Za-z0-9]+$  //匹配由数字和26个英文字母组成的字符串
// ^w+$  //匹配由数字、26个英文字母或者下划线组成的字符串
//
// 在使用RegularExpressionValidator验证控件时的验证功能及其验证表达式介绍如下:
//
// 只能输入数字:“^[0-9]*$”
// 只能输入n位的数字“^d{n}$”
// 只能输入至少n位数字“^d{n,}$”
// 只能输入m-n位的数字“^d{m,n}$”
// 只能输入零和非零开头的数字:“^(0|[1-9][0-9]*)$”
// 只能输入有两位小数的正实数:“^[0-9]+(.[0-9]{2})?$”
// 只能输入有1-3位小数的正实数“^[0-9]+(.[0-9]{1,3})?$”
// 只能输入非零的正整数:“^+?[1-9][0-9]*$”
// 只能输入非零的负整数:“^-[1-9][0-9]*$”
// 只能输入长度为3的字符“^.{3}$”
// 只能输入由26个英文字母组成的字符串“^[A-Za-z]+$”
// 只能输入由26个大写英文字母组成的字符串“^[A-Z]+$”
// 只能输入由26个小写英文字母组成的字符串“^[a-z]+$”
// 只能输入由数字和26个英文字母组成的字符串“^[A-Za-z0-9]+$”
// 只能输入由数字、26个英文字母或者下划线组成的字符串“^w+$”
// 验证用户密码:“^[a-zA-Z]\\w{5,17}$”正确格式为以字母开头长度在6-18之间
//
// 只能包含字符、数字和下划线。
// 验证是否含有^%&,;=?$”等字符:“[^%&,;=?$x22]+”
// 只能输入汉字:“^[u4e00-u9fa5],{0,}$”
// 验证Email地址“^w+[-+.]w+)*@w+([-.]w+)*.w+([-.]w+)*$”
// 验证InternetURL“^http://([\\w-]+\\.)+[\\w-]+(/[\\w-./?%&=]*)?$”
// 验证电话号码:“^((d{3,4})|d{3,4}-)?d{7,8}$”
//
// 正确格式为“XXXX-XXXXXXX”“XXXX-XXXXXXXX”“XXX-XXXXXXX”
//
// “XXX-XXXXXXXX”“XXXXXXX”“XXXXXXXX”。
// 验证身份证号15位或18位数字“^d{15}|d{}18$”
// 验证一年的12个月“^(0?[1-9]|1[0-2])$”正确格式为“01”-“09”和“1”“12”
// 验证一个月的31天“^((0?[1-9])|((1|2)[0-9])|30|31)$” 正确格式为“01”“09”和“1”“31”。
//
// 匹配中文字符的正则表达式: [u4e00-u9fa5]
// 匹配双字节字符(包括汉字在内)[^x00-xff]
// 匹配空行的正则表达式n[s| ]*r
// 匹配HTML标记的正则表达式/< (.*)>.*|< (.*) />/
// 匹配首尾空格的正则表达式:(^s*)|(s*$)
// 匹配Email地址的正则表达式w+([-+.]w+)*@w+([-.]w+)*.w+([-.]w+)*
// 匹配网址URL的正则表达式^http://([\\w-]+\\.)+[\\w-]+(/[\\w-./?%&=]*)?$

81
fieldvalidutil.h Normal file
View File

@ -0,0 +1,81 @@
/*
* Copyright (C) 2020, Tianjin KYLIN Information Technology 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, 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 <http://www.gnu.org/licenses/&gt;.
*
*/
#ifndef FIELDVALIDUTIL_H
#define FIELDVALIDUTIL_H
#include <QObject>
#include <QRegExp>
#include <QDebug>
#include <string>
#include <regex>
class FieldValidUtil : public QObject
{
Q_OBJECT
public:
explicit FieldValidUtil(QObject *parent = nullptr);
static bool isNull(int value) ;
static bool isNull(QString str) ;
static bool isNull(std::string str) ;
static bool isNull(long value) ;
static bool isNull(float value) ;
static bool isNull(double value) ;
static bool isNotNull(int value) ;
static bool isValueBetweenRange(int value,int small,int big) ;
static bool isNotNull(QString value) ;
static bool isNotNull(long value) ;
static bool isUrl(QString str);
static bool isPwd(QString str);
static bool QStringCheck(QString str);
static bool isEmail(QString str);
static bool isInteger(QString str);
static bool isNumeric(QString str);
static bool isDigits(QString str);
static bool isFloat(QString str);
static bool isTel(QString text);
static bool isPhone(QString text);
static bool isMobile(QString text);
static bool isIdCardNo(QString text);
static bool isZipCode(QString text);
static bool isIntEqZero(int num);
static bool isIntGtZero(int num);
static bool isIntGteZero(int num);
static bool isFloatEqZero(float num);
static bool isFloatGtZero(float num);
static bool isFloatGteZero(float num);
static bool isRightfulQString(QString text);
static bool isEnglish(QString text);
static bool isChineseChar(QString text);
static bool isChinese(QString text);
static bool isContainsSpecialChar(QString text);
static QString QStringFilter(QString text);
static QString QStringFilter(std::string text);
static QString htmlFilter(QString inputQString);
static bool match(QString text, QString reg);
static QString replaceAll(QString text, QString reg);
static QString replaceAll(std::string text, QString reg);
static void createEntityCode(QString fields);
static QString makeFirstUpper(QString str);
signals:
};
#define NO_SPECIAL_CHAR "^[\u4E00-\u9FA5A-Za-z0-9_]+$"
#endif // FIELDVALIDUTIL_H

147
gsettingsubject.cpp Normal file
View File

@ -0,0 +1,147 @@
/*
* Copyright (C) 2020, Tianjin KYLIN Information Technology 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, 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 <http://www.gnu.org/licenses/&gt;.
*
*/
#include "gsettingsubject.h"
#include "theme.h"
GsettingSubject::GsettingSubject(QObject *parent) : QObject(parent)
{
iniData();
iniConnection();
}
void GsettingSubject::iniConnection()
{
if(m_styleSettings!=nullptr){
connect(m_styleSettings, &QGSettings::changed, this, [=] (const QString &key){
if(key==STYLE_NAME){
if(m_stylelist.contains(m_styleSettings->get(STYLE_NAME).toString())){
theme::themetype=1;
emit blackStyle();
}else{
theme::themetype=0;
emit whiteStyle();
}
}
if(key==STYLE_ICON_NAME || key==STYLE_ICON){
emit iconChnaged();
}
if (key == SYSTEM_FONT_SIZE) {
const int size = m_styleSettings->get(SYSTEM_FONT_EKY).toInt();
emit fontChanged(size);
}
});
}
if(m_formatSettings!=nullptr){
connect(m_formatSettings, &QGSettings::changed, this, [=] (const QString &key) {
if (key == HOUR_SYSTEM) {
QString m_timeZone = m_formatSettings->get(TIME_FORMAT_KEY).toString();
emit timeZoneChanged(m_timeZone);
}
});
}
if(m_mouseSettings!=nullptr){
connect(m_mouseSettings, &QGSettings::changed, this, [=] (const QString &key) {
if(WHEEL_KEY_HW==key||WHEEL_KEY_SP==key){
getWheelSpeed();
}
});
}
}
void GsettingSubject::iniData()
{
const QByteArray style_id(ORG_UKUI_STYLE);
m_stylelist<<STYLE_NAME_KEY_DARK<<STYLE_NAME_KEY_BLACK;
if(QGSettings::isSchemaInstalled(style_id)){
m_styleSettings = new QGSettings(style_id);
}
const QByteArray timeId(FORMAT_SCHEMA);
if (QGSettings::isSchemaInstalled(timeId)){
m_formatSettings = new QGSettings(timeId);
}
const QByteArray mouseId(MOUSE_SCHEMA);
if (QGSettings::isSchemaInstalled(mouseId)){
m_mouseSettings = new QGSettings(mouseId);
}
}
/**
* @brief
*/
void GsettingSubject::iniWidgetStyle()
{
if(m_styleSettings!=nullptr){
if(m_stylelist.contains(m_styleSettings->get(STYLE_NAME).toString())){
emit blackStyle();
}else{
emit whiteStyle();
}
}
}
/**
* @brief
*/
void GsettingSubject::iniTimeZone()
{
// 监听时区变化
if(m_formatSettings!=nullptr){
QString m_timeZone = m_formatSettings->get(TIME_FORMAT_KEY).toString();
emit timeZoneChanged(m_timeZone);
}
}
/**
* @brief
*/
void GsettingSubject::iniFontSize()
{
if(m_styleSettings!=nullptr){
//字体
if (m_styleSettings->get(SYSTEM_FONT_EKY).toInt()) {
const int size = m_styleSettings->get(SYSTEM_FONT_EKY).toInt();
emit fontChanged(size);
}
}
}
void GsettingSubject::iniMouseWheel()
{
if(m_mouseSettings!=nullptr){
getWheelSpeed();
}
}
void GsettingSubject::getWheelSpeed()
{
if (m_mouseSettings->get(WHEEL_KEY_HW).toInt()) {
const int speed = m_mouseSettings->get(WHEEL_KEY_HW).toInt();
emit mouseWheelChanged(speed);
}
if (m_mouseSettings->get(WHEEL_KEY_SP).toInt()) {
const int speed = m_mouseSettings->get(WHEEL_KEY_SP).toInt();
emit mouseWheelChanged(speed);
}
}
GsettingSubject::~GsettingSubject()
{
delete m_styleSettings;
delete m_formatSettings;
delete m_mouseSettings;
}

59
gsettingsubject.h Normal file
View File

@ -0,0 +1,59 @@
/*
* Copyright (C) 2020, Tianjin KYLIN Information Technology 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, 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 <http://www.gnu.org/licenses/&gt;.
*
*/
#ifndef GSETTINGSUBJECT_H
#define GSETTINGSUBJECT_H
#include <QObject>
#include <QGSettings>
#include "constant_class.h"
#include <QMutex>
class GsettingSubject : public QObject
{
Q_OBJECT
public:
void iniWidgetStyle();
void iniTimeZone();
void iniFontSize();
~GsettingSubject();
GsettingSubject(const GsettingSubject&)=delete;
GsettingSubject& operator=(const GsettingSubject&)=delete;
static GsettingSubject* getInstance(){
static GsettingSubject instance;
return &instance;
}
void iniMouseWheel();
signals:
void blackStyle();
void whiteStyle();
void iconChnaged();
void fontChanged(int size);
void mouseWheelChanged(int speed);
void timeZoneChanged(QString timeZone);
private:
static void iniConnect();
void iniConnection();
void iniData();
QGSettings *m_styleSettings = nullptr;
QStringList m_stylelist ;
QGSettings *m_formatSettings = nullptr;
QGSettings *m_mouseSettings = nullptr;
explicit GsettingSubject(QObject *parent = nullptr);
void getWheelSpeed();
};
#endif // GSETTINGSUBJECT_H

BIN
guide/en_US/image/1.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

BIN
guide/en_US/image/2.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

BIN
guide/en_US/image/3.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
guide/en_US/image/menu.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

22
guide/en_US/index.md Normal file
View File

@ -0,0 +1,22 @@
# Alarm
## Overview
Alarm clock is a self-developed desktop utility with simple operation. It not only supports setting alarm clock, but also is equipped with countdown and stopwatch. It can be switched through the corresponding icon at the top of the interface. Different ring reminders can be set in the alarm clock and timer.
## Open mode
**“menu”>“Alarm”** or**“taskbar”>“search”>“Alarm”**。
## basic operation
The home page of the alarm clock is shown in the figure below. Select different icons at the top of the interface to switch to the interface of alarm clock, countdown and stopwatch.
![](image/1.png)
In the alarm clock interface, click **"add"** to add an alarm clock and set the time, alarm name, repeating day and ring tone.
![](image/2.png)
Click ![](image/menu.jpg) You can open the alarm menu bar. After selecting **"setting"** in the menu bar, a setting window will pop up. You can choose whether to mute, set the time format, later reminder time and default ring tone.
![](image/3.png)
In the alarm menu bar, select **"help"** to automatically jump to the user's manual and view the operating instructions of the tool. Select **"about"** to view the current version information, and **"exit"** to close the application.

BIN
guide/ukui-clock.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

BIN
guide/zh_CN/image/1.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

BIN
guide/zh_CN/image/2.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

BIN
guide/zh_CN/image/3.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
guide/zh_CN/image/menu.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

22
guide/zh_CN/index.md Normal file
View File

@ -0,0 +1,22 @@
# 闹钟
## 概 述
闹钟是自研的一款操作简易的桌面实用工具,不仅支持设置闹钟,还配置了倒计时和秒表,通过界面顶部对应的图标可进行切换。闹钟和计时器中可设置不同的铃声提醒。
## 打开方式
**“开始菜单”>“闹钟”**或**“任务栏”>“搜索”>“闹钟”**。
## 基本操作
闹钟首页如下图所示,选择界面顶部的不同的图标可对应切换至闹钟、倒计时、秒表界面。
![](image/1.png)
在闹钟界面中,点击**“添加”**可添加闹钟,并设定时间、闹钟名、重复日及铃声。
![](image/2.png)
点击导航栏中的![](image/menu.jpg)可打开闹钟菜单栏,在菜单栏中选择**“设置”**后将弹出设置窗口,可选择是否静音,设置时间格式、稍后提醒时间和默认铃声。
![](image/3.png)
在闹钟菜单栏中,选择**“帮助”**将自动跳转至用户手册中,可查看该工具的操作说明。选择**“关于”**可查看当前版本信息,选择**“退出”**可关闭应用。

Binary file not shown.

Binary file not shown.

BIN
image/alarm.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 995 B

BIN
image/alarmselect.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 951 B

BIN
image/aptdaemon-error.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 479 B

BIN
image/count.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 990 B

BIN
image/countselect.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 961 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 219 B

BIN
image/go-up-symbolic.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 168 B

BIN
image/icon-4-16x16.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 471 B

BIN
image/kylin-alarm-clock.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -0,0 +1,57 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Generator: Adobe Illustrator 21.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="&#x56FE;&#x5C42;_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px"
y="0px" viewBox="0 0 256 256" style="enable-background:new 0 0 256 256;" xml:space="preserve">
<title>画板 18</title>
<g id="&#x63A7;&#x5236;&#x9762;&#x677F;">
<g id="&#x65F6;&#x95F4;">
<g id="_256">
<g id="&#x65F6;&#x949F;">
<path style="opacity:0.08;enable-background:new ;" d="M130,254C61.517,254,6,198.483,6,130S61.517,6,130,6
s124,55.517,124,124C253.923,198.451,198.451,253.923,130,254z"/>
<path style="opacity:0.1;enable-background:new ;" d="M130,252C62.621,252,8,197.379,8,130S62.621,8,130,8
s122,54.621,122,122C251.923,197.347,197.347,251.923,130,252z"/>
<path style="opacity:0.2;enable-background:new ;" d="M128,250C60.621,250,6,195.379,6,128S60.621,6,128,6
s122,54.621,122,122C249.923,195.347,195.347,249.923,128,250z"/>
<linearGradient id="SVGID_1_" gradientUnits="userSpaceOnUse" x1="128" y1="90" x2="128" y2="-150" gradientTransform="matrix(1 0 0 1 0 158)">
<stop offset="0" style="stop-color:#CFD8DC"/>
<stop offset="1" style="stop-color:#FFFFFF"/>
</linearGradient>
<circle style="fill:url(#SVGID_1_);" cx="128" cy="128" r="120"/>
<linearGradient id="SVGID_2_" gradientUnits="userSpaceOnUse" x1="128" y1="-150" x2="128" y2="90" gradientTransform="matrix(1 0 0 1 0 158)">
<stop offset="0" style="stop-color:#4DD0E1"/>
<stop offset="1" style="stop-color:#0097A7"/>
</linearGradient>
<path style="fill:url(#SVGID_2_);" d="M128,18c60.751,0.002,109.998,49.252,109.997,110.003
c-0.001,29.172-11.589,57.148-32.217,77.777c-43.245,42.669-112.891,42.202-155.56-1.043
C7.955,161.902,7.955,93.055,50.22,50.22C70.803,29.523,98.811,17.921,128,18 M128,8C61.726,8,8,61.726,8,128
s53.726,120,120,120s120-53.726,120-120S194.274,8,128,8z"/>
<circle style="fill:#4D5D6A;" cx="128" cy="128" r="10.53"/>
<line style="fill:none;stroke:#4D5D6A;stroke-width:8;stroke-miterlimit:10;" x1="142.32" y1="115.58" x2="84.32" y2="165.89"/>
<line style="fill:none;stroke:#4D5D6A;stroke-width:6;stroke-miterlimit:10;" x1="137.07" y1="143.8" x2="98.7" y2="47.57"/>
<line style="fill:none;stroke:#E67A70;stroke-width:3;stroke-miterlimit:10;" x1="117.47" y1="116.93" x2="182.21" y2="183.26"/>
<path style="fill:#455A64;" d="M128,133.66c-3.126,0-5.66-2.534-5.66-5.66l0,0c0.131-3.123,2.77-5.548,5.893-5.417
c2.939,0.124,5.293,2.478,5.417,5.417C133.65,131.122,131.122,133.654,128,133.66z"/>
<path style="fill:#E67A70;" d="M128,123.84c2.212,0.195,3.965,1.948,4.16,4.16c-0.113,2.295-2.064,4.064-4.359,3.951
c-2.137-0.105-3.846-1.814-3.951-3.951c0.195-2.212,1.948-3.965,4.16-4.16 M128.01,120.84c-3.871,0.195-6.965,3.289-7.16,7.16
c0.148,3.952,3.471,7.035,7.423,6.887c3.744-0.14,6.747-3.143,6.887-6.887c-0.191-3.873-3.287-6.969-7.16-7.16H128.01z"/>
<circle style="fill:#455A64;" cx="128" cy="35.65" r="8.05"/>
<circle style="fill:#455A64;" cx="128" cy="221.4" r="8.05"/>
<circle style="fill:#455A64;" cx="35.13" cy="128.53" r="8.05"/>
<circle style="fill:#455A64;" cx="220.87" cy="128.53" r="8.05"/>
<path style="fill:#4D5D6A;" d="M171.65,210l5.58-3.22l-9.79-17c-1.81,1.16-3.65,2.25-5.56,3.24L171.65,210z"/>
<path style="fill:#4D5D6A;" d="M84.35,45.95l-5.58,3.22l9.79,17c1.81-1.16,3.65-2.25,5.56-3.25L84.35,45.95z"/>
<path style="fill:#4D5D6A;" d="M49.18,78.76L46,84.34l16.93,9.78c1-1.91,2.09-3.76,3.24-5.56L49.18,78.76z"/>
<path style="fill:#4D5D6A;" d="M206.82,177.22l3.22-5.58l-16.93-9.78c-1,1.91-2.09,3.76-3.24,5.56L206.82,177.22z"/>
<path style="fill:#4D5D6A;" d="M46,171.64l3.22,5.58l17-9.79c-1.16-1.81-2.25-3.66-3.24-5.57L46,171.64z"/>
<path style="fill:#4D5D6A;" d="M210,84.34l-3.22-5.58l-17,9.79c1.16,1.81,2.25,3.66,3.24,5.57L210,84.34z"/>
<path style="fill:#4D5D6A;" d="M177.23,49.17l-5.58-3.22l-9.77,16.93c1.91,1,3.76,2.09,5.56,3.25L177.23,49.17z"/>
<path style="fill:#4D5D6A;" d="M78.77,206.81l5.58,3.19l9.78-16.93c-1.91-1-3.76-2.09-5.56-3.24L78.77,206.81z"/>
</g>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 764 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 761 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 740 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 731 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 741 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 735 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 726 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 724 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 837 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 561 B

BIN
image/miniIcon/mute-off.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 453 B

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="32px" height="32px" viewBox="0 0 32 32" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>画板</title>
<g id="画板" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="编组" transform="translate(0.000000, 0.000000)">
<rect id="矩形备份-9" fill="#D8D8D8" opacity="0" x="4" y="4" width="24" height="24" rx="12"></rect>
<path d="M16.6378433,9.22700663 C16.675945,9.26736336 16.710583,9.30435704 16.7417571,9.35143989 C16.7694674,9.39515969 16.7971778,9.44224255 16.8179605,9.4893254 C16.8387433,9.53640826 16.8560623,9.59021724 16.8664536,9.64066315 C16.876845,9.68101989 16.8803088,9.72810275 16.8803088,9.77182254 C17.4663193,9.88632919 18.0202585,10.1214148 18.5048277,10.4612501 C18.6918725,10.5924095 18.733438,10.8446391 18.5983501,11.0262444 C18.4632622,11.2078497 18.2034777,11.2482064 18.0164329,11.117047 C17.4379829,10.7101166 16.7590794,10.4982438 16.0455381,10.4982438 C14.252959,10.4982438 12.7832892,11.8651612 12.6840642,13.5819155 L12.682,13.643 L12.6823904,17.8343347 L12.678,17.897 L12.6787247,17.927236 C12.6787247,17.9356437 12.6769928,17.9432106 12.6748279,17.9507775 L12.6683333,17.9743189 C12.6648695,18.0012234 12.6614057,18.0281279 12.6510143,18.0550324 L12.6332624,18.0932872 L12.6332624,18.0932872 L12.624,18.109 L12.6332803,18.0957258 C12.6087562,18.158522 12.575293,18.2178446 12.5334473,18.2715327 L10.8812181,20.4104429 C10.7980871,20.5214239 10.8361888,20.6256788 10.8569715,20.6660355 C10.8777543,20.7063923 10.9435664,20.800558 11.0821181,20.800558 L20.9178819,20.800558 C21.0564336,20.800558 21.1222457,20.7063923 21.1430285,20.6660355 C21.1596547,20.6337502 21.187365,20.5605699 21.155221,20.475767 L21.1187819,20.4104429 L19.4665527,18.2715327 C19.3889637,18.1719861 19.3401935,18.0530682 19.323789,17.9285543 L19.3176096,17.8343347 L19.3176096,13.4421736 C19.3176096,13.2202115 19.5046544,13.0386062 19.7332648,13.0386062 C19.9332988,13.0386062 20.1015092,13.1776478 20.1404363,13.3611054 L20.1489199,13.4421736 L20.1489199,17.8074204 L21.7838437,19.9261621 C22.029773,20.2456529 22.0678747,20.6693986 21.8877575,21.0258831 C21.7245743,21.3457476 21.4108659,21.5566655 21.0536723,21.5995872 L20.9178955,21.6076927 L17.7707089,21.6076927 L17.6719237,21.6097135 C17.5186903,22.399038 16.809098,23 15.9508029,23 C15.1423066,23 14.4626837,22.4667512 14.2613508,21.7451216 L14.2292911,21.6076927 L11.0821045,21.6076927 C10.6699132,21.6076927 10.2958236,21.3857306 10.1122425,21.0258831 C9.94668024,20.6982054 9.96549414,20.3136978 10.1606139,20.0055662 L10.1833909,19.9609329 L10.1833909,19.9609329 L10.2125041,19.918165 L11.8474144,17.7994364 L11.8474144,13.7704957 C11.8474144,13.7162644 11.8485108,13.6622775 11.8506832,13.6085548 L11.8510801,13.4421736 C11.8510801,13.3976351 11.8586112,13.3547216 11.872498,13.3145742 C12.0763284,11.5502065 13.4448261,10.1224433 15.2107606,9.7751856 C15.2107606,9.73146581 15.2142244,9.68774601 15.2280796,9.64066315 C15.2350072,9.59021724 15.2523262,9.53977132 15.2731089,9.4893254 C15.2973555,9.44224255 15.3181382,9.39515969 15.3493124,9.35143989 C15.3804865,9.30435704 15.4151244,9.26736336 15.4566899,9.22700663 C15.7684313,8.92433112 16.326102,8.92433112 16.6378433,9.22700663 Z M17,21 L15,21 C15.1529169,21.5804598 15.5432574,22 16.0020081,22 C16.4485174,21.9982084 16.8468932,21.599031 17,21 L17,21 Z" id="形状结合" fill="#000000" fill-rule="nonzero"></path>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 777 B

Some files were not shown because too many files have changed in this diff Show More