Skip to content

Commit

Permalink
Fix live update of DX grabbing
Browse files Browse the repository at this point in the history
  • Loading branch information
psieg committed Aug 1, 2015
1 parent 5401a5e commit c299b65
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 28 deletions.
22 changes: 18 additions & 4 deletions Software/src/GrabManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,6 @@ void GrabManager::onGrabberTypeChanged(const Grab::GrabberType grabberType)

m_grabber = queryGrabber(grabberType);

#ifdef D3D10_GRAB_SUPPORT
reinitDx1011Grabber();
#endif

if (isStartNeeded) {
#ifdef D3D10_GRAB_SUPPORT
if (Settings::isDx1011GrabberEnabled())
Expand Down Expand Up @@ -239,6 +235,20 @@ void GrabManager::onSendDataOnlyIfColorsEnabledChanged(bool state)
m_isSendDataOnlyIfColorsChanged = state;
}

#ifdef D3D10_GRAB_SUPPORT
void GrabManager::onDx1011GrabberEnabledChanged(bool state)
{
DEBUG_LOW_LEVEL << Q_FUNC_INFO << state;
reinitDx1011Grabber();
}

void GrabManager::onDx9GrabberEnabledChanged(bool state)
{
DEBUG_LOW_LEVEL << Q_FUNC_INFO << state;
reinitDx1011Grabber();
}
#endif

