Skip to content

Commit

Permalink
Remove unneeded 'Razer' prefix from various types
Browse files Browse the repository at this point in the history
Everything is already in the openrazer namespace, so no point in making
it extra verbose. There won't be any naming conflicts anyways.

Adjust to libopenrazer changes.
  • Loading branch information
z3ntu committed Jun 1, 2024
1 parent 296c7e9 commit d4d5245
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 45 deletions.
2 changes: 1 addition & 1 deletion src/devicewidget/dpicomboboxwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ DpiComboBoxWidget::DpiComboBoxWidget(QWidget *parent, libopenrazer::Device *devi
dpiComboBox->addItem(QString("%1 DPI").arg(dpi), dpi);
}

openrazer::RazerDPI currDPI = { 0, 0 };
openrazer::DPI currDPI = { 0, 0 };
try {
currDPI = device->getDPI();
} catch (const libopenrazer::DBusException &e) {
Expand Down
16 changes: 8 additions & 8 deletions src/devicewidget/dpisliderwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ DpiSliderWidget::DpiSliderWidget(QWidget *parent, libopenrazer::Device *device)
}

if (device->hasFeature("dpi_stages")) {
QPair<uchar, QVector<openrazer::RazerDPI>> stagesPair = { 1, {} };
QPair<uchar, QVector<openrazer::DPI>> stagesPair = { 1, {} };
try {
stagesPair = device->getDPIStages();
} catch (const libopenrazer::DBusException &e) {
Expand All @@ -91,7 +91,7 @@ DpiSliderWidget::DpiSliderWidget(QWidget *parent, libopenrazer::Device *device)

// Assume user wants DPI synced if all values are currently equal
bool isSynced = true;
for (openrazer::RazerDPI dpi : dpiStages) {
for (openrazer::DPI dpi : dpiStages) {
isSynced &= dpi.dpi_x == dpi.dpi_y;
}
dpiSyncCheckbox->setChecked(isSynced);
Expand All @@ -103,7 +103,7 @@ DpiSliderWidget::DpiSliderWidget(QWidget *parent, libopenrazer::Device *device)
dpiStages.append({ 0, 0 });
}
/* Get DPI for current stage */
openrazer::RazerDPI dpi = dpiStages[stageNumber - 1];
openrazer::DPI dpi = dpiStages[stageNumber - 1];

auto *stageWidget = new DpiStageWidget(stageNumber, minimumDpi, maximumDpi, dpi, activeStage == stageNumber);
stageWidget->setSyncDpi(isSynced);
Expand All @@ -117,7 +117,7 @@ DpiSliderWidget::DpiSliderWidget(QWidget *parent, libopenrazer::Device *device)
device->setDPIStages(activeStage, dpiStages);
});

