Refactoring fixes

This commit is contained in:
bsongis
2014-12-17 20:13:25 +01:00
parent 567dcd74f0
commit 5046f77cd9
5 changed files with 61 additions and 60 deletions
+2 -4
View File
@@ -715,6 +715,8 @@ void SetupPanel::updateStartupSwitches()
unsigned int switchStates = model->switchWarningStates;
for (int i=0; i<firmware->getCapability(Switches); i++) {
if (!IS_TARANIS(firmware->getBoard()) && i==firmware->getCapability(Switches)-1)
continue;
QSlider * slider = startupSwitchesSliders[i];
QCheckBox * cb = startupSwitchesCheckboxes[i];
bool enabled = !(model->switchWarningEnable & (1 << i));
@@ -725,10 +727,6 @@ void SetupPanel::updateStartupSwitches()
switchStates >>= 2;
}
else {
if (i == firmware->getCapability(Switches)-1) {
// Trainer switch, no switch warning
continue;
}
slider->setValue(i==0 ? switchStates & 0x3 : switchStates & 0x1);
switchStates >>= (i==0 ? 2 : 1);
}
+1 -3
View File
@@ -28,9 +28,7 @@
#ifndef MOUNTLIST_H_
# define MOUNTLIST_H_
#if defined WIN32 || !defined __GNUC__
#define bool char
#else
#if defined __GNUC__
# include <stdbool.h>
#endif
+4 -4
View File
@@ -74,7 +74,7 @@ void FlashProcess::onStarted()
}
# if !__GNUC__
bool KillProcessByName(const char *szProcessToKill)
bool killProcessByName(const char *szProcessToKill)
{
HANDLE hProcessSnap;
HANDLE hProcess;
@@ -107,13 +107,13 @@ bool KillProcessByName(const char *szProcessToKill)
}
#endif
# if !__GNUC__
void FlashProcess::onKillTimerElapsed()
{
# if !__GNUC__
// trick to accelerate SAM-BA startup
KillProcessByName("tasklist.exe");
}
killProcessByName("tasklist.exe");
#endif
}
void FlashProcess::analyseStandardOutput(const QString &text)
{
+5
View File
@@ -7,6 +7,7 @@
class ProgressWidget;
class QProcess;
class QTimer;
class FlashProcess : public QObject
{
@@ -25,6 +26,7 @@ protected slots:
void onReadyReadStandardOutput();
void onReadyReadStandardError();
void onFinished(int);
void onKillTimerElapsed();
protected:
void analyseStandardOutput(const QString &text);
@@ -43,6 +45,9 @@ protected:
unsigned int efuse;
enum FlashPhase { READING, WRITING, VERIFYING };
FlashPhase flashPhase;
#if !__GNUC__
QTimer *killTimer;
#endif
};
#endif // FLASHPROCESS_H_
+49 -49
View File
@@ -30,55 +30,6 @@ QString getRadioInterfaceCmd()
}
}
QString findMassstoragePath(const QString &filename)
{
QString temppath;
QStringList drives;
QString eepromfile;
QString fsname;
#if defined WIN32 || !defined __GNUC__
foreach( QFileInfo drive, QDir::drives() ) {
WCHAR szVolumeName[256] ;
WCHAR szFileSystemName[256];
DWORD dwSerialNumber = 0;
DWORD dwMaxFileNameLength=256;
DWORD dwFileSystemFlags=0;
bool ret = GetVolumeInformationW( (WCHAR *) drive.absolutePath().utf16(),szVolumeName,256,&dwSerialNumber,&dwMaxFileNameLength,&dwFileSystemFlags,szFileSystemName,256);
if (ret) {
QString vName = QString::fromUtf16 ( (const ushort *) szVolumeName) ;
temppath = drive.absolutePath();
eepromfile = temppath;
eepromfile.append("/" + filename);
if (QFile::exists(eepromfile)) {
return eepromfile;
}
}
}
#else
struct mount_entry *entry;
entry = read_file_system_list(true);
while (entry != NULL) {
if (!drives.contains(entry->me_devname)) {
drives.append(entry->me_devname);
temppath = entry->me_mountdir;
eepromfile = temppath;
eepromfile.append("/" + filename);
#if !defined __APPLE__
QString fstype = entry->me_type;
if (QFile::exists(eepromfile) && fstype.contains("fat") ) {
#else
if (QFile::exists(eepromfile)) {
#endif
return eepromfile;
}
}
entry = entry->me_next;
}
#endif
return QString();
}
QStringList getAvrdudeArgs(const QString &cmd, const QString &filename)
{
QStringList args;
@@ -407,3 +358,52 @@ bool writeEeprom(const QString &filename, ProgressWidget *progress)
return false;
}
QString findMassstoragePath(const QString &filename)
{
QString temppath;
QStringList drives;
QString eepromfile;
QString fsname;
#if defined WIN32 || !defined __GNUC__
foreach(QFileInfo drive, QDir::drives()) {
WCHAR szVolumeName[256] ;
WCHAR szFileSystemName[256];
DWORD dwSerialNumber = 0;
DWORD dwMaxFileNameLength=256;
DWORD dwFileSystemFlags=0;
bool ret = GetVolumeInformationW( (WCHAR *) drive.absolutePath().utf16(),szVolumeName,256,&dwSerialNumber,&dwMaxFileNameLength,&dwFileSystemFlags,szFileSystemName,256);
if (ret) {
QString vName = QString::fromUtf16 ( (const ushort *) szVolumeName) ;
temppath = drive.absolutePath();
eepromfile = temppath;
eepromfile.append("/" + filename);
if (QFile::exists(eepromfile)) {
return eepromfile;
}
}
}
#else
struct mount_entry *entry;
entry = read_file_system_list(true);
while (entry != NULL) {
if (!drives.contains(entry->me_devname)) {
drives.append(entry->me_devname);
temppath = entry->me_mountdir;
eepromfile = temppath;
eepromfile.append("/" + filename);
#if !defined __APPLE__
QString fstype = entry->me_type;
if (QFile::exists(eepromfile) && fstype.contains("fat") ) {
#else
if (QFile::exists(eepromfile)) {
#endif
return eepromfile;
}
}
entry = entry->me_next;
}
#endif
return QString();
}