!77 add savepathconfig
Merge pull request !77 from likehomedream/plymouthshow
This commit is contained in:
commit
78f003c9fa
|
@ -27,7 +27,7 @@ buildWidget::buildWidget(QWidget *parent)
|
||||||
if(m_buildProgressBar->value()==100){
|
if(m_buildProgressBar->value()==100){
|
||||||
this->close();
|
this->close();
|
||||||
//拷贝deb包至用户目录中
|
//拷贝deb包至用户目录中
|
||||||
QString sourceDirPath = QDir::homePath()+"/.cache/theme-build/"+FileProcess::g_date;
|
QString sourceDirPath = FileProcess::g_debPath;
|
||||||
QDir sourceDir = sourceDirPath;
|
QDir sourceDir = sourceDirPath;
|
||||||
QDir homePath =QDir::homePath();
|
QDir homePath =QDir::homePath();
|
||||||
|
|
||||||
|
|
|
@ -135,6 +135,11 @@ void Bridge::grubPathChanged(QString path)
|
||||||
+m_time+"/src/grubTheme","grub");
|
+m_time+"/src/grubTheme","grub");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Bridge::savePathConfigChanged(QString path)
|
||||||
|
{
|
||||||
|
m_configfilemanager->modifySavePathConf(path);
|
||||||
|
}
|
||||||
|
|
||||||
void Bridge::createConfig()
|
void Bridge::createConfig()
|
||||||
{
|
{
|
||||||
m_configfilemanager->createConf(QDir::homePath() + "/.cache/theme-build/"
|
m_configfilemanager->createConf(QDir::homePath() + "/.cache/theme-build/"
|
||||||
|
@ -156,7 +161,12 @@ void Bridge::createGrub()
|
||||||
void Bridge::createPlymouth()
|
void Bridge::createPlymouth()
|
||||||
{
|
{
|
||||||
m_configfilemanager->copyAllPictoCacheDir(m_plymouthdir,QDir::homePath()+"/.cache/theme-build/"
|
m_configfilemanager->copyAllPictoCacheDir(m_plymouthdir,QDir::homePath()+"/.cache/theme-build/"
|
||||||
+m_time+"/src/plymouthTheme");
|
+m_time+"/src/plymouthTheme");
|
||||||
|
}
|
||||||
|
|
||||||
|
void Bridge::createSavePathConfig()
|
||||||
|
{
|
||||||
|
m_configfilemanager->createSavePathConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bridge::startCopy()
|
void Bridge::startCopy()
|
||||||
|
|
|
@ -28,9 +28,11 @@ public:
|
||||||
void timeCursorMapChanged(QMap<QString, QString> *timecursormap);
|
void timeCursorMapChanged(QMap<QString, QString> *timecursormap);
|
||||||
void plymouthPathChanged(QString path);
|
void plymouthPathChanged(QString path);
|
||||||
void grubPathChanged(QString path);
|
void grubPathChanged(QString path);
|
||||||
|
void savePathConfigChanged(QString path);
|
||||||
void createConfig();
|
void createConfig();
|
||||||
void createGrub();
|
void createGrub();
|
||||||
void createPlymouth();
|
void createPlymouth();
|
||||||
|
void createSavePathConfig();
|
||||||
void startCopy();
|
void startCopy();
|
||||||
void updateIconCache(QMap<QString, QString> *iconsmaps,QString icontype);
|
void updateIconCache(QMap<QString, QString> *iconsmaps,QString icontype);
|
||||||
signals:
|
signals:
|
||||||
|
|
|
@ -72,6 +72,32 @@ bool ConfigFileManager::createConf(QDir cachedir)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ConfigFileManager::createSavePathConfig()
|
||||||
|
{
|
||||||
|
QString dirPath = QDir::homePath() + "/.cache/theme-build";
|
||||||
|
QString filePath = dirPath + "/savepath.conf";
|
||||||
|
|
||||||
|
QDir dir;
|
||||||
|
if (!dir.exists(dirPath)) {
|
||||||
|
dir.mkpath(dirPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
QFile file(filePath);
|
||||||
|
|
||||||
|
if (!file.exists()) {
|
||||||
|
if (file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||||
|
QTextStream stream(&file);
|
||||||
|
stream << QDir::homePath() + "/桌面";
|
||||||
|
file.close();
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 修改radius的json配置文件
|
* @brief 修改radius的json配置文件
|
||||||
*
|
*
|
||||||
|
@ -386,6 +412,25 @@ bool ConfigFileManager::modifywindowRadiusConf(int windowradius,QString confFile
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ConfigFileManager::modifySavePathConf(QString savePath)
|
||||||
|
{
|
||||||
|
QString dirPath = QDir::homePath() + "/.cache/theme-build";
|
||||||
|
QString filePath = dirPath + "/savepath.conf";
|
||||||
|
|
||||||
|
QFile file(filePath);
|
||||||
|
|
||||||
|
// Open the file in WriteOnly mode to clear the content
|
||||||
|
if (file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)) {
|
||||||
|
QTextStream stream(&file);
|
||||||
|
stream << savePath;
|
||||||
|
file.close();
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
// Handle the case when the file cannot be opened for writing
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief 复制文件内容到另一个文件
|
* @brief 复制文件内容到另一个文件
|
||||||
*
|
*
|
||||||
|
|
|
@ -21,6 +21,7 @@ public:
|
||||||
|
|
||||||
bool createJson(QDir cachedir);
|
bool createJson(QDir cachedir);
|
||||||
bool createConf(QDir cachedir);
|
bool createConf(QDir cachedir);
|
||||||
|
bool createSavePathConfig();
|
||||||
bool modifyRadiusJson(int radius,QString jsonFilePath);
|
bool modifyRadiusJson(int radius,QString jsonFilePath);
|
||||||
|
|
||||||
bool modifyAccentColorConf(QColor accentcolor,QString confFilePath);
|
bool modifyAccentColorConf(QColor accentcolor,QString confFilePath);
|
||||||
|
@ -29,6 +30,9 @@ public:
|
||||||
bool modifyWidgetStyleConf(QString WidgetStyle,QString confFilePath);
|
bool modifyWidgetStyleConf(QString WidgetStyle,QString confFilePath);
|
||||||
bool modifyTransparencyConf(int transparency,QString confFilePath);
|
bool modifyTransparencyConf(int transparency,QString confFilePath);
|
||||||
bool modifywindowRadiusConf(int windowradius,QString confFilePath);
|
bool modifywindowRadiusConf(int windowradius,QString confFilePath);
|
||||||
|
|
||||||
|
bool modifySavePathConf(QString savePath);
|
||||||
|
|
||||||
bool copyFileContent(const QString& sourceFilePath, const QString& destinationFilePath);
|
bool copyFileContent(const QString& sourceFilePath, const QString& destinationFilePath);
|
||||||
bool copyIcontoCacheDir(QMap<QString, QString> *map,QDir cachedir);
|
bool copyIcontoCacheDir(QMap<QString, QString> *map,QDir cachedir);
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,8 @@ QString FileProcess::g_themeENName;
|
||||||
QString FileProcess::g_builderName;
|
QString FileProcess::g_builderName;
|
||||||
QString FileProcess::g_builderMailName;
|
QString FileProcess::g_builderMailName;
|
||||||
QString FileProcess::g_createThemeType;
|
QString FileProcess::g_createThemeType;
|
||||||
|
QString FileProcess::g_debPath;
|
||||||
|
|
||||||
FileProcess::FileProcess()
|
FileProcess::FileProcess()
|
||||||
{
|
{
|
||||||
//创建缓存目录
|
//创建缓存目录
|
||||||
|
|
|
@ -24,6 +24,7 @@ public:
|
||||||
static QString g_builderName;
|
static QString g_builderName;
|
||||||
static QString g_builderMailName;
|
static QString g_builderMailName;
|
||||||
static QString g_createThemeType;
|
static QString g_createThemeType;
|
||||||
|
static QString g_debPath;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QDir m_builder;
|
QDir m_builder;
|
||||||
|
|
|
@ -7,7 +7,7 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
setWindowFlags(Qt::FramelessWindowHint);
|
setWindowFlags(Qt::FramelessWindowHint);
|
||||||
m_bridge = Bridge::getInstance();
|
m_bridge = Bridge::getInstance();
|
||||||
FileProcess();
|
FileProcess();
|
||||||
|
m_bridge->createSavePathConfig();
|
||||||
initUI();
|
initUI();
|
||||||
m_titlebar = new TitleBar(this);
|
m_titlebar = new TitleBar(this);
|
||||||
QVBoxLayout *layout = new QVBoxLayout(this);
|
QVBoxLayout *layout = new QVBoxLayout(this);
|
||||||
|
@ -91,6 +91,10 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
connect(m_maininterface, &MainInterface::gohomesignals, this, &MainWindow::onGoHomeClicked);
|
connect(m_maininterface, &MainInterface::gohomesignals, this, &MainWindow::onGoHomeClicked);
|
||||||
|
connect(m_titlebar,&TitleBar::savePathUpdate,this,[&](const QString& path){
|
||||||
|
FileProcess::g_debPath= path;
|
||||||
|
m_bridge->savePathConfigChanged(path);
|
||||||
|
});
|
||||||
this->setContentsMargins(0,2,0,0);
|
this->setContentsMargins(0,2,0,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,7 +155,9 @@ void MainWindow::initUI()
|
||||||
m_historywidget = new HistoryWidget();
|
m_historywidget = new HistoryWidget();
|
||||||
// m_historywidget->setMinimumHeight(2000);
|
// m_historywidget->setMinimumHeight(2000);
|
||||||
QDir builderDir = QDir::homePath()+"/.cache/theme-build/";
|
QDir builderDir = QDir::homePath()+"/.cache/theme-build/";
|
||||||
if(builderDir.isEmpty()){
|
QFileInfoList fileInfoList = builderDir.entryInfoList(QDir::NoDotAndDotDot | QDir::Files | QDir::Dirs);
|
||||||
|
|
||||||
|
if(fileInfoList.isEmpty() || (fileInfoList.count() == 1 && fileInfoList.first().isFile() && fileInfoList.first().fileName() == "savepath.conf")){
|
||||||
alllayout->addStretch(1);
|
alllayout->addStretch(1);
|
||||||
alllayout->addLayout(layout);
|
alllayout->addLayout(layout);
|
||||||
alllayout->addStretch(1);
|
alllayout->addStretch(1);
|
||||||
|
@ -265,9 +271,12 @@ void MainWindow::initUI()
|
||||||
|
|
||||||
QFileSystemWatcher* watcher = new QFileSystemWatcher(this);
|
QFileSystemWatcher* watcher = new QFileSystemWatcher(this);
|
||||||
watcher->addPath(builderDir.absolutePath());
|
watcher->addPath(builderDir.absolutePath());
|
||||||
connect(watcher, &QFileSystemWatcher::directoryChanged, this, [=](const QString& path) {
|
connect(watcher, &QFileSystemWatcher::directoryChanged, this, [=]() {
|
||||||
m_historywidget->updateHistoryDir();
|
m_historywidget->updateHistoryDir();
|
||||||
if (builderDir.isEmpty()) {
|
|
||||||
|
QFileInfoList fileInfoList = builderDir.entryInfoList(QDir::NoDotAndDotDot | QDir::Files | QDir::Dirs);
|
||||||
|
|
||||||
|
if(fileInfoList.isEmpty() || (fileInfoList.count() == 1 && fileInfoList.first().isFile() && fileInfoList.first().fileName() == "savepath.conf")) {
|
||||||
alllayout->removeWidget(m_guideWidget);
|
alllayout->removeWidget(m_guideWidget);
|
||||||
alllayout->removeItem(alllayout->itemAt(alllayout->count()-1));
|
alllayout->removeItem(alllayout->itemAt(alllayout->count()-1));
|
||||||
m_historywidget->setVisible(false);
|
m_historywidget->setVisible(false);
|
||||||
|
|
|
@ -9,7 +9,7 @@ SavePathDialog::SavePathDialog(QWidget *parent) :
|
||||||
QWidget*mainwindow = mainWidget();
|
QWidget*mainwindow = mainWidget();
|
||||||
QGridLayout *layout = new QGridLayout(mainwindow);
|
QGridLayout *layout = new QGridLayout(mainwindow);
|
||||||
m_pathLabel = new QLabel;
|
m_pathLabel = new QLabel;
|
||||||
m_pathLabel->setText(tr("Storage Path:")+m_savepath);
|
m_pathLabel->setText(tr("Storage Path:")+getSavePath());
|
||||||
m_modifyBtn = new QPushButton;
|
m_modifyBtn = new QPushButton;
|
||||||
m_modifyBtn->setFixedSize(QSize(88,33));
|
m_modifyBtn->setFixedSize(QSize(88,33));
|
||||||
m_modifyBtn->setText(tr("Modify"));
|
m_modifyBtn->setText(tr("Modify"));
|
||||||
|
@ -31,12 +31,30 @@ void SavePathDialog::updateLabel(QString savepath)
|
||||||
m_pathLabel->setToolTip(savepath);
|
m_pathLabel->setToolTip(savepath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString SavePathDialog::getSavePath()
|
||||||
|
{
|
||||||
|
QString dirPath = QDir::homePath() + "/.cache/theme-build";
|
||||||
|
QString filePath = dirPath + "/savepath.conf";
|
||||||
|
|
||||||
|
QFile file(filePath);
|
||||||
|
|
||||||
|
if (file.exists() && file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
|
QTextStream stream(&file);
|
||||||
|
QString savePath = stream.readAll();
|
||||||
|
file.close();
|
||||||
|
|
||||||
|
return savePath;
|
||||||
|
} else {
|
||||||
|
qDebug() << "Error: File does not exist or cannot be opened.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void SavePathDialog::onModifyBtnClicked()
|
void SavePathDialog::onModifyBtnClicked()
|
||||||
{
|
{
|
||||||
QString newFilePath = QFileDialog::getExistingDirectory(this);
|
QString newFilePath = QFileDialog::getExistingDirectory(this);
|
||||||
if(newFilePath != nullptr){
|
if(newFilePath != nullptr){
|
||||||
m_savepath = newFilePath;
|
m_savepath = newFilePath;
|
||||||
//FIX ME m_savepath保存在哪里?哪里需要用?
|
emit savePathUpdate(newFilePath);
|
||||||
this->updateLabel(newFilePath);
|
this->updateLabel(newFilePath);
|
||||||
m_confirmBtn->setEnabled(true);
|
m_confirmBtn->setEnabled(true);
|
||||||
connect(m_confirmBtn,&QPushButton::clicked,this,&SavePathDialog::close);
|
connect(m_confirmBtn,&QPushButton::clicked,this,&SavePathDialog::close);
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#ifndef SAVEPATHWIDGET_H
|
#ifndef SAVEPATHWIDGET_H
|
||||||
#define SAVEPATHWIDGET_H
|
#define SAVEPATHWIDGET_H
|
||||||
#include <kaboutdialog.h>
|
#include <kaboutdialog.h>
|
||||||
|
#include "../fileProcess/fileprocess.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
@ -13,8 +15,9 @@ class SavePathDialog : public kdk::KDialog
|
||||||
public:
|
public:
|
||||||
explicit SavePathDialog(QWidget *parent = nullptr);
|
explicit SavePathDialog(QWidget *parent = nullptr);
|
||||||
void updateLabel(QString savepath);
|
void updateLabel(QString savepath);
|
||||||
|
QString getSavePath();
|
||||||
signals:
|
signals:
|
||||||
|
void savePathUpdate(const QString& filePath);
|
||||||
public slots:
|
public slots:
|
||||||
void onModifyBtnClicked();
|
void onModifyBtnClicked();
|
||||||
|
|
||||||
|
|
|
@ -77,6 +77,10 @@ TitleBar::TitleBar(QWidget *parent) : QWidget(parent)
|
||||||
connect(saveAction,&QAction::triggered,this,[=](){
|
connect(saveAction,&QAction::triggered,this,[=](){
|
||||||
m_savepathdlg = new SavePathDialog();
|
m_savepathdlg = new SavePathDialog();
|
||||||
m_savepathdlg->show();
|
m_savepathdlg->show();
|
||||||
|
connect(m_savepathdlg,&SavePathDialog::savePathUpdate,this,[&](const QString& path){
|
||||||
|
|
||||||
|
emit savePathUpdate(path);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
connect(aboutAction,&QAction::triggered,this,[=](){
|
connect(aboutAction,&QAction::triggered,this,[=](){
|
||||||
AboutDialog *dlg = new AboutDialog(this);
|
AboutDialog *dlg = new AboutDialog(this);
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define TITLEBAR_H
|
#define TITLEBAR_H
|
||||||
#include "./module/aboutdialog.h"
|
#include "./module/aboutdialog.h"
|
||||||
#include "./module/savepathdialog.h"
|
#include "./module/savepathdialog.h"
|
||||||
|
#include "fileProcess/fileprocess.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
@ -23,7 +24,7 @@ public:
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void gohomesignal(); // 声明自定义信号
|
void gohomesignal(); // 声明自定义信号
|
||||||
|
void savePathUpdate(const QString& filePath);
|
||||||
private:
|
private:
|
||||||
bool m_ismaximized;
|
bool m_ismaximized;
|
||||||
QToolButton *m_optionbtn = nullptr; // 菜单选项
|
QToolButton *m_optionbtn = nullptr; // 菜单选项
|
||||||
|
|
Loading…
Reference in New Issue