From 1eff1df371855cee9f682c8a7976e389d74e5dc8 Mon Sep 17 00:00:00 2001 From: likehomedream Date: Tue, 4 Jul 2023 10:52:33 +0800 Subject: [PATCH 1/3] add some functions --- src/baseUI/baseUI.pro | 5 ++ src/baseUI/cursorthemewidget.cpp | 12 ++- src/baseUI/cursorthemewidget.h | 2 + src/baseUI/debian.qrc | 3 + src/baseUI/debiansource/changelog | 0 src/baseUI/debiansource/control | 0 src/baseUI/debiansource/copyright | 0 src/baseUI/debiansource/cursortheme.install | 0 src/baseUI/debiansource/globaltheme.install | 0 src/baseUI/debiansource/icontheme.install | 0 src/baseUI/debiansource/source/format | 1 + src/baseUI/debiansource/wallpaper.install | 0 src/baseUI/debiansources.qrc | 6 ++ src/baseUI/debmaker/debmaker.cpp | 85 ++++++++++++++++++++- src/baseUI/debmaker/debmaker.h | 16 ++++ src/baseUI/globalthemewidget.cpp | 12 ++- src/baseUI/globalthemewidget.h | 5 ++ src/baseUI/iconthemewidget.cpp | 22 ++++-- src/baseUI/iconthemewidget.h | 2 + src/baseUI/mainwindow.cpp | 68 ++++++++++++++--- src/baseUI/mainwindow.h | 21 ++++- src/baseUI/wallpaperthemewidget.cpp | 17 +++-- src/baseUI/wallpaperthemewidget.h | 5 +- src/baseUI/widgetbase.cpp | 16 +++- src/baseUI/widgetbase.h | 7 +- 25 files changed, 264 insertions(+), 41 deletions(-) create mode 100644 src/baseUI/debian.qrc create mode 100644 src/baseUI/debiansource/changelog create mode 100644 src/baseUI/debiansource/control create mode 100644 src/baseUI/debiansource/copyright create mode 100644 src/baseUI/debiansource/cursortheme.install create mode 100644 src/baseUI/debiansource/globaltheme.install create mode 100644 src/baseUI/debiansource/icontheme.install create mode 100644 src/baseUI/debiansource/source/format create mode 100644 src/baseUI/debiansource/wallpaper.install create mode 100644 src/baseUI/debiansources.qrc diff --git a/src/baseUI/baseUI.pro b/src/baseUI/baseUI.pro index 311a6ff..f7416e5 100644 --- a/src/baseUI/baseUI.pro +++ b/src/baseUI/baseUI.pro @@ -34,3 +34,8 @@ HEADERS += \ qnx: target.path = /tmp/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target + +RESOURCES += \ + debiansources.qrc + +DISTFILES += diff --git a/src/baseUI/cursorthemewidget.cpp b/src/baseUI/cursorthemewidget.cpp index f62c38f..3998212 100644 --- a/src/baseUI/cursorthemewidget.cpp +++ b/src/baseUI/cursorthemewidget.cpp @@ -7,14 +7,18 @@ CursorThemeWidget::CursorThemeWidget(QWidget *parent) : WidgetBase(parent) init(); connect(m_importButton , &QPushButton::clicked, this, [=](){ - this->importCursor(); - }); + this->importCursor(); + }); + connect(m_nameLineEdit,&QLineEdit::editingFinished,this,[=](){ + m_cursorthemename = m_nameLineEdit->text(); + emit lineEditEdited(m_cursorthemename); + }); } void CursorThemeWidget::init() { - QString name = qgetenv("USER"); - m_cursorpath = HOMEPATH +name + "/.cache/theme-build/cursor/"; + QString name = qgetenv("USER")+"/.cache/theme-build/"+WidgetBase::getSharedTimeString()+"/cursor/"; + m_cursorpath = HOMEPATH +name ; QWidget* newWidget = new QWidget(this); newWidget->setFixedHeight(291); diff --git a/src/baseUI/cursorthemewidget.h b/src/baseUI/cursorthemewidget.h index d90c552..9d2e074 100644 --- a/src/baseUI/cursorthemewidget.h +++ b/src/baseUI/cursorthemewidget.h @@ -26,10 +26,12 @@ public: Q_SIGNALS: void readyToBuild(); + void lineEditEdited(const QString& text); private: QFileDialog *m_fd; QString m_cursorpath; + QString m_cursorthemename; QListWidget *m_listwidget; }; diff --git a/src/baseUI/debian.qrc b/src/baseUI/debian.qrc new file mode 100644 index 0000000..4d8ed66 --- /dev/null +++ b/src/baseUI/debian.qrc @@ -0,0 +1,3 @@ + + + diff --git a/src/baseUI/debiansource/changelog b/src/baseUI/debiansource/changelog new file mode 100644 index 0000000..e69de29 diff --git a/src/baseUI/debiansource/control b/src/baseUI/debiansource/control new file mode 100644 index 0000000..e69de29 diff --git a/src/baseUI/debiansource/copyright b/src/baseUI/debiansource/copyright new file mode 100644 index 0000000..e69de29 diff --git a/src/baseUI/debiansource/cursortheme.install b/src/baseUI/debiansource/cursortheme.install new file mode 100644 index 0000000..e69de29 diff --git a/src/baseUI/debiansource/globaltheme.install b/src/baseUI/debiansource/globaltheme.install new file mode 100644 index 0000000..e69de29 diff --git a/src/baseUI/debiansource/icontheme.install b/src/baseUI/debiansource/icontheme.install new file mode 100644 index 0000000..e69de29 diff --git a/src/baseUI/debiansource/source/format b/src/baseUI/debiansource/source/format new file mode 100644 index 0000000..89ae9db --- /dev/null +++ b/src/baseUI/debiansource/source/format @@ -0,0 +1 @@ +3.0 (native) diff --git a/src/baseUI/debiansource/wallpaper.install b/src/baseUI/debiansource/wallpaper.install new file mode 100644 index 0000000..e69de29 diff --git a/src/baseUI/debiansources.qrc b/src/baseUI/debiansources.qrc new file mode 100644 index 0000000..3141d2f --- /dev/null +++ b/src/baseUI/debiansources.qrc @@ -0,0 +1,6 @@ + + + debiansource/cursortheme.install + debiansource/control + + diff --git a/src/baseUI/debmaker/debmaker.cpp b/src/baseUI/debmaker/debmaker.cpp index 2089a9d..d32b6b7 100644 --- a/src/baseUI/debmaker/debmaker.cpp +++ b/src/baseUI/debmaker/debmaker.cpp @@ -1,11 +1,12 @@ #include "debmaker.h" #include "mainwindow.h" +#include DebMaker::DebMaker(QObject *parent) : QObject(parent) { qDebug()<<"-------------11111-------------------------------------"; - //初始化,文件、XXX,打包操作在这里进行 + //初始化,文件、XXX,打包操作在这里进行 } @@ -13,3 +14,85 @@ void DebMaker::buildStart() { qDebug()<<"--------------------------------------------------"; } + +void DebMaker::receiveIconthemename(const QString &iconthemename) +{ + m_iconthemename = iconthemename; +} + +void DebMaker::receiveWallpaperthemename(const QString &wallpaperthemename) +{ + m_wallpaperthemename = wallpaperthemename; +} + +void DebMaker::receiveCursorthemename(const QString &cursorthemename) +{ + m_cursorthemename = cursorthemename; +} + +void DebMaker::receiveGlobalthemename(const QString &globalthemename) +{ + m_globalthemename = globalthemename; +} + +void DebMaker::initControl() +{ + QString staticContent = R"(Source: package-name +Section: misc +Priority: optional +Maintainer: Your Name +Build-Depends: debhelper (>= 10), dh-python, python3-all (>= 3.7), python3-setuptools + +Package: package-name +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends}, python3 +Description: A brief description of your package. +)"; + QString name = qgetenv("USER"); + QString filePath = HOMEPATH +name + "/.cache/theme-build/control"; + + QFile file(filePath); + if (file.open(QIODevice::WriteOnly | QIODevice::Text)) + { + QTextStream stream(&file); + stream << staticContent; + file.close(); + + qDebug() << "Control file written successfully."; + } + else + { + qDebug() << "Failed to write control file."; + } +} + +void DebMaker::initRules() +{ + QString staticContent = R"(#!/usr/bin/make -f + +export NO_PNG_PKG_MANGLE=1 + +%: + dh $@ + +override_dh_install: + dh_install -X.sass-cache +)"; + QString name = qgetenv("USER"); + QString filePath = HOMEPATH +name + "/.cache/theme-build/rules"; + + QFile file(filePath); + if (file.open(QIODevice::WriteOnly | QIODevice::Text)) + { + QTextStream stream(&file); + stream << staticContent; + file.close(); + + qDebug() << "Rules file written successfully."; + } + else + { + qDebug() << "Failed to write rules file."; + } +} + diff --git a/src/baseUI/debmaker/debmaker.h b/src/baseUI/debmaker/debmaker.h index 03c3231..ba9306b 100644 --- a/src/baseUI/debmaker/debmaker.h +++ b/src/baseUI/debmaker/debmaker.h @@ -3,6 +3,10 @@ #include + + +#define HOMEPATH "/home/"+qgetenv("USER")+"/.cache/theme-build/"; + class DebMaker : public QObject { Q_OBJECT @@ -12,6 +16,18 @@ public: signals: +public slots: + void receiveIconthemename(const QString& iconthemename); + void receiveWallpaperthemename(const QString& wallpaperthemename); + void receiveCursorthemename(const QString& cursorthemename); + void receiveGlobalthemename(const QString& globalthemename); + void initControl(); + void initRules(); +private: + QString m_iconthemename = ""; + QString m_wallpaperthemename = ""; + QString m_cursorthemename = ""; + QString m_globalthemename = ""; }; diff --git a/src/baseUI/globalthemewidget.cpp b/src/baseUI/globalthemewidget.cpp index 8ab2130..12c2d9b 100644 --- a/src/baseUI/globalthemewidget.cpp +++ b/src/baseUI/globalthemewidget.cpp @@ -12,12 +12,16 @@ GlobalThemeWidget::GlobalThemeWidget(QWidget *parent) : WidgetBase(parent) m_importButton->deleteLater(); // m_headWidget->setFixedHeight(62); init(); + connect(m_nameLineEdit,&QLineEdit::editingFinished,this,[=](){ + m_globalthemename = m_nameLineEdit->text(); + emit lineEditEdited(m_globalthemename); + }); } void GlobalThemeWidget::init() { - QString name = qgetenv("USER"); - m_globalpath = HOMEPATH +name + "/.cache/theme-build/global/"; + QString name = qgetenv("USER")+"/.cache/theme-build/"+WidgetBase::getSharedTimeString()+"/global/"; + m_globalpath = HOMEPATH +name; m_allLayout->takeAt(1); initGlobalWidget(); @@ -283,8 +287,8 @@ void GlobalThemeWidget::openFileDialog() coverfile.rename(m_globalpath+"cover.png"); }else{ QFile::copy(sourceFilePath, destinationFilePath); - QFile coverfile(m_globalpath+fileInfo.fileName()); - coverfile.rename(m_globalpath+"wallpaper.png"); + QFile wallpaperfile(m_globalpath+fileInfo.fileName()); + wallpaperfile.rename(m_globalpath+"wallpaper.png"); } diff --git a/src/baseUI/globalthemewidget.h b/src/baseUI/globalthemewidget.h index ef20d11..e6160e3 100644 --- a/src/baseUI/globalthemewidget.h +++ b/src/baseUI/globalthemewidget.h @@ -25,8 +25,13 @@ protected: bool eventFilter(QObject* obj, QEvent* event) override; signals: +Q_SIGNALS: + void readyToBuild(); + + void lineEditEdited(const QString& text); private: QString m_globalpath = ""; + QString m_globalthemename = ""; QWidget *m_globalwidget; QVBoxLayout *m_globallayout; diff --git a/src/baseUI/iconthemewidget.cpp b/src/baseUI/iconthemewidget.cpp index a321cac..e663349 100644 --- a/src/baseUI/iconthemewidget.cpp +++ b/src/baseUI/iconthemewidget.cpp @@ -16,19 +16,29 @@ IconThemeWidget::IconThemeWidget(QWidget *parent) : WidgetBase(parent) { - init(); this->initThemeLabel("创建主题图标"); this->initImportButton("导入图标"); + m_importButton->setDisabled(true); + + connect(m_importButton , &QPushButton::clicked, this, [=](){ - this->importIcons(); - }); + this->importIcons(); + }); + connect(m_nameLineEdit,&QLineEdit::editingFinished,this,[=](){ + m_iconthemename = m_nameLineEdit->text(); + emit lineEditEdited(m_iconthemename); + m_importButton->setDisabled(false); + }); + + init(); + } void IconThemeWidget::init() { - QString name = qgetenv("USER"); - m_iconpath = HOMEPATH +name + "/.cache/theme-build/icon/"; + QString name = qgetenv("USER") +"/.cache/theme-build/"+ WidgetBase::getSharedTimeString()+"/icon/"; + m_iconpath = HOMEPATH +name; QWidget* newWidget = new QWidget(this); newWidget->setFixedHeight(291); @@ -112,7 +122,7 @@ void IconThemeWidget::openFileDialog() QString selectedDirectory; selectedDirectory = m_fd->selectedFiles().first(); -// bool isLegal = ThemesCheck::checkIconsDir(selectedDirectory); + bool isLegal = ThemesCheck::checkIconsDir(selectedDirectory); // if(isLegal){ QStringList str_list = selectedDirectory.split("/"); diff --git a/src/baseUI/iconthemewidget.h b/src/baseUI/iconthemewidget.h index 82a110e..f1485ca 100644 --- a/src/baseUI/iconthemewidget.h +++ b/src/baseUI/iconthemewidget.h @@ -79,9 +79,11 @@ public: Q_SIGNALS: void readyToBuild(); + void lineEditEdited(const QString& text); private: QFileDialog *m_fd; + QString m_iconthemename; QString m_iconpath; QListView *m_listview; QStandardItemModel *m_model; diff --git a/src/baseUI/mainwindow.cpp b/src/baseUI/mainwindow.cpp index 1c6172f..79086ca 100644 --- a/src/baseUI/mainwindow.cpp +++ b/src/baseUI/mainwindow.cpp @@ -4,6 +4,7 @@ #include #include + MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { @@ -46,15 +47,26 @@ MainWindow::MainWindow(QWidget *parent) connect(m_cursorThemeWidget,&CursorThemeWidget::onBackButtonClicked,this,&MainWindow::backToCreateInterface); connect(m_globalThemeWidget,&GlobalThemeWidget::onBackButtonClicked,this,&MainWindow::backToCreateInterface); - connect(m_buildPackage,&QPushButton::clicked,this,[=](){ - qDebug()<<"-============================="; - m_debMaker = new DebMaker(this); - }); + connect(m_iconThemeWidget, &IconThemeWidget::lineEditEdited, this, &MainWindow::getIconThemeName); + connect(m_wallpaperThemeWidget, &WallpaperthemeWidget::lineEditEdited, this, &MainWindow::getWallPaperThemeName); + connect(m_cursorThemeWidget, &CursorThemeWidget::lineEditEdited, this, &MainWindow::getCursorThemeName); + connect(m_globalThemeWidget, &GlobalThemeWidget::lineEditEdited, this, &MainWindow::getGlobalThemeName); + connect(m_buildPackage,&QPushButton::clicked,this,&MainWindow::sendThemeName); + + m_debMaker = new DebMaker(this); + connect(this, &MainWindow::sendIconthemename, m_debMaker, &DebMaker::receiveIconthemename); + connect(this, &MainWindow::sendWallpaperthemename, m_debMaker, &DebMaker::receiveWallpaperthemename); + connect(this, &MainWindow::sendCursorthemename, m_debMaker, &DebMaker::receiveCursorthemename); + connect(this, &MainWindow::sendGlobalthemename, m_debMaker, &DebMaker::receiveGlobalthemename); + connect(m_buildPackage,&QPushButton::clicked,m_debMaker,&DebMaker::initControl); + connect(m_buildPackage,&QPushButton::clicked,m_debMaker,&DebMaker::initRules); } MainWindow::~MainWindow() { + FileOperate::deleteDirectoryFiles("/home/"+qgetenv("USER") +"/.cache/theme-build/"); + delete m_interface; delete m_createIconTheme; @@ -180,16 +192,48 @@ void MainWindow::createGlobalClicked() m_stackWidget->setCurrentIndex(4); } -void MainWindow::createInterfaceHidden() -{ -// m_createThemeInterface->setHidden(true); -// m_buildPackage->setHidden(true); -// m_backToCreateInterface->setHidden(false); -// m_buildThemeCheck->setHidden(false); -} - void MainWindow::backToCreateInterface() { m_stackWidget->setCurrentIndex(0); } +void MainWindow::getIconThemeName(const QString& text) +{ + m_iconthemename = text; + qDebug()<<"getIconThemeName" <initImportButton("导入图片"); init(); connect(m_importButton , &QPushButton::clicked, this, [=](){ - this->importWallpaper(); - }); + this->importWallpaper(); + }); + connect(m_nameLineEdit,&QLineEdit::editingFinished,this,[=](){ + m_wallpaperthemename = m_nameLineEdit->text(); + emit lineEditEdited(m_wallpaperthemename); + }); } void WallpaperthemeWidget::init() { - QString name = qgetenv("USER"); - m_wallpaperpath = HOMEPATH +name + "/.cache/theme-build/wallpapers/"; + QString name = qgetenv("USER") +"/.cache/theme-build/"+WidgetBase::getSharedTimeString()+"/wallpapers/"; + m_wallpaperpath = HOMEPATH +name; QWidget* newWidget = new QWidget(this); @@ -37,7 +41,7 @@ void WallpaperthemeWidget::init() QStringList fileNames = QDir(fixedPath).entryList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot); foreach (QString fileName, fileNames) { QString imgpath = m_wallpaperpath+fileName; - QListWidgetItem *item = new QListWidgetItem(/*fileName*/); + QListWidgetItem *item = new QListWidgetItem(fileName); item->setIcon(QIcon(imgpath)); m_listwidget->addItem(item); @@ -47,8 +51,7 @@ void WallpaperthemeWidget::init() int row = m_listwidget->row(item); - QString clicked_path = m_wallpaperpath+m_listwidget->currentItem()->data(Qt::DisplayRole).toString(); - + QString clicked_path = m_wallpaperpath+m_listwidget->currentItem()->data(Qt::UserRole).toString(); QFile::remove(clicked_path); m_listwidget->takeItem(row); delete item; diff --git a/src/baseUI/wallpaperthemewidget.h b/src/baseUI/wallpaperthemewidget.h index d22649a..27f0f9f 100644 --- a/src/baseUI/wallpaperthemewidget.h +++ b/src/baseUI/wallpaperthemewidget.h @@ -16,12 +16,13 @@ public: void importWallpaper(); void openFileDialog(); -signals: +Q_SIGNALS: + void lineEditEdited(const QString& text); private: QFileDialog *m_fd; QString m_wallpaperpath; - + QString m_wallpaperthemename; QListWidget *m_listwidget; }; diff --git a/src/baseUI/widgetbase.cpp b/src/baseUI/widgetbase.cpp index 48743a9..c9b549a 100644 --- a/src/baseUI/widgetbase.cpp +++ b/src/baseUI/widgetbase.cpp @@ -1,7 +1,16 @@ #include "widgetbase.h" #include +#include + +QString WidgetBase::m_date; + WidgetBase::WidgetBase(QWidget *parent) : QWidget(parent) { + if (m_date.isEmpty()) { + QDateTime currentDateTime = QDateTime::currentDateTime(); + m_date = currentDateTime.toString("yyyyMMddhhmmss"); + } + this->setAutoFillBackground(true); this->setBackgroundRole(QPalette::Base); m_allLayout = new QVBoxLayout; @@ -14,7 +23,7 @@ WidgetBase::WidgetBase(QWidget *parent) : QWidget(parent) // m_themeLabel->setText(QString("创建主题图标")); m_nameLineEdit = new QLineEdit(m_headWidget); - + m_nameLineEdit->setPlaceholderText("输入主题名称"); m_importButton = new QPushButton(m_headWidget); m_importButton->setFixedSize(QSize(96,36)); // m_importButton->setText(QString("导入图标")); @@ -61,6 +70,11 @@ WidgetBase::~WidgetBase() delete m_buttonLayout; } +QString WidgetBase::getSharedTimeString() +{ + return m_date; +} + void WidgetBase::initThemeLabel(QString text) { if(NULL != text){ diff --git a/src/baseUI/widgetbase.h b/src/baseUI/widgetbase.h index 320ce28..9fbf741 100644 --- a/src/baseUI/widgetbase.h +++ b/src/baseUI/widgetbase.h @@ -13,18 +13,23 @@ #define HOMEPATH "/home/" + class WidgetBase : public QWidget { Q_OBJECT public: explicit WidgetBase(QWidget *parent = nullptr); virtual ~WidgetBase(); - + static QString getSharedTimeString(); void initThemeLabel(QString text); void initImportButton(QString text); + private slots: +private: + static QString m_date; + protected: // virtual void init(); QVBoxLayout *m_allLayout; From f3c89bf2364151a3272bb9dd00aa8d1dc9dcf028 Mon Sep 17 00:00:00 2001 From: likehomedream Date: Tue, 11 Jul 2023 16:02:44 +0800 Subject: [PATCH 2/3] update baseUI --- src/baseUI/cursorthemewidget.cpp | 9 ++-- src/baseUI/globalthemewidget.cpp | 9 ++-- src/baseUI/iconthemewidget.cpp | 14 +++++-- src/baseUI/mainwindow.cpp | 64 +++++++++++++++++++++-------- src/baseUI/mainwindow.h | 13 ++++-- src/baseUI/wallpaperthemewidget.cpp | 9 ++-- 6 files changed, 85 insertions(+), 33 deletions(-) diff --git a/src/baseUI/cursorthemewidget.cpp b/src/baseUI/cursorthemewidget.cpp index 3998212..6bd2f47 100644 --- a/src/baseUI/cursorthemewidget.cpp +++ b/src/baseUI/cursorthemewidget.cpp @@ -9,9 +9,12 @@ CursorThemeWidget::CursorThemeWidget(QWidget *parent) : WidgetBase(parent) connect(m_importButton , &QPushButton::clicked, this, [=](){ this->importCursor(); }); - connect(m_nameLineEdit,&QLineEdit::editingFinished,this,[=](){ - m_cursorthemename = m_nameLineEdit->text(); - emit lineEditEdited(m_cursorthemename); + + connect(m_confirmButton,&QPushButton::clicked,this,[=](){ + if("" != m_nameLineEdit->text()){ + m_cursorthemename = m_nameLineEdit->text(); + emit lineEditEdited(m_cursorthemename); + } }); } diff --git a/src/baseUI/globalthemewidget.cpp b/src/baseUI/globalthemewidget.cpp index 12c2d9b..ead0527 100644 --- a/src/baseUI/globalthemewidget.cpp +++ b/src/baseUI/globalthemewidget.cpp @@ -12,9 +12,12 @@ GlobalThemeWidget::GlobalThemeWidget(QWidget *parent) : WidgetBase(parent) m_importButton->deleteLater(); // m_headWidget->setFixedHeight(62); init(); - connect(m_nameLineEdit,&QLineEdit::editingFinished,this,[=](){ - m_globalthemename = m_nameLineEdit->text(); - emit lineEditEdited(m_globalthemename); + + connect(m_confirmButton,&QPushButton::clicked,this,[=](){ + if("" != m_nameLineEdit->text()){ + m_globalthemename = m_nameLineEdit->text(); + emit lineEditEdited(m_globalthemename); + } }); } diff --git a/src/baseUI/iconthemewidget.cpp b/src/baseUI/iconthemewidget.cpp index e663349..c19abce 100644 --- a/src/baseUI/iconthemewidget.cpp +++ b/src/baseUI/iconthemewidget.cpp @@ -25,11 +25,17 @@ IconThemeWidget::IconThemeWidget(QWidget *parent) : WidgetBase(parent) connect(m_importButton , &QPushButton::clicked, this, [=](){ this->importIcons(); }); - connect(m_nameLineEdit,&QLineEdit::editingFinished,this,[=](){ - m_iconthemename = m_nameLineEdit->text(); - emit lineEditEdited(m_iconthemename); - m_importButton->setDisabled(false); + connect(m_confirmButton,&QPushButton::clicked,this,[=](){ + if("" != m_nameLineEdit->text()){ + m_iconthemename = m_nameLineEdit->text(); + emit lineEditEdited(m_iconthemename); + } }); +// connect(m_nameLineEdit,&QLineEdit::editingFinished,this,[=](){ +// m_iconthemename = m_nameLineEdit->text(); +// emit lineEditEdited(m_iconthemename); +// m_importButton->setDisabled(false); +// }); init(); diff --git a/src/baseUI/mainwindow.cpp b/src/baseUI/mainwindow.cpp index 79086ca..7a83649 100644 --- a/src/baseUI/mainwindow.cpp +++ b/src/baseUI/mainwindow.cpp @@ -47,10 +47,15 @@ MainWindow::MainWindow(QWidget *parent) connect(m_cursorThemeWidget,&CursorThemeWidget::onBackButtonClicked,this,&MainWindow::backToCreateInterface); connect(m_globalThemeWidget,&GlobalThemeWidget::onBackButtonClicked,this,&MainWindow::backToCreateInterface); - connect(m_iconThemeWidget, &IconThemeWidget::lineEditEdited, this, &MainWindow::getIconThemeName); - connect(m_wallpaperThemeWidget, &WallpaperthemeWidget::lineEditEdited, this, &MainWindow::getWallPaperThemeName); - connect(m_cursorThemeWidget, &CursorThemeWidget::lineEditEdited, this, &MainWindow::getCursorThemeName); - connect(m_globalThemeWidget, &GlobalThemeWidget::lineEditEdited, this, &MainWindow::getGlobalThemeName); + connect(m_iconThemeWidget,&IconThemeWidget::onConfirmButtonClicked,this,&MainWindow::backToCreateInterface); + connect(m_wallpaperThemeWidget,&WallpaperthemeWidget::onConfirmButtonClicked,this,&MainWindow::backToCreateInterface); + connect(m_cursorThemeWidget,&CursorThemeWidget::onConfirmButtonClicked,this,&MainWindow::backToCreateInterface); + connect(m_globalThemeWidget,&GlobalThemeWidget::onConfirmButtonClicked,this,&MainWindow::backToCreateInterface); + + connect(m_iconThemeWidget, &IconThemeWidget::lineEditEdited, this, &MainWindow::updateIconThemeName); + connect(m_wallpaperThemeWidget, &WallpaperthemeWidget::lineEditEdited, this, &MainWindow::updateWallPaperThemeName); + connect(m_cursorThemeWidget, &CursorThemeWidget::lineEditEdited, this, &MainWindow::updateCursorThemeName); + connect(m_globalThemeWidget, &GlobalThemeWidget::lineEditEdited, this, &MainWindow::updateGlobalThemeName); connect(m_buildPackage,&QPushButton::clicked,this,&MainWindow::sendThemeName); @@ -83,10 +88,7 @@ void MainWindow::initUI() // 创建 QStackedWidget 对象 m_stackWidget = new QStackedWidget(this); m_stackWidget->resize(480,580); - - // 创建网格布局 m_stackWidgetLayout = new QGridLayout(this); - // 将 QStackedWidget 对象添加到网格布局中 m_stackWidgetLayout->addWidget(m_stackWidget, 0, 0, 1, 1); m_interface = new QWidget(this); @@ -104,7 +106,15 @@ void MainWindow::initUI() QHBoxLayout *m_createIconThemeLayout = new QHBoxLayout(); QLabel *m_createIconThemeLabel = new QLabel(); m_createIconThemeLabel->setText("Create Icon theme"); + m_iconnamelabel = new QLabel(); + QLabel *iconlabel = new QLabel(); + QIcon icon = QIcon::fromTheme("kylin-boot-guide"); + iconlabel->setPixmap(icon.pixmap(QSize(24, 24))); + m_createIconThemeLayout->addWidget(m_createIconThemeLabel); + m_createIconThemeLayout->addStretch(1); + m_createIconThemeLayout->addWidget(m_iconnamelabel); + m_createIconThemeLayout->addWidget(iconlabel); m_createIconTheme->setLayout(m_createIconThemeLayout); //create cursor theme button @@ -113,7 +123,15 @@ void MainWindow::initUI() QHBoxLayout *m_createCursorThemeLayout = new QHBoxLayout(); QLabel *m_createCursorThemeLabel = new QLabel(); m_createCursorThemeLabel->setText("Create Cursor theme"); + m_cursornamelabel = new QLabel(); + QLabel *iconlabel1 = new QLabel(); + QIcon icon1 = QIcon::fromTheme("kylin-boot-guide"); + iconlabel1->setPixmap(icon1.pixmap(QSize(24, 24))); + m_createCursorThemeLayout->addWidget(m_createCursorThemeLabel); + m_createCursorThemeLayout->addStretch(1); + m_createCursorThemeLayout->addWidget(m_cursornamelabel); + m_createCursorThemeLayout->addWidget(iconlabel1); m_createCursorTheme->setLayout(m_createCursorThemeLayout); //create wallpaper theme button @@ -122,7 +140,14 @@ void MainWindow::initUI() QHBoxLayout *m_createWallpaperThemeLayout = new QHBoxLayout(); QLabel *m_createWallpaperThemeLabel = new QLabel(); m_createWallpaperThemeLabel->setText("Create Wallpaper theme"); + m_wallpapernamelabel = new QLabel(); + QLabel *iconlabel2 = new QLabel(); + QIcon icon2 = QIcon::fromTheme("kylin-boot-guide"); + iconlabel2->setPixmap(icon2.pixmap(QSize(24, 24))); m_createWallpaperThemeLayout->addWidget(m_createWallpaperThemeLabel); + m_createWallpaperThemeLayout->addStretch(1); + m_createWallpaperThemeLayout->addWidget(m_wallpapernamelabel); + m_createWallpaperThemeLayout->addWidget(iconlabel2); m_createWallpaperTheme->setLayout(m_createWallpaperThemeLayout); //create global theme button @@ -131,7 +156,15 @@ void MainWindow::initUI() QHBoxLayout *m_createGlobalThemeLayout = new QHBoxLayout(); QLabel *m_createGlobalThemeLabel = new QLabel(); m_createGlobalThemeLabel->setText("Create Global theme"); + m_globalnamelabel = new QLabel(); + QLabel *iconlabel3 = new QLabel(); + QIcon icon3 = QIcon::fromTheme("kylin-boot-guide"); + iconlabel3->setPixmap(icon3.pixmap(QSize(24, 24))); + m_createGlobalThemeLayout->addWidget(m_createGlobalThemeLabel); + m_createGlobalThemeLayout->addStretch(1); + m_createGlobalThemeLayout->addWidget(m_globalnamelabel); + m_createGlobalThemeLayout->addWidget(iconlabel3); m_createGlobalTheme->setLayout(m_createGlobalThemeLayout); m_createThemeLayout->setSpacing(0); @@ -197,29 +230,28 @@ void MainWindow::backToCreateInterface() m_stackWidget->setCurrentIndex(0); } -void MainWindow::getIconThemeName(const QString& text) +void MainWindow::updateIconThemeName(const QString& text) { m_iconthemename = text; - qDebug()<<"getIconThemeName" <setText(m_iconthemename); } -void MainWindow::getWallPaperThemeName(const QString &text) +void MainWindow::updateWallPaperThemeName(const QString &text) { m_wallpaperthemename = text; - qDebug()<<"getWallPaperThemeName" <setText(m_iconthemename); } -void MainWindow::getCursorThemeName(const QString &text) +void MainWindow::updateCursorThemeName(const QString &text) { - qDebug()<<"getCursorThemeName" <setText(m_cursorthemename); } -void MainWindow::getGlobalThemeName(const QString &text) +void MainWindow::updateGlobalThemeName(const QString &text) { m_globalthemename = text; - qDebug()<<"getGlobalThemeName" <setText(m_globalthemename); } void MainWindow::sendThemeName() diff --git a/src/baseUI/mainwindow.h b/src/baseUI/mainwindow.h index adcdbca..4be33d5 100644 --- a/src/baseUI/mainwindow.h +++ b/src/baseUI/mainwindow.h @@ -46,6 +46,11 @@ public: QPushButton *m_createWallpaperTheme; QPushButton *m_createGlobalTheme; + QLabel *m_iconnamelabel; + QLabel *m_cursornamelabel; + QLabel *m_wallpapernamelabel; + QLabel *m_globalnamelabel; + QWidget *m_buildThemeInterface; //打包按钮 QPushButton *m_buildPackage; @@ -70,10 +75,10 @@ Q_SIGNALS: public slots: void sendThemeName(); - void getIconThemeName(const QString& text); - void getWallPaperThemeName(const QString& text); - void getCursorThemeName(const QString& text); - void getGlobalThemeName(const QString& text); + void updateIconThemeName(const QString& text); + void updateWallPaperThemeName(const QString& text); + void updateCursorThemeName(const QString& text); + void updateGlobalThemeName(const QString& text); private: diff --git a/src/baseUI/wallpaperthemewidget.cpp b/src/baseUI/wallpaperthemewidget.cpp index a4157b5..9322eb2 100644 --- a/src/baseUI/wallpaperthemewidget.cpp +++ b/src/baseUI/wallpaperthemewidget.cpp @@ -9,9 +9,12 @@ WallpaperthemeWidget::WallpaperthemeWidget(QWidget *parent) : WidgetBase(parent) connect(m_importButton , &QPushButton::clicked, this, [=](){ this->importWallpaper(); }); - connect(m_nameLineEdit,&QLineEdit::editingFinished,this,[=](){ - m_wallpaperthemename = m_nameLineEdit->text(); - emit lineEditEdited(m_wallpaperthemename); + + connect(m_confirmButton,&QPushButton::clicked,this,[=](){ + if("" != m_nameLineEdit->text()){ + m_wallpaperthemename = m_nameLineEdit->text(); + emit lineEditEdited(m_wallpaperthemename); + } }); } From 1e6ee865a92109a61e02b6807a1708aa1ea7374d Mon Sep 17 00:00:00 2001 From: likehomedream Date: Thu, 13 Jul 2023 15:54:34 +0800 Subject: [PATCH 3/3] add fileoperation --- src/baseUI/cursorthemewidget.cpp | 6 +- src/baseUI/debiansource/control | 23 ++++++ src/baseUI/debiansource/rules | 9 +++ src/baseUI/debiansources.qrc | 7 ++ src/baseUI/debmaker/debmaker.cpp | 116 +++++++++++++++------------- src/baseUI/debmaker/debmaker.h | 15 ++-- src/baseUI/globalthemewidget.cpp | 8 +- src/baseUI/iconthemewidget.cpp | 15 ++-- src/baseUI/mainwindow.cpp | 5 +- src/baseUI/wallpaperthemewidget.cpp | 6 +- src/baseUI/widgetbase.h | 3 - 11 files changed, 130 insertions(+), 83 deletions(-) create mode 100755 src/baseUI/debiansource/rules diff --git a/src/baseUI/cursorthemewidget.cpp b/src/baseUI/cursorthemewidget.cpp index 6bd2f47..344410c 100644 --- a/src/baseUI/cursorthemewidget.cpp +++ b/src/baseUI/cursorthemewidget.cpp @@ -20,8 +20,8 @@ CursorThemeWidget::CursorThemeWidget(QWidget *parent) : WidgetBase(parent) void CursorThemeWidget::init() { - QString name = qgetenv("USER")+"/.cache/theme-build/"+WidgetBase::getSharedTimeString()+"/cursor/"; - m_cursorpath = HOMEPATH +name ; + QString name = "/.cache/theme-build/"+WidgetBase::getSharedTimeString()+"/cursor/"; + m_cursorpath = QDir::homePath() +name ; QWidget* newWidget = new QWidget(this); newWidget->setFixedHeight(291); @@ -62,7 +62,7 @@ void CursorThemeWidget::importCursor() { m_fd= new QFileDialog(this); m_fd->setFileMode(QFileDialog::Directory); - m_fd->setDirectory(HOMEPATH+qgetenv("USER")); + m_fd->setDirectory(QDir::homePath()); m_fd->setAcceptMode(QFileDialog::AcceptOpen); m_fd->setViewMode(QFileDialog::List); m_fd->setWindowTitle(tr("Select Import Dir")); diff --git a/src/baseUI/debiansource/control b/src/baseUI/debiansource/control index e69de29..facf0a8 100644 --- a/src/baseUI/debiansource/control +++ b/src/baseUI/debiansource/control @@ -0,0 +1,23 @@ +Package: icon_package_name +Version: package_version +Architecture: all +Maintainer: Ubuntu Kylin Team +Description: package_description + +Package: cursor_package_name +Version: package_version +Architecture: architecture +Maintainer: maintainer_name +Description: package_description + +Package: wallpaper_package_name +Version: package_version +Architecture: architecture +Maintainer: maintainer_name +Description: package_description + +Package: global_package_name +Version: package_version +Architecture: architecture +Maintainer: maintainer_name +Description: package_description diff --git a/src/baseUI/debiansource/rules b/src/baseUI/debiansource/rules new file mode 100755 index 0000000..3985b62 --- /dev/null +++ b/src/baseUI/debiansource/rules @@ -0,0 +1,9 @@ +#!/usr/bin/make -f + +export NO_PNG_PKG_MANGLE=1 + +%: + dh $@ + +override_dh_install: + dh_install -X.sass-cache diff --git a/src/baseUI/debiansources.qrc b/src/baseUI/debiansources.qrc index 3141d2f..88d7682 100644 --- a/src/baseUI/debiansources.qrc +++ b/src/baseUI/debiansources.qrc @@ -2,5 +2,12 @@ debiansource/cursortheme.install debiansource/control + debiansource/copyright + debiansource/wallpaper.install + debiansource/changelog + debiansource/globaltheme.install + debiansource/icontheme.install + debiansource/source/format + debiansource/rules diff --git a/src/baseUI/debmaker/debmaker.cpp b/src/baseUI/debmaker/debmaker.cpp index d32b6b7..7f74ba9 100644 --- a/src/baseUI/debmaker/debmaker.cpp +++ b/src/baseUI/debmaker/debmaker.cpp @@ -7,7 +7,9 @@ DebMaker::DebMaker(QObject *parent) : QObject(parent) qDebug()<<"-------------11111-------------------------------------"; //初始化,文件、XXX,打包操作在这里进行 - +// initControl(); +// initRules(); + initDebian(); } void DebMaker::buildStart() @@ -15,9 +17,31 @@ void DebMaker::buildStart() qDebug()<<"--------------------------------------------------"; } + void DebMaker::receiveIconthemename(const QString &iconthemename) { m_iconthemename = iconthemename; + + QFile resourceFile(m_contorlpath); + if (!resourceFile.open(QIODevice::ReadOnly | QIODevice::Text)) + { + qDebug() << "无法打开资源文件"; + } + + QTextStream in(&resourceFile); + QString fileContent = in.readAll(); + resourceFile.close(); + + QString variable = m_iconthemename; + fileContent.replace("icon_package_name", variable); + QFile outputFile(m_contorlpath); + if (!outputFile.open(QIODevice::WriteOnly | QIODevice::Text)) + { + qDebug() << "无法写入文件"; + } + QTextStream out(&outputFile); + out << fileContent; + outputFile.close(); } void DebMaker::receiveWallpaperthemename(const QString &wallpaperthemename) @@ -35,64 +59,52 @@ void DebMaker::receiveGlobalthemename(const QString &globalthemename) m_globalthemename = globalthemename; } -void DebMaker::initControl() +void DebMaker::initDebianFiles(const QString &sourceFilePath) { - QString staticContent = R"(Source: package-name -Section: misc -Priority: optional -Maintainer: Your Name -Build-Depends: debhelper (>= 10), dh-python, python3-all (>= 3.7), python3-setuptools -Package: package-name -Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends}, python3 -Description: A brief description of your package. -)"; - QString name = qgetenv("USER"); - QString filePath = HOMEPATH +name + "/.cache/theme-build/control"; - - QFile file(filePath); - if (file.open(QIODevice::WriteOnly | QIODevice::Text)) - { - QTextStream stream(&file); - stream << staticContent; - file.close(); - - qDebug() << "Control file written successfully."; + QFileInfo fileInfo(sourceFilePath); + QString destinationFilePath = m_filePath+fileInfo.fileName(); + if(sourceFilePath == ":/debiansource/source/format"){ + destinationFilePath= m_filePath+"source/format"; + QDir dir(m_filePath+"source/"); + if (!dir.exists()) { + dir.mkpath(m_filePath+"source/"); + } } - else - { - qDebug() << "Failed to write control file."; + QFile::copy(sourceFilePath,destinationFilePath); + changePermissions(destinationFilePath); + if(sourceFilePath == ":/debiansource/control"){ + m_contorlpath = destinationFilePath; } } -void DebMaker::initRules() +void DebMaker::initDebian() { - QString staticContent = R"(#!/usr/bin/make -f - -export NO_PNG_PKG_MANGLE=1 - -%: - dh $@ - -override_dh_install: - dh_install -X.sass-cache -)"; - QString name = qgetenv("USER"); - QString filePath = HOMEPATH +name + "/.cache/theme-build/rules"; - - QFile file(filePath); - if (file.open(QIODevice::WriteOnly | QIODevice::Text)) - { - QTextStream stream(&file); - stream << staticContent; - file.close(); - - qDebug() << "Rules file written successfully."; - } - else - { - qDebug() << "Failed to write rules file."; + m_filePath = QDir::homePath() + "/.cache/theme-build/"+WidgetBase::getSharedTimeString()+"/debian/"; + QDir dir(m_filePath); + if (!dir.exists()) { + dir.mkpath(m_filePath); } + initDebianFiles(":/debiansource/control"); + initDebianFiles(":/debiansource/copyright"); + initDebianFiles(":/debiansource/cursortheme.install"); + initDebianFiles(":/debiansource/globaltheme.install"); + initDebianFiles(":/debiansource/icontheme.install"); + initDebianFiles(":/debiansource/wallpaper.install"); + initDebianFiles(":/debiansource/rules"); + initDebianFiles(":/debiansource/source/format"); + } + +void DebMaker::changePermissions(const QString &destinationFilePath) +{ + QFile file(destinationFilePath); + if(!file.exists()){ + qDebug()<<"文件不存在?"; + } else { + file.setPermissions(QFile::ReadOwner | QFile::WriteOwner | QFile::ExeOwner | + QFile::ReadGroup | QFile::WriteGroup | QFile::ExeGroup | + QFile::ReadOther | QFile::WriteOther | QFile::ExeOther); + } +} diff --git a/src/baseUI/debmaker/debmaker.h b/src/baseUI/debmaker/debmaker.h index ba9306b..1d0a111 100644 --- a/src/baseUI/debmaker/debmaker.h +++ b/src/baseUI/debmaker/debmaker.h @@ -3,17 +3,12 @@ #include - - -#define HOMEPATH "/home/"+qgetenv("USER")+"/.cache/theme-build/"; - class DebMaker : public QObject { Q_OBJECT public: explicit DebMaker(QObject *parent = nullptr); void buildStart(); - signals: public slots: @@ -21,14 +16,18 @@ public slots: void receiveWallpaperthemename(const QString& wallpaperthemename); void receiveCursorthemename(const QString& cursorthemename); void receiveGlobalthemename(const QString& globalthemename); - void initControl(); - void initRules(); + + void initDebianFiles(const QString& sourceFilePath); + void initDebian(); + private: + void changePermissions(const QString& destinationFilePath); QString m_iconthemename = ""; QString m_wallpaperthemename = ""; QString m_cursorthemename = ""; QString m_globalthemename = ""; - + QString m_contorlpath = ""; + QString m_filePath = ""; }; #endif // DEBMAKER_H diff --git a/src/baseUI/globalthemewidget.cpp b/src/baseUI/globalthemewidget.cpp index ead0527..5ab0a7a 100644 --- a/src/baseUI/globalthemewidget.cpp +++ b/src/baseUI/globalthemewidget.cpp @@ -23,8 +23,8 @@ GlobalThemeWidget::GlobalThemeWidget(QWidget *parent) : WidgetBase(parent) void GlobalThemeWidget::init() { - QString name = qgetenv("USER")+"/.cache/theme-build/"+WidgetBase::getSharedTimeString()+"/global/"; - m_globalpath = HOMEPATH +name; + QString name = "/.cache/theme-build/"+WidgetBase::getSharedTimeString()+"/global/"; + m_globalpath = QDir::homePath() +name; m_allLayout->takeAt(1); initGlobalWidget(); @@ -193,7 +193,7 @@ void GlobalThemeWidget::importCover() m_fd->setViewMode(QFileDialog::List); m_fd->setNameFilter(filters); m_fd->setFileMode(QFileDialog::ExistingFile); - m_fd->setDirectory(HOMEPATH+qgetenv("USER")); + m_fd->setDirectory(QDir::homePath()); m_fd->setWindowTitle(tr("Select Import Wallpapers")); m_fd->setLabelText(QFileDialog::Accept, tr("Select")); m_fd->setLabelText(QFileDialog::Reject, tr("Cancel")); @@ -231,7 +231,7 @@ void GlobalThemeWidget::importWallpaper() m_fd->setViewMode(QFileDialog::List); m_fd->setNameFilter(filters); m_fd->setFileMode(QFileDialog::ExistingFile); - m_fd->setDirectory(HOMEPATH+qgetenv("USER")); + m_fd->setDirectory(QDir::homePath()); m_fd->setWindowTitle(tr("Select Import Wallpapers")); m_fd->setLabelText(QFileDialog::Accept, tr("Select")); m_fd->setLabelText(QFileDialog::Reject, tr("Cancel")); diff --git a/src/baseUI/iconthemewidget.cpp b/src/baseUI/iconthemewidget.cpp index c19abce..d6b027c 100644 --- a/src/baseUI/iconthemewidget.cpp +++ b/src/baseUI/iconthemewidget.cpp @@ -29,13 +29,12 @@ IconThemeWidget::IconThemeWidget(QWidget *parent) : WidgetBase(parent) if("" != m_nameLineEdit->text()){ m_iconthemename = m_nameLineEdit->text(); emit lineEditEdited(m_iconthemename); +// m_importButton->setDisabled(false); } }); -// connect(m_nameLineEdit,&QLineEdit::editingFinished,this,[=](){ -// m_iconthemename = m_nameLineEdit->text(); -// emit lineEditEdited(m_iconthemename); -// m_importButton->setDisabled(false); -// }); + connect(m_nameLineEdit,&QLineEdit::editingFinished,this,[=](){ + m_importButton->setDisabled(false); + }); init(); @@ -43,8 +42,8 @@ IconThemeWidget::IconThemeWidget(QWidget *parent) : WidgetBase(parent) void IconThemeWidget::init() { - QString name = qgetenv("USER") +"/.cache/theme-build/"+ WidgetBase::getSharedTimeString()+"/icon/"; - m_iconpath = HOMEPATH +name; + QString name = "/.cache/theme-build/"+ WidgetBase::getSharedTimeString()+"/icon/"; + m_iconpath = QDir::homePath() +name; QWidget* newWidget = new QWidget(this); newWidget->setFixedHeight(291); @@ -92,7 +91,7 @@ void IconThemeWidget::importIcons() // QString filters = tr("Icon files(*.png)"); m_fd= new QFileDialog(this); m_fd->setFileMode(QFileDialog::Directory); - m_fd->setDirectory(HOMEPATH+qgetenv("USER")); + m_fd->setDirectory(QDir::homePath()); m_fd->setAcceptMode(QFileDialog::AcceptOpen); m_fd->setViewMode(QFileDialog::List); // m_fd->setNameFilter(filters); diff --git a/src/baseUI/mainwindow.cpp b/src/baseUI/mainwindow.cpp index 7a83649..a1fd7f7 100644 --- a/src/baseUI/mainwindow.cpp +++ b/src/baseUI/mainwindow.cpp @@ -60,12 +60,13 @@ MainWindow::MainWindow(QWidget *parent) connect(m_buildPackage,&QPushButton::clicked,this,&MainWindow::sendThemeName); m_debMaker = new DebMaker(this); + connect(this, &MainWindow::sendIconthemename, m_debMaker, &DebMaker::receiveIconthemename); connect(this, &MainWindow::sendWallpaperthemename, m_debMaker, &DebMaker::receiveWallpaperthemename); connect(this, &MainWindow::sendCursorthemename, m_debMaker, &DebMaker::receiveCursorthemename); connect(this, &MainWindow::sendGlobalthemename, m_debMaker, &DebMaker::receiveGlobalthemename); - connect(m_buildPackage,&QPushButton::clicked,m_debMaker,&DebMaker::initControl); - connect(m_buildPackage,&QPushButton::clicked,m_debMaker,&DebMaker::initRules); +// connect(m_buildPackage,&QPushButton::clicked,m_debMaker,&DebMaker::initControl); +// connect(m_buildPackage,&QPushButton::clicked,m_debMaker,&DebMaker::initRules); } MainWindow::~MainWindow() diff --git a/src/baseUI/wallpaperthemewidget.cpp b/src/baseUI/wallpaperthemewidget.cpp index 9322eb2..fa7dd78 100644 --- a/src/baseUI/wallpaperthemewidget.cpp +++ b/src/baseUI/wallpaperthemewidget.cpp @@ -20,8 +20,8 @@ WallpaperthemeWidget::WallpaperthemeWidget(QWidget *parent) : WidgetBase(parent) void WallpaperthemeWidget::init() { - QString name = qgetenv("USER") +"/.cache/theme-build/"+WidgetBase::getSharedTimeString()+"/wallpapers/"; - m_wallpaperpath = HOMEPATH +name; + QString name = "/.cache/theme-build/"+WidgetBase::getSharedTimeString()+"/wallpapers/"; + m_wallpaperpath = QDir::homePath() +name; QWidget* newWidget = new QWidget(this); @@ -74,7 +74,7 @@ void WallpaperthemeWidget::importWallpaper() m_fd->setViewMode(QFileDialog::List); m_fd->setNameFilter(filters); m_fd->setFileMode(QFileDialog::ExistingFile); - m_fd->setDirectory(HOMEPATH+qgetenv("USER")); + m_fd->setDirectory(QDir::homePath()); m_fd->setWindowTitle(tr("Select Import Wallpapers")); m_fd->setLabelText(QFileDialog::Accept, tr("Select")); m_fd->setLabelText(QFileDialog::Reject, tr("Cancel")); diff --git a/src/baseUI/widgetbase.h b/src/baseUI/widgetbase.h index 9fbf741..11a1f3e 100644 --- a/src/baseUI/widgetbase.h +++ b/src/baseUI/widgetbase.h @@ -11,9 +11,6 @@ #include "fileoperate.h" -#define HOMEPATH "/home/" - - class WidgetBase : public QWidget { Q_OBJECT