add fileoperation
This commit is contained in:
parent
f3c89bf236
commit
1e6ee865a9
|
@ -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"));
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
Package: icon_package_name
|
||||
Version: package_version
|
||||
Architecture: all
|
||||
Maintainer: Ubuntu Kylin Team <ubuntukylin-members@lists.launchpad.net>
|
||||
Description: package_description
|
||||
|
||||
Package: cursor_package_name
|
||||
Version: package_version
|
||||
Architecture: architecture
|
||||
Maintainer: maintainer_name <maintainer_email>
|
||||
Description: package_description
|
||||
|
||||
Package: wallpaper_package_name
|
||||
Version: package_version
|
||||
Architecture: architecture
|
||||
Maintainer: maintainer_name <maintainer_email>
|
||||
Description: package_description
|
||||
|
||||
Package: global_package_name
|
||||
Version: package_version
|
||||
Architecture: architecture
|
||||
Maintainer: maintainer_name <maintainer_email>
|
||||
Description: package_description
|
|
@ -0,0 +1,9 @@
|
|||
#!/usr/bin/make -f
|
||||
|
||||
export NO_PNG_PKG_MANGLE=1
|
||||
|
||||
%:
|
||||
dh $@
|
||||
|
||||
override_dh_install:
|
||||
dh_install -X.sass-cache
|
|
@ -2,5 +2,12 @@
|
|||
<qresource prefix="/">
|
||||
<file>debiansource/cursortheme.install</file>
|
||||
<file>debiansource/control</file>
|
||||
<file>debiansource/copyright</file>
|
||||
<file>debiansource/wallpaper.install</file>
|
||||
<file>debiansource/changelog</file>
|
||||
<file>debiansource/globaltheme.install</file>
|
||||
<file>debiansource/icontheme.install</file>
|
||||
<file>debiansource/source/format</file>
|
||||
<file>debiansource/rules</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
@ -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 <your@email.com>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,17 +3,12 @@
|
|||
|
||||
#include <QObject>
|
||||
|
||||
|
||||
|
||||
#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
|
||||
|
|
|
@ -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"));
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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"));
|
||||
|
|
|
@ -11,9 +11,6 @@
|
|||
|
||||
#include "fileoperate.h"
|
||||
|
||||
#define HOMEPATH "/home/"
|
||||
|
||||
|
||||
class WidgetBase : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
|
Loading…
Reference in New Issue