#1808 - Synchronization done. Still missing a nice progress dialog with

a cancel button.
This commit is contained in:
bsongis
2014-12-03 19:58:07 +01:00
parent c2d772cfd6
commit 4a5f5432dd
5 changed files with 35 additions and 4 deletions
+4
View File
@@ -886,6 +886,7 @@
<file>themes/yerico/16/contributors.png</file>
<file>themes/yerico/16/stop.png</file>
<file>themes/yerico/16/write_eeprom.png</file>
<file>themes/yerico/16/sdsync.png</file>
<file>themes/yerico/24/paintbrush.png</file>
<file>themes/yerico/24/open.png</file>
<file>themes/yerico/24/edit.png</file>
@@ -929,6 +930,7 @@
<file>themes/yerico/24/contributors.png</file>
<file>themes/yerico/24/stop.png</file>
<file>themes/yerico/24/write_eeprom.png</file>
<file>themes/yerico/24/sdsync.png</file>
<file>themes/yerico/32/paintbrush.png</file>
<file>themes/yerico/32/open.png</file>
<file>themes/yerico/32/edit.png</file>
@@ -972,6 +974,7 @@
<file>themes/yerico/32/contributors.png</file>
<file>themes/yerico/32/stop.png</file>
<file>themes/yerico/32/write_eeprom.png</file>
<file>themes/yerico/32/sdsync.png</file>
<file>themes/yerico/48/paintbrush.png</file>
<file>themes/yerico/48/open.png</file>
<file>themes/yerico/48/edit.png</file>
@@ -1015,5 +1018,6 @@
<file>themes/yerico/48/contributors.png</file>
<file>themes/yerico/48/stop.png</file>
<file>themes/yerico/48/write_eeprom.png</file>
<file>themes/yerico/48/sdsync.png</file>
</qresource>
</RCC>
@@ -198,7 +198,7 @@ using namespace Open9xX9D;
OpentxTaranisSimulator::OpentxTaranisSimulator()
{
taranisSimulatorBoard = GetEepromInterface()->getBoard();
QString path=g.profile[g.id()].sdPath()+"/";
QString path = g.profile[g.id()].sdPath()+"/";
int i=0;
for (i=0; i< std::min(path.length(),1022); i++) {
simuSdDirectory[i]=path.at(i).toAscii();
+16
View File
@@ -64,6 +64,7 @@
#include "helpers.h"
#include "appdata.h"
#include "radionotfound.h"
#include "foldersync.h"
#define OPENTX_COMPANION_DOWNLOADS "http://downloads-20.open-tx.org/companion"
#define DONATE_STR "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QUZ48K4SEXDP2"
@@ -667,6 +668,15 @@ void MainWindow::contributors()
cd->exec();
}
void MainWindow::sdsync()
{
QString massstoragePath = FindMassstoragePath("SOUNDS");
if (!massstoragePath.isEmpty())
massstoragePath += "/..";
FoldersSyncTask syncTask(massstoragePath, g.profile[g.id()].sdPath());
syncTask.run();
}
void MainWindow::changelog()
{
contributorsDialog *cd = new contributorsDialog(this,1);
@@ -1462,8 +1472,11 @@ void MainWindow::updateMenus()
updateLanguageActions();
updateIconSizeActions();
updateIconThemeActions();
sdsyncAct->setEnabled(!FindMassstoragePath("SOUNDS").isEmpty());
setWindowTitle(tr("OpenTX Companion - FW: %1 - Profile: %2").arg(GetCurrentFirmware()->getName()).arg( g.profile[g.id()].name() ));
qDebug() << "updateMenus";
}
MdiChild *MainWindow::createMdiChild()
@@ -1600,6 +1613,7 @@ void MainWindow::createActions()
writeBackupToRadioAct = addAct("write_eeprom_file.png", tr("Write Backup to Radio"), tr("Write Backup from file to Radio"), SLOT(writeBackup()));
readBackupToFileAct = addAct("read_eeprom_file.png", tr("Backup Radio to File"), tr("Save a complete backup file of all settings and model data in the Radio"), SLOT(readBackup()));
contributorsAct = addAct("contributors.png", tr("Contributors..."), tr("A tribute to those who have contributed to OpenTX and Companion"), SLOT(contributors()));
sdsyncAct = addAct("sdsync.png", tr("SD Synchro"), tr("SD card synchronization"), SLOT(sdsync()));
compareAct->setEnabled(false);
simulateAct->setEnabled(false);
@@ -1629,6 +1643,7 @@ void MainWindow::createMenus()
fileMenu->addAction(simulateAct);
fileMenu->addAction(printAct);
fileMenu->addAction(compareAct);
fileMenu->addAction(sdsyncAct);
fileMenu->addSeparator();
fileMenu->addAction(exitAct);
@@ -1778,6 +1793,7 @@ void MainWindow::createToolBars()
fileToolBar->addAction(simulateAct);
fileToolBar->addAction(printAct);
fileToolBar->addAction(compareAct);
fileToolBar->addAction(sdsyncAct);
editToolBar = addToolBar(tr("Edit"));
editToolBar->setIconSize(size);
+2
View File
@@ -146,6 +146,7 @@ class MainWindow : public QMainWindow
void burnFuses();
void simulate();
void contributors();
void sdsync();
void changelog();
void fwchangelog();
void customizeSplash();
@@ -237,6 +238,7 @@ class MainWindow : public QMainWindow
QAction *fwPrefsAct;
QAction *checkForUpdatesAct;
QAction *contributorsAct;
QAction *sdsyncAct;
QAction *changelogAct;
QAction *fwchangelogAct;
QAction *compareAct;
+12 -3
View File
@@ -13,9 +13,17 @@ FoldersSyncTask::FoldersSyncTask(const QString &folder1, const QString &folder2)
void FoldersSyncTask::run()
{
if (!QFile::exists(folders[0])) {
QMessageBox::warning(NULL, QObject::tr("Synchronization error"), QObject::tr("The directory '%1' doesn't exist!").arg(folders[0]));
return;
}
if (!QFile::exists(folders[1])) {
QMessageBox::warning(NULL, QObject::tr("Synchronization error"), QObject::tr("The directory '%1' doesn't exist!").arg(folders[1]));
return;
}
QStringList errors = updateDir(folders[0], folders[1]) + updateDir(folders[1], folders[0]);
if (errors.count() > 0) {
QMessageBox::warning(NULL, QObject::tr("Copy errors"), errors.join("\n"));
QMessageBox::warning(NULL, QObject::tr("Synchronization error"), errors.join("\n"));
}
}
@@ -25,6 +33,7 @@ QStringList FoldersSyncTask::updateDir(const QDir &source, const QDir &destinati
QDirIterator it(source, QDirIterator::Subdirectories);
while (it.hasNext()) {
QString path = it.next();
// qDebug() << path;
QFileInfo sourceInfo(path);
QString relativePath = source.relativeFilePath(path);
QString destinationPath = destination.absoluteFilePath(relativePath);
@@ -39,7 +48,7 @@ QStringList FoldersSyncTask::updateDir(const QDir &source, const QDir &destinati
}
else {
if (!destinationInfo.exists()) {
// qDebug() << "Copy" << path << "to" << destinationPath;
qDebug() << "Copy" << path << "to" << destinationPath;
if (!QFile::copy(path, destinationPath)) {
errors << QObject::tr("Copy '%1' to '%2' failed").arg(path).arg(destinationPath);
continue;
@@ -68,7 +77,7 @@ QStringList FoldersSyncTask::updateDir(const QDir &source, const QDir &destinati
errors << QObject::tr("Write '%1' failed").arg(destinationPath);
continue;
}
// qDebug() << "Write" << destinationPath;
qDebug() << "Write" << destinationPath;
QTextStream destinationStream(&destinationFile);
destinationStream << sourceContents;
destinationFile.close();