Improved: Switched to stricter code formatter (Uncrustify) for better consistency across all source files.

This commit is contained in:
jthedering committed 2015-11-23 21:17:34 +00:00
1 parent a1be4cc70f
commit 57e8158efd
143 files changed
+1989 -1678

No files matched your search

+29 -29
View File
@@ -46,7 +46,7 @@ int main(int argc, char** argv)
{ {
stringstream versionStream; stringstream versionStream;
versionStream << MAJOR << "." << MINOR; versionStream << MAJOR << "." << MINOR;
if(REVISION != 0) if (REVISION != 0)
versionStream << "." << REVISION; versionStream << "." << REVISION;
TCLAP::CmdLine cmd("Benchmark generates a linear sine sweep or reads from the given input file. " TCLAP::CmdLine cmd("Benchmark generates a linear sine sweep or reads from the given input file. "
"It then filters the waveform using the Equalizer APO filter configuration " "It then filters the waveform using the Equalizer APO filter configuration "
@@ -71,8 +71,8 @@ int main(int argc, char** argv)
bool verbose = verboseArg.getValue(); bool verbose = verboseArg.getValue();
LogHelper::set(stderr, verbose, true, true); LogHelper::set(stderr, verbose, true, true);
#ifdef _DEBUG #ifdef _DEBUG
_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
//_CrtSetBreakAlloc(3318); // _CrtSetBreakAlloc(3318);
#endif #endif
unsigned sampleRate; unsigned sampleRate;
@@ -82,7 +82,7 @@ int main(int argc, char** argv)
float length; float length;
float* buf; float* buf;
if(REVISION == 0) if (REVISION == 0)
printf("Benchmark %d.%d\n", MAJOR, MINOR); printf("Benchmark %d.%d\n", MAJOR, MINOR);
else else
printf("Benchmark %d.%d.%d\n", MAJOR, MINOR, REVISION); printf("Benchmark %d.%d.%d\n", MAJOR, MINOR, REVISION);
@@ -91,7 +91,7 @@ int main(int argc, char** argv)
printf("\n"); printf("\n");
string input = inputArg.getValue(); string input = inputArg.getValue();
if(input != "") if (input != "")
{ {
printf("Reading sound data from %s\n", input.c_str()); printf("Reading sound data from %s\n", input.c_str());
@@ -100,7 +100,7 @@ int main(int argc, char** argv)
SF_INFO info; SF_INFO info;
SNDFILE* inFile = sf_open(input.c_str(), SFM_READ, &info); SNDFILE* inFile = sf_open(input.c_str(), SFM_READ, &info);
if(inFile == NULL) if (inFile == NULL)
{ {
fprintf(stderr, "%s", sf_strerror(inFile)); fprintf(stderr, "%s", sf_strerror(inFile));
return 1; return 1;
@@ -115,7 +115,7 @@ int main(int argc, char** argv)
buf = new float[frameCount * channelCount]; buf = new float[frameCount * channelCount];
sf_count_t numRead = 0; sf_count_t numRead = 0;
while(numRead < frameCount) while (numRead < frameCount)
numRead += sf_readf_float(inFile, buf + numRead * channelCount, frameCount - numRead); numRead += sf_readf_float(inFile, buf + numRead * channelCount, frameCount - numRead);
sf_close(inFile); sf_close(inFile);
@@ -141,13 +141,13 @@ int main(int argc, char** argv)
timer.start(); timer.start();
buf = new float[frameCount * channelCount]; buf = new float[frameCount * channelCount];
for(unsigned i=0; i<frameCount; i++) for (unsigned i = 0; i < frameCount; i++)
{ {
double t=i*1.0 / sampleRate; double t = i * 1.0 / sampleRate;
float s = (float)sin(((sweepFrom + sweepDiff*(t/length)/2)*t)*2*M_PI); float s = (float)sin(((sweepFrom + sweepDiff * (t / length) / 2) * t) * 2 * M_PI);
for(unsigned j=0; j<channelCount; j++) for (unsigned j = 0; j < channelCount; j++)
buf[i*channelCount + j] = s; buf[i * channelCount + j] = s;
} }
double genTime = timer.stop(); double genTime = timer.stop();
@@ -157,8 +157,8 @@ int main(int argc, char** argv)
unsigned batchsize = batchsizeArg.getValue(); unsigned batchsize = batchsizeArg.getValue();
float* buf2 = new float[frameCount * channelCount]; float* buf2 = new float[frameCount * channelCount];
for(unsigned i=0;i<frameCount*channelCount;i++) for (unsigned i = 0; i < frameCount * channelCount; i++)
buf2[i]=0.0f; buf2[i] = 0.0f;
PrecisionTimer timer; PrecisionTimer timer;
timer.start(); timer.start();
@@ -170,16 +170,16 @@ int main(int argc, char** argv)
engine.initialize((float)sampleRate, channelCount, channelCount, channelCount, channelMask, batchsize); engine.initialize((float)sampleRate, channelCount, channelCount, channelCount, channelMask, batchsize);
double initTime = timer.stop(); double initTime = timer.stop();
if(!verbose) if (!verbose)
printf("\nLoading configuration took %g ms\n", initTime * 1000.0); printf("\nLoading configuration took %g ms\n", initTime * 1000.0);
printf("\nProcessing %d frames from %d channel(s)\n", frameCount, channelCount); printf("\nProcessing %d frames from %d channel(s)\n", frameCount, channelCount);
timer.start(); timer.start();
for(unsigned i=0; i<frameCount; i+=batchsize) for (unsigned i = 0; i < frameCount; i += batchsize)
{ {
engine.process(buf2 + i*channelCount, buf + i*channelCount, min(batchsize, frameCount - i)); engine.process(buf2 + i * channelCount, buf + i * channelCount, min(batchsize, frameCount - i));
} }
double time = timer.stop(); double time = timer.stop();
@@ -189,25 +189,25 @@ int main(int argc, char** argv)
unsigned clipCount = 0; unsigned clipCount = 0;
float max = 0; float max = 0;
for(unsigned i=0; i<frameCount*channelCount; i++) for (unsigned i = 0; i < frameCount * channelCount; i++)
{ {
float f = fabs(buf2[i]); float f = fabs(buf2[i]);
if(f > max) if (f > max)
max = f; max = f;
if(f > 1.0f) if (f > 1.0f)
clipCount++; clipCount++;
} }
printf("Max output level: %f (%f dB)", max, log10(max) * 20.0f); printf("Max output level: %f (%f dB)", max, log10(max) * 20.0f);
if(clipCount > 0) if (clipCount > 0)
printf(" (%d samples clipped!)", clipCount); printf(" (%d samples clipped!)", clipCount);
printf("\n"); printf("\n");
string output = outputArg.getValue(); string output = outputArg.getValue();
if(output == "") if (output == "")
{ {
char temp[255]; char temp[255];
GetTempPathA(sizeof(temp)/sizeof(wchar_t), temp); GetTempPathA(sizeof(temp) / sizeof(wchar_t), temp);
output = temp; output = temp;
output += "testout.wav"; output += "testout.wav";
@@ -217,28 +217,28 @@ int main(int argc, char** argv)
SF_INFO info = {frameCount, (int)sampleRate, (int)channelCount, SF_FORMAT_WAV | SF_FORMAT_PCM_16, 0}; SF_INFO info = {frameCount, (int)sampleRate, (int)channelCount, SF_FORMAT_WAV | SF_FORMAT_PCM_16, 0};
SNDFILE* outFile = sf_open(output.c_str(), SFM_WRITE, &info); SNDFILE* outFile = sf_open(output.c_str(), SFM_WRITE, &info);
if(outFile == NULL) if (outFile == NULL)
{ {
fprintf(stderr, "%s", sf_strerror(outFile)); fprintf(stderr, "%s", sf_strerror(outFile));
return 1; return 1;
} }
sf_count_t numWritten = 0; sf_count_t numWritten = 0;
while(numWritten < frameCount) while (numWritten < frameCount)
numWritten += sf_writef_float(outFile, buf2 + numWritten * channelCount, frameCount - numWritten); numWritten += sf_writef_float(outFile, buf2 + numWritten * channelCount, frameCount - numWritten);
sf_close(outFile); sf_close(outFile);
outFile = NULL; outFile = NULL;
delete[] buf; delete[]buf;
delete[] buf2; delete[]buf2;
if(!noPauseArg.getValue()) if (!noPauseArg.getValue())
system("pause"); system("pause");
return 0; return 0;
} }
catch(TCLAP::ArgException e) catch (TCLAP::ArgException e)
{ {
printf("Error: %s for arg %s\n", e.error().c_str(), e.argId().c_str()); printf("Error: %s for arg %s\n", e.error().c_str(), e.argId().c_str());
return -1; return -1;
+5 -5
View File
@@ -31,7 +31,7 @@ ClassFactory::ClassFactory()
HRESULT __stdcall ClassFactory::QueryInterface(const IID& iid, void** ppv) HRESULT __stdcall ClassFactory::QueryInterface(const IID& iid, void** ppv)
{ {
if(iid == __uuidof(IUnknown) || iid == __uuidof(IClassFactory)) if (iid == __uuidof(IUnknown) || iid == __uuidof(IClassFactory))
*ppv = static_cast<IClassFactory*>(this); *ppv = static_cast<IClassFactory*>(this);
else else
{ {
@@ -50,7 +50,7 @@ ULONG __stdcall ClassFactory::AddRef()
ULONG __stdcall ClassFactory::Release() ULONG __stdcall ClassFactory::Release()
{ {
if(InterlockedDecrement(&refCount) == 0) if (InterlockedDecrement(&refCount) == 0)
{ {
delete this; delete this;
return 0; return 0;
@@ -61,11 +61,11 @@ ULONG __stdcall ClassFactory::Release()
HRESULT __stdcall ClassFactory::CreateInstance(IUnknown* pUnknownOuter, const IID& iid, void** ppv) HRESULT __stdcall ClassFactory::CreateInstance(IUnknown* pUnknownOuter, const IID& iid, void** ppv)
{ {
if(pUnknownOuter != NULL && iid != __uuidof(IUnknown)) if (pUnknownOuter != NULL && iid != __uuidof(IUnknown))
return E_NOINTERFACE; return E_NOINTERFACE;
EqualizerAPO* apo = new EqualizerAPO(pUnknownOuter); EqualizerAPO* apo = new EqualizerAPO(pUnknownOuter);
if(apo == NULL) if (apo == NULL)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
HRESULT hr = apo->NonDelegatingQueryInterface(iid, ppv); HRESULT hr = apo->NonDelegatingQueryInterface(iid, ppv);
@@ -76,7 +76,7 @@ HRESULT __stdcall ClassFactory::CreateInstance(IUnknown* pUnknownOuter, const II
HRESULT __stdcall ClassFactory::LockServer(BOOL bLock) HRESULT __stdcall ClassFactory::LockServer(BOOL bLock)
{ {
if(bLock) if (bLock)
InterlockedIncrement(&lockCount); InterlockedIncrement(&lockCount);
else else
InterlockedDecrement(&lockCount); InterlockedDecrement(&lockCount);
+1 -1
View File
@@ -21,7 +21,7 @@
#include <Unknwn.h> #include <Unknwn.h>
class ClassFactory: public IClassFactory class ClassFactory : public IClassFactory
{ {
public: public:
ClassFactory(); ClassFactory();
+103 -103
View File
@@ -32,7 +32,7 @@ using namespace std;
Configurator* configurator; Configurator* configurator;
Configurator::Configurator(HINSTANCE hInstance, const wchar_t* cmdLine) Configurator::Configurator(HINSTANCE hInstance, const wchar_t* cmdLine)
:cmdLine(cmdLine) : cmdLine(cmdLine)
{ {
this->hInstance = hInstance; this->hInstance = hInstance;
hDlg = NULL; hDlg = NULL;
@@ -67,56 +67,56 @@ void Configurator::onInitDialog(HWND hDlg)
tci.pszText = stringBuf; tci.pszText = stringBuf;
tci.mask = TCIF_TEXT; tci.mask = TCIF_TEXT;
LoadStringW(hInstance, IDS_PLAYBACK_DEVICES, stringBuf, sizeof(stringBuf)/sizeof(wchar_t)); LoadStringW(hInstance, IDS_PLAYBACK_DEVICES, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
TabCtrl_InsertItem(categoryTabCtrl, 0, &tci); TabCtrl_InsertItem(categoryTabCtrl, 0, &tci);
LoadStringW(hInstance, IDS_CAPTURE_DEVICES, stringBuf, sizeof(stringBuf)/sizeof(wchar_t)); LoadStringW(hInstance, IDS_CAPTURE_DEVICES, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
TabCtrl_InsertItem(categoryTabCtrl, 1, &tci); TabCtrl_InsertItem(categoryTabCtrl, 1, &tci);
LoadStringW(hInstance, IDS_REQUEST, stringBuf, sizeof(stringBuf)/sizeof(wchar_t)); LoadStringW(hInstance, IDS_REQUEST, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
SetWindowTextW(requestLabel, stringBuf); SetWindowTextW(requestLabel, stringBuf);
LoadStringW(hInstance, IDS_COPY_DEVICE_COMMAND, stringBuf, sizeof(stringBuf)/sizeof(wchar_t)); LoadStringW(hInstance, IDS_COPY_DEVICE_COMMAND, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
SetWindowTextW(copyDeviceCommandButton, stringBuf); SetWindowTextW(copyDeviceCommandButton, stringBuf);
LoadStringW(hInstance, IDS_OK, stringBuf, sizeof(stringBuf)/sizeof(wchar_t)); LoadStringW(hInstance, IDS_OK, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
SetWindowTextW(okButton, stringBuf); SetWindowTextW(okButton, stringBuf);
LoadStringW(hInstance, IDS_CANCEL, stringBuf, sizeof(stringBuf)/sizeof(wchar_t)); LoadStringW(hInstance, IDS_CANCEL, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
SetWindowTextW(cancelButton, stringBuf); SetWindowTextW(cancelButton, stringBuf);
LoadStringW(hInstance, IDS_TOGGLE_TROUBLESHOOTING, stringBuf, sizeof(stringBuf)/sizeof(wchar_t)); LoadStringW(hInstance, IDS_TOGGLE_TROUBLESHOOTING, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
SetWindowTextW(toggleTroubleShooting, stringBuf); SetWindowTextW(toggleTroubleShooting, stringBuf);
int width = 185; int width = 185;
if(wcsncmp(stringBuf, L"Probleml", 8) == 0) if (wcsncmp(stringBuf, L"Probleml", 8) == 0)
width = 215; width = 215;
RECT rect = {0, 0, width, 10}; RECT rect = {0, 0, width, 10};
MapDialogRect(hDlg, &rect); MapDialogRect(hDlg, &rect);
SetWindowPos(toggleTroubleShooting, NULL, 0, 0, rect.right-rect.left, rect.bottom-rect.top, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER); SetWindowPos(toggleTroubleShooting, NULL, 0, 0, rect.right - rect.left, rect.bottom - rect.top, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER);
LoadStringW(hInstance, IDS_PRE_MIX_LABEL, stringBuf, sizeof(stringBuf)/sizeof(wchar_t)); LoadStringW(hInstance, IDS_PRE_MIX_LABEL, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
SetWindowTextW(preMixLabel, stringBuf); SetWindowTextW(preMixLabel, stringBuf);
LoadStringW(hInstance, IDS_POST_MIX_LABEL, stringBuf, sizeof(stringBuf)/sizeof(wchar_t)); LoadStringW(hInstance, IDS_POST_MIX_LABEL, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
SetWindowTextW(postMixLabel, stringBuf); SetWindowTextW(postMixLabel, stringBuf);
LoadStringW(hInstance, IDS_INSTALL_APO, stringBuf, sizeof(stringBuf)/sizeof(wchar_t)); LoadStringW(hInstance, IDS_INSTALL_APO, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
SetWindowTextW(installPreMix, stringBuf); SetWindowTextW(installPreMix, stringBuf);
SetWindowTextW(installPostMix, stringBuf); SetWindowTextW(installPostMix, stringBuf);
LoadStringW(hInstance, IDS_USE_ORIGINAL_APO, stringBuf, sizeof(stringBuf)/sizeof(wchar_t)); LoadStringW(hInstance, IDS_USE_ORIGINAL_APO, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
SetWindowTextW(useOriginalAPOPreMix, stringBuf); SetWindowTextW(useOriginalAPOPreMix, stringBuf);
SetWindowTextW(useOriginalAPOPostMix, stringBuf); SetWindowTextW(useOriginalAPOPostMix, stringBuf);
LoadStringW(hInstance, IDS_INSTALL_MODE_LFX_GFX, stringBuf, sizeof(stringBuf)/sizeof(wchar_t)); LoadStringW(hInstance, IDS_INSTALL_MODE_LFX_GFX, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
ComboBox_AddString(installModeComboBox, stringBuf); ComboBox_AddString(installModeComboBox, stringBuf);
if(RegistryHelper::isWindowsVersionAtLeast(6, 3)) // Windows 8.1 if (RegistryHelper::isWindowsVersionAtLeast(6, 3)) // Windows 8.1
{ {
LoadStringW(hInstance, IDS_INSTALL_MODE_SFX_MFX, stringBuf, sizeof(stringBuf)/sizeof(wchar_t)); LoadStringW(hInstance, IDS_INSTALL_MODE_SFX_MFX, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
ComboBox_AddString(installModeComboBox, stringBuf); ComboBox_AddString(installModeComboBox, stringBuf);
LoadStringW(hInstance, IDS_INSTALL_MODE_SFX_EFX, stringBuf, sizeof(stringBuf)/sizeof(wchar_t)); LoadStringW(hInstance, IDS_INSTALL_MODE_SFX_EFX, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
ComboBox_AddString(installModeComboBox, stringBuf); ComboBox_AddString(installModeComboBox, stringBuf);
} }
ComboBox_SetCurSel(installModeComboBox, 0); ComboBox_SetCurSel(installModeComboBox, 0);
@@ -124,7 +124,7 @@ void Configurator::onInitDialog(HWND hDlg)
LoadStringW(hInstance, IDS_SELECT_ONE_DEVICE, stringBuf, sizeof(stringBuf) / sizeof(wchar_t)); LoadStringW(hInstance, IDS_SELECT_ONE_DEVICE, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
SetWindowTextW(selectOneDeviceLabel, stringBuf); SetWindowTextW(selectOneDeviceLabel, stringBuf);
for(int i=0; i<=1; i++) for (int i = 0; i <= 1; i++)
{ {
HWND deviceList = deviceLists[i]; HWND deviceList = deviceLists[i];
ListView_SetExtendedListViewStyle(deviceList, ListView_GetExtendedListViewStyle(deviceList) | LVS_EX_CHECKBOXES); ListView_SetExtendedListViewStyle(deviceList, ListView_GetExtendedListViewStyle(deviceList) | LVS_EX_CHECKBOXES);
@@ -132,13 +132,13 @@ void Configurator::onInitDialog(HWND hDlg)
column.pszText = stringBuf; column.pszText = stringBuf;
column.mask = LVCF_TEXT; column.mask = LVCF_TEXT;
LoadStringW(hInstance, IDS_CONNECTOR, stringBuf, sizeof(stringBuf)/sizeof(wchar_t)); LoadStringW(hInstance, IDS_CONNECTOR, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
ListView_InsertColumn(deviceList, 0, &column); ListView_InsertColumn(deviceList, 0, &column);
LoadStringW(hInstance, IDS_DEVICE, stringBuf, sizeof(stringBuf)/sizeof(wchar_t)); LoadStringW(hInstance, IDS_DEVICE, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
ListView_InsertColumn(deviceList, 1, &column); ListView_InsertColumn(deviceList, 1, &column);
LoadStringW(hInstance, IDS_STATUS, stringBuf, sizeof(stringBuf)/sizeof(wchar_t)); LoadStringW(hInstance, IDS_STATUS, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
ListView_InsertColumn(deviceList, 2, &column); ListView_InsertColumn(deviceList, 2, &column);
LVITEM item; LVITEM item;
@@ -148,42 +148,42 @@ void Configurator::onInitDialog(HWND hDlg)
try try
{ {
apoInfos[i] = DeviceAPOInfo::loadAllInfos(i==1); apoInfos[i] = DeviceAPOInfo::loadAllInfos(i == 1);
wstring defaultDevice = StringHelper::toLowerCase(DeviceAPOInfo::getDefaultDevice(i==1)); wstring defaultDevice = StringHelper::toLowerCase(DeviceAPOInfo::getDefaultDevice(i == 1));
int itemCount=0; int itemCount = 0;
for(vector<DeviceAPOInfo>::iterator it = apoInfos[i].begin(); it != apoInfos[i].end(); it++) for (vector<DeviceAPOInfo>::iterator it = apoInfos[i].begin(); it != apoInfos[i].end(); it++)
{ {
wcsncpy_s(stringBuf, sizeof(stringBuf)/sizeof(wchar_t), it->connectionName.c_str(), _TRUNCATE); wcsncpy_s(stringBuf, sizeof(stringBuf) / sizeof(wchar_t), it->connectionName.c_str(), _TRUNCATE);
item.iItem = itemCount; item.iItem = itemCount;
item.lParam = itemCount; item.lParam = itemCount;
ListView_InsertItem(deviceList, &item); ListView_InsertItem(deviceList, &item);
wcsncpy_s(stringBuf, sizeof(stringBuf)/sizeof(wchar_t), it->deviceName.c_str(), _TRUNCATE); wcsncpy_s(stringBuf, sizeof(stringBuf) / sizeof(wchar_t), it->deviceName.c_str(), _TRUNCATE);
ListView_SetItemText(deviceList, itemCount, 1, stringBuf); ListView_SetItemText(deviceList, itemCount, 1, stringBuf);
if(it->isInstalled) if (it->isInstalled)
{ {
ListView_SetCheckState(deviceList, itemCount, TRUE); ListView_SetCheckState(deviceList, itemCount, TRUE);
if(it->canBeUpgraded()) if (it->canBeUpgraded())
LoadStringW(hInstance, IDS_WILL_BE_UPGRADED, stringBuf, sizeof(stringBuf) / sizeof(wchar_t)); LoadStringW(hInstance, IDS_WILL_BE_UPGRADED, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
else if(it->isEnhancementsDisabled) else if (it->isEnhancementsDisabled)
LoadStringW(hInstance, IDS_ENHANCEMENTS_WILL_BE_ENABLED, stringBuf, sizeof(stringBuf) / sizeof(wchar_t)); LoadStringW(hInstance, IDS_ENHANCEMENTS_WILL_BE_ENABLED, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
else else
LoadStringW(hInstance, IDS_ALREADY_INSTALLED, stringBuf, sizeof(stringBuf)/sizeof(wchar_t)); LoadStringW(hInstance, IDS_ALREADY_INSTALLED, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
} }
else if(it->isExperimental()) else if (it->isExperimental())
{ {
LoadStringW(hInstance, IDS_CAN_BE_INSTALLED_EXPERIMENTAL, stringBuf, sizeof(stringBuf)/sizeof(wchar_t)); LoadStringW(hInstance, IDS_CAN_BE_INSTALLED_EXPERIMENTAL, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
} }
else else
{ {
LoadStringW(hInstance, IDS_CAN_BE_INSTALLED, stringBuf, sizeof(stringBuf)/sizeof(wchar_t)); LoadStringW(hInstance, IDS_CAN_BE_INSTALLED, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
} }
if(it->isDefaultDevice) if (it->isDefaultDevice)
{ {
wstring statusText = stringBuf; wstring statusText = stringBuf;
LoadStringW(hInstance, IDS_DEFAULT_DEVICE, stringBuf, sizeof(stringBuf)/sizeof(wchar_t)); LoadStringW(hInstance, IDS_DEFAULT_DEVICE, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
statusText = wstring(stringBuf) + L", " + statusText; statusText = wstring(stringBuf) + L", " + statusText;
ListView_SetItemText(deviceList, itemCount, 2, const_cast<wchar_t*>(statusText.c_str())); ListView_SetItemText(deviceList, itemCount, 2, const_cast<wchar_t*>(statusText.c_str()));
@@ -196,7 +196,7 @@ void Configurator::onInitDialog(HWND hDlg)
itemCount++; itemCount++;
} }
} }
catch(RegistryException e) catch (RegistryException e)
{ {
MessageBoxW(hDlg, e.getMessage().c_str(), L"Error while accessing the registry", MB_ICONERROR | MB_OK); MessageBoxW(hDlg, e.getMessage().c_str(), L"Error while accessing the registry", MB_ICONERROR | MB_OK);
} }
@@ -226,15 +226,15 @@ void Configurator::onLvnItemChanged(unsigned sourceId, LPNMLISTVIEW info)
bool Configurator::onButtonClicked(unsigned sourceId) bool Configurator::onButtonClicked(unsigned sourceId)
{ {
switch(sourceId) switch (sourceId)
{ {
case IDOK: case IDOK:
{ {
for(int index = 0; index <= 1; index++) for (int index = 0; index <= 1; index++)
{ {
HWND deviceList = deviceLists[index]; HWND deviceList = deviceLists[index];
for(int i = 0; i < ListView_GetItemCount(deviceList); i++) for (int i = 0; i < ListView_GetItemCount(deviceList); i++)
{ {
LVITEM item; LVITEM item;
item.iItem = i; item.iItem = i;
@@ -245,18 +245,18 @@ bool Configurator::onButtonClicked(unsigned sourceId)
try try
{ {
DeviceAPOInfo info = apoInfos[index][item.lParam]; DeviceAPOInfo info = apoInfos[index][item.lParam];
if(ListView_GetCheckState(deviceList, i) && !info.isInstalled) if (ListView_GetCheckState(deviceList, i) && !info.isInstalled)
info.install(); info.install();
else if(!ListView_GetCheckState(deviceList, i) && info.isInstalled) else if (!ListView_GetCheckState(deviceList, i) && info.isInstalled)
info.uninstall(); info.uninstall();
else if(ListView_GetCheckState(deviceList, i) && (info.canBeUpgraded() || info.hasChanges() || info.isEnhancementsDisabled)) else if (ListView_GetCheckState(deviceList, i) && (info.canBeUpgraded() || info.hasChanges() || info.isEnhancementsDisabled))
{ {
info.uninstall(); info.uninstall();
info.load(info.deviceGuid); info.load(info.deviceGuid);
info.install(); info.install();
} }
} }
catch(RegistryException e) catch (RegistryException e)
{ {
MessageBoxW(hDlg, e.getMessage().c_str(), L"Error while accessing the registry", MB_ICONERROR | MB_OK); MessageBoxW(hDlg, e.getMessage().c_str(), L"Error while accessing the registry", MB_ICONERROR | MB_OK);
} }
@@ -272,7 +272,7 @@ bool Configurator::onButtonClicked(unsigned sourceId)
HWND deviceList = deviceLists[index]; HWND deviceList = deviceLists[index];
bool first = true; bool first = true;
for(int i = 0; i < ListView_GetItemCount(deviceList); i++) for (int i = 0; i < ListView_GetItemCount(deviceList); i++)
{ {
LVITEM item; LVITEM item;
item.iItem = i; item.iItem = i;
@@ -281,9 +281,9 @@ bool Configurator::onButtonClicked(unsigned sourceId)
item.stateMask = LVIS_SELECTED; item.stateMask = LVIS_SELECTED;
ListView_GetItem(deviceList, &item); ListView_GetItem(deviceList, &item);
if(item.state & LVIS_SELECTED) if (item.state & LVIS_SELECTED)
{ {
if(first) if (first)
first = false; first = false;
else else
command += L"; "; command += L"; ";
@@ -321,7 +321,7 @@ bool Configurator::onButtonClicked(unsigned sourceId)
HWND deviceList = deviceLists[index]; HWND deviceList = deviceLists[index];
unsigned selectedCount = ListView_GetSelectedCount(deviceList); unsigned selectedCount = ListView_GetSelectedCount(deviceList);
for(int i = 0; i < ListView_GetItemCount(deviceList); i++) for (int i = 0; i < ListView_GetItemCount(deviceList); i++)
{ {
LVITEM item; LVITEM item;
item.iItem = i; item.iItem = i;
@@ -330,11 +330,11 @@ bool Configurator::onButtonClicked(unsigned sourceId)
item.stateMask = LVIS_SELECTED; item.stateMask = LVIS_SELECTED;
ListView_GetItem(deviceList, &item); ListView_GetItem(deviceList, &item);
if(item.state & LVIS_SELECTED) if (item.state & LVIS_SELECTED)
{ {
DeviceAPOInfo& info = apoInfos[index][item.lParam]; DeviceAPOInfo& info = apoInfos[index][item.lParam];
switch(sourceId) switch (sourceId)
{ {
case IDC_INSTALL_PRE_MIX: case IDC_INSTALL_PRE_MIX:
info.selectedInstallState.installPreMix = Button_GetCheck(installPreMix) == BST_CHECKED; info.selectedInstallState.installPreMix = Button_GetCheck(installPreMix) == BST_CHECKED;
@@ -362,45 +362,45 @@ bool Configurator::onButtonClicked(unsigned sourceId)
break; break;
} }
if(sourceId == IDCANCEL && hasUpgrades()) if (sourceId == IDCANCEL && hasUpgrades())
{ {
wchar_t captionBuf[255]; wchar_t captionBuf[255];
LoadStringW(hInstance, IDS_CANCEL_UPGRADES_CAPTION, captionBuf, sizeof(captionBuf)/sizeof(wchar_t)); LoadStringW(hInstance, IDS_CANCEL_UPGRADES_CAPTION, captionBuf, sizeof(captionBuf) / sizeof(wchar_t));
wchar_t stringBuf[255]; wchar_t stringBuf[255];
LoadStringW(hInstance, IDS_CANCEL_UPGRADES, stringBuf, sizeof(stringBuf)/sizeof(wchar_t)); LoadStringW(hInstance, IDS_CANCEL_UPGRADES, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
if(MessageBoxW(hDlg, stringBuf, captionBuf, MB_ICONWARNING | MB_YESNO) == IDNO) if (MessageBoxW(hDlg, stringBuf, captionBuf, MB_ICONWARNING | MB_YESNO) == IDNO)
return false; return false;
} }
if(sourceId == IDOK || sourceId == IDCANCEL) if (sourceId == IDOK || sourceId == IDCANCEL)
{ {
if(cmdLine == L"/i") if (cmdLine == L"/i")
{ {
wchar_t stringBuf[255]; wchar_t stringBuf[255];
LoadStringW(hInstance, IDS_AFTERINSTALL, stringBuf, sizeof(stringBuf)/sizeof(wchar_t)); LoadStringW(hInstance, IDS_AFTERINSTALL, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
MessageBoxW(hDlg, stringBuf, L"Info", MB_ICONINFORMATION | MB_OK); MessageBoxW(hDlg, stringBuf, L"Info", MB_ICONINFORMATION | MB_OK);
} }
else if(sourceId == IDOK && RegistryHelper::isWindowsVersionAtLeast(6, 3) // Windows 8.1 else if (sourceId == IDOK && RegistryHelper::isWindowsVersionAtLeast(6, 3) // Windows 8.1
|| askForReboot) || askForReboot)
{ {
wchar_t captionBuf[255]; wchar_t captionBuf[255];
LoadStringW(hInstance, IDS_SHOULD_REBOOT_CAPTION, captionBuf, sizeof(captionBuf)/sizeof(wchar_t)); LoadStringW(hInstance, IDS_SHOULD_REBOOT_CAPTION, captionBuf, sizeof(captionBuf) / sizeof(wchar_t));
wchar_t stringBuf[255]; wchar_t stringBuf[255];
LoadStringW(hInstance, IDS_SHOULD_REBOOT, stringBuf, sizeof(stringBuf)/sizeof(wchar_t)); LoadStringW(hInstance, IDS_SHOULD_REBOOT, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
if(MessageBoxW(hDlg, stringBuf, captionBuf, MB_ICONQUESTION | MB_YESNO) == IDYES) if (MessageBoxW(hDlg, stringBuf, captionBuf, MB_ICONQUESTION | MB_YESNO) == IDYES)
{ {
HANDLE tokenHandle; HANDLE tokenHandle;
if(OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &tokenHandle)) if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &tokenHandle))
{ {
LUID luid; LUID luid;
if(LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &luid)) if (LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, &luid))
{ {
TOKEN_PRIVILEGES tp; TOKEN_PRIVILEGES tp;
tp.PrivilegeCount = 1; tp.PrivilegeCount = 1;
tp.Privileges[0].Luid = luid; tp.Privileges[0].Luid = luid;
tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
if(AdjustTokenPrivileges(tokenHandle, FALSE, &tp, sizeof(TOKEN_PRIVILEGES), NULL, NULL)) if (AdjustTokenPrivileges(tokenHandle, FALSE, &tp, sizeof(TOKEN_PRIVILEGES), NULL, NULL))
InitiateShutdownW(NULL, NULL, 0, SHUTDOWN_RESTART | SHUTDOWN_GRACE_OVERRIDE, SHTDN_REASON_MAJOR_APPLICATION | SHTDN_REASON_MINOR_MAINTENANCE); InitiateShutdownW(NULL, NULL, 0, SHUTDOWN_RESTART | SHUTDOWN_GRACE_OVERRIDE, SHTDN_REASON_MAJOR_APPLICATION | SHTDN_REASON_MINOR_MAINTENANCE);
} }
@@ -431,11 +431,11 @@ bool Configurator::isAnySelected()
{ {
bool anySelected = false; bool anySelected = false;
for(int index = 0; index <= 1; index++) for (int index = 0; index <= 1; index++)
{ {
HWND deviceList = deviceLists[index]; HWND deviceList = deviceLists[index];
for(int i = 0; i < ListView_GetItemCount(deviceList); i++) for (int i = 0; i < ListView_GetItemCount(deviceList); i++)
{ {
LVITEM item; LVITEM item;
item.iItem = i; item.iItem = i;
@@ -443,7 +443,7 @@ bool Configurator::isAnySelected()
item.mask = LVIF_PARAM; item.mask = LVIF_PARAM;
ListView_GetItem(deviceList, &item); ListView_GetItem(deviceList, &item);
DeviceAPOInfo apoInfo = apoInfos[index][item.lParam]; DeviceAPOInfo apoInfo = apoInfos[index][item.lParam];
if(ListView_GetCheckState(deviceList, i) != 0) if (ListView_GetCheckState(deviceList, i) != 0)
{ {
anySelected = true; anySelected = true;
break; break;
@@ -458,11 +458,11 @@ bool Configurator::isChanged()
{ {
bool changed = false; bool changed = false;
for(int index = 0; index <= 1; index++) for (int index = 0; index <= 1; index++)
{ {
HWND deviceList = deviceLists[index]; HWND deviceList = deviceLists[index];
for(int i = 0; i < ListView_GetItemCount(deviceList); i++) for (int i = 0; i < ListView_GetItemCount(deviceList); i++)
{ {
LVITEM item; LVITEM item;
item.iItem = i; item.iItem = i;
@@ -470,7 +470,7 @@ bool Configurator::isChanged()
item.mask = LVIF_PARAM; item.mask = LVIF_PARAM;
ListView_GetItem(deviceList, &item); ListView_GetItem(deviceList, &item);
DeviceAPOInfo apoInfo = apoInfos[index][item.lParam]; DeviceAPOInfo apoInfo = apoInfos[index][item.lParam];
if((ListView_GetCheckState(deviceList, i) != 0) != apoInfo.isInstalled if ((ListView_GetCheckState(deviceList, i) != 0) != apoInfo.isInstalled
|| ListView_GetCheckState(deviceList, i) && apoInfo.isInstalled && (apoInfo.canBeUpgraded() || apoInfo.hasChanges() || apoInfo.isEnhancementsDisabled)) || ListView_GetCheckState(deviceList, i) && apoInfo.isInstalled && (apoInfo.canBeUpgraded() || apoInfo.hasChanges() || apoInfo.isEnhancementsDisabled))
{ {
changed = true; changed = true;
@@ -486,11 +486,11 @@ bool Configurator::hasUpgrades()
{ {
bool hasUpgrades = false; bool hasUpgrades = false;
for(int index = 0; index <= 1; index++) for (int index = 0; index <= 1; index++)
{ {
HWND deviceList = deviceLists[index]; HWND deviceList = deviceLists[index];
for(int i = 0; i < ListView_GetItemCount(deviceList); i++) for (int i = 0; i < ListView_GetItemCount(deviceList); i++)
{ {
LVITEM item; LVITEM item;
item.iItem = i; item.iItem = i;
@@ -498,7 +498,7 @@ bool Configurator::hasUpgrades()
item.mask = LVIF_PARAM; item.mask = LVIF_PARAM;
ListView_GetItem(deviceList, &item); ListView_GetItem(deviceList, &item);
DeviceAPOInfo apoInfo = apoInfos[index][item.lParam]; DeviceAPOInfo apoInfo = apoInfos[index][item.lParam];
if(ListView_GetCheckState(deviceList, i) && apoInfo.isInstalled && (apoInfo.canBeUpgraded() || apoInfo.isEnhancementsDisabled)) if (ListView_GetCheckState(deviceList, i) && apoInfo.isInstalled && (apoInfo.canBeUpgraded() || apoInfo.isEnhancementsDisabled))
{ {
hasUpgrades = true; hasUpgrades = true;
break; break;
@@ -536,15 +536,15 @@ void Configurator::expandTroubleShooting(bool expand)
WINDOWINFO windowInfo; WINDOWINFO windowInfo;
GetWindowInfo(hDlg, &windowInfo); GetWindowInfo(hDlg, &windowInfo);
int height = expand ? 250 : 209; int height = expand ? 250 : 209;
RECT rect={0, 0, 401, height}; RECT rect = {0, 0, 401, height};
MapDialogRect(hDlg, &rect); MapDialogRect(hDlg, &rect);
AdjustWindowRect(&rect, windowInfo.dwStyle, false); AdjustWindowRect(&rect, windowInfo.dwStyle, false);
SetWindowPos(hDlg, NULL, 0, 0, rect.right-rect.left, rect.bottom-rect.top, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER); SetWindowPos(hDlg, NULL, 0, 0, rect.right - rect.left, rect.bottom - rect.top, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER);
} }
HDWP Configurator::moveWindow(HDWP hdwp, HWND hWnd, int x, int y) HDWP Configurator::moveWindow(HDWP hdwp, HWND hWnd, int x, int y)
{ {
RECT rect={x, y, 0, 0}; RECT rect = {x, y, 0, 0};
MapDialogRect(hDlg, &rect); MapDialogRect(hDlg, &rect);
return DeferWindowPos(hdwp, hWnd, NULL, rect.left, rect.top, 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER); return DeferWindowPos(hdwp, hWnd, NULL, rect.left, rect.top, 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER);
} }
@@ -555,32 +555,32 @@ void Configurator::updateList(int listIndex, int itemIndex)
int itemCount = ListView_GetItemCount(deviceList); int itemCount = ListView_GetItemCount(deviceList);
if(apoInfos[listIndex].size() == itemCount) if (apoInfos[listIndex].size() == itemCount)
{ {
DeviceAPOInfo apoInfo = apoInfos[listIndex][itemIndex]; DeviceAPOInfo apoInfo = apoInfos[listIndex][itemIndex];
bool checked = ListView_GetCheckState(deviceList, itemIndex) != 0; bool checked = ListView_GetCheckState(deviceList, itemIndex) != 0;
wchar_t stringBuf[255]; wchar_t stringBuf[255];
if(checked && !apoInfo.isInstalled) if (checked && !apoInfo.isInstalled)
LoadStringW(hInstance, IDS_WILL_BE_INSTALLED, stringBuf, sizeof(stringBuf)/sizeof(wchar_t)); LoadStringW(hInstance, IDS_WILL_BE_INSTALLED, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
else if(!checked && apoInfo.isInstalled) else if (!checked && apoInfo.isInstalled)
LoadStringW(hInstance, IDS_WILL_BE_UNINSTALLED, stringBuf, sizeof(stringBuf)/sizeof(wchar_t)); LoadStringW(hInstance, IDS_WILL_BE_UNINSTALLED, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
else if(apoInfo.isInstalled && apoInfo.canBeUpgraded()) else if (apoInfo.isInstalled && apoInfo.canBeUpgraded())
LoadStringW(hInstance, IDS_WILL_BE_UPGRADED, stringBuf, sizeof(stringBuf)/sizeof(wchar_t)); LoadStringW(hInstance, IDS_WILL_BE_UPGRADED, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
else if(apoInfo.isInstalled && apoInfo.hasChanges()) else if (apoInfo.isInstalled && apoInfo.hasChanges())
LoadStringW(hInstance, IDS_WILL_BE_CHANGED, stringBuf, sizeof(stringBuf)/sizeof(wchar_t)); LoadStringW(hInstance, IDS_WILL_BE_CHANGED, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
else if(apoInfo.isInstalled && apoInfo.isEnhancementsDisabled) else if (apoInfo.isInstalled && apoInfo.isEnhancementsDisabled)
LoadStringW(hInstance, IDS_ENHANCEMENTS_WILL_BE_ENABLED, stringBuf, sizeof(stringBuf) / sizeof(wchar_t)); LoadStringW(hInstance, IDS_ENHANCEMENTS_WILL_BE_ENABLED, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
else if(apoInfo.isInstalled) else if (apoInfo.isInstalled)
LoadStringW(hInstance, IDS_ALREADY_INSTALLED, stringBuf, sizeof(stringBuf)/sizeof(wchar_t)); LoadStringW(hInstance, IDS_ALREADY_INSTALLED, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
else if(apoInfo.isExperimental()) else if (apoInfo.isExperimental())
LoadStringW(hInstance, IDS_CAN_BE_INSTALLED_EXPERIMENTAL, stringBuf, sizeof(stringBuf)/sizeof(wchar_t)); LoadStringW(hInstance, IDS_CAN_BE_INSTALLED_EXPERIMENTAL, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
else else
LoadStringW(hInstance, IDS_CAN_BE_INSTALLED, stringBuf, sizeof(stringBuf)/sizeof(wchar_t)); LoadStringW(hInstance, IDS_CAN_BE_INSTALLED, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
if(apoInfo.isDefaultDevice) if (apoInfo.isDefaultDevice)
{ {
wstring statusText = stringBuf; wstring statusText = stringBuf;
LoadStringW(hInstance, IDS_DEFAULT_DEVICE, stringBuf, sizeof(stringBuf)/sizeof(wchar_t)); LoadStringW(hInstance, IDS_DEFAULT_DEVICE, stringBuf, sizeof(stringBuf) / sizeof(wchar_t));
statusText = wstring(stringBuf) + L", " + statusText; statusText = wstring(stringBuf) + L", " + statusText;
ListView_SetItemText(deviceList, itemIndex, 2, const_cast<wchar_t*>(statusText.c_str())); ListView_SetItemText(deviceList, itemIndex, 2, const_cast<wchar_t*>(statusText.c_str()));
@@ -600,7 +600,7 @@ void Configurator::updateButtons(int listIndex)
wchar_t stringBuf[255]; wchar_t stringBuf[255];
bool changed = isChanged(); bool changed = isChanged();
if(changed || !isAnySelected()) if (changed || !isAnySelected())
{ {
ShowWindow(okButton, SW_SHOW); ShowWindow(okButton, SW_SHOW);
EnableWindow(okButton, changed); EnableWindow(okButton, changed);
@@ -622,10 +622,10 @@ void Configurator::updateButtons(int listIndex)
bool hasOriginalAPOPreMix = true; bool hasOriginalAPOPreMix = true;
bool hasOriginalAPOPostMix = true; bool hasOriginalAPOPostMix = true;
DeviceAPOInfo::InstallState installState; DeviceAPOInfo::InstallState installState;
if(selectedCount == 1) if (selectedCount == 1)
{ {
int selectedIndex = ListView_GetNextItem(deviceList, -1, LVNI_SELECTED); int selectedIndex = ListView_GetNextItem(deviceList, -1, LVNI_SELECTED);
if(selectedIndex != -1) if (selectedIndex != -1)
{ {
enable = ListView_GetCheckState(deviceList, selectedIndex) != 0; enable = ListView_GetCheckState(deviceList, selectedIndex) != 0;
@@ -651,7 +651,7 @@ void Configurator::updateButtons(int listIndex)
Button_SetCheck(useOriginalAPOPreMix, installState.useOriginalAPOPreMix && hasOriginalAPOPreMix); Button_SetCheck(useOriginalAPOPreMix, installState.useOriginalAPOPreMix && hasOriginalAPOPreMix);
Button_SetCheck(useOriginalAPOPostMix, installState.useOriginalAPOPostMix && hasOriginalAPOPostMix); Button_SetCheck(useOriginalAPOPostMix, installState.useOriginalAPOPostMix && hasOriginalAPOPostMix);
if(RegistryHelper::isWindowsVersionAtLeast(6, 3)) // Windows 8.1 if (RegistryHelper::isWindowsVersionAtLeast(6, 3)) // Windows 8.1
ComboBox_SetCurSel(installModeComboBox, installState.installMode); ComboBox_SetCurSel(installModeComboBox, installState.installMode);
expandTroubleShooting(Button_GetCheck(toggleTroubleShooting) != 0); expandTroubleShooting(Button_GetCheck(toggleTroubleShooting) != 0);
@@ -673,17 +673,17 @@ int APIENTRY wWinMain(HINSTANCE hInstance,
int result = 0; int result = 0;
if(wcscmp(lpCmdLine, L"/u") == 0) if (wcscmp(lpCmdLine, L"/u") == 0)
{ {
for(int index = 0; index <= 1; index++) for (int index = 0; index <= 1; index++)
{ {
vector<DeviceAPOInfo> apoInfos = DeviceAPOInfo::loadAllInfos(index == 1); vector<DeviceAPOInfo> apoInfos = DeviceAPOInfo::loadAllInfos(index == 1);
for(vector<DeviceAPOInfo>::iterator it = apoInfos.begin(); it != apoInfos.end(); it++) for (vector<DeviceAPOInfo>::iterator it = apoInfos.begin(); it != apoInfos.end(); it++)
{ {
try try
{ {
if(it->isInstalled) if (it->isInstalled)
it->uninstall(); it->uninstall();
} }
catch (RegistryException e) catch (RegistryException e)
@@ -716,7 +716,7 @@ INT_PTR CALLBACK dlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
return (INT_PTR)TRUE; return (INT_PTR)TRUE;
case WM_COMMAND: case WM_COMMAND:
if(configurator->onButtonClicked(LOWORD(wParam))) if (configurator->onButtonClicked(LOWORD(wParam)))
{ {
EndDialog(hDlg, LOWORD(wParam)); EndDialog(hDlg, LOWORD(wParam));
return (INT_PTR)TRUE; return (INT_PTR)TRUE;
+95 -95
View File
@@ -73,12 +73,12 @@ vector<DeviceAPOInfo> DeviceAPOInfo::loadAllInfos(bool input)
vector<DeviceAPOInfo> result; vector<DeviceAPOInfo> result;
vector<wstring> deviceGuidStrings = RegistryHelper::enumSubKeys(input ? captureKeyPath : renderKeyPath); vector<wstring> deviceGuidStrings = RegistryHelper::enumSubKeys(input ? captureKeyPath : renderKeyPath);
wstring defaultDeviceGuid = getDefaultDevice(input); wstring defaultDeviceGuid = getDefaultDevice(input);
for(vector<wstring>::iterator it = deviceGuidStrings.begin(); it != deviceGuidStrings.end(); it++) for (vector<wstring>::iterator it = deviceGuidStrings.begin(); it != deviceGuidStrings.end(); it++)
{ {
wstring deviceGuidString = *it; wstring deviceGuidString = *it;
DeviceAPOInfo info; DeviceAPOInfo info;
if(info.load(deviceGuidString, defaultDeviceGuid)) if (info.load(deviceGuidString, defaultDeviceGuid))
{ {
info.selectedInstallState = info.currentInstallState; info.selectedInstallState = info.currentInstallState;
result.push_back(info); result.push_back(info);
@@ -94,20 +94,20 @@ wstring DeviceAPOInfo::getDefaultDevice(bool input, int role)
IMMDeviceEnumerator* enumerator = NULL; IMMDeviceEnumerator* enumerator = NULL;
HRESULT hr = CoCreateInstance(__uuidof(MMDeviceEnumerator), NULL, CLSCTX_ALL, __uuidof(IMMDeviceEnumerator), (void**)&enumerator); HRESULT hr = CoCreateInstance(__uuidof(MMDeviceEnumerator), NULL, CLSCTX_ALL, __uuidof(IMMDeviceEnumerator), (void**)&enumerator);
if(SUCCEEDED(hr)) if (SUCCEEDED(hr))
{ {
IMMDevice* endPoint = NULL; IMMDevice* endPoint = NULL;
hr = enumerator->GetDefaultAudioEndpoint(input ? eCapture : eRender, (ERole)role, &endPoint); hr = enumerator->GetDefaultAudioEndpoint(input ? eCapture : eRender, (ERole)role, &endPoint);
if(SUCCEEDED(hr)) if (SUCCEEDED(hr))
{ {
IPropertyStore* propertyStore = NULL; IPropertyStore* propertyStore = NULL;
hr = endPoint->OpenPropertyStore(STGM_READ, &propertyStore); hr = endPoint->OpenPropertyStore(STGM_READ, &propertyStore);
if(SUCCEEDED(hr)) if (SUCCEEDED(hr))
{ {
PROPVARIANT variant; PROPVARIANT variant;
PropVariantInit(&variant); PropVariantInit(&variant);
hr = propertyStore->GetValue(guidPropertyKey, &variant); hr = propertyStore->GetValue(guidPropertyKey, &variant);
if(SUCCEEDED(hr)) if (SUCCEEDED(hr))
{ {
result = variant.pwszVal; result = variant.pwszVal;
PropVariantClear(&variant); PropVariantClear(&variant);
@@ -151,7 +151,7 @@ bool DeviceAPOInfo::checkAPORegistration(bool fix)
if (fix) if (fix)
{ {
wchar_t path[MAX_PATH]; wchar_t path[MAX_PATH];
if(GetModuleFileNameW(NULL, path, MAX_PATH) != 0) if (GetModuleFileNameW(NULL, path, MAX_PATH) != 0)
{ {
PathRemoveFileSpecW(path); PathRemoveFileSpecW(path);
wstring params = wstring(L"/s \"") + path + L"\\EqualizerAPO.dll\""; wstring params = wstring(L"/s \"") + path + L"\\EqualizerAPO.dll\"";
@@ -166,7 +166,7 @@ bool DeviceAPOInfo::checkAPORegistration(bool fix)
bool DeviceAPOInfo::load(const wstring& deviceGuid, wstring defaultDeviceGuid) bool DeviceAPOInfo::load(const wstring& deviceGuid, wstring defaultDeviceGuid)
{ {
wstring keyPath; wstring keyPath;
if(RegistryHelper::keyExists(renderKeyPath L"\\" + deviceGuid)) if (RegistryHelper::keyExists(renderKeyPath L"\\" + deviceGuid))
{ {
keyPath = renderKeyPath L"\\" + deviceGuid; keyPath = renderKeyPath L"\\" + deviceGuid;
isInput = false; isInput = false;
@@ -178,7 +178,7 @@ bool DeviceAPOInfo::load(const wstring& deviceGuid, wstring defaultDeviceGuid)
} }
unsigned long deviceState = RegistryHelper::readDWORDValue(keyPath, L"DeviceState"); unsigned long deviceState = RegistryHelper::readDWORDValue(keyPath, L"DeviceState");
if(deviceState & DEVICE_STATE_NOTPRESENT) if (deviceState & DEVICE_STATE_NOTPRESENT)
return false; return false;
this->deviceGuid = deviceGuid; this->deviceGuid = deviceGuid;
@@ -189,35 +189,35 @@ bool DeviceAPOInfo::load(const wstring& deviceGuid, wstring defaultDeviceGuid)
channelCount = 0; channelCount = 0;
sampleRate = 0; sampleRate = 0;
channelMask = 0; channelMask = 0;
if(RegistryHelper::valueExists(keyPath + L"\\Properties", formatValueName)) if (RegistryHelper::valueExists(keyPath + L"\\Properties", formatValueName))
{ {
std::vector<unsigned char> format = RegistryHelper::readBinaryValue(keyPath + L"\\Properties", formatValueName); std::vector<unsigned char> format = RegistryHelper::readBinaryValue(keyPath + L"\\Properties", formatValueName);
if(format.size() >= sizeof(WAVEFORMATEX) + 8) if (format.size() >= sizeof(WAVEFORMATEX) + 8)
{ {
WAVEFORMATEX* waveFormat = (WAVEFORMATEX*)&format[8]; WAVEFORMATEX* waveFormat = (WAVEFORMATEX*)&format[8];
channelCount = waveFormat->nChannels; channelCount = waveFormat->nChannels;
sampleRate = waveFormat->nSamplesPerSec; sampleRate = waveFormat->nSamplesPerSec;
if(waveFormat->wFormatTag == WAVE_FORMAT_EXTENSIBLE) if (waveFormat->wFormatTag == WAVE_FORMAT_EXTENSIBLE)
{ {
WAVEFORMATEXTENSIBLE* waveFormatExtensible = (WAVEFORMATEXTENSIBLE*)waveFormat; WAVEFORMATEXTENSIBLE* waveFormatExtensible = (WAVEFORMATEXTENSIBLE*)waveFormat;
channelMask = waveFormatExtensible->dwChannelMask; channelMask = waveFormatExtensible->dwChannelMask;
} }
} }
} }
if(channelMask == 0 && RegistryHelper::valueExists(keyPath + L"\\Properties", channelMaskValueName)) if (channelMask == 0 && RegistryHelper::valueExists(keyPath + L"\\Properties", channelMaskValueName))
channelMask = RegistryHelper::readDWORDValue(keyPath + L"\\Properties", channelMaskValueName); channelMask = RegistryHelper::readDWORDValue(keyPath + L"\\Properties", channelMaskValueName);
if(defaultDeviceGuid == L"") if (defaultDeviceGuid == L"")
defaultDeviceGuid = getDefaultDevice(isInput); defaultDeviceGuid = getDefaultDevice(isInput);
GUID guid1, guid2; GUID guid1, guid2;
if(SUCCEEDED(CLSIDFromString(deviceGuid.c_str(), &guid1)) && SUCCEEDED(CLSIDFromString(defaultDeviceGuid.c_str(), &guid2))) if (SUCCEEDED(CLSIDFromString(deviceGuid.c_str(), &guid1)) && SUCCEEDED(CLSIDFromString(defaultDeviceGuid.c_str(), &guid2)))
isDefaultDevice = (guid1 == guid2) != 0; isDefaultDevice = (guid1 == guid2) != 0;
else else
isDefaultDevice = false; isDefaultDevice = false;
isEnhancementsDisabled = false; isEnhancementsDisabled = false;
if(RegistryHelper::keyExists(keyPath + L"\\FxProperties") && RegistryHelper::valueExists(keyPath + L"\\FxProperties", disableEnhancementsValueName)) if (RegistryHelper::keyExists(keyPath + L"\\FxProperties") && RegistryHelper::valueExists(keyPath + L"\\FxProperties", disableEnhancementsValueName))
isEnhancementsDisabled = RegistryHelper::readDWORDValue(keyPath + L"\\FxProperties", disableEnhancementsValueName) != 0; isEnhancementsDisabled = RegistryHelper::readDWORDValue(keyPath + L"\\FxProperties", disableEnhancementsValueName) != 0;
isInstalled = false; isInstalled = false;
@@ -230,16 +230,16 @@ bool DeviceAPOInfo::load(const wstring& deviceGuid, wstring defaultDeviceGuid)
currentInstallState.useOriginalAPOPreMix = true; currentInstallState.useOriginalAPOPreMix = true;
currentInstallState.useOriginalAPOPostMix = !isInput; currentInstallState.useOriginalAPOPostMix = !isInput;
if(!RegistryHelper::keyExists(keyPath + L"\\FxProperties")) if (!RegistryHelper::keyExists(keyPath + L"\\FxProperties"))
{ {
for(int i = 0; i < allGuidValueNameCount; i++) for (int i = 0; i < allGuidValueNameCount; i++)
originalApoGuids[i] = APOGUID_NOKEY; originalApoGuids[i] = APOGUID_NOKEY;
} }
else else
{ {
for(int i = 0; i < allGuidValueNameCount; i++) for (int i = 0; i < allGuidValueNameCount; i++)
{ {
if(RegistryHelper::valueExists(keyPath + L"\\FxProperties", allGuidValueNames[i])) if (RegistryHelper::valueExists(keyPath + L"\\FxProperties", allGuidValueNames[i]))
originalApoGuids[i] = RegistryHelper::readValue(keyPath + L"\\FxProperties", allGuidValueNames[i]); originalApoGuids[i] = RegistryHelper::readValue(keyPath + L"\\FxProperties", allGuidValueNames[i]);
else else
originalApoGuids[i] = APOGUID_NOVALUE; originalApoGuids[i] = APOGUID_NOVALUE;
@@ -247,18 +247,18 @@ bool DeviceAPOInfo::load(const wstring& deviceGuid, wstring defaultDeviceGuid)
bool found = false; bool found = false;
bool foundAt[allGuidValueNameCount]; bool foundAt[allGuidValueNameCount];
for(int i = 0; i < allGuidValueNameCount; i++) for (int i = 0; i < allGuidValueNameCount; i++)
{ {
foundAt[i] = false; foundAt[i] = false;
if(RegistryHelper::valueExists(keyPath + L"\\FxProperties", allGuidValueNames[i])) if (RegistryHelper::valueExists(keyPath + L"\\FxProperties", allGuidValueNames[i]))
{ {
wstring apoGuidString = RegistryHelper::readValue(keyPath + L"\\FxProperties", allGuidValueNames[i]); wstring apoGuidString = RegistryHelper::readValue(keyPath + L"\\FxProperties", allGuidValueNames[i]);
GUID apoGuid; GUID apoGuid;
if(SUCCEEDED(CLSIDFromString(apoGuidString.c_str(), &apoGuid))) if (SUCCEEDED(CLSIDFromString(apoGuidString.c_str(), &apoGuid)))
{ {
if(apoGuid == EQUALIZERAPO_PRE_MIX_GUID || apoGuid == EQUALIZERAPO_POST_MIX_GUID) if (apoGuid == EQUALIZERAPO_PRE_MIX_GUID || apoGuid == EQUALIZERAPO_POST_MIX_GUID)
{ {
foundAt[i] = true; foundAt[i] = true;
found = true; found = true;
@@ -267,16 +267,16 @@ bool DeviceAPOInfo::load(const wstring& deviceGuid, wstring defaultDeviceGuid)
} }
} }
if(found) if (found)
{ {
isInstalled = true; isInstalled = true;
if(RegistryHelper::keyExists(childApoPath L"\\" + deviceGuid)) if (RegistryHelper::keyExists(childApoPath L"\\" + deviceGuid))
{ {
if(RegistryHelper::valueExists(childApoPath L"\\" + deviceGuid, versionValueName)) if (RegistryHelper::valueExists(childApoPath L"\\" + deviceGuid, versionValueName))
{ {
version = RegistryHelper::readValue(childApoPath L"\\" + deviceGuid, versionValueName); version = RegistryHelper::readValue(childApoPath L"\\" + deviceGuid, versionValueName);
if(version != installVersion) if (version != installVersion)
throw RegistryException(L"Unsupported version of APO installation detected! Please uninstall newer Equalizer APO before using this version of Configurator."); throw RegistryException(L"Unsupported version of APO installation detected! Please uninstall newer Equalizer APO before using this version of Configurator.");
} }
else else
@@ -284,37 +284,37 @@ bool DeviceAPOInfo::load(const wstring& deviceGuid, wstring defaultDeviceGuid)
version = L"1"; version = L"1";
} }
for(int i = 0; i < allGuidValueNameCount; i++) for (int i = 0; i < allGuidValueNameCount; i++)
{ {
if(RegistryHelper::valueExists(childApoPath L"\\" + deviceGuid, allGuidValueNames[i])) if (RegistryHelper::valueExists(childApoPath L"\\" + deviceGuid, allGuidValueNames[i]))
originalApoGuids[i] = RegistryHelper::readValue(childApoPath L"\\" + deviceGuid, allGuidValueNames[i]); originalApoGuids[i] = RegistryHelper::readValue(childApoPath L"\\" + deviceGuid, allGuidValueNames[i]);
} }
if(version == installVersion) if (version == installVersion)
{ {
if(RegistryHelper::valueExists(childApoPath L"\\" + deviceGuid, preMixChildGuidValueName)) if (RegistryHelper::valueExists(childApoPath L"\\" + deviceGuid, preMixChildGuidValueName))
preMixChildGuid = RegistryHelper::readValue(childApoPath L"\\" + deviceGuid, preMixChildGuidValueName); preMixChildGuid = RegistryHelper::readValue(childApoPath L"\\" + deviceGuid, preMixChildGuidValueName);
if(RegistryHelper::valueExists(childApoPath L"\\" + deviceGuid, postMixChildGuidValueName)) if (RegistryHelper::valueExists(childApoPath L"\\" + deviceGuid, postMixChildGuidValueName))
postMixChildGuid = RegistryHelper::readValue(childApoPath L"\\" + deviceGuid, postMixChildGuidValueName); postMixChildGuid = RegistryHelper::readValue(childApoPath L"\\" + deviceGuid, postMixChildGuidValueName);
currentInstallState.installPreMix = foundAt[LFX_INDEX] || foundAt[SFX_INDEX]; currentInstallState.installPreMix = foundAt[LFX_INDEX] || foundAt[SFX_INDEX];
currentInstallState.installPostMix = foundAt[GFX_INDEX] || foundAt[MFX_INDEX] || foundAt[EFX_INDEX]; currentInstallState.installPostMix = foundAt[GFX_INDEX] || foundAt[MFX_INDEX] || foundAt[EFX_INDEX];
if(preMixChildGuid == L"") if (preMixChildGuid == L"")
currentInstallState.useOriginalAPOPreMix = false; currentInstallState.useOriginalAPOPreMix = false;
if(postMixChildGuid == L"") if (postMixChildGuid == L"")
currentInstallState.useOriginalAPOPostMix = false; currentInstallState.useOriginalAPOPostMix = false;
if(foundAt[LFX_INDEX] || foundAt[GFX_INDEX]) if (foundAt[LFX_INDEX] || foundAt[GFX_INDEX])
currentInstallState.installMode = INSTALL_LFX_GFX; currentInstallState.installMode = INSTALL_LFX_GFX;
else if(foundAt[EFX_INDEX]) else if (foundAt[EFX_INDEX])
currentInstallState.installMode = INSTALL_SFX_EFX; currentInstallState.installMode = INSTALL_SFX_EFX;
else if(foundAt[SFX_INDEX] || foundAt[MFX_INDEX]) else if (foundAt[SFX_INDEX] || foundAt[MFX_INDEX])
currentInstallState.installMode = INSTALL_SFX_MFX; currentInstallState.installMode = INSTALL_SFX_MFX;
} }
else else
{ {
if(RegistryHelper::valueExists(childApoPath L"\\" + deviceGuid, lfxGuidValueName)) if (RegistryHelper::valueExists(childApoPath L"\\" + deviceGuid, lfxGuidValueName))
{ {
preMixChildGuid = originalApoGuids[0]; preMixChildGuid = originalApoGuids[0];
postMixChildGuid = originalApoGuids[1]; postMixChildGuid = originalApoGuids[1];
@@ -326,14 +326,14 @@ bool DeviceAPOInfo::load(const wstring& deviceGuid, wstring defaultDeviceGuid)
} }
} }
} }
else if(RegistryHelper::valueExists(childApoPath, deviceGuid)) else if (RegistryHelper::valueExists(childApoPath, deviceGuid))
{ {
for(int i = 0; i < allGuidValueNameCount; i++) for (int i = 0; i < allGuidValueNameCount; i++)
{ {
if(foundAt[i]) if (foundAt[i])
{ {
originalApoGuids[i] = RegistryHelper::readValue(childApoPath, deviceGuid); originalApoGuids[i] = RegistryHelper::readValue(childApoPath, deviceGuid);
if(i == LFX_INDEX || i == SFX_INDEX) if (i == LFX_INDEX || i == SFX_INDEX)
preMixChildGuid = originalApoGuids[i]; preMixChildGuid = originalApoGuids[i];
else else
postMixChildGuid = originalApoGuids[i]; postMixChildGuid = originalApoGuids[i];
@@ -365,29 +365,29 @@ bool DeviceAPOInfo::isExperimental()
wstring DeviceAPOInfo::getOriginalAPOPreMix() wstring DeviceAPOInfo::getOriginalAPOPreMix()
{ {
wstring guid; wstring guid;
switch(selectedInstallState.installMode) switch (selectedInstallState.installMode)
{ {
case INSTALL_LFX_GFX: case INSTALL_LFX_GFX:
guid = originalApoGuids[LFX_INDEX]; guid = originalApoGuids[LFX_INDEX];
if(RegistryHelper::isWindowsVersionAtLeast(6, 3)) // Windows 8.1 if (RegistryHelper::isWindowsVersionAtLeast(6, 3)) // Windows 8.1
{ {
if(originalApoGuids[LFX_INDEX] == APOGUID_NOVALUE && originalApoGuids[GFX_INDEX] == APOGUID_NOVALUE) if (originalApoGuids[LFX_INDEX] == APOGUID_NOVALUE && originalApoGuids[GFX_INDEX] == APOGUID_NOVALUE)
guid = originalApoGuids[SFX_INDEX]; guid = originalApoGuids[SFX_INDEX];
} }
break; break;
case INSTALL_SFX_MFX: case INSTALL_SFX_MFX:
guid = originalApoGuids[SFX_INDEX]; guid = originalApoGuids[SFX_INDEX];
if(originalApoGuids[SFX_INDEX] == APOGUID_NOVALUE && originalApoGuids[MFX_INDEX] == APOGUID_NOVALUE) if (originalApoGuids[SFX_INDEX] == APOGUID_NOVALUE && originalApoGuids[MFX_INDEX] == APOGUID_NOVALUE)
guid = originalApoGuids[LFX_INDEX]; guid = originalApoGuids[LFX_INDEX];
break; break;
case INSTALL_SFX_EFX: case INSTALL_SFX_EFX:
guid = originalApoGuids[SFX_INDEX]; guid = originalApoGuids[SFX_INDEX];
if(originalApoGuids[SFX_INDEX] == APOGUID_NOVALUE && originalApoGuids[EFX_INDEX] == APOGUID_NOVALUE) if (originalApoGuids[SFX_INDEX] == APOGUID_NOVALUE && originalApoGuids[EFX_INDEX] == APOGUID_NOVALUE)
guid = originalApoGuids[LFX_INDEX]; guid = originalApoGuids[LFX_INDEX];
break; break;
} }
if(guid == APOGUID_NOKEY || guid == APOGUID_NOVALUE) if (guid == APOGUID_NOKEY || guid == APOGUID_NOVALUE)
guid = L""; guid = L"";
return guid; return guid;
@@ -396,29 +396,29 @@ wstring DeviceAPOInfo::getOriginalAPOPreMix()
wstring DeviceAPOInfo::getOriginalAPOPostMix() wstring DeviceAPOInfo::getOriginalAPOPostMix()
{ {
wstring guid; wstring guid;
switch(selectedInstallState.installMode) switch (selectedInstallState.installMode)
{ {
case INSTALL_LFX_GFX: case INSTALL_LFX_GFX:
guid = originalApoGuids[GFX_INDEX]; guid = originalApoGuids[GFX_INDEX];
if(RegistryHelper::isWindowsVersionAtLeast(6, 3)) // Windows 8.1 if (RegistryHelper::isWindowsVersionAtLeast(6, 3)) // Windows 8.1
{ {
if(originalApoGuids[LFX_INDEX] == APOGUID_NOVALUE && originalApoGuids[GFX_INDEX] == APOGUID_NOVALUE) if (originalApoGuids[LFX_INDEX] == APOGUID_NOVALUE && originalApoGuids[GFX_INDEX] == APOGUID_NOVALUE)
guid = originalApoGuids[MFX_INDEX]; guid = originalApoGuids[MFX_INDEX];
} }
break; break;
case INSTALL_SFX_MFX: case INSTALL_SFX_MFX:
guid = originalApoGuids[MFX_INDEX]; guid = originalApoGuids[MFX_INDEX];
if(originalApoGuids[SFX_INDEX] == APOGUID_NOVALUE && originalApoGuids[MFX_INDEX] == APOGUID_NOVALUE) if (originalApoGuids[SFX_INDEX] == APOGUID_NOVALUE && originalApoGuids[MFX_INDEX] == APOGUID_NOVALUE)
guid = originalApoGuids[GFX_INDEX]; guid = originalApoGuids[GFX_INDEX];
break; break;
case INSTALL_SFX_EFX: case INSTALL_SFX_EFX:
guid = originalApoGuids[EFX_INDEX]; guid = originalApoGuids[EFX_INDEX];
if(originalApoGuids[SFX_INDEX] == APOGUID_NOVALUE && originalApoGuids[EFX_INDEX] == APOGUID_NOVALUE) if (originalApoGuids[SFX_INDEX] == APOGUID_NOVALUE && originalApoGuids[EFX_INDEX] == APOGUID_NOVALUE)
guid = originalApoGuids[GFX_INDEX]; guid = originalApoGuids[GFX_INDEX];
break; break;
} }
if(guid == APOGUID_NOKEY || guid == APOGUID_NOVALUE) if (guid == APOGUID_NOKEY || guid == APOGUID_NOVALUE)
guid = L""; guid = L"";
return guid; return guid;
@@ -426,25 +426,25 @@ wstring DeviceAPOInfo::getOriginalAPOPostMix()
void DeviceAPOInfo::install() void DeviceAPOInfo::install()
{ {
if(!selectedInstallState.installPreMix && !selectedInstallState.installPostMix) if (!selectedInstallState.installPreMix && !selectedInstallState.installPostMix)
return; return;
RegistryHelper::createKey(childApoPath); RegistryHelper::createKey(childApoPath);
RegistryHelper::createKey(childApoPath L"\\" + deviceGuid); RegistryHelper::createKey(childApoPath L"\\" + deviceGuid);
wstring keyPath; wstring keyPath;
if(!isInput) if (!isInput)
keyPath = renderKeyPath L"\\" + deviceGuid; keyPath = renderKeyPath L"\\" + deviceGuid;
else else
keyPath = captureKeyPath L"\\" + deviceGuid; keyPath = captureKeyPath L"\\" + deviceGuid;
if(!RegistryHelper::keyExists(keyPath + L"\\FxProperties")) if (!RegistryHelper::keyExists(keyPath + L"\\FxProperties"))
{ {
try try
{ {
RegistryHelper::createKey(keyPath + L"\\FxProperties"); RegistryHelper::createKey(keyPath + L"\\FxProperties");
} }
catch(RegistryException e) catch (RegistryException e)
{ {
// Permissions were not sufficient, so change them // Permissions were not sufficient, so change them
RegistryHelper::takeOwnership(keyPath); RegistryHelper::takeOwnership(keyPath);
@@ -455,7 +455,7 @@ void DeviceAPOInfo::install()
RegistryHelper::writeValue(keyPath + L"\\FxProperties", fxTitleValueName, L"Equalizer APO"); RegistryHelper::writeValue(keyPath + L"\\FxProperties", fxTitleValueName, L"Equalizer APO");
for(int i = 0; i < allGuidValueNameCount; i++) for (int i = 0; i < allGuidValueNameCount; i++)
{ {
RegistryHelper::writeValue(childApoPath L"\\" + deviceGuid, allGuidValueNames[i], APOGUID_NOKEY); RegistryHelper::writeValue(childApoPath L"\\" + deviceGuid, allGuidValueNames[i], APOGUID_NOKEY);
} }
@@ -464,10 +464,10 @@ void DeviceAPOInfo::install()
{ {
vector<wstring> valuenames; vector<wstring> valuenames;
for(int i = 0; i < allGuidValueNameCount; i++) for (int i = 0; i < allGuidValueNameCount; i++)
{ {
wstring apoGuidString = APOGUID_NOVALUE; wstring apoGuidString = APOGUID_NOVALUE;
if(RegistryHelper::valueExists(keyPath + L"\\FxProperties", allGuidValueNames[i])) if (RegistryHelper::valueExists(keyPath + L"\\FxProperties", allGuidValueNames[i]))
{ {
apoGuidString = RegistryHelper::readValue(keyPath + L"\\FxProperties", allGuidValueNames[i]); apoGuidString = RegistryHelper::readValue(keyPath + L"\\FxProperties", allGuidValueNames[i]);
valuenames.push_back(allGuidValueNames[i]); valuenames.push_back(allGuidValueNames[i]);
@@ -476,115 +476,115 @@ void DeviceAPOInfo::install()
RegistryHelper::writeValue(childApoPath L"\\" + deviceGuid, allGuidValueNames[i], apoGuidString); RegistryHelper::writeValue(childApoPath L"\\" + deviceGuid, allGuidValueNames[i], apoGuidString);
} }
if(!valuenames.empty()) if (!valuenames.empty())
RegistryHelper::saveToFile(keyPath + L"\\FxProperties", valuenames, RegistryHelper::saveToFile(keyPath + L"\\FxProperties", valuenames,
L"backup_" + StringHelper::replaceIllegalCharacters(deviceName) + L"_" + StringHelper::replaceIllegalCharacters(connectionName) + L".reg"); L"backup_" + StringHelper::replaceIllegalCharacters(deviceName) + L"_" + StringHelper::replaceIllegalCharacters(connectionName) + L".reg");
} }
wstring preMixValue; wstring preMixValue;
wstring postMixValue; wstring postMixValue;
if(selectedInstallState.useOriginalAPOPreMix) if (selectedInstallState.useOriginalAPOPreMix)
preMixValue = getOriginalAPOPreMix(); preMixValue = getOriginalAPOPreMix();
if(selectedInstallState.useOriginalAPOPostMix) if (selectedInstallState.useOriginalAPOPostMix)
postMixValue = getOriginalAPOPostMix(); postMixValue = getOriginalAPOPostMix();
RegistryHelper::writeValue(childApoPath L"\\" + deviceGuid, preMixChildGuidValueName, preMixValue); RegistryHelper::writeValue(childApoPath L"\\" + deviceGuid, preMixChildGuidValueName, preMixValue);
RegistryHelper::writeValue(childApoPath L"\\" + deviceGuid, postMixChildGuidValueName, postMixValue); RegistryHelper::writeValue(childApoPath L"\\" + deviceGuid, postMixChildGuidValueName, postMixValue);
RegistryHelper::writeValue(childApoPath L"\\" + deviceGuid, versionValueName, installVersion); RegistryHelper::writeValue(childApoPath L"\\" + deviceGuid, versionValueName, installVersion);
if(selectedInstallState.installMode == INSTALL_LFX_GFX) if (selectedInstallState.installMode == INSTALL_LFX_GFX)
{ {
if(selectedInstallState.installPreMix) if (selectedInstallState.installPreMix)
RegistryHelper::writeValue(keyPath + L"\\FxProperties", lfxGuidValueName, RegistryHelper::getGuidString(EQUALIZERAPO_PRE_MIX_GUID)); RegistryHelper::writeValue(keyPath + L"\\FxProperties", lfxGuidValueName, RegistryHelper::getGuidString(EQUALIZERAPO_PRE_MIX_GUID));
if(selectedInstallState.installPostMix && !isInput) if (selectedInstallState.installPostMix && !isInput)
RegistryHelper::writeValue(keyPath + L"\\FxProperties", gfxGuidValueName, RegistryHelper::getGuidString(EQUALIZERAPO_POST_MIX_GUID)); RegistryHelper::writeValue(keyPath + L"\\FxProperties", gfxGuidValueName, RegistryHelper::getGuidString(EQUALIZERAPO_POST_MIX_GUID));
if(RegistryHelper::valueExists(keyPath + L"\\FxProperties", sfxGuidValueName)) if (RegistryHelper::valueExists(keyPath + L"\\FxProperties", sfxGuidValueName))
RegistryHelper::deleteValue(keyPath + L"\\FxProperties", sfxGuidValueName); RegistryHelper::deleteValue(keyPath + L"\\FxProperties", sfxGuidValueName);
if(RegistryHelper::valueExists(keyPath + L"\\FxProperties", mfxGuidValueName)) if (RegistryHelper::valueExists(keyPath + L"\\FxProperties", mfxGuidValueName))
RegistryHelper::deleteValue(keyPath + L"\\FxProperties", mfxGuidValueName); RegistryHelper::deleteValue(keyPath + L"\\FxProperties", mfxGuidValueName);
if(RegistryHelper::valueExists(keyPath + L"\\FxProperties", efxGuidValueName)) if (RegistryHelper::valueExists(keyPath + L"\\FxProperties", efxGuidValueName))
RegistryHelper::deleteValue(keyPath + L"\\FxProperties", efxGuidValueName); RegistryHelper::deleteValue(keyPath + L"\\FxProperties", efxGuidValueName);
} }
else if(selectedInstallState.installMode == INSTALL_SFX_MFX) else if (selectedInstallState.installMode == INSTALL_SFX_MFX)
{ {
if(RegistryHelper::valueExists(keyPath + L"\\FxProperties", lfxGuidValueName)) if (RegistryHelper::valueExists(keyPath + L"\\FxProperties", lfxGuidValueName))
RegistryHelper::deleteValue(keyPath + L"\\FxProperties", lfxGuidValueName); RegistryHelper::deleteValue(keyPath + L"\\FxProperties", lfxGuidValueName);
if(RegistryHelper::valueExists(keyPath + L"\\FxProperties", gfxGuidValueName)) if (RegistryHelper::valueExists(keyPath + L"\\FxProperties", gfxGuidValueName))
RegistryHelper::deleteValue(keyPath + L"\\FxProperties", gfxGuidValueName); RegistryHelper::deleteValue(keyPath + L"\\FxProperties", gfxGuidValueName);
if(selectedInstallState.installPreMix) if (selectedInstallState.installPreMix)
{ {
RegistryHelper::writeValue(keyPath + L"\\FxProperties", sfxGuidValueName, RegistryHelper::getGuidString(EQUALIZERAPO_PRE_MIX_GUID)); RegistryHelper::writeValue(keyPath + L"\\FxProperties", sfxGuidValueName, RegistryHelper::getGuidString(EQUALIZERAPO_PRE_MIX_GUID));
if(!RegistryHelper::valueExists(keyPath + L"\\FxProperties", sfxProcessingModesValueName)) if (!RegistryHelper::valueExists(keyPath + L"\\FxProperties", sfxProcessingModesValueName))
RegistryHelper::writeMultiValue(keyPath + L"\\FxProperties", sfxProcessingModesValueName, defaultProcessingModeValue); RegistryHelper::writeMultiValue(keyPath + L"\\FxProperties", sfxProcessingModesValueName, defaultProcessingModeValue);
} }
if(selectedInstallState.installPostMix && !isInput) if (selectedInstallState.installPostMix && !isInput)
{ {
RegistryHelper::writeValue(keyPath + L"\\FxProperties", mfxGuidValueName, RegistryHelper::getGuidString(EQUALIZERAPO_POST_MIX_GUID)); RegistryHelper::writeValue(keyPath + L"\\FxProperties", mfxGuidValueName, RegistryHelper::getGuidString(EQUALIZERAPO_POST_MIX_GUID));
if(!RegistryHelper::valueExists(keyPath + L"\\FxProperties", mfxProcessingModesValueName)) if (!RegistryHelper::valueExists(keyPath + L"\\FxProperties", mfxProcessingModesValueName))
RegistryHelper::writeMultiValue(keyPath + L"\\FxProperties", mfxProcessingModesValueName, defaultProcessingModeValue); RegistryHelper::writeMultiValue(keyPath + L"\\FxProperties", mfxProcessingModesValueName, defaultProcessingModeValue);
} }
// don't change efx // don't change efx
} }
else if(selectedInstallState.installMode == INSTALL_SFX_EFX) else if (selectedInstallState.installMode == INSTALL_SFX_EFX)
{ {
if(RegistryHelper::valueExists(keyPath + L"\\FxProperties", lfxGuidValueName)) if (RegistryHelper::valueExists(keyPath + L"\\FxProperties", lfxGuidValueName))
RegistryHelper::deleteValue(keyPath + L"\\FxProperties", lfxGuidValueName); RegistryHelper::deleteValue(keyPath + L"\\FxProperties", lfxGuidValueName);
if(RegistryHelper::valueExists(keyPath + L"\\FxProperties", gfxGuidValueName)) if (RegistryHelper::valueExists(keyPath + L"\\FxProperties", gfxGuidValueName))
RegistryHelper::deleteValue(keyPath + L"\\FxProperties", gfxGuidValueName); RegistryHelper::deleteValue(keyPath + L"\\FxProperties", gfxGuidValueName);
if(selectedInstallState.installPreMix) if (selectedInstallState.installPreMix)
{ {
RegistryHelper::writeValue(keyPath + L"\\FxProperties", sfxGuidValueName, RegistryHelper::getGuidString(EQUALIZERAPO_PRE_MIX_GUID)); RegistryHelper::writeValue(keyPath + L"\\FxProperties", sfxGuidValueName, RegistryHelper::getGuidString(EQUALIZERAPO_PRE_MIX_GUID));
if(!RegistryHelper::valueExists(keyPath + L"\\FxProperties", sfxProcessingModesValueName)) if (!RegistryHelper::valueExists(keyPath + L"\\FxProperties", sfxProcessingModesValueName))
RegistryHelper::writeMultiValue(keyPath + L"\\FxProperties", sfxProcessingModesValueName, defaultProcessingModeValue); RegistryHelper::writeMultiValue(keyPath + L"\\FxProperties", sfxProcessingModesValueName, defaultProcessingModeValue);
} }
// don't change mfx // don't change mfx
if(selectedInstallState.installPostMix && !isInput) if (selectedInstallState.installPostMix && !isInput)
{ {
RegistryHelper::writeValue(keyPath + L"\\FxProperties", efxGuidValueName, RegistryHelper::getGuidString(EQUALIZERAPO_POST_MIX_GUID)); RegistryHelper::writeValue(keyPath + L"\\FxProperties", efxGuidValueName, RegistryHelper::getGuidString(EQUALIZERAPO_POST_MIX_GUID));
if(!RegistryHelper::valueExists(keyPath + L"\\FxProperties", efxProcessingModesValueName)) if (!RegistryHelper::valueExists(keyPath + L"\\FxProperties", efxProcessingModesValueName))
RegistryHelper::writeMultiValue(keyPath + L"\\FxProperties", efxProcessingModesValueName, defaultProcessingModeValue); RegistryHelper::writeMultiValue(keyPath + L"\\FxProperties", efxProcessingModesValueName, defaultProcessingModeValue);
} }
} }
// force-enable enhancements // force-enable enhancements
if(RegistryHelper::valueExists(keyPath + L"\\FxProperties", disableEnhancementsValueName)) if (RegistryHelper::valueExists(keyPath + L"\\FxProperties", disableEnhancementsValueName))
RegistryHelper::deleteValue(keyPath + L"\\FxProperties", disableEnhancementsValueName); RegistryHelper::deleteValue(keyPath + L"\\FxProperties", disableEnhancementsValueName);
} }
void DeviceAPOInfo::uninstall() void DeviceAPOInfo::uninstall()
{ {
wstring keyPath; wstring keyPath;
if(!isInput) if (!isInput)
keyPath = renderKeyPath L"\\" + deviceGuid; keyPath = renderKeyPath L"\\" + deviceGuid;
else else
keyPath = captureKeyPath L"\\" + deviceGuid; keyPath = captureKeyPath L"\\" + deviceGuid;
if(originalApoGuids[0] == APOGUID_NOKEY) if (originalApoGuids[0] == APOGUID_NOKEY)
{ {
RegistryHelper::deleteKey(keyPath + L"\\FxProperties"); RegistryHelper::deleteKey(keyPath + L"\\FxProperties");
} }
else else
{ {
for(int i = 0; i < allGuidValueNameCount; i++) for (int i = 0; i < allGuidValueNameCount; i++)
{ {
if(originalApoGuids[i] == APOGUID_NOVALUE) if (originalApoGuids[i] == APOGUID_NOVALUE)
{ {
if(RegistryHelper::valueExists(keyPath + L"\\FxProperties", allGuidValueNames[i])) if (RegistryHelper::valueExists(keyPath + L"\\FxProperties", allGuidValueNames[i]))
RegistryHelper::deleteValue(keyPath + L"\\FxProperties", allGuidValueNames[i]); RegistryHelper::deleteValue(keyPath + L"\\FxProperties", allGuidValueNames[i]);
} }
else if(originalApoGuids[i] != L"") else if (originalApoGuids[i] != L"")
{ {
RegistryHelper::writeValue(keyPath + L"\\FxProperties", allGuidValueNames[i], originalApoGuids[i]); RegistryHelper::writeValue(keyPath + L"\\FxProperties", allGuidValueNames[i], originalApoGuids[i]);
} }
} }
} }
if(RegistryHelper::valueExists(childApoPath, deviceGuid)) if (RegistryHelper::valueExists(childApoPath, deviceGuid))
RegistryHelper::deleteValue(childApoPath, deviceGuid); RegistryHelper::deleteValue(childApoPath, deviceGuid);
if(RegistryHelper::keyExists(childApoPath L"\\" + deviceGuid)) if (RegistryHelper::keyExists(childApoPath L"\\" + deviceGuid))
RegistryHelper::deleteKey(childApoPath L"\\" + deviceGuid); RegistryHelper::deleteKey(childApoPath L"\\" + deviceGuid);
if(RegistryHelper::keyEmpty(childApoPath)) if (RegistryHelper::keyEmpty(childApoPath))
RegistryHelper::deleteKey(childApoPath); RegistryHelper::deleteKey(childApoPath);
} }
+9 -9
View File
@@ -33,7 +33,7 @@ static HINSTANCE hModule;
BOOL WINAPI DllMain(HINSTANCE hModule, DWORD dwReason, void* lpReserved) BOOL WINAPI DllMain(HINSTANCE hModule, DWORD dwReason, void* lpReserved)
{ {
if(dwReason == DLL_PROCESS_ATTACH) if (dwReason == DLL_PROCESS_ATTACH)
::hModule = hModule; ::hModule = hModule;
return TRUE; return TRUE;
@@ -41,7 +41,7 @@ BOOL WINAPI DllMain(HINSTANCE hModule, DWORD dwReason, void* lpReserved)
STDAPI DllCanUnloadNow() STDAPI DllCanUnloadNow()
{ {
if(EqualizerAPO::instCount == 0 && ClassFactory::lockCount == 0) if (EqualizerAPO::instCount == 0 && ClassFactory::lockCount == 0)
return S_OK; return S_OK;
else else
return S_FALSE; return S_FALSE;
@@ -49,11 +49,11 @@ STDAPI DllCanUnloadNow()
STDAPI DllGetClassObject(const CLSID& clsid, const IID& iid, void** ppv) STDAPI DllGetClassObject(const CLSID& clsid, const IID& iid, void** ppv)
{ {
if(clsid != EQUALIZERAPO_POST_MIX_GUID && clsid != EQUALIZERAPO_PRE_MIX_GUID) if (clsid != EQUALIZERAPO_POST_MIX_GUID && clsid != EQUALIZERAPO_PRE_MIX_GUID)
return CLASS_E_CLASSNOTAVAILABLE; return CLASS_E_CLASSNOTAVAILABLE;
ClassFactory* factory = new ClassFactory(); ClassFactory* factory = new ClassFactory();
if(factory == NULL) if (factory == NULL)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
HRESULT hr = factory->QueryInterface(iid, ppv); HRESULT hr = factory->QueryInterface(iid, ppv);
@@ -65,17 +65,17 @@ STDAPI DllGetClassObject(const CLSID& clsid, const IID& iid, void** ppv)
STDAPI DllRegisterServer() STDAPI DllRegisterServer()
{ {
wchar_t filename[1024]; wchar_t filename[1024];
GetModuleFileNameW(hModule, filename, sizeof(filename)/sizeof(wchar_t)); GetModuleFileNameW(hModule, filename, sizeof(filename) / sizeof(wchar_t));
HRESULT hr = RegisterAPO(EqualizerAPO::regPostMixProperties); HRESULT hr = RegisterAPO(EqualizerAPO::regPostMixProperties);
if(FAILED(hr)) if (FAILED(hr))
{ {
UnregisterAPO(EQUALIZERAPO_POST_MIX_GUID); UnregisterAPO(EQUALIZERAPO_POST_MIX_GUID);
return hr; return hr;
} }
hr = RegisterAPO(EqualizerAPO::regPreMixProperties); hr = RegisterAPO(EqualizerAPO::regPreMixProperties);
if(FAILED(hr)) if (FAILED(hr))
{ {
UnregisterAPO(EQUALIZERAPO_POST_MIX_GUID); UnregisterAPO(EQUALIZERAPO_POST_MIX_GUID);
UnregisterAPO(EQUALIZERAPO_PRE_MIX_GUID); UnregisterAPO(EQUALIZERAPO_PRE_MIX_GUID);
@@ -100,7 +100,7 @@ STDAPI DllRegisterServer()
RegistryHelper::writeValue(L"HKEY_LOCAL_MACHINE\\SOFTWARE\\Classes\\CLSID\\" + apoClsidString + L"\\InprocServer32", L"", filename); RegistryHelper::writeValue(L"HKEY_LOCAL_MACHINE\\SOFTWARE\\Classes\\CLSID\\" + apoClsidString + L"\\InprocServer32", L"", filename);
RegistryHelper::writeValue(L"HKEY_LOCAL_MACHINE\\SOFTWARE\\Classes\\CLSID\\" + apoClsidString + L"\\InprocServer32", L"ThreadingModel", L"Both"); RegistryHelper::writeValue(L"HKEY_LOCAL_MACHINE\\SOFTWARE\\Classes\\CLSID\\" + apoClsidString + L"\\InprocServer32", L"ThreadingModel", L"Both");
} }
catch(RegistryException e) catch (RegistryException e)
{ {
UnregisterAPO(EQUALIZERAPO_POST_MIX_GUID); UnregisterAPO(EQUALIZERAPO_POST_MIX_GUID);
UnregisterAPO(EQUALIZERAPO_PRE_MIX_GUID); UnregisterAPO(EQUALIZERAPO_PRE_MIX_GUID);
@@ -124,7 +124,7 @@ STDAPI DllUnregisterServer()
RegistryHelper::deleteKey(L"HKEY_LOCAL_MACHINE\\SOFTWARE\\Classes\\CLSID\\" + apoClsidString + L"\\InprocServer32"); RegistryHelper::deleteKey(L"HKEY_LOCAL_MACHINE\\SOFTWARE\\Classes\\CLSID\\" + apoClsidString + L"\\InprocServer32");
RegistryHelper::deleteKey(L"HKEY_LOCAL_MACHINE\\SOFTWARE\\Classes\\CLSID\\" + apoClsidString); RegistryHelper::deleteKey(L"HKEY_LOCAL_MACHINE\\SOFTWARE\\Classes\\CLSID\\" + apoClsidString);
} }
catch(RegistryException e) catch (RegistryException e)
{ {
return E_FAIL; return E_FAIL;
} }
+2 -2
View File
@@ -31,11 +31,11 @@ AnalysisPlotScene::AnalysisPlotScene(QObject* parent)
void AnalysisPlotScene::setFreqData(fftwf_complex* freqData, int frameCount, unsigned sampleRate) void AnalysisPlotScene::setFreqData(fftwf_complex* freqData, int frameCount, unsigned sampleRate)
{ {
nodes.clear(); nodes.clear();
for(int i = 0; i < frameCount / 2; i++) for (int i = 0; i < frameCount / 2; i++)
{ {
float freq = (i * 1.0f / frameCount) * sampleRate; float freq = (i * 1.0f / frameCount) * sampleRate;
// GainIterator can't handle 0 Hz node // GainIterator can't handle 0 Hz node
if(freq == 0.0f) if (freq == 0.0f)
freq = 0.001f; freq = 0.001f;
float gain = sqrt(freqData[i][0] * freqData[i][0] + freqData[i][1] * freqData[i][1]); float gain = sqrt(freqData[i][0] * freqData[i][0] + freqData[i][1] * freqData[i][1]);
float dbGain = log10(gain) * 20; float dbGain = log10(gain) * 20;
+4 -4
View File
@@ -41,15 +41,15 @@ void AnalysisPlotView::drawBackground(QPainter* painter, const QRectF& rect)
QPainterPath path; QPainterPath path;
bool first = true; bool first = true;
double lastDb = -1000; double lastDb = -1000;
for(int x = rect.left() - 1; x <= rect.right() + 1; x++) for (int x = rect.left() - 1; x <= rect.right() + 1; x++)
{ {
double hz = s->xToHz(x); double hz = s->xToHz(x);
double db = gainIterator.gainAt(hz); double db = gainIterator.gainAt(hz);
double y = s->dbToY(db); double y = s->dbToY(db);
if(db == lastDb) if (db == lastDb)
y = floor(y) + 0.5; y = floor(y) + 0.5;
lastDb = db; lastDb = db;
if(first) if (first)
{ {
path.moveTo(x, y); path.moveTo(x, y);
first = false; first = false;
@@ -64,7 +64,7 @@ void AnalysisPlotView::drawBackground(QPainter* painter, const QRectF& rect)
path.lineTo(rect.left() - 1, rect.bottom() + 1); path.lineTo(rect.left() - 1, rect.bottom() + 1);
double thresholdY = s->dbToY(0); double thresholdY = s->dbToY(0);
if(rect.top() < thresholdY) if (rect.top() < thresholdY)
{ {
QPainterPath rectPath; QPainterPath rectPath;
rectPath.addRect(rect.left(), rect.top(), rect.width(), min(thresholdY - rect.top(), rect.height())); rectPath.addRect(rect.left(), rect.top(), rect.width(), min(thresholdY - rect.top(), rect.height()));
+35 -35
View File
@@ -36,18 +36,18 @@ AnalysisThread::~AnalysisThread()
wait(); wait();
if(resultFreqData != NULL) if (resultFreqData != NULL)
fftwf_free(resultFreqData); fftwf_free(resultFreqData);
if(buf != NULL) if (buf != NULL)
delete buf; delete buf;
if(buf2 != NULL) if (buf2 != NULL)
delete buf2; delete buf2;
if(timeData != NULL) if (timeData != NULL)
fftwf_free(timeData); fftwf_free(timeData);
if(freqData != NULL) if (freqData != NULL)
fftwf_free(freqData); fftwf_free(freqData);
if(planForward != NULL) if (planForward != NULL)
fftwf_destroy_plan(planForward); fftwf_destroy_plan(planForward);
} }
@@ -115,12 +115,12 @@ int AnalysisThread::getProcessedFrames() const
void AnalysisThread::run() void AnalysisThread::run()
{ {
while(true) while (true)
{ {
mutex.lock(); mutex.lock();
if(!quit && this->frameCount == 0) if (!quit && this->frameCount == 0)
condition.wait(&mutex); condition.wait(&mutex);
if(quit) if (quit)
{ {
mutex.unlock(); mutex.unlock();
break; break;
@@ -138,13 +138,13 @@ void AnalysisThread::run()
timer.start(); timer.start();
unsigned channelCount = device.channelCount; unsigned channelCount = device.channelCount;
if(channelMask != 0 && channelMask != device.channelMask) if (channelMask != 0 && channelMask != device.channelMask)
{ {
channelCount = 0; channelCount = 0;
for(int i = 0; i < 31; i++) for (int i = 0; i < 31; i++)
{ {
int channelPos = 1 << i; int channelPos = 1 << i;
if(channelMask & channelPos) if (channelMask & channelPos)
channelCount++; channelCount++;
} }
} }
@@ -157,31 +157,31 @@ void AnalysisThread::run()
engine.initialize(sampleRate, channelCount, channelCount, channelCount, channelMask, frameCount, configPath.toStdWString()); engine.initialize(sampleRate, channelCount, channelCount, channelCount, channelMask, frameCount, configPath.toStdWString());
double initializationTime = (timer.nsecsElapsed() - startTime) / 1e6; double initializationTime = (timer.nsecsElapsed() - startTime) / 1e6;
if(frameCount != lastFrameCount || channelCount != lastChannelCount) if (frameCount != lastFrameCount || channelCount != lastChannelCount)
{ {
if(buf != NULL) if (buf != NULL)
delete buf; delete buf;
buf = new float[frameCount * channelCount]; buf = new float[frameCount * channelCount];
memset(buf, 0, frameCount * channelCount * sizeof(float)); memset(buf, 0, frameCount * channelCount * sizeof(float));
if(buf2 != NULL) if (buf2 != NULL)
delete buf2; delete buf2;
buf2 = new float[frameCount * channelCount]; buf2 = new float[frameCount * channelCount];
} }
for(unsigned i = 0; i < channelCount; i++) for (unsigned i = 0; i < channelCount; i++)
buf[i] = 1.0f; buf[i] = 1.0f;
if(frameCount != lastFrameCount) if (frameCount != lastFrameCount)
{ {
if(timeData != NULL) if (timeData != NULL)
fftwf_free(timeData); fftwf_free(timeData);
timeData = fftwf_alloc_real(frameCount); timeData = fftwf_alloc_real(frameCount);
if(freqData != NULL) if (freqData != NULL)
fftwf_free(freqData); fftwf_free(freqData);
freqData = fftwf_alloc_complex(frameCount); freqData = fftwf_alloc_complex(frameCount);
if(planForward != NULL) if (planForward != NULL)
fftwf_destroy_plan(planForward); fftwf_destroy_plan(planForward);
planForward = fftwf_plan_dft_r2c_1d(frameCount, timeData, freqData, FFTW_ESTIMATE); planForward = fftwf_plan_dft_r2c_1d(frameCount, timeData, freqData, FFTW_ESTIMATE);
} }
@@ -193,50 +193,50 @@ void AnalysisThread::run()
int startFrame = -1; int startFrame = -1;
double processingTime = 0.0; double processingTime = 0.0;
int processedFrames = 0; int processedFrames = 0;
while(true) while (true)
{ {
qint64 startTime = timer.nsecsElapsed(); qint64 startTime = timer.nsecsElapsed();
engine.process(buf2, buf, frameCount); engine.process(buf2, buf, frameCount);
processingTime += (timer.nsecsElapsed() - startTime) / 1e6; processingTime += (timer.nsecsElapsed() - startTime) / 1e6;
processedFrames += frameCount; processedFrames += frameCount;
if(startFrame != -1) if (startFrame != -1)
{ {
for(int i = 0; i < startFrame; i++) for (int i = 0; i < startFrame; i++)
{ {
timeData[frameCount - startFrame + i] = buf2[i * channelCount + channelIndex]; timeData[frameCount - startFrame + i] = buf2[i * channelCount + channelIndex];
} }
break; break;
} }
for(int i = 0; i < frameCount; i++) for (int i = 0; i < frameCount; i++)
{ {
float s = buf2[i * channelCount + channelIndex]; float s = buf2[i * channelCount + channelIndex];
if(abs(s) > 1e-5f) if (abs(s) > 1e-5f)
{ {
startFrame = i; startFrame = i;
break; break;
} }
} }
if(startFrame != -1) if (startFrame != -1)
{ {
for(int i = 0; i < frameCount - startFrame; i++) for (int i = 0; i < frameCount - startFrame; i++)
{ {
timeData[i] = buf2[(startFrame + i) * channelCount + channelIndex]; timeData[i] = buf2[(startFrame + i) * channelCount + channelIndex];
} }
if(startFrame == 0) if (startFrame == 0)
break; break;
} }
if(latency == 0) if (latency == 0)
{ {
for(unsigned i = 0; i < channelCount; i++) for (unsigned i = 0; i < channelCount; i++)
buf[i] = 0.0f; buf[i] = 0.0f;
} }
if(startFrame == -1) if (startFrame == -1)
latency += frameCount; latency += frameCount;
} }
latency += startFrame; latency += startFrame;
@@ -245,19 +245,19 @@ void AnalysisThread::run()
double peakGain = -DBL_MAX; double peakGain = -DBL_MAX;
for(int i = 0; i < frameCount; i++) for (int i = 0; i < frameCount; i++)
{ {
float sqrGain = freqData[i][0] * freqData[i][0] + freqData[i][1] * freqData[i][1]; float sqrGain = freqData[i][0] * freqData[i][0] + freqData[i][1] * freqData[i][1];
if(sqrGain > peakGain) if (sqrGain > peakGain)
peakGain = sqrGain; peakGain = sqrGain;
} }
peakGain = sqrt(peakGain); peakGain = sqrt(peakGain);
peakGain = log10(peakGain) * 20.0; peakGain = log10(peakGain) * 20.0;
mutex.lock(); mutex.lock();
if(this->freqDataLength != frameCount) if (this->freqDataLength != frameCount)
{ {
if(resultFreqData != NULL) if (resultFreqData != NULL)
fftwf_free(resultFreqData); fftwf_free(resultFreqData);
resultFreqData = fftwf_alloc_complex(frameCount); resultFreqData = fftwf_alloc_complex(frameCount);
} }
+1 -1
View File
@@ -254,4 +254,4 @@ TRANSLATIONS += translations/Editor_de.ts
RC_ICONS = icons/accessories-text-editor.ico RC_ICONS = icons/accessories-text-editor.ico
DISTFILES += DISTFILES += ../uncrustify.cfg
+131 -132
View File
@@ -56,8 +56,8 @@
using namespace std; using namespace std;
FilterTable::FilterTable(MainWindow* mainWindow, QWidget *parent) : FilterTable::FilterTable(MainWindow* mainWindow, QWidget* parent)
QWidget(parent), mainWindow(mainWindow) : QWidget(parent), mainWindow(mainWindow)
{ {
gridLayout = new QGridLayout(this); gridLayout = new QGridLayout(this);
@@ -88,7 +88,7 @@ void FilterTable::initialize(QScrollArea* scrollArea, const QList<DeviceAPOInfo>
this->outputDevices = outputDevices; this->outputDevices = outputDevices;
this->inputDevices = inputDevices; this->inputDevices = inputDevices;
for(IFilterGUIFactory* factory : factories) for (IFilterGUIFactory* factory : factories)
factory->initialize(this); factory->initialize(this);
} }
@@ -97,7 +97,7 @@ void FilterTable::updateDeviceAndChannelMask(DeviceAPOInfo* selectedDevice, int
this->selectedDevice = selectedDevice; this->selectedDevice = selectedDevice;
this->selectedChannelMask = channelMask; this->selectedChannelMask = channelMask;
if(!items.empty()) if (!items.empty())
updateGuis(); updateGuis();
} }
@@ -106,9 +106,9 @@ void FilterTable::updateGuis()
QElapsedTimer timer; QElapsedTimer timer;
timer.start(); timer.start();
for(Item* item : items) for (Item* item : items)
{ {
if(item->gui != NULL) if (item->gui != NULL)
{ {
item->prefs.clear(); item->prefs.clear();
item->gui->storePreferences(item->prefs); item->gui->storePreferences(item->prefs);
@@ -117,12 +117,12 @@ void FilterTable::updateGuis()
delete layout(); delete layout();
for(QObject* object : children()) for (QObject* object : children())
{ {
if(object != insertArrow) if (object != insertArrow)
{ {
QWidget* widget = qobject_cast<QWidget*>(object); QWidget* widget = qobject_cast<QWidget*>(object);
if(widget != NULL) if (widget != NULL)
widget->setVisible(false); widget->setVisible(false);
object->deleteLater(); object->deleteLater();
} }
@@ -137,16 +137,16 @@ void FilterTable::updateGuis()
gridLayout->setColumnStretch(0, 0); gridLayout->setColumnStretch(0, 0);
gridLayout->setColumnStretch(1, 1); gridLayout->setColumnStretch(1, 1);
for(IFilterGUIFactory* factory : factories) for (IFilterGUIFactory* factory : factories)
factory->startOfFile(configPath); factory->startOfFile(configPath);
int row = 0; int row = 0;
for(Item* item : items) for (Item* item : items)
{ {
QString line = item->text; QString line = item->text;
IFilterGUI* gui = NULL; IFilterGUI* gui = NULL;
int pos = line.indexOf(':'); int pos = line.indexOf(':');
if(pos != -1) if (pos != -1)
{ {
QString key = line.mid(0, pos); QString key = line.mid(0, pos);
QString value = line.mid(pos + 1); QString value = line.mid(pos + 1);
@@ -156,17 +156,17 @@ void FilterTable::updateGuis()
QString factoryKey = key; QString factoryKey = key;
QString factoryValue = value; QString factoryValue = value;
for(IFilterGUIFactory* factory : factories) for (IFilterGUIFactory* factory : factories)
{ {
gui = factory->createFilterGUI(factoryKey, factoryValue); gui = factory->createFilterGUI(factoryKey, factoryValue);
if(gui != NULL || factoryKey == "") if (gui != NULL || factoryKey == "")
break; break;
} }
if(gui != NULL) if (gui != NULL)
{ {
for(IFilterGUIFactory* factory : factories) for (IFilterGUIFactory* factory : factories)
{ {
gui = factory->decorateFilterGUI(gui); gui = factory->decorateFilterGUI(gui);
} }
@@ -178,7 +178,7 @@ void FilterTable::updateGuis()
item->gui = gui; item->gui = gui;
if(gui != NULL) if (gui != NULL)
{ {
gui->loadPreferences(item->prefs); gui->loadPreferences(item->prefs);
@@ -189,7 +189,7 @@ void FilterTable::updateGuis()
row++; row++;
} }
for(IFilterGUIFactory* factory : factories) for (IFilterGUIFactory* factory : factories)
factory->endOfFile(configPath); factory->endOfFile(configPath);
propagateChannels(); propagateChannels();
@@ -223,9 +223,9 @@ void FilterTable::propagateChannels()
{ {
vector<wstring> channelNames = ChannelHelper::getChannelNames(selectedDevice->channelCount, selectedChannelMask); vector<wstring> channelNames = ChannelHelper::getChannelNames(selectedDevice->channelCount, selectedChannelMask);
for(Item* item : items) for (Item* item : items)
{ {
if(item->gui != NULL) if (item->gui != NULL)
item->gui->configureChannels(channelNames); item->gui->configureChannels(channelNames);
} }
} }
@@ -233,7 +233,7 @@ void FilterTable::propagateChannels()
QList<QString> FilterTable::getLines() QList<QString> FilterTable::getLines()
{ {
QList<QString> result; QList<QString> result;
for(Item* item : items) for (Item* item : items)
result.append(item->text); result.append(item->text);
return result; return result;
@@ -246,7 +246,7 @@ void FilterTable::setLines(const QString& configPath, const QList<QString>& line
qDeleteAll(items); qDeleteAll(items);
items.clear(); items.clear();
for(QString line : lines) for (QString line : lines)
{ {
items.append(new Item(line)); items.append(new Item(line));
} }
@@ -255,35 +255,35 @@ void FilterTable::setLines(const QString& configPath, const QList<QString>& line
settings.beginGroup(QString(configPath).replace('\\', '|')); settings.beginGroup(QString(configPath).replace('\\', '|'));
QVariant prefsValue = settings.value("rowPrefs"); QVariant prefsValue = settings.value("rowPrefs");
QStringList prefLines; QStringList prefLines;
if(prefsValue.isValid()) if (prefsValue.isValid())
prefLines = prefsValue.toStringList(); prefLines = prefsValue.toStringList();
for(QString prefLine : prefLines) for (QString prefLine : prefLines)
{ {
int index = prefLine.indexOf(':'); int index = prefLine.indexOf(':');
int lineNumber; int lineNumber;
if(index != -1) if (index != -1)
lineNumber = prefLine.left(index).toInt(); lineNumber = prefLine.left(index).toInt();
QString prefCommand; QString prefCommand;
QString prefString; QString prefString;
if(lineNumber > 0) if (lineNumber > 0)
{ {
int index2 = prefLine.indexOf(':', index + 1); int index2 = prefLine.indexOf(':', index + 1);
if(index2 != -1) if (index2 != -1)
{ {
prefCommand = prefLine.mid(index + 1, index2 - index - 1); prefCommand = prefLine.mid(index + 1, index2 - index - 1);
prefString = prefLine.mid(index2 + 1); prefString = prefLine.mid(index2 + 1);
if(lineNumber <= items.size()) if (lineNumber <= items.size())
{ {
Item* item = items[lineNumber - 1]; Item* item = items[lineNumber - 1];
QString command; QString command;
int index = item->text.indexOf(':'); int index = item->text.indexOf(':');
if(index != -1) if (index != -1)
command = item->text.left(index).trimmed(); command = item->text.left(index).trimmed();
if(command == prefCommand) if (command == prefCommand)
item->prefs = QJsonDocument::fromJson(prefString.toUtf8()).toVariant().toMap(); item->prefs = QJsonDocument::fromJson(prefString.toUtf8()).toVariant().toMap();
} }
} }
@@ -292,7 +292,7 @@ void FilterTable::setLines(const QString& configPath, const QList<QString>& line
setScrollOffsets(settings.value("scrollX", 0).toInt(), settings.value("scrollY", 0).toInt()); setScrollOffsets(settings.value("scrollX", 0).toInt(), settings.value("scrollY", 0).toInt());
settings.endGroup(); settings.endGroup();
if(!items.isEmpty()) if (!items.isEmpty())
{ {
focused = items[0]; focused = items[0];
selectionStart = items[0]; selectionStart = items[0];
@@ -310,7 +310,7 @@ FilterTable::Item* FilterTable::addLine(const QString& line, FilterTable::Item*
{ {
Item* newItem = new Item(line); Item* newItem = new Item(line);
if(before != NULL) if (before != NULL)
{ {
int index = items.indexOf(before); int index = items.indexOf(before);
items.insert(index, newItem); items.insert(index, newItem);
@@ -337,21 +337,21 @@ QMenu* FilterTable::createAddPopupMenu()
QMenu* rootMenu = new QMenu; QMenu* rootMenu = new QMenu;
pathMap[QStringList()] = rootMenu; pathMap[QStringList()] = rootMenu;
for(IFilterGUIFactory* f : factories) for (IFilterGUIFactory* f : factories)
{ {
QList<FilterTemplate> templates = f->createFilterTemplates(); QList<FilterTemplate> templates = f->createFilterTemplates();
for(FilterTemplate t : templates) for (FilterTemplate t : templates)
{ {
QMenu* menu = pathMap.value(t.getPath()); QMenu* menu = pathMap.value(t.getPath());
if(menu == NULL) if (menu == NULL)
{ {
QMenu* parentMenu = rootMenu; QMenu* parentMenu = rootMenu;
QStringList currentPath; QStringList currentPath;
for(QString pathSegment : t.getPath()) for (QString pathSegment : t.getPath())
{ {
currentPath.append(pathSegment); currentPath.append(pathSegment);
menu = pathMap.value(currentPath); menu = pathMap.value(currentPath);
if(menu == NULL) if (menu == NULL)
{ {
menu = new QMenu(pathSegment); menu = new QMenu(pathSegment);
pathMap.insert(currentPath, menu); pathMap.insert(currentPath, menu);
@@ -380,11 +380,11 @@ void FilterTable::copy()
QString text; QString text;
QList<QVariantMap> prefsList; QList<QVariantMap> prefsList;
bool first = true; bool first = true;
for(Item* item : items) for (Item* item : items)
{ {
if(selected.contains(item)) if (selected.contains(item))
{ {
if(first) if (first)
first = false; first = false;
else else
text += "\n"; text += "\n";
@@ -393,7 +393,7 @@ void FilterTable::copy()
} }
} }
if(selected.size() > 0) if (selected.size() > 0)
{ {
FilterTableMimeData* mimeData = new FilterTableMimeData; FilterTableMimeData* mimeData = new FilterTableMimeData;
mimeData->setText(text); mimeData->setText(text);
@@ -407,12 +407,12 @@ void FilterTable::paste()
{ {
QClipboard* clipboard = QApplication::clipboard(); QClipboard* clipboard = QApplication::clipboard();
const QMimeData* mimeData = clipboard->mimeData(); const QMimeData* mimeData = clipboard->mimeData();
if(mimeData->hasText()) if (mimeData->hasText())
{ {
int dropRow = items.size(); int dropRow = items.size();
for(int i = 0; i < items.size(); i++) for (int i = 0; i < items.size(); i++)
{ {
if(selected.contains(items[i])) if (selected.contains(items[i]))
{ {
dropRow = i; dropRow = i;
break; break;
@@ -423,21 +423,21 @@ void FilterTable::paste()
QStringList textLines = text.split("\n"); QStringList textLines = text.split("\n");
QList<QVariantMap> prefsList; QList<QVariantMap> prefsList;
const FilterTableMimeData* filterTableMimeData = qobject_cast<const FilterTableMimeData*>(mimeData); const FilterTableMimeData* filterTableMimeData = qobject_cast<const FilterTableMimeData*>(mimeData);
if(filterTableMimeData != NULL) if (filterTableMimeData != NULL)
prefsList = filterTableMimeData->getPrefsList(); prefsList = filterTableMimeData->getPrefsList();
selected.clear(); selected.clear();
focused = NULL; focused = NULL;
selectionStart = NULL; selectionStart = NULL;
for(int i = 0; i < textLines.size(); i++) for (int i = 0; i < textLines.size(); i++)
{ {
QString line = textLines[i]; QString line = textLines[i];
Item* item = new Item(line); Item* item = new Item(line);
if(!prefsList.isEmpty()) if (!prefsList.isEmpty())
item->prefs = prefsList[i]; item->prefs = prefsList[i];
selected.insert(item); selected.insert(item);
items.insert(dropRow++, item); items.insert(dropRow++, item);
if(focused == NULL) if (focused == NULL)
{ {
focused = item; focused = item;
selectionStart = item; selectionStart = item;
@@ -452,13 +452,13 @@ void FilterTable::paste()
void FilterTable::deleteSelectedLines() void FilterTable::deleteSelectedLines()
{ {
QList<Item*> newItems; QList<Item*> newItems;
for(Item* item : items) for (Item* item : items)
{ {
if(selected.contains(item)) if (selected.contains(item))
{ {
if(item == focused) if (item == focused)
focused = NULL; focused = NULL;
if(item == selectionStart) if (item == selectionStart)
selectionStart = NULL; selectionStart = NULL;
delete item; delete item;
} }
@@ -492,7 +492,7 @@ void FilterTable::addActionTriggered()
QPoint p = toolBar->mapToGlobal(QPoint(rect.x(), rect.y() + rect.height())); QPoint p = toolBar->mapToGlobal(QPoint(rect.x(), rect.y() + rect.height()));
QAction* action = menu->exec(p); QAction* action = menu->exec(p);
addAction->setChecked(false); addAction->setChecked(false);
if(action != NULL) if (action != NULL)
{ {
FilterTemplate t = action->data().value<FilterTemplate>(); FilterTemplate t = action->data().value<FilterTemplate>();
QString line = t.getLine(); QString line = t.getLine();
@@ -508,7 +508,7 @@ void FilterTable::openConfig(QString path)
int FilterTable::getPreferredWidth() int FilterTable::getPreferredWidth()
{ {
if(scrollArea == NULL) if (scrollArea == NULL)
return width(); return width();
return scrollArea->viewport()->width(); return scrollArea->viewport()->width();
@@ -516,7 +516,7 @@ int FilterTable::getPreferredWidth()
void FilterTable::updateSizeHints() void FilterTable::updateSizeHints()
{ {
for(int i = 0; i < items.size(); i++) for (int i = 0; i < items.size(); i++)
{ {
FilterTableRow* tableRow = qobject_cast<FilterTableRow*>(gridLayout->itemAtPosition(i, 0)->widget()); FilterTableRow* tableRow = qobject_cast<FilterTableRow*>(gridLayout->itemAtPosition(i, 0)->widget());
tableRow->updateGeometry(); tableRow->updateGeometry();
@@ -526,7 +526,7 @@ void FilterTable::updateSizeHints()
QSize FilterTable::minimumSizeHint() const QSize FilterTable::minimumSizeHint() const
{ {
QSize size = QWidget::minimumSizeHint(); QSize size = QWidget::minimumSizeHint();
if(size.height() < minimumHeightHint) if (size.height() < minimumHeightHint)
size.setHeight(minimumHeightHint); size.setHeight(minimumHeightHint);
return size; return size;
@@ -540,25 +540,25 @@ void FilterTable::setMinimumHeightHint(int height)
void FilterTable::savePreferences() void FilterTable::savePreferences()
{ {
if(!configPath.isEmpty()) if (!configPath.isEmpty())
{ {
QStringList prefLines; QStringList prefLines;
for(int i = 0; i < items.size(); i++) for (int i = 0; i < items.size(); i++)
{ {
Item* item = items[i]; Item* item = items[i];
if(item->gui != NULL) if (item->gui != NULL)
{ {
item->prefs.clear(); item->prefs.clear();
item->gui->storePreferences(item->prefs); item->gui->storePreferences(item->prefs);
} }
if(!item->prefs.isEmpty()) if (!item->prefs.isEmpty())
{ {
QString command; QString command;
int index = item->text.indexOf(':'); int index = item->text.indexOf(':');
if(index != -1) if (index != -1)
command = item->text.left(index).trimmed(); command = item->text.left(index).trimmed();
QByteArray byteArray = QJsonDocument::fromVariant(item->prefs).toJson(QJsonDocument::Compact); QByteArray byteArray = QJsonDocument::fromVariant(item->prefs).toJson(QJsonDocument::Compact);
@@ -584,26 +584,26 @@ void FilterTable::setScrollOffsets(int x, int y)
void FilterTable::mousePressEvent(QMouseEvent* event) void FilterTable::mousePressEvent(QMouseEvent* event)
{ {
if(event->buttons() & Qt::LeftButton ) if (event->buttons() & Qt::LeftButton)
{ {
int row = rowForPos(event->pos(), false); int row = rowForPos(event->pos(), false);
if(row != -1) if (row != -1)
{ {
Item* item = items[row]; Item* item = items[row];
if(event->modifiers() & Qt::ControlModifier) if (event->modifiers() & Qt::ControlModifier)
{ {
if(!selected.remove(item)) if (!selected.remove(item))
selected.insert(item); selected.insert(item);
selectionStart = item; selectionStart = item;
} }
else if(event->modifiers() & Qt::ShiftModifier) else if (event->modifiers() & Qt::ShiftModifier)
{ {
int startRow = items.indexOf(selectionStart); int startRow = items.indexOf(selectionStart);
if(startRow != -1) if (startRow != -1)
{ {
selected.clear(); selected.clear();
for(int i = min(startRow, row); i <= max(startRow, row); i++) for (int i = min(startRow, row); i <= max(startRow, row); i++)
{ {
selected.insert(items[i]); selected.insert(items[i]);
} }
@@ -611,7 +611,7 @@ void FilterTable::mousePressEvent(QMouseEvent* event)
} }
else else
{ {
if(!selected.contains(item)) if (!selected.contains(item))
{ {
selected.clear(); selected.clear();
selected.insert(item); selected.insert(item);
@@ -634,40 +634,40 @@ void FilterTable::mousePressEvent(QMouseEvent* event)
void FilterTable::mouseMoveEvent(QMouseEvent* event) void FilterTable::mouseMoveEvent(QMouseEvent* event)
{ {
if(event->buttons() & Qt::LeftButton) if (event->buttons() & Qt::LeftButton)
{ {
if((event->pos() - dragStartPos).manhattanLength() >= QApplication::startDragDistance()) if ((event->pos() - dragStartPos).manhattanLength() >= QApplication::startDragDistance())
{ {
QString text; QString text;
QList<QVariantMap> prefsList; QList<QVariantMap> prefsList;
bool first = true; bool first = true;
int i = 0; int i = 0;
bool dragPosInside = false; bool dragPosInside = false;
for(Item* item : items) for (Item* item : items)
{ {
if(selected.contains(item)) if (selected.contains(item))
{ {
if(first) if (first)
first = false; first = false;
else else
text += "\n"; text += "\n";
text += item->text; text += item->text;
if(item->gui != NULL) if (item->gui != NULL)
item->gui->storePreferences(item->prefs); item->gui->storePreferences(item->prefs);
prefsList.append(item->prefs); prefsList.append(item->prefs);
if(!dragPosInside) if (!dragPosInside)
{ {
FilterTableRow* tableRow = qobject_cast<FilterTableRow*>(gridLayout->itemAtPosition(i, 0)->widget()); FilterTableRow* tableRow = qobject_cast<FilterTableRow*>(gridLayout->itemAtPosition(i, 0)->widget());
QRect rect = tableRow->getHeaderRect().translated(tableRow->pos()); QRect rect = tableRow->getHeaderRect().translated(tableRow->pos());
if(rect.contains(dragStartPos)) if (rect.contains(dragStartPos))
dragPosInside = true; dragPosInside = true;
} }
} }
i++; i++;
} }
if(selected.size() > 0 && dragPosInside) if (selected.size() > 0 && dragPosInside)
{ {
FilterTableMimeData* mimeData = new FilterTableMimeData; FilterTableMimeData* mimeData = new FilterTableMimeData;
mimeData->setText(text); mimeData->setText(text);
@@ -679,21 +679,21 @@ void FilterTable::mouseMoveEvent(QMouseEvent* event)
internalDrag = true; internalDrag = true;
Qt::DropAction action = drag->exec(Qt::MoveAction | Qt::CopyAction); Qt::DropAction action = drag->exec(Qt::MoveAction | Qt::CopyAction);
internalDrag = false; internalDrag = false;
if(action == Qt::MoveAction) if (action == Qt::MoveAction)
{ {
for(Item* item : selectedBefore) for (Item* item : selectedBefore)
{ {
items.removeOne(item); items.removeOne(item);
if(focused == item) if (focused == item)
focused = NULL; focused = NULL;
if(selectionStart == item) if (selectionStart == item)
selectionStart = NULL; selectionStart = NULL;
selected.remove(item); selected.remove(item);
delete item; delete item;
} }
} }
if(action != Qt::IgnoreAction) if (action != Qt::IgnoreAction)
{ {
emit linesChanged(); emit linesChanged();
updateGuis(); updateGuis();
@@ -707,9 +707,9 @@ void FilterTable::mouseMoveEvent(QMouseEvent* event)
void FilterTable::dragEnterEvent(QDragEnterEvent* event) void FilterTable::dragEnterEvent(QDragEnterEvent* event)
{ {
if(event->mimeData()->hasText()) if (event->mimeData()->hasText())
{ {
if(event->keyboardModifiers() & Qt::ControlModifier) if (event->keyboardModifiers() & Qt::ControlModifier)
event->setDropAction(Qt::CopyAction); event->setDropAction(Qt::CopyAction);
else else
event->setDropAction(Qt::MoveAction); event->setDropAction(Qt::MoveAction);
@@ -721,9 +721,9 @@ void FilterTable::dragEnterEvent(QDragEnterEvent* event)
void FilterTable::dragMoveEvent(QDragMoveEvent* event) void FilterTable::dragMoveEvent(QDragMoveEvent* event)
{ {
if(event->mimeData()->hasText()) if (event->mimeData()->hasText())
{ {
if(event->keyboardModifiers() & Qt::ControlModifier) if (event->keyboardModifiers() & Qt::ControlModifier)
event->setDropAction(Qt::CopyAction); event->setDropAction(Qt::CopyAction);
else else
event->setDropAction(Qt::MoveAction); event->setDropAction(Qt::MoveAction);
@@ -748,9 +748,9 @@ void FilterTable::dragLeaveEvent(QDragLeaveEvent* event)
void FilterTable::dropEvent(QDropEvent* event) void FilterTable::dropEvent(QDropEvent* event)
{ {
const QMimeData* mimeData = event->mimeData(); const QMimeData* mimeData = event->mimeData();
if(mimeData->hasText()) if (mimeData->hasText())
{ {
if(event->keyboardModifiers() & Qt::ControlModifier) if (event->keyboardModifiers() & Qt::ControlModifier)
event->setDropAction(Qt::CopyAction); event->setDropAction(Qt::CopyAction);
else else
event->setDropAction(Qt::MoveAction); event->setDropAction(Qt::MoveAction);
@@ -759,25 +759,25 @@ void FilterTable::dropEvent(QDropEvent* event)
QStringList textLines = text.split("\n"); QStringList textLines = text.split("\n");
QList<QVariantMap> prefsList; QList<QVariantMap> prefsList;
const FilterTableMimeData* filterTableMimeData = qobject_cast<const FilterTableMimeData*>(mimeData); const FilterTableMimeData* filterTableMimeData = qobject_cast<const FilterTableMimeData*>(mimeData);
if(filterTableMimeData != NULL) if (filterTableMimeData != NULL)
prefsList = filterTableMimeData->getPrefsList(); prefsList = filterTableMimeData->getPrefsList();
int dropRow = rowForPos(event->pos(), true); int dropRow = rowForPos(event->pos(), true);
if(dropRow == -1) if (dropRow == -1)
dropRow = items.size(); dropRow = items.size();
selected.clear(); selected.clear();
focused = NULL; focused = NULL;
selectionStart = NULL; selectionStart = NULL;
for(int i = 0; i < textLines.size(); i++) for (int i = 0; i < textLines.size(); i++)
{ {
QString line = textLines[i]; QString line = textLines[i];
Item* item = new Item(line); Item* item = new Item(line);
if(!prefsList.isEmpty()) if (!prefsList.isEmpty())
item->prefs = prefsList[i]; item->prefs = prefsList[i];
selected.insert(item); selected.insert(item);
items.insert(dropRow++, item); items.insert(dropRow++, item);
if(focused == NULL) if (focused == NULL)
{ {
focused = item; focused = item;
selectionStart = item; selectionStart = item;
@@ -785,7 +785,7 @@ void FilterTable::dropEvent(QDropEvent* event)
} }
event->accept(); event->accept();
if(!internalDrag) if (!internalDrag)
{ {
emit linesChanged(); emit linesChanged();
updateGuis(); updateGuis();
@@ -799,32 +799,32 @@ void FilterTable::dropEvent(QDropEvent* event)
void FilterTable::keyPressEvent(QKeyEvent* event) void FilterTable::keyPressEvent(QKeyEvent* event)
{ {
if(event->key() == Qt::Key_Down || event->key() == Qt::Key_Up) if (event->key() == Qt::Key_Down || event->key() == Qt::Key_Up)
{ {
if(focused != NULL) if (focused != NULL)
{ {
int row = items.indexOf(focused); int row = items.indexOf(focused);
if(row != -1) if (row != -1)
{ {
int newRow = row; int newRow = row;
if(event->key() == Qt::Key_Down && row + 1 < items.size()) if (event->key() == Qt::Key_Down && row + 1 < items.size())
newRow = row + 1; newRow = row + 1;
else if(event->key() == Qt::Key_Up && row - 1 >= 0) else if (event->key() == Qt::Key_Up && row - 1 >= 0)
newRow = row - 1; newRow = row - 1;
if(newRow != row) if (newRow != row)
{ {
focused = items[newRow]; focused = items[newRow];
if(event->modifiers() & Qt::ControlModifier) if (event->modifiers() & Qt::ControlModifier)
{ {
} }
else if(event->modifiers() & Qt::ShiftModifier) else if (event->modifiers() & Qt::ShiftModifier)
{ {
int startRow = items.indexOf(selectionStart); int startRow = items.indexOf(selectionStart);
if(startRow != -1) if (startRow != -1)
{ {
selected.clear(); selected.clear();
for(int i = min(startRow, newRow); i <= max(startRow, newRow); i++) for (int i = min(startRow, newRow); i <= max(startRow, newRow); i++)
{ {
selected.insert(items[i]); selected.insert(items[i]);
} }
@@ -844,35 +844,35 @@ void FilterTable::keyPressEvent(QKeyEvent* event)
} }
} }
if(event->key() == Qt::Key_Space) if (event->key() == Qt::Key_Space)
{ {
if(!(event->modifiers() & Qt::ControlModifier) || !selected.remove(focused)) if (!(event->modifiers() & Qt::ControlModifier) || !selected.remove(focused))
selected.insert(focused); selected.insert(focused);
update(); update();
} }
if(event->key() == Qt::Key_F2) if (event->key() == Qt::Key_F2)
{ {
if(focused != NULL) if (focused != NULL)
{ {
int rowIndex = items.indexOf(focused); int rowIndex = items.indexOf(focused);
if(rowIndex != -1) if (rowIndex != -1)
{ {
QLayoutItem* layoutItem = gridLayout->itemAtPosition(rowIndex, 0); QLayoutItem* layoutItem = gridLayout->itemAtPosition(rowIndex, 0);
FilterTableRow* tableRow = qobject_cast<FilterTableRow*>(layoutItem->widget()); FilterTableRow* tableRow = qobject_cast<FilterTableRow*>(layoutItem->widget());
if(tableRow != NULL) if (tableRow != NULL)
tableRow->editText(); tableRow->editText();
} }
} }
} }
if(event->key() == Qt::Key_Delete) if (event->key() == Qt::Key_Delete)
{ {
deleteSelectedLines(); deleteSelectedLines();
} }
} }
void FilterTable::wheelEvent(QWheelEvent * event) void FilterTable::wheelEvent(QWheelEvent* event)
{ {
scrollingNow = true; scrollingNow = true;
scrollStartPoint = event->globalPos(); scrollStartPoint = event->globalPos();
@@ -880,34 +880,33 @@ void FilterTable::wheelEvent(QWheelEvent * event)
QWidget::wheelEvent(event); QWidget::wheelEvent(event);
} }
bool FilterTable::eventFilter(QObject* obj, QEvent* event) bool FilterTable::eventFilter(QObject* obj, QEvent* event)
{ {
QEvent::Type type = event->type(); QEvent::Type type = event->type();
if(scrollingNow) if (scrollingNow)
{ {
if(type == QEvent::Wheel) if (type == QEvent::Wheel)
{ {
QWidget* widget = qobject_cast<QWidget*>(obj); QWidget* widget = qobject_cast<QWidget*>(obj);
if(widget != NULL) if (widget != NULL)
{ {
if(isAncestorOf(widget)) if (isAncestorOf(widget))
{ {
QApplication::sendEvent(parent(), event); QApplication::sendEvent(parent(), event);
return true; return true;
} }
} }
} }
else if(type == QEvent::MouseMove) else if (type == QEvent::MouseMove)
{ {
QMouseEvent* mouseEvent = (QMouseEvent*)event; QMouseEvent* mouseEvent = (QMouseEvent*)event;
if((mouseEvent->globalPos() - scrollStartPoint).manhattanLength() > QApplication::startDragDistance()) if ((mouseEvent->globalPos() - scrollStartPoint).manhattanLength() > QApplication::startDragDistance())
scrollingNow = false; scrollingNow = false;
} }
} }
if(obj == scrollArea && type == QEvent::Resize) if (obj == scrollArea && type == QEvent::Resize)
{ {
updateSizeHints(); updateSizeHints();
} }
@@ -917,13 +916,13 @@ bool FilterTable::eventFilter(QObject* obj, QEvent* event)
void FilterTable::showEvent(QShowEvent*) void FilterTable::showEvent(QShowEvent*)
{ {
if(presetScrollX != -1) if (presetScrollX != -1)
{ {
scrollArea->horizontalScrollBar()->setValue(presetScrollX); scrollArea->horizontalScrollBar()->setValue(presetScrollX);
presetScrollX = -1; presetScrollX = -1;
} }
if(presetScrollY != -1) if (presetScrollY != -1)
{ {
scrollArea->verticalScrollBar()->setValue(presetScrollY); scrollArea->verticalScrollBar()->setValue(presetScrollY);
presetScrollY = -1; presetScrollY = -1;
@@ -933,12 +932,12 @@ void FilterTable::showEvent(QShowEvent*)
void FilterTable::ensureRowVisible(int row) void FilterTable::ensureRowVisible(int row)
{ {
QScrollBar* vScrollBar = scrollArea->verticalScrollBar(); QScrollBar* vScrollBar = scrollArea->verticalScrollBar();
if(vScrollBar != NULL) if (vScrollBar != NULL)
{ {
QRect rect = rowRect(row).toAlignedRect(); QRect rect = rowRect(row).toAlignedRect();
if(rect.top() < vScrollBar->value()) if (rect.top() < vScrollBar->value())
vScrollBar->setValue(max(0, rect.top())); vScrollBar->setValue(max(0, rect.top()));
else if(rect.bottom() + 1 > vScrollBar->value() + scrollArea->viewport()->height()) else if (rect.bottom() + 1 > vScrollBar->value() + scrollArea->viewport()->height())
vScrollBar->setValue(min(vScrollBar->maximum(), rect.bottom() + 1 - scrollArea->viewport()->height())); vScrollBar->setValue(min(vScrollBar->maximum(), rect.bottom() + 1 - scrollArea->viewport()->height()));
} }
} }
@@ -946,16 +945,16 @@ void FilterTable::ensureRowVisible(int row)
int FilterTable::rowForPos(QPoint pos, bool insert) int FilterTable::rowForPos(QPoint pos, bool insert)
{ {
int row = -1; int row = -1;
for(int i = 0; i < gridLayout->rowCount() - 2; i++) for (int i = 0; i < gridLayout->rowCount() - 2; i++)
{ {
QRect rect = gridLayout->itemAtPosition(i, 0)->geometry(); QRect rect = gridLayout->itemAtPosition(i, 0)->geometry();
int y; int y;
if(insert) if (insert)
y = rect.center().y(); y = rect.center().y();
else else
y = rect.bottom(); y = rect.bottom();
if(pos.y() <= y) if (pos.y() <= y)
{ {
row = i; row = i;
break; break;
@@ -975,12 +974,12 @@ QRectF FilterTable::rowRect(int row)
void FilterTable::disableWheelForWidgets() void FilterTable::disableWheelForWidgets()
{ {
QList<QWidget*> widgets = findChildren<QWidget*>(); QList<QWidget*> widgets = findChildren<QWidget*>();
for(QWidget* widget : widgets) for (QWidget* widget : widgets)
{ {
if(qobject_cast<QComboBox*>(widget) || qobject_cast<QAbstractSpinBox*>(widget) || qobject_cast<QDial*>(widget)) if (qobject_cast<QComboBox*>(widget) || qobject_cast<QAbstractSpinBox*>(widget) || qobject_cast<QDial*>(widget))
{ {
widget->installEventFilter(new DisableWheelFilter(this, widget)); widget->installEventFilter(new DisableWheelFilter(this, widget));
if(widget->focusPolicy() == Qt::WheelFocus) if (widget->focusPolicy() == Qt::WheelFocus)
widget->setFocusPolicy(Qt::StrongFocus); widget->setFocusPolicy(Qt::StrongFocus);
} }
} }
+8 -7
View File
@@ -39,7 +39,8 @@ class FilterTable : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
struct Item { struct Item
{
Item() Item()
{ {
} }
@@ -54,7 +55,7 @@ public:
IFilterGUI* gui = NULL; IFilterGUI* gui = NULL;
}; };
explicit FilterTable(MainWindow* mainWindow, QWidget *parent = 0); explicit FilterTable(MainWindow* mainWindow, QWidget* parent = 0);
void initialize(QScrollArea* scrollArea, const QList<DeviceAPOInfo>& outputDevices, const QList<DeviceAPOInfo>& inputDevices); void initialize(QScrollArea* scrollArea, const QList<DeviceAPOInfo>& outputDevices, const QList<DeviceAPOInfo>& inputDevices);
void updateDeviceAndChannelMask(DeviceAPOInfo* selectedDevice, int selectedChannelMask); void updateDeviceAndChannelMask(DeviceAPOInfo* selectedDevice, int selectedChannelMask);
void updateGuis(); void updateGuis();
@@ -101,11 +102,11 @@ public slots:
protected: protected:
void mousePressEvent(QMouseEvent* event) override; void mousePressEvent(QMouseEvent* event) override;
void mouseMoveEvent(QMouseEvent *event) override; void mouseMoveEvent(QMouseEvent* event) override;
void dragEnterEvent(QDragEnterEvent *event) override; void dragEnterEvent(QDragEnterEvent* event) override;
void dragMoveEvent(QDragMoveEvent *event) override; void dragMoveEvent(QDragMoveEvent* event) override;
void dragLeaveEvent(QDragLeaveEvent* event) override; void dragLeaveEvent(QDragLeaveEvent* event) override;
void dropEvent(QDropEvent *event) override; void dropEvent(QDropEvent* event) override;
void keyPressEvent(QKeyEvent* event) override; void keyPressEvent(QKeyEvent* event) override;
void wheelEvent(QWheelEvent* event) override; void wheelEvent(QWheelEvent* event) override;
bool eventFilter(QObject* obj, QEvent* event) override; bool eventFilter(QObject* obj, QEvent* event) override;
@@ -144,7 +145,7 @@ template<typename T> inline uint qHash(QList<T> list)
{ {
uint hashValue = 0; uint hashValue = 0;
for(T t : list) for (T t : list)
hashValue = 31 * hashValue + qHash(t); hashValue = 31 * hashValue + qHash(t);
return hashValue; return hashValue;
+15 -15
View File
@@ -25,8 +25,8 @@
#include "FilterTableRow.h" #include "FilterTableRow.h"
#include "ui_FilterTableRow.h" #include "ui_FilterTableRow.h"
FilterTableRow::FilterTableRow(FilterTable* table, int number, FilterTable::Item* item, IFilterGUI* gui) : FilterTableRow::FilterTableRow(FilterTable* table, int number, FilterTable::Item* item, IFilterGUI* gui)
QWidget(table), : QWidget(table),
ui(new Ui::FilterTableRow) ui(new Ui::FilterTableRow)
{ {
ui->setupUi(this); ui->setupUi(this);
@@ -44,7 +44,7 @@ FilterTableRow::FilterTableRow(FilterTable* table, int number, FilterTable::Item
ui->stackedWidget->setContentsMargins(0, 5, 0, 5); ui->stackedWidget->setContentsMargins(0, 5, 0, 5);
if(gui != NULL) if (gui != NULL)
{ {
connect(gui, SIGNAL(updateModel()), this, SLOT(updateModel())); connect(gui, SIGNAL(updateModel()), this, SLOT(updateModel()));
ui->stackedWidget->addWidget(gui); ui->stackedWidget->addWidget(gui);
@@ -70,7 +70,7 @@ QRect FilterTableRow::getHeaderRect()
void FilterTableRow::editText() void FilterTableRow::editText()
{ {
if(!ui->actionEditText->isChecked()) if (!ui->actionEditText->isChecked())
ui->actionEditText->trigger(); ui->actionEditText->trigger();
} }
@@ -78,14 +78,14 @@ QSize FilterTableRow::sizeHint() const
{ {
QSize size = QWidget::minimumSizeHint(); QSize size = QWidget::minimumSizeHint();
int preferredWidth = table->getPreferredWidth(); int preferredWidth = table->getPreferredWidth();
if(size.width() < preferredWidth) if (size.width() < preferredWidth)
size = QSize(preferredWidth, size.height()); size = QSize(preferredWidth, size.height());
return size; return size;
} }
void FilterTableRow::mouseDoubleClickEvent(QMouseEvent*) void FilterTableRow::mouseDoubleClickEvent(QMouseEvent*)
{ {
if(gui == NULL && ui->stackedWidget->currentIndex() == 1) if (gui == NULL && ui->stackedWidget->currentIndex() == 1)
ui->actionEditText->trigger(); ui->actionEditText->trigger();
} }
@@ -98,16 +98,16 @@ void FilterTableRow::paintEvent(QPaintEvent*)
r = r.marginsAdded(QMarginsF(-1.5, -1.5, -1.5, -0.5)); r = r.marginsAdded(QMarginsF(-1.5, -1.5, -1.5, -0.5));
QColor color; QColor color;
if(table->getSelectedItems().contains(item)) if (table->getSelectedItems().contains(item))
{ {
if(table->getFocusedItem() == item) if (table->getFocusedItem() == item)
color = QColor(44, 111, 222); color = QColor(44, 111, 222);
else else
color = QColor(64, 136, 255); color = QColor(64, 136, 255);
} }
else else
{ {
if(table->getFocusedItem() == item) if (table->getFocusedItem() == item)
color = QColor(160, 160, 160); color = QColor(160, 160, 160);
else else
color = QColor(180, 180, 180); color = QColor(180, 180, 180);
@@ -149,7 +149,7 @@ void FilterTableRow::on_actionAdd_triggered()
QPoint p = ui->toolBar->mapToGlobal(QPoint(rect.x(), rect.y() + rect.height())); QPoint p = ui->toolBar->mapToGlobal(QPoint(rect.x(), rect.y() + rect.height()));
QAction* action = menu->exec(p); QAction* action = menu->exec(p);
ui->actionAdd->setChecked(false); ui->actionAdd->setChecked(false);
if(action != NULL) if (action != NULL)
{ {
FilterTemplate t = action->data().value<FilterTemplate>(); FilterTemplate t = action->data().value<FilterTemplate>();
QString line = t.getLine(); QString line = t.getLine();
@@ -166,9 +166,9 @@ void FilterTableRow::on_actionRemove_triggered()
void FilterTableRow::on_actionEditText_triggered(bool checked) void FilterTableRow::on_actionEditText_triggered(bool checked)
{ {
if(checked) if (checked)
{ {
if(!lastEditTime.isValid() || lastEditTime.elapsed() > 100) if (!lastEditTime.isValid() || lastEditTime.elapsed() > 100)
{ {
ui->lineEdit->setText(item->text); ui->lineEdit->setText(item->text);
ui->stackedWidget->setCurrentIndex(0); ui->stackedWidget->setCurrentIndex(0);
@@ -183,9 +183,9 @@ void FilterTableRow::on_actionEditText_triggered(bool checked)
void FilterTableRow::on_lineEdit_editingFinished() void FilterTableRow::on_lineEdit_editingFinished()
{ {
if(ui->stackedWidget->currentIndex() == 0 && !editingDone) if (ui->stackedWidget->currentIndex() == 0 && !editingDone)
{ {
if(ui->lineEdit->text() != item->text) if (ui->lineEdit->text() != item->text)
{ {
editingDone = true; editingDone = true;
item->text = ui->lineEdit->text(); item->text = ui->lineEdit->text();
@@ -204,7 +204,7 @@ void FilterTableRow::on_lineEdit_editingFinished()
void FilterTableRow::on_lineEdit_editingCanceled() void FilterTableRow::on_lineEdit_editingCanceled()
{ {
if(ui->stackedWidget->currentIndex() == 0) if (ui->stackedWidget->currentIndex() == 0)
{ {
// will cause editingFinished to be called, so prevent committing // will cause editingFinished to be called, so prevent committing
editingDone = true; editingDone = true;
+1 -1
View File
@@ -55,7 +55,7 @@ private slots:
void on_lineEdit_editingCanceled(); void on_lineEdit_editingCanceled();
private: private:
Ui::FilterTableRow *ui; Ui::FilterTableRow* ui;
FilterTable* table; FilterTable* table;
FilterTable::Item* item; FilterTable::Item* item;
IFilterGUI* gui; IFilterGUI* gui;
+2 -2
View File
@@ -19,8 +19,8 @@
#include "IFilterGUI.h" #include "IFilterGUI.h"
IFilterGUI::IFilterGUI(QWidget* parent) : IFilterGUI::IFilterGUI(QWidget* parent)
QWidget(parent) : QWidget(parent)
{ {
} }
+125 -125
View File
@@ -47,16 +47,16 @@
using namespace std; using namespace std;
MainWindow::MainWindow(QDir configDir, QWidget *parent) : MainWindow::MainWindow(QDir configDir, QWidget* parent)
QMainWindow(parent), ui(new Ui::MainWindow), configDir(configDir) : QMainWindow(parent), ui(new Ui::MainWindow), configDir(configDir)
{ {
outputDevices = QList<DeviceAPOInfo>::fromVector(QVector<DeviceAPOInfo>::fromStdVector(DeviceAPOInfo::loadAllInfos(false))); outputDevices = QList<DeviceAPOInfo>::fromVector(QVector<DeviceAPOInfo>::fromStdVector(DeviceAPOInfo::loadAllInfos(false)));
inputDevices = QList<DeviceAPOInfo>::fromVector(QVector<DeviceAPOInfo>::fromStdVector(DeviceAPOInfo::loadAllInfos(true))); inputDevices = QList<DeviceAPOInfo>::fromVector(QVector<DeviceAPOInfo>::fromStdVector(DeviceAPOInfo::loadAllInfos(true)));
defaultOutputDevice = NULL; defaultOutputDevice = NULL;
for(DeviceAPOInfo& apoInfo : outputDevices) for (DeviceAPOInfo& apoInfo : outputDevices)
{ {
if(apoInfo.isDefaultDevice) if (apoInfo.isDefaultDevice)
{ {
defaultOutputDevice = &apoInfo; defaultOutputDevice = &apoInfo;
break; break;
@@ -68,7 +68,7 @@ MainWindow::MainWindow(QDir configDir, QWidget *parent) :
LogHelper::set(stderr, true, false, false); LogHelper::set(stderr, true, false, false);
QString version = QString("%0.%1").arg(MAJOR).arg(MINOR); QString version = QString("%0.%1").arg(MAJOR).arg(MINOR);
if(REVISION != 0) if (REVISION != 0)
version += QString(".%0").arg(REVISION); version += QString(".%0").arg(REVISION);
setWindowTitle(tr("Equalizer APO %0 Configuration Editor").arg(version)); setWindowTitle(tr("Equalizer APO %0 Configuration Editor").arg(version));
@@ -103,7 +103,7 @@ MainWindow::MainWindow(QDir configDir, QWidget *parent) :
ui->mainToolBar->addWidget(channelConfigurationComboBox); ui->mainToolBar->addWidget(channelConfigurationComboBox);
QStandardItemModel* model = qobject_cast<QStandardItemModel*>(deviceComboBox->model()); QStandardItemModel* model = qobject_cast<QStandardItemModel*>(deviceComboBox->model());
if(defaultOutputDevice != NULL) if (defaultOutputDevice != NULL)
deviceComboBox->addItem(tr("Default") + " (" + QString::fromStdWString(defaultOutputDevice->connectionName) + " - " + QString::fromStdWString(defaultOutputDevice->deviceName) + ")", NULL); deviceComboBox->addItem(tr("Default") + " (" + QString::fromStdWString(defaultOutputDevice->connectionName) + " - " + QString::fromStdWString(defaultOutputDevice->deviceName) + ")", NULL);
deviceComboBox->addItem(tr("Playback devices:")); deviceComboBox->addItem(tr("Playback devices:"));
@@ -113,8 +113,8 @@ MainWindow::MainWindow(QDir configDir, QWidget *parent) :
item->setFont(font); item->setFont(font);
item->setSelectable(false); item->setSelectable(false);
for(DeviceAPOInfo& apoInfo : outputDevices) for (DeviceAPOInfo& apoInfo : outputDevices)
if(apoInfo.isInstalled) if (apoInfo.isInstalled)
deviceComboBox->addItem(QString::fromStdWString(apoInfo.connectionName) + " - " + QString::fromStdWString(apoInfo.deviceName), QVariant::fromValue(&apoInfo)); deviceComboBox->addItem(QString::fromStdWString(apoInfo.connectionName) + " - " + QString::fromStdWString(apoInfo.deviceName), QVariant::fromValue(&apoInfo));
deviceComboBox->addItem(tr("Capture devices:")); deviceComboBox->addItem(tr("Capture devices:"));
@@ -122,8 +122,8 @@ MainWindow::MainWindow(QDir configDir, QWidget *parent) :
item->setFont(font); item->setFont(font);
item->setSelectable(false); item->setSelectable(false);
for(DeviceAPOInfo& apoInfo : inputDevices) for (DeviceAPOInfo& apoInfo : inputDevices)
if(apoInfo.isInstalled) if (apoInfo.isInstalled)
deviceComboBox->addItem(QString::fromStdWString(apoInfo.connectionName) + " - " + QString::fromStdWString(apoInfo.deviceName), QVariant::fromValue(&apoInfo)); deviceComboBox->addItem(QString::fromStdWString(apoInfo.connectionName) + " - " + QString::fromStdWString(apoInfo.deviceName), QVariant::fromValue(&apoInfo));
connect(channelConfigurationComboBox, SIGNAL(activated(int)), this, SLOT(channelConfigurationSelected(int))); connect(channelConfigurationComboBox, SIGNAL(activated(int)), this, SLOT(channelConfigurationSelected(int)));
@@ -136,21 +136,21 @@ MainWindow::MainWindow(QDir configDir, QWidget *parent) :
connect(analysisThread, SIGNAL(analysisFinished()), this, SLOT(updateAnalysisPanel())); connect(analysisThread, SIGNAL(analysisFinished()), this, SLOT(updateAnalysisPanel()));
QLocale autoLocale = QLocale::system(); QLocale autoLocale = QLocale::system();
if(autoLocale.language() != QLocale::German) if (autoLocale.language() != QLocale::German)
autoLocale = QLocale("en"); autoLocale = QLocale("en");
QLocale::Language languages[] = {QLocale::AnyLanguage, QLocale::English, QLocale::German}; QLocale::Language languages[] = {QLocale::AnyLanguage, QLocale::English, QLocale::German};
for(int i = 0; i < sizeof(languages) / sizeof(QLocale::Language); i++) for (int i = 0; i < sizeof(languages) / sizeof(QLocale::Language); i++)
{ {
QLocale::Language language = languages[i]; QLocale::Language language = languages[i];
QString languageName; QString languageName;
if(language == QLocale::AnyLanguage) if (language == QLocale::AnyLanguage)
languageName = autoLocale.nativeLanguageName(); languageName = autoLocale.nativeLanguageName();
else else
languageName = QLocale(language).nativeLanguageName(); languageName = QLocale(language).nativeLanguageName();
if(languageName == "American English") if (languageName == "American English")
languageName = "English"; languageName = "English";
QString text; QString text;
if(language == QLocale::AnyLanguage) if (language == QLocale::AnyLanguage)
text = tr("Automatic (%0)").arg(languageName); text = tr("Automatic (%0)").arg(languageName);
else else
text = languageName; text = languageName;
@@ -172,18 +172,18 @@ MainWindow::~MainWindow()
void MainWindow::doChecks() void MainWindow::doChecks()
{ {
if(!DeviceAPOInfo::checkProtectedAudioDG(false) || !DeviceAPOInfo::checkAPORegistration(false)) if (!DeviceAPOInfo::checkProtectedAudioDG(false) || !DeviceAPOInfo::checkAPORegistration(false))
{ {
if(QMessageBox::warning(this, tr("Registry problem"), tr("A registry value that is required for the operation of Equalizer APO is not set correctly.\nDo you want to run the Configurator application to fix the problem?"), QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes) if (QMessageBox::warning(this, tr("Registry problem"), tr("A registry value that is required for the operation of Equalizer APO is not set correctly.\nDo you want to run the Configurator application to fix the problem?"), QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes)
{ {
runConfigurator(); runConfigurator();
return; return;
} }
} }
if(!defaultOutputDevice->isInstalled) if (!defaultOutputDevice->isInstalled)
{ {
if(QMessageBox::warning(this, tr("APO not installed to device"), tr("Equalizer APO has not been installed to the selected device.\nDo you want to run the Configurator application to fix the problem?"), QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes) if (QMessageBox::warning(this, tr("APO not installed to device"), tr("Equalizer APO has not been installed to the selected device.\nDo you want to run the Configurator application to fix the problem?"), QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes)
{ {
runConfigurator(); runConfigurator();
return; return;
@@ -191,20 +191,20 @@ void MainWindow::doChecks()
} }
DeviceAPOInfo* disabledApoInfo = NULL; DeviceAPOInfo* disabledApoInfo = NULL;
for(DeviceAPOInfo& apoInfo : outputDevices) for (DeviceAPOInfo& apoInfo : outputDevices)
{ {
if(apoInfo.isInstalled && apoInfo.isEnhancementsDisabled) if (apoInfo.isInstalled && apoInfo.isEnhancementsDisabled)
{ {
disabledApoInfo = &apoInfo; disabledApoInfo = &apoInfo;
break; break;
} }
} }
if(disabledApoInfo == NULL) if (disabledApoInfo == NULL)
{ {
for(DeviceAPOInfo& apoInfo : inputDevices) for (DeviceAPOInfo& apoInfo : inputDevices)
{ {
if(apoInfo.isInstalled && apoInfo.isEnhancementsDisabled) if (apoInfo.isInstalled && apoInfo.isEnhancementsDisabled)
{ {
disabledApoInfo = &apoInfo; disabledApoInfo = &apoInfo;
break; break;
@@ -212,9 +212,9 @@ void MainWindow::doChecks()
} }
} }
if(disabledApoInfo != NULL) if (disabledApoInfo != NULL)
{ {
if(QMessageBox::warning(this, tr("Audio enhancements disabled"), tr("Audio enhancements are not enabled for the device\n%0 %1.\nDo you want to run the Configurator application to fix the problem?").arg(QString::fromStdWString(disabledApoInfo->connectionName)).arg(QString::fromStdWString(disabledApoInfo->deviceName)), QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes) if (QMessageBox::warning(this, tr("Audio enhancements disabled"), tr("Audio enhancements are not enabled for the device\n%0 %1.\nDo you want to run the Configurator application to fix the problem?").arg(QString::fromStdWString(disabledApoInfo->connectionName)).arg(QString::fromStdWString(disabledApoInfo->deviceName)), QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes)
{ {
runConfigurator(); runConfigurator();
return; return;
@@ -227,7 +227,7 @@ void MainWindow::runConfigurator()
// cannot use QProcess::startDetached because of UAC // cannot use QProcess::startDetached because of UAC
wstring file = (QDir::toNativeSeparators(QCoreApplication::applicationDirPath() + "/Configurator.exe")).toStdWString(); wstring file = (QDir::toNativeSeparators(QCoreApplication::applicationDirPath() + "/Configurator.exe")).toStdWString();
int result = (int)ShellExecuteW(NULL, L"open", file.c_str(), NULL, NULL, SW_SHOWNORMAL); int result = (int)ShellExecuteW(NULL, L"open", file.c_str(), NULL, NULL, SW_SHOWNORMAL);
if(result == SE_ERR_ACCESSDENIED) if (result == SE_ERR_ACCESSDENIED)
ShellExecuteW(NULL, L"runas", file.c_str(), NULL, NULL, SW_SHOWNORMAL); ShellExecuteW(NULL, L"runas", file.c_str(), NULL, NULL, SW_SHOWNORMAL);
} }
@@ -235,12 +235,12 @@ void MainWindow::load(QString path)
{ {
path = QDir::toNativeSeparators(path); path = QDir::toNativeSeparators(path);
for(int i = 0; i < ui->tabWidget->count(); i++) for (int i = 0; i < ui->tabWidget->count(); i++)
{ {
QScrollArea* scrollArea = qobject_cast<QScrollArea*>(ui->tabWidget->widget(i)); QScrollArea* scrollArea = qobject_cast<QScrollArea*>(ui->tabWidget->widget(i));
FilterTable* filterTable = qobject_cast<FilterTable*>(scrollArea->widget()); FilterTable* filterTable = qobject_cast<FilterTable*>(scrollArea->widget());
if(filterTable->getConfigPath() == path) if (filterTable->getConfigPath() == path)
{ {
ui->tabWidget->setCurrentIndex(i); ui->tabWidget->setCurrentIndex(i);
return; return;
@@ -251,13 +251,13 @@ void MainWindow::load(QString path)
timer.start(); timer.start();
HANDLE hFile = INVALID_HANDLE_VALUE; HANDLE hFile = INVALID_HANDLE_VALUE;
while(hFile == INVALID_HANDLE_VALUE) while (hFile == INVALID_HANDLE_VALUE)
{ {
hFile = CreateFile(path.toStdWString().c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); hFile = CreateFile(path.toStdWString().c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if(hFile == INVALID_HANDLE_VALUE) if (hFile == INVALID_HANDLE_VALUE)
{ {
DWORD error = GetLastError(); DWORD error = GetLastError();
if(error != ERROR_SHARING_VIOLATION) if (error != ERROR_SHARING_VIOLATION)
{ {
QMessageBox::critical(this, tr("Error"), tr("Error while reading configuration file: %0").arg(QString::fromStdWString(StringHelper::getSystemErrorString(error)))); QMessageBox::critical(this, tr("Error"), tr("Error while reading configuration file: %0").arg(QString::fromStdWString(StringHelper::getSystemErrorString(error))));
return; return;
@@ -272,7 +272,7 @@ void MainWindow::load(QString path)
char buf[8192]; char buf[8192];
unsigned long bytesRead = -1; unsigned long bytesRead = -1;
while(ReadFile(hFile, buf, sizeof(buf), &bytesRead, NULL) && bytesRead != 0) while (ReadFile(hFile, buf, sizeof(buf), &bytesRead, NULL) && bytesRead != 0)
{ {
inputStream.write(buf, bytesRead); inputStream.write(buf, bytesRead);
} }
@@ -282,15 +282,15 @@ void MainWindow::load(QString path)
inputStream.seekg(0); inputStream.seekg(0);
QList<QString> lines; QList<QString> lines;
while(inputStream.good()) while (inputStream.good())
{ {
string encodedLine; string encodedLine;
getline(inputStream, encodedLine); getline(inputStream, encodedLine);
if(encodedLine.size() > 0 && encodedLine[encodedLine.size() - 1] == '\r') if (encodedLine.size() > 0 && encodedLine[encodedLine.size() - 1] == '\r')
encodedLine.resize(encodedLine.size() - 1); encodedLine.resize(encodedLine.size() - 1);
wstring line = StringHelper::toWString(encodedLine, CP_UTF8); wstring line = StringHelper::toWString(encodedLine, CP_UTF8);
if(line.find(L'\uFFFD') != -1) if (line.find(L'\uFFFD') != -1)
line = StringHelper::toWString(encodedLine, CP_ACP); line = StringHelper::toWString(encodedLine, CP_ACP);
lines.append(QString::fromStdWString(line)); lines.append(QString::fromStdWString(line));
@@ -309,7 +309,7 @@ void MainWindow::load(QString path)
recentFiles.removeAll(path); recentFiles.removeAll(path);
recentFiles.prepend(path); recentFiles.prepend(path);
if(recentFiles.size() > 10) if (recentFiles.size() > 10)
recentFiles.removeLast(); recentFiles.removeLast();
updateRecentFiles(); updateRecentFiles();
} }
@@ -323,9 +323,9 @@ void MainWindow::save(FilterTable* filterTable, QString path)
bool first = true; bool first = true;
QByteArray byteArray; QByteArray byteArray;
for(QString line : lines) for (QString line : lines)
{ {
if(first) if (first)
first = false; first = false;
else else
byteArray.append("\r\n"); byteArray.append("\r\n");
@@ -333,13 +333,13 @@ void MainWindow::save(FilterTable* filterTable, QString path)
} }
HANDLE hFile = INVALID_HANDLE_VALUE; HANDLE hFile = INVALID_HANDLE_VALUE;
while(hFile == INVALID_HANDLE_VALUE) while (hFile == INVALID_HANDLE_VALUE)
{ {
hFile = CreateFile(path.toStdWString().c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); hFile = CreateFile(path.toStdWString().c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if(hFile == INVALID_HANDLE_VALUE) if (hFile == INVALID_HANDLE_VALUE)
{ {
DWORD error = GetLastError(); DWORD error = GetLastError();
if(error != ERROR_SHARING_VIOLATION) if (error != ERROR_SHARING_VIOLATION)
{ {
QMessageBox::critical(this, tr("Error"), tr("Error while writing configuration file: %0").arg(QString::fromStdWString(StringHelper::getSystemErrorString(error)))); QMessageBox::critical(this, tr("Error"), tr("Error while writing configuration file: %0").arg(QString::fromStdWString(StringHelper::getSystemErrorString(error))));
return; return;
@@ -352,7 +352,7 @@ void MainWindow::save(FilterTable* filterTable, QString path)
unsigned long bytesWritten; unsigned long bytesWritten;
WriteFile(hFile, byteArray.constData(), byteArray.length(), &bytesWritten, NULL); WriteFile(hFile, byteArray.constData(), byteArray.length(), &bytesWritten, NULL);
if(bytesWritten != byteArray.length()) if (bytesWritten != byteArray.length())
{ {
// should never happen // should never happen
QMessageBox::critical(this, tr("Error"), tr("Only %0/%1 bytes have been written!").arg(bytesWritten).arg(byteArray.length())); QMessageBox::critical(this, tr("Error"), tr("Only %0/%1 bytes have been written!").arg(bytesWritten).arg(byteArray.length()));
@@ -378,16 +378,16 @@ bool MainWindow::shouldRestart()
void MainWindow::closeEvent(QCloseEvent* event) void MainWindow::closeEvent(QCloseEvent* event)
{ {
bool canceled = false; bool canceled = false;
for(int i = 0; i < ui->tabWidget->count(); i++) for (int i = 0; i < ui->tabWidget->count(); i++)
{ {
if(!askForClose(i)) if (!askForClose(i))
{ {
canceled = true; canceled = true;
break; break;
} }
} }
if(canceled) if (canceled)
{ {
event->ignore(); event->ignore();
restart = false; restart = false;
@@ -403,32 +403,32 @@ void MainWindow::closeEvent(QCloseEvent* event)
void MainWindow::deviceSelected(int index) void MainWindow::deviceSelected(int index)
{ {
DeviceAPOInfo* apoInfo = deviceComboBox->itemData(index).value<DeviceAPOInfo*>(); DeviceAPOInfo* apoInfo = deviceComboBox->itemData(index).value<DeviceAPOInfo*>();
if(apoInfo == NULL) if (apoInfo == NULL)
apoInfo = defaultOutputDevice; apoInfo = defaultOutputDevice;
channelConfigurationComboBox->clear(); channelConfigurationComboBox->clear();
const QList<GUIChannelHelper::ChannelConfigurationInfo>& infos = GUIChannelHelper::getInstance()->getChannelConfigurationInfos(); const QList<GUIChannelHelper::ChannelConfigurationInfo>& infos = GUIChannelHelper::getInstance()->getChannelConfigurationInfos();
if(apoInfo != NULL) if (apoInfo != NULL)
{ {
const GUIChannelHelper::ChannelConfigurationInfo* selectedInfo = NULL; const GUIChannelHelper::ChannelConfigurationInfo* selectedInfo = NULL;
for(const GUIChannelHelper::ChannelConfigurationInfo& info : infos) for (const GUIChannelHelper::ChannelConfigurationInfo& info : infos)
{ {
if(info.channelMask == apoInfo->channelMask) if (info.channelMask == apoInfo->channelMask)
{ {
selectedInfo = &info; selectedInfo = &info;
break; break;
} }
} }
if(selectedInfo != NULL) if (selectedInfo != NULL)
channelConfigurationComboBox->addItem(tr("From device") + " (" + selectedInfo->name + ")", 0); channelConfigurationComboBox->addItem(tr("From device") + " (" + selectedInfo->name + ")", 0);
else else
channelConfigurationComboBox->addItem(tr("From device") + " (" + apoInfo->channelCount + " channels)", 0); channelConfigurationComboBox->addItem(tr("From device") + " (" + apoInfo->channelCount + " channels)", 0);
} }
for(const GUIChannelHelper::ChannelConfigurationInfo& info : infos) for (const GUIChannelHelper::ChannelConfigurationInfo& info : infos)
channelConfigurationComboBox->addItem(info.name, info.channelMask); channelConfigurationComboBox->addItem(info.name, info.channelMask);
channelConfigurationSelected(channelConfigurationComboBox->currentIndex()); channelConfigurationSelected(channelConfigurationComboBox->currentIndex());
@@ -440,7 +440,7 @@ void MainWindow::channelConfigurationSelected(int index)
int channelMask; int channelMask;
getDeviceAndChannelMask(&selectedDevice, &channelMask); getDeviceAndChannelMask(&selectedDevice, &channelMask);
for(int i = 0; i < ui->tabWidget->count(); i++) for (int i = 0; i < ui->tabWidget->count(); i++)
{ {
QScrollArea* scrollArea = qobject_cast<QScrollArea*>(ui->tabWidget->widget(i)); QScrollArea* scrollArea = qobject_cast<QScrollArea*>(ui->tabWidget->widget(i));
FilterTable* filterTable = qobject_cast<FilterTable*>(scrollArea->widget()); FilterTable* filterTable = qobject_cast<FilterTable*>(scrollArea->widget());
@@ -449,22 +449,22 @@ void MainWindow::channelConfigurationSelected(int index)
ui->analysisChannelComboBox->clear(); ui->analysisChannelComboBox->clear();
if(selectedDevice != NULL) if (selectedDevice != NULL)
{ {
unsigned channelCount = selectedDevice->channelCount; unsigned channelCount = selectedDevice->channelCount;
if(channelMask != 0 && channelMask != selectedDevice->channelMask) if (channelMask != 0 && channelMask != selectedDevice->channelMask)
{ {
channelCount = 0; channelCount = 0;
for(int i = 0; i < 31; i++) for (int i = 0; i < 31; i++)
{ {
int channelPos = 1 << i; int channelPos = 1 << i;
if(channelMask & channelPos) if (channelMask & channelPos)
channelCount++; channelCount++;
} }
} }
vector<wstring> channelNames = ChannelHelper::getChannelNames(channelCount, channelMask); vector<wstring> channelNames = ChannelHelper::getChannelNames(channelCount, channelMask);
for(wstring channelName : channelNames) for (wstring channelName : channelNames)
{ {
ui->analysisChannelComboBox->addItem(QString::fromStdWString(channelName)); ui->analysisChannelComboBox->addItem(QString::fromStdWString(channelName));
} }
@@ -475,10 +475,10 @@ void MainWindow::linesChanged()
{ {
FilterTable* filterTable = qobject_cast<FilterTable*>(sender()); FilterTable* filterTable = qobject_cast<FilterTable*>(sender());
if(instantModeCheckBox->isChecked()) if (instantModeCheckBox->isChecked())
{ {
QString configPath = filterTable->getConfigPath(); QString configPath = filterTable->getConfigPath();
if(configPath.length() > 0) if (configPath.length() > 0)
{ {
save(filterTable, configPath); save(filterTable, configPath);
return; return;
@@ -486,17 +486,17 @@ void MainWindow::linesChanged()
} }
int tabIndex = -1; int tabIndex = -1;
for(int i = 0; i < ui->tabWidget->count(); i++) for (int i = 0; i < ui->tabWidget->count(); i++)
{ {
QScrollArea* scrollArea = qobject_cast<QScrollArea*>(ui->tabWidget->widget(i)); QScrollArea* scrollArea = qobject_cast<QScrollArea*>(ui->tabWidget->widget(i));
if(scrollArea->widget() == filterTable) if (scrollArea->widget() == filterTable)
{ {
tabIndex = i; tabIndex = i;
break; break;
} }
} }
QString tabText = ui->tabWidget->tabText(tabIndex); QString tabText = ui->tabWidget->tabText(tabIndex);
if(!tabText.endsWith('*')) if (!tabText.endsWith('*'))
{ {
tabText += '*'; tabText += '*';
ui->tabWidget->setTabText(tabIndex, tabText); ui->tabWidget->setTabText(tabIndex, tabText);
@@ -505,7 +505,7 @@ void MainWindow::linesChanged()
bool MainWindow::on_tabWidget_tabCloseRequested(int index) bool MainWindow::on_tabWidget_tabCloseRequested(int index)
{ {
if(askForClose(index)) if (askForClose(index))
ui->tabWidget->removeTab(index); ui->tabWidget->removeTab(index);
return true; return true;
} }
@@ -514,25 +514,25 @@ void MainWindow::on_actionOpen_triggered()
{ {
QScrollArea* scrollArea = qobject_cast<QScrollArea*>(ui->tabWidget->currentWidget()); QScrollArea* scrollArea = qobject_cast<QScrollArea*>(ui->tabWidget->currentWidget());
QString path; QString path;
if(scrollArea != NULL) if (scrollArea != NULL)
{ {
FilterTable* filterTable = qobject_cast<FilterTable*>(scrollArea->widget()); FilterTable* filterTable = qobject_cast<FilterTable*>(scrollArea->widget());
if(filterTable->getConfigPath().length() > 0) if (filterTable->getConfigPath().length() > 0)
{ {
QFileInfo fileInfo(filterTable->getConfigPath()); QFileInfo fileInfo(filterTable->getConfigPath());
path = fileInfo.absolutePath(); path = fileInfo.absolutePath();
} }
} }
if(path.length() == 0) if (path.length() == 0)
path = configDir.absolutePath(); path = configDir.absolutePath();
QFileDialog dialog(this, tr("Open file"), path, "*.txt"); QFileDialog dialog(this, tr("Open file"), path, "*.txt");
dialog.setFileMode(QFileDialog::ExistingFiles); dialog.setFileMode(QFileDialog::ExistingFiles);
dialog.setNameFilter(tr("E-APO configurations (*.txt)")); dialog.setNameFilter(tr("E-APO configurations (*.txt)"));
if(dialog.exec() == QDialog::Accepted) if (dialog.exec() == QDialog::Accepted)
{ {
for(QString file : dialog.selectedFiles()) for (QString file : dialog.selectedFiles())
load(file); load(file);
} }
} }
@@ -540,12 +540,12 @@ void MainWindow::on_actionOpen_triggered()
void MainWindow::on_actionSave_triggered() void MainWindow::on_actionSave_triggered()
{ {
QScrollArea* scrollArea = qobject_cast<QScrollArea*>(ui->tabWidget->currentWidget()); QScrollArea* scrollArea = qobject_cast<QScrollArea*>(ui->tabWidget->currentWidget());
if(scrollArea == NULL) if (scrollArea == NULL)
return; return;
FilterTable* filterTable = qobject_cast<FilterTable*>(scrollArea->widget()); FilterTable* filterTable = qobject_cast<FilterTable*>(scrollArea->widget());
if(filterTable->getConfigPath().length() == 0) if (filterTable->getConfigPath().length() == 0)
{ {
ui->actionSaveAs->trigger(); ui->actionSaveAs->trigger();
} }
@@ -554,7 +554,7 @@ void MainWindow::on_actionSave_triggered()
save(filterTable, filterTable->getConfigPath()); save(filterTable, filterTable->getConfigPath());
QString tabText = ui->tabWidget->tabText(ui->tabWidget->currentIndex()); QString tabText = ui->tabWidget->tabText(ui->tabWidget->currentIndex());
if(tabText.endsWith('*')) if (tabText.endsWith('*'))
ui->tabWidget->setTabText(ui->tabWidget->currentIndex(), tabText.left(tabText.length() - 1)); ui->tabWidget->setTabText(ui->tabWidget->currentIndex(), tabText.left(tabText.length() - 1));
} }
} }
@@ -562,13 +562,13 @@ void MainWindow::on_actionSave_triggered()
void MainWindow::on_actionSaveAs_triggered() void MainWindow::on_actionSaveAs_triggered()
{ {
QScrollArea* scrollArea = qobject_cast<QScrollArea*>(ui->tabWidget->currentWidget()); QScrollArea* scrollArea = qobject_cast<QScrollArea*>(ui->tabWidget->currentWidget());
if(scrollArea == NULL) if (scrollArea == NULL)
return; return;
FilterTable* filterTable = qobject_cast<FilterTable*>(scrollArea->widget()); FilterTable* filterTable = qobject_cast<FilterTable*>(scrollArea->widget());
QString path; QString path;
QString filename; QString filename;
if(filterTable->getConfigPath().length() == 0) if (filterTable->getConfigPath().length() == 0)
{ {
path = configDir.absolutePath(); path = configDir.absolutePath();
} }
@@ -583,10 +583,10 @@ void MainWindow::on_actionSaveAs_triggered()
dialog.setAcceptMode(QFileDialog::AcceptSave); dialog.setAcceptMode(QFileDialog::AcceptSave);
dialog.setNameFilter(tr("E-APO configurations (*.txt)")); dialog.setNameFilter(tr("E-APO configurations (*.txt)"));
dialog.setDefaultSuffix(".txt"); dialog.setDefaultSuffix(".txt");
if(filename.length() > 0) if (filename.length() > 0)
dialog.selectFile(filename); dialog.selectFile(filename);
if(dialog.exec() == QDialog::Accepted) if (dialog.exec() == QDialog::Accepted)
{ {
QString savePath = dialog.selectedFiles().first(); QString savePath = dialog.selectedFiles().first();
save(filterTable, savePath); save(filterTable, savePath);
@@ -616,7 +616,7 @@ void MainWindow::recentFileSelected()
void MainWindow::on_actionCut_triggered() void MainWindow::on_actionCut_triggered()
{ {
QScrollArea* scrollArea = qobject_cast<QScrollArea*>(ui->tabWidget->currentWidget()); QScrollArea* scrollArea = qobject_cast<QScrollArea*>(ui->tabWidget->currentWidget());
if(scrollArea == NULL) if (scrollArea == NULL)
return; return;
FilterTable* filterTable = qobject_cast<FilterTable*>(scrollArea->widget()); FilterTable* filterTable = qobject_cast<FilterTable*>(scrollArea->widget());
@@ -626,7 +626,7 @@ void MainWindow::on_actionCut_triggered()
void MainWindow::on_actionCopy_triggered() void MainWindow::on_actionCopy_triggered()
{ {
QScrollArea* scrollArea = qobject_cast<QScrollArea*>(ui->tabWidget->currentWidget()); QScrollArea* scrollArea = qobject_cast<QScrollArea*>(ui->tabWidget->currentWidget());
if(scrollArea == NULL) if (scrollArea == NULL)
return; return;
FilterTable* filterTable = qobject_cast<FilterTable*>(scrollArea->widget()); FilterTable* filterTable = qobject_cast<FilterTable*>(scrollArea->widget());
@@ -636,7 +636,7 @@ void MainWindow::on_actionCopy_triggered()
void MainWindow::on_actionPaste_triggered() void MainWindow::on_actionPaste_triggered()
{ {
QScrollArea* scrollArea = qobject_cast<QScrollArea*>(ui->tabWidget->currentWidget()); QScrollArea* scrollArea = qobject_cast<QScrollArea*>(ui->tabWidget->currentWidget());
if(scrollArea == NULL) if (scrollArea == NULL)
return; return;
FilterTable* filterTable = qobject_cast<FilterTable*>(scrollArea->widget()); FilterTable* filterTable = qobject_cast<FilterTable*>(scrollArea->widget());
@@ -646,7 +646,7 @@ void MainWindow::on_actionPaste_triggered()
void MainWindow::on_actionDelete_triggered() void MainWindow::on_actionDelete_triggered()
{ {
QScrollArea* scrollArea = qobject_cast<QScrollArea*>(ui->tabWidget->currentWidget()); QScrollArea* scrollArea = qobject_cast<QScrollArea*>(ui->tabWidget->currentWidget());
if(scrollArea == NULL) if (scrollArea == NULL)
return; return;
FilterTable* filterTable = qobject_cast<FilterTable*>(scrollArea->widget()); FilterTable* filterTable = qobject_cast<FilterTable*>(scrollArea->widget());
@@ -655,19 +655,19 @@ void MainWindow::on_actionDelete_triggered()
void MainWindow::instantModeEnabled(bool enabled) void MainWindow::instantModeEnabled(bool enabled)
{ {
if(enabled) if (enabled)
{ {
for(int i = 0; i < ui->tabWidget->count(); i++) for (int i = 0; i < ui->tabWidget->count(); i++)
{ {
QScrollArea* scrollArea = qobject_cast<QScrollArea*>(ui->tabWidget->widget(i)); QScrollArea* scrollArea = qobject_cast<QScrollArea*>(ui->tabWidget->widget(i));
FilterTable* filterTable = qobject_cast<FilterTable*>(scrollArea->widget()); FilterTable* filterTable = qobject_cast<FilterTable*>(scrollArea->widget());
if(filterTable->getConfigPath().length() > 0) if (filterTable->getConfigPath().length() > 0)
{ {
save(filterTable, filterTable->getConfigPath()); save(filterTable, filterTable->getConfigPath());
QString tabText = ui->tabWidget->tabText(i); QString tabText = ui->tabWidget->tabText(i);
if(tabText.endsWith('*')) if (tabText.endsWith('*'))
ui->tabWidget->setTabText(i, tabText.left(tabText.length() - 1)); ui->tabWidget->setTabText(i, tabText.left(tabText.length() - 1));
} }
} }
@@ -740,7 +740,7 @@ void MainWindow::languageSelected(bool selected)
{ {
QAction* action = qobject_cast<QAction*>(sender()); QAction* action = qobject_cast<QAction*>(sender());
if(!selected) if (!selected)
{ {
action->setChecked(true); action->setChecked(true);
return; return;
@@ -748,10 +748,10 @@ void MainWindow::languageSelected(bool selected)
QLocale::Language language = (QLocale::Language)action->data().toInt(); QLocale::Language language = (QLocale::Language)action->data().toInt();
if(QMessageBox::question(this, tr("Restart required"), tr("Configuration Editor will be restarted to apply the changed settings. Proceed?")) == QMessageBox::Yes) if (QMessageBox::question(this, tr("Restart required"), tr("Configuration Editor will be restarted to apply the changed settings. Proceed?")) == QMessageBox::Yes)
{ {
QSettings settings(QString::fromWCharArray(EDITOR_REGPATH), QSettings::NativeFormat); QSettings settings(QString::fromWCharArray(EDITOR_REGPATH), QSettings::NativeFormat);
if(language == QLocale::AnyLanguage) if (language == QLocale::AnyLanguage)
{ {
settings.remove("language"); settings.remove("language");
} }
@@ -759,7 +759,7 @@ void MainWindow::languageSelected(bool selected)
{ {
QString name = QLocale(language).name(); QString name = QLocale(language).name();
int index = name.indexOf('_'); int index = name.indexOf('_');
if(index != -1) if (index != -1)
name = name.left(index); name = name.left(index);
settings.setValue("language", name); settings.setValue("language", name);
} }
@@ -775,15 +775,15 @@ void MainWindow::languageSelected(bool selected)
void MainWindow::on_actionResetAllGlobalPreferences_triggered() void MainWindow::on_actionResetAllGlobalPreferences_triggered()
{ {
if(QMessageBox::question(this, tr("Restart required"), tr("Configuration Editor will be restarted to apply the changed settings. Proceed?")) == QMessageBox::Yes) if (QMessageBox::question(this, tr("Restart required"), tr("Configuration Editor will be restarted to apply the changed settings. Proceed?")) == QMessageBox::Yes)
{ {
QSettings settings(QString::fromWCharArray(EDITOR_REGPATH), QSettings::NativeFormat); QSettings settings(QString::fromWCharArray(EDITOR_REGPATH), QSettings::NativeFormat);
for(QString key : settings.childGroups()) for (QString key : settings.childGroups())
{ {
if(key != "file-specific") if (key != "file-specific")
settings.remove(key); settings.remove(key);
} }
for(QString key : settings.childKeys()) for (QString key : settings.childKeys())
settings.remove(key); settings.remove(key);
restart = true; restart = true;
@@ -794,12 +794,12 @@ void MainWindow::on_actionResetAllGlobalPreferences_triggered()
void MainWindow::on_actionResetAllFileSpecificPreferences_triggered() void MainWindow::on_actionResetAllFileSpecificPreferences_triggered()
{ {
if(QMessageBox::question(this, tr("Restart required"), tr("Configuration Editor will be restarted to apply the changed settings. Proceed?")) == QMessageBox::Yes) if (QMessageBox::question(this, tr("Restart required"), tr("Configuration Editor will be restarted to apply the changed settings. Proceed?")) == QMessageBox::Yes)
{ {
QSettings settings(QString::fromWCharArray(EDITOR_PER_FILE_REGPATH), QSettings::NativeFormat); QSettings settings(QString::fromWCharArray(EDITOR_PER_FILE_REGPATH), QSettings::NativeFormat);
for(QString key : settings.childGroups()) for (QString key : settings.childGroups())
settings.remove(key); settings.remove(key);
for(QString key : settings.childKeys()) for (QString key : settings.childKeys())
settings.remove(key); settings.remove(key);
restart = true; restart = true;
@@ -832,15 +832,15 @@ FilterTable* MainWindow::addTab(QString title, QString tooltip)
void MainWindow::getDeviceAndChannelMask(DeviceAPOInfo** selectedDevice, int* channelMask) void MainWindow::getDeviceAndChannelMask(DeviceAPOInfo** selectedDevice, int* channelMask)
{ {
*selectedDevice = deviceComboBox->currentData().value<DeviceAPOInfo*>(); *selectedDevice = deviceComboBox->currentData().value<DeviceAPOInfo*>();
if(*selectedDevice == NULL) if (*selectedDevice == NULL)
*selectedDevice = defaultOutputDevice; *selectedDevice = defaultOutputDevice;
*channelMask = channelConfigurationComboBox->currentData().toInt(); *channelMask = channelConfigurationComboBox->currentData().toInt();
if(*channelMask == 0 && selectedDevice != NULL) if (*channelMask == 0 && selectedDevice != NULL)
{ {
*channelMask = (*selectedDevice)->channelMask; *channelMask = (*selectedDevice)->channelMask;
if(*channelMask == 0) if (*channelMask == 0)
*channelMask = ChannelHelper::getDefaultChannelMask((*selectedDevice)->channelCount); *channelMask = ChannelHelper::getDefaultChannelMask((*selectedDevice)->channelCount);
} }
} }
@@ -848,7 +848,7 @@ void MainWindow::getDeviceAndChannelMask(DeviceAPOInfo** selectedDevice, int* ch
bool MainWindow::askForClose(int tabIndex) bool MainWindow::askForClose(int tabIndex)
{ {
bool discarded = false; bool discarded = false;
if(ui->tabWidget->tabText(tabIndex).endsWith('*')) if (ui->tabWidget->tabText(tabIndex).endsWith('*'))
{ {
ui->tabWidget->setCurrentIndex(tabIndex); ui->tabWidget->setCurrentIndex(tabIndex);
QString configPath = ui->tabWidget->tabToolTip(tabIndex); QString configPath = ui->tabWidget->tabToolTip(tabIndex);
@@ -863,11 +863,11 @@ bool MainWindow::askForClose(int tabIndex)
messageBox.setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint); messageBox.setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint);
int result = messageBox.exec(); int result = messageBox.exec();
switch(result) switch (result)
{ {
case QMessageBox::Save: case QMessageBox::Save:
ui->actionSave->trigger(); ui->actionSave->trigger();
if(ui->tabWidget->tabText(tabIndex).endsWith('*')) if (ui->tabWidget->tabText(tabIndex).endsWith('*'))
// saving was canceled // saving was canceled
return false; return false;
break; break;
@@ -879,10 +879,10 @@ bool MainWindow::askForClose(int tabIndex)
} }
} }
if(!discarded && !noSaveFilePreferences) if (!discarded && !noSaveFilePreferences)
{ {
QScrollArea* scrollArea = qobject_cast<QScrollArea*>(ui->tabWidget->widget(tabIndex)); QScrollArea* scrollArea = qobject_cast<QScrollArea*>(ui->tabWidget->widget(tabIndex));
if(scrollArea != NULL) if (scrollArea != NULL)
{ {
FilterTable* filterTable = qobject_cast<FilterTable*>(scrollArea->widget()); FilterTable* filterTable = qobject_cast<FilterTable*>(scrollArea->widget());
filterTable->savePreferences(); filterTable->savePreferences();
@@ -899,23 +899,23 @@ void MainWindow::startAnalysis()
int channelMask; int channelMask;
getDeviceAndChannelMask(&selectedDevice, &channelMask); getDeviceAndChannelMask(&selectedDevice, &channelMask);
if(selectedDevice != NULL) if (selectedDevice != NULL)
{ {
QString configPath; QString configPath;
if(ui->startFromComboBox->currentIndex() == 1) if (ui->startFromComboBox->currentIndex() == 1)
{ {
QScrollArea* scrollArea = qobject_cast<QScrollArea*>(ui->tabWidget->currentWidget()); QScrollArea* scrollArea = qobject_cast<QScrollArea*>(ui->tabWidget->currentWidget());
if(scrollArea != NULL) if (scrollArea != NULL)
{ {
FilterTable* filterTable = qobject_cast<FilterTable*>(scrollArea->widget()); FilterTable* filterTable = qobject_cast<FilterTable*>(scrollArea->widget());
if(filterTable->getConfigPath().length() > 0) if (filterTable->getConfigPath().length() > 0)
configPath = filterTable->getConfigPath(); configPath = filterTable->getConfigPath();
} }
} }
if(configPath.isEmpty()) if (configPath.isEmpty())
configPath = configDir.absoluteFilePath("config.txt"); configPath = configDir.absoluteFilePath("config.txt");
configPath = QDir::toNativeSeparators(configPath); configPath = QDir::toNativeSeparators(configPath);
@@ -927,10 +927,10 @@ void MainWindow::loadPreferences()
{ {
QSettings settings(QString::fromWCharArray(EDITOR_REGPATH), QSettings::NativeFormat); QSettings settings(QString::fromWCharArray(EDITOR_REGPATH), QSettings::NativeFormat);
QVariant geometryValue = settings.value("geometry"); QVariant geometryValue = settings.value("geometry");
if(geometryValue.isValid()) if (geometryValue.isValid())
restoreGeometry(geometryValue.toByteArray()); restoreGeometry(geometryValue.toByteArray());
QVariant stateValue = settings.value("windowState"); QVariant stateValue = settings.value("windowState");
if(stateValue.isValid()) if (stateValue.isValid())
restoreState(stateValue.toByteArray()); restoreState(stateValue.toByteArray());
instantModeCheckBox->setChecked(settings.value("instantMode", true).toBool()); instantModeCheckBox->setChecked(settings.value("instantMode", true).toBool());
@@ -939,7 +939,7 @@ void MainWindow::loadPreferences()
ui->resolutionSpinBox->setValue(settings.value("analysis/resolution", 65536).toInt()); ui->resolutionSpinBox->setValue(settings.value("analysis/resolution", 65536).toInt());
double zoomX = settings.value("analysis/zoomX", 1.0).toDouble(); double zoomX = settings.value("analysis/zoomX", 1.0).toDouble();
double zoomY = settings.value("analysis/zoomY", 1.0).toDouble(); double zoomY = settings.value("analysis/zoomY", 1.0).toDouble();
if(zoomX != 1.0 || zoomY != 1.0) if (zoomX != 1.0 || zoomY != 1.0)
analysisPlotScene->setZoom(zoomX, zoomY); analysisPlotScene->setZoom(zoomX, zoomY);
int scrollX = settings.value("analysis/scrollX", round(analysisPlotScene->hzToX(20))).toInt(); int scrollX = settings.value("analysis/scrollX", round(analysisPlotScene->hzToX(20))).toInt();
int scrollY = settings.value("analysis/scrollY", round(analysisPlotScene->dbToY(22))).toInt(); int scrollY = settings.value("analysis/scrollY", round(analysisPlotScene->dbToY(22))).toInt();
@@ -947,13 +947,13 @@ void MainWindow::loadPreferences()
QVariant openFilesValue = settings.value("openFiles"); QVariant openFilesValue = settings.value("openFiles");
int tabIndex = settings.value("tabIndex").toInt(); int tabIndex = settings.value("tabIndex").toInt();
if(openFilesValue.isValid()) if (openFilesValue.isValid())
{ {
QStringList fileList = openFilesValue.toStringList(); QStringList fileList = openFilesValue.toStringList();
for(int i = 0; i < fileList.size(); i++) for (int i = 0; i < fileList.size(); i++)
{ {
load(fileList[i]); load(fileList[i]);
if(i == tabIndex) if (i == tabIndex)
tabIndex = ui->tabWidget->currentIndex(); tabIndex = ui->tabWidget->currentIndex();
} }
} }
@@ -963,18 +963,18 @@ void MainWindow::loadPreferences()
QVariant languageValue = settings.value("language"); QVariant languageValue = settings.value("language");
QLocale::Language language; QLocale::Language language;
if(languageValue.isValid()) if (languageValue.isValid())
language = QLocale(languageValue.toString()).language(); language = QLocale(languageValue.toString()).language();
else else
language = QLocale::AnyLanguage; language = QLocale::AnyLanguage;
for(QAction* action : ui->menuLanguage->actions()) for (QAction* action : ui->menuLanguage->actions())
action->setChecked(action->data().toInt() == language); action->setChecked(action->data().toInt() == language);
} }
void MainWindow::savePreferences() void MainWindow::savePreferences()
{ {
if(noSavePreferences) if (noSavePreferences)
return; return;
QSettings settings(QString::fromWCharArray(EDITOR_REGPATH), QSettings::NativeFormat); QSettings settings(QString::fromWCharArray(EDITOR_REGPATH), QSettings::NativeFormat);
@@ -995,13 +995,13 @@ void MainWindow::savePreferences()
settings.setValue("analysis/scrollY", value); settings.setValue("analysis/scrollY", value);
QStringList fileList; QStringList fileList;
for(int i = 0; i < ui->tabWidget->count(); i++) for (int i = 0; i < ui->tabWidget->count(); i++)
{ {
QScrollArea* scrollArea = qobject_cast<QScrollArea*>(ui->tabWidget->widget(i)); QScrollArea* scrollArea = qobject_cast<QScrollArea*>(ui->tabWidget->widget(i));
if(scrollArea == NULL) if (scrollArea == NULL)
continue; continue;
FilterTable* filterTable = qobject_cast<FilterTable*>(scrollArea->widget()); FilterTable* filterTable = qobject_cast<FilterTable*>(scrollArea->widget());
if(filterTable->getConfigPath().length() > 0) if (filterTable->getConfigPath().length() > 0)
{ {
fileList.append(filterTable->getConfigPath()); fileList.append(filterTable->getConfigPath());
} }
@@ -1017,17 +1017,17 @@ void MainWindow::updateRecentFiles()
{ {
QList<QAction*> actions = ui->menuFile->actions(); QList<QAction*> actions = ui->menuFile->actions();
int separatorsFound = 0; int separatorsFound = 0;
for(int i = actions.size() - 1; i >= 0; i--) for (int i = actions.size() - 1; i >= 0; i--)
{ {
QAction* action = actions[i]; QAction* action = actions[i];
if(action->isSeparator()) if (action->isSeparator())
{ {
separatorsFound++; separatorsFound++;
if(separatorsFound == 1) if (separatorsFound == 1)
{ {
QList<QAction*> newActions; QList<QAction*> newActions;
for(QString recentFile : recentFiles) for (QString recentFile : recentFiles)
{ {
QAction* newAction = new QAction(recentFile, ui->menuFile); QAction* newAction = new QAction(recentFile, ui->menuFile);
connect(newAction, SIGNAL(triggered(bool)), this, SLOT(recentFileSelected())); connect(newAction, SIGNAL(triggered(bool)), this, SLOT(recentFileSelected()));
@@ -1040,7 +1040,7 @@ void MainWindow::updateRecentFiles()
break; break;
} }
} }
else if(separatorsFound >= 1) else if (separatorsFound >= 1)
{ {
ui->menuFile->removeAction(action); ui->menuFile->removeAction(action);
} }
+2 -2
View File
@@ -44,7 +44,7 @@ class MainWindow : public QMainWindow
Q_OBJECT Q_OBJECT
public: public:
explicit MainWindow(QDir configDir, QWidget *parent = 0); explicit MainWindow(QDir configDir, QWidget* parent = 0);
~MainWindow(); ~MainWindow();
void doChecks(); void doChecks();
void runConfigurator(); void runConfigurator();
@@ -98,7 +98,7 @@ private:
void savePreferences(); void savePreferences();
void updateRecentFiles(); void updateRecentFiles();
Ui::MainWindow *ui; Ui::MainWindow* ui;
QDir configDir; QDir configDir;
QCheckBox* instantModeCheckBox; QCheckBox* instantModeCheckBox;
+42 -42
View File
@@ -30,8 +30,8 @@ static const double dialQSteps = 1000;
static const double dialQMin = 0.3333; static const double dialQMin = 0.3333;
static const double dialQMax = 33.3333; static const double dialQMax = 33.3333;
BiQuadFilterGUI::BiQuadFilterGUI(BiQuadFilter* filter) : BiQuadFilterGUI::BiQuadFilterGUI(BiQuadFilter* filter)
ui(new Ui::BiQuadFilterGUI) : ui(new Ui::BiQuadFilterGUI)
{ {
ui->setupUi(this); ui->setupUi(this);
@@ -46,22 +46,22 @@ BiQuadFilterGUI::BiQuadFilterGUI(BiQuadFilter* filter) :
BiQuad::Type type = filter->getType(); BiQuad::Type type = filter->getType();
int typeIndex = ui->typeComboBox->findData(type); int typeIndex = ui->typeComboBox->findData(type);
if(typeIndex != -1) if (typeIndex != -1)
ui->typeComboBox->setCurrentIndex(typeIndex); ui->typeComboBox->setCurrentIndex(typeIndex);
if(type == BiQuad::LOW_SHELF || type == BiQuad::HIGH_SHELF ) if (type == BiQuad::LOW_SHELF || type == BiQuad::HIGH_SHELF)
ui->freqComboBox->setCurrentIndex(filter->getIsCornerFreq() ? 1 : 0); ui->freqComboBox->setCurrentIndex(filter->getIsCornerFreq() ? 1 : 0);
ui->freqSpinBox->setValue(filter->getFreq()); ui->freqSpinBox->setValue(filter->getFreq());
if(type == BiQuad::PEAKING ) if (type == BiQuad::PEAKING)
ui->qComboBox->setCurrentIndex(filter->getIsBandwidth() ? 1 : 0); ui->qComboBox->setCurrentIndex(filter->getIsBandwidth() ? 1 : 0);
else if(type == BiQuad::LOW_PASS || type == BiQuad::HIGH_PASS || type == BiQuad::BAND_PASS) else if (type == BiQuad::LOW_PASS || type == BiQuad::HIGH_PASS || type == BiQuad::BAND_PASS)
ui->qComboBox->setCurrentIndex(filter->getBandwidthOrQOrS() == M_SQRT1_2 ? 0 : 1); ui->qComboBox->setCurrentIndex(filter->getBandwidthOrQOrS() == M_SQRT1_2 ? 0 : 1);
else if((type == BiQuad::LOW_SHELF || type == BiQuad::HIGH_SHELF) && !filter->getIsCornerFreq()) else if ((type == BiQuad::LOW_SHELF || type == BiQuad::HIGH_SHELF) && !filter->getIsCornerFreq())
ui->qComboBox->setCurrentIndex(filter->getBandwidthOrQOrS() == 0.9 ? 0 : 1); ui->qComboBox->setCurrentIndex(filter->getBandwidthOrQOrS() == 0.9 ? 0 : 1);
if((type == BiQuad::LOW_SHELF || type == BiQuad::HIGH_SHELF) && filter->getBandwidthOrQOrS() != 0.9) if ((type == BiQuad::LOW_SHELF || type == BiQuad::HIGH_SHELF) && filter->getBandwidthOrQOrS() != 0.9)
ui->qSpinBox->setValue(filter->getBandwidthOrQOrS() * 12.0); ui->qSpinBox->setValue(filter->getBandwidthOrQOrS() * 12.0);
else else
ui->qSpinBox->setValue(filter->getBandwidthOrQOrS()); ui->qSpinBox->setValue(filter->getBandwidthOrQOrS());
@@ -82,19 +82,19 @@ void BiQuadFilterGUI::store(QString& command, QString& parameters)
command = "Filter"; command = "Filter";
parameters = "ON "; parameters = "ON ";
switch(type) switch (type)
{ {
case BiQuad::PEAKING: case BiQuad::PEAKING:
parameters += "PK"; parameters += "PK";
break; break;
case BiQuad::LOW_PASS: case BiQuad::LOW_PASS:
if(mode == 'F') if (mode == 'F')
parameters += "LP"; parameters += "LP";
else else
parameters += "LPQ"; parameters += "LPQ";
break; break;
case BiQuad::HIGH_PASS: case BiQuad::HIGH_PASS:
if(mode == 'F') if (mode == 'F')
parameters += "HP"; parameters += "HP";
else else
parameters += "HPQ"; parameters += "HPQ";
@@ -103,13 +103,13 @@ void BiQuadFilterGUI::store(QString& command, QString& parameters)
parameters += "BP"; parameters += "BP";
break; break;
case BiQuad::LOW_SHELF: case BiQuad::LOW_SHELF:
if(freqMode == 'E' && mode == 'S') if (freqMode == 'E' && mode == 'S')
parameters += "LSC"; parameters += "LSC";
else else
parameters += "LS"; parameters += "LS";
break; break;
case BiQuad::HIGH_SHELF: case BiQuad::HIGH_SHELF:
if(freqMode == 'E' && mode == 'S') if (freqMode == 'E' && mode == 'S')
parameters += "HSC"; parameters += "HSC";
else else
parameters += "HS"; parameters += "HS";
@@ -122,18 +122,18 @@ void BiQuadFilterGUI::store(QString& command, QString& parameters)
break; break;
} }
if((type == BiQuad::LOW_SHELF || type == BiQuad::HIGH_SHELF) && mode == 'S') if ((type == BiQuad::LOW_SHELF || type == BiQuad::HIGH_SHELF) && mode == 'S')
parameters += QString(" %1 dB").arg(ui->qSpinBox->value()); parameters += QString(" %1 dB").arg(ui->qSpinBox->value());
parameters += QString(" Fc %1 Hz").arg(ui->freqSpinBox->value()); parameters += QString(" Fc %1 Hz").arg(ui->freqSpinBox->value());
if(type == BiQuad::PEAKING || type == BiQuad::LOW_SHELF if (type == BiQuad::PEAKING || type == BiQuad::LOW_SHELF
|| type == BiQuad::HIGH_SHELF) || type == BiQuad::HIGH_SHELF)
parameters += QString(" Gain %1 dB").arg(ui->gainSpinBox->value()); parameters += QString(" Gain %1 dB").arg(ui->gainSpinBox->value());
if(mode == 'Q') if (mode == 'Q')
parameters += QString(" Q %1").arg(ui->qSpinBox->value()); parameters += QString(" Q %1").arg(ui->qSpinBox->value());
else if(mode == 'B') else if (mode == 'B')
parameters += QString(" BW Oct %1").arg(ui->qSpinBox->value()); parameters += QString(" BW Oct %1").arg(ui->qSpinBox->value());
} }
@@ -187,13 +187,13 @@ void BiQuadFilterGUI::on_typeComboBox_currentIndexChanged(int index)
QChar freqMode = ui->freqComboBox->currentData().toChar(); QChar freqMode = ui->freqComboBox->currentData().toChar();
double freqValue = ui->freqSpinBox->value(); double freqValue = ui->freqSpinBox->value();
ui->freqComboBox->clear(); ui->freqComboBox->clear();
if(type == BiQuad::PEAKING || type == BiQuad::BAND_PASS || type == BiQuad::LOW_SHELF || type == BiQuad::HIGH_SHELF || type == BiQuad::NOTCH || type == BiQuad::ALL_PASS ) if (type == BiQuad::PEAKING || type == BiQuad::BAND_PASS || type == BiQuad::LOW_SHELF || type == BiQuad::HIGH_SHELF || type == BiQuad::NOTCH || type == BiQuad::ALL_PASS)
ui->freqComboBox->addItem(tr("Center frequency"), 'E'); ui->freqComboBox->addItem(tr("Center frequency"), 'E');
if(type == BiQuad::LOW_PASS || type == BiQuad::HIGH_PASS || type == BiQuad::LOW_SHELF || type == BiQuad::HIGH_SHELF) if (type == BiQuad::LOW_PASS || type == BiQuad::HIGH_PASS || type == BiQuad::LOW_SHELF || type == BiQuad::HIGH_SHELF)
ui->freqComboBox->addItem(tr("Corner frequency"), 'O'); ui->freqComboBox->addItem(tr("Corner frequency"), 'O');
ui->freqComboBox->setEnabled(ui->freqComboBox->count() > 1); ui->freqComboBox->setEnabled(ui->freqComboBox->count() > 1);
int freqIndex = ui->freqComboBox->findData(freqMode); int freqIndex = ui->freqComboBox->findData(freqMode);
if(freqIndex != -1 && sameTypeCategory) if (freqIndex != -1 && sameTypeCategory)
{ {
ui->freqComboBox->setCurrentIndex(freqIndex); ui->freqComboBox->setCurrentIndex(freqIndex);
ui->freqSpinBox->setValue(freqValue); ui->freqSpinBox->setValue(freqValue);
@@ -206,24 +206,24 @@ void BiQuadFilterGUI::on_typeComboBox_currentIndexChanged(int index)
QChar mode = ui->qComboBox->currentData().toChar(); QChar mode = ui->qComboBox->currentData().toChar();
double qValue = ui->qSpinBox->value(); double qValue = ui->qSpinBox->value();
ui->qComboBox->clear(); ui->qComboBox->clear();
if(type == BiQuad::LOW_PASS || type == BiQuad::HIGH_PASS || type == BiQuad::BAND_PASS || type == BiQuad::NOTCH ) if (type == BiQuad::LOW_PASS || type == BiQuad::HIGH_PASS || type == BiQuad::BAND_PASS || type == BiQuad::NOTCH)
ui->qComboBox->addItem(tr("Fixed Q"), 'F'); ui->qComboBox->addItem(tr("Fixed Q"), 'F');
else if((type == BiQuad::LOW_SHELF || type == BiQuad::HIGH_SHELF) && freqMode == 'E') else if ((type == BiQuad::LOW_SHELF || type == BiQuad::HIGH_SHELF) && freqMode == 'E')
ui->qComboBox->addItem(tr("Fixed S"), 'F'); ui->qComboBox->addItem(tr("Fixed S"), 'F');
if(type == BiQuad::PEAKING || type == BiQuad::LOW_PASS || type == BiQuad::HIGH_PASS || type == BiQuad::ALL_PASS || type == BiQuad::BAND_PASS || type == BiQuad::NOTCH) if (type == BiQuad::PEAKING || type == BiQuad::LOW_PASS || type == BiQuad::HIGH_PASS || type == BiQuad::ALL_PASS || type == BiQuad::BAND_PASS || type == BiQuad::NOTCH)
ui->qComboBox->addItem(tr("Q factor"), 'Q'); ui->qComboBox->addItem(tr("Q factor"), 'Q');
if(type == BiQuad::PEAKING) if (type == BiQuad::PEAKING)
ui->qComboBox->addItem(tr("Bandwidth"), 'B'); ui->qComboBox->addItem(tr("Bandwidth"), 'B');
if(type == BiQuad::LOW_SHELF || type == BiQuad::HIGH_SHELF) if (type == BiQuad::LOW_SHELF || type == BiQuad::HIGH_SHELF)
ui->qComboBox->addItem(tr("Slope"), 'S'); ui->qComboBox->addItem(tr("Slope"), 'S');
ui->qComboBox->setEnabled(ui->qComboBox->count() > 1); ui->qComboBox->setEnabled(ui->qComboBox->count() > 1);
int qIndex = ui->qComboBox->findData(mode); int qIndex = ui->qComboBox->findData(mode);
if(qIndex != -1 && sameTypeCategory) if (qIndex != -1 && sameTypeCategory)
{ {
ui->qComboBox->setCurrentIndex(qIndex); ui->qComboBox->setCurrentIndex(qIndex);
ui->qSpinBox->setValue(qValue); ui->qSpinBox->setValue(qValue);
} }
else if(type == BiQuad::PEAKING || type == BiQuad::ALL_PASS) else if (type == BiQuad::PEAKING || type == BiQuad::ALL_PASS)
{ {
ui->qSpinBox->setValue(10); ui->qSpinBox->setValue(10);
} }
@@ -243,17 +243,17 @@ void BiQuadFilterGUI::on_freqComboBox_currentIndexChanged(int index)
{ {
BiQuad::Type type = (BiQuad::Type)ui->typeComboBox->currentData().toInt(); BiQuad::Type type = (BiQuad::Type)ui->typeComboBox->currentData().toInt();
QChar freqMode = ui->freqComboBox->itemData(index).toChar(); QChar freqMode = ui->freqComboBox->itemData(index).toChar();
if(type == BiQuad::LOW_SHELF || type == BiQuad::HIGH_SHELF) if (type == BiQuad::LOW_SHELF || type == BiQuad::HIGH_SHELF)
{ {
QChar mode = ui->qComboBox->currentData().toChar(); QChar mode = ui->qComboBox->currentData().toChar();
double qValue = ui->qSpinBox->value(); double qValue = ui->qSpinBox->value();
ui->qComboBox->clear(); ui->qComboBox->clear();
if(freqMode == 'E') if (freqMode == 'E')
ui->qComboBox->addItem(tr("Fixed S"), 'F'); ui->qComboBox->addItem(tr("Fixed S"), 'F');
ui->qComboBox->addItem(tr("Slope"), 'S'); ui->qComboBox->addItem(tr("Slope"), 'S');
ui->qComboBox->setEnabled(ui->qComboBox->count() > 1); ui->qComboBox->setEnabled(ui->qComboBox->count() > 1);
int qIndex = ui->qComboBox->findData(mode); int qIndex = ui->qComboBox->findData(mode);
if(qIndex != -1) if (qIndex != -1)
{ {
ui->qComboBox->setCurrentIndex(qIndex); ui->qComboBox->setCurrentIndex(qIndex);
ui->qSpinBox->setValue(qValue); ui->qSpinBox->setValue(qValue);
@@ -261,7 +261,7 @@ void BiQuadFilterGUI::on_freqComboBox_currentIndexChanged(int index)
double centerFreqFactor = pow(10.0, abs(ui->gainSpinBox->value()) / 80.0 / (ui->qSpinBox->value() / 12.0)); double centerFreqFactor = pow(10.0, abs(ui->gainSpinBox->value()) / 80.0 / (ui->qSpinBox->value() / 12.0));
double freq = ui->freqSpinBox->value(); double freq = ui->freqSpinBox->value();
if((freqMode == 'E') == (type == BiQuad::LOW_SHELF) ) if ((freqMode == 'E') == (type == BiQuad::LOW_SHELF))
freq *= centerFreqFactor; freq *= centerFreqFactor;
else else
freq /= centerFreqFactor; freq /= centerFreqFactor;
@@ -272,27 +272,27 @@ void BiQuadFilterGUI::on_freqComboBox_currentIndexChanged(int index)
void BiQuadFilterGUI::on_qComboBox_currentIndexChanged(int index) void BiQuadFilterGUI::on_qComboBox_currentIndexChanged(int index)
{ {
QChar mode = ui->qComboBox->currentData().toChar(); QChar mode = ui->qComboBox->currentData().toChar();
if(mode == 'F' || mode == 'Q') if (mode == 'F' || mode == 'Q')
ui->qSpinBox->setSuffix(""); ui->qSpinBox->setSuffix("");
else if(mode == 'B') else if (mode == 'B')
ui->qSpinBox->setSuffix(" Oct"); ui->qSpinBox->setSuffix(" Oct");
else if(mode == 'S') else if (mode == 'S')
ui->qSpinBox->setSuffix(" dB/Oct"); ui->qSpinBox->setSuffix(" dB/Oct");
ui->qDial->setEnabled(mode != 'F'); ui->qDial->setEnabled(mode != 'F');
ui->qSpinBox->setEnabled(mode != 'F'); ui->qSpinBox->setEnabled(mode != 'F');
if(mode == 'F') if (mode == 'F')
{ {
BiQuad::Type type = (BiQuad::Type)ui->typeComboBox->currentData().toInt(); BiQuad::Type type = (BiQuad::Type)ui->typeComboBox->currentData().toInt();
if(type == BiQuad::LOW_PASS || type == BiQuad::HIGH_PASS || type == BiQuad::BAND_PASS) if (type == BiQuad::LOW_PASS || type == BiQuad::HIGH_PASS || type == BiQuad::BAND_PASS)
ui->qSpinBox->setValue(M_SQRT1_2); ui->qSpinBox->setValue(M_SQRT1_2);
else if(type == BiQuad::LOW_SHELF || type == BiQuad::HIGH_SHELF) else if (type == BiQuad::LOW_SHELF || type == BiQuad::HIGH_SHELF)
ui->qSpinBox->setValue(0.9); ui->qSpinBox->setValue(0.9);
else if(type == BiQuad::NOTCH) else if (type == BiQuad::NOTCH)
ui->qSpinBox->setValue(30); ui->qSpinBox->setValue(30);
} }
else if(qIsBw && mode == 'Q') else if (qIsBw && mode == 'Q')
{ {
double n = ui->qSpinBox->value(); double n = ui->qSpinBox->value();
double p2n = pow(2.0, n); double p2n = pow(2.0, n);
@@ -300,14 +300,14 @@ void BiQuadFilterGUI::on_qComboBox_currentIndexChanged(int index)
ui->qSpinBox->setValue(q); ui->qSpinBox->setValue(q);
qIsBw = false; qIsBw = false;
} }
else if(!qIsBw && mode == 'B') else if (!qIsBw && mode == 'B')
{ {
double q = ui->qSpinBox->value(); double q = ui->qSpinBox->value();
double n = 2.0 / M_LN2 * asinh(1.0 / (2.0 * q)); double n = 2.0 / M_LN2 * asinh(1.0 / (2.0 * q));
ui->qSpinBox->setValue(n); ui->qSpinBox->setValue(n);
qIsBw = true; qIsBw = true;
} }
else if(mode == 'S') else if (mode == 'S')
{ {
ui->qSpinBox->setValue(12.0); ui->qSpinBox->setValue(12.0);
} }
@@ -317,7 +317,7 @@ void BiQuadFilterGUI::on_qComboBox_currentIndexChanged(int index)
int BiQuadFilterGUI::getTypeCategory(BiQuad::Type type) int BiQuadFilterGUI::getTypeCategory(BiQuad::Type type)
{ {
switch(type) switch (type)
{ {
case BiQuad::PEAKING: case BiQuad::PEAKING:
return 0; return 0;
+1 -2
View File
@@ -22,8 +22,7 @@
#include "Editor/IFilterGUI.h" #include "Editor/IFilterGUI.h"
#include <filters/BiQuadFilter.h> #include <filters/BiQuadFilter.h>
namespace Ui namespace Ui {
{
class BiQuadFilterGUI; class BiQuadFilterGUI;
} }
+3 -3
View File
@@ -43,17 +43,17 @@ IFilterGUI* BiQuadFilterGUIFactory::createFilterGUI(QString& command, QString& p
{ {
BiQuadFilterGUI* result = NULL; BiQuadFilterGUI* result = NULL;
if(command.startsWith("Filter")) if (command.startsWith("Filter"))
{ {
BiQuadFilterFactory factory; BiQuadFilterFactory factory;
std::vector<IFilter*> filters = factory.createFilter(L"", command.toStdWString(), parameters.toStdWString()); std::vector<IFilter*> filters = factory.createFilter(L"", command.toStdWString(), parameters.toStdWString());
if(!filters.empty()) if (!filters.empty())
{ {
BiQuadFilter* filter = (BiQuadFilter*)filters[0]; BiQuadFilter* filter = (BiQuadFilter*)filters[0];
result = new BiQuadFilterGUI(filter); result = new BiQuadFilterGUI(filter);
} }
for(IFilter* f : filters) for (IFilter* f : filters)
{ {
f->~IFilter(); f->~IFilter();
MemoryHelper::free(f); MemoryHelper::free(f);
+5 -5
View File
@@ -23,8 +23,8 @@
using namespace std; using namespace std;
ChannelFilterGUI::ChannelFilterGUI(const QString& parameters, int selectedChannelMask) : ChannelFilterGUI::ChannelFilterGUI(const QString& parameters, int selectedChannelMask)
ui(new Ui::ChannelFilterGUI) : ui(new Ui::ChannelFilterGUI)
{ {
ui->setupUi(this); ui->setupUi(this);
@@ -38,8 +38,8 @@ ChannelFilterGUI::ChannelFilterGUI(const QString& parameters, int selectedChanne
selectedChannels.clear(); selectedChannels.clear();
QStringList words = parameters.trimmed().split(' ', QString::SkipEmptyParts); QStringList words = parameters.trimmed().split(' ', QString::SkipEmptyParts);
for(QString word : words) for (QString word : words)
if(word.length() > 0) if (word.length() > 0)
selectedChannels.append(word.toUpper()); selectedChannels.append(word.toUpper());
} }
@@ -66,7 +66,7 @@ void ChannelFilterGUI::store(QString& command, QString& parameters)
void ChannelFilterGUI::on_pushButton_clicked() void ChannelFilterGUI::on_pushButton_clicked()
{ {
ChannelFilterGUIDialog dialog(this, selectedChannels, selectedChannelMask, channelNames); ChannelFilterGUIDialog dialog(this, selectedChannels, selectedChannelMask, channelNames);
if(dialog.exec() == QDialog::Accepted) if (dialog.exec() == QDialog::Accepted)
{ {
selectedChannels = dialog.getSelectedChannels(); selectedChannels = dialog.getSelectedChannels();
refreshGui(); refreshGui();
+1 -1
View File
@@ -43,7 +43,7 @@ private slots:
private: private:
void refreshGui(); void refreshGui();
Ui::ChannelFilterGUI *ui; Ui::ChannelFilterGUI* ui;
QStringList selectedChannels; QStringList selectedChannels;
int selectedChannelMask; int selectedChannelMask;
std::vector<std::wstring> channelNames; std::vector<std::wstring> channelNames;
+3 -3
View File
@@ -22,8 +22,8 @@
#include "ChannelFilterGUIScene.h" #include "ChannelFilterGUIScene.h"
#include "ChannelFilterGUIChannelItem.h" #include "ChannelFilterGUIChannelItem.h"
ChannelFilterGUIChannelItem::ChannelFilterGUIChannelItem(const QString& name) : ChannelFilterGUIChannelItem::ChannelFilterGUIChannelItem(const QString& name)
ChannelGraphItem(name) : ChannelGraphItem(name)
{ {
setFlag(ItemIsSelectable); setFlag(ItemIsSelectable);
} }
@@ -32,7 +32,7 @@ void ChannelFilterGUIChannelItem::paint(QPainter* painter, const QStyleOptionGra
{ {
QColor color; QColor color;
if(isSelected()) if (isSelected())
{ {
color = QColor(176, 229, 255); color = QColor(176, 229, 255);
} }
+1 -1
View File
@@ -26,7 +26,7 @@ class ChannelFilterGUIChannelItem : public ChannelGraphItem
public: public:
ChannelFilterGUIChannelItem(const QString& name); ChannelFilterGUIChannelItem(const QString& name);
enum { Type = UserType + 2 }; enum {Type = UserType + 2};
virtual int type() const virtual int type() const
{ {
return Type; return Type;
+16 -16
View File
@@ -30,8 +30,8 @@
using namespace std; using namespace std;
ChannelFilterGUIDialog::ChannelFilterGUIDialog(QWidget *parent, QStringList selectedChannels, int selectedChannelMask, const vector<wstring>& channelNames) : ChannelFilterGUIDialog::ChannelFilterGUIDialog(QWidget* parent, QStringList selectedChannels, int selectedChannelMask, const vector<wstring>& channelNames)
QDialog(parent), : QDialog(parent),
ui(new Ui::ChannelFilterGUIDialog) ui(new Ui::ChannelFilterGUIDialog)
{ {
ui->setupUi(this); ui->setupUi(this);
@@ -68,26 +68,26 @@ ChannelFilterGUIDialog::ChannelFilterGUIDialog(QWidget *parent, QStringList sele
vector<wstring> remainingChannelNames = channelNames; vector<wstring> remainingChannelNames = channelNames;
QStringList remainingSelectedChannels = selectedChannels; QStringList remainingSelectedChannels = selectedChannels;
if(selectedChannels.contains("ALL")) if (selectedChannels.contains("ALL"))
{ {
ui->allChannelsCheckBox->setChecked(true); ui->allChannelsCheckBox->setChecked(true);
remainingSelectedChannels.clear(); remainingSelectedChannels.clear();
} }
int channelIndex = 0; int channelIndex = 0;
for(QCheckBox* checkBox : checkBoxes) for (QCheckBox* checkBox : checkBoxes)
{ {
int channelPos = checkBox->property(PROPERTY_POSITION).toInt(); int channelPos = checkBox->property(PROPERTY_POSITION).toInt();
QString channelName = checkBox->property(PROPERTY_NAME).toString(); QString channelName = checkBox->property(PROPERTY_NAME).toString();
bool exists = selectedChannelMask & channelPos; bool exists = selectedChannelMask & channelPos;
checkBox->setVisible(exists); checkBox->setVisible(exists);
if(exists) if (exists)
{ {
channelIndex++; channelIndex++;
bool checked = false; bool checked = false;
remainingChannelNames.erase(remove(remainingChannelNames.begin(), remainingChannelNames.end(), channelName.toStdWString()), remainingChannelNames.end()); remainingChannelNames.erase(remove(remainingChannelNames.begin(), remainingChannelNames.end(), channelName.toStdWString()), remainingChannelNames.end());
if(remainingSelectedChannels.removeOne(channelName)) if (remainingSelectedChannels.removeOne(channelName))
checked = true; checked = true;
if(remainingSelectedChannels.removeOne(QString(channelIndex))) if (remainingSelectedChannels.removeOne(QString(channelIndex)))
checked = true; checked = true;
checkBox->setChecked(checked); checkBox->setChecked(checked);
} }
@@ -98,18 +98,18 @@ ChannelFilterGUIDialog::ChannelFilterGUIDialog(QWidget *parent, QStringList sele
} }
ui->listWidget->clear(); ui->listWidget->clear();
for(wstring channelName : remainingChannelNames) for (wstring channelName : remainingChannelNames)
{ {
QListWidgetItem* item = new QListWidgetItem(QString::fromStdWString(channelName)); QListWidgetItem* item = new QListWidgetItem(QString::fromStdWString(channelName));
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable); item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable);
if(remainingSelectedChannels.removeOne(QString::fromStdWString(channelName))) if (remainingSelectedChannels.removeOne(QString::fromStdWString(channelName)))
item->setCheckState(Qt::Checked); item->setCheckState(Qt::Checked);
else else
item->setCheckState(Qt::Unchecked); item->setCheckState(Qt::Unchecked);
ui->listWidget->addItem(item); ui->listWidget->addItem(item);
} }
for(QString c : remainingSelectedChannels) for (QString c : remainingSelectedChannels)
{ {
QListWidgetItem* item = new QListWidgetItem(c); QListWidgetItem* item = new QListWidgetItem(c);
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable); item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable);
@@ -143,28 +143,28 @@ QStringList ChannelFilterGUIDialog::getSelectedChannels() const
{ {
QStringList selectedChannels; QStringList selectedChannels;
if(ui->allChannelsCheckBox->isChecked()) if (ui->allChannelsCheckBox->isChecked())
{ {
selectedChannels.append("ALL"); selectedChannels.append("ALL");
} }
else else
{ {
for(QCheckBox* checkBox : checkBoxes) for (QCheckBox* checkBox : checkBoxes)
{ {
if(checkBox->isChecked()) if (checkBox->isChecked())
{ {
QString channelName = checkBox->property(PROPERTY_NAME).toString(); QString channelName = checkBox->property(PROPERTY_NAME).toString();
selectedChannels.append(channelName); selectedChannels.append(channelName);
} }
} }
for(int i = 0; i < ui->listWidget->count(); i++) for (int i = 0; i < ui->listWidget->count(); i++)
{ {
QListWidgetItem* item = ui->listWidget->item(i); QListWidgetItem* item = ui->listWidget->item(i);
if(item->checkState() == Qt::Checked) if (item->checkState() == Qt::Checked)
{ {
QString text = item->text().trimmed(); QString text = item->text().trimmed();
if(text.length() > 0) if (text.length() > 0)
selectedChannels.append(text.toUpper()); selectedChannels.append(text.toUpper());
} }
} }
+2 -2
View File
@@ -31,7 +31,7 @@ class ChannelFilterGUIDialog : public QDialog
Q_OBJECT Q_OBJECT
public: public:
explicit ChannelFilterGUIDialog(QWidget *parent, QStringList selectedChannels, int selectedChannelMask, const std::vector<std::wstring>& channelNames); explicit ChannelFilterGUIDialog(QWidget* parent, QStringList selectedChannels, int selectedChannelMask, const std::vector<std::wstring>& channelNames);
~ChannelFilterGUIDialog(); ~ChannelFilterGUIDialog();
QStringList getSelectedChannels() const; QStringList getSelectedChannels() const;
@@ -44,6 +44,6 @@ private slots:
void on_allChannelsCheckBox_toggled(bool checked); void on_allChannelsCheckBox_toggled(bool checked);
private: private:
Ui::ChannelFilterGUIDialog *ui; Ui::ChannelFilterGUIDialog* ui;
QList<QCheckBox*> checkBoxes; QList<QCheckBox*> checkBoxes;
}; };
+1 -1
View File
@@ -41,7 +41,7 @@ IFilterGUI* ChannelFilterGUIFactory::createFilterGUI(QString& command, QString&
{ {
ChannelFilterGUI* result = NULL; ChannelFilterGUI* result = NULL;
if(command == "Channel") if (command == "Channel")
{ {
result = new ChannelFilterGUI(parameters, filterTable->getSelectedChannelMask()); result = new ChannelFilterGUI(parameters, filterTable->getSelectedChannelMask());
} }
+7 -7
View File
@@ -37,7 +37,7 @@ void ChannelFilterGUIScene::load(vector<wstring> channelNames, QStringList selec
channelNames.push_back(L"ALL"); channelNames.push_back(L"ALL");
for(unsigned i = 0; i < channelNames.size(); i++) for (unsigned i = 0; i < channelNames.size(); i++)
{ {
QString c = QString::fromStdWString(channelNames[i]); QString c = QString::fromStdWString(channelNames[i]);
@@ -46,15 +46,15 @@ void ChannelFilterGUIScene::load(vector<wstring> channelNames, QStringList selec
addItem(item); addItem(item);
channelMap.insert(c, item); channelMap.insert(c, item);
if(c != "ALL") if (c != "ALL")
channelMap.insert(QString().setNum(i), item); channelMap.insert(QString().setNum(i), item);
lastItem = item; lastItem = item;
} }
for(QString c : selectedChannels) for (QString c : selectedChannels)
{ {
ChannelFilterGUIChannelItem* item = channelMap.value(c.toUpper()); ChannelFilterGUIChannelItem* item = channelMap.value(c.toUpper());
if(item == NULL) if (item == NULL)
{ {
item = new ChannelFilterGUIChannelItem(c); item = new ChannelFilterGUIChannelItem(c);
item->setPos(getNextChannelPoint(lastItem, false)); item->setPos(getNextChannelPoint(lastItem, false));
@@ -74,12 +74,12 @@ QStringList ChannelFilterGUIScene::getSelectedChannels()
{ {
QStringList selectedChannels; QStringList selectedChannels;
for(QGraphicsItem* item : items(Qt::AscendingOrder)) for (QGraphicsItem* item : items(Qt::AscendingOrder))
{ {
ChannelFilterGUIChannelItem* channelItem = qgraphicsitem_cast<ChannelFilterGUIChannelItem*>(item); ChannelFilterGUIChannelItem* channelItem = qgraphicsitem_cast<ChannelFilterGUIChannelItem*>(item);
if(channelItem != NULL) if (channelItem != NULL)
{ {
if(channelItem->isSelected()) if (channelItem->isSelected())
selectedChannels.append(channelItem->getName()); selectedChannels.append(channelItem->getName());
} }
} }
+2 -2
View File
@@ -49,7 +49,7 @@ CommentFilterGUI::~CommentFilterGUI()
void CommentFilterGUI::configureChannels(vector<wstring>& channelNames) void CommentFilterGUI::configureChannels(vector<wstring>& channelNames)
{ {
if(ui->actionPowerOn->isChecked()) if (ui->actionPowerOn->isChecked())
{ {
child->configureChannels(channelNames); child->configureChannels(channelNames);
} }
@@ -65,7 +65,7 @@ void CommentFilterGUI::store(QString& command, QString& parameters)
{ {
child->store(command, parameters); child->store(command, parameters);
if(!ui->actionPowerOn->isChecked()) if (!ui->actionPowerOn->isChecked())
command = "# " + command; command = "# " + command;
} }
+1 -2
View File
@@ -21,8 +21,7 @@
#include "Editor/IFilterGUI.h" #include "Editor/IFilterGUI.h"
namespace Ui namespace Ui {
{
class CommentFilterGUI; class CommentFilterGUI;
} }
+1 -1
View File
@@ -37,7 +37,7 @@ QList<FilterTemplate> CommentFilterGUIFactory::createFilterTemplates()
IFilterGUI* CommentFilterGUIFactory::createFilterGUI(QString& command, QString& parameters) IFilterGUI* CommentFilterGUIFactory::createFilterGUI(QString& command, QString& parameters)
{ {
lastWasComment = command.length() > 0 && command[0] == '#'; lastWasComment = command.length() > 0 && command[0] == '#';
if(lastWasComment) if (lastWasComment)
command = command.mid(1).trimmed(); command = command.mid(1).trimmed();
return NULL; return NULL;
+10 -10
View File
@@ -24,8 +24,8 @@
#include "ConvolutionFilterGUI.h" #include "ConvolutionFilterGUI.h"
#include "ui_ConvolutionFilterGUI.h" #include "ui_ConvolutionFilterGUI.h"
ConvolutionFilterGUI::ConvolutionFilterGUI(const QString& configPath, unsigned deviceSampleRate, const QString& path) : ConvolutionFilterGUI::ConvolutionFilterGUI(const QString& configPath, unsigned deviceSampleRate, const QString& path)
ui(new Ui::ConvolutionFilterGUI), deviceSampleRate(deviceSampleRate) : ui(new Ui::ConvolutionFilterGUI), deviceSampleRate(deviceSampleRate)
{ {
ui->setupUi(this); ui->setupUi(this);
@@ -51,19 +51,19 @@ void ConvolutionFilterGUI::on_selectFileToolButton_clicked()
QFileInfo fileInfo(configPath); QFileInfo fileInfo(configPath);
QDir configDir = fileInfo.absoluteDir(); QDir configDir = fileInfo.absoluteDir();
QString path = ui->pathLineEdit->text(); QString path = ui->pathLineEdit->text();
if(path.length() > 0) if (path.length() > 0)
fileInfo.setFile(configDir, path); fileInfo.setFile(configDir, path);
QFileDialog dialog(this, tr("Select impulse response file"), fileInfo.absolutePath(), "*.wav;*.flac;*.ogg"); QFileDialog dialog(this, tr("Select impulse response file"), fileInfo.absolutePath(), "*.wav;*.flac;*.ogg");
dialog.setFileMode(QFileDialog::ExistingFile); dialog.setFileMode(QFileDialog::ExistingFile);
dialog.setNameFilter(tr("Impulse response (*.wav *.flac *.ogg)")); dialog.setNameFilter(tr("Impulse response (*.wav *.flac *.ogg)"));
if(path.length() > 0) if (path.length() > 0)
dialog.selectFile(fileInfo.fileName()); dialog.selectFile(fileInfo.fileName());
if(dialog.exec() == QDialog::Accepted) if (dialog.exec() == QDialog::Accepted)
{ {
QString absolutePath = dialog.selectedFiles().first(); QString absolutePath = dialog.selectedFiles().first();
QString relativePath = configDir.relativeFilePath(absolutePath); QString relativePath = configDir.relativeFilePath(absolutePath);
if(relativePath.startsWith("../../")) if (relativePath.startsWith("../../"))
relativePath = absolutePath; relativePath = absolutePath;
ui->pathLineEdit->setText(QDir::toNativeSeparators(relativePath)); ui->pathLineEdit->setText(QDir::toNativeSeparators(relativePath));
updateFileInfo(); updateFileInfo();
@@ -85,7 +85,7 @@ void ConvolutionFilterGUI::updateFileInfo()
QString error = ""; QString error = "";
QString path = ui->pathLineEdit->text(); QString path = ui->pathLineEdit->text();
if(path.length() == 0) if (path.length() == 0)
{ {
error = tr("No file selected"); error = tr("No file selected");
labelsVisible = false; labelsVisible = false;
@@ -95,7 +95,7 @@ void ConvolutionFilterGUI::updateFileInfo()
QFileInfo fileInfo(configPath); QFileInfo fileInfo(configPath);
QDir configDir = fileInfo.absoluteDir(); QDir configDir = fileInfo.absoluteDir();
fileInfo.setFile(configDir, path); fileInfo.setFile(configDir, path);
if(!fileInfo.exists()) if (!fileInfo.exists())
{ {
error = tr("File not found"); error = tr("File not found");
labelsVisible = false; labelsVisible = false;
@@ -106,7 +106,7 @@ void ConvolutionFilterGUI::updateFileInfo()
SF_INFO info; SF_INFO info;
SNDFILE* file = sf_wchar_open(path.toStdWString().c_str(), SFM_READ, &info); SNDFILE* file = sf_wchar_open(path.toStdWString().c_str(), SFM_READ, &info);
if(file == NULL) if (file == NULL)
{ {
error = tr("Unsupported file format"); error = tr("Unsupported file format");
labelsVisible = false; labelsVisible = false;
@@ -120,7 +120,7 @@ void ConvolutionFilterGUI::updateFileInfo()
ui->labelSampleRateValue->setText(tr("%0 Hz").arg(sampleRate)); ui->labelSampleRateValue->setText(tr("%0 Hz").arg(sampleRate));
sf_close(file); sf_close(file);
if(sampleRate != deviceSampleRate) if (sampleRate != deviceSampleRate)
{ {
error = tr("The file sample rate does not match the device sample rate (%0 Hz)!\nSelect a different file or change the device configuration.").arg(deviceSampleRate); error = tr("The file sample rate does not match the device sample rate (%0 Hz)!\nSelect a different file or change the device configuration.").arg(deviceSampleRate);
} }
+1 -1
View File
@@ -43,7 +43,7 @@ private slots:
private: private:
void updateFileInfo(); void updateFileInfo();
Ui::ConvolutionFilterGUI *ui; Ui::ConvolutionFilterGUI* ui;
QString configPath; QString configPath;
unsigned deviceSampleRate; unsigned deviceSampleRate;
}; };
+1 -1
View File
@@ -47,7 +47,7 @@ IFilterGUI* ConvolutionFilterGUIFactory::createFilterGUI(QString& command, QStri
{ {
ConvolutionFilterGUI* result = NULL; ConvolutionFilterGUI* result = NULL;
if(command == "Convolution") if (command == "Convolution")
{ {
result = new ConvolutionFilterGUI(configPath, deviceSampleRate, parameters.trimmed()); result = new ConvolutionFilterGUI(configPath, deviceSampleRate, parameters.trimmed());
} }
+24 -24
View File
@@ -27,8 +27,8 @@ static const int DEFAULT_HEIGHT = 88;
using namespace std; using namespace std;
CopyFilterGUI::CopyFilterGUI(CopyFilter* filter, FilterTable* filterTable) : CopyFilterGUI::CopyFilterGUI(CopyFilter* filter, FilterTable* filterTable)
ui(new Ui::CopyFilterGUI) : ui(new Ui::CopyFilterGUI)
{ {
ui->setupUi(this); ui->setupUi(this);
@@ -66,7 +66,7 @@ void CopyFilterGUI::configureChannels(vector<wstring>& channelNames)
{ {
vector<Assignment> assignments = ui->form->buildAssignments(); vector<Assignment> assignments = ui->form->buildAssignments();
if(channelNames != inputChannelNames) if (channelNames != inputChannelNames)
{ {
inputChannelNames = channelNames; inputChannelNames = channelNames;
@@ -74,24 +74,24 @@ void CopyFilterGUI::configureChannels(vector<wstring>& channelNames)
ui->form->setChannelNames(channelNames); ui->form->setChannelNames(channelNames);
} }
for(Assignment assignment : assignments) for (Assignment assignment : assignments)
{ {
if(assignment.targetChannel == L"") if (assignment.targetChannel == L"")
continue; continue;
bool hasSummand = false; bool hasSummand = false;
for(Assignment::Summand summand : assignment.sourceSum) for (Assignment::Summand summand : assignment.sourceSum)
{ {
if(summand.channel != L" ") if (summand.channel != L" ")
{ {
hasSummand = true; hasSummand = true;
break; break;
} }
} }
if(!hasSummand) if (!hasSummand)
continue; continue;
int channelIndex = ChannelHelper::getChannelIndex(assignment.targetChannel, channelNames, true); int channelIndex = ChannelHelper::getChannelIndex(assignment.targetChannel, channelNames, true);
if(channelIndex == -1) if (channelIndex == -1)
channelNames.push_back(assignment.targetChannel); channelNames.push_back(assignment.targetChannel);
} }
} }
@@ -102,29 +102,29 @@ void CopyFilterGUI::store(QString& command, QString& parameters)
std::vector<Assignment> assignments; std::vector<Assignment> assignments;
if(ui->tabWidget->currentIndex() == 0) if (ui->tabWidget->currentIndex() == 0)
assignments = scene->buildAssignments(); assignments = scene->buildAssignments();
else else
assignments = ui->form->buildAssignments(); assignments = ui->form->buildAssignments();
bool firstAssignment = true; bool firstAssignment = true;
for(const Assignment& assignment : assignments) for (const Assignment& assignment : assignments)
{ {
if(assignment.targetChannel == L"") if (assignment.targetChannel == L"")
continue; continue;
bool firstSummand = true; bool firstSummand = true;
for(const Assignment::Summand& summand : assignment.sourceSum) for (const Assignment::Summand& summand : assignment.sourceSum)
{ {
// skip not yet filled row // skip not yet filled row
if(summand.channel == L" ") if (summand.channel == L" ")
continue; continue;
if(firstSummand) if (firstSummand)
{ {
firstSummand = false; firstSummand = false;
if(firstAssignment) if (firstAssignment)
firstAssignment = false; firstAssignment = false;
else else
parameters += " "; parameters += " ";
@@ -140,25 +140,25 @@ void CopyFilterGUI::store(QString& command, QString& parameters)
bool hasChannel = summand.channel != L""; bool hasChannel = summand.channel != L"";
bool hasFactor = !hasChannel || summand.factor != 1.0 || summand.isDecibel; bool hasFactor = !hasChannel || summand.factor != 1.0 || summand.isDecibel;
if(hasFactor) if (hasFactor)
{ {
QString factorString; QString factorString;
factorString.setNum(summand.factor); factorString.setNum(summand.factor);
if(factorString != "0" && !factorString.contains('.')) if (factorString != "0" && !factorString.contains('.'))
factorString += ".0"; factorString += ".0";
parameters += factorString; parameters += factorString;
if(summand.isDecibel) if (summand.isDecibel)
parameters += "dB"; parameters += "dB";
} }
if(hasFactor && hasChannel) if (hasFactor && hasChannel)
parameters += "*"; parameters += "*";
if(hasChannel) if (hasChannel)
parameters += QString::fromStdWString(summand.channel); parameters += QString::fromStdWString(summand.channel);
} }
if(ui->tabWidget->currentIndex() == 0) if (ui->tabWidget->currentIndex() == 0)
ui->form->load(assignments); ui->form->load(assignments);
else else
scene->load(inputChannelNames, assignments); scene->load(inputChannelNames, assignments);
@@ -173,8 +173,8 @@ void CopyFilterGUI::loadPreferences(const QVariantMap& prefs)
void CopyFilterGUI::storePreferences(QVariantMap& prefs) void CopyFilterGUI::storePreferences(QVariantMap& prefs)
{ {
if(ui->scrollArea->height() != DEFAULT_HEIGHT) if (ui->scrollArea->height() != DEFAULT_HEIGHT)
prefs.insert("height", ui->scrollArea->height()); prefs.insert("height", ui->scrollArea->height());
if(ui->tabWidget->currentIndex() != 0) if (ui->tabWidget->currentIndex() != 0)
prefs.insert("tabIndex", ui->tabWidget->currentIndex()); prefs.insert("tabIndex", ui->tabWidget->currentIndex());
} }
+1 -1
View File
@@ -44,7 +44,7 @@ public:
void storePreferences(QVariantMap& prefs) override; void storePreferences(QVariantMap& prefs) override;
private: private:
Ui::CopyFilterGUI *ui; Ui::CopyFilterGUI* ui;
CopyFilterGUIScene* scene; CopyFilterGUIScene* scene;
std::vector<std::wstring> inputChannelNames; std::vector<std::wstring> inputChannelNames;
+22 -22
View File
@@ -22,8 +22,8 @@
#include "CopyFilterGUIScene.h" #include "CopyFilterGUIScene.h"
#include "CopyFilterGUIChannelItem.h" #include "CopyFilterGUIChannelItem.h"
CopyFilterGUIChannelItem::CopyFilterGUIChannelItem(const QString& name, bool output) : CopyFilterGUIChannelItem::CopyFilterGUIChannelItem(const QString& name, bool output)
ChannelGraphItem(name), output(output) : ChannelGraphItem(name), output(output)
{ {
setZValue(-1); setZValue(-1);
} }
@@ -31,19 +31,19 @@ CopyFilterGUIChannelItem::CopyFilterGUIChannelItem(const QString& name, bool out
void CopyFilterGUIChannelItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) void CopyFilterGUIChannelItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
{ {
QColor color; QColor color;
if(output) if (output)
color = QColor(255, 194, 194); color = QColor(255, 194, 194);
else else
color = QColor(176, 255, 176); color = QColor(176, 255, 176);
ChannelGraphItem::paint(painter, color) ; ChannelGraphItem::paint(painter, color);
} }
QPointF CopyFilterGUIChannelItem::getPerimeterPointTo(QPointF oppositePoint) QPointF CopyFilterGUIChannelItem::getPerimeterPointTo(QPointF oppositePoint)
{ {
QRectF rect = boundingRect(); QRectF rect = boundingRect();
if(output) if (output)
return scenePos() + QPointF(rect.center().x(), rect.top()); return scenePos() + QPointF(rect.center().x(), rect.top());
else else
return scenePos() + QPointF(rect.center().x(), rect.top() + rect.height()); return scenePos() + QPointF(rect.center().x(), rect.top() + rect.height());
@@ -54,10 +54,10 @@ CopyFilterGUIChannelItem* CopyFilterGUIChannelItem::findAt(QPointF mousePos)
CopyFilterGUIChannelItem* result = NULL; CopyFilterGUIChannelItem* result = NULL;
QList<QGraphicsItem*> items = scene()->items(mousePos); QList<QGraphicsItem*> items = scene()->items(mousePos);
for(QGraphicsItem* item : items) for (QGraphicsItem* item : items)
{ {
CopyFilterGUIChannelItem* channelItem = qgraphicsitem_cast<CopyFilterGUIChannelItem*>(item); CopyFilterGUIChannelItem* channelItem = qgraphicsitem_cast<CopyFilterGUIChannelItem*>(item);
if(channelItem != NULL && channelItem->output != output) if (channelItem != NULL && channelItem->output != output)
{ {
result = channelItem; result = channelItem;
break; break;
@@ -74,7 +74,7 @@ QLineF CopyFilterGUIChannelItem::getLineTo(CopyFilterGUIChannelItem* item)
QPointF startPoint = getPerimeterPointTo(endPoint); QPointF startPoint = getPerimeterPointTo(endPoint);
QLineF line; QLineF line;
if(output) if (output)
line = QLineF(endPoint, startPoint); line = QLineF(endPoint, startPoint);
else else
line = QLineF(startPoint, endPoint); line = QLineF(startPoint, endPoint);
@@ -88,23 +88,23 @@ void CopyFilterGUIChannelItem::mousePressEvent(QGraphicsSceneMouseEvent* event)
void CopyFilterGUIChannelItem::mouseMoveEvent(QGraphicsSceneMouseEvent* event) void CopyFilterGUIChannelItem::mouseMoveEvent(QGraphicsSceneMouseEvent* event)
{ {
if(currentConnection == NULL) if (currentConnection == NULL)
{ {
if( !boundingRect().contains(event->pos())) if (!boundingRect().contains(event->pos()))
{ {
currentConnection = new CopyFilterGUIConnectionItem(); currentConnection = new CopyFilterGUIConnectionItem();
scene()->addItem(currentConnection); scene()->addItem(currentConnection);
} }
} }
if(currentConnection != NULL) if (currentConnection != NULL)
{ {
CopyFilterGUIChannelItem* item = findAt(event->scenePos()); CopyFilterGUIChannelItem* item = findAt(event->scenePos());
if(item == NULL) if (item == NULL)
{ {
QLineF line; QLineF line;
if(output) if (output)
line = QLineF(event->scenePos(), getPerimeterPointTo(event->scenePos())); line = QLineF(event->scenePos(), getPerimeterPointTo(event->scenePos()));
else else
line = QLineF(getPerimeterPointTo(event->scenePos()), event->scenePos()); line = QLineF(getPerimeterPointTo(event->scenePos()), event->scenePos());
@@ -119,14 +119,14 @@ void CopyFilterGUIChannelItem::mouseMoveEvent(QGraphicsSceneMouseEvent* event)
void CopyFilterGUIChannelItem::mouseReleaseEvent(QGraphicsSceneMouseEvent* event) void CopyFilterGUIChannelItem::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
{ {
if(currentConnection != NULL) if (currentConnection != NULL)
{ {
CopyFilterGUIChannelItem* item = findAt(event->scenePos()); CopyFilterGUIChannelItem* item = findAt(event->scenePos());
if(item != NULL) if (item != NULL)
{ {
CopyFilterGUIChannelItem* source; CopyFilterGUIChannelItem* source;
CopyFilterGUIChannelItem* target; CopyFilterGUIChannelItem* target;
if(output) if (output)
{ {
source = item; source = item;
target = this; target = this;
@@ -138,13 +138,13 @@ void CopyFilterGUIChannelItem::mouseReleaseEvent(QGraphicsSceneMouseEvent* event
} }
double factor = 1.0; double factor = 1.0;
if(source->getName() == "") if (source->getName() == "")
factor = 0.0; factor = 0.0;
scene()->addItem(new CopyFilterGUIConnectionItem(source, target, factor, false)); scene()->addItem(new CopyFilterGUIConnectionItem(source, target, factor, false));
emit ((CopyFilterGUIScene*)scene())->updateModel(); emit((CopyFilterGUIScene*)scene())->updateModel();
emit ((CopyFilterGUIScene*)scene())->updateChannels(); emit((CopyFilterGUIScene*)scene())->updateChannels();
} }
scene()->removeItem(currentConnection); scene()->removeItem(currentConnection);
@@ -155,12 +155,12 @@ void CopyFilterGUIChannelItem::mouseReleaseEvent(QGraphicsSceneMouseEvent* event
{ {
scene()->clearSelection(); scene()->clearSelection();
QList<QGraphicsItem*> items = scene()->items(); QList<QGraphicsItem*> items = scene()->items();
for(QGraphicsItem* item : items) for (QGraphicsItem* item : items)
{ {
CopyFilterGUIConnectionItem* connItem = qgraphicsitem_cast<CopyFilterGUIConnectionItem*>(item); CopyFilterGUIConnectionItem* connItem = qgraphicsitem_cast<CopyFilterGUIConnectionItem*>(item);
if(connItem != NULL) if (connItem != NULL)
{ {
if(connItem->getSource() == this || connItem->getTarget() == this) if (connItem->getSource() == this || connItem->getTarget() == this)
connItem->setSelected(true); connItem->setSelected(true);
} }
} }
+1 -1
View File
@@ -30,7 +30,7 @@ class CopyFilterGUIChannelItem : public ChannelGraphItem
public: public:
CopyFilterGUIChannelItem(const QString& name, bool output); CopyFilterGUIChannelItem(const QString& name, bool output);
enum { Type = UserType + 2 }; enum {Type = UserType + 2};
virtual int type() const virtual int type() const
{ {
return Type; return Type;
+12 -12
View File
@@ -64,7 +64,7 @@ QPainterPath CopyFilterGUIConnectionItem::shape() const
QPainterPath path; QPainterPath path;
path.setFillRule(Qt::WindingFill); path.setFillRule(Qt::WindingFill);
double length = line().length(); double length = line().length();
if(length > 0) if (length > 0)
{ {
double offset = min(length, maxArrowSize); double offset = min(length, maxArrowSize);
QLineF unit = l.unitVector(); QLineF unit = l.unitVector();
@@ -89,13 +89,13 @@ QPainterPath CopyFilterGUIConnectionItem::shape() const
polygon2.append(p1 + 3 * n); polygon2.append(p1 + 3 * n);
path.addPolygon(polygon2); path.addPolygon(polygon2);
if(factor != 1.0 || isDecibel) if (factor != 1.0 || isDecibel)
{ {
QFont font; QFont font;
font.setPixelSize(10); font.setPixelSize(10);
QPointF center = (l.p1() + l.p2()) / 2; QPointF center = (l.p1() + l.p2()) / 2;
QString text = QString("%1").arg(factor); QString text = QString("%1").arg(factor);
if(isDecibel) if (isDecibel)
text += " dB"; text += " dB";
QFontMetrics fontMetrics(font); QFontMetrics fontMetrics(font);
@@ -119,10 +119,10 @@ bool CopyFilterGUIConnectionItem::contains(const QPointF& point) const
void CopyFilterGUIConnectionItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) void CopyFilterGUIConnectionItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
{ {
QLineF l = line(); QLineF l = line();
if(!l.isNull()) if (!l.isNull())
{ {
painter->setBrush(Qt::black); painter->setBrush(Qt::black);
if(isSelected()) if (isSelected())
{ {
painter->setBrush(Qt::blue); painter->setBrush(Qt::blue);
painter->setPen(QPen(Qt::blue, 1.5)); painter->setPen(QPen(Qt::blue, 1.5));
@@ -146,14 +146,14 @@ void CopyFilterGUIConnectionItem::paint(QPainter* painter, const QStyleOptionGra
painter->drawPolygon(polygon); painter->drawPolygon(polygon);
if(factor != 1.0 || isDecibel) if (factor != 1.0 || isDecibel)
{ {
QFont font = painter->font(); QFont font = painter->font();
font.setPixelSize(10); font.setPixelSize(10);
painter->setFont(font); painter->setFont(font);
QPointF center = (l.p1() + l.p2()) / 2; QPointF center = (l.p1() + l.p2()) / 2;
QString text = QString("%1").arg(factor); QString text = QString("%1").arg(factor);
if(isDecibel) if (isDecibel)
text += " dB"; text += " dB";
QSizeF size = painter->fontMetrics().size(0, text); QSizeF size = painter->fontMetrics().size(0, text);
@@ -171,7 +171,7 @@ void CopyFilterGUIConnectionItem::paint(QPainter* painter, const QStyleOptionGra
void CopyFilterGUIConnectionItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event) void CopyFilterGUIConnectionItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event)
{ {
QString text = QString("%1").arg(factor); QString text = QString("%1").arg(factor);
if(isDecibel) if (isDecibel)
text += " dB"; text += " dB";
ResizingLineEdit* lineEdit = new ResizingLineEdit(""); ResizingLineEdit* lineEdit = new ResizingLineEdit("");
@@ -199,7 +199,7 @@ void CopyFilterGUIConnectionItem::hoverLeaveEvent(QGraphicsSceneHoverEvent* even
QVariant CopyFilterGUIConnectionItem::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant& value) QVariant CopyFilterGUIConnectionItem::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant& value)
{ {
if(change == ItemSelectedHasChanged) if (change == ItemSelectedHasChanged)
{ {
setZValue(isSelected() ? 1 : 0); setZValue(isSelected() ? 1 : 0);
} }
@@ -211,7 +211,7 @@ void CopyFilterGUIConnectionItem::lineEditEditingFinished()
{ {
QLineEdit* lineEdit = qobject_cast<QLineEdit*>(QObject::sender()); QLineEdit* lineEdit = qobject_cast<QLineEdit*>(QObject::sender());
// might be called twice // might be called twice
if(!lineEdit->isVisible()) if (!lineEdit->isVisible())
return; return;
QString text = lineEdit->text(); QString text = lineEdit->text();
@@ -220,7 +220,7 @@ void CopyFilterGUIConnectionItem::lineEditEditingFinished()
int lengthBefore = text.length(); int lengthBefore = text.length();
text.replace("db", "", Qt::CaseInsensitive); text.replace("db", "", Qt::CaseInsensitive);
double value = text.toDouble(&ok); double value = text.toDouble(&ok);
if(ok) if (ok)
{ {
factor = value; factor = value;
isDecibel = text.length() < lengthBefore; isDecibel = text.length() < lengthBefore;
@@ -229,7 +229,7 @@ void CopyFilterGUIConnectionItem::lineEditEditingFinished()
lineEdit->setVisible(false); lineEdit->setVisible(false);
lineEdit->deleteLater(); lineEdit->deleteLater();
emit ((CopyFilterGUIScene*)scene())->updateModel(); emit((CopyFilterGUIScene*)scene())->updateModel();
} }
CopyFilterGUIChannelItem* CopyFilterGUIConnectionItem::getSource() const CopyFilterGUIChannelItem* CopyFilterGUIConnectionItem::getSource() const
+1 -1
View File
@@ -31,7 +31,7 @@ public:
CopyFilterGUIConnectionItem(); CopyFilterGUIConnectionItem();
CopyFilterGUIConnectionItem(CopyFilterGUIChannelItem* source, CopyFilterGUIChannelItem* target, double factor, bool isDecibel); CopyFilterGUIConnectionItem(CopyFilterGUIChannelItem* source, CopyFilterGUIChannelItem* target, double factor, bool isDecibel);
enum { Type = UserType + 1 }; enum {Type = UserType + 1};
virtual int type() const virtual int type() const
{ {
return Type; return Type;
+3 -3
View File
@@ -42,17 +42,17 @@ IFilterGUI* CopyFilterGUIFactory::createFilterGUI(QString& command, QString& par
{ {
CopyFilterGUI* result = NULL; CopyFilterGUI* result = NULL;
if(command == "Copy") if (command == "Copy")
{ {
CopyFilterFactory factory; CopyFilterFactory factory;
std::vector<IFilter*> filters = factory.createFilter(L"", command.toStdWString(), parameters.toStdWString()); std::vector<IFilter*> filters = factory.createFilter(L"", command.toStdWString(), parameters.toStdWString());
if(!filters.empty()) if (!filters.empty())
{ {
CopyFilter* filter = (CopyFilter*)filters[0]; CopyFilter* filter = (CopyFilter*)filters[0];
result = new CopyFilterGUI(filter, filterTable); result = new CopyFilterGUI(filter, filterTable);
} }
for(IFilter* f : filters) for (IFilter* f : filters)
{ {
f->~IFilter(); f->~IFilter();
MemoryHelper::free(f); MemoryHelper::free(f);
+20 -20
View File
@@ -29,20 +29,20 @@
using namespace std; using namespace std;
CopyFilterGUIForm::CopyFilterGUIForm(QWidget *parent) : CopyFilterGUIForm::CopyFilterGUIForm(QWidget* parent)
QWidget(parent) : QWidget(parent)
{ {
} }
void CopyFilterGUIForm::load(vector<Assignment> assignments) void CopyFilterGUIForm::load(vector<Assignment> assignments)
{ {
if(gridLayout != NULL) if (gridLayout != NULL)
delete gridLayout; delete gridLayout;
for(QObject* object : children()) for (QObject* object : children())
{ {
QWidget* widget = qobject_cast<QWidget*>(object); QWidget* widget = qobject_cast<QWidget*>(object);
if(widget != NULL) if (widget != NULL)
widget->setVisible(false); widget->setVisible(false);
object->deleteLater(); object->deleteLater();
} }
@@ -55,20 +55,20 @@ void CopyFilterGUIForm::load(vector<Assignment> assignments)
gridLayout->setColumnStretch(5, 1); gridLayout->setColumnStretch(5, 1);
int row = 0; int row = 0;
for(Assignment assignment : assignments) for (Assignment assignment : assignments)
{ {
QString oc = QString::fromStdWString(assignment.targetChannel); QString oc = QString::fromStdWString(assignment.targetChannel);
bool firstSummand = true; bool firstSummand = true;
for(Assignment::Summand summand : assignment.sourceSum) for (Assignment::Summand summand : assignment.sourceSum)
{ {
if(firstSummand) if (firstSummand)
{ {
gridLayout->addWidget(new QLabel(tr("Channel"), this), row, 0); gridLayout->addWidget(new QLabel(tr("Channel"), this), row, 0);
QComboBox* targetComboBox = new QComboBox(this); QComboBox* targetComboBox = new QComboBox(this);
targetComboBox->setEditable(true); targetComboBox->setEditable(true);
for(wstring channelName : inputChannelNames) for (wstring channelName : inputChannelNames)
targetComboBox->addItem(QString::fromStdWString(channelName)); targetComboBox->addItem(QString::fromStdWString(channelName));
targetComboBox->setEditText(oc); targetComboBox->setEditText(oc);
connect(targetComboBox, SIGNAL(editTextChanged(QString)), this, SIGNAL(updateModel())); connect(targetComboBox, SIGNAL(editTextChanged(QString)), this, SIGNAL(updateModel()));
@@ -96,7 +96,7 @@ void CopyFilterGUIForm::load(vector<Assignment> assignments)
connect(addSummandButton, SIGNAL(pressed()), this, SLOT(addSummand())); connect(addSummandButton, SIGNAL(pressed()), this, SLOT(addSummand()));
QPushButton* removeButton = new QPushButton(this); QPushButton* removeButton = new QPushButton(this);
if(assignment.sourceSum.size() == 1) if (assignment.sourceSum.size() == 1)
removeButton->setText(tr("Remove assignment")); removeButton->setText(tr("Remove assignment"));
else else
removeButton->setText(tr("Remove summand")); removeButton->setText(tr("Remove summand"));
@@ -122,16 +122,16 @@ void CopyFilterGUIForm::setChannelNames(const vector<wstring>& channelNames)
{ {
inputChannelNames = channelNames; inputChannelNames = channelNames;
for(int row = 0; row < gridLayout->rowCount() - 1; row++) for (int row = 0; row < gridLayout->rowCount() - 1; row++)
{ {
QLayoutItem* item = gridLayout->itemAtPosition(row, 1); QLayoutItem* item = gridLayout->itemAtPosition(row, 1);
if(item != NULL) if (item != NULL)
{ {
QComboBox* targetComboBox = qobject_cast<QComboBox*>(item->widget()); QComboBox* targetComboBox = qobject_cast<QComboBox*>(item->widget());
targetComboBox->blockSignals(true); targetComboBox->blockSignals(true);
QString text = targetComboBox->currentText(); QString text = targetComboBox->currentText();
targetComboBox->clear(); targetComboBox->clear();
for(wstring channelName : channelNames) for (wstring channelName : channelNames)
targetComboBox->addItem(QString::fromStdWString(channelName)); targetComboBox->addItem(QString::fromStdWString(channelName));
targetComboBox->setEditText(text); targetComboBox->setEditText(text);
targetComboBox->blockSignals(false); targetComboBox->blockSignals(false);
@@ -148,10 +148,10 @@ vector<Assignment> CopyFilterGUIForm::buildAssignments(QWidget* pressedButton)
vector<Assignment> assignments; vector<Assignment> assignments;
Assignment* currentAssignment = NULL; Assignment* currentAssignment = NULL;
for(int row = 0; row < gridLayout->rowCount() - 1; row++) for (int row = 0; row < gridLayout->rowCount() - 1; row++)
{ {
QLayoutItem* item = gridLayout->itemAtPosition(row, 1); QLayoutItem* item = gridLayout->itemAtPosition(row, 1);
if(item != NULL) if (item != NULL)
{ {
QComboBox* targetComboBox = qobject_cast<QComboBox*>(item->widget()); QComboBox* targetComboBox = qobject_cast<QComboBox*>(item->widget());
QString oc = targetComboBox->currentText().trimmed(); QString oc = targetComboBox->currentText().trimmed();
@@ -160,12 +160,12 @@ vector<Assignment> CopyFilterGUIForm::buildAssignments(QWidget* pressedButton)
currentAssignment->targetChannel = oc.toStdWString(); currentAssignment->targetChannel = oc.toStdWString();
} }
if(currentAssignment != NULL) if (currentAssignment != NULL)
{ {
if(pressedButton != NULL) if (pressedButton != NULL)
{ {
QWidget* removeButton = gridLayout->itemAtPosition(row, 5)->widget(); QWidget* removeButton = gridLayout->itemAtPosition(row, 5)->widget();
if(removeButton == pressedButton) if (removeButton == pressedButton)
{ {
continue; continue;
} }
@@ -175,10 +175,10 @@ vector<Assignment> CopyFilterGUIForm::buildAssignments(QWidget* pressedButton)
CopyFilterGUIRow* summandWidget = qobject_cast<CopyFilterGUIRow*>(summandItem->widget()); CopyFilterGUIRow* summandWidget = qobject_cast<CopyFilterGUIRow*>(summandItem->widget());
currentAssignment->sourceSum.push_back(summandWidget->buildSummand()); currentAssignment->sourceSum.push_back(summandWidget->buildSummand());
if(pressedButton != NULL) if (pressedButton != NULL)
{ {
QWidget* addSummandButton = gridLayout->itemAtPosition(row, 4)->widget(); QWidget* addSummandButton = gridLayout->itemAtPosition(row, 4)->widget();
if(addSummandButton == pressedButton) if (addSummandButton == pressedButton)
{ {
Assignment::Summand newSummand; Assignment::Summand newSummand;
newSummand.channel = L" "; newSummand.channel = L" ";
+1 -1
View File
@@ -29,7 +29,7 @@ class CopyFilterGUIForm : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit CopyFilterGUIForm(QWidget *parent = 0); explicit CopyFilterGUIForm(QWidget* parent = 0);
void load(std::vector<Assignment> assignments); void load(std::vector<Assignment> assignments);
void setChannelNames(const std::vector<std::wstring>& channelNames); void setChannelNames(const std::vector<std::wstring>& channelNames);
+11 -11
View File
@@ -22,8 +22,8 @@
using namespace std; using namespace std;
CopyFilterGUIRow::CopyFilterGUIRow(Assignment::Summand summand, std::vector<wstring> channelNames, QWidget *parent) : CopyFilterGUIRow::CopyFilterGUIRow(Assignment::Summand summand, std::vector<wstring> channelNames, QWidget* parent)
QWidget(parent), : QWidget(parent),
ui(new Ui::CopyFilterGUIRow) ui(new Ui::CopyFilterGUIRow)
{ {
ui->setupUi(this); ui->setupUi(this);
@@ -34,11 +34,11 @@ CopyFilterGUIRow::CopyFilterGUIRow(Assignment::Summand summand, std::vector<wstr
ui->modeComboBox->addItem(tr("Constant value"), 'v'); ui->modeComboBox->addItem(tr("Constant value"), 'v');
QChar mode; QChar mode;
if(summand.channel == L"") if (summand.channel == L"")
mode = 'v'; mode = 'v';
else if(summand.isDecibel) else if (summand.isDecibel)
mode = 'd'; mode = 'd';
else if(summand.factor != 1.0) else if (summand.factor != 1.0)
mode = 'f'; mode = 'f';
else else
mode = 'c'; mode = 'c';
@@ -47,7 +47,7 @@ CopyFilterGUIRow::CopyFilterGUIRow(Assignment::Summand summand, std::vector<wstr
ui->factorSpinBox->setValue(summand.factor); ui->factorSpinBox->setValue(summand.factor);
for(wstring channelName : channelNames) for (wstring channelName : channelNames)
ui->channelComboBox->addItem(QString::fromStdWString(channelName)); ui->channelComboBox->addItem(QString::fromStdWString(channelName));
ui->channelComboBox->setEditText(QString::fromStdWString(summand.channel).trimmed()); ui->channelComboBox->setEditText(QString::fromStdWString(summand.channel).trimmed());
@@ -67,7 +67,7 @@ void CopyFilterGUIRow::setChannelNames(const vector<wstring>& channelNames)
ui->channelComboBox->blockSignals(true); ui->channelComboBox->blockSignals(true);
QString text = ui->channelComboBox->currentText(); QString text = ui->channelComboBox->currentText();
ui->channelComboBox->clear(); ui->channelComboBox->clear();
for(wstring channelName : channelNames) for (wstring channelName : channelNames)
ui->channelComboBox->addItem(QString::fromStdWString(channelName)); ui->channelComboBox->addItem(QString::fromStdWString(channelName));
ui->channelComboBox->setEditText(text); ui->channelComboBox->setEditText(text);
ui->channelComboBox->blockSignals(false); ui->channelComboBox->blockSignals(false);
@@ -78,18 +78,18 @@ Assignment::Summand CopyFilterGUIRow::buildSummand()
Assignment::Summand summand; Assignment::Summand summand;
QChar mode = ui->modeComboBox->currentData().toChar(); QChar mode = ui->modeComboBox->currentData().toChar();
if(mode != 'c') if (mode != 'c')
summand.factor = ui->factorSpinBox->value(); summand.factor = ui->factorSpinBox->value();
else else
summand.factor = 1.0; summand.factor = 1.0;
// fix for rounding error when using the spin buttons // fix for rounding error when using the spin buttons
if(abs(summand.factor) < 1e-10) if (abs(summand.factor) < 1e-10)
summand.factor = 0.0; summand.factor = 0.0;
if(mode != 'v') if (mode != 'v')
summand.channel = ui->channelComboBox->currentText().trimmed().toStdWString(); summand.channel = ui->channelComboBox->currentText().trimmed().toStdWString();
// allow channel mode to be remembered when reloading // allow channel mode to be remembered when reloading
if(mode == 'c' && summand.channel == L"") if (mode == 'c' && summand.channel == L"")
summand.channel = L" "; summand.channel = L" ";
summand.isDecibel = mode == 'd'; summand.isDecibel = mode == 'd';
+2 -2
View File
@@ -32,7 +32,7 @@ class CopyFilterGUIRow : public QWidget
Q_OBJECT Q_OBJECT
public: public:
explicit CopyFilterGUIRow(Assignment::Summand summand, std::vector<std::wstring> channelNames, QWidget *parent = 0); explicit CopyFilterGUIRow(Assignment::Summand summand, std::vector<std::wstring> channelNames, QWidget* parent = 0);
~CopyFilterGUIRow(); ~CopyFilterGUIRow();
void setChannelNames(const std::vector<std::wstring>& channelNames); void setChannelNames(const std::vector<std::wstring>& channelNames);
@@ -46,5 +46,5 @@ private slots:
void on_modeComboBox_currentIndexChanged(int index); void on_modeComboBox_currentIndexChanged(int index);
private: private:
Ui::CopyFilterGUIRow *ui; Ui::CopyFilterGUIRow* ui;
}; };
+17 -17
View File
@@ -39,7 +39,7 @@ void CopyFilterGUIScene::load(const vector<wstring>& channelNames, vector<Assign
QGraphicsItem* lastInputItem = NULL; QGraphicsItem* lastInputItem = NULL;
lastOutputItem = NULL; lastOutputItem = NULL;
for(unsigned i = 0; i < channelNames.size(); i++) for (unsigned i = 0; i < channelNames.size(); i++)
{ {
QString c = QString::fromStdWString(channelNames[i]); QString c = QString::fromStdWString(channelNames[i]);
@@ -65,13 +65,13 @@ void CopyFilterGUIScene::load(const vector<wstring>& channelNames, vector<Assign
addItem(noChannelItem); addItem(noChannelItem);
inputChannelMap.insert("", noChannelItem); inputChannelMap.insert("", noChannelItem);
for(Assignment assignment : assignments) for (Assignment assignment : assignments)
{ {
QString oc = QString::fromStdWString(assignment.targetChannel); QString oc = QString::fromStdWString(assignment.targetChannel);
if(oc == "") if (oc == "")
continue; continue;
CopyFilterGUIChannelItem* outputItem = outputChannelMap.value(oc.toUpper()); CopyFilterGUIChannelItem* outputItem = outputChannelMap.value(oc.toUpper());
if(outputItem == NULL) if (outputItem == NULL)
{ {
outputItem = new CopyFilterGUIChannelItem(oc, true); outputItem = new CopyFilterGUIChannelItem(oc, true);
outputItem->setPos(getNextChannelPoint(lastOutputItem, true)); outputItem->setPos(getNextChannelPoint(lastOutputItem, true));
@@ -80,13 +80,13 @@ void CopyFilterGUIScene::load(const vector<wstring>& channelNames, vector<Assign
outputChannelMap.insert(oc, outputItem); outputChannelMap.insert(oc, outputItem);
lastOutputItem = outputItem; lastOutputItem = outputItem;
} }
for(Assignment::Summand summand : assignment.sourceSum) for (Assignment::Summand summand : assignment.sourceSum)
{ {
QString ic = QString::fromStdWString(summand.channel); QString ic = QString::fromStdWString(summand.channel);
if(ic == " ") if (ic == " ")
continue; continue;
CopyFilterGUIChannelItem* inputItem = inputChannelMap.value(ic.toUpper()); CopyFilterGUIChannelItem* inputItem = inputChannelMap.value(ic.toUpper());
if(inputItem == NULL) if (inputItem == NULL)
{ {
inputItem = new CopyFilterGUIChannelItem(ic, false); inputItem = new CopyFilterGUIChannelItem(ic, false);
inputItem->setPos(getNextChannelPoint(lastInputItem, false)); inputItem->setPos(getNextChannelPoint(lastInputItem, false));
@@ -114,19 +114,19 @@ std::vector<Assignment> CopyFilterGUIScene::buildAssignments()
{ {
std::vector<CopyFilterGUIConnectionItem*> connItems; std::vector<CopyFilterGUIConnectionItem*> connItems;
for(QGraphicsItem* item : items()) for (QGraphicsItem* item : items())
{ {
CopyFilterGUIConnectionItem* connItem = qgraphicsitem_cast<CopyFilterGUIConnectionItem*>(item); CopyFilterGUIConnectionItem* connItem = qgraphicsitem_cast<CopyFilterGUIConnectionItem*>(item);
if(connItem != NULL && connItem->getTarget() != NULL) if (connItem != NULL && connItem->getTarget() != NULL)
{ {
connItems.push_back(connItem); connItems.push_back(connItem);
} }
} }
std::sort(connItems.begin(), connItems.end(), [](CopyFilterGUIConnectionItem * a, CopyFilterGUIConnectionItem * b) std::sort(connItems.begin(), connItems.end(), [](CopyFilterGUIConnectionItem* a, CopyFilterGUIConnectionItem* b)
{ {
double diff = a->getTarget()->x() - b->getTarget()->x(); double diff = a->getTarget()->x() - b->getTarget()->x();
if(diff == 0.0) if (diff == 0.0)
diff = a->getSource()->x() - b->getSource()->x(); diff = a->getSource()->x() - b->getSource()->x();
return diff < 0; return diff < 0;
@@ -134,11 +134,11 @@ std::vector<Assignment> CopyFilterGUIScene::buildAssignments()
std::vector<Assignment> assignments; std::vector<Assignment> assignments;
QHash<QString, Assignment*> channelAssignmentMap; QHash<QString, Assignment*> channelAssignmentMap;
for(CopyFilterGUIConnectionItem* connItem : connItems) for (CopyFilterGUIConnectionItem* connItem : connItems)
{ {
QString oc = connItem->getTarget()->getName(); QString oc = connItem->getTarget()->getName();
Assignment* assignment = channelAssignmentMap.value(oc); Assignment* assignment = channelAssignmentMap.value(oc);
if(assignment == NULL) if (assignment == NULL)
{ {
Assignment newAssignment; Assignment newAssignment;
newAssignment.targetChannel = oc.toStdWString(); newAssignment.targetChannel = oc.toStdWString();
@@ -177,7 +177,7 @@ void CopyFilterGUIScene::lineEditEditingFinished()
{ {
QLineEdit* lineEdit = qobject_cast<QLineEdit*>(QObject::sender()); QLineEdit* lineEdit = qobject_cast<QLineEdit*>(QObject::sender());
// might be called twice // might be called twice
if(!lineEdit->isVisible()) if (!lineEdit->isVisible())
return; return;
QString text = lineEdit->text(); QString text = lineEdit->text();
@@ -197,12 +197,12 @@ void CopyFilterGUIScene::lineEditEditingFinished()
void CopyFilterGUIScene::keyPressEvent(QKeyEvent* event) void CopyFilterGUIScene::keyPressEvent(QKeyEvent* event)
{ {
// focusItem != NULL means that the cursor is inside a line edit // focusItem != NULL means that the cursor is inside a line edit
if(event->key() == Qt::Key_Delete && focusItem() == NULL) if (event->key() == Qt::Key_Delete && focusItem() == NULL)
{ {
for(QGraphicsItem* item : selectedItems()) for (QGraphicsItem* item : selectedItems())
{ {
CopyFilterGUIConnectionItem* connectionItem = qgraphicsitem_cast<CopyFilterGUIConnectionItem*>(item); CopyFilterGUIConnectionItem* connectionItem = qgraphicsitem_cast<CopyFilterGUIConnectionItem*>(item);
if(connectionItem != NULL) if (connectionItem != NULL)
{ {
removeItem(connectionItem); removeItem(connectionItem);
delete connectionItem; delete connectionItem;
+3 -3
View File
@@ -24,8 +24,8 @@ static const double dialSteps = 1000;
static const double dialMin = 1.0; static const double dialMin = 1.0;
static const double dialMax = 10000.0; static const double dialMax = 10000.0;
DelayFilterGUI::DelayFilterGUI(double delay, bool isMs) : DelayFilterGUI::DelayFilterGUI(double delay, bool isMs)
ui(new Ui::DelayFilterGUI) : ui(new Ui::DelayFilterGUI)
{ {
ui->setupUi(this); ui->setupUi(this);
@@ -42,7 +42,7 @@ void DelayFilterGUI::store(QString& command, QString& parameters)
{ {
command = "Delay"; command = "Delay";
parameters = QString("%0").arg(ui->delaySpinBox->value()); parameters = QString("%0").arg(ui->delaySpinBox->value());
if(ui->unitComboBox->currentIndex() == 0) if (ui->unitComboBox->currentIndex() == 0)
parameters += " ms"; parameters += " ms";
else else
parameters += " samples"; parameters += " samples";
+1 -1
View File
@@ -43,5 +43,5 @@ private slots:
void on_delaySpinBox_valueChanged(double value); void on_delaySpinBox_valueChanged(double value);
private: private:
Ui::DelayFilterGUI *ui; Ui::DelayFilterGUI* ui;
}; };
+3 -3
View File
@@ -37,17 +37,17 @@ IFilterGUI* DelayFilterGUIFactory::createFilterGUI(QString& command, QString& pa
{ {
DelayFilterGUI* result = NULL; DelayFilterGUI* result = NULL;
if(command == "Delay") if (command == "Delay")
{ {
DelayFilterFactory factory; DelayFilterFactory factory;
std::vector<IFilter*> filters = factory.createFilter(L"", command.toStdWString(), parameters.toStdWString()); std::vector<IFilter*> filters = factory.createFilter(L"", command.toStdWString(), parameters.toStdWString());
if(!filters.empty()) if (!filters.empty())
{ {
DelayFilter* filter = (DelayFilter*)filters[0]; DelayFilter* filter = (DelayFilter*)filters[0];
result = new DelayFilterGUI(filter->getDelay(), filter->getIsMs()); result = new DelayFilterGUI(filter->getDelay(), filter->getIsMs());
} }
for(IFilter* f : filters) for (IFilter* f : filters)
{ {
f->~IFilter(); f->~IFilter();
MemoryHelper::free(f); MemoryHelper::free(f);
+1 -1
View File
@@ -29,5 +29,5 @@ public:
explicit DelayFilterGUIFactory(); explicit DelayFilterGUIFactory();
QList<FilterTemplate> createFilterTemplates() override; QList<FilterTemplate> createFilterTemplates() override;
IFilterGUI*createFilterGUI(QString& command, QString& parameters) override;; IFilterGUI* createFilterGUI(QString& command, QString& parameters) override;;
}; };
+12 -12
View File
@@ -25,8 +25,8 @@
using namespace std; using namespace std;
DeviceFilterGUI::DeviceFilterGUI(DeviceFilterGUIFactory* factory): DeviceFilterGUI::DeviceFilterGUI(DeviceFilterGUIFactory* factory)
ui(new Ui::DeviceFilterGUI) : ui(new Ui::DeviceFilterGUI)
{ {
ui->setupUi(this); ui->setupUi(this);
this->factory = factory; this->factory = factory;
@@ -52,7 +52,7 @@ void DeviceFilterGUI::load(const QString& parameters)
QTreeWidgetItem* lastItem = NULL; QTreeWidgetItem* lastItem = NULL;
if(parameters.trimmed() == "all") if (parameters.trimmed() == "all")
{ {
QStringList values; QStringList values;
values.append(""); values.append("");
@@ -64,23 +64,23 @@ void DeviceFilterGUI::load(const QString& parameters)
else else
{ {
const QList<DeviceAPOInfo>& devices = factory->getDevices(); const QList<DeviceAPOInfo>& devices = factory->getDevices();
for(const DeviceAPOInfo& apoInfo : devices) for (const DeviceAPOInfo& apoInfo : devices)
{ {
if(!apoInfo.isInstalled) if (!apoInfo.isInstalled)
continue; continue;
wstring deviceString = apoInfo.connectionName + L" " + apoInfo.deviceName + L" " + apoInfo.deviceGuid; wstring deviceString = apoInfo.connectionName + L" " + apoInfo.deviceName + L" " + apoInfo.deviceGuid;
if(DeviceFilterFactory::matchDevice(deviceString, pattern.toStdWString())) if (DeviceFilterFactory::matchDevice(deviceString, pattern.toStdWString()))
{ {
QStringList values; QStringList values;
if(apoInfo.isInput) if (apoInfo.isInput)
values.append(tr("Capture")); values.append(tr("Capture"));
else else
values.append(tr("Playback")); values.append(tr("Playback"));
values.append(QString::fromStdWString(apoInfo.connectionName)); values.append(QString::fromStdWString(apoInfo.connectionName));
values.append(QString::fromStdWString(apoInfo.deviceName)); values.append(QString::fromStdWString(apoInfo.deviceName));
QString state; QString state;
if(apoInfo.isInstalled) if (apoInfo.isInstalled)
state = tr("APO installed"); state = tr("APO installed");
else else
state = tr("APO not installed"); state = tr("APO not installed");
@@ -89,7 +89,7 @@ void DeviceFilterGUI::load(const QString& parameters)
} }
} }
if(ui->treeWidget->topLevelItemCount() == 0) if (ui->treeWidget->topLevelItemCount() == 0)
{ {
QStringList values; QStringList values;
values.append(""); values.append("");
@@ -102,12 +102,12 @@ void DeviceFilterGUI::load(const QString& parameters)
} }
} }
for(int i = 0; i < ui->treeWidget->columnCount(); i++) for (int i = 0; i < ui->treeWidget->columnCount(); i++)
ui->treeWidget->resizeColumnToContents(i); ui->treeWidget->resizeColumnToContents(i);
int headerHeight = ui->treeWidget->header()->height(); int headerHeight = ui->treeWidget->header()->height();
int itemAreaHeight = 0; int itemAreaHeight = 0;
if(lastItem != NULL) if (lastItem != NULL)
itemAreaHeight = ui->treeWidget->visualItemRect(lastItem).bottom() + 1; itemAreaHeight = ui->treeWidget->visualItemRect(lastItem).bottom() + 1;
ui->treeWidget->setFixedHeight(headerHeight + itemAreaHeight + 3); ui->treeWidget->setFixedHeight(headerHeight + itemAreaHeight + 3);
} }
@@ -121,7 +121,7 @@ void DeviceFilterGUI::store(QString& command, QString& parameters)
void DeviceFilterGUI::on_pushButton_clicked() void DeviceFilterGUI::on_pushButton_clicked()
{ {
DeviceFilterGUIDialog dialog(this, factory, pattern); DeviceFilterGUIDialog dialog(this, factory, pattern);
if(dialog.exec() == QDialog::Accepted) if (dialog.exec() == QDialog::Accepted)
{ {
load(dialog.getPattern()); load(dialog.getPattern());
emit updateModel(); emit updateModel();
+1 -1
View File
@@ -40,7 +40,7 @@ private slots:
void on_pushButton_clicked(); void on_pushButton_clicked();
private: private:
Ui::DeviceFilterGUI *ui; Ui::DeviceFilterGUI* ui;
DeviceFilterGUIFactory* factory; DeviceFilterGUIFactory* factory;
QString pattern; QString pattern;
}; };
+15 -15
View File
@@ -24,8 +24,8 @@
using namespace std; using namespace std;
DeviceFilterGUIDialog::DeviceFilterGUIDialog(DeviceFilterGUI* gui, DeviceFilterGUIFactory* factory, const QString& pattern) : DeviceFilterGUIDialog::DeviceFilterGUIDialog(DeviceFilterGUI* gui, DeviceFilterGUIFactory* factory, const QString& pattern)
QDialog(gui), : QDialog(gui),
ui(new Ui::DeviceFilterGUIDialog) ui(new Ui::DeviceFilterGUIDialog)
{ {
ui->setupUi(this); ui->setupUi(this);
@@ -43,13 +43,13 @@ DeviceFilterGUIDialog::DeviceFilterGUIDialog(DeviceFilterGUI* gui, DeviceFilterG
QTreeWidgetItem* inputNode = new QTreeWidgetItem(ui->treeWidget, QStringList(tr("Capture devices"))); QTreeWidgetItem* inputNode = new QTreeWidgetItem(ui->treeWidget, QStringList(tr("Capture devices")));
inputNode->setExpanded(true); inputNode->setExpanded(true);
const QList<DeviceAPOInfo>& devices = factory->getDevices(); const QList<DeviceAPOInfo>& devices = factory->getDevices();
for(const DeviceAPOInfo& apoInfo : devices) for (const DeviceAPOInfo& apoInfo : devices)
{ {
QStringList values; QStringList values;
values.append(QString::fromStdWString(apoInfo.connectionName)); values.append(QString::fromStdWString(apoInfo.connectionName));
values.append(QString::fromStdWString(apoInfo.deviceName)); values.append(QString::fromStdWString(apoInfo.deviceName));
QString state; QString state;
if(apoInfo.isInstalled) if (apoInfo.isInstalled)
state = tr("APO installed"); state = tr("APO installed");
else else
state = tr("APO not installed"); state = tr("APO not installed");
@@ -61,12 +61,12 @@ DeviceFilterGUIDialog::DeviceFilterGUIDialog(DeviceFilterGUI* gui, DeviceFilterG
item->setCheckState(0, matches ? Qt::Checked : Qt::Unchecked); item->setCheckState(0, matches ? Qt::Checked : Qt::Unchecked);
item->setData(0, Qt::UserRole, QVariant::fromValue(&apoInfo)); item->setData(0, Qt::UserRole, QVariant::fromValue(&apoInfo));
item->setHidden(!matches && !apoInfo.isInstalled && ui->showOnlyInstalledCheckBox->isChecked()); item->setHidden(!matches && !apoInfo.isInstalled && ui->showOnlyInstalledCheckBox->isChecked());
if(!apoInfo.isInstalled) if (!apoInfo.isInstalled)
for(int i = 0; i < ui->treeWidget->columnCount(); i++) for (int i = 0; i < ui->treeWidget->columnCount(); i++)
item->setForeground(i, QBrush(Qt::gray)); item->setForeground(i, QBrush(Qt::gray));
} }
for(int i = 0; i < ui->treeWidget->columnCount(); i++) for (int i = 0; i < ui->treeWidget->columnCount(); i++)
ui->treeWidget->resizeColumnToContents(i); ui->treeWidget->resizeColumnToContents(i);
} }
@@ -77,22 +77,22 @@ DeviceFilterGUIDialog::~DeviceFilterGUIDialog()
QString DeviceFilterGUIDialog::getPattern() QString DeviceFilterGUIDialog::getPattern()
{ {
if(ui->allDevicesCheckBox->isChecked()) if (ui->allDevicesCheckBox->isChecked())
{ {
return "all"; return "all";
} }
else else
{ {
QString pattern = ""; QString pattern = "";
for(int i = 0; i < ui->treeWidget->topLevelItemCount(); i++) for (int i = 0; i < ui->treeWidget->topLevelItemCount(); i++)
{ {
QTreeWidgetItem* groupItem = ui->treeWidget->topLevelItem(i); QTreeWidgetItem* groupItem = ui->treeWidget->topLevelItem(i);
for(int j = 0; j < groupItem->childCount(); j++) for (int j = 0; j < groupItem->childCount(); j++)
{ {
QTreeWidgetItem* item = groupItem->child(j); QTreeWidgetItem* item = groupItem->child(j);
if(item->checkState(0) == Qt::Checked) if (item->checkState(0) == Qt::Checked)
{ {
if(pattern != "") if (pattern != "")
pattern += "; "; pattern += "; ";
const DeviceAPOInfo* apoInfo = item->data(0, Qt::UserRole).value<const DeviceAPOInfo*>(); const DeviceAPOInfo* apoInfo = item->data(0, Qt::UserRole).value<const DeviceAPOInfo*>();
wstring deviceString = apoInfo->connectionName + L" " + apoInfo->deviceName + L" " + apoInfo->deviceGuid; wstring deviceString = apoInfo->connectionName + L" " + apoInfo->deviceName + L" " + apoInfo->deviceGuid;
@@ -112,10 +112,10 @@ void DeviceFilterGUIDialog::on_allDevicesCheckBox_toggled(bool checked)
void DeviceFilterGUIDialog::on_showOnlyInstalledCheckBox_toggled(bool checked) void DeviceFilterGUIDialog::on_showOnlyInstalledCheckBox_toggled(bool checked)
{ {
for(int i = 0; i < ui->treeWidget->topLevelItemCount(); i++) for (int i = 0; i < ui->treeWidget->topLevelItemCount(); i++)
{ {
QTreeWidgetItem* groupItem = ui->treeWidget->topLevelItem(i); QTreeWidgetItem* groupItem = ui->treeWidget->topLevelItem(i);
for(int j = 0; j < groupItem->childCount(); j++) for (int j = 0; j < groupItem->childCount(); j++)
{ {
QTreeWidgetItem* item = groupItem->child(j); QTreeWidgetItem* item = groupItem->child(j);
const DeviceAPOInfo* apoInfo = item->data(0, Qt::UserRole).value<const DeviceAPOInfo*>(); const DeviceAPOInfo* apoInfo = item->data(0, Qt::UserRole).value<const DeviceAPOInfo*>();
@@ -123,6 +123,6 @@ void DeviceFilterGUIDialog::on_showOnlyInstalledCheckBox_toggled(bool checked)
} }
} }
for(int i = 0; i < ui->treeWidget->columnCount(); i++) for (int i = 0; i < ui->treeWidget->columnCount(); i++)
ui->treeWidget->resizeColumnToContents(i); ui->treeWidget->resizeColumnToContents(i);
} }
+2 -2
View File
@@ -33,7 +33,7 @@ class DeviceFilterGUIDialog : public QDialog
Q_OBJECT Q_OBJECT
public: public:
explicit DeviceFilterGUIDialog( DeviceFilterGUI* gui, DeviceFilterGUIFactory* factory, const QString& pattern); explicit DeviceFilterGUIDialog(DeviceFilterGUI* gui, DeviceFilterGUIFactory* factory, const QString& pattern);
~DeviceFilterGUIDialog(); ~DeviceFilterGUIDialog();
QString getPattern(); QString getPattern();
@@ -44,7 +44,7 @@ private slots:
void on_showOnlyInstalledCheckBox_toggled(bool checked); void on_showOnlyInstalledCheckBox_toggled(bool checked);
private: private:
Ui::DeviceFilterGUIDialog *ui; Ui::DeviceFilterGUIDialog* ui;
}; };
Q_DECLARE_METATYPE(const DeviceAPOInfo*) Q_DECLARE_METATYPE(const DeviceAPOInfo*)
+1 -1
View File
@@ -42,7 +42,7 @@ IFilterGUI* DeviceFilterGUIFactory::createFilterGUI(QString& command, QString& p
{ {
DeviceFilterGUI* result = NULL; DeviceFilterGUI* result = NULL;
if(command == "Device") if (command == "Device")
{ {
result = new DeviceFilterGUI(this); result = new DeviceFilterGUI(this);
result->load(parameters); result->load(parameters);
+1 -1
View File
@@ -22,7 +22,7 @@
IFilterGUI* ExpressionFilterGUIFactory::createFilterGUI(QString& command, QString& parameters) IFilterGUI* ExpressionFilterGUIFactory::createFilterGUI(QString& command, QString& parameters)
{ {
// do not create a gui if parameters contain expressions // do not create a gui if parameters contain expressions
if(parameters.contains('`')) if (parameters.contains('`'))
command = ""; command = "";
return NULL; return NULL;
+44 -44
View File
@@ -36,8 +36,8 @@ using namespace std;
QRegularExpression GraphicEQFilterGUI::numberRegEx("[-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?"); QRegularExpression GraphicEQFilterGUI::numberRegEx("[-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?");
GraphicEQFilterGUI::GraphicEQFilterGUI(GraphicEQFilter* filter, QString configPath, FilterTable* filterTable) : GraphicEQFilterGUI::GraphicEQFilterGUI(GraphicEQFilter* filter, QString configPath, FilterTable* filterTable)
ui(new Ui::GraphicEQFilterGUI), configPath(configPath) : ui(new Ui::GraphicEQFilterGUI), configPath(configPath)
{ {
ui->setupUi(this); ui->setupUi(this);
@@ -71,7 +71,7 @@ GraphicEQFilterGUI::GraphicEQFilterGUI(GraphicEQFilter* filter, QString configPa
scene->setNodes(filter->getNodes()); scene->setNodes(filter->getNodes());
int bandCount = scene->verifyBands(filter->getNodes()); int bandCount = scene->verifyBands(filter->getNodes());
switch(bandCount) switch (bandCount)
{ {
case 15: case 15:
ui->radioButton15->click(); ui->radioButton15->click();
@@ -91,14 +91,14 @@ GraphicEQFilterGUI::~GraphicEQFilterGUI()
delete ui; delete ui;
} }
void GraphicEQFilterGUI::store(QString & command, QString & parameters) void GraphicEQFilterGUI::store(QString& command, QString& parameters)
{ {
command = "GraphicEQ"; command = "GraphicEQ";
bool first = true; bool first = true;
for(FilterNode node : scene->getNodes()) for (FilterNode node : scene->getNodes())
{ {
if(first) if (first)
first = false; first = false;
else else
parameters += "; "; parameters += "; ";
@@ -113,7 +113,7 @@ void GraphicEQFilterGUI::loadPreferences(const QVariantMap& prefs)
ui->graphicsView->setFixedHeight(prefs.value("viewHeight", DEFAULT_VIEW_HEIGHT).toInt()); ui->graphicsView->setFixedHeight(prefs.value("viewHeight", DEFAULT_VIEW_HEIGHT).toInt());
double zoomX = prefs.value("zoomX", 1.0).toDouble(); double zoomX = prefs.value("zoomX", 1.0).toDouble();
double zoomY = prefs.value("zoomY", 1.0).toDouble(); double zoomY = prefs.value("zoomY", 1.0).toDouble();
if(zoomX != 1.0 || zoomY != 1.0) if (zoomX != 1.0 || zoomY != 1.0)
scene->setZoom(zoomX, zoomY); scene->setZoom(zoomX, zoomY);
int scrollX = prefs.value("scrollX", round(scene->hzToX(20))).toInt(); int scrollX = prefs.value("scrollX", round(scene->hzToX(20))).toInt();
int scrollY = prefs.value("scrollY", round(scene->dbToY(22))).toInt(); int scrollY = prefs.value("scrollY", round(scene->dbToY(22))).toInt();
@@ -122,21 +122,21 @@ void GraphicEQFilterGUI::loadPreferences(const QVariantMap& prefs)
void GraphicEQFilterGUI::storePreferences(QVariantMap& prefs) void GraphicEQFilterGUI::storePreferences(QVariantMap& prefs)
{ {
if(ui->tableWidget->width() != DEFAULT_TABLE_WIDTH) if (ui->tableWidget->width() != DEFAULT_TABLE_WIDTH)
prefs.insert("tableWidth", ui->tableWidget->width()); prefs.insert("tableWidth", ui->tableWidget->width());
if(ui->graphicsView->height() != DEFAULT_VIEW_HEIGHT) if (ui->graphicsView->height() != DEFAULT_VIEW_HEIGHT)
prefs.insert("viewHeight", ui->graphicsView->height()); prefs.insert("viewHeight", ui->graphicsView->height());
if(scene->getZoomX() != 1.0) if (scene->getZoomX() != 1.0)
prefs.insert("zoomX", scene->getZoomX()); prefs.insert("zoomX", scene->getZoomX());
if(scene->getZoomY() != 1.0) if (scene->getZoomY() != 1.0)
prefs.insert("zoomY", scene->getZoomY()); prefs.insert("zoomY", scene->getZoomY());
QScrollBar* hScrollBar = ui->graphicsView->horizontalScrollBar(); QScrollBar* hScrollBar = ui->graphicsView->horizontalScrollBar();
int value = hScrollBar->value(); int value = hScrollBar->value();
if(value != round(scene->hzToX(20))) if (value != round(scene->hzToX(20)))
prefs.insert("scrollX", value); prefs.insert("scrollX", value);
QScrollBar* vScrollBar = ui->graphicsView->verticalScrollBar(); QScrollBar* vScrollBar = ui->graphicsView->verticalScrollBar();
value = vScrollBar->value(); value = vScrollBar->value();
if(value != round(scene->dbToY(22))) if (value != round(scene->dbToY(22)))
prefs.insert("scrollY", value); prefs.insert("scrollY", value);
} }
@@ -180,7 +180,7 @@ void GraphicEQFilterGUI::moveRow(int fromIndex, int toIndex)
ui->tableWidget->insertRow(toIndex); ui->tableWidget->insertRow(toIndex);
ui->tableWidget->setItem(toIndex, 0, freqItem); ui->tableWidget->setItem(toIndex, 0, freqItem);
ui->tableWidget->setItem(toIndex, 1, gainItem); ui->tableWidget->setItem(toIndex, 1, gainItem);
if(selected) if (selected)
{ {
QModelIndex modelIndex = ui->tableWidget->model()->index(toIndex, 0); QModelIndex modelIndex = ui->tableWidget->model()->index(toIndex, 0);
ui->tableWidget->selectionModel()->select(modelIndex, QItemSelectionModel::Rows | QItemSelectionModel::Select); ui->tableWidget->selectionModel()->select(modelIndex, QItemSelectionModel::Rows | QItemSelectionModel::Select);
@@ -193,7 +193,7 @@ void GraphicEQFilterGUI::selectRow(int index, bool select)
{ {
ui->tableWidget->blockSignals(true); ui->tableWidget->blockSignals(true);
QItemSelectionModel::SelectionFlags command = QItemSelectionModel::Rows; QItemSelectionModel::SelectionFlags command = QItemSelectionModel::Rows;
if(select) if (select)
command |= QItemSelectionModel::Select; command |= QItemSelectionModel::Select;
else else
command |= QItemSelectionModel::Deselect; command |= QItemSelectionModel::Deselect;
@@ -205,12 +205,12 @@ void GraphicEQFilterGUI::selectRow(int index, bool select)
void GraphicEQFilterGUI::on_tableWidget_cellChanged(int row, int column) void GraphicEQFilterGUI::on_tableWidget_cellChanged(int row, int column)
{ {
if(column == 0) if (column == 0)
{ {
QTableWidgetItem* freqItem = ui->tableWidget->item(row, 0); QTableWidgetItem* freqItem = ui->tableWidget->item(row, 0);
bool ok; bool ok;
double freq = freqItem->text().toDouble(&ok); double freq = freqItem->text().toDouble(&ok);
if(ok) if (ok)
{ {
double gain = scene->getNodes()[row].dbGain; double gain = scene->getNodes()[row].dbGain;
scene->setNode(row, freq, gain); scene->setNode(row, freq, gain);
@@ -221,12 +221,12 @@ void GraphicEQFilterGUI::on_tableWidget_cellChanged(int row, int column)
freqItem->setText(QString("%0").arg(freq)); freqItem->setText(QString("%0").arg(freq));
} }
} }
else if(column == 1) else if (column == 1)
{ {
QTableWidgetItem* gainItem = ui->tableWidget->item(row, 1); QTableWidgetItem* gainItem = ui->tableWidget->item(row, 1);
bool ok; bool ok;
double gain = gainItem->text().toDouble(&ok); double gain = gainItem->text().toDouble(&ok);
if(ok) if (ok)
{ {
double freq = scene->getNodes()[row].freq; double freq = scene->getNodes()[row].freq;
scene->setNode(row, freq, gain); scene->setNode(row, freq, gain);
@@ -242,7 +242,7 @@ void GraphicEQFilterGUI::on_tableWidget_cellChanged(int row, int column)
void GraphicEQFilterGUI::on_tableWidget_itemSelectionChanged() void GraphicEQFilterGUI::on_tableWidget_itemSelectionChanged()
{ {
QSet<int> selectedRows; QSet<int> selectedRows;
for(QTableWidgetItem* item : ui->tableWidget->selectedItems()) for (QTableWidgetItem* item : ui->tableWidget->selectedItems())
selectedRows.insert(item->row()); selectedRows.insert(item->row());
scene->setSelectedNodes(selectedRows); scene->setSelectedNodes(selectedRows);
@@ -250,7 +250,7 @@ void GraphicEQFilterGUI::on_tableWidget_itemSelectionChanged()
void GraphicEQFilterGUI::on_radioButton15_toggled(bool checked) void GraphicEQFilterGUI::on_radioButton15_toggled(bool checked)
{ {
if(checked) if (checked)
{ {
scene->setBandCount(15); scene->setBandCount(15);
setFreqEditable(false); setFreqEditable(false);
@@ -259,7 +259,7 @@ void GraphicEQFilterGUI::on_radioButton15_toggled(bool checked)
void GraphicEQFilterGUI::on_radioButton31_toggled(bool checked) void GraphicEQFilterGUI::on_radioButton31_toggled(bool checked)
{ {
if(checked) if (checked)
{ {
scene->setBandCount(31); scene->setBandCount(31);
setFreqEditable(false); setFreqEditable(false);
@@ -268,7 +268,7 @@ void GraphicEQFilterGUI::on_radioButton31_toggled(bool checked)
void GraphicEQFilterGUI::on_radioButtonVar_toggled(bool checked) void GraphicEQFilterGUI::on_radioButtonVar_toggled(bool checked)
{ {
if(checked) if (checked)
{ {
scene->setBandCount(-1); scene->setBandCount(-1);
setFreqEditable(true); setFreqEditable(true);
@@ -278,10 +278,10 @@ void GraphicEQFilterGUI::on_radioButtonVar_toggled(bool checked)
void GraphicEQFilterGUI::setFreqEditable(bool editable) void GraphicEQFilterGUI::setFreqEditable(bool editable)
{ {
ui->tableWidget->blockSignals(true); ui->tableWidget->blockSignals(true);
for(int i = 0; i < ui->tableWidget->rowCount(); i++) for (int i = 0; i < ui->tableWidget->rowCount(); i++)
{ {
QTableWidgetItem* item = ui->tableWidget->item(i, 0); QTableWidgetItem* item = ui->tableWidget->item(i, 0);
if(editable) if (editable)
item->setFlags(item->flags() | Qt::ItemIsEditable | Qt::ItemIsEnabled); item->setFlags(item->flags() | Qt::ItemIsEditable | Qt::ItemIsEnabled);
else else
item->setFlags(item->flags() & ~(Qt::ItemIsEditable | Qt::ItemIsEnabled)); item->setFlags(item->flags() & ~(Qt::ItemIsEditable | Qt::ItemIsEnabled));
@@ -298,32 +298,32 @@ void GraphicEQFilterGUI::on_actionImport_triggered()
nameFilters.append(tr("Frequency response (*.csv)")); nameFilters.append(tr("Frequency response (*.csv)"));
nameFilters.append(tr("All files (*.*)")); nameFilters.append(tr("All files (*.*)"));
dialog.setNameFilters(nameFilters); dialog.setNameFilters(nameFilters);
if(dialog.exec() == QDialog::Accepted) if (dialog.exec() == QDialog::Accepted)
{ {
vector<FilterNode> newNodes; vector<FilterNode> newNodes;
for(QString path : dialog.selectedFiles()) for (QString path : dialog.selectedFiles())
{ {
QFile file(path); QFile file(path);
if(file.open(QFile::ReadOnly)) if (file.open(QFile::ReadOnly))
{ {
QTextStream stream(&file); QTextStream stream(&file);
QString text = stream.readAll(); QString text = stream.readAll();
if(!text.contains('.')) if (!text.contains('.'))
text = text.replace(',', '.'); text = text.replace(',', '.');
QRegularExpressionMatchIterator it = numberRegEx.globalMatch(text); QRegularExpressionMatchIterator it = numberRegEx.globalMatch(text);
while(it.hasNext()) while (it.hasNext())
{ {
QRegularExpressionMatch match = it.next(); QRegularExpressionMatch match = it.next();
QString freqString = match.captured(); QString freqString = match.captured();
bool ok; bool ok;
double freq = freqString.toDouble(&ok); double freq = freqString.toDouble(&ok);
if(ok && it.hasNext()) if (ok && it.hasNext())
{ {
match = it.next(); match = it.next();
QString gainString = match.captured(); QString gainString = match.captured();
double gain = gainString.toDouble(&ok); double gain = gainString.toDouble(&ok);
if(ok) if (ok)
newNodes.push_back(FilterNode(freq, gain)); newNodes.push_back(FilterNode(freq, gain));
} }
} }
@@ -334,9 +334,9 @@ void GraphicEQFilterGUI::on_actionImport_triggered()
scene->setNodes(newNodes); scene->setNodes(newNodes);
int bandCount = scene->verifyBands(newNodes); int bandCount = scene->verifyBands(newNodes);
if(bandCount != scene->getBandCount()) if (bandCount != scene->getBandCount())
{ {
switch(bandCount) switch (bandCount)
{ {
case 15: case 15:
ui->radioButton15->click(); ui->radioButton15->click();
@@ -367,15 +367,15 @@ void GraphicEQFilterGUI::on_actionExport_triggered()
dialog.setNameFilters(nameFilters); dialog.setNameFilters(nameFilters);
dialog.setDefaultSuffix(".csv"); dialog.setDefaultSuffix(".csv");
if(dialog.exec() == QDialog::Accepted) if (dialog.exec() == QDialog::Accepted)
{ {
QString savePath = dialog.selectedFiles().first(); QString savePath = dialog.selectedFiles().first();
QFile file(savePath); QFile file(savePath);
if(file.open(QFile::WriteOnly | QFile::Truncate)) if (file.open(QFile::WriteOnly | QFile::Truncate))
{ {
QTextStream stream(&file); QTextStream stream(&file);
for(FilterNode node : scene->getNodes()) for (FilterNode node : scene->getNodes())
{ {
stream << node.freq << '\t' << node.dbGain << '\n'; stream << node.freq << '\t' << node.dbGain << '\n';
} }
@@ -387,7 +387,7 @@ void GraphicEQFilterGUI::on_actionExport_triggered()
void GraphicEQFilterGUI::on_actionInvertResponse_triggered() void GraphicEQFilterGUI::on_actionInvertResponse_triggered()
{ {
vector<FilterNode> newNodes = scene->getNodes(); vector<FilterNode> newNodes = scene->getNodes();
for(FilterNode& node : newNodes) for (FilterNode& node : newNodes)
node.dbGain = -node.dbGain; node.dbGain = -node.dbGain;
scene->setNodes(newNodes); scene->setNodes(newNodes);
@@ -399,15 +399,15 @@ void GraphicEQFilterGUI::on_actionNormalizeResponse_triggered()
vector<FilterNode> newNodes = scene->getNodes(); vector<FilterNode> newNodes = scene->getNodes();
double maxGain = -DBL_MAX; double maxGain = -DBL_MAX;
for(FilterNode node : newNodes) for (FilterNode node : newNodes)
{ {
if(node.dbGain > maxGain) if (node.dbGain > maxGain)
maxGain = node.dbGain; maxGain = node.dbGain;
} }
if(maxGain != 0) if (maxGain != 0)
{ {
for(FilterNode& node : newNodes) for (FilterNode& node : newNodes)
node.dbGain -= maxGain; node.dbGain -= maxGain;
scene->setNodes(newNodes); scene->setNodes(newNodes);
@@ -421,9 +421,9 @@ void GraphicEQFilterGUI::on_actionResetResponse_triggered()
QSet<int> selectedIndices = scene->getSelectedIndices(); QSet<int> selectedIndices = scene->getSelectedIndices();
int index = 0; int index = 0;
for(FilterNode& node : newNodes) for (FilterNode& node : newNodes)
{ {
if(selectedIndices.isEmpty() || selectedIndices.contains(index)) if (selectedIndices.isEmpty() || selectedIndices.contains(index))
node.dbGain = 0.0; node.dbGain = 0.0;
index++; index++;
} }
+1 -1
View File
@@ -67,7 +67,7 @@ private slots:
private: private:
void setFreqEditable(bool editable); void setFreqEditable(bool editable);
Ui::GraphicEQFilterGUI *ui; Ui::GraphicEQFilterGUI* ui;
GraphicEQFilterGUIScene* scene; GraphicEQFilterGUIScene* scene;
QString configPath; QString configPath;
static QRegularExpression numberRegEx; static QRegularExpression numberRegEx;
+3 -3
View File
@@ -49,17 +49,17 @@ IFilterGUI* GraphicEQFilterGUIFactory::createFilterGUI(QString& command, QString
{ {
GraphicEQFilterGUI* result = NULL; GraphicEQFilterGUI* result = NULL;
if(command == "GraphicEQ") if (command == "GraphicEQ")
{ {
GraphicEQFilterFactory factory; GraphicEQFilterFactory factory;
std::vector<IFilter*> filters = factory.createFilter(L"", command.toStdWString(), parameters.toStdWString()); std::vector<IFilter*> filters = factory.createFilter(L"", command.toStdWString(), parameters.toStdWString());
if(!filters.empty()) if (!filters.empty())
{ {
GraphicEQFilter* filter = (GraphicEQFilter*)filters[0]; GraphicEQFilter* filter = (GraphicEQFilter*)filters[0];
result = new GraphicEQFilterGUI(filter, configPath, filterTable); result = new GraphicEQFilterGUI(filter, configPath, filterTable);
} }
for(IFilter* f : filters) for (IFilter* f : filters)
{ {
f->~IFilter(); f->~IFilter();
MemoryHelper::free(f); MemoryHelper::free(f);
+7 -7
View File
@@ -46,12 +46,12 @@ QPainterPath GraphicEQFilterGUIItem::shape() const
void GraphicEQFilterGUIItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) void GraphicEQFilterGUIItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
{ {
painter->setBrush(Qt::white); painter->setBrush(Qt::white);
if(isSelected()) if (isSelected())
painter->setBrush(QColor(38, 147, 255)); painter->setBrush(QColor(38, 147, 255));
painter->drawPath(shape()); painter->drawPath(shape());
if(index < 99) if (index < 99)
{ {
if(isSelected()) if (isSelected())
painter->setPen(Qt::white); painter->setPen(Qt::white);
QFont font; QFont font;
@@ -68,20 +68,20 @@ QVariant GraphicEQFilterGUIItem::itemChange(QGraphicsItem::GraphicsItemChange ch
{ {
QVariant result = QGraphicsItem::itemChange(change, value); QVariant result = QGraphicsItem::itemChange(change, value);
if(change == ItemScenePositionHasChanged) if (change == ItemScenePositionHasChanged)
{ {
GraphicEQFilterGUIScene* s = qobject_cast<GraphicEQFilterGUIScene*>(scene()); GraphicEQFilterGUIScene* s = qobject_cast<GraphicEQFilterGUIScene*>(scene());
s->itemMoved(index); s->itemMoved(index);
} }
else if(change == ItemSelectedHasChanged) else if (change == ItemSelectedHasChanged)
{ {
GraphicEQFilterGUIScene* s = qobject_cast<GraphicEQFilterGUIScene*>(scene()); GraphicEQFilterGUIScene* s = qobject_cast<GraphicEQFilterGUIScene*>(scene());
s->itemSelectionChanged(index, value.toBool()); s->itemSelectionChanged(index, value.toBool());
} }
else if(change == ItemPositionChange) else if (change == ItemPositionChange)
{ {
GraphicEQFilterGUIScene* s = qobject_cast<GraphicEQFilterGUIScene*>(scene()); GraphicEQFilterGUIScene* s = qobject_cast<GraphicEQFilterGUIScene*>(scene());
if(s->getBandCount() != -1) if (s->getBandCount() != -1)
{ {
QPointF newPos = value.toPointF(); QPointF newPos = value.toPointF();
newPos.setX(s->hzToX(getHz())); newPos.setX(s->hzToX(getHz()));
+2 -2
View File
@@ -21,12 +21,12 @@
#include "Editor/widgets/FrequencyPlotItem.h" #include "Editor/widgets/FrequencyPlotItem.h"
class GraphicEQFilterGUIItem: public FrequencyPlotItem class GraphicEQFilterGUIItem : public FrequencyPlotItem
{ {
public: public:
GraphicEQFilterGUIItem(int index, double hz, double db); GraphicEQFilterGUIItem(int index, double hz, double db);
enum { Type = UserType + 2 }; enum {Type = UserType + 2};
virtual int type() const virtual int type() const
{ {
return Type; return Type;
+54 -54
View File
@@ -26,8 +26,8 @@
using namespace std; using namespace std;
GraphicEQFilterGUIScene::GraphicEQFilterGUIScene(QObject* parent) : GraphicEQFilterGUIScene::GraphicEQFilterGUIScene(QObject* parent)
FrequencyPlotScene(parent) : FrequencyPlotScene(parent)
{ {
} }
@@ -35,13 +35,13 @@ void GraphicEQFilterGUIScene::setNodes(const std::vector<FilterNode>& nodes)
{ {
noUpdateModel = true; noUpdateModel = true;
for(int i = (int)this->nodes.size() - 1; i >= 0; i--) for (int i = (int)this->nodes.size() - 1; i >= 0; i--)
removeNode(i); removeNode(i);
this->nodes = nodes; this->nodes = nodes;
int i = 0; int i = 0;
for(FilterNode node : nodes) for (FilterNode node : nodes)
{ {
GraphicEQFilterGUIItem* item = new GraphicEQFilterGUIItem(i, node.freq, node.dbGain); GraphicEQFilterGUIItem* item = new GraphicEQFilterGUIItem(i, node.freq, node.dbGain);
addItem(item); addItem(item);
@@ -67,20 +67,20 @@ void GraphicEQFilterGUIScene::addNode(double hz, double db)
addItem(item); addItem(item);
item->updatePos(); item->updatePos();
items.insert(index, item); items.insert(index, item);
for(int i = index + 1; i < items.size(); i++) for (int i = index + 1; i < items.size(); i++)
items[i]->setIndex(i); items[i]->setIndex(i);
emit nodeInserted(index, hz, db); emit nodeInserted(index, hz, db);
QRectF rect = sceneRect(); QRectF rect = sceneRect();
if(index > 0) if (index > 0)
rect.setLeft(items[index - 1]->x()); rect.setLeft(items[index - 1]->x());
if(index + 1 < items.size()) if (index + 1 < items.size())
rect.setRight(items[index + 1]->x()); rect.setRight(items[index + 1]->x());
update(rect); update(rect);
for(int i = index + 1; i < items.size(); i++) for (int i = index + 1; i < items.size(); i++)
items[i]->update(); items[i]->update();
if(!noUpdateModel) if (!noUpdateModel)
emit updateModel(); emit updateModel();
} }
@@ -90,20 +90,20 @@ void GraphicEQFilterGUIScene::removeNode(int index)
GraphicEQFilterGUIItem* item = items[index]; GraphicEQFilterGUIItem* item = items[index];
removeItem(item); removeItem(item);
items.removeAt(index); items.removeAt(index);
for(int i = index; i < items.size(); i++) for (int i = index; i < items.size(); i++)
items[i]->setIndex(i); items[i]->setIndex(i);
emit nodeRemoved(index); emit nodeRemoved(index);
QRectF rect = sceneRect(); QRectF rect = sceneRect();
if(index > 0) if (index > 0)
rect.setLeft(items[index - 1]->x()); rect.setLeft(items[index - 1]->x());
if(index < items.size()) if (index < items.size())
rect.setRight(items[index]->x()); rect.setRight(items[index]->x());
update(rect); update(rect);
for(int i = index; i < items.size(); i++) for (int i = index; i < items.size(); i++)
items[i]->update(); items[i]->update();
if(!noUpdateModel) if (!noUpdateModel)
emit updateModel(); emit updateModel();
} }
@@ -117,24 +117,24 @@ void GraphicEQFilterGUIScene::setNode(int index, double hz, double db)
FilterNode node(hz, db); FilterNode node(hz, db);
vector<FilterNode>::iterator it = lower_bound(nodes.begin(), nodes.end(), node); vector<FilterNode>::iterator it = lower_bound(nodes.begin(), nodes.end(), node);
int newIndex = it - nodes.begin(); int newIndex = it - nodes.begin();
if(newIndex > index) if (newIndex > index)
newIndex--; newIndex--;
if(newIndex != index) if (newIndex != index)
{ {
items.move(index, newIndex); items.move(index, newIndex);
if(newIndex < index) if (newIndex < index)
{ {
for(int i = index; i > newIndex; i--) for (int i = index; i > newIndex; i--)
nodes[i] = nodes[i - 1]; nodes[i] = nodes[i - 1];
for(int i = newIndex; i <= index; i++) for (int i = newIndex; i <= index; i++)
items[i]->setIndex(i); items[i]->setIndex(i);
emit nodeMoved(index, newIndex); emit nodeMoved(index, newIndex);
} }
else else
{ {
for(int i = index; i < newIndex; i++) for (int i = index; i < newIndex; i++)
nodes[i] = nodes[i + 1]; nodes[i] = nodes[i + 1];
for(int i = index; i <= newIndex; i++) for (int i = index; i <= newIndex; i++)
items[i]->setIndex(i); items[i]->setIndex(i);
emit nodeMoved(index, newIndex); emit nodeMoved(index, newIndex);
} }
@@ -145,19 +145,19 @@ void GraphicEQFilterGUIScene::setNode(int index, double hz, double db)
QRectF rect = sceneRect(); QRectF rect = sceneRect();
int lowerIndex = min(index, newIndex); int lowerIndex = min(index, newIndex);
int upperIndex = max(index, newIndex); int upperIndex = max(index, newIndex);
if(lowerIndex > 0) if (lowerIndex > 0)
rect.setLeft(items[lowerIndex - 1]->x()); rect.setLeft(items[lowerIndex - 1]->x());
if(upperIndex + 1 < items.size()) if (upperIndex + 1 < items.size())
rect.setRight(items[upperIndex + 1]->x()); rect.setRight(items[upperIndex + 1]->x());
update(rect); update(rect);
if(!noUpdateModel) if (!noUpdateModel)
emit updateModel(); emit updateModel();
} }
void GraphicEQFilterGUIScene::setSelectedNodes(QSet<int> indices) void GraphicEQFilterGUIScene::setSelectedNodes(QSet<int> indices)
{ {
for(GraphicEQFilterGUIItem* item : items) for (GraphicEQFilterGUIItem* item : items)
item->setSelected(indices.contains(item->getIndex())); item->setSelected(indices.contains(item->getIndex()));
} }
@@ -165,8 +165,8 @@ QSet<int> GraphicEQFilterGUIScene::getSelectedIndices()
{ {
QSet<int> set; QSet<int> set;
for(GraphicEQFilterGUIItem* item : items) for (GraphicEQFilterGUIItem* item : items)
if(item->isSelected()) if (item->isSelected())
set.insert(item->getIndex()); set.insert(item->getIndex());
return set; return set;
@@ -178,29 +178,29 @@ void GraphicEQFilterGUIScene::itemMoved(int index)
double db = yToDb(item->scenePos().y()); double db = yToDb(item->scenePos().y());
double oldHz = item->getHz(); double oldHz = item->getHz();
double hz; double hz;
if(getBandCount() != -1) if (getBandCount() != -1)
{ {
hz = oldHz; hz = oldHz;
} }
else else
{ {
hz = xToHz(item->scenePos().x()); hz = xToHz(item->scenePos().x());
if(hz >= 10000) if (hz >= 10000)
hz = round(hz); hz = round(hz);
else else
hz = round(hz * 10) / 10; hz = round(hz * 10) / 10;
item->setHz(hz); item->setHz(hz);
} }
if(getZoomY() < 4) if (getZoomY() < 4)
db = round(db * 10) / 10; db = round(db * 10) / 10;
else else
db = round(db * 100) / 100; db = round(db * 100) / 100;
item->setDb(db); item->setDb(db);
int newIndex = index; int newIndex = index;
if(hz < oldHz) if (hz < oldHz)
{ {
while(newIndex > 0 && nodes[newIndex - 1].freq > hz) while (newIndex > 0 && nodes[newIndex - 1].freq > hz)
{ {
nodes[newIndex] = nodes[newIndex - 1]; nodes[newIndex] = nodes[newIndex - 1];
items[newIndex] = items[newIndex - 1]; items[newIndex] = items[newIndex - 1];
@@ -208,9 +208,9 @@ void GraphicEQFilterGUIScene::itemMoved(int index)
newIndex--; newIndex--;
} }
} }
else if(hz > oldHz) else if (hz > oldHz)
{ {
while(newIndex < (int)nodes.size() - 1 && nodes[newIndex + 1].freq < hz) while (newIndex < (int)nodes.size() - 1 && nodes[newIndex + 1].freq < hz)
{ {
nodes[newIndex] = nodes[newIndex + 1]; nodes[newIndex] = nodes[newIndex + 1];
items[newIndex] = items[newIndex + 1]; items[newIndex] = items[newIndex + 1];
@@ -219,7 +219,7 @@ void GraphicEQFilterGUIScene::itemMoved(int index)
} }
} }
nodes[newIndex] = FilterNode(hz, db); nodes[newIndex] = FilterNode(hz, db);
if(newIndex != index) if (newIndex != index)
{ {
items[newIndex] = item; items[newIndex] = item;
item->setIndex(newIndex); item->setIndex(newIndex);
@@ -230,13 +230,13 @@ void GraphicEQFilterGUIScene::itemMoved(int index)
QRectF rect = sceneRect(); QRectF rect = sceneRect();
int lowerIndex = min(index, newIndex); int lowerIndex = min(index, newIndex);
int upperIndex = max(index, newIndex); int upperIndex = max(index, newIndex);
if(lowerIndex > 0) if (lowerIndex > 0)
rect.setLeft(items[lowerIndex - 1]->x()); rect.setLeft(items[lowerIndex - 1]->x());
if(upperIndex + 1 < items.size()) if (upperIndex + 1 < items.size())
rect.setRight(items[upperIndex + 1]->x()); rect.setRight(items[upperIndex + 1]->x());
update(rect); update(rect);
if(!noUpdateModel) if (!noUpdateModel)
emit updateModel(); emit updateModel();
} }
@@ -247,7 +247,7 @@ void GraphicEQFilterGUIScene::itemSelectionChanged(int index, bool selected)
void GraphicEQFilterGUIScene::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event) void GraphicEQFilterGUIScene::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event)
{ {
if(getBandCount() != -1) if (getBandCount() != -1)
return; return;
double hz = xToHz(event->scenePos().x()); double hz = xToHz(event->scenePos().x());
@@ -257,15 +257,15 @@ void GraphicEQFilterGUIScene::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* ev
void GraphicEQFilterGUIScene::keyPressEvent(QKeyEvent* event) void GraphicEQFilterGUIScene::keyPressEvent(QKeyEvent* event)
{ {
switch(event->key()) switch (event->key())
{ {
case Qt::Key_Delete: case Qt::Key_Delete:
if(getBandCount() == -1) if (getBandCount() == -1)
{ {
for(QGraphicsItem* item : selectedItems()) for (QGraphicsItem* item : selectedItems())
{ {
GraphicEQFilterGUIItem* plotItem = qgraphicsitem_cast<GraphicEQFilterGUIItem*>(item); GraphicEQFilterGUIItem* plotItem = qgraphicsitem_cast<GraphicEQFilterGUIItem*>(item);
if(plotItem != NULL) if (plotItem != NULL)
{ {
// this works for multiple items because the index of the other items is updated inside removeNode // this works for multiple items because the index of the other items is updated inside removeNode
int index = plotItem->getIndex(); int index = plotItem->getIndex();
@@ -279,14 +279,14 @@ void GraphicEQFilterGUIScene::keyPressEvent(QKeyEvent* event)
case Qt::Key_Down: case Qt::Key_Down:
case Qt::Key_Left: case Qt::Key_Left:
case Qt::Key_Right: case Qt::Key_Right:
for(QGraphicsItem* item : selectedItems()) for (QGraphicsItem* item : selectedItems())
{ {
GraphicEQFilterGUIItem* plotItem = qgraphicsitem_cast<GraphicEQFilterGUIItem*>(item); GraphicEQFilterGUIItem* plotItem = qgraphicsitem_cast<GraphicEQFilterGUIItem*>(item);
if(plotItem != NULL) if (plotItem != NULL)
{ {
int index = plotItem->getIndex(); int index = plotItem->getIndex();
FilterNode node = nodes[index]; FilterNode node = nodes[index];
switch(event->key()) switch (event->key())
{ {
case Qt::Key_Up: case Qt::Key_Up:
node.dbGain += 1; node.dbGain += 1;
@@ -307,7 +307,7 @@ void GraphicEQFilterGUIScene::keyPressEvent(QKeyEvent* event)
break; break;
case Qt::Key_A: case Qt::Key_A:
if(event->modifiers() & Qt::ControlModifier) if (event->modifiers() & Qt::ControlModifier)
{ {
QPainterPath painterPath; QPainterPath painterPath;
painterPath.addRect(sceneRect()); painterPath.addRect(sceneRect());
@@ -327,12 +327,12 @@ int GraphicEQFilterGUIScene::verifyBands(const std::vector<FilterNode>& nodes)
const vector<double>& bands = getBands((int)nodes.size()); const vector<double>& bands = getBands((int)nodes.size());
int bandCount = -1; int bandCount = -1;
if(!bands.empty()) if (!bands.empty())
{ {
bandCount = (int)nodes.size(); bandCount = (int)nodes.size();
for(unsigned i = 0; i < nodes.size(); i++) for (unsigned i = 0; i < nodes.size(); i++)
{ {
if(abs(nodes[i].freq - bands[i]) > 0.1) if (abs(nodes[i].freq - bands[i]) > 0.1)
{ {
bandCount = -1; bandCount = -1;
break; break;
@@ -345,14 +345,14 @@ int GraphicEQFilterGUIScene::verifyBands(const std::vector<FilterNode>& nodes)
void GraphicEQFilterGUIScene::setBandCount(int value) void GraphicEQFilterGUIScene::setBandCount(int value)
{ {
if(value != getBandCount()) if (value != getBandCount())
{ {
const vector<double>& bands = getBands(value); const vector<double>& bands = getBands(value);
if(!bands.empty()) if (!bands.empty())
{ {
vector<FilterNode> newNodes; vector<FilterNode> newNodes;
GainIterator gainIterator(nodes); GainIterator gainIterator(nodes);
for(double band : bands) for (double band : bands)
{ {
double dbGain = gainIterator.gainAt(band); double dbGain = gainIterator.gainAt(band);
dbGain = round(dbGain * 100) / 100; dbGain = round(dbGain * 100) / 100;
@@ -365,7 +365,7 @@ void GraphicEQFilterGUIScene::setBandCount(int value)
FrequencyPlotScene::setBandCount(value); FrequencyPlotScene::setBandCount(value);
if(!noUpdateModel) if (!noUpdateModel)
emit updateModel(); emit updateModel();
} }
} }
+1 -1
View File
@@ -29,7 +29,7 @@ class GraphicEQFilterGUIScene : public FrequencyPlotScene
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit GraphicEQFilterGUIScene(QObject *parent = 0); explicit GraphicEQFilterGUIScene(QObject* parent = 0);
void setNodes(const std::vector<FilterNode>& nodes); void setNodes(const std::vector<FilterNode>& nodes);
void addNode(double hz, double db); void addNode(double hz, double db);
void removeNode(int index); void removeNode(int index);
+5 -5
View File
@@ -20,8 +20,8 @@
#include "GraphicEQFilterGUIScene.h" #include "GraphicEQFilterGUIScene.h"
#include "GraphicEQFilterGUIView.h" #include "GraphicEQFilterGUIView.h"
GraphicEQFilterGUIView::GraphicEQFilterGUIView(QWidget *parent) : GraphicEQFilterGUIView::GraphicEQFilterGUIView(QWidget* parent)
FrequencyPlotView(parent) : FrequencyPlotView(parent)
{ {
} }
@@ -36,15 +36,15 @@ void GraphicEQFilterGUIView::drawBackground(QPainter* painter, const QRectF& rec
QPainterPath path; QPainterPath path;
bool first = true; bool first = true;
double lastDb = -1000; double lastDb = -1000;
for(int x = rect.left() - 1; x <= rect.right() + 1; x++) for (int x = rect.left() - 1; x <= rect.right() + 1; x++)
{ {
double hz = s->xToHz(x); double hz = s->xToHz(x);
double db = gainIterator.gainAt(hz); double db = gainIterator.gainAt(hz);
double y = s->dbToY(db); double y = s->dbToY(db);
if(db == lastDb) if (db == lastDb)
y = floor(y) + 0.5; y = floor(y) + 0.5;
lastDb = db; lastDb = db;
if(first) if (first)
{ {
path.moveTo(x, y); path.moveTo(x, y);
first = false; first = false;
+1 -1
View File
@@ -26,7 +26,7 @@ class GraphicEQFilterGUIView : public FrequencyPlotView
Q_OBJECT Q_OBJECT
public: public:
explicit GraphicEQFilterGUIView(QWidget *parent = 0); explicit GraphicEQFilterGUIView(QWidget* parent = 0);
protected: protected:
void drawBackground(QPainter* painter, const QRectF& rect) override; void drawBackground(QPainter* painter, const QRectF& rect) override;
+7 -7
View File
@@ -22,8 +22,8 @@
#include "IncludeFilterGUI.h" #include "IncludeFilterGUI.h"
#include "ui_IncludeFilterGUI.h" #include "ui_IncludeFilterGUI.h"
IncludeFilterGUI::IncludeFilterGUI(FilterTable* filterTable, const QString& path) : IncludeFilterGUI::IncludeFilterGUI(FilterTable* filterTable, const QString& path)
ui(new Ui::IncludeFilterGUI), filterTable(filterTable) : ui(new Ui::IncludeFilterGUI), filterTable(filterTable)
{ {
ui->setupUi(this); ui->setupUi(this);
@@ -46,19 +46,19 @@ void IncludeFilterGUI::on_selectFileToolButton_clicked()
QFileInfo fileInfo(filterTable->getConfigPath()); QFileInfo fileInfo(filterTable->getConfigPath());
QDir configDir = fileInfo.absoluteDir(); QDir configDir = fileInfo.absoluteDir();
QString path = ui->pathLineEdit->text(); QString path = ui->pathLineEdit->text();
if(path.length() > 0) if (path.length() > 0)
fileInfo.setFile(configDir, path); fileInfo.setFile(configDir, path);
QFileDialog dialog(this, tr("Include file"), fileInfo.absolutePath(), "*.txt"); QFileDialog dialog(this, tr("Include file"), fileInfo.absolutePath(), "*.txt");
dialog.setFileMode(QFileDialog::ExistingFile); dialog.setFileMode(QFileDialog::ExistingFile);
dialog.setNameFilter(tr("E-APO configurations (*.txt)")); dialog.setNameFilter(tr("E-APO configurations (*.txt)"));
if(path.length() > 0) if (path.length() > 0)
dialog.selectFile(fileInfo.fileName()); dialog.selectFile(fileInfo.fileName());
if(dialog.exec() == QDialog::Accepted) if (dialog.exec() == QDialog::Accepted)
{ {
QString absolutePath = dialog.selectedFiles().first(); QString absolutePath = dialog.selectedFiles().first();
QString relativePath = configDir.relativeFilePath(absolutePath); QString relativePath = configDir.relativeFilePath(absolutePath);
if(relativePath.startsWith("../../")) if (relativePath.startsWith("../../"))
relativePath = absolutePath; relativePath = absolutePath;
ui->pathLineEdit->setText(QDir::toNativeSeparators(relativePath)); ui->pathLineEdit->setText(QDir::toNativeSeparators(relativePath));
@@ -76,7 +76,7 @@ void IncludeFilterGUI::on_openFileToolButton_clicked()
QFileInfo fileInfo(filterTable->getConfigPath()); QFileInfo fileInfo(filterTable->getConfigPath());
QDir configDir = fileInfo.absoluteDir(); QDir configDir = fileInfo.absoluteDir();
QString path = ui->pathLineEdit->text(); QString path = ui->pathLineEdit->text();
if(path.length() > 0) if (path.length() > 0)
{ {
fileInfo.setFile(configDir, path); fileInfo.setFile(configDir, path);
+1 -1
View File
@@ -42,6 +42,6 @@ private slots:
void on_openFileToolButton_clicked(); void on_openFileToolButton_clicked();
private: private:
Ui::IncludeFilterGUI *ui; Ui::IncludeFilterGUI* ui;
FilterTable* filterTable; FilterTable* filterTable;
}; };
+1 -1
View File
@@ -40,7 +40,7 @@ IFilterGUI* IncludeFilterGUIFactory::createFilterGUI(QString& command, QString&
{ {
IncludeFilterGUI* result = NULL; IncludeFilterGUI* result = NULL;
if(command == "Include") if (command == "Include")
{ {
result = new IncludeFilterGUI(filterTable, parameters.trimmed()); result = new IncludeFilterGUI(filterTable, parameters.trimmed());
} }
+2 -2
View File
@@ -24,8 +24,8 @@
using namespace std; using namespace std;
PreampFilterGUI::PreampFilterGUI(double dbGain): PreampFilterGUI::PreampFilterGUI(double dbGain)
ui(new Ui::PreampFilterGUI) : ui(new Ui::PreampFilterGUI)
{ {
ui->setupUi(this); ui->setupUi(this);
+1 -2
View File
@@ -22,8 +22,7 @@
#include "Editor/IFilterGUI.h" #include "Editor/IFilterGUI.h"
#include <filters/PreampFilter.h> #include <filters/PreampFilter.h>
namespace Ui namespace Ui {
{
class PreampFilterGUI; class PreampFilterGUI;
} }
+3 -3
View File
@@ -32,17 +32,17 @@ IFilterGUI* PreampFilterGUIFactory::createFilterGUI(QString& command, QString& p
{ {
PreampFilterGUI* result = NULL; PreampFilterGUI* result = NULL;
if(command == "Preamp") if (command == "Preamp")
{ {
PreampFilterFactory factory; PreampFilterFactory factory;
std::vector<IFilter*> filters = factory.createFilter(L"", command.toStdWString(), parameters.toStdWString()); std::vector<IFilter*> filters = factory.createFilter(L"", command.toStdWString(), parameters.toStdWString());
if(!filters.empty()) if (!filters.empty())
{ {
PreampFilter* filter = (PreampFilter*)filters[0]; PreampFilter* filter = (PreampFilter*)filters[0];
result = new PreampFilterGUI(filter->getDbGain()); result = new PreampFilterGUI(filter->getDbGain());
} }
for(IFilter* f : filters) for (IFilter* f : filters)
{ {
f->~IFilter(); f->~IFilter();
MemoryHelper::free(f); MemoryHelper::free(f);
+5 -5
View File
@@ -20,8 +20,8 @@
#include "StageFilterGUI.h" #include "StageFilterGUI.h"
#include "ui_StageFilterGUI.h" #include "ui_StageFilterGUI.h"
StageFilterGUI::StageFilterGUI(const QString& parameters) : StageFilterGUI::StageFilterGUI(const QString& parameters)
ui(new Ui::StageFilterGUI) : ui(new Ui::StageFilterGUI)
{ {
ui->setupUi(this); ui->setupUi(this);
@@ -40,11 +40,11 @@ void StageFilterGUI::store(QString& command, QString& parameters)
{ {
command = "Stage"; command = "Stage";
QStringList list; QStringList list;
if(ui->preMixCheckBox->isChecked()) if (ui->preMixCheckBox->isChecked())
list.append("pre-mix"); list.append("pre-mix");
if(ui->postMixCheckBox->isChecked()) if (ui->postMixCheckBox->isChecked())
list.append("post-mix"); list.append("post-mix");
if(ui->captureCheckBox->isChecked()) if (ui->captureCheckBox->isChecked())
list.append("capture"); list.append("capture");
parameters = list.join(' '); parameters = list.join(' ');
+1 -1
View File
@@ -43,5 +43,5 @@ private slots:
void on_captureCheckBox_toggled(bool checked); void on_captureCheckBox_toggled(bool checked);
private: private:
Ui::StageFilterGUI *ui; Ui::StageFilterGUI* ui;
}; };
+1 -1
View File
@@ -31,7 +31,7 @@ IFilterGUI* StageFilterGUIFactory::createFilterGUI(QString& command, QString& pa
{ {
StageFilterGUI* result = NULL; StageFilterGUI* result = NULL;
if(command == "Stage") if (command == "Stage")
{ {
result = new StageFilterGUI(parameters); result = new StageFilterGUI(parameters);
} }
+4 -4
View File
@@ -21,17 +21,17 @@
#include "DisableWheelFilter.h" #include "DisableWheelFilter.h"
DisableWheelFilter::DisableWheelFilter(QObject* scrollTarget, QObject *parent) : DisableWheelFilter::DisableWheelFilter(QObject* scrollTarget, QObject* parent)
QObject(parent), scrollTarget(scrollTarget) : QObject(parent), scrollTarget(scrollTarget)
{ {
} }
bool DisableWheelFilter::eventFilter(QObject* obj, QEvent* event) bool DisableWheelFilter::eventFilter(QObject* obj, QEvent* event)
{ {
if(event->type() == QEvent::Wheel) if (event->type() == QEvent::Wheel)
{ {
QWidget* widget = qobject_cast<QWidget*>(obj); QWidget* widget = qobject_cast<QWidget*>(obj);
if(widget == NULL || !widget->hasFocus()) if (widget == NULL || !widget->hasFocus())
{ {
QApplication::sendEvent(scrollTarget, event); QApplication::sendEvent(scrollTarget, event);
return true; return true;
+1 -1
View File
@@ -25,7 +25,7 @@ class DisableWheelFilter : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit DisableWheelFilter(QObject* scrollTarget, QObject *parent = 0); explicit DisableWheelFilter(QObject* scrollTarget, QObject* parent = 0);
bool eventFilter(QObject* obj, QEvent* event) override; bool eventFilter(QObject* obj, QEvent* event) override;
+1 -1
View File
@@ -26,7 +26,7 @@ GUIChannelHelper* GUIChannelHelper::instance = NULL;
GUIChannelHelper* GUIChannelHelper::getInstance() GUIChannelHelper* GUIChannelHelper::getInstance()
{ {
if(instance == NULL) if (instance == NULL)
instance = new GUIChannelHelper(); instance = new GUIChannelHelper();
return instance; return instance;
+1 -1
View File
@@ -22,7 +22,7 @@
#include <QHash> #include <QHash>
#include <QObject> #include <QObject>
class GUIChannelHelper: public QObject class GUIChannelHelper : public QObject
{ {
Q_OBJECT Q_OBJECT
+11 -11
View File
@@ -27,12 +27,12 @@
using namespace std; using namespace std;
int main(int argc, char *argv[]) int main(int argc, char* argv[])
{ {
int result = -1; int result = -1;
#ifdef _DEBUG #ifdef _DEBUG
//_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); // _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
//_CrtSetBreakAlloc(3318); // _CrtSetBreakAlloc(3318);
#endif #endif
QCoreApplication::addLibraryPath("qt"); QCoreApplication::addLibraryPath("qt");
@@ -44,7 +44,7 @@ int main(int argc, char *argv[])
QSettings settings(QString::fromWCharArray(EDITOR_REGPATH), QSettings::NativeFormat); QSettings settings(QString::fromWCharArray(EDITOR_REGPATH), QSettings::NativeFormat);
QVariant languageValue = settings.value("language"); QVariant languageValue = settings.value("language");
if(languageValue.isValid()) if (languageValue.isValid())
QLocale::setDefault(languageValue.toString()); QLocale::setDefault(languageValue.toString());
else else
QLocale::setDefault(QLocale::system()); QLocale::setDefault(QLocale::system());
@@ -58,17 +58,17 @@ int main(int argc, char *argv[])
application.installTranslator(&editorTranslator); application.installTranslator(&editorTranslator);
QString configPath = QDir::currentPath(); QString configPath = QDir::currentPath();
if(RegistryHelper::keyExists(APP_REGPATH) && RegistryHelper::valueExists(APP_REGPATH, L"ConfigPath")) if (RegistryHelper::keyExists(APP_REGPATH) && RegistryHelper::valueExists(APP_REGPATH, L"ConfigPath"))
configPath = QString::fromStdWString(RegistryHelper::readValue(APP_REGPATH, L"ConfigPath")); configPath = QString::fromStdWString(RegistryHelper::readValue(APP_REGPATH, L"ConfigPath"));
QDir configDir(configPath); QDir configDir(configPath);
if(!RegistryHelper::keyExists(USER_REGPATH)) if (!RegistryHelper::keyExists(USER_REGPATH))
RegistryHelper::createKey(USER_REGPATH); RegistryHelper::createKey(USER_REGPATH);
if(!RegistryHelper::keyExists(EDITOR_REGPATH)) if (!RegistryHelper::keyExists(EDITOR_REGPATH))
RegistryHelper::createKey(EDITOR_REGPATH); RegistryHelper::createKey(EDITOR_REGPATH);
if(!RegistryHelper::keyExists(EDITOR_PER_FILE_REGPATH)) if (!RegistryHelper::keyExists(EDITOR_PER_FILE_REGPATH))
RegistryHelper::createKey(EDITOR_PER_FILE_REGPATH); RegistryHelper::createKey(EDITOR_PER_FILE_REGPATH);
MainWindow w(configDir); MainWindow w(configDir);
@@ -77,10 +77,10 @@ int main(int argc, char *argv[])
QCommandLineParser parser; QCommandLineParser parser;
parser.process(application); parser.process(application);
QStringList args = parser.positionalArguments(); QStringList args = parser.positionalArguments();
if(args.isEmpty() && w.isEmpty()) if (args.isEmpty() && w.isEmpty())
args = QStringList("config.txt"); args = QStringList("config.txt");
for(QString arg : args) for (QString arg : args)
w.load(configDir.absoluteFilePath(arg)); w.load(configDir.absoluteFilePath(arg));
w.doChecks(); w.doChecks();
@@ -89,7 +89,7 @@ int main(int argc, char *argv[])
restart = w.shouldRestart(); restart = w.shouldRestart();
} }
while(restart); while (restart);
return result; return result;
} }
+2 -2
View File
@@ -31,14 +31,14 @@ ChannelGraphItem::ChannelGraphItem(const QString& name)
QRectF ChannelGraphItem::boundingRect() const QRectF ChannelGraphItem::boundingRect() const
{ {
if(cachedRect.isNull()) if (cachedRect.isNull())
{ {
QFontMetrics metrics(scene()->font()); QFontMetrics metrics(scene()->font());
int width = metrics.width(name); int width = metrics.width(name);
// we only use upper case characters and digits, so everything is above the baseline // we only use upper case characters and digits, so everything is above the baseline
int height = metrics.ascent(); int height = metrics.ascent();
// make it at least quadratic // make it at least quadratic
if(width < height) if (width < height)
width = height; width = height;
// shift by 0.5 to have sharp lines // shift by 0.5 to have sharp lines
cachedRect.setLeft(0.5); cachedRect.setLeft(0.5);
+3 -3
View File
@@ -21,15 +21,15 @@
#include "ChannelGraphScene.h" #include "ChannelGraphScene.h"
ChannelGraphScene::ChannelGraphScene(QWidget *parent) : ChannelGraphScene::ChannelGraphScene(QWidget* parent)
QGraphicsScene(parent) : QGraphicsScene(parent)
{ {
} }
QPointF ChannelGraphScene::getNextChannelPoint(QGraphicsItem* lastItem, bool output) QPointF ChannelGraphScene::getNextChannelPoint(QGraphicsItem* lastItem, bool output)
{ {
int x = 0; int x = 0;
if(lastItem != NULL) if (lastItem != NULL)
{ {
QRectF lastRect = lastItem->sceneBoundingRect(); QRectF lastRect = lastItem->sceneBoundingRect();
x = lastRect.left() + lastRect.width() + 1 + 10; x = lastRect.left() + lastRect.width() + 1 + 10;
+1 -1
View File
@@ -25,7 +25,7 @@ class ChannelGraphScene : public QGraphicsScene
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit ChannelGraphScene(QWidget *parent = 0); explicit ChannelGraphScene(QWidget* parent = 0);
protected: protected:
QPointF getNextChannelPoint(QGraphicsItem* lastItem, bool output); QPointF getNextChannelPoint(QGraphicsItem* lastItem, bool output);
+2 -2
View File
@@ -19,8 +19,8 @@
#include "CompactToolBar.h" #include "CompactToolBar.h"
CompactToolBar::CompactToolBar(QWidget *parent) : CompactToolBar::CompactToolBar(QWidget* parent)
QToolBar(parent) : QToolBar(parent)
{ {
setMinimumHeight(1); setMinimumHeight(1);
setOrientation(Qt::Vertical); setOrientation(Qt::Vertical);
+1 -1
View File
@@ -25,7 +25,7 @@ class CompactToolBar : public QToolBar
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit CompactToolBar(QWidget *parent = 0); explicit CompactToolBar(QWidget* parent = 0);
QSize sizeHint() const override; QSize sizeHint() const override;
void updateMaximumHeight(); void updateMaximumHeight();
+3 -3
View File
@@ -21,15 +21,15 @@
#include "EscapableLineEdit.h" #include "EscapableLineEdit.h"
EscapableLineEdit::EscapableLineEdit(QWidget *parent) : EscapableLineEdit::EscapableLineEdit(QWidget* parent)
QLineEdit(parent) : QLineEdit(parent)
{ {
} }
void EscapableLineEdit::keyPressEvent(QKeyEvent* event) void EscapableLineEdit::keyPressEvent(QKeyEvent* event)
{ {
if(event->key() == Qt::Key_Escape) if (event->key() == Qt::Key_Escape)
emit editingCanceled(); emit editingCanceled();
else else
QLineEdit::keyPressEvent(event); QLineEdit::keyPressEvent(event);
+1 -1
View File
@@ -25,7 +25,7 @@ class EscapableLineEdit : public QLineEdit
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit EscapableLineEdit(QWidget *parent = 0); explicit EscapableLineEdit(QWidget* parent = 0);
signals: signals:
void editingCanceled(); void editingCanceled();
+3 -3
View File
@@ -31,16 +31,16 @@ ExponentialSpinBox::ExponentialSpinBox(QWidget* parent)
void ExponentialSpinBox::stepBy(int steps) void ExponentialSpinBox::stepBy(int steps)
{ {
qint64 v = value(); qint64 v = value();
if(steps > 0) if (steps > 0)
{ {
v <<= steps; v <<= steps;
if(v > maximum()) if (v > maximum())
v = maximum(); v = maximum();
} }
else else
{ {
v >>= -steps; v >>= -steps;
if(v < minimum()) if (v < minimum())
v = minimum(); v = minimum();
} }
+14 -14
View File
@@ -26,8 +26,8 @@
using namespace std; using namespace std;
FrequencyPlotHRuler::FrequencyPlotHRuler(QWidget* parent) : FrequencyPlotHRuler::FrequencyPlotHRuler(QWidget* parent)
QWidget(parent) : QWidget(parent)
{ {
} }
@@ -46,43 +46,43 @@ void FrequencyPlotHRuler::paintEvent(QPaintEvent*)
double fromHz = s->xToHz(topLeft.x()); double fromHz = s->xToHz(topLeft.x());
double toHz = s->xToHz(bottomRight.x()); double toHz = s->xToHz(bottomRight.x());
const vector<double>& bands = s->getBands(); const vector<double>& bands = s->getBands();
if(bands.empty()) if (bands.empty())
{ {
double hzBase = pow(10, floor(log10(fromHz))); double hzBase = pow(10, floor(log10(fromHz)));
fromHz = floor(fromHz / hzBase) * hzBase; fromHz = floor(fromHz / hzBase) * hzBase;
fromHz += hzBase; fromHz += hzBase;
if(round(fromHz / hzBase) >= 10) if (round(fromHz / hzBase) >= 10)
hzBase *= 10; hzBase *= 10;
for(double hz = fromHz; hz <= toHz;) for (double hz = fromHz; hz <= toHz;)
{ {
double x = s->hzToX(hz); double x = s->hzToX(hz);
if(x != -1) if (x != -1)
{ {
QString text; QString text;
if(hz < 1000) if (hz < 1000)
text = QString("%0").arg(hz); text = QString("%0").arg(hz);
else else
text = QString("%0k").arg(hz / 1000); text = QString("%0k").arg(hz / 1000);
if(metrics.width(text) + 2 < s->hzToX(hz + hzBase) - x) if (metrics.width(text) + 2 < s->hzToX(hz + hzBase) - x)
painter.drawText(x - topLeft.x() + offsetLeft + 1, 0, 0, height(), Qt::TextDontClip | Qt::AlignCenter, text); painter.drawText(x - topLeft.x() + offsetLeft + 1, 0, 0, height(), Qt::TextDontClip | Qt::AlignCenter, text);
} }
hz += hzBase; hz += hzBase;
if(round(hz / hzBase) >= 10) if (round(hz / hzBase) >= 10)
hzBase *= 10; hzBase *= 10;
} }
} }
else else
{ {
vector<double>::const_iterator it = lower_bound(bands.cbegin(), bands.cend(), fromHz); vector<double>::const_iterator it = lower_bound(bands.cbegin(), bands.cend(), fromHz);
for(; it != bands.cend() && *it < toHz; it++) for (; it != bands.cend() && *it < toHz; it++)
{ {
double hz = *it; double hz = *it;
double x = s->hzToX(hz); double x = s->hzToX(hz);
if(x != -1) if (x != -1)
{ {
QString text; QString text;
if(hz < 1000) if (hz < 1000)
text = QString("%0").arg(hz); text = QString("%0").arg(hz);
else else
text = QString("%0k").arg(hz / 1000); text = QString("%0k").arg(hz / 1000);
@@ -92,13 +92,13 @@ void FrequencyPlotHRuler::paintEvent(QPaintEvent*)
} }
QPoint mousePos = view->getLastMousePos(); QPoint mousePos = view->getLastMousePos();
if(!mousePos.isNull()) if (!mousePos.isNull())
{ {
QPointF mouseScenePos = view->mapToScene(mousePos); QPointF mouseScenePos = view->mapToScene(mousePos);
double hz = s->xToHz(mouseScenePos.x()); double hz = s->xToHz(mouseScenePos.x());
double x = s->hzToX(hz); double x = s->hzToX(hz);
if(x != -1) if (x != -1)
{ {
QString text = QString("%0").arg(hz, 0, 'f', 1); QString text = QString("%0").arg(hz, 0, 'f', 1);
QFontMetrics metrics = painter.fontMetrics(); QFontMetrics metrics = painter.fontMetrics();
+1 -1
View File
@@ -26,7 +26,7 @@ class FrequencyPlotItem : public QGraphicsItem
public: public:
FrequencyPlotItem(double hz, double db); FrequencyPlotItem(double hz, double db);
enum { Type = UserType + 1 }; enum {Type = UserType + 1};
virtual int type() const virtual int type() const
{ {
return Type; return Type;
+10 -11
View File
@@ -31,12 +31,11 @@ static double maxDb = 100;
vector<double> FrequencyPlotScene::bands15 = {25, 40, 63, 100, 160, 250, 400, 630, 1000, 1600, 2500, 4000, 6300, 10000, 16000}; vector<double> FrequencyPlotScene::bands15 = {25, 40, 63, 100, 160, 250, 400, 630, 1000, 1600, 2500, 4000, 6300, 10000, 16000};
vector<double> FrequencyPlotScene::bands31 = {20, 25, 31.5, 40, 50, 63, 80, 100, 125, 160, 200, 250, 315, 400, 500, 630, 800, vector<double> FrequencyPlotScene::bands31 = {20, 25, 31.5, 40, 50, 63, 80, 100, 125, 160, 200, 250, 315, 400, 500, 630, 800,
1000, 1250, 1600, 2000, 2500, 3150, 4000, 5000, 6300, 8000, 10000, 12500, 16000, 20000 1000, 1250, 1600, 2000, 2500, 3150, 4000, 5000, 6300, 8000, 10000, 12500, 16000, 20000};
};
vector<double> FrequencyPlotScene::bandsVar; vector<double> FrequencyPlotScene::bandsVar;
FrequencyPlotScene::FrequencyPlotScene(QObject *parent) : FrequencyPlotScene::FrequencyPlotScene(QObject* parent)
QGraphicsScene(parent) : QGraphicsScene(parent)
{ {
updateSceneRect(); updateSceneRect();
} }
@@ -53,7 +52,7 @@ double FrequencyPlotScene::xToHz(double x)
double FrequencyPlotScene::hzToX(double hz) double FrequencyPlotScene::hzToX(double hz)
{ {
if(hz < minHz || hz > maxHz) if (hz < minHz || hz > maxHz)
return -1; return -1;
return log(hz / minHz) / log(maxHz / minHz) * maxX * zoomX; return log(hz / minHz) / log(maxHz / minHz) * maxX * zoomX;
@@ -61,12 +60,12 @@ double FrequencyPlotScene::hzToX(double hz)
double FrequencyPlotScene::yToDb(double y) double FrequencyPlotScene::yToDb(double y)
{ {
return (minDb + (1 - y / zoomY / maxY) * (maxDb - minDb)); return(minDb + (1 - y / zoomY / maxY) * (maxDb - minDb));
} }
double FrequencyPlotScene::dbToY(double db) double FrequencyPlotScene::dbToY(double db)
{ {
if(db < minDb || db > maxDb) if (db < minDb || db > maxDb)
return -1; return -1;
return (1 - (db - minDb) / (maxDb - minDb)) * maxY * zoomY; return (1 - (db - minDb) / (maxDb - minDb)) * maxY * zoomY;
@@ -88,7 +87,7 @@ void FrequencyPlotScene::setZoom(double zoomX, double zoomY)
this->zoomY = zoomY; this->zoomY = zoomY;
updateSceneRect(); updateSceneRect();
for(QGraphicsItem* item : items()) for (QGraphicsItem* item : items())
{ {
FrequencyPlotItem* plotItem = (FrequencyPlotItem*)item; FrequencyPlotItem* plotItem = (FrequencyPlotItem*)item;
plotItem->updatePos(); plotItem->updatePos();
@@ -107,7 +106,7 @@ int FrequencyPlotScene::getBandCount() const
void FrequencyPlotScene::setBandCount(int value) void FrequencyPlotScene::setBandCount(int value)
{ {
if(value != bandCount) if (value != bandCount)
{ {
bandCount = value; bandCount = value;
update(); update();
@@ -121,9 +120,9 @@ const vector<double>& FrequencyPlotScene::getBands()
return getBands(bandCount); return getBands(bandCount);
} }
const std::vector<double>&FrequencyPlotScene::getBands(int count) const std::vector<double>& FrequencyPlotScene::getBands(int count)
{ {
switch(count) switch (count)
{ {
case 15: case 15:
return bands15; return bands15;
+2 -2
View File
@@ -28,9 +28,9 @@ class FrequencyPlotScene : public QGraphicsScene
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit FrequencyPlotScene(QObject *parent = 0); explicit FrequencyPlotScene(QObject* parent = 0);
void addItem(FrequencyPlotItem *item); void addItem(FrequencyPlotItem* item);
double xToHz(double x); double xToHz(double x);
double hzToX(double hz); double hzToX(double hz);
+9 -9
View File
@@ -23,8 +23,8 @@
#include "FrequencyPlotScene.h" #include "FrequencyPlotScene.h"
#include "FrequencyPlotVRuler.h" #include "FrequencyPlotVRuler.h"
FrequencyPlotVRuler::FrequencyPlotVRuler(QWidget *parent) : FrequencyPlotVRuler::FrequencyPlotVRuler(QWidget* parent)
QWidget(parent) : QWidget(parent)
{ {
} }
@@ -40,9 +40,9 @@ void FrequencyPlotVRuler::paintEvent(QPaintEvent*)
double dbStep = abs(s->yToDb(0) - s->yToDb(30)); double dbStep = abs(s->yToDb(0) - s->yToDb(30));
double dbBase = pow(10, floor(log10(dbStep))); double dbBase = pow(10, floor(log10(dbStep)));
if(dbStep >= 5 * dbBase) if (dbStep >= 5 * dbBase)
dbStep = 5 * dbBase; dbStep = 5 * dbBase;
else if(dbStep >= 2 * dbBase) else if (dbStep >= 2 * dbBase)
dbStep = 2 * dbBase; dbStep = 2 * dbBase;
else else
dbStep = dbBase; dbStep = dbBase;
@@ -51,23 +51,23 @@ void FrequencyPlotVRuler::paintEvent(QPaintEvent*)
double toDb = ceil(s->yToDb(bottomRight.y()) / dbStep) * dbStep; double toDb = ceil(s->yToDb(bottomRight.y()) / dbStep) * dbStep;
painter.setPen(QColor(50, 50, 50)); painter.setPen(QColor(50, 50, 50));
for(double db = toDb; db <= fromDb; db += dbStep) for (double db = toDb; db <= fromDb; db += dbStep)
{ {
if(abs(db) < 1e-6) if (abs(db) < 1e-6)
db = 0; db = 0;
double y = s->dbToY(db); double y = s->dbToY(db);
if(y != -1) if (y != -1)
painter.drawText(0, y - topLeft.y() - 1, width(), 0, Qt::TextDontClip | Qt::AlignCenter, QString("%0").arg(db)); painter.drawText(0, y - topLeft.y() - 1, width(), 0, Qt::TextDontClip | Qt::AlignCenter, QString("%0").arg(db));
} }
QPoint mousePos = view->getLastMousePos(); QPoint mousePos = view->getLastMousePos();
if(!mousePos.isNull()) if (!mousePos.isNull())
{ {
QPointF mouseScenePos = view->mapToScene(mousePos); QPointF mouseScenePos = view->mapToScene(mousePos);
double db = s->yToDb(mouseScenePos.y()); double db = s->yToDb(mouseScenePos.y());
double y = s->dbToY(db); double y = s->dbToY(db);
if(y != -1) if (y != -1)
{ {
QString text = QString("%0").arg(db, 0, 'f', 1); QString text = QString("%0").arg(db, 0, 'f', 1);
QFontMetrics metrics = painter.fontMetrics(); QFontMetrics metrics = painter.fontMetrics();
+1 -1
View File
@@ -25,7 +25,7 @@ class FrequencyPlotVRuler : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit FrequencyPlotVRuler(QWidget *parent = 0); explicit FrequencyPlotVRuler(QWidget* parent = 0);
protected: protected:
void paintEvent(QPaintEvent*) override; void paintEvent(QPaintEvent*) override;
+25 -25
View File
@@ -26,8 +26,8 @@
using namespace std; using namespace std;
FrequencyPlotView::FrequencyPlotView(QWidget *parent) : FrequencyPlotView::FrequencyPlotView(QWidget* parent)
QGraphicsView(parent) : QGraphicsView(parent)
{ {
setViewportMargins(32, 0, 0, 20); setViewportMargins(32, 0, 0, 20);
hRuler = new FrequencyPlotHRuler(this); hRuler = new FrequencyPlotHRuler(this);
@@ -51,7 +51,7 @@ void FrequencyPlotView::drawBackground(QPainter* painter, const QRectF& drawRect
painter->setRenderHint(QPainter::Antialiasing, false); painter->setRenderHint(QPainter::Antialiasing, false);
QRectF rect = drawRect; QRectF rect = drawRect;
if(!sceneRect().contains(rect)) if (!sceneRect().contains(rect))
{ {
rect = rect.intersected(sceneRect()); rect = rect.intersected(sceneRect());
painter->setClipRect(rect); painter->setClipRect(rect);
@@ -63,9 +63,9 @@ void FrequencyPlotView::drawBackground(QPainter* painter, const QRectF& drawRect
double dbStep = abs(s->yToDb(0) - s->yToDb(30)); double dbStep = abs(s->yToDb(0) - s->yToDb(30));
double dbBase = pow(10, floor(log10(dbStep))); double dbBase = pow(10, floor(log10(dbStep)));
if(dbStep >= 5 * dbBase) if (dbStep >= 5 * dbBase)
dbStep = 5 * dbBase; dbStep = 5 * dbBase;
else if(dbStep >= 2 * dbBase) else if (dbStep >= 2 * dbBase)
dbStep = 2 * dbBase; dbStep = 2 * dbBase;
else else
dbStep = dbBase; dbStep = dbBase;
@@ -74,10 +74,10 @@ void FrequencyPlotView::drawBackground(QPainter* painter, const QRectF& drawRect
double toDb = ceil(s->yToDb(rect.top()) / dbStep) * dbStep; double toDb = ceil(s->yToDb(rect.top()) / dbStep) * dbStep;
painter->setPen(QColor(200, 200, 200)); painter->setPen(QColor(200, 200, 200));
for(double db = fromDb; db <= toDb; db += dbStep) for (double db = fromDb; db <= toDb; db += dbStep)
{ {
double y = floor(s->dbToY(db)) + 0.5; double y = floor(s->dbToY(db)) + 0.5;
if(y != -1) if (y != -1)
painter->drawLine(topLeft.x(), y, bottomRight.x(), y); painter->drawLine(topLeft.x(), y, bottomRight.x(), y);
} }
@@ -85,32 +85,32 @@ void FrequencyPlotView::drawBackground(QPainter* painter, const QRectF& drawRect
double toHz = s->xToHz(rect.left() + rect.width()); double toHz = s->xToHz(rect.left() + rect.width());
const vector<double>& bands = s->getBands(); const vector<double>& bands = s->getBands();
if(bands.empty()) if (bands.empty())
{ {
double hzBase = pow(10, floor(log10(fromHz))); double hzBase = pow(10, floor(log10(fromHz)));
fromHz = floor(fromHz / hzBase) * hzBase; fromHz = floor(fromHz / hzBase) * hzBase;
fromHz += hzBase; fromHz += hzBase;
if(round(fromHz / hzBase) >= 10) if (round(fromHz / hzBase) >= 10)
hzBase *= 10; hzBase *= 10;
for(double hz = fromHz; hz <= toHz;) for (double hz = fromHz; hz <= toHz;)
{ {
double x = floor(s->hzToX(hz)) + 0.5; double x = floor(s->hzToX(hz)) + 0.5;
if(x >= 0) if (x >= 0)
painter->drawLine(x, topLeft.y(), x, bottomRight.y()); painter->drawLine(x, topLeft.y(), x, bottomRight.y());
hz += hzBase; hz += hzBase;
if(round(hz / hzBase) >= 10) if (round(hz / hzBase) >= 10)
hzBase *= 10; hzBase *= 10;
} }
} }
else else
{ {
vector<double>::const_iterator it = lower_bound(bands.cbegin(), bands.cend(), fromHz); vector<double>::const_iterator it = lower_bound(bands.cbegin(), bands.cend(), fromHz);
for(; it != bands.cend() && *it < toHz; it++) for (; it != bands.cend() && *it < toHz; it++)
{ {
double hz = *it; double hz = *it;
double x = floor(s->hzToX(hz)) + 0.5; double x = floor(s->hzToX(hz)) + 0.5;
if(x >= 0) if (x >= 0)
painter->drawLine(x, topLeft.y(), x, bottomRight.y()); painter->drawLine(x, topLeft.y(), x, bottomRight.y());
} }
} }
@@ -146,25 +146,25 @@ void FrequencyPlotView::zoom(int deltaX, int deltaY, int mouseX, int mouseY)
double zoomY = max(0.5, min(30.0, s->getZoomY() * zoomFactorY)); double zoomY = max(0.5, min(30.0, s->getZoomY() * zoomFactorY));
s->setZoom(zoomX, zoomY); s->setZoom(zoomX, zoomY);
if(deltaX != 0) if (deltaX != 0)
{ {
double x = s->hzToX(hz); double x = s->hzToX(hz);
if(x != -1) if (x != -1)
horizontalScrollBar()->setValue(horizontalScrollBar()->value() + round(x - scenePos.x())); horizontalScrollBar()->setValue(horizontalScrollBar()->value() + round(x - scenePos.x()));
} }
if(deltaY != 0) if (deltaY != 0)
{ {
double y = s->dbToY(db); double y = s->dbToY(db);
if(y != -1) if (y != -1)
verticalScrollBar()->setValue(verticalScrollBar()->value() + round(y - scenePos.y())); verticalScrollBar()->setValue(verticalScrollBar()->value() + round(y - scenePos.y()));
} }
resetCachedContent(); resetCachedContent();
viewport()->update(); viewport()->update();
if(deltaX != 0) if (deltaX != 0)
hRuler->update(); hRuler->update();
if(deltaY != 0) if (deltaY != 0)
vRuler->update(); vRuler->update();
} }
@@ -184,9 +184,9 @@ void FrequencyPlotView::scrollContentsBy(int dx, int dy)
{ {
QGraphicsView::scrollContentsBy(dx, dy); QGraphicsView::scrollContentsBy(dx, dy);
if(dx != 0) if (dx != 0)
hRuler->update(); hRuler->update();
if(dy != 0) if (dy != 0)
vRuler->update(); vRuler->update();
} }
@@ -209,7 +209,7 @@ void FrequencyPlotView::mousePressEvent(QMouseEvent* event)
void FrequencyPlotView::mouseMoveEvent(QMouseEvent* event) void FrequencyPlotView::mouseMoveEvent(QMouseEvent* event)
{ {
if(event->buttons() & Qt::RightButton) if (event->buttons() & Qt::RightButton)
{ {
horizontalScrollBar()->setValue(horizontalScrollBar()->value() - (event->x() - lastMousePos.x())); horizontalScrollBar()->setValue(horizontalScrollBar()->value() - (event->x() - lastMousePos.x()));
verticalScrollBar()->setValue(verticalScrollBar()->value() - (event->y() - lastMousePos.y())); verticalScrollBar()->setValue(verticalScrollBar()->value() - (event->y() - lastMousePos.y()));
@@ -230,13 +230,13 @@ void FrequencyPlotView::showEvent(QShowEvent* event)
{ {
QGraphicsView::showEvent(event); QGraphicsView::showEvent(event);
if(presetScrollX != -1) if (presetScrollX != -1)
{ {
horizontalScrollBar()->setValue(presetScrollX); horizontalScrollBar()->setValue(presetScrollX);
presetScrollX = -1; presetScrollX = -1;
} }
if(presetScrollY != -1) if (presetScrollY != -1)
{ {
verticalScrollBar()->setValue(presetScrollY); verticalScrollBar()->setValue(presetScrollY);
presetScrollY = -1; presetScrollY = -1;
+1 -1
View File
@@ -29,7 +29,7 @@ class FrequencyPlotView : public QGraphicsView
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit FrequencyPlotView(QWidget *parent = 0); explicit FrequencyPlotView(QWidget* parent = 0);
FrequencyPlotScene* scene() const; FrequencyPlotScene* scene() const;
void setScene(FrequencyPlotScene* scene); void setScene(FrequencyPlotScene* scene);
+1 -1
View File
@@ -21,7 +21,7 @@
#include "ResizeCorner.h" #include "ResizeCorner.h"
ResizeCorner::ResizeCorner(FilterTable* filterTable, QSize minimumSize, QSize maximumSize, std::function<QSize()> getFunc, std::function<void(QSize)> setFunc, QWidget *parent) ResizeCorner::ResizeCorner(FilterTable* filterTable, QSize minimumSize, QSize maximumSize, std::function<QSize()> getFunc, std::function<void(QSize)> setFunc, QWidget* parent)
: QLabel(parent), minimumSize(minimumSize), maximumSize(maximumSize), getFunc(getFunc), setFunc(setFunc), filterTable(filterTable) : QLabel(parent), minimumSize(minimumSize), maximumSize(maximumSize), getFunc(getFunc), setFunc(setFunc), filterTable(filterTable)
{ {
setPixmap(QPixmap(":/icons/resize_corner.png")); setPixmap(QPixmap(":/icons/resize_corner.png"));
+1 -1
View File
@@ -30,7 +30,7 @@ class ResizeCorner : public QLabel
public: public:
explicit ResizeCorner(FilterTable* filterTable, QSize minimumSize, QSize maximumSize, explicit ResizeCorner(FilterTable* filterTable, QSize minimumSize, QSize maximumSize,
std::function<QSize()> getFunc, std::function<void(QSize)> setFunc, QWidget *parent = 0); std::function<QSize()> getFunc, std::function<void(QSize)> setFunc, QWidget* parent = 0);
protected: protected:
void mousePressEvent(QMouseEvent* event) override; void mousePressEvent(QMouseEvent* event) override;
+4 -4
View File
@@ -19,16 +19,16 @@
#include "ResizingLineEdit.h" #include "ResizingLineEdit.h"
ResizingLineEdit::ResizingLineEdit(QWidget *parent) : ResizingLineEdit::ResizingLineEdit(QWidget* parent)
QLineEdit(parent) : QLineEdit(parent)
{ {
connect(this, SIGNAL(textChanged(QString)), this, SLOT(readjustSize())); connect(this, SIGNAL(textChanged(QString)), this, SLOT(readjustSize()));
readjustSize(); readjustSize();
} }
ResizingLineEdit::ResizingLineEdit(const QString& text, QWidget* parent) : ResizingLineEdit::ResizingLineEdit(const QString& text, QWidget* parent)
QLineEdit(text, parent) : QLineEdit(text, parent)
{ {
connect(this, SIGNAL(textChanged(QString)), this, SLOT(readjustSize())); connect(this, SIGNAL(textChanged(QString)), this, SLOT(readjustSize()));
+2 -2
View File
@@ -25,8 +25,8 @@ class ResizingLineEdit : public QLineEdit
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit ResizingLineEdit(QWidget *parent = 0); explicit ResizingLineEdit(QWidget* parent = 0);
explicit ResizingLineEdit(const QString& text, QWidget* parent=0); explicit ResizingLineEdit(const QString& text, QWidget* parent = 0);
QSize sizeHint() const override; QSize sizeHint() const override;
+56 -56
View File
@@ -33,16 +33,16 @@ using namespace std;
long EqualizerAPO::instCount = 0; long EqualizerAPO::instCount = 0;
const CRegAPOProperties<1> EqualizerAPO::regPostMixProperties( const CRegAPOProperties<1> EqualizerAPO::regPostMixProperties(
EQUALIZERAPO_POST_MIX_GUID, L"EqualizerAPO", L"Copyright (C) 2015", 1, 0, __uuidof(IAudioProcessingObject), EQUALIZERAPO_POST_MIX_GUID, L"EqualizerAPO", L"Copyright (C) 2015", 1, 0, __uuidof(IAudioProcessingObject),
(APO_FLAG)( APO_FLAG_FRAMESPERSECOND_MUST_MATCH | APO_FLAG_BITSPERSAMPLE_MUST_MATCH | APO_FLAG_INPLACE)); (APO_FLAG)(APO_FLAG_FRAMESPERSECOND_MUST_MATCH | APO_FLAG_BITSPERSAMPLE_MUST_MATCH | APO_FLAG_INPLACE));
const CRegAPOProperties<1> EqualizerAPO::regPreMixProperties( const CRegAPOProperties<1> EqualizerAPO::regPreMixProperties(
EQUALIZERAPO_PRE_MIX_GUID, L"EqualizerAPO", L"Copyright (C) 2015", 1, 0, __uuidof(IAudioProcessingObject), EQUALIZERAPO_PRE_MIX_GUID, L"EqualizerAPO", L"Copyright (C) 2015", 1, 0, __uuidof(IAudioProcessingObject),
(APO_FLAG)( APO_FLAG_FRAMESPERSECOND_MUST_MATCH | APO_FLAG_BITSPERSAMPLE_MUST_MATCH | APO_FLAG_INPLACE)); (APO_FLAG)(APO_FLAG_FRAMESPERSECOND_MUST_MATCH | APO_FLAG_BITSPERSAMPLE_MUST_MATCH | APO_FLAG_INPLACE));
EqualizerAPO::EqualizerAPO(IUnknown* pUnkOuter) EqualizerAPO::EqualizerAPO(IUnknown* pUnkOuter)
:CBaseAudioProcessingObject(regPostMixProperties) : CBaseAudioProcessingObject(regPostMixProperties)
{ {
refCount = 1; refCount = 1;
if(pUnkOuter != NULL) if (pUnkOuter != NULL)
this->pUnkOuter = pUnkOuter; this->pUnkOuter = pUnkOuter;
else else
this->pUnkOuter = reinterpret_cast<IUnknown*>(static_cast<INonDelegatingUnknown*>(this)); this->pUnkOuter = reinterpret_cast<IUnknown*>(static_cast<INonDelegatingUnknown*>(this));
@@ -78,14 +78,14 @@ ULONG EqualizerAPO::Release()
HRESULT EqualizerAPO::GetLatency(HNSTIME* pTime) HRESULT EqualizerAPO::GetLatency(HNSTIME* pTime)
{ {
if(!pTime) if (!pTime)
return E_POINTER; return E_POINTER;
if(!m_bIsLocked) if (!m_bIsLocked)
return APOERR_ALREADY_UNLOCKED; return APOERR_ALREADY_UNLOCKED;
*pTime = 0; *pTime = 0;
if(childAPO) if (childAPO)
childAPO->GetLatency(pTime); childAPO->GetLatency(pTime);
return S_OK; return S_OK;
@@ -97,11 +97,11 @@ HRESULT EqualizerAPO::Initialize(UINT32 cbDataSize, BYTE* pbyData)
TraceF(L"Initialize"); TraceF(L"Initialize");
if((NULL == pbyData) && (0 != cbDataSize)) if ((NULL == pbyData) && (0 != cbDataSize))
return E_INVALIDARG; return E_INVALIDARG;
if((NULL != pbyData) && (0 == cbDataSize)) if ((NULL != pbyData) && (0 == cbDataSize))
return E_POINTER; return E_POINTER;
if(cbDataSize != sizeof(APOInitSystemEffects) ) if (cbDataSize != sizeof(APOInitSystemEffects))
return E_INVALIDARG; return E_INVALIDARG;
resetChild(); resetChild();
@@ -112,7 +112,7 @@ HRESULT EqualizerAPO::Initialize(UINT32 cbDataSize, BYTE* pbyData)
{ {
TraceF(L"APO GUID: %s", RegistryHelper::getGuidString(apoGuid).c_str()); TraceF(L"APO GUID: %s", RegistryHelper::getGuidString(apoGuid).c_str());
} }
catch(RegistryException e) catch (RegistryException e)
{ {
LogF(L"Could not convert apo guid to guid string"); LogF(L"Could not convert apo guid to guid string");
} }
@@ -121,7 +121,7 @@ HRESULT EqualizerAPO::Initialize(UINT32 cbDataSize, BYTE* pbyData)
PROPVARIANT var; PROPVARIANT var;
PropVariantInit(&var); PropVariantInit(&var);
HRESULT hr = initStruct->pAPOEndpointProperties->GetValue(PKEY_AudioEndpoint_GUID, &var); HRESULT hr = initStruct->pAPOEndpointProperties->GetValue(PKEY_AudioEndpoint_GUID, &var);
if(FAILED(hr)) if (FAILED(hr))
{ {
LogF(L"Can't read endpoint guid"); LogF(L"Can't read endpoint guid");
return hr; return hr;
@@ -134,35 +134,35 @@ HRESULT EqualizerAPO::Initialize(UINT32 cbDataSize, BYTE* pbyData)
try try
{ {
DeviceAPOInfo apoInfo; DeviceAPOInfo apoInfo;
if(apoInfo.load(deviceGuid)) if (apoInfo.load(deviceGuid))
{ {
engine.setDeviceInfo(apoInfo.isInput, apoInfo.currentInstallState.installPostMix, apoInfo.deviceName, apoInfo.connectionName, apoInfo.deviceGuid); engine.setDeviceInfo(apoInfo.isInput, apoInfo.currentInstallState.installPostMix, apoInfo.deviceName, apoInfo.connectionName, apoInfo.deviceGuid);
if(apoGuid == EQUALIZERAPO_PRE_MIX_GUID) if (apoGuid == EQUALIZERAPO_PRE_MIX_GUID)
childApoGuid = apoInfo.preMixChildGuid; childApoGuid = apoInfo.preMixChildGuid;
else else
childApoGuid = apoInfo.postMixChildGuid; childApoGuid = apoInfo.postMixChildGuid;
} }
} }
catch(RegistryException e) catch (RegistryException e)
{ {
LogF(L"Could not read endpoint device info because of: %s", e.getMessage().c_str()); LogF(L"Could not read endpoint device info because of: %s", e.getMessage().c_str());
} }
TraceF(L"Child APO GUID: %s", childApoGuid.c_str()); TraceF(L"Child APO GUID: %s", childApoGuid.c_str());
if(childApoGuid != L"" && childApoGuid != APOGUID_NULL && childApoGuid != APOGUID_NOKEY && childApoGuid != APOGUID_NOVALUE) if (childApoGuid != L"" && childApoGuid != APOGUID_NULL && childApoGuid != APOGUID_NOKEY && childApoGuid != APOGUID_NOVALUE)
{ {
GUID childGuid; GUID childGuid;
hr = CLSIDFromString(childApoGuid.c_str(), &childGuid); hr = CLSIDFromString(childApoGuid.c_str(), &childGuid);
if(FAILED(hr)) if (FAILED(hr))
{ {
LogF(L"Can't convert child apo guid string to guid"); LogF(L"Can't convert child apo guid string to guid");
return S_OK; return S_OK;
} }
hr = CoCreateInstance(childGuid, NULL, CLSCTX_INPROC_SERVER, __uuidof(IAudioProcessingObject), (void**)&childAPO); hr = CoCreateInstance(childGuid, NULL, CLSCTX_INPROC_SERVER, __uuidof(IAudioProcessingObject), (void**)&childAPO);
if(FAILED(hr)) if (FAILED(hr))
{ {
LogF(L"Error in CoCreateInstance for child apo"); LogF(L"Error in CoCreateInstance for child apo");
resetChild(); resetChild();
@@ -170,7 +170,7 @@ HRESULT EqualizerAPO::Initialize(UINT32 cbDataSize, BYTE* pbyData)
} }
hr = childAPO->QueryInterface(__uuidof(IAudioProcessingObjectRT), (void**)&childRT); hr = childAPO->QueryInterface(__uuidof(IAudioProcessingObjectRT), (void**)&childRT);
if(FAILED(hr)) if (FAILED(hr))
{ {
LogF(L"Error in QueryInterface for child apo RT"); LogF(L"Error in QueryInterface for child apo RT");
resetChild(); resetChild();
@@ -178,7 +178,7 @@ HRESULT EqualizerAPO::Initialize(UINT32 cbDataSize, BYTE* pbyData)
} }
hr = childAPO->QueryInterface(__uuidof(IAudioProcessingObjectConfiguration), (void**)&childCfg); hr = childAPO->QueryInterface(__uuidof(IAudioProcessingObjectConfiguration), (void**)&childCfg);
if(FAILED(hr)) if (FAILED(hr))
{ {
LogF(L"Error in QueryInterface for child apo configuration"); LogF(L"Error in QueryInterface for child apo configuration");
resetChild(); resetChild();
@@ -186,7 +186,7 @@ HRESULT EqualizerAPO::Initialize(UINT32 cbDataSize, BYTE* pbyData)
} }
hr = childAPO->Initialize(cbDataSize, pbyData); hr = childAPO->Initialize(cbDataSize, pbyData);
if(FAILED(hr)) if (FAILED(hr))
{ {
LogF(L"Error in Initialize of child apo"); LogF(L"Error in Initialize of child apo");
resetChild(); resetChild();
@@ -202,12 +202,12 @@ HRESULT EqualizerAPO::Initialize(UINT32 cbDataSize, BYTE* pbyData)
HRESULT EqualizerAPO::IsInputFormatSupported(IAudioMediaType* pOutputFormat, HRESULT EqualizerAPO::IsInputFormatSupported(IAudioMediaType* pOutputFormat,
IAudioMediaType* pRequestedInputFormat, IAudioMediaType** ppSupportedInputFormat) IAudioMediaType* pRequestedInputFormat, IAudioMediaType** ppSupportedInputFormat)
{ {
if(!pRequestedInputFormat) if (!pRequestedInputFormat)
return E_POINTER; return E_POINTER;
UNCOMPRESSEDAUDIOFORMAT inFormat; UNCOMPRESSEDAUDIOFORMAT inFormat;
HRESULT hr = pRequestedInputFormat->GetUncompressedAudioFormat(&inFormat); HRESULT hr = pRequestedInputFormat->GetUncompressedAudioFormat(&inFormat);
if(FAILED(hr)) if (FAILED(hr))
{ {
LogF(L"Error in GetUncompressedAudioFormat"); LogF(L"Error in GetUncompressedAudioFormat");
return hr; return hr;
@@ -219,7 +219,7 @@ HRESULT EqualizerAPO::IsInputFormatSupported(IAudioMediaType* pOutputFormat,
UNCOMPRESSEDAUDIOFORMAT outFormat; UNCOMPRESSEDAUDIOFORMAT outFormat;
hr = pOutputFormat->GetUncompressedAudioFormat(&outFormat); hr = pOutputFormat->GetUncompressedAudioFormat(&outFormat);
if(FAILED(hr)) if (FAILED(hr))
{ {
LogF(L"Error in second GetUncompressedAudioFormat"); LogF(L"Error in second GetUncompressedAudioFormat");
return hr; return hr;
@@ -229,10 +229,10 @@ HRESULT EqualizerAPO::IsInputFormatSupported(IAudioMediaType* pOutputFormat,
outFormat.guidFormatType.Data1, outFormat.dwSamplesPerFrame, outFormat.dwBytesPerSampleContainer, outFormat.guidFormatType.Data1, outFormat.dwSamplesPerFrame, outFormat.dwBytesPerSampleContainer,
outFormat.dwValidBitsPerSample, outFormat.fFramesPerSecond, outFormat.dwChannelMask); outFormat.dwValidBitsPerSample, outFormat.fFramesPerSecond, outFormat.dwChannelMask);
if(childAPO) if (childAPO)
{ {
hr = childAPO->IsInputFormatSupported(pOutputFormat, pRequestedInputFormat, ppSupportedInputFormat); hr = childAPO->IsInputFormatSupported(pOutputFormat, pRequestedInputFormat, ppSupportedInputFormat);
if(SUCCEEDED(hr)) if (SUCCEEDED(hr))
{ {
TraceF(L"Success in IsInputFormatSupported of child apo"); TraceF(L"Success in IsInputFormatSupported of child apo");
} }
@@ -243,23 +243,23 @@ HRESULT EqualizerAPO::IsInputFormatSupported(IAudioMediaType* pOutputFormat,
} }
} }
if(!childAPO || !SUCCEEDED(hr)) if (!childAPO || !SUCCEEDED(hr))
{ {
hr = CBaseAudioProcessingObject::IsInputFormatSupported(pOutputFormat, pRequestedInputFormat, ppSupportedInputFormat); hr = CBaseAudioProcessingObject::IsInputFormatSupported(pOutputFormat, pRequestedInputFormat, ppSupportedInputFormat);
// we do not support downmixing currently // we do not support downmixing currently
if(hr == S_OK && inFormat.dwSamplesPerFrame > 2 && inFormat.dwSamplesPerFrame > outFormat.dwSamplesPerFrame) if (hr == S_OK && inFormat.dwSamplesPerFrame > 2 && inFormat.dwSamplesPerFrame > outFormat.dwSamplesPerFrame)
{ {
CreateAudioMediaTypeFromUncompressedAudioFormat(&outFormat, ppSupportedInputFormat); CreateAudioMediaTypeFromUncompressedAudioFormat(&outFormat, ppSupportedInputFormat);
hr = S_FALSE; hr = S_FALSE;
} }
} }
if(hr == S_FALSE) if (hr == S_FALSE)
{ {
UNCOMPRESSEDAUDIOFORMAT supportedFormat; UNCOMPRESSEDAUDIOFORMAT supportedFormat;
HRESULT hr2 = (*ppSupportedInputFormat)->GetUncompressedAudioFormat(&supportedFormat); HRESULT hr2 = (*ppSupportedInputFormat)->GetUncompressedAudioFormat(&supportedFormat);
if(FAILED(hr2)) if (FAILED(hr2))
{ {
LogF(L"Error in third GetUncompressedAudioFormat"); LogF(L"Error in third GetUncompressedAudioFormat");
return hr2; return hr2;
@@ -269,7 +269,7 @@ HRESULT EqualizerAPO::IsInputFormatSupported(IAudioMediaType* pOutputFormat,
supportedFormat.guidFormatType.Data1, supportedFormat.dwSamplesPerFrame, supportedFormat.dwBytesPerSampleContainer, supportedFormat.guidFormatType.Data1, supportedFormat.dwSamplesPerFrame, supportedFormat.dwBytesPerSampleContainer,
supportedFormat.dwValidBitsPerSample, supportedFormat.fFramesPerSecond, supportedFormat.dwChannelMask); supportedFormat.dwValidBitsPerSample, supportedFormat.fFramesPerSecond, supportedFormat.dwChannelMask);
} }
else if(hr == S_OK) else if (hr == S_OK)
{ {
TraceF(L"InputFormat accepted"); TraceF(L"InputFormat accepted");
} }
@@ -285,7 +285,7 @@ HRESULT EqualizerAPO::LockForProcess(UINT32 u32NumInputConnections,
UNCOMPRESSEDAUDIOFORMAT inFormat; UNCOMPRESSEDAUDIOFORMAT inFormat;
hr = ppInputConnections[0]->pFormat->GetUncompressedAudioFormat(&inFormat); hr = ppInputConnections[0]->pFormat->GetUncompressedAudioFormat(&inFormat);
if(FAILED(hr)) if (FAILED(hr))
{ {
LogF(L"Error in GetUncompressedAudioFormat in LockForProcess"); LogF(L"Error in GetUncompressedAudioFormat in LockForProcess");
return hr; return hr;
@@ -299,7 +299,7 @@ HRESULT EqualizerAPO::LockForProcess(UINT32 u32NumInputConnections,
UNCOMPRESSEDAUDIOFORMAT outFormat; UNCOMPRESSEDAUDIOFORMAT outFormat;
hr = ppOutputConnections[0]->pFormat->GetUncompressedAudioFormat(&outFormat); hr = ppOutputConnections[0]->pFormat->GetUncompressedAudioFormat(&outFormat);
if(FAILED(hr)) if (FAILED(hr))
{ {
LogF(L"Error in second GetUncompressedAudioFormat in LockForProcess"); LogF(L"Error in second GetUncompressedAudioFormat in LockForProcess");
return hr; return hr;
@@ -311,47 +311,47 @@ HRESULT EqualizerAPO::LockForProcess(UINT32 u32NumInputConnections,
outFormat.guidFormatType.Data1, outFormat.dwSamplesPerFrame, outFormat.dwBytesPerSampleContainer, outFormat.guidFormatType.Data1, outFormat.dwSamplesPerFrame, outFormat.dwBytesPerSampleContainer,
outFormat.dwValidBitsPerSample, outFormat.fFramesPerSecond, outFormat.dwChannelMask, maxOutputFrameCount); outFormat.dwValidBitsPerSample, outFormat.fFramesPerSecond, outFormat.dwChannelMask, maxOutputFrameCount);
if(childCfg != NULL) if (childCfg != NULL)
{ {
hr = childCfg->LockForProcess(u32NumInputConnections, ppInputConnections, u32NumOutputConnections, hr = childCfg->LockForProcess(u32NumInputConnections, ppInputConnections, u32NumOutputConnections,
ppOutputConnections); ppOutputConnections);
if(SUCCEEDED(hr)) if (SUCCEEDED(hr))
TraceF(L"Success in LockForProcess of child apo"); TraceF(L"Success in LockForProcess of child apo");
} }
hr = CBaseAudioProcessingObject::LockForProcess(u32NumInputConnections, ppInputConnections, hr = CBaseAudioProcessingObject::LockForProcess(u32NumInputConnections, ppInputConnections,
u32NumOutputConnections, ppOutputConnections); u32NumOutputConnections, ppOutputConnections);
if(FAILED(hr)) if (FAILED(hr))
{ {
LogF(L"Error in CBaseAudioProcessingObject::LockForProcess"); LogF(L"Error in CBaseAudioProcessingObject::LockForProcess");
return hr; return hr;
} }
else if(hr == S_OK) else if (hr == S_OK)
{ {
TraceF(L"LockForProcess successful"); TraceF(L"LockForProcess successful");
} }
unsigned maxFrameCount = maxInputFrameCount; unsigned maxFrameCount = maxInputFrameCount;
if(maxFrameCount == 0) if (maxFrameCount == 0)
maxFrameCount = maxOutputFrameCount; maxFrameCount = maxOutputFrameCount;
unsigned realChannelCount; unsigned realChannelCount;
if(childCfg != NULL) if (childCfg != NULL)
realChannelCount = outFormat.dwSamplesPerFrame; realChannelCount = outFormat.dwSamplesPerFrame;
else else
realChannelCount = inFormat.dwSamplesPerFrame; realChannelCount = inFormat.dwSamplesPerFrame;
unsigned channelMask; unsigned channelMask;
if(engine.isCapture()) if (engine.isCapture())
{ {
channelMask = inFormat.dwChannelMask; channelMask = inFormat.dwChannelMask;
if(channelMask == 0 && inFormat.dwSamplesPerFrame == outFormat.dwSamplesPerFrame) if (channelMask == 0 && inFormat.dwSamplesPerFrame == outFormat.dwSamplesPerFrame)
channelMask = outFormat.dwChannelMask; channelMask = outFormat.dwChannelMask;
} }
else else
{ {
channelMask = outFormat.dwChannelMask; channelMask = outFormat.dwChannelMask;
if(channelMask == 0 && inFormat.dwSamplesPerFrame == outFormat.dwSamplesPerFrame) if (channelMask == 0 && inFormat.dwSamplesPerFrame == outFormat.dwSamplesPerFrame)
channelMask = inFormat.dwChannelMask; channelMask = inFormat.dwChannelMask;
} }
@@ -362,10 +362,10 @@ HRESULT EqualizerAPO::LockForProcess(UINT32 u32NumInputConnections,
HRESULT EqualizerAPO::UnlockForProcess() HRESULT EqualizerAPO::UnlockForProcess()
{ {
if(childCfg) if (childCfg)
{ {
HRESULT hr = childCfg->UnlockForProcess(); HRESULT hr = childCfg->UnlockForProcess();
if(FAILED(hr)) if (FAILED(hr))
{ {
LogF(L"Error in UnlockForProcess"); LogF(L"Error in UnlockForProcess");
return hr; return hr;
@@ -377,19 +377,19 @@ HRESULT EqualizerAPO::UnlockForProcess()
void EqualizerAPO::resetChild() void EqualizerAPO::resetChild()
{ {
if(childAPO != NULL) if (childAPO != NULL)
{ {
childAPO->Release(); childAPO->Release();
childAPO = NULL; childAPO = NULL;
} }
if(childRT != NULL) if (childRT != NULL)
{ {
childRT->Release(); childRT->Release();
childRT = NULL; childRT = NULL;
} }
if(childCfg != NULL) if (childCfg != NULL)
{ {
childCfg->Release(); childCfg->Release();
childCfg = NULL; childCfg = NULL;
@@ -401,7 +401,7 @@ void EqualizerAPO::APOProcess(UINT32 u32NumInputConnections,
APO_CONNECTION_PROPERTY** ppInputConnections, UINT32 u32NumOutputConnections, APO_CONNECTION_PROPERTY** ppInputConnections, UINT32 u32NumOutputConnections,
APO_CONNECTION_PROPERTY** ppOutputConnections) APO_CONNECTION_PROPERTY** ppOutputConnections)
{ {
switch( ppInputConnections[0]->u32BufferFlags ) switch (ppInputConnections[0]->u32BufferFlags)
{ {
case BUFFER_VALID: case BUFFER_VALID:
case BUFFER_SILENT: case BUFFER_SILENT:
@@ -409,10 +409,10 @@ void EqualizerAPO::APOProcess(UINT32 u32NumInputConnections,
float* inputFrames = reinterpret_cast<float*>(ppInputConnections[0]->pBuffer); float* inputFrames = reinterpret_cast<float*>(ppInputConnections[0]->pBuffer);
float* outputFrames = reinterpret_cast<float*>(ppOutputConnections[0]->pBuffer); float* outputFrames = reinterpret_cast<float*>(ppOutputConnections[0]->pBuffer);
if(ppInputConnections[0]->u32BufferFlags == BUFFER_SILENT) if (ppInputConnections[0]->u32BufferFlags == BUFFER_SILENT)
memset(inputFrames, 0, ppInputConnections[0]->u32ValidFrameCount * engine.getInputChannelCount() * sizeof(float)); memset(inputFrames, 0, ppInputConnections[0]->u32ValidFrameCount * engine.getInputChannelCount() * sizeof(float));
if(childRT) if (childRT)
{ {
childRT->APOProcess(u32NumInputConnections, ppInputConnections, u32NumOutputConnections, ppOutputConnections); childRT->APOProcess(u32NumInputConnections, ppInputConnections, u32NumOutputConnections, ppOutputConnections);
@@ -432,15 +432,15 @@ void EqualizerAPO::APOProcess(UINT32 u32NumInputConnections,
HRESULT EqualizerAPO::NonDelegatingQueryInterface(const IID& iid, void** ppv) HRESULT EqualizerAPO::NonDelegatingQueryInterface(const IID& iid, void** ppv)
{ {
if(iid == __uuidof(IUnknown)) if (iid == __uuidof(IUnknown))
*ppv = static_cast<INonDelegatingUnknown*>(this); *ppv = static_cast<INonDelegatingUnknown*>(this);
else if(iid == __uuidof(IAudioProcessingObject)) else if (iid == __uuidof(IAudioProcessingObject))
*ppv = static_cast<IAudioProcessingObject*>(this); *ppv = static_cast<IAudioProcessingObject*>(this);
else if(iid == __uuidof(IAudioProcessingObjectRT)) else if (iid == __uuidof(IAudioProcessingObjectRT))
*ppv = static_cast<IAudioProcessingObjectRT*>(this); *ppv = static_cast<IAudioProcessingObjectRT*>(this);
else if(iid == __uuidof(IAudioProcessingObjectConfiguration)) else if (iid == __uuidof(IAudioProcessingObjectConfiguration))
*ppv = static_cast<IAudioProcessingObjectConfiguration*>(this); *ppv = static_cast<IAudioProcessingObjectConfiguration*>(this);
else if(iid == __uuidof(IAudioSystemEffects)) else if (iid == __uuidof(IAudioSystemEffects))
*ppv = static_cast<IAudioSystemEffects*>(this); *ppv = static_cast<IAudioSystemEffects*>(this);
else else
{ {
@@ -459,7 +459,7 @@ ULONG EqualizerAPO::NonDelegatingAddRef()
ULONG EqualizerAPO::NonDelegatingRelease() ULONG EqualizerAPO::NonDelegatingRelease()
{ {
if(InterlockedDecrement(&refCount) == 0) if (InterlockedDecrement(&refCount) == 0)
{ {
delete this; delete this;
return 0; return 0;
Loaded 100 of 143 files, more files were not shown because too many files have changed in this diff. Show more