From d3335dec58fff9fd5f33433f80c0a1f7500c1ea5 Mon Sep 17 00:00:00 2001 From: Benjamin Dobell Date: Sat, 21 Feb 2015 03:44:07 +1100 Subject: Fixed a few Heimdall Frontend niggles Yes, the HeimdallState enum class operator overloading and operator usage is crazy nonsense. I want to love enum class, but this is just ridiculous. --- heimdall-frontend/source/mainwindow.h | 43 +++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 10 deletions(-) (limited to 'heimdall-frontend/source/mainwindow.h') diff --git a/heimdall-frontend/source/mainwindow.h b/heimdall-frontend/source/mainwindow.h index 8783792..d0b8703 100644 --- a/heimdall-frontend/source/mainwindow.h +++ b/heimdall-frontend/source/mainwindow.h @@ -39,22 +39,45 @@ using namespace libpit; namespace HeimdallFrontend { + enum class HeimdallState : int + { + Stopped = 1, + Flashing = (int)Stopped << 1, + DetectingDevice = (int)Flashing << 1, + ClosingPcScreen = (int)DetectingDevice << 1, + PrintingPit = (int)ClosingPcScreen << 1, + DownloadingPit = (int)PrintingPit << 1, + NoReboot = (int)DownloadingPit << 1 + }; + + inline HeimdallState operator|(HeimdallState lhs, HeimdallState rhs) + { + return (HeimdallState)((int)lhs | (int)rhs); + } + + inline HeimdallState& operator|=(HeimdallState& lhs, HeimdallState rhs) + { + lhs = lhs | rhs; + return lhs; + } + + inline HeimdallState operator&(HeimdallState lhs, HeimdallState rhs) + { + lhs = (HeimdallState)((int)lhs & (int)rhs); + return lhs; + } + + inline bool operator!(HeimdallState state) + { + return (int)state == 0; + } + class MainWindow : public QMainWindow, public Ui::MainWindow { Q_OBJECT private: - enum class HeimdallState - { - Stopped = 0, - Flashing, - DetectingDevice, - ClosingPcScreen, - PrintingPit, - DownloadingPit - }; - enum { kPrintPitSourceDevice = 0, -- cgit v1.2.3