connect(stageWidget, &DpiStageWidget::dpiChanged, this, [=](int stageNumber, openrazer::RazerDPI dpi) {
connect(stageWidget, &DpiStageWidget::dpiChanged, this, [=](int stageNumber, openrazer::DPI dpi) {
handleStageUpdates();

/* Apply to device */
Expand All @@ -144,7 +144,7 @@ DpiSliderWidget::DpiSliderWidget(QWidget *parent, libopenrazer::Device *device)

handleStageUpdates();
} else {
openrazer::RazerDPI currentDpi = { 0, 0 };
openrazer::DPI currentDpi = { 0, 0 };
try {
currentDpi = device->getDPI();
} catch (const libopenrazer::DBusException &e) {
Expand All @@ -158,7 +158,7 @@ DpiSliderWidget::DpiSliderWidget(QWidget *parent, libopenrazer::Device *device)
auto *stageWidget = new DpiStageWidget(0, minimumDpi, maximumDpi, currentDpi, false);
stageWidget->setSingleStage(true);
stageWidget->setSyncDpi(isSynced);
connect(stageWidget, &DpiStageWidget::dpiChanged, this, [=](int /*stageNumber*/, openrazer::RazerDPI dpi) {
connect(stageWidget, &DpiStageWidget::dpiChanged, this, [=](int /*stageNumber*/, openrazer::DPI dpi) {
device->setDPI(dpi);
});

Expand All @@ -175,7 +175,7 @@ void DpiSliderWidget::handleStageUpdates()
int stageNumber = 1;
dpiStages.clear();
for (DpiStageWidget *stageWidget : dpiStageWidgets) {
openrazer::RazerDPI dpi = stageWidget->getDpi();
openrazer::DPI dpi = stageWidget->getDpi();
if (dpi.dpi_x != 0 && dpi.dpi_y != 0)
dpiStages.insert(stageNumber - 1, dpi);

Expand All @@ -188,7 +188,7 @@ void DpiSliderWidget::handleStageUpdates()

/* Disable "Enable" button if last stage active */
int nrDisabledStages = 0;
for (openrazer::RazerDPI dpiStage : dpiStages) {
for (openrazer::DPI dpiStage : dpiStages) {
if (dpiStage.dpi_x == 0 && dpiStage.dpi_y == 0) {
nrDisabledStages++;
}
Expand Down
2 changes: 1 addition & 1 deletion src/devicewidget/dpisliderwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class DpiSliderWidget : public QWidget
bool singleStage;

uchar activeStage;
QVector<openrazer::RazerDPI> dpiStages;
QVector<openrazer::DPI> dpiStages;

QVector<DpiStageWidget *> dpiStageWidgets;

Expand Down
8 changes: 4 additions & 4 deletions src/devicewidget/dpistagewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <QHBoxLayout>
#include <QVBoxLayout>

DpiStageWidget::DpiStageWidget(int initialStageNumber, int minimumDpi, int maximumDpi, openrazer::RazerDPI currentDpi, bool activeStage, QWidget *parent)
DpiStageWidget::DpiStageWidget(int initialStageNumber, int minimumDpi, int maximumDpi, openrazer::DPI currentDpi, bool activeStage, QWidget *parent)
: QWidget(parent)
{
this->stageNumber = initialStageNumber;
Expand Down Expand Up @@ -182,9 +182,9 @@ bool DpiStageWidget::setStageNumber(int stageNumber)
return true;
}

openrazer::RazerDPI DpiStageWidget::getDpi()
openrazer::DPI DpiStageWidget::getDpi()
{
openrazer::RazerDPI dpi = { 0, 0 };
openrazer::DPI dpi = { 0, 0 };

/* Only provide the value if the stage is enabled */
if (enableCheckBox->isChecked())
Expand All @@ -196,7 +196,7 @@ openrazer::RazerDPI DpiStageWidget::getDpi()

void DpiStageWidget::emitDpiChanged()
{
openrazer::RazerDPI dpi = getDpi();
openrazer::DPI dpi = getDpi();
emit dpiChanged(stageNumber, dpi);
}

Expand Down
6 changes: 3 additions & 3 deletions src/devicewidget/dpistagewidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class DpiStageWidget : public QWidget
{
Q_OBJECT
public:
DpiStageWidget(int initialStageNumber, int minimumDpi, int maximumDpi, openrazer::RazerDPI currentDpi, bool activeStage, QWidget *parent = nullptr);
DpiStageWidget(int initialStageNumber, int minimumDpi, int maximumDpi, openrazer::DPI currentDpi, bool activeStage, QWidget *parent = nullptr);

/* Tell the stage that syncing DPI is active - so the Y axis can get hidden */
void setSyncDpi(bool syncDpi);
Expand All @@ -33,12 +33,12 @@ class DpiStageWidget : public QWidget
bool setStageNumber(int stageNumber);
/* Return the currently selected DPI - if the stage is disabled then pass
* the DPI {0,0} */
openrazer::RazerDPI getDpi();
openrazer::DPI getDpi();

signals:
/* The DPI of this stage have changed - if the stage is disabled then
* pass the DPI {0,0} */
void dpiChanged(int stageNumber, openrazer::RazerDPI dpi);
void dpiChanged(int stageNumber, openrazer::DPI dpi);
/* This stage has been activated */
void stageActivated(int stageNumber);

Expand Down
54 changes: 27 additions & 27 deletions src/devicewidget/ledwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ LedWidget::LedWidget(QWidget *parent, libopenrazer::Led *led)

// TODO Sync effects in comboboxes & colorStuff when the sync checkbox is active

openrazer::RazerEffect currentEffect = openrazer::RazerEffect::Static;
openrazer::Effect currentEffect = openrazer::Effect::Static;
try {
currentEffect = led->getCurrentEffect();
} catch (const libopenrazer::DBusException &e) {
Expand Down Expand Up @@ -84,7 +84,7 @@ LedWidget::LedWidget(QWidget *parent, libopenrazer::Led *led)
colorButton->setObjectName("colorbutton" + QString::number(i));
lightingHBox->addWidget(colorButton);

libopenrazer::RazerCapability capability = comboBox->currentData().value<libopenrazer::RazerCapability>();
libopenrazer::Capability capability = comboBox->currentData().value<libopenrazer::Capability>();
if (capability.getNumColors() < i)
colorButton->hide();
connect(colorButton, &QPushButton::clicked, this, &LedWidget::colorButtonClicked);
Expand All @@ -104,7 +104,7 @@ LedWidget::LedWidget(QWidget *parent, libopenrazer::Led *led)
if (i == 1) // set the 'left' checkbox to activated
radio->setChecked(true);
// Hide radio button when we don't need it
if (currentEffect != openrazer::RazerEffect::Wave && currentEffect != openrazer::RazerEffect::Wheel) {
if (currentEffect != openrazer::Effect::Wave && currentEffect != openrazer::Effect::Wheel) {
radio->hide();
}
lightingHBox->addWidget(radio);
Expand Down Expand Up @@ -181,22 +181,22 @@ void LedWidget::colorButtonClicked()
void LedWidget::fxComboboxChanged(int index)
{
auto *sender = qobject_cast<QComboBox *>(QObject::sender());
libopenrazer::RazerCapability capability;
libopenrazer::Capability capability;

/* In theory we could remove half of this special handling because
* .value<>() will give us a default RazerCapability anyways if it's
* .value<>() will give us a default Capability anyways if it's
* missing. But to be explicit let's do it like this. */
bool isCustomEffect = sender->itemText(index) == "Custom Effect";
if (!isCustomEffect) {
QVariant itemData = sender->itemData(index);
if (!itemData.canConvert<libopenrazer::RazerCapability>())
throw new std::runtime_error("Expected to be able to convert itemData into RazerCapability");
capability = itemData.value<libopenrazer::RazerCapability>();
if (!itemData.canConvert<libopenrazer::Capability>())
throw new std::runtime_error("Expected to be able to convert itemData into Capability");
capability = itemData.value<libopenrazer::Capability>();
} else {
/* We're fine with getting an empty RazerCapability as we do want to
/* We're fine with getting an empty Capability as we do want to
* reset all the extra buttons etc. We just don't want to actually do
* more than UI work with this though. */
capability = libopenrazer::RazerCapability();
capability = libopenrazer::Capability();
}

// Remove "Custom Effect" entry when you switch away from it - only gets added by the Custom Editor button
Expand All @@ -217,7 +217,7 @@ void LedWidget::fxComboboxChanged(int index)
}

// Show/hide the wave radiobuttons
if (capability.getIdentifier() != openrazer::RazerEffect::Wave && capability.getIdentifier() != openrazer::RazerEffect::Wheel) {
if (capability.getIdentifier() != openrazer::Effect::Wave && capability.getIdentifier() != openrazer::Effect::Wheel) {
findChild<QRadioButton *>("radiobutton1")->hide();
findChild<QRadioButton *>("radiobutton2")->hide();
} else {
Expand Down Expand Up @@ -250,70 +250,70 @@ openrazer::WheelDirection LedWidget::getWheelDirection()
: openrazer::WheelDirection::COUNTER_CLOCKWISE;
}

void LedWidget::applyEffectStandardLoc(openrazer::RazerEffect effect)
void LedWidget::applyEffectStandardLoc(openrazer::Effect effect)
{
try {
switch (effect) {
case openrazer::RazerEffect::Off: {
case openrazer::Effect::Off: {
mLed->setOff();
break;
}
case openrazer::RazerEffect::On: {
case openrazer::Effect::On: {
mLed->setOn();
break;
}
case openrazer::RazerEffect::Static: {
case openrazer::Effect::Static: {
openrazer::RGB c = getColorForButton(1);
mLed->setStatic(c);
break;
}
case openrazer::RazerEffect::Breathing: {
case openrazer::Effect::Breathing: {
openrazer::RGB c = getColorForButton(1);
mLed->setBreathing(c);
break;
}
case openrazer::RazerEffect::BreathingDual: {
case openrazer::Effect::BreathingDual: {
openrazer::RGB c1 = getColorForButton(1);
openrazer::RGB c2 = getColorForButton(2);
mLed->setBreathingDual(c1, c2);
break;
}
case openrazer::RazerEffect::BreathingRandom: {
case openrazer::Effect::BreathingRandom: {
mLed->setBreathingRandom();
break;
}
case openrazer::RazerEffect::BreathingMono: {
case openrazer::Effect::BreathingMono: {
mLed->setBreathingMono();
break;
}
case openrazer::RazerEffect::Blinking: {
case openrazer::Effect::Blinking: {
openrazer::RGB c = getColorForButton(1);
mLed->setBlinking(c);
break;
}
case openrazer::RazerEffect::Spectrum: {
case openrazer::Effect::Spectrum: {
mLed->setSpectrum();
break;
}
case openrazer::RazerEffect::Wave: {
case openrazer::Effect::Wave: {
mLed->setWave(getWaveDirection());
break;
}
case openrazer::RazerEffect::Wheel: {
case openrazer::Effect::Wheel: {
mLed->setWheel(getWheelDirection());
break;
}
case openrazer::RazerEffect::Reactive: {
case openrazer::Effect::Reactive: {
openrazer::RGB c = getColorForButton(1);
mLed->setReactive(c, openrazer::ReactiveSpeed::_500MS); // TODO Configure speed?
break;
}
case openrazer::RazerEffect::Ripple: {
case openrazer::Effect::Ripple: {
openrazer::RGB c = getColorForButton(1);
mLed->setRipple(c);
break;
}
case openrazer::RazerEffect::RippleRandom: {
case openrazer::Effect::RippleRandom: {
mLed->setRippleRandom();
break;
}
Expand All @@ -330,7 +330,7 @@ void LedWidget::applyEffect()
{
auto *combobox = findChild<QComboBox *>("combobox");

libopenrazer::RazerCapability capability = combobox->itemData(combobox->currentIndex()).value<libopenrazer::RazerCapability>();
libopenrazer::Capability capability = combobox->itemData(combobox->currentIndex()).value<libopenrazer::Capability>();

applyEffectStandardLoc(capability.getIdentifier());
}
Expand Down
2 changes: 1 addition & 1 deletion src/devicewidget/ledwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class LedWidget : public QWidget
openrazer::WheelDirection getWheelDirection();

void applyEffect();
void applyEffectStandardLoc(openrazer::RazerEffect identifier);
void applyEffectStandardLoc(openrazer::Effect identifier);
};

#endif // LEDWIDGET_H

0 comments on commit d4d5245

Please sign in to comment.