-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
addfbbe
commit bf17aa6
Showing
14 changed files
with
294 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#include "bgcolor_btn.h" | ||
#include "applebutton.h" | ||
|
||
BgColor_btn::BgColor_btn(QWidget *parent) : AppleButton(BG_COLOR_BTN,parent) | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#ifndef BGCOLOR_BTN_H | ||
#define BGCOLOR_BTN_H | ||
|
||
#include <QWidget> | ||
#include "applebutton.h" | ||
|
||
class BgColor_btn : public AppleButton | ||
{ | ||
Q_OBJECT | ||
public: | ||
explicit BgColor_btn(QWidget *parent = nullptr); | ||
|
||
signals: | ||
|
||
}; | ||
|
||
#endif // BGCOLOR_BTN_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include "lrc_button.h" | ||
#include "applebutton.h" | ||
Lrc_button::Lrc_button(QWidget *parent) : AppleButton(LRC_BTN,parent) | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#ifndef LRC_BUTTON_H | ||
#define LRC_BUTTON_H | ||
|
||
#include "applebutton.h" | ||
#include <QWidget> | ||
#include <QPushButton> | ||
|
||
class Lrc_button : public AppleButton | ||
{ | ||
Q_OBJECT | ||
public: | ||
explicit Lrc_button(QWidget *parent = nullptr); | ||
|
||
signals: | ||
|
||
}; | ||
|
||
#endif // LRC_BUTTON_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#include <QFile> | ||
#include <QDir> | ||
#include <QStandardPaths> | ||
#include <QJsonObject> | ||
#include <QJsonDocument> | ||
#include <QDebug> | ||
#include "setstruct.h" | ||
#define cout qDebug().noquote()<<"["<<__FILE__<<":"<<__LINE__<<"]: " | ||
|
||
void SetStruct::setAttributes(QString bgColor,QString fontFamily,QString fontSize,QString lang){ | ||
this->bgColor = bgColor; | ||
this->fontFamily = fontFamily; | ||
this->fontSize = fontSize; | ||
this->lang = lang; | ||
|
||
} | ||
void SetStruct::setDeskLrc(QString deskLrcStatus,QString deskLrcOri){ | ||
this->deskLrcOri = deskLrcOri; | ||
this->deskLrcStatus = deskLrcStatus; | ||
} | ||
void SetStruct::initConfigFile(){ | ||
QString appDataPath = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); | ||
QDir appDir(appDataPath); | ||
if(!appDir.exists()){ | ||
//创建父级目录 | ||
appDir.mkdir(appDataPath); | ||
} | ||
this->configName = appDataPath +"/config.json"; | ||
cout<<"configName:"<<configName; | ||
//读取配置 | ||
QFile file(configName); | ||
if(!file.exists()) { | ||
qDebug()<<"config file does not exist"; | ||
return; | ||
} | ||
file.open(QIODevice::ReadOnly); | ||
QString config=file.readAll(); | ||
QJsonDocument document = QJsonDocument::fromJson(config.toUtf8()); | ||
QJsonObject jsonObject = document.object(); | ||
QString lang = jsonObject.value("lang").toString(); | ||
QString fontSize = jsonObject.value("fontSize").toString(); | ||
QString fontFamily = jsonObject.value("fontFamily").toString(); | ||
QString bgColor = jsonObject.value("bgColor").toString(); | ||
QString deskLrcOri = jsonObject.value("deskLrcOri").toString(); | ||
QString deskLrcStatus = jsonObject.value("deskLrcStatus").toString(); | ||
this->setAttributes(bgColor,fontFamily,fontSize,lang); | ||
this->setDeskLrc(deskLrcStatus,deskLrcOri); | ||
} | ||
void SetStruct::writeConfigFile(){ | ||
cout<<"modify changeset file"; | ||
QJsonObject jsonObject; | ||
jsonObject.insert("fontSize",this->fontSize); | ||
jsonObject.insert("fontFamily",this->fontFamily); | ||
jsonObject.insert("lang",this->lang); | ||
jsonObject.insert("bgColor",this->bgColor); | ||
jsonObject.insert("deskLrcStatus",this->deskLrcStatus); | ||
jsonObject.insert("deskLrcOri",this->deskLrcOri); | ||
QJsonDocument jsonDoc; | ||
jsonDoc.setObject(jsonObject); | ||
QFile file(this->configName); | ||
if(file.exists()){ | ||
file.remove(); | ||
} | ||
if(file.open(QIODevice::WriteOnly)){ | ||
file.write(jsonDoc.toJson()); | ||
} | ||
file.close(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#ifndef SETSTRUCT_H | ||
#define SETSTRUCT_H | ||
#include <QString> | ||
|
||
class SetStruct | ||
{ | ||
private: | ||
QString configName; | ||
public: | ||
QString bgColor; | ||
QString fontFamily; | ||
QString fontSize; | ||
//简体中文,English | ||
QString lang; | ||
QString deskLrcStatus; | ||
QString deskLrcOri; | ||
//语言不设置预置项 | ||
SetStruct(QString bgColor="white",QString fontFamily="Arial", | ||
QString fontSize="20",QString lang="") { | ||
this->bgColor = bgColor; | ||
this->fontFamily = fontFamily; | ||
this->fontSize = fontSize; | ||
this->lang = lang; | ||
this->deskLrcStatus = "off"; | ||
this->deskLrcOri = "HORIZONTAL"; | ||
initConfigFile(); | ||
} | ||
void setDeskLrc(QString deskLrcStatus = "off",QString deskLrcOri = "HORIZONTAL"); | ||
void setAttributes(QString bgColor,QString fontFamily,QString fontSize,QString lang); | ||
void initConfigFile(); | ||
void writeConfigFile(); | ||
|
||
}; | ||
|
||
#endif // SETSTRUCT_H |
Oops, something went wrong.