| 1 | #cxx . . $ `<file>/src/InteractiveButton.cpp`/include "InteractiveButton.h"cxx . . $ `<file>/src/InteractiveButton.h`/ |
| 2 | #include <QApplication> |
| 3 | #include <QPalette> |
| 4 | |
| 5 | InteractiveButtoncxx . . $ InteractiveButton#::InteractiveButtoncxx . . $ InteractiveButton#InteractiveButton(108f35f7aa7f3cf9).(QWidgetcxx . . $ QWidget#* parent) |
| 6 | : QPushButtoncxx . . $ QPushButton#(parent) |
| 7 | { |
| 8 | setEnabledcxx . . $ QWidget#setEnabled(b45ddcbc8423892c).(true); |
| 9 | setAutoFillBackgroundcxx . . $ QWidget#setAutoFillBackground(b45ddcbc8423892c).(true); |
| 10 | _mustBeSetcxx . . $ InteractiveButton#_mustBeSet. = false; |
| 11 | _highlightcxx . . $ InteractiveButton#_highlight. = false; |
| 12 | connectcxx . . $ QObject#connect(835f87066c895669).(this, &InteractiveButtoncxx . . $ InteractiveButton#::toggledcxx . . $ QAbstractButton#toggled(b45ddcbc8423892c)., this, &InteractiveButtoncxx . . $ InteractiveButton#::newBitValueSlotcxx . . $ InteractiveButton#newBitValueSlot(b45ddcbc8423892c).); |
| 13 | } |
| 14 | |
| 15 | void InteractiveButtoncxx . . $ InteractiveButton#::highlightcxx . . $ InteractiveButton#highlight(b45ddcbc8423892c).(bool state) |
| 16 | { |
| 17 | if (_highlightcxx . . $ InteractiveButton#_highlight. == state) return; |
| 18 | |
| 19 | _highlightcxx . . $ InteractiveButton#_highlight. = state; |
| 20 | setColorcxx . . $ InteractiveButton#setColor(49f6e7a06ebc5aa8).(); |
| 21 | } |
| 22 | |
| 23 | void InteractiveButtoncxx . . $ InteractiveButton#::setColorcxx . . $ InteractiveButton#setColor(49f6e7a06ebc5aa8).() |
| 24 | { |
| 25 | // No style sheet since this will not work for Mac OS X atm. |
| 26 | QPalettecxx . . $ QPalette# fiddle = QApplicationcxx . . $ QApplication#::palettecxx . . $ QApplication#palette(522fbdbbff1b5a68).(); |
| 27 | int colorset = (_mustBeSetcxx . . $ InteractiveButton#_mustBeSet. ? 4 : 0) + (_highlightcxx . . $ InteractiveButton#_highlight. ? 2 : 0) + ((_mustBeSetcxx . . $ InteractiveButton#_mustBeSet. & !_statecxx . . $ InteractiveButton#_state.) ? 1 : 0); |
| 28 | switch (colorset) { |
| 29 | case 6: |
| 30 | fiddle.setColorcxx . . $ QPalette#setColor(5c3218fcc49a2895).(QPalettecxx . . $ QPalette#::Activecxx . . $ QPalette#Active., QPalettecxx . . $ QPalette#::Buttoncxx . . $ QPalette#Button., Qtcxx . . $ QColor#QColor(408ec4d5924bfb00).::greencxx . . $ Qt/green.); |
| 31 | break; |
| 32 | case 4: |
| 33 | fiddle.setColorcxx . . $ QPalette#setColor(5c3218fcc49a2895).(QPalettecxx . . $ QPalette#::Activecxx . . $ QPalette#Active., QPalettecxx . . $ QPalette#::Buttoncxx . . $ QPalette#Button., Qtcxx . . $ QColor#QColor(408ec4d5924bfb00).::darkGreencxx . . $ Qt/darkGreen.); |
| 34 | break; |
| 35 | case 3: |
| 36 | case 7: |
| 37 | fiddle.setColorcxx . . $ QPalette#setColor(5c3218fcc49a2895).(QPalettecxx . . $ QPalette#::Activecxx . . $ QPalette#Active., QPalettecxx . . $ QPalette#::Buttoncxx . . $ QPalette#Button., Qtcxx . . $ QColor#QColor(408ec4d5924bfb00).::redcxx . . $ Qt/red.); |
| 38 | break; |
| 39 | case 2: |
| 40 | fiddle.setColorcxx . . $ QPalette#setColor(5c3218fcc49a2895).(QPalettecxx . . $ QPalette#::Activecxx . . $ QPalette#Active., QPalettecxx . . $ QPalette#::Buttoncxx . . $ QPalette#Button., Qtcxx . . $ QColor#QColor(408ec4d5924bfb00).::yellowcxx . . $ Qt/yellow.); |
| 41 | break; |
| 42 | case 5: |
| 43 | case 1: |
| 44 | fiddle.setColorcxx . . $ QPalette#setColor(5c3218fcc49a2895).(QPalettecxx . . $ QPalette#::Activecxx . . $ QPalette#Active., QPalettecxx . . $ QPalette#::Buttoncxx . . $ QPalette#Button., Qtcxx . . $ QColor#QColor(408ec4d5924bfb00).::darkRedcxx . . $ Qt/darkRed.); |
| 45 | break; |
| 46 | } |
| 47 | setPalettecxx . . $ QWidget#setPalette(f826ed73d5553cd5).(fiddle); |
| 48 | updatecxx . . $ QWidget#update(49f6e7a06ebc5aa8).(); |
| 49 | } |
| 50 | |
| 51 | void InteractiveButtoncxx . . $ InteractiveButton#::enterEventcxx . . $ InteractiveButton#enterEvent(c2473e2e70986fd7).(QEventcxx . . $ QEvent#* /*event*/) |
| 52 | { |
| 53 | emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! mouseOvercxx . . $ InteractiveButton#mouseOver(b45ddcbc8423892c).(true); |
| 54 | } |
| 55 | |
| 56 | void InteractiveButtoncxx . . $ InteractiveButton#::leaveEventcxx . . $ InteractiveButton#leaveEvent(c2473e2e70986fd7).(QEventcxx . . $ QEvent#* /*event*/) |
| 57 | { |
| 58 | emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! mouseOvercxx . . $ InteractiveButton#mouseOver(b45ddcbc8423892c).(false); |
| 59 | } |
| 60 | |
| 61 | void InteractiveButtoncxx . . $ InteractiveButton#::newBitValueSlotcxx . . $ InteractiveButton#newBitValueSlot(b45ddcbc8423892c).(bool state) |
| 62 | { |
| 63 | _statecxx . . $ InteractiveButton#_state.=state; |
| 64 | QStringcxx . . $ QString# name = objectNamecxx . . $ QObject#objectName(6ef7b6c27b00b43d).(); |
| 65 | int bit = name.rightcxx . . $ QString#right(3f3c3d0e9c0eb37f).(1).toIntcxx . . $ QString#toInt(d7972accae11ee1f).(); |
| 66 | int reg = name.midcxx . . $ QString#mid(44b7563da18aea72).( |
| 67 | 1 + name.indexOfcxx . . $ QString#indexOf(75b556ba78e4903c).('_'cxx . . $ QChar#QChar(f349c77f591a7878).), |
| 68 | name.lastIndexOfcxx . . $ QString#lastIndexOf(75b556ba78e4903c).('_'cxx . . $ QChar#QChar(f349c77f591a7878).) - name.indexOfcxx . . $ QString#indexOf(75b556ba78e4903c).('_'cxx . . $ QChar#QChar(f349c77f591a7878).) - 1).toIntcxx . . $ QString#toInt(d7972accae11ee1f).(); |
| 69 | emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! newBitValuecxx . . $ InteractiveButton#newBitValue(6908015b96d379c0).(reg, bit, state); |
| 70 | setColorcxx . . $ InteractiveButton#setColor(49f6e7a06ebc5aa8).(); |
| 71 | } |
| 72 | |
| 73 | void InteractiveButtoncxx . . $ InteractiveButton#::mustBeSetcxx . . $ InteractiveButton#mustBeSet(b45ddcbc8423892c).(bool state) |
| 74 | { |
| 75 | if (state == _mustBeSetcxx . . $ InteractiveButton#_mustBeSet.) return; |
| 76 | _mustBeSetcxx . . $ InteractiveButton#_mustBeSet. = state; |
| 77 | setColorcxx . . $ InteractiveButton#setColor(49f6e7a06ebc5aa8).(); |
| 78 | } |