ledok
This commit is contained in:
parent
38b63542f3
commit
6a8c7e5cad
|
@ -130,7 +130,7 @@ void Downloader::startDownload (const QUrl& url)
|
|||
|
||||
/* Ensure that downloads directory exists */
|
||||
if (!m_downloadDir.exists())
|
||||
m_downloadDir.mkpath(".");
|
||||
m_downloadDir.mkpath(m_downloadDir.absolutePath());
|
||||
|
||||
/* Remove old downloads */
|
||||
QFile::remove (m_downloadDir.filePath (m_fileName));
|
||||
|
|
|
@ -56,8 +56,8 @@ ProgPanel::ProgPanel(QSettings &settings, QWidget *parent) : QWidget(parent) {
|
|||
auto item = new ProgItem(mProgsDir, dlg.fdName->text(), width, dlg.fdHeight->value(), dlg.fdRemark->toPlainText(), widths, max, mProgTree, this);
|
||||
item->save();//保存pro.json
|
||||
mProgTree->adjustCheckState();
|
||||
ProgEditorWin editor(item, gMainWin);
|
||||
editor.exec();
|
||||
auto editor = new ProgEditorWin(item, gMainWin);
|
||||
editor->show();
|
||||
});
|
||||
|
||||
bnEdit = new QPushButton(tr("Edit"));
|
||||
|
@ -79,7 +79,7 @@ ProgPanel::ProgPanel(QSettings &settings, QWidget *parent) : QWidget(parent) {
|
|||
bnImport->setProperty("ssType", "progManageTool");
|
||||
hBox->addWidget(bnImport);
|
||||
connect(bnImport, &QPushButton::clicked, this, [this] {
|
||||
QString dir = QFileDialog::getExistingDirectory(this, tr("Choose Directory"), "/home", QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
|
||||
auto dir = QFileDialog::getExistingDirectory(this, tr("Choose Directory"), "/home", QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
|
||||
if(dir.isEmpty()) return;
|
||||
QString progsDir = programsDir();
|
||||
if(dir.contains(progsDir, Qt::CaseInsensitive)) {
|
||||
|
@ -328,8 +328,8 @@ void ProgPanel::onEditClicked(bool){
|
|||
for(int i=0; i<cnt; i++) {
|
||||
if(mProgTree->topLevelItem(i)->checkState(0) == Qt::Checked) {
|
||||
auto item = static_cast<ProgItem*>(mProgTree->topLevelItem(i));
|
||||
ProgEditorWin editor(item, gMainWin);
|
||||
editor.exec();
|
||||
auto editor = new ProgEditorWin(item, gMainWin);
|
||||
editor->show();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -353,8 +353,8 @@ void ProgPanel::onCreateNewProgramOnOpenEditProgramWidget(QString name, QSize re
|
|||
auto item = new ProgItem(mProgsDir, name, res.width(), res.height(), remarks, splitWidths, max, mProgTree, this);
|
||||
item->save();//保存pro.json
|
||||
mProgTree->adjustCheckState();
|
||||
ProgEditorWin editor(item, gMainWin);
|
||||
editor.exec();
|
||||
auto editor = new ProgEditorWin(item, gMainWin);
|
||||
editor->show();
|
||||
}
|
||||
void ProgPanel::onDeleteClicked(bool){
|
||||
auto res = QMessageBox::information(this, tr("Tip Info"), tr("You will delete the selected solution(s),are you sure?"), QMessageBox::Ok, QMessageBox::Cancel);
|
||||
|
|
|
@ -14,7 +14,7 @@ void CopyDirThread::run() {
|
|||
|
||||
bool CopyDirThread::copyDir(const QString &fromDir, const QString &toDir, bool coverIfExist) {
|
||||
QDir targetDir(toDir);
|
||||
if(! targetDir.exists() && ! targetDir.mkdir(".")) return false;
|
||||
if(! targetDir.exists() && ! targetDir.mkdir(toDir)) return false;
|
||||
QFileInfoList fileInfos = QDir(fromDir).entryInfoList(QDir::AllEntries | QDir::NoDotAndDotDot);
|
||||
foreach(QFileInfo fileInfo, fileInfos) {
|
||||
if(fileInfo.isDir()) { //< 当为目录时,递归的进行copy
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#include "base/locolorselector.h"
|
||||
#include "cfg.h"
|
||||
#include "etext.h"
|
||||
#include "globaldefine.h"
|
||||
#include "tools.h"
|
||||
|
@ -636,7 +635,7 @@ QWidget* EText::attrWgt() {
|
|||
|
||||
bool EText::save(const QString &pageDir) {
|
||||
QString idDir = pageDir + QString("/%1-%2-%3-%4-%5").arg(zValue()).arg((int)x()).arg((int)y()).arg((int)mWidth).arg((int)mHeight);
|
||||
QDir(idDir).mkdir(".");
|
||||
QDir().mkpath(idDir);
|
||||
for(int i=0; i<mImgs.count(); i++) mImgs[i].save(idDir + QString("/text%1.png").arg(i));
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -2,13 +2,9 @@
|
|||
#include "cfg.h"
|
||||
#include "globaldefine.h"
|
||||
#include "tools.h"
|
||||
#include "program/eaclock.h"
|
||||
#include "program/eaudio.h"
|
||||
#include "program/edclock.h"
|
||||
#include "program/eenviron.h"
|
||||
#include "program/egif.h"
|
||||
#include "program/etext.h"
|
||||
#include "program/etimer.h"
|
||||
#include "program/evideo.h"
|
||||
#include <QBuffer>
|
||||
#include <QJsonArray>
|
||||
|
@ -41,7 +37,7 @@ void GenTmpThread::run() {
|
|||
|
||||
QFile jsonFile(srcDir+"/pro.json");
|
||||
if(! jsonFile.open(QIODevice::ReadOnly)) {
|
||||
onErr("Can't open "+srcDir+"/pro.json");
|
||||
emit onErr("Can't open "+srcDir+"/pro.json");
|
||||
return;
|
||||
}
|
||||
auto data = jsonFile.readAll();
|
||||
|
@ -49,7 +45,7 @@ void GenTmpThread::run() {
|
|||
QJsonParseError error;
|
||||
auto proJson = QJsonDocument::fromJson(data, &error);
|
||||
if(error.error != QJsonParseError::NoError) {
|
||||
onErr("Parse "+srcDir+"/pro.json Error: "+error.errorString());
|
||||
emit onErr("Parse "+srcDir+"/pro.json Error: "+error.errorString());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -98,9 +94,15 @@ void GenTmpThread::run() {
|
|||
|
||||
//如果是usb更新则生成压缩包,网络发送则不需要
|
||||
if(! zip_file.isEmpty()) {
|
||||
#ifdef Q_OS_WINDOWS
|
||||
QStringList args{"a", zip_file, dstDir+"/*"};
|
||||
if(! password.isEmpty()) args << "-p"+password;
|
||||
QProcess::execute("7z.exe", args);
|
||||
#else
|
||||
QStringList args{"-r", zip_file, dstDir};
|
||||
if(! password.isEmpty()) args << "-P "+password;
|
||||
QProcess::execute("zip", args);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ void PageListItem::updateJson() {
|
|||
bool PageListItem::saveFiles() {
|
||||
mPageDir = gProgItem->mProgDir + "/" + mAttr["name"].toString();
|
||||
QDir pageQDir(mPageDir);
|
||||
if(! pageQDir.exists() && ! pageQDir.mkpath(".")) return false;
|
||||
if(! pageQDir.exists() && ! pageQDir.mkpath(mPageDir)) return false;
|
||||
|
||||
QJsonArray elements;
|
||||
auto items = mScene->items();
|
||||
|
|
|
@ -37,16 +37,23 @@
|
|||
ProgItem *gProgItem{0};
|
||||
QWidget *gProgEditorWin;
|
||||
|
||||
ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QDialog(parent), mProgItem(progItem) {
|
||||
ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QWidget(parent), mProgItem(progItem) {
|
||||
gProgEditorWin = this;
|
||||
gProgItem = progItem;
|
||||
setWindowFlag(Qt::WindowContextHelpButtonHint, 0);
|
||||
setWindowFlag(Qt::WindowMaximizeButtonHint);
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
#ifdef Q_OS_WINDOWS
|
||||
setWindowFlag(Qt::Window);
|
||||
setWindowModality(Qt::WindowModal);
|
||||
#else
|
||||
setWindowFlag(Qt::Dialog);
|
||||
#endif
|
||||
setAttribute(Qt::WA_AlwaysShowToolTips);
|
||||
if(parent && ! parent->isMaximized()) resize(parent->size());
|
||||
if(! parent->isMaximized()) resize(parent->size());
|
||||
else resize(1280, 720);
|
||||
setWindowTitle(progItem->mName);
|
||||
|
||||
parent->setVisible(false);
|
||||
|
||||
auto vBox = new QVBoxLayout(this);
|
||||
vBox->setContentsMargins(0, 0, 0, 0);
|
||||
vBox->setSpacing(0);
|
||||
|
@ -532,7 +539,7 @@ ProgEditorWin::ProgEditorWin(ProgItem *progItem, QWidget *parent) : QDialog(pare
|
|||
foreach(QJsonObject pageJson, mPageJsons) {
|
||||
auto pageDir = mProgItem->mProgDir+"/"+pageJson["name"].toString();
|
||||
QDir dir(pageDir);
|
||||
if(! dir.exists() && ! dir.mkdir(".")) continue;
|
||||
if(! dir.exists() && ! dir.mkdir(pageDir)) continue;
|
||||
auto item = new PageListItem(pageJson, pageDir);
|
||||
listPage->addItem(item);
|
||||
listPage->setItemWidget(item, item->itemWgt());
|
||||
|
@ -554,10 +561,12 @@ void ProgEditorWin::closeEvent(QCloseEvent *event) {
|
|||
mProgItem->m_last = QDateTime::currentDateTime();
|
||||
mProgItem->m_fsize = dirFileSize(mProgItem->mProgDir);
|
||||
mProgItem->onSetProgram();
|
||||
if(! isProgChanged()) return;
|
||||
if(isProgChanged()) {
|
||||
auto res = QMessageBox::question(this, tr("Tip Info"), tr("Do you want to save the modifications?"), QMessageBox::Yes, QMessageBox::No, QMessageBox::Cancel);
|
||||
if(res == QMessageBox::Yes) onSave();
|
||||
else if(res == QMessageBox::Cancel) event->ignore();
|
||||
}
|
||||
parentWidget()->setVisible(true);
|
||||
}
|
||||
//停止每个页面元素的播放,将节目目录下的每个页面的文件夹另命名
|
||||
void ProgEditorWin::save() {
|
||||
|
@ -568,7 +577,7 @@ void ProgEditorWin::save() {
|
|||
foreach(auto item, items) static_cast<EBase*>(item)->freeFiles();
|
||||
}
|
||||
QDir progDir(mProgItem->mProgDir);
|
||||
if(! progDir.exists() && ! progDir.mkdir(".")) return;
|
||||
if(! progDir.exists() && ! progDir.mkdir(mProgItem->mProgDir)) return;
|
||||
QStringList pageNames = progDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks);
|
||||
foreach(QString pageName, pageNames) {
|
||||
if(! progDir.rename(pageName, pageName + PAGEDEL_SUFFIX)) QMessageBox::critical(this, tr("Error"), tr("Rename fail when saving")+" "+pageName);
|
||||
|
@ -625,7 +634,7 @@ void ProgEditorWin::onAddPage() {
|
|||
auto name = now.toString("yyyyMMddhhmmsszzz");
|
||||
auto pageDir = mProgItem->mProgDir+"/"+name;
|
||||
QDir dir(pageDir);
|
||||
if(! dir.exists() && ! dir.mkpath(".")) return;
|
||||
if(! dir.exists() && ! dir.mkpath(pageDir)) return;
|
||||
QJsonObject attr;
|
||||
attr["name"] = name;
|
||||
attr["order"] = listPage->count();
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
#ifndef PROGEDITORWIN_H
|
||||
#define PROGEDITORWIN_H
|
||||
#include "QtWidgets/qdialog.h"
|
||||
#include "program/pageeditor.h"
|
||||
#include <QListWidget>
|
||||
#include <QJsonObject>
|
||||
|
||||
class ProgPanel;
|
||||
class ProgItem;
|
||||
class ProgEditorWin : public QDialog {
|
||||
class ProgEditorWin : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ProgEditorWin(ProgItem *progItem, QWidget *parent = 0);
|
||||
explicit ProgEditorWin(ProgItem *progItem, QWidget *);
|
||||
|
||||
public slots:
|
||||
void onSave();
|
||||
|
|
|
@ -63,8 +63,8 @@ QPushButton:hover {
|
|||
m_bnName->setCursor(QCursor(Qt::PointingHandCursor));
|
||||
mTree->setItemWidget(this, ENUM_PROGRAMLISTHEADERITEM_NAME, m_bnName);
|
||||
connect(m_bnName, &QPushButton::clicked, this, [this] {
|
||||
ProgEditorWin editor(this, gMainWin);
|
||||
editor.exec();
|
||||
auto editor = new ProgEditorWin(this, gMainWin);
|
||||
editor->show();
|
||||
});
|
||||
m_bnExport = new QPushButton();
|
||||
m_bnExport->setCursor(QCursor(Qt::PointingHandCursor));
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "usbdetectdialog.h"
|
||||
#include <QVBoxLayout>
|
||||
#include "gutil/qgui.h"
|
||||
#include <QPushButton>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
|
@ -8,23 +8,14 @@
|
|||
#include <QMessageBox>
|
||||
#include <QTimerEvent>
|
||||
|
||||
UsbDetectDialog::UsbDetectDialog(QWidget *parent) : BaseDlg(parent) {
|
||||
UsbDetectDialog::UsbDetectDialog(QWidget *parent) : QDialog(parent) {
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
setWindowTitle(tr("Usb upgrade program"));
|
||||
resize(240, 220);
|
||||
auto vBox = new QVBoxLayout(this);
|
||||
|
||||
auto hBox = new QHBoxLayout();
|
||||
hBox->addStretch();
|
||||
auto bnClose = new QPushButton("X");
|
||||
bnClose->setProperty("ssType","progManageTool");
|
||||
bnClose->setFixedWidth(32);
|
||||
connect(bnClose, &QPushButton::clicked, this, &BaseDlg::close);
|
||||
hBox->addWidget(bnClose);
|
||||
auto vBox = new VBox(this);
|
||||
auto hBox = new HBox(vBox);
|
||||
|
||||
vBox->addLayout(hBox);
|
||||
|
||||
hBox = new QHBoxLayout();
|
||||
hBox->addWidget(new QLabel(tr("Password")));
|
||||
|
||||
fdPassword = new QLineEdit();
|
||||
|
@ -32,22 +23,20 @@ UsbDetectDialog::UsbDetectDialog(QWidget *parent) : BaseDlg(parent) {
|
|||
fdPassword->setPlaceholderText(tr("Input password"));
|
||||
hBox->addWidget(fdPassword);
|
||||
|
||||
vBox->addLayout(hBox);
|
||||
|
||||
fdDrives = new QListWidget();
|
||||
fdDrives->setSelectionRectVisible(true);
|
||||
fdDrives->setProperty("ssType", "usbList");
|
||||
fdDrives->setProperty("ssName", "usbListName");
|
||||
vBox->addWidget(fdDrives);
|
||||
|
||||
hBox = new QHBoxLayout();
|
||||
hBox = new HBox(vBox);
|
||||
hBox->addStretch();
|
||||
auto bnOk = new QPushButton(tr("OK"));
|
||||
bnOk->setProperty("ssType","progManageTool");
|
||||
connect(bnOk, &QPushButton::clicked, this, [this] {
|
||||
auto selects = fdDrives->selectedItems();
|
||||
if(selects.count() > 0) {
|
||||
for(auto select : selects) emit acceptData(select->text(), fdPassword->text());
|
||||
foreach(auto select, selects) emit acceptData(select->text(), fdPassword->text());
|
||||
accept();
|
||||
return;
|
||||
}
|
||||
|
@ -58,16 +47,19 @@ UsbDetectDialog::UsbDetectDialog(QWidget *parent) : BaseDlg(parent) {
|
|||
hBox->addStretch();
|
||||
auto bnCancel = new QPushButton(tr("Cancel"));
|
||||
bnCancel->setProperty("ssType","progManageTool");
|
||||
connect(bnCancel, &QPushButton::clicked, this, &BaseDlg::reject);
|
||||
connect(bnCancel, &QPushButton::clicked, this, &QDialog::reject);
|
||||
hBox->addWidget(bnCancel);
|
||||
hBox->addStretch();
|
||||
vBox->addLayout(hBox);
|
||||
|
||||
detectDriver();
|
||||
}
|
||||
|
||||
void UsbDetectDialog::detectDriver() {
|
||||
#ifdef Q_OS_WINDOWS
|
||||
auto drives = QDir::drives(); //获取当前系统的盘符
|
||||
#else
|
||||
auto drives = QDir("/Volumes").entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
|
||||
#endif
|
||||
fdDrives->clear();
|
||||
foreach(auto drive, drives) fdDrives->addItem(drive.filePath());
|
||||
foreach(auto drive, drives) fdDrives->addItem(drive.fileName());
|
||||
}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
#ifndef USBDETECTDIALOG_H
|
||||
#define USBDETECTDIALOG_H
|
||||
|
||||
#include <basedlg.h>
|
||||
#include <QDialog>
|
||||
#include <QListWidget>
|
||||
|
||||
class UsbDetectDialog : public BaseDlg {
|
||||
class UsbDetectDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit UsbDetectDialog(QWidget *parent = nullptr);
|
||||
explicit UsbDetectDialog(QWidget *parent = 0);
|
||||
signals:
|
||||
void acceptData(QString string1, QString string2);
|
||||
private:
|
||||
|
|
Loading…
Reference in New Issue
Block a user