#1808 - Synchronization done. Still missing a nice progress dialog with
a cancel button.
This commit is contained in:
@@ -886,6 +886,7 @@
|
|||||||
<file>themes/yerico/16/contributors.png</file>
|
<file>themes/yerico/16/contributors.png</file>
|
||||||
<file>themes/yerico/16/stop.png</file>
|
<file>themes/yerico/16/stop.png</file>
|
||||||
<file>themes/yerico/16/write_eeprom.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/paintbrush.png</file>
|
||||||
<file>themes/yerico/24/open.png</file>
|
<file>themes/yerico/24/open.png</file>
|
||||||
<file>themes/yerico/24/edit.png</file>
|
<file>themes/yerico/24/edit.png</file>
|
||||||
@@ -929,6 +930,7 @@
|
|||||||
<file>themes/yerico/24/contributors.png</file>
|
<file>themes/yerico/24/contributors.png</file>
|
||||||
<file>themes/yerico/24/stop.png</file>
|
<file>themes/yerico/24/stop.png</file>
|
||||||
<file>themes/yerico/24/write_eeprom.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/paintbrush.png</file>
|
||||||
<file>themes/yerico/32/open.png</file>
|
<file>themes/yerico/32/open.png</file>
|
||||||
<file>themes/yerico/32/edit.png</file>
|
<file>themes/yerico/32/edit.png</file>
|
||||||
@@ -972,6 +974,7 @@
|
|||||||
<file>themes/yerico/32/contributors.png</file>
|
<file>themes/yerico/32/contributors.png</file>
|
||||||
<file>themes/yerico/32/stop.png</file>
|
<file>themes/yerico/32/stop.png</file>
|
||||||
<file>themes/yerico/32/write_eeprom.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/paintbrush.png</file>
|
||||||
<file>themes/yerico/48/open.png</file>
|
<file>themes/yerico/48/open.png</file>
|
||||||
<file>themes/yerico/48/edit.png</file>
|
<file>themes/yerico/48/edit.png</file>
|
||||||
@@ -1015,5 +1018,6 @@
|
|||||||
<file>themes/yerico/48/contributors.png</file>
|
<file>themes/yerico/48/contributors.png</file>
|
||||||
<file>themes/yerico/48/stop.png</file>
|
<file>themes/yerico/48/stop.png</file>
|
||||||
<file>themes/yerico/48/write_eeprom.png</file>
|
<file>themes/yerico/48/write_eeprom.png</file>
|
||||||
|
<file>themes/yerico/48/sdsync.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|||||||
@@ -198,7 +198,7 @@ using namespace Open9xX9D;
|
|||||||
OpentxTaranisSimulator::OpentxTaranisSimulator()
|
OpentxTaranisSimulator::OpentxTaranisSimulator()
|
||||||
{
|
{
|
||||||
taranisSimulatorBoard = GetEepromInterface()->getBoard();
|
taranisSimulatorBoard = GetEepromInterface()->getBoard();
|
||||||
QString path=g.profile[g.id()].sdPath()+"/";
|
QString path = g.profile[g.id()].sdPath()+"/";
|
||||||
int i=0;
|
int i=0;
|
||||||
for (i=0; i< std::min(path.length(),1022); i++) {
|
for (i=0; i< std::min(path.length(),1022); i++) {
|
||||||
simuSdDirectory[i]=path.at(i).toAscii();
|
simuSdDirectory[i]=path.at(i).toAscii();
|
||||||
|
|||||||
@@ -64,6 +64,7 @@
|
|||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
#include "appdata.h"
|
#include "appdata.h"
|
||||||
#include "radionotfound.h"
|
#include "radionotfound.h"
|
||||||
|
#include "foldersync.h"
|
||||||
|
|
||||||
#define OPENTX_COMPANION_DOWNLOADS "http://downloads-20.open-tx.org/companion"
|
#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"
|
#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();
|
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()
|
void MainWindow::changelog()
|
||||||
{
|
{
|
||||||
contributorsDialog *cd = new contributorsDialog(this,1);
|
contributorsDialog *cd = new contributorsDialog(this,1);
|
||||||
@@ -1462,8 +1472,11 @@ void MainWindow::updateMenus()
|
|||||||
updateLanguageActions();
|
updateLanguageActions();
|
||||||
updateIconSizeActions();
|
updateIconSizeActions();
|
||||||
updateIconThemeActions();
|
updateIconThemeActions();
|
||||||
|
sdsyncAct->setEnabled(!FindMassstoragePath("SOUNDS").isEmpty());
|
||||||
|
|
||||||
setWindowTitle(tr("OpenTX Companion - FW: %1 - Profile: %2").arg(GetCurrentFirmware()->getName()).arg( g.profile[g.id()].name() ));
|
setWindowTitle(tr("OpenTX Companion - FW: %1 - Profile: %2").arg(GetCurrentFirmware()->getName()).arg( g.profile[g.id()].name() ));
|
||||||
|
|
||||||
|
qDebug() << "updateMenus";
|
||||||
}
|
}
|
||||||
|
|
||||||
MdiChild *MainWindow::createMdiChild()
|
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()));
|
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()));
|
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()));
|
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);
|
compareAct->setEnabled(false);
|
||||||
simulateAct->setEnabled(false);
|
simulateAct->setEnabled(false);
|
||||||
@@ -1629,6 +1643,7 @@ void MainWindow::createMenus()
|
|||||||
fileMenu->addAction(simulateAct);
|
fileMenu->addAction(simulateAct);
|
||||||
fileMenu->addAction(printAct);
|
fileMenu->addAction(printAct);
|
||||||
fileMenu->addAction(compareAct);
|
fileMenu->addAction(compareAct);
|
||||||
|
fileMenu->addAction(sdsyncAct);
|
||||||
fileMenu->addSeparator();
|
fileMenu->addSeparator();
|
||||||
fileMenu->addAction(exitAct);
|
fileMenu->addAction(exitAct);
|
||||||
|
|
||||||
@@ -1778,6 +1793,7 @@ void MainWindow::createToolBars()
|
|||||||
fileToolBar->addAction(simulateAct);
|
fileToolBar->addAction(simulateAct);
|
||||||
fileToolBar->addAction(printAct);
|
fileToolBar->addAction(printAct);
|
||||||
fileToolBar->addAction(compareAct);
|
fileToolBar->addAction(compareAct);
|
||||||
|
fileToolBar->addAction(sdsyncAct);
|
||||||
|
|
||||||
editToolBar = addToolBar(tr("Edit"));
|
editToolBar = addToolBar(tr("Edit"));
|
||||||
editToolBar->setIconSize(size);
|
editToolBar->setIconSize(size);
|
||||||
|
|||||||
@@ -146,6 +146,7 @@ class MainWindow : public QMainWindow
|
|||||||
void burnFuses();
|
void burnFuses();
|
||||||
void simulate();
|
void simulate();
|
||||||
void contributors();
|
void contributors();
|
||||||
|
void sdsync();
|
||||||
void changelog();
|
void changelog();
|
||||||
void fwchangelog();
|
void fwchangelog();
|
||||||
void customizeSplash();
|
void customizeSplash();
|
||||||
@@ -237,6 +238,7 @@ class MainWindow : public QMainWindow
|
|||||||
QAction *fwPrefsAct;
|
QAction *fwPrefsAct;
|
||||||
QAction *checkForUpdatesAct;
|
QAction *checkForUpdatesAct;
|
||||||
QAction *contributorsAct;
|
QAction *contributorsAct;
|
||||||
|
QAction *sdsyncAct;
|
||||||
QAction *changelogAct;
|
QAction *changelogAct;
|
||||||
QAction *fwchangelogAct;
|
QAction *fwchangelogAct;
|
||||||
QAction *compareAct;
|
QAction *compareAct;
|
||||||
|
|||||||
@@ -13,9 +13,17 @@ FoldersSyncTask::FoldersSyncTask(const QString &folder1, const QString &folder2)
|
|||||||
|
|
||||||
void FoldersSyncTask::run()
|
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]);
|
QStringList errors = updateDir(folders[0], folders[1]) + updateDir(folders[1], folders[0]);
|
||||||
if (errors.count() > 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);
|
QDirIterator it(source, QDirIterator::Subdirectories);
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
QString path = it.next();
|
QString path = it.next();
|
||||||
|
// qDebug() << path;
|
||||||
QFileInfo sourceInfo(path);
|
QFileInfo sourceInfo(path);
|
||||||
QString relativePath = source.relativeFilePath(path);
|
QString relativePath = source.relativeFilePath(path);
|
||||||
QString destinationPath = destination.absoluteFilePath(relativePath);
|
QString destinationPath = destination.absoluteFilePath(relativePath);
|
||||||
@@ -39,7 +48,7 @@ QStringList FoldersSyncTask::updateDir(const QDir &source, const QDir &destinati
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (!destinationInfo.exists()) {
|
if (!destinationInfo.exists()) {
|
||||||
// qDebug() << "Copy" << path << "to" << destinationPath;
|
qDebug() << "Copy" << path << "to" << destinationPath;
|
||||||
if (!QFile::copy(path, destinationPath)) {
|
if (!QFile::copy(path, destinationPath)) {
|
||||||
errors << QObject::tr("Copy '%1' to '%2' failed").arg(path).arg(destinationPath);
|
errors << QObject::tr("Copy '%1' to '%2' failed").arg(path).arg(destinationPath);
|
||||||
continue;
|
continue;
|
||||||
@@ -68,7 +77,7 @@ QStringList FoldersSyncTask::updateDir(const QDir &source, const QDir &destinati
|
|||||||
errors << QObject::tr("Write '%1' failed").arg(destinationPath);
|
errors << QObject::tr("Write '%1' failed").arg(destinationPath);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// qDebug() << "Write" << destinationPath;
|
qDebug() << "Write" << destinationPath;
|
||||||
QTextStream destinationStream(&destinationFile);
|
QTextStream destinationStream(&destinationFile);
|
||||||
destinationStream << sourceContents;
|
destinationStream << sourceContents;
|
||||||
destinationFile.close();
|
destinationFile.close();
|
||||||
|
|||||||
Reference in New Issue
Block a user