Skip to content

Commit

Permalink
Fixed #114 and fixed #112
Browse files Browse the repository at this point in the history
  • Loading branch information
juliagoda committed Jun 10, 2020
1 parent 3cc4be5 commit deb11f2
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 42 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)

if(COMPILER_SUPPORTS_CXX11)
if (NOT WIN32)
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wlogical-op -Wmissing-declarations -Wmissing-include-dirs -Wnoexcept -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wstrict-null-sentinel -Wstrict-overflow=5 -Wundef -Wno-unused -std=c++11")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wextra -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wlogical-op -Wmissing-declarations -Wmissing-include-dirs -Wnoexcept -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wstrict-null-sentinel -Wstrict-overflow=5 -Wundef -Wno-unused -std=c++11")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif()
Expand Down
21 changes: 15 additions & 6 deletions src/advancebuttondialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include <QComboBox>
#include <QLabel>
#include <QListWidgetItem>
//#include <QTest>


AdvanceButtonDialog::AdvanceButtonDialog(JoyButton *button, QWidget *parent) :
Expand Down Expand Up @@ -599,26 +600,35 @@ void AdvanceButtonDialog::joinSlot()
for(auto mini : *firstGrabBtn->getValue()->getMixSlots())
slotsList.append(new JoyButtonSlot(mini->getSlotCode(), mini->getSlotCodeAlias(), mini->getSlotMode()));

// Q_ASSERT(blankButton->getValue() != nullptr);
blankButton->getValue()->appendMiniSlot<QList<JoyButtonSlot*>>(slotsList);
}
else
{
JoyButtonSlot* slotmini = new JoyButtonSlot(firstGrabBtn->getValue()->getSlotCode(), firstGrabBtn->getValue()->getSlotCodeAlias(), firstGrabBtn->getValue()->getSlotMode());

// Q_ASSERT(blankButton->getValue() != nullptr);
blankButton->getValue()->appendMiniSlot<JoyButtonSlot*>(slotmini);
}

text += firstGrabBtn->getValue()->getSlotString();


}

blankButton->getValue()->setTextData(text);
blankButton->getValue()->setSlotMode(JoyButtonSlot::JoyMix);
blankButton->getValue()->setSlotCode(-1);

deleteSlot(false);

/* for(auto x : *blankButton->getValue()->getMixSlots())
// Q_ASSERT(blankButton->getValue()->getMixSlots() != nullptr);
// Q_ASSERT(blankButton->getValue()->getMixSlots()->count() > 0);

for(auto x : *blankButton->getValue()->getMixSlots())
{
// Q_ASSERT(x->getSlotMode() == 0);
// Q_ASSERT(!x->getSlotString().isEmpty());
qDebug() << "JOINED MINI: " << x->getSlotCode() << " - " << x->getSlotMode() << " - " << x->getSlotString();
}*/
}


QListWidgetItem *joinedItem = new QListWidgetItem();
Expand All @@ -635,7 +645,7 @@ void AdvanceButtonDialog::joinSlot()
ui->slotListWidget->setItemWidget(joinedItem, widget);
ui->slotListWidget->setCurrentItem(joinedItem);

blankButton->setValues(text, blankButton->getValue()->getMixSlots(), JoyButtonSlot::JoyMix);
// blankButton->setValues(text, blankButton->getValue()->getMixSlots(), JoyButtonSlot::JoyMix);

connectButtonEvents(blankButton);
blankButton->refreshButtonLabel(); // instead of blankButton->setText(text);
Expand All @@ -646,7 +656,6 @@ void AdvanceButtonDialog::joinSlot()
Q_ARG(bool, false));
}


joinLock.unlock();
}

Expand Down
33 changes: 9 additions & 24 deletions src/joybutton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2462,29 +2462,21 @@ bool JoyButton::insertAssignedSlot(JoyButtonSlot *newSlot, bool updateActiveStri
}


