修改bug 128089 128065
This commit is contained in:
parent
e5c5fee9e3
commit
d66b4a1f6a
|
@ -24,6 +24,7 @@ SOURCES += \
|
|||
src/include/menumodule.cpp \
|
||||
src/include/theme.cpp \
|
||||
src/include/utils.cpp \
|
||||
src/line.cpp \
|
||||
src/main.cpp \
|
||||
src/mainwindow.cpp \
|
||||
src/page1.cpp \
|
||||
|
@ -45,6 +46,7 @@ HEADERS += \
|
|||
src/include/menumodule.h \
|
||||
src/include/theme.h \
|
||||
src/include/utils.h \
|
||||
src/line.h \
|
||||
src/mainwindow.h \
|
||||
src/page1.h \
|
||||
src/page2.h \
|
||||
|
@ -76,7 +78,7 @@ desktop.files = kylin-usb-creator.desktop
|
|||
INSTALLS += target desktop icons schemes
|
||||
CONFIG += link_pkgconfig
|
||||
|
||||
PKGCONFIG += gsettings-qt
|
||||
PKGCONFIG += gsettings-qt kysdk-waylandhelper
|
||||
# translations
|
||||
#qm_files.files = src/translations/*.pm
|
||||
#qm_files.path = /usr/share/kylin
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
#include "line.h"
|
||||
#include <QComboBox>
|
||||
line::line()
|
||||
{
|
||||
this->setMouseTracking(true);
|
||||
|
||||
}
|
||||
void line::leaveEvent(QEvent *event)
|
||||
{
|
||||
}
|
||||
void line::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
if(event->button()==Qt::LeftButton){
|
||||
}
|
||||
QLineEdit::mousePressEvent(event);
|
||||
}
|
||||
void line::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
|
||||
QLineEdit::mouseReleaseEvent(event);
|
||||
|
||||
}
|
||||
void line::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
{
|
||||
|
||||
}
|
||||
void line::mouseMoveEvent(QMouseEvent *e)
|
||||
{
|
||||
QLineEdit::mouseMoveEvent(e);
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
#ifndef LINE_H
|
||||
#define LINE_H
|
||||
#include <QLineEdit>
|
||||
#include <QDebug>
|
||||
#include <QMouseEvent>
|
||||
class line : public QLineEdit
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
line();
|
||||
|
||||
protected:
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
void mouseReleaseEvent(QMouseEvent *event);
|
||||
void mouseMoveEvent(QMouseEvent *e);
|
||||
|
||||
void mouseDoubleClickEvent(QMouseEvent *event);
|
||||
void leaveEvent(QEvent *event);
|
||||
};
|
||||
|
||||
#endif // LINE_H
|
|
@ -21,6 +21,7 @@
|
|||
#include "include/qtsingleapplication.h"
|
||||
#include <QTranslator>
|
||||
#include <QDebug>
|
||||
#include <QGuiApplication>
|
||||
#include <QApplication>
|
||||
#include <QStringList>
|
||||
#include <QStandardPaths>
|
||||
|
@ -29,6 +30,8 @@
|
|||
#include <QLibraryInfo>
|
||||
#include "include/xatom-helper.h"
|
||||
#include "mainwindow.h"
|
||||
#include "ukuistylehelper/ukuistylehelper.h"
|
||||
#include "windowmanager/windowmanager.h"
|
||||
#if (QT_VERSION <= QT_VERSION_CHECK(5,15,0))
|
||||
#include "dbusadaptor.h"
|
||||
#endif
|
||||
|
@ -47,6 +50,8 @@ void activeMainwindow()
|
|||
}
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
bool isWayland=false;
|
||||
|
||||
// init log module
|
||||
initUkuiLog4qt("usb-boot-maker");
|
||||
QString parm = "--";
|
||||
|
@ -108,9 +113,16 @@ int main(int argc, char *argv[])
|
|||
}else {
|
||||
MainWindow w(NULL,parm);
|
||||
w.handleIconClickedSub();
|
||||
w.show();
|
||||
|
||||
// center window
|
||||
int sw=QGuiApplication::primaryScreen()->availableGeometry().width();
|
||||
int sh=QGuiApplication::primaryScreen()->availableGeometry().height();
|
||||
kdk::WindowManager::setGeometry(w.windowHandle(),QRect((sw-w.width())/2,(sh-w.height())/2,w.width(),w.height()));
|
||||
|
||||
QObject::connect(&a,SIGNAL(messageReceived(const QString&)),&w,SLOT(handleIconClickedSub()));
|
||||
return a.exec();
|
||||
|
||||
}
|
||||
return a.exec();
|
||||
}
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
*/
|
||||
#include "mainwindow.h"
|
||||
#include "include/xatom-helper.h"
|
||||
#include "ukuistylehelper/ukuistylehelper.h"
|
||||
#include "windowmanager/windowmanager.h"
|
||||
MainWindow::MainWindow(QWidget *parent,QString isoPath)
|
||||
: QWidget(parent)
|
||||
{
|
||||
|
@ -141,10 +143,12 @@ void MainWindow::setIconchange(){
|
|||
|
||||
}
|
||||
void MainWindow::init(){
|
||||
// bool isWayland=false;
|
||||
this->setWindowTitle(tr("usb boot maker"));
|
||||
this->setFixedSize(472,648);
|
||||
// 在屏幕中央显示
|
||||
|
||||
QRect availableGeometry = qApp->primaryScreen()->availableGeometry();
|
||||
qInfo()<<"148availableGeometry"<<availableGeometry;
|
||||
this->move((availableGeometry.width()-this->width())/2,(availableGeometry.height()- this->height())/2);
|
||||
m_DaemonIpcDbus = new DaemonIpcDbus();
|
||||
// 连结systembus进程消息
|
||||
|
@ -300,6 +304,8 @@ void MainWindow::handleIconClickedSub()
|
|||
hints.decorations = MWM_DECOR_BORDER;
|
||||
XAtomHelper::getInstance()->setWindowMotifHint(this->winId(), hints);
|
||||
// this->isActiveWindow()
|
||||
// this->move((QApplication::desktop()->width() - this->width())/2,(QApplication::desktop()->height() - this->height())/2);
|
||||
|
||||
QDesktopWidget* m = QApplication::desktop();
|
||||
QRect desk_rect = m->screenGeometry(m->screenNumber(QCursor::pos()));
|
||||
int desk_x = desk_rect.width();
|
||||
|
@ -395,6 +401,7 @@ void MainWindow::dealAuthorityStatus(QString status){
|
|||
makeStart();
|
||||
}else{
|
||||
// 授权失败,回到到page1
|
||||
|
||||
}
|
||||
}
|
||||
void MainWindow::setThemeDark()
|
||||
|
@ -433,7 +440,10 @@ void MainWindow::dragEnterEvent(QDragEnterEvent *event){
|
|||
// }
|
||||
return QWidget::dragEnterEvent(event);
|
||||
}
|
||||
|
||||
void MainWindow::dragLeaveEvent(QDragLeaveEvent *event){
|
||||
page1->dragLeaveEvent(event);
|
||||
return QWidget::dragLeaveEvent(event);
|
||||
}
|
||||
void MainWindow::dropEvent(QDropEvent *event){
|
||||
// if(pageIndex == PAGE_ONE){
|
||||
if(page1){
|
||||
|
|
|
@ -101,6 +101,8 @@ private:
|
|||
|
||||
void keyPressEvent(QKeyEvent* event);
|
||||
void dragEnterEvent(QDragEnterEvent*);
|
||||
void dragLeaveEvent(QDragLeaveEvent*);
|
||||
// void eventFilter()
|
||||
void dropEvent(QDropEvent*);
|
||||
|
||||
void init(); //初始化mainwindow相关的设置
|
||||
|
|
|
@ -26,47 +26,43 @@ Page1::Page1()
|
|||
}
|
||||
void Page1::initControlQss()
|
||||
{
|
||||
edit = new QLineEdit;
|
||||
topwidget1 = new QWidget(this);
|
||||
topwidget1->setFixedSize(450,300);
|
||||
topwidget1->hide();
|
||||
edit = new line;
|
||||
edit->installEventFilter(this);
|
||||
// topwidget1 = new QWidget(this);
|
||||
// topwidget1->setFixedSize(450,300);
|
||||
// topwidget1->hide();
|
||||
topwidget=new QWidget(this);
|
||||
top=new topborder(this);
|
||||
top->hide();
|
||||
top->setGeometry(40,55,500,400);
|
||||
topwidget->setFixedSize(450,300);
|
||||
// tabUdisk = new QLabel(topwidget);
|
||||
tabUdisk1 = new QLabel(topwidget1);
|
||||
// tabUdisk->setFixedSize(192,192);
|
||||
fram=new QFrame;
|
||||
fram->setFrameShape(QFrame::NoFrame);
|
||||
//fram->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
// top=new topborder(this);
|
||||
// top->hide();
|
||||
fram->setGeometry(40,95,500,400);
|
||||
fram->hide();
|
||||
topwidget->setFixedSize(450,320);
|
||||
tabUdisk1 = new QLabel(fram);
|
||||
tabUdisk1->setFixedSize(127,127);
|
||||
urlIso=new QLabel(topwidget);
|
||||
urlIso1=new QLabel(topwidget1);
|
||||
urlIso1=new QLabel(fram);
|
||||
QPixmap pix(":/data/button lightmode inactive.png");
|
||||
urlIso1->setText(tr("Drag and drop the image file here"));
|
||||
tabUdisk1->setPixmap(pix);
|
||||
// QPixmap pix(":/data/Placeholder lighter.png");
|
||||
// tabUdisk->setPixmap(pix);
|
||||
urlIso->setWordWrap(true);
|
||||
// urlIso->setFixedSize(400,90);
|
||||
urlIso->setEnabled(false);
|
||||
urlIso->setText(tr("Click or drag to add a mirror file"));
|
||||
urlIso->setAlignment(Qt::AlignHCenter);
|
||||
urlIso1->setAlignment(Qt::AlignHCenter);
|
||||
urlIso1->setWordWrap(true);
|
||||
comboUdisk = new QComboBox(this);
|
||||
comboUdisk->setFixedSize(400,40);
|
||||
comboUdisk->setEnabled(false);
|
||||
//format=new QCheckBox(this);
|
||||
// format->setText(tr("format partition"));
|
||||
QWidget *btnwidget = new QWidget(this);
|
||||
findIso=new QPushButton(btnwidget);
|
||||
findIso->setStyleSheet("QPushButton{border-image:url(:/data/button lightmode normal.png);}"
|
||||
"QPushButton:hover{border-image:url(:/data/button lightmode hover.png);}"
|
||||
"QPushButton:clicked{border-image:url(:/data/button lightmode click.png);}");
|
||||
findIso->setFixedSize(127,127);
|
||||
// findIso->setText(tr("select file"));
|
||||
// findIso->setFixedSize(150,40);
|
||||
creatStart=new QPushButton(btnwidget);
|
||||
// creatStart->setFixedSize(150,40);
|
||||
creatStart->setText(tr("Start"));
|
||||
creatStart->setEnabled(false);
|
||||
connect(findIso,&QPushButton::clicked,this,[=]{
|
||||
|
@ -88,28 +84,33 @@ void Page1::initControlQss()
|
|||
QHBoxLayout *hlay=new QHBoxLayout(this);
|
||||
btnwidget->setLayout(hlay);
|
||||
hlay->addStretch(100);
|
||||
// hlay->addWidget(findIso);
|
||||
hlay->addWidget(creatStart);
|
||||
hlay->addStretch(100);
|
||||
QVBoxLayout *vlay1 = new QVBoxLayout(this);
|
||||
QVBoxLayout *vlay2 = new QVBoxLayout(this);
|
||||
// if(comboUdisk->currentText()!=tr("No USB drive available")){
|
||||
// qInfo()<<"wenbenshuchu";
|
||||
// edit->installEventFilter(this);
|
||||
// }
|
||||
topwidget->setLayout(vlay1);
|
||||
topwidget1->setLayout(vlay2);
|
||||
//vlay1->addWidget(tabUdisk,0,Qt::AlignCenter);
|
||||
fram->setLayout(vlay2);
|
||||
vlay1->addWidget(findIso,0,Qt::AlignCenter);
|
||||
vlay1->addWidget(urlIso,0,Qt::AlignCenter);
|
||||
vlay1->addSpacing(70);
|
||||
vlay2->addWidget(tabUdisk1,0,Qt::AlignCenter);
|
||||
vlay2->addSpacing(150);
|
||||
vlay2->addWidget(urlIso1,0,Qt::AlignCenter);
|
||||
vlay2->addSpacing(70);
|
||||
QVBoxLayout *vlay =new QVBoxLayout(this);
|
||||
vlay->addStretch(40);
|
||||
vlay->addWidget(topwidget1,0,Qt::AlignCenter);
|
||||
vlay->addSpacing(100);
|
||||
// vlay->addWidget(topwidget1,0,Qt::AlignCenter);
|
||||
vlay->addWidget(fram,0,Qt::AlignCenter);
|
||||
vlay->addWidget(topwidget,0,Qt::AlignCenter);
|
||||
vlay->addStretch(40);
|
||||
vlay->addSpacing(50);
|
||||
vlay->addWidget(comboUdisk,0,Qt::AlignCenter);
|
||||
// vlay->addWidget(format,0,Qt::AlignCenter);
|
||||
vlay->addStretch(30);
|
||||
vlay->addSpacing(30);
|
||||
vlay->addWidget(btnwidget);
|
||||
vlay->addStretch(50);
|
||||
vlay->addSpacing(30);
|
||||
udiskPlugWatcherInit(); //监控U盘插拔
|
||||
}
|
||||
//{
|
||||
|
@ -320,12 +321,17 @@ void Page1::getStorageInfo()
|
|||
|
||||
comboUdisk->addItem(info,diskInfo->devicePath);
|
||||
comboUdisk->setEnabled(true);
|
||||
}
|
||||
comboUdisk->setCurrentIndex(-1);
|
||||
comboUdisk->setLineEdit(edit);
|
||||
edit->setText(tr("select USB flash drive"));
|
||||
edit->setReadOnly(true);
|
||||
|
||||
}
|
||||
if(comboUdisk->count()!=1){
|
||||
comboUdisk->setCurrentIndex(-1);
|
||||
comboUdisk->setLineEdit(edit);
|
||||
edit->setText(tr("select USB flash drive"));
|
||||
edit->setReadOnly(true);
|
||||
}
|
||||
// comboUdisk->setCurrentIndex(-1);
|
||||
// comboUdisk->setLineEdit(edit);
|
||||
// edit->setText(tr("select USB flash drive"));
|
||||
// edit->setReadOnly(true);
|
||||
if(0==comboUdisk->count())
|
||||
{
|
||||
comboUdisk->addItem(tr("No USB drive available"));
|
||||
|
@ -445,17 +451,24 @@ void Page1::dragEnterEvent(QDragEnterEvent *event){
|
|||
return ;
|
||||
}
|
||||
if(event->mimeData()->hasFormat("text/uri-list")){
|
||||
// QPixmap pix(":/data/button lightmode inactive.png");
|
||||
// urlIso1->setText(tr("Drag and drop the image file here"));
|
||||
// tabUdisk1->setPixmap(pix);
|
||||
topwidget1->show();
|
||||
topwidget->hide();
|
||||
top->show();
|
||||
qInfo()<<"437"<<filePath;
|
||||
fram->setFrameShape(QFrame::StyledPanel);
|
||||
fram->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
|
||||
fram->show();
|
||||
// topwidget1->show();
|
||||
topwidget->hide();
|
||||
// top->show();
|
||||
event->acceptProposedAction();
|
||||
}
|
||||
return QWidget::dragEnterEvent(event);
|
||||
}
|
||||
void Page1::dragLeaveEvent(QDragLeaveEvent *event){
|
||||
findIso->show();
|
||||
topwidget->show();
|
||||
fram->hide();
|
||||
return QWidget::dragLeaveEvent(event);
|
||||
|
||||
}
|
||||
void Page1::dropEvent(QDropEvent *event){
|
||||
auto urls = event->mimeData()->urls();
|
||||
if(urls.isEmpty())
|
||||
|
@ -463,12 +476,8 @@ void Page1::dropEvent(QDropEvent *event){
|
|||
for(auto url:urls){
|
||||
dealSelectedFile(url.toLocalFile());
|
||||
findIso->show();
|
||||
// QPixmap pix(":/data/Placeholder lighter.png");
|
||||
// tabUdisk->setPixmap(pix);
|
||||
// tabUdisk->show();
|
||||
topwidget1->hide();
|
||||
topwidget->show();
|
||||
top->hide();
|
||||
fram->hide();
|
||||
ifStartBtnChange();
|
||||
}
|
||||
return ;
|
||||
|
@ -483,3 +492,13 @@ void Page1::settingStyle(){
|
|||
});
|
||||
subject->iniWidgetStyle();
|
||||
}
|
||||
bool Page1::eventFilter(QObject *watched, QEvent *event){
|
||||
if(watched==edit){
|
||||
if(event->type()==QEvent::MouseButtonPress){
|
||||
if(comboUdisk->currentText()!=tr("No USB drive available")){
|
||||
qInfo()<<"wenbenshuchu";
|
||||
comboUdisk->showPopup();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,7 +61,9 @@
|
|||
#include <QTableWidget>
|
||||
#include <QPainter>
|
||||
#include "topborder.h"
|
||||
#include "line.h"
|
||||
#include "include/GSettingSubject.h"
|
||||
#include<QFrame>
|
||||
class AvailableDiskInfo
|
||||
{
|
||||
public:
|
||||
|
@ -80,6 +82,7 @@ class Page1 : public QWidget
|
|||
public:
|
||||
explicit Page1();
|
||||
QString isoPath; //iso文件的路径
|
||||
QFrame *fram;
|
||||
QList<AvailableDiskInfo*> diskInfos; // U盘信息
|
||||
bool ifStartBtnChange(); //开始制作按钮是否可以点击
|
||||
void setThemeStyleLight(); //设置浅色主题
|
||||
|
@ -93,12 +96,14 @@ public:
|
|||
QLabel *urlIso1 = nullptr;
|
||||
QComboBox *comboUdisk = nullptr;//U盘列表
|
||||
topborder * top;
|
||||
QLineEdit * edit;
|
||||
// QLineEdit * edit;
|
||||
line * edit;
|
||||
QPushButton *creatStart = nullptr;//开始制作
|
||||
QPushButton *findIso = nullptr;//浏览文件按钮
|
||||
GsettingSubject *subject;
|
||||
void dropEvent(QDropEvent*);
|
||||
void dragEnterEvent(QDragEnterEvent *event);
|
||||
void dragLeaveEvent(QDragLeaveEvent *event);
|
||||
signals:
|
||||
void makeStart(QString sourcePath,QString targetPath); //make start
|
||||
void starmake(QString sourcepath,QString usbpath);
|
||||
|
@ -139,6 +144,9 @@ public:
|
|||
QLabel *tabUdisk1= nullptr;
|
||||
QWidget *topwidget;
|
||||
QWidget * topwidget1;
|
||||
protected:
|
||||
bool eventFilter(QObject *watched, QEvent *event);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -159,14 +159,13 @@ void Page2::startMaking()
|
|||
{
|
||||
playLoadingGif();
|
||||
QDBusConnection::systemBus().connect(QString(),QString("/"),"com.kylinusbcreator.interface","workingProgress",this,SLOT(dealWorkingProgress(int)));
|
||||
QDBusConnection::systemBus().connect(QString(),QString("/"),"com.kylinusbcreator.interface","errorstr",this,SLOT(dealerror(QString)));
|
||||
QDBusConnection::systemBus().connect(QString(),QString("/"),"com.kylinusbcreator.interface","makeFinish",this,SLOT(dealMakeFinish(QString)));
|
||||
}
|
||||
void Page2::dealerrorstr(QString str){
|
||||
qInfo()<<"errorstr"<<str;
|
||||
if(str.isEmpty()){
|
||||
playErrorGif();
|
||||
}
|
||||
// qInfo()<<"errorstr"<<str;
|
||||
// if(str.isEmpty()){
|
||||
// playErrorGif();
|
||||
// }
|
||||
}
|
||||
void Page2::dealWorkingProgress(int progress){
|
||||
QString ii=QString::number(progress);
|
||||
|
@ -174,6 +173,7 @@ void Page2::dealWorkingProgress(int progress){
|
|||
return;
|
||||
}else{
|
||||
round->setPersent(progress);
|
||||
qInfo()<<"progress"<<progress;
|
||||
}
|
||||
//round->setValue(progress);
|
||||
// round->setFormat(QString::number(progress)+"%");
|
||||
|
@ -184,13 +184,17 @@ void Page2::dealMakeFinish(QString status)
|
|||
uDiskPath = "";
|
||||
if("success" == status){
|
||||
//TODO:success action
|
||||
//mountDevice(uDiskPath);
|
||||
round->setPersent(100);
|
||||
mountDevice(uDiskPath);
|
||||
playFinishGif();
|
||||
qDebug()<<"status"<<status;
|
||||
}else{
|
||||
// playLoadingGif();
|
||||
mountDevice(uDiskPath);
|
||||
qInfo()<<"status"<<status;
|
||||
}else if("unmount_error"==status){
|
||||
playLoadingGif();
|
||||
qInfo()<<"status"<<status;
|
||||
}else if("make_error"){
|
||||
playErrorGif();
|
||||
qInfo()<<"status"<<status;
|
||||
}
|
||||
// playErrorGif();
|
||||
emit makeFinish();
|
||||
|
@ -203,7 +207,7 @@ bool Page2::mountDevice(QString target){
|
|||
// sync.waitForFinished();
|
||||
|
||||
QProcess mount;
|
||||
qDebug()<<"start mounting disk:"<<target+"1";
|
||||
qInfo()<<"start mounting disk:"<<target+"1";
|
||||
mount.start("udisksctl",QStringList{"mount","-b",target+"1"});
|
||||
if(!mount.waitForStarted()){
|
||||
qWarning()<<"count process start failed";
|
||||
|
@ -214,7 +218,7 @@ bool Page2::mountDevice(QString target){
|
|||
return false;
|
||||
}
|
||||
if(QProcess::NormalExit == mount.exitCode()){
|
||||
qDebug()<<"Mount success!";
|
||||
qInfo()<<"Mount success!";
|
||||
return true;
|
||||
}
|
||||
qWarning()<<"An unknown error occurred! Mount process exit code:"<<mount.exitCode();
|
||||
|
|
|
@ -5,15 +5,15 @@
|
|||
<name>MainWindow</name>
|
||||
<message>
|
||||
<source>Kylin USB Creator</source>
|
||||
<translation type="vanished">麒麟U盘启动器</translation>
|
||||
<translation type="vanished">ཆི་ལིན་Uསྡེར་སྒུལ་ཆས་</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>kylin usb creator</source>
|
||||
<translation type="vanished">麒麟U盘启动器</translation>
|
||||
<translation type="vanished">ཆི་ལིན་Uསྡེར་སྒུལ་ཆས་</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>minimize</source>
|
||||
<translation type="vanished">最小化</translation>
|
||||
<translation type="vanished">ཆེས་ཆུང་ཅན་</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mainwindow.cpp" line="167"/>
|
||||
|
@ -25,7 +25,7 @@
|
|||
<location filename="../mainwindow.cpp" line="144"/>
|
||||
<location filename="../mainwindow.cpp" line="245"/>
|
||||
<source>usb boot maker</source>
|
||||
<translation>usb ལྷམ་བཟོ་མཁན།</translation>
|
||||
<translation>Uསྡེར་ ལྷམ་བཟོ་མཁན།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../mainwindow.cpp" line="82"/>
|
||||
|
@ -92,14 +92,14 @@
|
|||
<message>
|
||||
<location filename="../page1.cpp" line="65"/>
|
||||
<source>choose iso file</source>
|
||||
<translation>iso ཡིག་ཆ་བདམས་པ།</translation>
|
||||
<translation>བདམས་པའི་ཤེལ་བརྙན་ཡིག་ཆ།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../page1.cpp" line="312"/>
|
||||
<location filename="../page1.cpp" line="333"/>
|
||||
<location filename="../page1.cpp" line="391"/>
|
||||
<source>select USB flash drive</source>
|
||||
<translation>USB 闪存驱动器选择</translation>
|
||||
<translation>Uསྡེར་འདེམས་སྒྲིག་ཆས་</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../page1.cpp" line="386"/>
|
||||
|
@ -113,27 +113,27 @@
|
|||
</message>
|
||||
<message>
|
||||
<source>USB drive will be formatted,please backup your files!</source>
|
||||
<translation type="vanished">制作启动盘的U盘将被格式化,请先备份好重要文件!</translation>
|
||||
<translation type="vanished">སྒོ་ཕྱེ་པའི་Uསྡེར་དེ་རྣམ་པར་འཇོག་པས།སྔོན་ལ་ཡིག་ཆ་གལ་ཆེན་དག་གྲབས་ཉར་བྱེད་རོགས།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Authorization</source>
|
||||
<translation type="vanished">授权</translation>
|
||||
<translation type="vanished">དབང་སྐུར།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>cancel</source>
|
||||
<translation type="vanished">取消</translation>
|
||||
<translation type="vanished">མེད་པར་བཟོ་བ་</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Choose iso file</source>
|
||||
<translation type="vanished">选择光盘镜像文件</translation>
|
||||
<translation type="vanished">འོད་སྡེར་བདམས་པའི་ཤེལ་བརྙན་ཡིག་ཆ།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Select USB drive</source>
|
||||
<translation type="vanished">选择U盘</translation>
|
||||
<translation type="vanished">Uསྡེར་འདེམ་པ།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Open</source>
|
||||
<translation type="vanished">浏览</translation>
|
||||
<translation type="vanished">རགས་ལྟ་</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../page1.cpp" line="386"/>
|
||||
|
@ -142,7 +142,7 @@
|
|||
</message>
|
||||
<message>
|
||||
<source>ISO Invalid,please make sure you choose a vavlid image!</source>
|
||||
<translation type="vanished">ISO镜像无效,请选择正确的镜像!</translation>
|
||||
<translation type="vanished">ISOOབརྙན་ལ་ནུས་པ་མི་འདུགཁྱེད་ཀྱིས་ཡང་དག་གི་སྣང་བརྙན་འདེམས་རོགས།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../page1.cpp" line="62"/>
|
||||
|
@ -151,32 +151,34 @@
|
|||
</message>
|
||||
<message>
|
||||
<source>These operations needs to be verified:</source>
|
||||
<translation type="vanished">执行该动作需要root授权,您需要进行验证:</translation>
|
||||
<translation type="vanished">འགུལ་སྟངས་འདི་ལག་བསྟར་བྱེད་པར་rotཡིས་དབང་ཆ་བསྐུར་དགོས་པས་ཁྱེད་ཀྱིས་ཚོད་ལྟས་ར་སྤྲོད་བྱེད་དགོས།:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>USB drive will be formatted,please backup your files</source>
|
||||
<translation type="vanished">制作启动盘的U盘将被格式化,请先备份好重要文件</translation>
|
||||
<translation type="vanished">སྒོ་འབྱེད་སྡེར་བཟོས་ཀྱི་Uསྡེར་ནི་རྣམ་གཞག་དང་།ཡིག་ཆ་གལ་ཆེན་སྔོན་ལ་གྲབས་ཉར་ཡག་པོ་རོགས་།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>OK</source>
|
||||
<translation type="vanished">授权</translation>
|
||||
<translation type="vanished">དབང་སྐུར།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>These operations needs to be verified.</source>
|
||||
<translation type="vanished">要安装或卸载软件,您需要进行验证。</translation>
|
||||
<translation type="vanished">མ་ལག་སྒྲིག་པའམ་ཕབ་དགོས།ཁྱེད་ཀྱིས་ཞིབ་བཤེར་བྱེད་དགོས།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Request authorization:</source>
|
||||
<translation type="vanished">一个程序正试图执行一个需要特权的动作。要求授权以执行该动作:</translation>
|
||||
<translation type="vanished">གོ་རིམ་ཞིག་ལག་བསྟར་བྱེད་པར་ཚོད་ལྟ་བྱེད་བཞིན་ཡོད་།ཁྱད་དབང་གི་འགུལ་སྟངས་ཞིག་རེད། དབང་བསྐུར་ནས་བྱ་སྤྱོད་དེ་ལག་བསྟར་བྱེད་དུ་འཇུག་དགོས།:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Password:</source>
|
||||
<translation type="vanished">输入密码:</translation>
|
||||
<translation type="vanished">གསང་ཨང་འགོད་པ།:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../page1.cpp" line="317"/>
|
||||
<location filename="../page1.cpp" line="333"/>
|
||||
<location filename="../page1.cpp" line="334"/>
|
||||
<location filename="../page1.cpp" line="391"/>
|
||||
<location filename="../page1.cpp" line="90"/>
|
||||
<source>No USB drive available</source>
|
||||
<translation>USBསྒུལ་ཆས་བཀོལ་སྤྱོད་བྱེད་མི་ཐུབ།</translation>
|
||||
</message>
|
||||
|
@ -190,7 +192,7 @@
|
|||
</message>
|
||||
<message>
|
||||
<source>Please do not remove the USB driver or power off now.</source>
|
||||
<translation type="obsolete">制作时请不要移除U盘或关机。</translation>
|
||||
<translation type="obsolete">བཟོ་དུས་སུUསྡེར་དང་ཡང་ན་ཁ་མ་རྒྱག་རོགས།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../page2.cpp" line="41"/>
|
||||
|
@ -251,27 +253,27 @@
|
|||
<name>StyleWidget</name>
|
||||
<message>
|
||||
<source>kylin usb creator</source>
|
||||
<translation type="vanished">麒麟U盘启动器</translation>
|
||||
<translation type="vanished">ཆི་ལིན་Uསྡེར་སྒུལ་ཆས་</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Theme</source>
|
||||
<translation type="vanished">主题</translation>
|
||||
<translation type="vanished">བརྗོད་བྱ་གཙོ་བོ།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Help</source>
|
||||
<translation type="vanished">帮助</translation>
|
||||
<translation type="vanished">རོགས་རམ།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>About</source>
|
||||
<translation type="vanished">关于</translation>
|
||||
<translation type="vanished">སྐོར་</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Setting</source>
|
||||
<translation type="vanished">设置</translation>
|
||||
<translation type="vanished">གསར་འཛུགས་</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Quit</source>
|
||||
<translation type="vanished">退出</translation>
|
||||
<translation type="vanished">ཕྱིར་འབུད་</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
|
@ -291,7 +293,7 @@
|
|||
<name>menuModule</name>
|
||||
<message>
|
||||
<source>menu</source>
|
||||
<translation type="vanished">菜单</translation>
|
||||
<translation type="vanished">ཟས་ཐོ།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../include/menumodule.cpp" line="40"/>
|
||||
|
@ -390,23 +392,23 @@
|
|||
<message>
|
||||
<location filename="../include/menumodule.cpp" line="357"/>
|
||||
<source>USB Boot Maker provides system image making function.The operation process is simple and easy.You can choose ISO image and usb driver,and make boot driver with a few clicks.</source>
|
||||
<translation>USB Boot Maker提供了系统图像功能。 བཀོལ་སྤྱོད་ཀྱི་གོ་རིམ་སྟབས་བདེ་ཞིང་སྟབས་བདེ་ཡིན། ཁྱེད་ཚོས་ISOཡི་པར་རིས་དང་usb ཁ་ལོ་བ་གདམ་གསེས་བྱས་ཆོག་པ་མ་ཟད། ད་དུང་མཐེབ་བཀྱག་འགའ་བརྒྱབ་ནས་ལྷམ་ཡུ་རིང་གི་ཁ</translation>
|
||||
<translation>Uསྡེར་སྒུལ་ཆས་ཀྱིས་མ་ལག་བརྙན་རིས་ནུས་པ་འདོན་སྤྲོད་བྱས།。 བཀོལ་སྤྱོད་ཀྱི་གོ་རིམ་སྟབས་བདེ་ཞིང་སྟབས་བདེ་ཡིན། ཁྱེད་ཚོས་ISOཡི་པར་རིས་དང་usb ཁ་ལོ་བ་གདམ་གསེས་བྱས་ཆོག་པ་མ་ཟད། ད་དུང་མཐེབ་བཀྱག་འགའ་བརྒྱབ་ནས་ལྷམ་ཡུ་རིང་གི་ཁ</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>close</source>
|
||||
<translation type="vanished">关闭</translation>
|
||||
<translation type="vanished">སྒོ་རྒྱག་པ་</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>kylin usb creator</source>
|
||||
<translation type="vanished">麒麟U盘启动器</translation>
|
||||
<translation type="vanished">ཆི་ལིན་Uསྡེར་སྒུལ་ཆས་</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Kylin USB Creator provides system image making function.The operation process is simple and easy.You can choose ISO image and usb driver,and make boot driver with a few clicks.</source>
|
||||
<translation type="vanished">麒麟U盘启动器提供系统盘制作功能,操作流程简单便捷。用户可以自行选择ISO镜像和U盘,一键轻松制作U盘启动盘。</translation>
|
||||
<translation type="vanished">ཆི་ལིན་Uསྡེར་སྒུལ་ཆས་ཀྱིས་མ་ལག་གི་བྱེད་ནུས་འདོན་སྤྲོད་བྱས་ཡོད་ལ།བཀོལ་སྤྱོད་ཀྱི་བརྒྱུད་རིམ་སྟབས་བདེ་ཡིན། བཀོལ་མཁན་གྱིས་རང་འགུལ་ངང་ISOབརྙན་བརྙན་དང་Uསྡེར་འདེམས་ཆོགམཐེབ་གཅིག་བདེ་མོའི་ངང་Uསྡེར་ལས་ཆོག</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Kylin USB Creator provides system image making function.The operation process is simple and easy.You can choose ISO image and usb driver,and make boot driver with a few clicks</source>
|
||||
<translation type="vanished">麒麟U盘启动器提供系统盘制作功能。操作流程简单便捷。用户可以自行选择ISO镜像和U盘,一键轻松制作U盘启动器。</translation>
|
||||
<translation type="vanished">ཆི་ལིན་Uསྡེར་སྒུལ་ཆས་ཀྱིས་མ་ལག་སྡེར་བཟོ་བའི་ནུས་པ་འདོན་སྤྲོད་བྱས། བཀོལ་སྤྱོད་ཀྱི་བརྒྱུད་རིམ་སྟབས་བདེ་ལ་སྟབས་བདེ། བཀོལ་མཁན་གྱིས་རང་འགུལ་ངང་ISOབརྙན་བརྙན་དང་Uསྡེར་འདེམས་ཆོགམཐེབ་གཅིག་བདེ་མོའི་ངང་Uསྡེར་སྒུལ་ཆས་བཟོས་ཆོག</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../include/menumodule.cpp" line="246"/>
|
||||
|
@ -421,30 +423,30 @@
|
|||
</message>
|
||||
<message>
|
||||
<source>Support: support@kylinos.cn</source>
|
||||
<translation type="vanished">支持:support@kylinos.cn</translation>
|
||||
<translation type="vanished">རྒྱབ་སྐྱོར་:support@kylinos.cn</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>rootAuthDialog</name>
|
||||
<message>
|
||||
<source>Input password</source>
|
||||
<translation type="vanished">请输入密码</translation>
|
||||
<translation type="vanished">གསང་ཨང་ནང་འཇུག་རོགས་།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>please enter the password</source>
|
||||
<translation type="vanished">请输入密码</translation>
|
||||
<translation type="vanished">གསང་ཨང་ནང་འཇུག་རོགས་།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Wrong password!Try again</source>
|
||||
<translation type="vanished">密码错误,请重新尝试</translation>
|
||||
<translation type="vanished">གསང་ཨང་ནོར་འཁྲུལ་དང་།ཡང་བསྐྱར་ཚོད་ལྟ་ཞིག་བྱེད་རོགས་།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Current user is not in the sudoers file,please change another account or change authority</source>
|
||||
<translation type="vanished">当前用户不在sudoer名单中,请修改账户或权限</translation>
|
||||
<translation type="vanished">མིག་སྔར་སྤྱོད་མཁན་གྱི་མིང་ཐོ་ནང་དུ་མེད་།ཐོ་ཁོངས་སམ་དབང་ཚད་བཟོ་བཅོས་རྒྱག་རོགས་།</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Current user is not in the sudoers file,please change another account or change authority.</source>
|
||||
<translation type="vanished">当前用户不在sudoer名单中,请修改账户或权限。</translation>
|
||||
<translation type="vanished">མིག་སྔར་སྤྱོད་མཁན་གྱི་མིང་ཐོ་ནང་དུ་མེད་།ཐོ་ཁོངས་སམ་དབང་ཚད་བཟོ་བཅོས་རྒྱག་རོགས་།。</translation>
|
||||
</message>
|
||||
</context>
|
||||
</TS>
|
||||
|
|
|
@ -176,7 +176,9 @@
|
|||
<message>
|
||||
<location filename="../page1.cpp" line="317"/>
|
||||
<location filename="../page1.cpp" line="333"/>
|
||||
<location filename="../page1.cpp" line="334"/>
|
||||
<location filename="../page1.cpp" line="391"/>
|
||||
<location filename="../page1.cpp" line="90"/>
|
||||
<source>No USB drive available</source>
|
||||
<translation>无可用U盘</translation>
|
||||
</message>
|
||||
|
|
|
@ -1,3 +1,13 @@
|
|||
kylin-usb-creator (1.2.0.3kord-ok3) yangtze; urgency=medium
|
||||
|
||||
* BUG:128065 【U盘启动器】U盘启动器制作的启动盘无法安装系统
|
||||
128089 【U盘启动器】U盘启动器打开后,页面未处于中间
|
||||
*其他改动说明:无
|
||||
* 其他改动影响域:无
|
||||
|
||||
|
||||
-- rongyouli <rongyouli@kylinos.cn> Wed, 13 Jul 2022 09:37:04 +0800
|
||||
|
||||
kylin-usb-creator (1.2.0.3kord-ok2) yangtze; urgency=medium
|
||||
|
||||
* Fix build error
|
||||
|
|
|
@ -3,6 +3,17 @@ Section: utils
|
|||
Priority: optional
|
||||
Maintainer: liuyuhui <liuyuhui@kylinos.cn>
|
||||
Build-Depends: debhelper-compat (= 12),
|
||||
qtbase5-dev,
|
||||
qt5-qmake,
|
||||
qtchooser,
|
||||
libkf5windowsystem-dev,
|
||||
libqt5x11extras5-dev,
|
||||
qtscript5-dev,
|
||||
libkysdk-waylandheleper,
|
||||
libkysdk-waylandheleper-dev,
|
||||
libkysdk-appcommon,
|
||||
qttools5-dev-tools,
|
||||
qtbase5-dev-tools,
|
||||
libgsettings-qt-dev,
|
||||
libkf5windowsystem-dev,
|
||||
libpolkit-qt5-1-dev,
|
||||
|
|
|
@ -1,8 +1,17 @@
|
|||
TEMPLATE = subdirs
|
||||
|
||||
CONFIG += ordered
|
||||
CONFIG += ordered \
|
||||
qt
|
||||
|
||||
SUBDIRS = \
|
||||
UIControl \
|
||||
registeredQDbus \
|
||||
|
||||
HEADERS += \
|
||||
UIControl/src/line.h
|
||||
|
||||
SOURCES += \
|
||||
UIControl/src/line.cpp
|
||||
|
||||
QT += widgets
|
||||
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
#include "mythread.h"
|
||||
|
||||
Mythread::Mythread()
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
#ifndef MYTHREAD_H
|
||||
#define MYTHREAD_H
|
||||
|
||||
|
||||
class Mythread
|
||||
{
|
||||
public:
|
||||
Mythread();
|
||||
};
|
||||
|
||||
#endif // MYTHREAD_H
|
|
@ -38,6 +38,7 @@ INSTALLS += \
|
|||
|
||||
SOURCES += \
|
||||
main.cpp \
|
||||
mythread.cpp \
|
||||
systemdbusregister.cpp \
|
||||
# systemdbusregister.cpp
|
||||
|
||||
|
@ -45,6 +46,7 @@ LIBS += -L/usr/lib/x86_64-linux-gnu/ -lpolkit-qt5-core-1
|
|||
LIBS += -lukui-log4qt
|
||||
|
||||
HEADERS += \
|
||||
mythread.h \
|
||||
systemdbusregister.h
|
||||
|
||||
DISTFILES += \
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include <QDBusError>
|
||||
#include <QDBusMessage>
|
||||
#include <QDebug>
|
||||
#include <QThread>
|
||||
|
||||
using namespace PolkitQt1;
|
||||
|
||||
|
@ -45,34 +46,167 @@ void SystemDbusRegister::MakeStart(QString sourcePath,QString targetPath){
|
|||
emit authorityStatus("failed");
|
||||
return ;
|
||||
}
|
||||
// if(!unmountDevice(targetPath)){
|
||||
// // TODO:Deal sbus message unmount_error
|
||||
// emit makeFinish("unmount_error");
|
||||
|
||||
// }
|
||||
|
||||
// if(!unmountDevice(targetPath + "1")){
|
||||
// // TODO:Deal sbus message unmount_error
|
||||
// emit makeFinish("unmount_error");
|
||||
// }
|
||||
uDiskPath = targetPath;
|
||||
QFileInfo info(sourcePath);
|
||||
sourceFileSize = info.size()/1000000;
|
||||
command_dd = new QProcess();
|
||||
//指定输出语言
|
||||
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
|
||||
env.insert("LANGUAGE","en_US:en");
|
||||
command_dd->setProcessEnvironment(env);
|
||||
connect(command_dd,&QProcess::readyReadStandardError,this,&SystemDbusRegister::readBashStandardErrorInfo);
|
||||
connect(command_dd,SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(dd_finished(int,QProcess::ExitStatus)));
|
||||
QTimer::singleShot(1*1000, this, &SystemDbusRegister::handletimeout);
|
||||
command_dd->start("bash");
|
||||
command_dd->start("bash");
|
||||
command_dd->waitForStarted();
|
||||
QFileInfo info(sourcePath);
|
||||
sourceFileSize = info.size()/1000000;
|
||||
command_dd = new QProcess();
|
||||
//指定输出语言
|
||||
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
|
||||
env.insert("LANGUAGE","en_US:en");
|
||||
command_dd->setProcessEnvironment(env);
|
||||
//command_dd->setProcessChannelMode(QProcess::MergedChannels);
|
||||
connect(command_dd,&QProcess::readyReadStandardOutput,this,&SystemDbusRegister::readBashStandardErrorInfo);
|
||||
connect(command_dd,&QProcess::readyReadStandardError,this,&SystemDbusRegister::readBashStandardErrorInfo);
|
||||
connect(command_dd,SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(dd_finished(int,QProcess::ExitStatus)));
|
||||
QTimer::singleShot(1*1000, this, &SystemDbusRegister::handletimeout);
|
||||
// QThread::create([=](){
|
||||
qDebug("输出线程");
|
||||
if(!unmountDevice(targetPath)){
|
||||
// TODO:Deal sbus message unmount_error
|
||||
QProcess *format=new QProcess;
|
||||
// format->start("bash");
|
||||
QStringList args512;
|
||||
args512<<"if=/dev/zero"<<"of="+targetPath.toLocal8Bit()<<"bs=512"<<"count=1";
|
||||
format->start("dd", args512);
|
||||
connect(format,SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(clear_finished(int,QProcess::ExitStatus)));
|
||||
format->waitForStarted();
|
||||
if(format->waitForStarted()){
|
||||
qDebug()<<"58ag0"<<format->arguments();
|
||||
}
|
||||
|
||||
QString ddshell = "dd if='"+sourcePath.toLocal8Bit()+"' of="+targetPath.toLocal8Bit()+" status=progress"+" bs=4096";
|
||||
command_dd->write(ddshell.toLocal8Bit() + '\n');
|
||||
return ;
|
||||
// format->waitForFinished();
|
||||
emit makeFinish("unmount_error");
|
||||
}
|
||||
|
||||
if(!unmountDevice(targetPath + "1")){
|
||||
// // TODO:Deal sbus message unmount_error
|
||||
QProcess *format=new QProcess;
|
||||
QStringList args512;
|
||||
args512<<"if=/dev/zero"<<"of="+targetPath.toLocal8Bit()<<"bs=512"<<"count=1";
|
||||
format->start("dd", args512);
|
||||
connect(format,SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(clear_finished(int,QProcess::ExitStatus)));
|
||||
format->waitForStarted();
|
||||
if(format->waitForStarted()){
|
||||
qDebug()<<"70ag0"<<format->arguments();
|
||||
}
|
||||
//format->waitForFinished();
|
||||
emit makeFinish("unmount_error");
|
||||
}
|
||||
// uDiskPath = targetPath;
|
||||
// QFileInfo info(sourcePath);
|
||||
// sourceFileSize = info.size()/1000000;
|
||||
// this->command_dd = new QProcess();
|
||||
// //指定输出语言
|
||||
// QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
|
||||
// env.insert("LANGUAGE","en_US:en");
|
||||
// this->command_dd->setProcessEnvironment(env);
|
||||
// //command_dd->setProcessChannelMode(QProcess::MergedChannels);
|
||||
// connect(this->command_dd,&QProcess::readyReadStandardOutput,this,&SystemDbusRegister::readBashStandardErrorInfo);
|
||||
// connect(this->command_dd,&QProcess::readyReadStandardError,this,&SystemDbusRegister::readBashStandardErrorInfo);
|
||||
// connect(this->command_dd,SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(dd_finished(int,QProcess::ExitStatus)));
|
||||
// QTimer::singleShot(1*1000, this, &SystemDbusRegister::handletimeout);
|
||||
//command_dd->start("bash");
|
||||
// command_dd->start("bash");
|
||||
// QStringList args;
|
||||
// args<<"if="+sourcePath.toLocal8Bit()<<"of="+targetPath.toLocal8Bit()<<"status=progress"<<"bs=32M";
|
||||
// command_dd->start("dd", args);
|
||||
// command_dd->waitForStarted();
|
||||
// if(command_dd->waitForStarted()){
|
||||
// qDebug()<<"97command_dd->arguments()"<<this->command_dd->arguments();
|
||||
// }
|
||||
// // QString ddshell = "dd if='"+sourcePath.toLocal8Bit()+"' of="+targetPath.toLocal8Bit()+" status=progress"+" bs=32M";
|
||||
// // command_dd->write(ddshell.toLocal8Bit() + '\n');
|
||||
// qDebug()<<"shuchu91"<<this->command_dd->arguments();
|
||||
//return ;
|
||||
// })->start();
|
||||
// QStringList args;
|
||||
// args<<"if="+sourcePath.toLocal8Bit()<<"of="+targetPath.toLocal8Bit()<<"status=progress"<<"bs=32M";
|
||||
// command_dd->start("dd", args);
|
||||
// command_dd->waitForStarted();
|
||||
// if(command_dd->waitForStarted()){
|
||||
// qDebug()<<"97command_dd->arguments()"<<command_dd->arguments();
|
||||
// }
|
||||
// // QString ddshell = "dd if='"+sourcePath.toLocal8Bit()+"' of="+targetPath.toLocal8Bit()+" status=progress"+" bs=32M";
|
||||
// // command_dd->write(ddshell.toLocal8Bit() + '\n');
|
||||
// qDebug()<<"shuchu91"<<command_dd->arguments();
|
||||
// if(!unmountDevice(targetPath)){
|
||||
// // TODO:Deal sbus message unmount_error
|
||||
// QProcess *format=new QProcess;
|
||||
// format->start("bash");
|
||||
// QString fileformat="mkfs -t ext4 "+targetPath;
|
||||
// format->write(fileformat.toLocal8Bit()+'\n');
|
||||
// format->waitForFinished();
|
||||
// emit makeFinish("unmount_error");
|
||||
// }
|
||||
|
||||
// if(!unmountDevice(targetPath + "1")){
|
||||
// // TODO:Deal sbus message unmount_error
|
||||
// QProcess *format=new QProcess;
|
||||
// format->start("bash");
|
||||
// QString fileformat="mkfs -t ext4 "+targetPath+"1";
|
||||
// format->write(fileformat.toLocal8Bit()+'\n');
|
||||
// format->waitForFinished();
|
||||
// emit makeFinish("unmount_error");
|
||||
// }
|
||||
// uDiskPath = targetPath;
|
||||
|
||||
// // udiskmountpoint();
|
||||
//// QProcess *format=new QProcess;
|
||||
//// format->start("bash");
|
||||
//// QString fileformat="mkfs -t ext4 "+targetPath;
|
||||
//// format->write(fileformat.toLocal8Bit()+'\n');
|
||||
//// format->waitForFinished();
|
||||
//// QProcess *clearor=new QProcess;
|
||||
//// connect(clearor,SIGNAL(finished(int)),this,SLOT(clear_finished(int)));
|
||||
//// QStringList args512;
|
||||
// // args512<<"if=/dev/zero"<<"of="+targetPath.toLocal8Bit()<<"status=progress"<<"bs=512"<<"count=1";
|
||||
// // clearor->start("dd", args512);
|
||||
//// clearor->start("bash");
|
||||
//// clearor->start("bash");
|
||||
//// clearor->waitForStarted();
|
||||
//// QString source="/dev/zero";
|
||||
//// QString ddshell1 ="dd if='"+source.toLocal8Bit()+"' of="+targetPath.toLocal8Bit()+" status=progress"+" bs=512"+" count=1";
|
||||
//// clearor->write(ddshell1.toLocal8Bit() + '\n');
|
||||
// // connect(clearor,&QProcess::finished,this,&SystemDbusRegister::clear_finished);
|
||||
// // clearor->waitForFinished();
|
||||
// QFileInfo info(sourcePath);
|
||||
// sourceFileSize = info.size()/1000000;
|
||||
// command_dd = new QProcess();
|
||||
// //指定输出语言
|
||||
// QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
|
||||
// env.insert("LANGUAGE","en_US:en");
|
||||
// command_dd->setProcessEnvironment(env);
|
||||
// connect(command_dd,&QProcess::readyReadStandardError,this,&SystemDbusRegister::readBashStandardErrorInfo);
|
||||
// connect(command_dd,SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(dd_finished(int,QProcess::ExitStatus)));
|
||||
// QTimer::singleShot(1*1000, this, &SystemDbusRegister::handletimeout);
|
||||
// command_dd->start("bash");
|
||||
// command_dd->start("bash");
|
||||
// command_dd->waitForStarted();
|
||||
// QString ddshell = "dd if='"+sourcePath.toLocal8Bit()+"' of="+targetPath.toLocal8Bit()+" status=progress"+" bs=32M";
|
||||
// command_dd->write(ddshell.toLocal8Bit() + '\n');
|
||||
// qDebug()<<"shuchu91"<<command_dd->arguments();
|
||||
// return ;
|
||||
}
|
||||
void SystemDbusRegister::clear_finished(int exitCode,QProcess::ExitStatus exitStatus){
|
||||
qDebug()<<"85exitCode"<<exitCode;
|
||||
qDebug("清空输出");
|
||||
if(exitStatus==QProcess::NormalExit){
|
||||
QStringList args;
|
||||
args<<"if="+sourceFile.toLocal8Bit()<<"of="+uDiskPath.toLocal8Bit()<<"status=progress"<<"bs=32M";
|
||||
command_dd->start("dd", args);
|
||||
command_dd->waitForStarted();
|
||||
if(command_dd->waitForStarted()){
|
||||
qDebug()<<"97command_dd->arguments()"<<command_dd->arguments();
|
||||
}
|
||||
// QString ddshell = "dd if='"+sourcePath.toLocal8Bit()+"' of="+targetPath.toLocal8Bit()+" status=progress"+" bs=32M";
|
||||
// command_dd->write(ddshell.toLocal8Bit() + '\n');
|
||||
qDebug()<<"shuchu91"<<command_dd->arguments();
|
||||
}
|
||||
// command_dd->start("bash");
|
||||
// command_dd->start("bash");
|
||||
// command_dd->waitForStarted();
|
||||
// QString ddshell = "dd if='"+sourceFile.toLocal8Bit()+"' of="+uDiskPath.toLocal8Bit()+" status=progress"+" bs=32M";
|
||||
// command_dd->write(ddshell.toLocal8Bit() + '\n');
|
||||
}
|
||||
void SystemDbusRegister::dd_finished(int exitCode, QProcess::ExitStatus exitStatus){
|
||||
if(exitStatus!=QProcess::NormalExit){
|
||||
|
@ -88,27 +222,95 @@ void SystemDbusRegister::handletimeout(){
|
|||
command_dd->kill();
|
||||
}
|
||||
}
|
||||
//bool SystemDbusRegister::unmountDevice(QString target)
|
||||
//{
|
||||
// QProcess unmount;
|
||||
// unmount.start("udisksctl",QStringList{"unmount","-b",target});
|
||||
// qDebug()<<"Start unmount disk:"<<target;
|
||||
// if(!unmount.waitForStarted()){
|
||||
// qWarning()<<"unmount process start failed.device path:"<<target;
|
||||
//bool SystemDbusRegister::mountDevice(QString target){
|
||||
// QProcess mount;
|
||||
// qInfo()<<"start mounting disk:"<<target+"1";
|
||||
// mount.start("udisksctl",QStringList{"mount","-b",target+"1"});
|
||||
// if(!mount.waitForStarted()){
|
||||
// qWarning()<<"count process start failed";
|
||||
// return false;
|
||||
// }
|
||||
// if(!unmount.waitForFinished()){
|
||||
// qWarning()<<"unmount process finish failed,device path:"<<target;
|
||||
// if(!mount.waitForFinished()){
|
||||
// qWarning()<<"装载失败";
|
||||
// return false;
|
||||
// }
|
||||
// if(QProcess::NormalExit == unmount.exitCode()){
|
||||
// qDebug()<<"unmount device success.device path:"<<target;
|
||||
// if(QProcess::NormalExit == mount.exitCode()){
|
||||
// qInfo()<<"Mount success!";
|
||||
// return true;
|
||||
// }
|
||||
// qWarning()<<"An unknown error occurred! unmount process exit code:"<<unmount.exitCode();
|
||||
// qWarning()<<"An unknown error occurred! Mount process exit code:"<<mount.exitCode();
|
||||
// return false;
|
||||
//}
|
||||
|
||||
bool SystemDbusRegister::unmountDevice(QString target)
|
||||
{
|
||||
QProcess unmount;
|
||||
unmount.start("udisksctl",QStringList{"unmount","-b",target});
|
||||
qDebug()<<"Start unmount disk:"<<target;
|
||||
if(!unmount.waitForStarted()){
|
||||
qWarning()<<"unmount process start failed.device path:"<<target;
|
||||
return false;
|
||||
}
|
||||
if(!unmount.waitForFinished()){
|
||||
qWarning()<<"unmount process finish failed,device path:"<<target;
|
||||
return false;
|
||||
}
|
||||
if(QProcess::NormalExit == unmount.exitCode()){
|
||||
qDebug()<<"unmount device success.device path:"<<target;
|
||||
return true;
|
||||
}else{
|
||||
QString output = unmount.readAll();
|
||||
qDebug()<<__func__<<__LINE__<<output;
|
||||
|
||||
}
|
||||
qWarning()<<"An unknown error occurred! unmount process exit code:"<<unmount.exitCode();
|
||||
return false;
|
||||
}
|
||||
void SystemDbusRegister::udiskmountpoint(){
|
||||
QProcess lsblk;
|
||||
lsblk.start("lsblk -J");
|
||||
lsblk.waitForFinished();
|
||||
|
||||
QProcess lsblk2;
|
||||
lsblk2.start("lsblk -JS");
|
||||
lsblk2.waitForFinished();
|
||||
QJsonArray arr1 = QStringToJsonArray(QString::fromLocal8Bit(lsblk.readAllStandardOutput())); //获取json类型的shell执行结果
|
||||
QJsonArray arr2 = QStringToJsonArray(QString::fromLocal8Bit(lsblk2.readAllStandardOutput()));
|
||||
foreach (const QJsonValue& value, arr1) {
|
||||
QJsonObject jsonObj1 = value.toObject();
|
||||
foreach (const QJsonValue& value, arr2) {
|
||||
QJsonObject jsonObj2 = value.toObject();
|
||||
if(jsonObj1["name"] == jsonObj2["name"] && jsonObj2["tran"] == "usb" && jsonObj2["type"] == "disk"){
|
||||
QString usbmountpoint=jsonObj1["mountpoint"].toString();
|
||||
qDebug()<<"usbmountpoint"<<usbmountpoint;
|
||||
if(!usbmountpoint.isEmpty()){
|
||||
unmountDevice(uDiskPath);
|
||||
unmountDevice(uDiskPath+"1");
|
||||
}/*else{
|
||||
QJsonArray arr3 = QStringToJsonArray(QString::fromLocal8Bit(lsblk.readAllStandardOutput())); //获取json类型的shell执行结果
|
||||
foreach (const QJsonValue& value, arr3) {
|
||||
QJsonObject jsonObj3 = value.toObject();
|
||||
QString name=jsonObj3["name"].toString();
|
||||
{
|
||||
foreach (const QJsonValue& value, arr2){
|
||||
QJsonObject jsonObj2 = value.toObject();
|
||||
QString name1=jsonObj2["name"].toString()+"1";
|
||||
if(name==name1){
|
||||
QString usbmountpoint1=jsonObj3["mountpoint"].toString();
|
||||
qDebug()<<"usbmountpoint"<<usbmountpoint1;
|
||||
if(!usbmountpoint1.isEmpty()){
|
||||
QString udiskpath1=uDiskPath+"1";
|
||||
unmountDevice(udiskpath1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//kill task process
|
||||
void SystemDbusRegister::MakeExit(){
|
||||
qDebug()<<"exit dd process";
|
||||
|
@ -120,6 +322,7 @@ void SystemDbusRegister::MakeExit(){
|
|||
}
|
||||
void SystemDbusRegister::readBashStandardErrorInfo()
|
||||
{
|
||||
qDebug()<<__func__<<__LINE__;
|
||||
QByteArray cmdout = command_dd->readAllStandardError();
|
||||
cmdout.trimmed();
|
||||
if(!cmdout.isEmpty() && cmdout != "\r" && cmdout != "\n"){
|
||||
|
@ -146,8 +349,9 @@ void SystemDbusRegister::readBashStandardErrorInfo()
|
|||
return;
|
||||
}
|
||||
//send mission percent debus message every output
|
||||
qDebug()<<__func__<<__LINE__<<mission_percent;
|
||||
emit workingProgress(mission_percent);
|
||||
emit errorstr(str);
|
||||
// emit errorstr(str);
|
||||
}else{
|
||||
return;
|
||||
}
|
||||
|
@ -159,12 +363,14 @@ void SystemDbusRegister::finishEvent(){
|
|||
diskRefreshDelay->stop();
|
||||
if(isMakingSucess()){
|
||||
//send production success dbus message
|
||||
qDebug()<<"make success";
|
||||
qInfo()<<"make success";
|
||||
QProcess sync;
|
||||
sync.start("sync");
|
||||
sync.waitForStarted();
|
||||
sync.waitForFinished();
|
||||
emit makeFinish("success");
|
||||
//mountDevice(uDiskPath);
|
||||
// mountDevice(uDiskPath+"1");
|
||||
qDebug()<<"uDiskPath"<<uDiskPath;
|
||||
}else{
|
||||
//send production failure dbus message
|
||||
|
@ -174,6 +380,32 @@ void SystemDbusRegister::finishEvent(){
|
|||
});
|
||||
diskRefreshDelay->start(2000);
|
||||
}
|
||||
|
||||
bool SystemDbusRegister::mountDevice(QString target){
|
||||
|
||||
// QProcess sync;
|
||||
// sync.start("sync");
|
||||
// sync.waitForStarted();
|
||||
// sync.waitForFinished();
|
||||
|
||||
QProcess mount;
|
||||
qInfo()<<"start mounting disk:"<<target;
|
||||
mount.start("udisksctl",QStringList{"mount","-b",target});
|
||||
if(!mount.waitForStarted()){
|
||||
qWarning()<<"count process start failed";
|
||||
return false;
|
||||
}
|
||||
if(!mount.waitForFinished()){
|
||||
qWarning()<<"装载失败";
|
||||
return false;
|
||||
}
|
||||
if(QProcess::NormalExit == mount.exitCode()){
|
||||
qInfo()<<"Mount success!";
|
||||
return true;
|
||||
}
|
||||
qWarning()<<"An unknown error occurred! Mount process exit code:"<<mount.exitCode();
|
||||
return false;
|
||||
}
|
||||
bool SystemDbusRegister::isMakingSucess()
|
||||
{
|
||||
QProcess lsblk;
|
||||
|
@ -212,3 +444,18 @@ QJsonArray SystemDbusRegister::QStringToJsonArray(const QString jsonString){
|
|||
QJsonObject obj = jsonDocument.object();
|
||||
return obj["blockdevices"].toArray();
|
||||
}
|
||||
QJsonArray SystemDbusRegister::QStringToJsonArray1(const QString jsonString){
|
||||
QJsonParseError err;
|
||||
QJsonDocument jsonDocument = QJsonDocument::fromJson(jsonString.toLocal8Bit().data(),&err);
|
||||
if(jsonDocument.isNull())
|
||||
{
|
||||
qDebug()<< "JsonDocument is NULL.Origin data is:"<< jsonString.toLocal8Bit().data();
|
||||
}
|
||||
if(err.error != QJsonParseError::NoError){
|
||||
qDebug()<<"Parase json"<<jsonString<<" error:"<<err.error;
|
||||
//TODO:这里的错误处理后期还可以优化,目前处理错误了就会调用exit()退出程序
|
||||
// exit(-1);
|
||||
}
|
||||
QJsonObject obj = jsonDocument.object();
|
||||
return obj["children"].toArray();
|
||||
}
|
||||
|
|
|
@ -54,12 +54,13 @@ public slots:
|
|||
Q_SCRIPTABLE void MakeExit();
|
||||
void handletimeout();
|
||||
void dd_finished(int,QProcess::ExitStatus);
|
||||
void clear_finished(int,QProcess::ExitStatus);
|
||||
private:
|
||||
void readBashStandardErrorInfo();
|
||||
void finishEvent();
|
||||
bool unmountDevice(QString);
|
||||
bool isMakingSucess();
|
||||
|
||||
void udiskmountpoint();
|
||||
private:
|
||||
QString uDiskPath = "";
|
||||
qint64 sourceFileSize = 0;
|
||||
|
@ -67,6 +68,7 @@ private:
|
|||
QTimer *time;
|
||||
QString sourceFile;
|
||||
QJsonArray QStringToJsonArray(const QString);
|
||||
QJsonArray QStringToJsonArray1(const QString);
|
||||
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue