Skip to content

Commit

Permalink
First Build
Browse files Browse the repository at this point in the history
  • Loading branch information
skykeyjoker committed Jun 29, 2020
1 parent 221abaa commit 834cbd8
Show file tree
Hide file tree
Showing 12 changed files with 1,206 additions and 37 deletions.
9 changes: 9 additions & 0 deletions PKGBUILD_ASSISTANT.pro
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,16 @@ DEFINES += QT_DEPRECATED_WARNINGS
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0

SOURCES += \
dialogfilechmod.cpp \
dialogfilecopy.cpp \
dialogfiledelete.cpp \
main.cpp \
pkgbuildassistant.cpp

HEADERS += \
dialogfilechmod.h \
dialogfilecopy.h \
dialogfiledelete.h \
pkgbuildassistant.h

FORMS += \
Expand All @@ -29,3 +35,6 @@ FORMS += \
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target

RESOURCES += \
res.qrc
2 changes: 1 addition & 1 deletion PKGBUILD_ASSISTANT.pro.user
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.12.3, 2020-06-29T02:47:57. -->
<!-- Written by QtCreator 4.12.3, 2020-06-30T02:52:29. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
Expand Down
86 changes: 86 additions & 0 deletions dialogfilechmod.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#include "dialogfilechmod.h"

DialogFileChmod::DialogFileChmod(QWidget *parent, int mode) : QDialog(parent), _mode(mode)
{
setWindowIcon(QIcon(":/ico.png"));

setFixedSize(QSize(600,150));

mainLay = new QVBoxLayout(this);
le_fileName = new QLineEdit;
le_mod = new QLineEdit;
combox = new QComboBox;

QHBoxLayout *lay_edit = new QHBoxLayout;
QHBoxLayout *lay_mod = new QHBoxLayout;
QHBoxLayout *lay_btns = new QHBoxLayout;

mainLay->addLayout(lay_edit);
mainLay->addLayout(lay_mod);
mainLay->addLayout(lay_btns);

lay_edit->addWidget(new QLabel("目标路径:"));
lay_edit->addWidget(combox);
lay_edit->addWidget(le_fileName);

lay_mod->addWidget(new QLabel("目标权限:"));
lay_mod->addWidget(le_mod);
lay_mod->addStretch(3);

combox->addItem("${srcdir}");
combox->addItem("${pkgdir}");
combox->setCurrentIndex(1);

QPushButton *btn_cancel = new QPushButton("取消");
QPushButton *btn_apply = new QPushButton("确定");

lay_btns->addStretch();
lay_btns->addWidget(btn_cancel);
lay_btns->addStretch();
lay_btns->addWidget(btn_apply);
lay_btns->addStretch();

le_fileName->setText("/");

//file
if(_mode == 0)
{
setWindowTitle("更改文件权限");
}

//dir
if(_mode == 1)
{
setWindowTitle("更改文件夹权限");
}

connect(btn_cancel, &QPushButton::clicked, [=](){
int ret = QMessageBox::question(this, "确认退出", "确认退出文件权限更改吗?");

if(ret == QMessageBox::Yes)
{
close();
}
});

connect(btn_apply, &QPushButton::clicked, [=](){
if(le_fileName->text()=="/" || le_mod->text().isEmpty())
{
QMessageBox::critical(this, "错误!", "请填写目标路径及对应权限!");

return;
}

if(_mode == 0)
{
emit signalAddOperation(tr("chmod 0%1 %2").arg(le_mod->text()).arg(combox->currentText()+le_fileName->text()));
}

if(_mode == 1)
{
emit signalAddOperation(tr("chmod -R 0%1 %2").arg(le_mod->text()).arg(combox->currentText()+le_fileName->text()));
}
});


}
38 changes: 38 additions & 0 deletions dialogfilechmod.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#ifndef DIALOGFILECHMOD_H
#define DIALOGFILECHMOD_H

#include <QWidget>
#include <QDialog>
#include <QPushButton>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QLineEdit>
#include <QComboBox>
#include <QLabel>
#include <QMessageBox>

class DialogFileChmod : public QDialog
{
Q_OBJECT
public:
explicit DialogFileChmod(QWidget *parent = nullptr, int mode =0);

QVBoxLayout *mainLay;

QComboBox *combox;

QLineEdit *le_fileName;

QLineEdit *le_mod;


private:
int _mode;

signals:

void signalAddOperation(QString operation);

};

#endif // DIALOGFILECHMOD_H
118 changes: 118 additions & 0 deletions dialogfilecopy.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
#include "dialogfilecopy.h"