bool JoyButton::insertAssignedSlot(JoyButtonSlot *slot, int index, bool updateActiveString)
bool JoyButton::insertAssignedSlot(JoyButtonSlot *newSlot, int index, bool updateActiveString)
{
qInstallMessageHandler(MessageHandler::myMessageOutput);

bool permitSlot = true;
//JoyButtonSlot *slot = new JoyButtonSlot(newSlot, this);
JoyButtonSlot *slot = new JoyButtonSlot(newSlot, this);

if (slot->getSlotMode() == JoyButtonSlot::JoyDistance && (slot->getSlotCode() >= 1) && (slot->getSlotCode() <= 100))
{
if (getTotalSlotDistance(slot) > 1.0) permitSlot = false;
}
else if (slot->getSlotMode() == JoyButtonSlot::JoyMix && slot->getMixSlots()->count() == 0)
{
permitSlot = false;
}
else if (slot->getSlotCode() < 0)
{
permitSlot = false;
}
else if (slot->getSlotMode() == JoyButtonSlot::JoyMix && slot->getMixSlots()->count() < 2)
{
permitSlot = false;
}

if (permitSlot)
{
Expand All @@ -2506,17 +2498,18 @@ bool JoyButton::insertAssignedSlot(JoyButtonSlot *slot, int index, bool updateAc
checkTurboCondition(slot);
assignmentsLock.unlock();
buildActiveZoneSummaryString();

if (updateActiveString)
buildActiveZoneSummaryString();

emit slotsChanged();
}
/* else if (slot != nullptr)
else if (slot != nullptr)
{
/*if (slot->getSlotMode() == 15)
{
qDeleteAll(*slot->getMixSlots());
}*/

delete slot;
slot = nullptr;
}*/
}

return permitSlot;
}
Expand Down Expand Up @@ -3313,14 +3306,6 @@ void JoyButton::clearAssignedSlots(bool signalEmit)
{
auto el = iter.next();
qDebug() << "AssignedSLot mode: " << el->getSlotMode();

if (el->getSlotMode() == JoyButtonSlot::JoySlotInputAction::JoyMix)
{
for (auto j : *el->getMixSlots())
{
qDebug() << "Minislot: " << j->getSlotString();
}
}
}

while (iter.hasNext())
Expand Down
31 changes: 23 additions & 8 deletions src/joybuttonslot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,31 @@ JoyButtonSlot::JoyButtonSlot(JoyButtonSlot *slot, QObject *parent) :
{
qInstallMessageHandler(MessageHandler::myMessageOutput);

deviceCode = slot->deviceCode;
qkeyaliasCode = slot->qkeyaliasCode;
m_mode = slot->m_mode;
m_distance = slot->m_distance;
easingActive = false;
m_textData = slot->m_textData;
extraData = slot->extraData;
// setMixSlots(slot->mix_slots);
this->deviceCode = slot->getSlotCode();
this->m_mode = slot->getSlotMode();
this->qkeyaliasCode = slot->getSlotCodeAlias();
this->m_distance = slot->getDistance();
this->previousDistance = slot->getPreviousDistance();
this->easingActive = slot->isEasingActive();
this->easingTime.fromString(slot->getEasingTime()->toString());
this->extraData = slot->getExtraData();

/*
* if (slot->getMixSlots() != nullptr)
{
secureMixSlotsInit();
for(auto minislot : *slot->getMixSlots())
{
this->mix_slots->append(new JoyButtonSlot(minislot->getSlotCode(), minislot->getSlotCodeAlias(), minislot->getSlotMode()));
}
}*/

if (slot->getMixSlots() != nullptr)
this->mix_slots = slot->getMixSlots();

if (!slot->getTextData().isNull() ^ (slot->getTextData() != ""))
this->m_textData = slot->getTextData();
}

JoyButtonSlot::JoyButtonSlot(QString text, JoySlotInputAction mode, QObject *parent) :
Expand Down
2 changes: 0 additions & 2 deletions src/joybuttonslot.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ class JoyButtonSlot : public QObject
JoyButtonSlot& operator=(JoyButtonSlot* slot);




private:
void secureMixSlotsInit();

Expand Down

0 comments on commit deb11f2

Please sign in to comment.