void GrabManager::setNumberOfLeds(int numberOfLeds)
{
DEBUG_LOW_LEVEL << Q_FUNC_INFO << numberOfLeds;
Expand Down Expand Up @@ -551,6 +561,8 @@ GrabberBase *GrabManager::initGrabber(GrabberBase * grabber) {

#ifdef D3D10_GRAB_SUPPORT
void GrabManager::reinitDx1011Grabber() {
QApplication::setOverrideCursor(Qt::WaitCursor);

if (m_d3d10Grabber) {
delete m_d3d10Grabber;
m_d3d10Grabber = NULL;
Expand All @@ -561,6 +573,8 @@ void GrabManager::reinitDx1011Grabber() {
connect(m_d3d10Grabber, SIGNAL(grabberStateChangeRequested(bool)), SLOT(onGrabberStateChangeRequested(bool)));
m_d3d10Grabber->init();
}

QApplication::restoreOverrideCursor();
}
#endif

Expand Down
4 changes: 4 additions & 0 deletions Software/src/GrabManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ public slots:
void onGrabSlowdownChanged(int ms);
void onGrabAvgColorsEnabledChanged(bool state);
void onSendDataOnlyIfColorsEnabledChanged(bool state);
#ifdef D3D10_GRAB_SUPPORT
void onDx1011GrabberEnabledChanged(bool state);
void onDx9GrabberEnabledChanged(bool state);
#endif
void start(bool isGrabEnabled);
void settingsProfileChanged(const QString &profileName);
void setVisibleLedWidgets(bool state);
Expand Down
4 changes: 4 additions & 0 deletions Software/src/LightpackApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,10 @@ void LightpackApplication::initGrabManager()
connect(settings(), SIGNAL(grabSlowdownChanged(int)), m_grabManager, SLOT(onGrabSlowdownChanged(int)), Qt::QueuedConnection);
connect(settings(), SIGNAL(grabAvgColorsEnabledChanged(bool)), m_grabManager, SLOT(onGrabAvgColorsEnabledChanged(bool)), Qt::QueuedConnection);
connect(settings(), SIGNAL(sendDataOnlyIfColorsChangesChanged(bool)), m_grabManager, SLOT(onSendDataOnlyIfColorsEnabledChanged(bool)), Qt::QueuedConnection);
#ifdef D3D10_GRAB_SUPPORT
connect(settings(), SIGNAL(dx1011GrabberEnabledChanged(bool)), m_grabManager, SLOT(onDx1011GrabberEnabledChanged(bool)), Qt::QueuedConnection);
connect(settings(), SIGNAL(dx9GrabberEnabledChanged(bool)), m_grabManager, SLOT(onDx9GrabberEnabledChanged(bool)), Qt::QueuedConnection);
#endif

connect(settings(), SIGNAL(profileLoaded(const QString &)), m_grabManager, SLOT(settingsProfileChanged(const QString &)), Qt::QueuedConnection);
connect(settings(), SIGNAL(currentProfileInited(const QString &)), m_grabManager, SLOT(settingsProfileChanged(const QString &)), Qt::QueuedConnection);
Expand Down
2 changes: 2 additions & 0 deletions Software/src/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1147,12 +1147,14 @@ void Settings::setDx1011GrabberEnabled(bool isEnabled) {
setValue(Profile::Key::Grab::IsDx1011GrabberEnabled, isEnabled);
m_this->dx1011GrabberEnabledChanged(isEnabled);
}

bool Settings::isDx9GrabbingEnabled() {
return value(Profile::Key::Grab::IsDx9GrabbingEnabled).toBool();
}

void Settings::setDx9GrabbingEnabled(bool isEnabled) {
setValue(Profile::Key::Grab::IsDx9GrabbingEnabled, isEnabled);
m_this->dx9GrabberEnabledChanged(isEnabled);
}
#endif

Expand Down
19 changes: 11 additions & 8 deletions Software/src/Settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ class Settings : public QObject
static void setExpertModeEnabled(bool isEnabled);
static bool isKeepLightsOnAfterExit();
static void setKeepLightsOnAfterExit(bool isEnabled);
static bool isKeepLightsOnAfterLock();
static void setKeepLightsOnAfterLock(bool isEnabled);
static bool isKeepLightsOnAfterLock();
static void setKeepLightsOnAfterLock(bool isEnabled);
static bool isPingDeviceEverySecond();
static void setPingDeviceEverySecond(bool isEnabled);
static bool isUpdateFirmwareMessageShown();
Expand Down Expand Up @@ -166,10 +166,10 @@ class Settings : public QObject
static void setGrabberType(Grab::GrabberType grabMode);

#ifdef D3D10_GRAB_SUPPORT
static bool isDx1011GrabberEnabled();
static void setDx1011GrabberEnabled(bool isEnabled);
static bool isDx9GrabbingEnabled();
static void setDx9GrabbingEnabled(bool isEnabled);
static bool isDx1011GrabberEnabled();
static void setDx1011GrabberEnabled(bool isEnabled);
static bool isDx9GrabbingEnabled();
static void setDx9GrabbingEnabled(bool isEnabled);
#endif

static Lightpack::Mode getLightpackMode();
Expand Down Expand Up @@ -240,7 +240,7 @@ class Settings : public QObject
void apiKeyChanged(const QString &);
void expertModeEnabledChanged(bool);
void keepLightsOnAfterExitChanged(bool isEnabled);
void keepLightsOnAfterLockChanged(bool isEnabled);
void keepLightsOnAfterLockChanged(bool isEnabled);
void pingDeviceEverySecondEnabledChanged(bool);

void languageChanged(const QString &);
Expand Down Expand Up @@ -269,7 +269,10 @@ class Settings : public QObject
void deviceGammaChanged(double gamma);
void deviceColorSequenceChanged(QString value);
void grabberTypeChanged(const Grab::GrabberType grabMode);
void dx1011GrabberEnabledChanged(const bool isEnabled);
#ifdef D3D10_GRAB_SUPPORT
void dx1011GrabberEnabledChanged(bool isEnabled);
void dx9GrabberEnabledChanged(bool isEnabled);
#endif
void lightpackModeChanged(const Lightpack::Mode mode);
void moodLampLiquidModeChanged(bool isLiquidMode);
void moodLampColorChanged(const QColor color);
Expand Down
35 changes: 19 additions & 16 deletions Software/src/SettingsWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,6 @@ void SettingsWindow::connectSignalsSlots()
connect(ui->checkBox_KeepLightsOnAfterLockComputer, SIGNAL(toggled(bool)), this, SLOT(onKeepLightsAfterLock_Toggled(bool)));

// Dev tab
connect(ui->checkBox_EnableDx1011Capture, SIGNAL(toggled(bool)), this, SLOT(onGrabberChanged()));
connect(ui->checkBox_EnableDx9Capture, SIGNAL(toggled(bool)), this, SLOT(onGrabberChanged()));
#ifdef QT_GRAB_SUPPORT
connect(ui->radioButton_GrabQt, SIGNAL(toggled(bool)), this, SLOT(onGrabberChanged()));
connect(ui->radioButton_GrabQt_EachWidget, SIGNAL(toggled(bool)), this, SLOT(onGrabberChanged()));
Expand Down Expand Up @@ -560,19 +558,6 @@ void SettingsWindow::setDeviceLockViaAPI(DeviceLocked::DeviceLockStatus status,
startBacklight();
}

void SettingsWindow::onDx1011CaptureEnabledChanged(bool isEnabled) {
DEBUG_LOW_LEVEL << Q_FUNC_INFO << isEnabled;
#ifdef D3D10_GRAB_SUPPORT
Settings::setDx1011GrabberEnabled(isEnabled);
ui->checkBox_EnableDx9Capture->setEnabled(isEnabled);
#endif
}
void SettingsWindow::onDx9CaptureEnabledChanged(bool isEnabled) {
DEBUG_LOW_LEVEL << Q_FUNC_INFO << isEnabled;
#ifdef D3D10_GRAB_SUPPORT
Settings::setDx9GrabbingEnabled(isEnabled);
#endif
}
void SettingsWindow::setModeChanged(Lightpack::Mode mode)
{
DEBUG_LOW_LEVEL << Q_FUNC_INFO << mode;
Expand Down Expand Up @@ -1057,12 +1042,30 @@ void SettingsWindow::onGrabberChanged()

if (grabberType != Settings::getGrabberType()) {
DEBUG_LOW_LEVEL << Q_FUNC_INFO << "GrabberType: " << grabberType << ", isDx1011CaptureEnabled: " << isDx1011CaptureEnabled();

Settings::setGrabberType(grabberType);
}
}
}

void SettingsWindow::onDx1011CaptureEnabledChanged(bool isEnabled) {
DEBUG_LOW_LEVEL << Q_FUNC_INFO << isEnabled;
if (!updatingFromSettings) {
#ifdef D3D10_GRAB_SUPPORT
Settings::setDx1011GrabberEnabled(isEnabled);
#endif
}
ui->checkBox_EnableDx9Capture->setEnabled(isEnabled);
}

void SettingsWindow::onDx9CaptureEnabledChanged(bool isEnabled) {
DEBUG_LOW_LEVEL << Q_FUNC_INFO << isEnabled;
if (!updatingFromSettings) {
#ifdef D3D10_GRAB_SUPPORT
Settings::setDx9GrabbingEnabled(isEnabled);
#endif
}
}

void SettingsWindow::onGrabSlowdown_valueChanged(int value)
{
DEBUG_LOW_LEVEL << Q_FUNC_INFO << value;
Expand Down

0 comments on commit c299b65

Please sign in to comment.