DialogFileCopy::DialogFileCopy(QWidget *parent, int mode) : QDialog(parent), _mode(mode)
{
setWindowIcon(QIcon(":/ico.png"));

setFixedSize(QSize(600,200));

mainLay = new QVBoxLayout(this);

QHBoxLayout *hlay_source = new QHBoxLayout;
QHBoxLayout *hlay_destination = new QHBoxLayout;
QHBoxLayout *hlay_btns = new QHBoxLayout;

check_binary = new QCheckBox("可执行文件");

mainLay->addWidget(check_binary);
mainLay->addLayout(hlay_source);
mainLay->addLayout(hlay_destination);
mainLay->addLayout(hlay_btns);

combox_source = new QComboBox;
combox_destination = new QComboBox;
le_source = new QLineEdit;
le_destination = new QLineEdit;

QPushButton *btn_cancel = new QPushButton("取消");
QPushButton *btn_apply = new QPushButton("确定");

hlay_source->addWidget(new QLabel("源路径:"));
hlay_source->addWidget(combox_source);
hlay_source->addWidget(le_source);


hlay_destination->addWidget(new QLabel("目标路径:"));
hlay_destination->addWidget(combox_destination);
hlay_destination->addWidget(le_destination);


hlay_btns->addStretch();
hlay_btns->addWidget(btn_cancel);
hlay_btns->addStretch();
hlay_btns->addWidget(btn_apply);
hlay_btns->addStretch();

combox_source->addItem("${srcdir}");
combox_source->addItem("${pkgdir}");
combox_source->setCurrentIndex(0);

combox_destination->addItem("${srcdir}");
combox_destination->addItem("${pkgdir}");
combox_destination->setCurrentIndex(1);

le_source->setText("/");
le_destination->setText("/");

check_binary->setChecked(false);

if(_mode==0) //文件
{
setWindowTitle("复制文件");

check_binary->setCheckable(true);

}

if(_mode==1) //文件夹
{
setWindowTitle("复制文件夹");

check_binary->setCheckable(false);
}


connect(btn_cancel, &QPushButton::clicked, [=](){
int ret = QMessageBox::question(this, "确认退出", "确认退出文件拷贝吗?");

if(ret == QMessageBox::Yes)
{
close();
}
});

connect(btn_apply, &QPushButton::clicked, [=](){
if(le_source->text()=="/" || le_destination->text()=="/")
{
QMessageBox::critical(this, "错误!", "请填写源路径和目标路径!");

return;
}

if(_mode == 0)
{

if(check_binary->isChecked())
{
emit signalAddOperation(tr("install -Dm755 %1 %2").arg(combox_source->currentText()+le_source->text()).arg(combox_destination->currentText()+le_destination->text()));
}
else
{
emit signalAddOperation(tr("install -Dm644 %1 %2").arg(combox_source->currentText()+le_source->text()).arg(combox_destination->currentText()+le_destination->text()));
}
}

if(_mode == 1)
{

if(le_source->text().at(le_source->text().length()-1)!='/')
{
le_source->setText(le_source->text()+"/");
}

emit signalAddOperation(tr("install -Dm644 %1* %2").arg(combox_source->currentText()+le_source->text()).arg(combox_destination->currentText()+le_destination->text()));
}
});

}

37 changes: 37 additions & 0 deletions dialogfilecopy.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#ifndef DIALOGFILECOPY_H
#define DIALOGFILECOPY_H

#include <QWidget>
#include <QDialog>
#include <QPushButton>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QLineEdit>
#include <QComboBox>
#include <QLabel>
#include <QCheckBox>
#include <QMessageBox>

class DialogFileCopy : public QDialog
{
Q_OBJECT
public:
explicit DialogFileCopy(QWidget *parent = nullptr, int mode = 0);

QVBoxLayout *mainLay;

QComboBox *combox_source;
QComboBox *combox_destination;
QCheckBox *check_binary;

QLineEdit *le_source;
QLineEdit *le_destination;

private:
int _mode;
signals:
void signalAddOperation(QString operation);

};

#endif // DIALOGFILECOPY_H
77 changes: 77 additions & 0 deletions dialogfiledelete.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#include "dialogfiledelete.h"

DialogFileDelete::DialogFileDelete(QWidget *parent, int mode) : QDialog(parent), _mode(mode)
{
setWindowIcon(QIcon(":/ico.png"));

setFixedSize(QSize(600,100));

mainLay = new QVBoxLayout(this);
le_fileName = new QLineEdit;
combox = new QComboBox;

QHBoxLayout *lay_edit = new QHBoxLayout;
QHBoxLayout *lay_btns = new QHBoxLayout;

mainLay->addLayout(lay_edit);
mainLay->addLayout(lay_btns);

lay_edit->addWidget(new QLabel("目标路径:"));
lay_edit->addWidget(combox);
lay_edit->addWidget(le_fileName);

combox->addItem("${srcdir}");
combox->addItem("${pkgdir}");
combox->setCurrentIndex(1);

QPushButton *btn_cancel = new QPushButton("取消");
QPushButton *btn_apply = new QPushButton("确定");

lay_btns->addStretch();
lay_btns->addWidget(btn_cancel);
lay_btns->addStretch();
lay_btns->addWidget(btn_apply);
lay_btns->addStretch();

le_fileName->setText("/");

//file
if(_mode == 0)
{
setWindowTitle("删除文件");
}

//dir
if(_mode == 1)
{
setWindowTitle("删除文件夹");
}

connect(btn_cancel, &QPushButton::clicked, [=](){
int ret = QMessageBox::question(this, "确认退出", "确认退出文件删除吗?");

if(ret == QMessageBox::Yes)
{
close();
}
});

connect(btn_apply, &QPushButton::clicked, [=](){
if(le_fileName->text()=="/")
{
QMessageBox::critical(this, "错误!", "请填写目标路径!");

return;
}

if(_mode == 0)
{
emit signalAddOperation(tr("rm -f %1").arg(combox->currentText()+le_fileName->text()));
}

if(_mode == 1)
{
emit signalAddOperation(tr("rm -rf %1").arg(combox->currentText()+le_fileName->text()));
}
});
}
Loading

0 comments on commit 834cbd8

Please sign in to comment.