diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f3d4cb11d..f81a6e1e6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,14 +16,14 @@ jobs: steps: - uses: actions/checkout@v2 - with: + with: submodules: recursive fetch-depth: 0 - name: Install Qt5 run: | sudo apt-get update - sudo apt-get install build-essential libgl1-mesa-dev libxkbcommon-x11-0 libpulse-dev -y + sudo apt-get install build-essential libgl1-mesa-dev libxkbcommon-x11-0 libpulse-dev -y cmake libkf5config-dev python3 -m pip install setuptools wheel python3 -m pip install py7zr==0.10.1 python3 -m pip install aqtinstall==0.9.7 @@ -40,7 +40,7 @@ jobs: export PATH - name: Install AppImage dependencies run: | - sudo apt-get install libgstreamer-plugins-base1.0-0 libgstreamer-plugins-base1.0-dev + sudo apt-get install libgstreamer-plugins-base1.0-0 libgstreamer-plugins-base1.0-dev sudo apt-get install libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-render-util0-dev libxcb-render-util0 libxcb-xinerama0 - name: Get linuxdeployqt run: | @@ -50,10 +50,7 @@ jobs: run: | PATH=/home/runner/work/wiredpanda-testing/Qt/5.15.1/gcc_64/bin:$PATH export PATH - mkdir build - cd build - qmake ../WPanda.pro - make -j8 + cmake -B build -DCMAKE_BUILD_TYPE=Release && cmake --build build --parallel --config Release - name: Deploy uses: actions/upload-artifact@v2 with: @@ -66,7 +63,7 @@ jobs: export PATH cp installer/Linux/portable_files/wpanda.desktop build/app/wpanda.desktop cp app/resources/wpanda.png build/app/wpanda.png - ~/linuxdeployqt-continuous-x86_64.AppImage build/app/wpanda -appimage + ~/linuxdeployqt-continuous-x86_64.AppImage build/app/wpanda -appimage - name: Upload WiredPanda AppImage uses: actions/upload-artifact@v2 with: @@ -81,7 +78,7 @@ jobs: steps: - uses: actions/checkout@v2 - with: + with: submodules: recursive fetch-depth: 0 @@ -90,13 +87,13 @@ jobs: with: version: 5.15.1 modules: qtcharts qtmultimedia + run: | + sudo apt-get update + sudo apt-get install build-essential libgl1-mesa-dev libxkbcommon-x11-0 libpulse-dev -y cmake libkf5config-dev - name: Build run: | - mkdir build - cd build - qmake ../WPanda.pro - make -j8 + cmake -B build -DCMAKE_BUILD_TYPE=Release && cmake --build build --parallel --config Release - name: Deploy uses: actions/upload-artifact@v2 with: @@ -109,7 +106,7 @@ jobs: steps: - uses: actions/checkout@v2 - with: + with: submodules: recursive fetch-depth: 0 @@ -125,10 +122,7 @@ jobs: - name: Build run: | - mkdir build - cd build - qmake ../WPanda.pro - make -j8 + cmake -B build -DCMAKE_BUILD_TYPE=Release && cmake --build build --parallel --config Release - name: Deploy WiredPanda binary run : | cd build\app\release @@ -153,7 +147,7 @@ jobs: steps: - uses: actions/checkout@v2 - with: + with: submodules: recursive fetch-depth: 0 @@ -163,10 +157,7 @@ jobs: - name: Build run: | QTDIR="/usr/local/opt/qt/" && PATH="${QTDIR}/bin:$PATH" && LDFLAGS=-L${QTDIR}/lib && CPPFLAGS=-I${QTDIR}/include; - mkdir build - cd build - qmake ../WPanda.pro - make -j8 + cmake -B build -DCMAKE_BUILD_TYPE=Release && cmake --build build --parallel --config Release - name: Deploy uses: actions/upload-artifact@v2 with: diff --git a/CMakeLists.txt b/CMakeLists.txt index 5a7b57e09..a351e47b8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,6 +26,12 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) +if(MSVC) + set(COMPILE_WARNS /W4 /WX) +else() + set(COMPILE_WARNS -Wall -Wextra -pedantic) +endif() + add_compile_definitions( QT_USE_QSTRINGBUILDER QT_NO_CAST_TO_ASCII @@ -57,7 +63,7 @@ set( KF5::ConfigGui ) -find_package (ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE) +find_package (ECM ${KF5_MIN_VERSION} NO_MODULE) set (CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) include(cmake/Git.cmake) diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 3006e9726..5033e8d3e 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -51,6 +51,7 @@ target_compile_definitions( -DCURRENTDIR="${CMAKE_CURRENT_SOURCE_DIR}" -DAPP_VERSION="${APP_VERSION}" ) +target_compile_options( wpandacommon PUBLIC ${COMPILE_WARNS} ) add_subdirectory(element) add_subdirectory(logicelement) @@ -90,6 +91,7 @@ target_compile_definitions( PUBLIC -DAPP_VERSION="${APP_VERSION}" ) +target_compile_options( wpanda PUBLIC ${COMPILE_WARNS} ) target_link_libraries( wpanda diff --git a/app/element/CMakeLists.txt b/app/element/CMakeLists.txt index 97fd4b340..4f4b799f0 100644 --- a/app/element/CMakeLists.txt +++ b/app/element/CMakeLists.txt @@ -30,3 +30,4 @@ set ( # tlatch.cpp add_library(wpandaelements ${WPANDA_ELEMENT} ) target_link_libraries(wpandaelements PUBLIC ${WPANDA_LIBS} ) +target_compile_options(wpandaelements PRIVATE ${COMPILE_WARNS} ) diff --git a/app/element/and.cpp b/app/element/and.cpp index 89d065c49..3660ab56a 100644 --- a/app/element/and.cpp +++ b/app/element/and.cpp @@ -6,10 +6,10 @@ And::And(QGraphicsItem *parent) : GraphicElement(ElementType::AND, ElementGroup::GATE, 2, 8, 1, 1, parent) { - pixmapSkinName = {":/basic/and.png"}; + m_pixmapSkinName = {":/basic/and.png"}; setOutputsOnTop(true); - setPixmap(pixmapSkinName[0]); + setPixmap(m_pixmapSkinName[0]); updatePorts(); setCanChangeSkin(true); setPortName("AND"); @@ -18,6 +18,6 @@ And::And(QGraphicsItem *parent) void And::setSkin(bool defaultSkin, const QString &filename) { - pixmapSkinName[0] = defaultSkin ? ":/basic/and.png" : filename; - setPixmap(pixmapSkinName[0]); + m_pixmapSkinName[0] = defaultSkin ? ":/basic/and.png" : filename; + setPixmap(m_pixmapSkinName[0]); } diff --git a/app/element/buzzer.cpp b/app/element/buzzer.cpp index aa26828ca..b7c6a30e4 100644 --- a/app/element/buzzer.cpp +++ b/app/element/buzzer.cpp @@ -23,12 +23,12 @@ static constexpr std::array defaultSkins { Buzzer::Buzzer(QGraphicsItem *parent) : GraphicElement(ElementType::BUZZER, ElementGroup::OUTPUT, 1, 1, 0, 0, parent) { - // pixmapSkinName.append( ":/output/BuzzerOff.png" ); - // pixmapSkinName.append( ":/output/BuzzerOn.png" ); + // m_pixmapSkinName.append( ":/output/BuzzerOff.png" ); + // m_pixmapSkinName.append( ":/output/BuzzerOn.png" ); setOutputsOnTop(true); setRotatable(false); setHasAudio(true); - // setPixmap( pixmapSkinName[ 0 ] ); + // setPixmap( m_pixmapSkinName[ 0 ] ); setPixmap(defaultSkins[0]); m_alternativeSkins = QVector({defaultSkins[0], defaultSkins[1]}); updatePorts(); @@ -40,7 +40,7 @@ Buzzer::Buzzer(QGraphicsItem *parent) setPortName("Buzzer"); setLabel(objectName() + "_" + QString::number(Buzzer::current_id_number)); ++Buzzer::current_id_number; - usingDefaultSkin = true; + m_usingDefaultSkin = true; setAudio("C6"); m_play = 0; } @@ -84,14 +84,14 @@ void Buzzer::playbuzzer() return; } - usingDefaultSkin ? setPixmap(defaultSkins[1]) : setPixmap(m_alternativeSkins[1]); + m_usingDefaultSkin ? setPixmap(defaultSkins[1]) : setPixmap(m_alternativeSkins[1]); m_audio.play(); m_play = 1; } void Buzzer::stopbuzzer() { - usingDefaultSkin ? setPixmap(defaultSkins[0]) : setPixmap(m_alternativeSkins[0]); + m_usingDefaultSkin ? setPixmap(defaultSkins[0]) : setPixmap(m_alternativeSkins[0]); m_play = 0; m_audio.stop(); } @@ -119,10 +119,10 @@ void Buzzer::setSkin(bool defaultSkin, const QString &filename) m_play = 1; } if (defaultSkin) { - usingDefaultSkin = true; + m_usingDefaultSkin = true; setPixmap(defaultSkins[m_play]); } else { - usingDefaultSkin = false; + m_usingDefaultSkin = false; m_alternativeSkins[m_play] = filename; setPixmap(m_alternativeSkins[m_play]); // std::cerr << "Filename: " << alternativeSkins[ play ].toStdString() << '\n'; diff --git a/app/element/clock.cpp b/app/element/clock.cpp index 914ff014e..1b63cfe8b 100644 --- a/app/element/clock.cpp +++ b/app/element/clock.cpp @@ -15,7 +15,7 @@ Clock::~Clock() = default; Clock::Clock(QGraphicsItem *parent) : GraphicElement(ElementType::CLOCK, ElementGroup::INPUT, 0, 0, 1, 1, parent) { - pixmapSkinName = { + m_pixmapSkinName = { ":/input/clock0.png", ":/input/clock1.png" }; @@ -31,7 +31,7 @@ Clock::Clock(QGraphicsItem *parent) setHasLabel(true); setPortName("Clock"); setOn(false); - setPixmap(pixmapSkinName[0]); + setPixmap(m_pixmapSkinName[0]); } void Clock::updateClock() @@ -53,7 +53,7 @@ bool Clock::getOn() const void Clock::setOn(bool value) { m_isOn = value; - setPixmap(pixmapSkinName[m_isOn ? 1 : 0]); + setPixmap(m_pixmapSkinName[m_isOn ? 1 : 0]); m_outputs.first()->setValue(m_isOn); } @@ -113,10 +113,10 @@ QString Clock::genericProperties() void Clock::setSkin(bool defaultSkin, const QString &filename) { if (!m_isOn) { - pixmapSkinName[0] = defaultSkin ? ":/input/clock0.png" : filename; - setPixmap(pixmapSkinName[0]); + m_pixmapSkinName[0] = defaultSkin ? ":/input/clock0.png" : filename; + setPixmap(m_pixmapSkinName[0]); } else { - pixmapSkinName[1] = defaultSkin ? ":/input/clock1.png" : filename; - setPixmap(pixmapSkinName[1]); + m_pixmapSkinName[1] = defaultSkin ? ":/input/clock1.png" : filename; + setPixmap(m_pixmapSkinName[1]); } } diff --git a/app/element/demux.cpp b/app/element/demux.cpp index b8f21f5b0..8eb1a1ec0 100644 --- a/app/element/demux.cpp +++ b/app/element/demux.cpp @@ -8,8 +8,8 @@ Demux::Demux(QGraphicsItem *parent) : GraphicElement(ElementType::DEMUX, ElementGroup::MUX, 2, 2, 2, 2, parent) { - pixmapSkinName = {":/basic/demux.png"}; - setPixmap(pixmapSkinName[0]); + m_pixmapSkinName = {":/basic/demux.png"}; + setPixmap(m_pixmapSkinName[0]); setRotatable(true); setCanChangeSkin(true); updatePorts(); @@ -34,9 +34,9 @@ void Demux::updatePorts() void Demux::setSkin(bool defaultSkin, const QString &filename) { if (defaultSkin) { - pixmapSkinName[0] = ":/basic/demux.png"; + m_pixmapSkinName[0] = ":/basic/demux.png"; } else { - pixmapSkinName[0] = filename; + m_pixmapSkinName[0] = filename; } - setPixmap(pixmapSkinName[0]); + setPixmap(m_pixmapSkinName[0]); } diff --git a/app/element/dflipflop.cpp b/app/element/dflipflop.cpp index f4f63c840..57a8da498 100644 --- a/app/element/dflipflop.cpp +++ b/app/element/dflipflop.cpp @@ -8,9 +8,9 @@ DFlipFlop::DFlipFlop(QGraphicsItem *parent) : GraphicElement(ElementType::DFLIPFLOP, ElementGroup::MEMORY, 4, 4, 2, 2, parent) { - pixmapSkinName = {":/memory/D-flipflop.png"}; + m_pixmapSkinName = {":/memory/D-flipflop.png"}; - setPixmap(pixmapSkinName[0]); + setPixmap(m_pixmapSkinName[0]); setRotatable(false); setCanChangeSkin(true); updatePorts(); @@ -46,9 +46,9 @@ void DFlipFlop::updatePorts() void DFlipFlop::setSkin(bool defaultSkin, const QString &filename) { if (defaultSkin) { - pixmapSkinName[0] = ":/memory/D-flipflop.png"; + m_pixmapSkinName[0] = ":/memory/D-flipflop.png"; } else { - pixmapSkinName[0] = filename; + m_pixmapSkinName[0] = filename; } - setPixmap(pixmapSkinName[0]); + setPixmap(m_pixmapSkinName[0]); } diff --git a/app/element/display.cpp b/app/element/display.cpp index 0b45d3127..f363b7532 100644 --- a/app/element/display.cpp +++ b/app/element/display.cpp @@ -13,7 +13,7 @@ int Display::current_id_number = 0; Display::Display(QGraphicsItem *parent) : GraphicElement(ElementType::DISPLAY, ElementGroup::OUTPUT, 8, 8, 0, 0, parent) { - pixmapSkinName = { + m_pixmapSkinName = { ":/output/counter/counter_off.png", ":/output/counter/counter_a.png", ":/output/counter/counter_b.png", @@ -33,15 +33,15 @@ Display::Display(QGraphicsItem *parent) setTopPosition(6); setHasLabel(true); - setPixmap(pixmapSkinName[0]); - a = QPixmap(pixmapSkinName[1]); - b = QPixmap(pixmapSkinName[2]); - c = QPixmap(pixmapSkinName[3]); - d = QPixmap(pixmapSkinName[4]); - e = QPixmap(pixmapSkinName[5]); - f = QPixmap(pixmapSkinName[6]); - g = QPixmap(pixmapSkinName[7]); - dp = QPixmap(pixmapSkinName[8]); + setPixmap(m_pixmapSkinName[0]); + a = QPixmap(m_pixmapSkinName[1]); + b = QPixmap(m_pixmapSkinName[2]); + c = QPixmap(m_pixmapSkinName[3]); + d = QPixmap(m_pixmapSkinName[4]); + e = QPixmap(m_pixmapSkinName[5]); + f = QPixmap(m_pixmapSkinName[6]); + g = QPixmap(m_pixmapSkinName[7]); + dp = QPixmap(m_pixmapSkinName[8]); setPortName("Display"); for (QNEPort *in : qAsConst(m_inputs)) { @@ -139,9 +139,9 @@ void Display::load(QDataStream &ds, QMap &portMap, double ve void Display::setSkin(bool defaultSkin, const QString &filename) { if (defaultSkin) { - pixmapSkinName[0] = ":/output/counter/counter_off.png"; + m_pixmapSkinName[0] = ":/output/counter/counter_off.png"; } else { - pixmapSkinName[0] = filename; + m_pixmapSkinName[0] = filename; } - setPixmap(pixmapSkinName[0]); + setPixmap(m_pixmapSkinName[0]); } diff --git a/app/element/display_14.cpp b/app/element/display_14.cpp index c1f6d4083..4e4c5dc87 100644 --- a/app/element/display_14.cpp +++ b/app/element/display_14.cpp @@ -13,7 +13,7 @@ int Display14::current_id_number = 0; Display14::Display14(QGraphicsItem *parent) : GraphicElement(ElementType::DISPLAY14, ElementGroup::OUTPUT, 15, 15, 0, 0, parent) { - pixmapSkinName = { + m_pixmapSkinName = { ":/output/counter/counter_14_off.png", ":/output/counter/counter_a.png", ":/output/counter/counter_b.png", @@ -40,22 +40,22 @@ Display14::Display14(QGraphicsItem *parent) setTopPosition(6); setHasLabel(true); - setPixmap(pixmapSkinName[0]); - a = QPixmap(pixmapSkinName[1]); - b = QPixmap(pixmapSkinName[2]); - c = QPixmap(pixmapSkinName[3]); - d = QPixmap(pixmapSkinName[4]); - e = QPixmap(pixmapSkinName[5]); - f = QPixmap(pixmapSkinName[6]); - g1 = QPixmap(pixmapSkinName[7]); - g2 = QPixmap(pixmapSkinName[8]); - h = QPixmap(pixmapSkinName[9]); - j = QPixmap(pixmapSkinName[10]); - k = QPixmap(pixmapSkinName[11]); - l = QPixmap(pixmapSkinName[12]); - m = QPixmap(pixmapSkinName[13]); - n = QPixmap(pixmapSkinName[14]); - dp = QPixmap(pixmapSkinName[15]); + setPixmap(m_pixmapSkinName[0]); + a = QPixmap(m_pixmapSkinName[1]); + b = QPixmap(m_pixmapSkinName[2]); + c = QPixmap(m_pixmapSkinName[3]); + d = QPixmap(m_pixmapSkinName[4]); + e = QPixmap(m_pixmapSkinName[5]); + f = QPixmap(m_pixmapSkinName[6]); + g1 = QPixmap(m_pixmapSkinName[7]); + g2 = QPixmap(m_pixmapSkinName[8]); + h = QPixmap(m_pixmapSkinName[9]); + j = QPixmap(m_pixmapSkinName[10]); + k = QPixmap(m_pixmapSkinName[11]); + l = QPixmap(m_pixmapSkinName[12]); + m = QPixmap(m_pixmapSkinName[13]); + n = QPixmap(m_pixmapSkinName[14]); + dp = QPixmap(m_pixmapSkinName[15]); setPortName("Display14"); for (QNEPort *in : qAsConst(m_inputs)) { @@ -161,9 +161,9 @@ void Display14::load(QDataStream &ds, QMap &portMap, double void Display14::setSkin(bool defaultSkin, const QString &filename) { if (defaultSkin) { - pixmapSkinName[0] = ":/output/counter/counter_14_off.png"; + m_pixmapSkinName[0] = ":/output/counter/counter_14_off.png"; } else { - pixmapSkinName[0] = filename; + m_pixmapSkinName[0] = filename; } - setPixmap(pixmapSkinName[0]); + setPixmap(m_pixmapSkinName[0]); } diff --git a/app/element/dlatch.cpp b/app/element/dlatch.cpp index 2088ca544..4ad04fcad 100644 --- a/app/element/dlatch.cpp +++ b/app/element/dlatch.cpp @@ -8,9 +8,9 @@ DLatch::DLatch(QGraphicsItem *parent) : GraphicElement(ElementType::DLATCH, ElementGroup::MEMORY, 2, 2, 2, 2, parent) { - pixmapSkinName = {":/memory/D-latch.png"}; + m_pixmapSkinName = {":/memory/D-latch.png"}; - setPixmap(pixmapSkinName[0]); + setPixmap(m_pixmapSkinName[0]); setRotatable(false); setCanChangeSkin(true); updatePorts(); @@ -36,9 +36,9 @@ void DLatch::updatePorts() void DLatch::setSkin(bool defaultSkin, const QString &filename) { if (defaultSkin) { - pixmapSkinName[0] = ":/memory/D-latch.png"; + m_pixmapSkinName[0] = ":/memory/D-latch.png"; } else { - pixmapSkinName[0] = filename; + m_pixmapSkinName[0] = filename; } - setPixmap(pixmapSkinName[0]); + setPixmap(m_pixmapSkinName[0]); } diff --git a/app/element/inputbutton.cpp b/app/element/inputbutton.cpp index b2b2d4008..6f6e15b28 100644 --- a/app/element/inputbutton.cpp +++ b/app/element/inputbutton.cpp @@ -12,14 +12,14 @@ int InputButton::current_id_number = 0; InputButton::InputButton(QGraphicsItem *parent) : GraphicElement(ElementType::BUTTON, ElementGroup::INPUT, 0, 0, 1, 1, parent) { - pixmapSkinName = { + m_pixmapSkinName = { ":/input/buttonOff.png", ":/input/buttonOn.png", }; setOutputsOnTop(false); setCanChangeSkin(true); - setPixmap(pixmapSkinName[0]); + setPixmap(m_pixmapSkinName[0]); setRotatable(false); m_outputs.first()->setValue(0); setOn(false); @@ -56,7 +56,7 @@ bool InputButton::getOn() const void InputButton::setOn(const bool value) { on = value; - setPixmap(on ? pixmapSkinName[1] : pixmapSkinName[0]); + setPixmap(on ? m_pixmapSkinName[1] : m_pixmapSkinName[0]); if (!disabled()) { output()->setValue(on); } @@ -66,19 +66,19 @@ void InputButton::setSkin(bool defaultSkin, const QString &filename) { if (defaultSkin) { if (!on) { - pixmapSkinName[0] = ":/input/buttonOff.png"; - setPixmap(pixmapSkinName[0]); + m_pixmapSkinName[0] = ":/input/buttonOff.png"; + setPixmap(m_pixmapSkinName[0]); } else { - pixmapSkinName[1] = ":/input/buttonOn.png"; - setPixmap(pixmapSkinName[1]); + m_pixmapSkinName[1] = ":/input/buttonOn.png"; + setPixmap(m_pixmapSkinName[1]); } } else { if (!on) { - pixmapSkinName[0] = filename; - setPixmap(pixmapSkinName[0]); + m_pixmapSkinName[0] = filename; + setPixmap(m_pixmapSkinName[0]); } else { - pixmapSkinName[1] = filename; - setPixmap(pixmapSkinName[1]); + m_pixmapSkinName[1] = filename; + setPixmap(m_pixmapSkinName[1]); } } } diff --git a/app/element/inputgnd.cpp b/app/element/inputgnd.cpp index 49384f629..000b1686d 100644 --- a/app/element/inputgnd.cpp +++ b/app/element/inputgnd.cpp @@ -8,11 +8,11 @@ InputGnd::InputGnd(QGraphicsItem *parent) : GraphicElement(ElementType::GND, ElementGroup::STATICINPUT, 0, 0, 1, 1, parent) { - pixmapSkinName = {":/input/0.png"}; + m_pixmapSkinName = {":/input/0.png"}; setOutputsOnTop(false); setCanChangeSkin(true); - setPixmap(pixmapSkinName[0]); + setPixmap(m_pixmapSkinName[0]); setRotatable(false); setPortName("GND"); m_outputs.first()->setValue(false); @@ -21,9 +21,9 @@ InputGnd::InputGnd(QGraphicsItem *parent) void InputGnd::setSkin(bool defaultSkin, const QString &filename) { if (defaultSkin) { - pixmapSkinName[0] = ":/input/0.png"; + m_pixmapSkinName[0] = ":/input/0.png"; } else { - pixmapSkinName[0] = filename; + m_pixmapSkinName[0] = filename; } - setPixmap(pixmapSkinName[0]); + setPixmap(m_pixmapSkinName[0]); } diff --git a/app/element/inputswitch.cpp b/app/element/inputswitch.cpp index 55f585306..2325fdf27 100644 --- a/app/element/inputswitch.cpp +++ b/app/element/inputswitch.cpp @@ -12,7 +12,7 @@ int InputSwitch::current_id_number = 0; InputSwitch::InputSwitch(QGraphicsItem *parent) : GraphicElement(ElementType::SWITCH, ElementGroup::INPUT, 0, 0, 1, 1, parent) { - pixmapSkinName = { + m_pixmapSkinName = { ":/input/switchOff.png", ":/input/switchOn.png", }; @@ -20,7 +20,7 @@ InputSwitch::InputSwitch(QGraphicsItem *parent) setOutputsOnTop(false); setCanChangeSkin(true); setRotatable(false); - setPixmap(pixmapSkinName[0]); + setPixmap(m_pixmapSkinName[0]); on = false; setHasLabel(true); setHasTrigger(true); @@ -39,9 +39,9 @@ void InputSwitch::setOn(bool value) output()->setValue(on); } if (on) { - setPixmap(pixmapSkinName[1]); + setPixmap(m_pixmapSkinName[1]); } else { - setPixmap(pixmapSkinName[0]); + setPixmap(m_pixmapSkinName[0]); } } @@ -73,19 +73,19 @@ void InputSwitch::setSkin(bool defaultSkin, const QString &filename) { if (defaultSkin) { if (!on) { - pixmapSkinName[0] = ":/input/switchOff.png"; - setPixmap(pixmapSkinName[0]); + m_pixmapSkinName[0] = ":/input/switchOff.png"; + setPixmap(m_pixmapSkinName[0]); } else { - pixmapSkinName[1] = ":/input/switchOn.png"; - setPixmap(pixmapSkinName[1]); + m_pixmapSkinName[1] = ":/input/switchOn.png"; + setPixmap(m_pixmapSkinName[1]); } } else { if (!on) { - pixmapSkinName[0] = filename; - setPixmap(pixmapSkinName[0]); + m_pixmapSkinName[0] = filename; + setPixmap(m_pixmapSkinName[0]); } else { - pixmapSkinName[1] = filename; - setPixmap(pixmapSkinName[1]); + m_pixmapSkinName[1] = filename; + setPixmap(m_pixmapSkinName[1]); } } } diff --git a/app/element/inputvcc.cpp b/app/element/inputvcc.cpp index e7f42eb81..92093134e 100644 --- a/app/element/inputvcc.cpp +++ b/app/element/inputvcc.cpp @@ -8,11 +8,11 @@ InputVcc::InputVcc(QGraphicsItem *parent) : GraphicElement(ElementType::VCC, ElementGroup::STATICINPUT, 0, 0, 1, 1, parent) { - pixmapSkinName = {":/input/1.png"}; + m_pixmapSkinName = {":/input/1.png"}; setOutputsOnTop(false); setCanChangeSkin(true); - setPixmap(pixmapSkinName[0]); + setPixmap(m_pixmapSkinName[0]); setRotatable(false); setPortName("VCC"); m_outputs.first()->setValue(true); @@ -21,9 +21,9 @@ InputVcc::InputVcc(QGraphicsItem *parent) void InputVcc::setSkin(bool defaultSkin, const QString &filename) { if (defaultSkin) { - pixmapSkinName[0] = ":/input/1.png"; + m_pixmapSkinName[0] = ":/input/1.png"; } else { - pixmapSkinName[0] = filename; + m_pixmapSkinName[0] = filename; } - setPixmap(pixmapSkinName[0]); + setPixmap(m_pixmapSkinName[0]); } diff --git a/app/element/jkflipflop.cpp b/app/element/jkflipflop.cpp index 6f56ef8b4..dc7958263 100644 --- a/app/element/jkflipflop.cpp +++ b/app/element/jkflipflop.cpp @@ -8,9 +8,9 @@ JKFlipFlop::JKFlipFlop(QGraphicsItem *parent) : GraphicElement(ElementType::JKFLIPFLOP, ElementGroup::MEMORY, 5, 5, 2, 2, parent) { - pixmapSkinName = {":/memory/JK-flipflop.png"}; + m_pixmapSkinName = {":/memory/JK-flipflop.png"}; - setPixmap(pixmapSkinName[0]); + setPixmap(m_pixmapSkinName[0]); setRotatable(false); setCanChangeSkin(true); updatePorts(); @@ -52,9 +52,9 @@ void JKFlipFlop::updatePorts() void JKFlipFlop::setSkin(bool defaultSkin, const QString &filename) { if (defaultSkin) { - pixmapSkinName[0] = ":/memory/JK-flipflop.png"; + m_pixmapSkinName[0] = ":/memory/JK-flipflop.png"; } else { - pixmapSkinName[0] = filename; + m_pixmapSkinName[0] = filename; } - setPixmap(pixmapSkinName[0]); + setPixmap(m_pixmapSkinName[0]); } diff --git a/app/element/led.cpp b/app/element/led.cpp index 346dc6056..27c0912ec 100644 --- a/app/element/led.cpp +++ b/app/element/led.cpp @@ -18,7 +18,7 @@ int Led::current_id_number = 0; Led::Led(QGraphicsItem *parent) : GraphicElement(ElementType::LED, ElementGroup::OUTPUT, 1, 4, 0, 0, parent) { - pixmapSkinName = { + m_pixmapSkinName = { ":/output/WhiteLedOff.png", // Single input values: 0 ":/output/WhiteLedOn.png", // 1 ":/output/RedLedOff.png", // 2 @@ -51,7 +51,7 @@ Led::Led(QGraphicsItem *parent) setRotatable(false); setHasColors(true); setColor("White"); - setPixmap(pixmapSkinName[0]); + setPixmap(m_pixmapSkinName[0]); updatePorts(); setHasLabel(true); setCanChangeSkin(true); @@ -70,23 +70,23 @@ void Led::refresh() } switch (inputSize()) { case 1: { /* 1 bit */ - setPixmap(pixmapSkinName[m_colorNumber + idx]); + setPixmap(m_pixmapSkinName[m_colorNumber + idx]); break; } case 2: { /* 2 bits */ // TODO: add option to select dark/light colors according to the theme. if (idx == 3) { - setPixmap(pixmapSkinName[22]); + setPixmap(m_pixmapSkinName[22]); } else { - setPixmap(pixmapSkinName[18 + idx]); + setPixmap(m_pixmapSkinName[18 + idx]); } break; } case 3: { /* 3 bits */ // TODO: add option to select dark/light colors according to the theme. - setPixmap(pixmapSkinName[18 + idx]); + setPixmap(m_pixmapSkinName[18 + idx]); break; } case 4: { /* 4 bits */ - setPixmap(pixmapSkinName[10 + idx]); + setPixmap(m_pixmapSkinName[10 + idx]); break; } } @@ -173,91 +173,91 @@ void Led::setSkin(bool defaultSkin, const QString &filename) if (defaultSkin) { resetLedPixmapName(value_idx); } else { - pixmapSkinName[value_idx] = filename; + m_pixmapSkinName[value_idx] = filename; } - setPixmap(pixmapSkinName[value_idx]); + setPixmap(m_pixmapSkinName[value_idx]); } void Led::resetLedPixmapName(int ledNumber) { switch (ledNumber) { case 0: - pixmapSkinName[0] = ":/output/WhiteLedOff.png"; + m_pixmapSkinName[0] = ":/output/WhiteLedOff.png"; break; case 1: - pixmapSkinName[1] = ":/output/WhiteLedOn.png"; + m_pixmapSkinName[1] = ":/output/WhiteLedOn.png"; break; case 2: - pixmapSkinName[2] = ":/output/RedLedOff.png"; + m_pixmapSkinName[2] = ":/output/RedLedOff.png"; break; case 3: - pixmapSkinName[3] = ":/output/RedLedOn.png"; + m_pixmapSkinName[3] = ":/output/RedLedOn.png"; break; case 4: - pixmapSkinName[4] = ":/output/GreenLedOff.png"; + m_pixmapSkinName[4] = ":/output/GreenLedOff.png"; break; case 5: - pixmapSkinName[5] = ":/output/GreenLedOn.png"; + m_pixmapSkinName[5] = ":/output/GreenLedOn.png"; break; case 6: - pixmapSkinName[6] = ":/output/BlueLedOff.png"; + m_pixmapSkinName[6] = ":/output/BlueLedOff.png"; break; case 7: - pixmapSkinName[7] = ":/output/BlueLedOn.png"; + m_pixmapSkinName[7] = ":/output/BlueLedOn.png"; break; case 8: - pixmapSkinName[8] = ":/output/PurpleLedOff.png"; + m_pixmapSkinName[8] = ":/output/PurpleLedOff.png"; break; case 9: - pixmapSkinName[9] = ":/output/PurpleLedOn.png"; + m_pixmapSkinName[9] = ":/output/PurpleLedOn.png"; break; case 10: - pixmapSkinName[10] = ":/output/16colors/BlackLedOn.png"; + m_pixmapSkinName[10] = ":/output/16colors/BlackLedOn.png"; break; case 11: - pixmapSkinName[11] = ":/output/16colors/NavyBlueLedOn.png"; + m_pixmapSkinName[11] = ":/output/16colors/NavyBlueLedOn.png"; break; case 12: - pixmapSkinName[12] = ":/output/16colors/GreenLedOn.png"; + m_pixmapSkinName[12] = ":/output/16colors/GreenLedOn.png"; break; case 13: - pixmapSkinName[13] = ":/output/16colors/TealLedOn.png"; + m_pixmapSkinName[13] = ":/output/16colors/TealLedOn.png"; break; case 14: - pixmapSkinName[14] = ":/output/16colors/DarkRedLedOn.png"; + m_pixmapSkinName[14] = ":/output/16colors/DarkRedLedOn.png"; break; case 15: - pixmapSkinName[15] = ":/output/16colors/MagentaLedOn.png"; + m_pixmapSkinName[15] = ":/output/16colors/MagentaLedOn.png"; break; case 16: - pixmapSkinName[16] = ":/output/16colors/OrangeLedOn.png"; + m_pixmapSkinName[16] = ":/output/16colors/OrangeLedOn.png"; break; case 17: - pixmapSkinName[17] = ":/output/16colors/LightGrayLedOn.png"; + m_pixmapSkinName[17] = ":/output/16colors/LightGrayLedOn.png"; break; case 18: - pixmapSkinName[18] = ":/output/16colors/DarkGrayLedOn.png"; + m_pixmapSkinName[18] = ":/output/16colors/DarkGrayLedOn.png"; break; case 19: - pixmapSkinName[19] = ":/output/16colors/RoyalLedOn.png"; + m_pixmapSkinName[19] = ":/output/16colors/RoyalLedOn.png"; break; case 20: - pixmapSkinName[20] = ":/output/16colors/LimeGreenLedOn.png"; + m_pixmapSkinName[20] = ":/output/16colors/LimeGreenLedOn.png"; break; case 21: - pixmapSkinName[21] = ":/output/16colors/AquaLightLedOn.png"; + m_pixmapSkinName[21] = ":/output/16colors/AquaLightLedOn.png"; break; case 22: - pixmapSkinName[22] = ":/output/16colors/RedLedOn.png"; + m_pixmapSkinName[22] = ":/output/16colors/RedLedOn.png"; break; case 23: - pixmapSkinName[23] = ":/output/16colors/HotPinkLedOn.png"; + m_pixmapSkinName[23] = ":/output/16colors/HotPinkLedOn.png"; break; case 24: - pixmapSkinName[24] = ":/output/16colors/YellowLedOn.png"; + m_pixmapSkinName[24] = ":/output/16colors/YellowLedOn.png"; break; case 25: - pixmapSkinName[25] = ":/output/16colors/WhiteLedOn.png"; + m_pixmapSkinName[25] = ":/output/16colors/WhiteLedOn.png"; break; } } diff --git a/app/element/mux.cpp b/app/element/mux.cpp index 897a7cb66..3ca44fa34 100644 --- a/app/element/mux.cpp +++ b/app/element/mux.cpp @@ -8,9 +8,9 @@ Mux::Mux(QGraphicsItem *parent) : GraphicElement(ElementType::MUX, ElementGroup::MUX, 3, 3, 1, 1, parent) { - pixmapSkinName = {":/basic/mux.png"}; + m_pixmapSkinName = {":/basic/mux.png"}; - setPixmap(pixmapSkinName[0]); + setPixmap(m_pixmapSkinName[0]); setRotatable(true); updatePorts(); setPortName("MUX"); @@ -31,9 +31,9 @@ void Mux::updatePorts() void Mux::setSkin(bool defaultSkin, const QString &filename) { if (defaultSkin) { - pixmapSkinName[0] = ":/basic/mux.png"; + m_pixmapSkinName[0] = ":/basic/mux.png"; } else { - pixmapSkinName[0] = filename; + m_pixmapSkinName[0] = filename; } - setPixmap(pixmapSkinName[0]); + setPixmap(m_pixmapSkinName[0]); } diff --git a/app/element/nand.cpp b/app/element/nand.cpp index c8e36d28b..135862a99 100644 --- a/app/element/nand.cpp +++ b/app/element/nand.cpp @@ -6,10 +6,10 @@ Nand::Nand(QGraphicsItem *parent) : GraphicElement(ElementType::NAND, ElementGroup::GATE, 2, 8, 1, 1, parent) { - pixmapSkinName = {":/basic/nand.png"}; + m_pixmapSkinName = {":/basic/nand.png"}; setOutputsOnTop(true); - setPixmap(pixmapSkinName[0]); + setPixmap(m_pixmapSkinName[0]); setCanChangeSkin(true); updatePorts(); setCanChangeSkin(true); @@ -19,9 +19,9 @@ Nand::Nand(QGraphicsItem *parent) void Nand::setSkin(bool defaultSkin, const QString &filename) { if (defaultSkin) { - pixmapSkinName[0] = ":/basic/nand.png"; + m_pixmapSkinName[0] = ":/basic/nand.png"; } else { - pixmapSkinName[0] = filename; + m_pixmapSkinName[0] = filename; } - setPixmap(pixmapSkinName[0]); + setPixmap(m_pixmapSkinName[0]); } diff --git a/app/element/node.cpp b/app/element/node.cpp index 8c83e2aa4..58fca9e7e 100644 --- a/app/element/node.cpp +++ b/app/element/node.cpp @@ -8,9 +8,9 @@ Node::Node(QGraphicsItem *parent) : GraphicElement(ElementType::NODE, ElementGroup::GATE, 1, 1, 1, 1, parent) { - pixmapSkinName = {":/basic/node.png"}; + m_pixmapSkinName = {":/basic/node.png"}; - setPixmap(pixmapSkinName[0], QRect(QPoint(16, 16), QPoint(48, 48))); + setPixmap(m_pixmapSkinName[0], QRect(QPoint(16, 16), QPoint(48, 48))); updatePorts(); setCanChangeSkin(true); setPortName("NODE"); @@ -26,9 +26,9 @@ void Node::updatePorts() void Node::setSkin(bool defaultSkin, const QString &filename) { if (defaultSkin) { - pixmapSkinName[0] = ":/basic/node.png"; + m_pixmapSkinName[0] = ":/basic/node.png"; } else { - pixmapSkinName[0] = filename; + m_pixmapSkinName[0] = filename; } - setPixmap(pixmapSkinName[0]); + setPixmap(m_pixmapSkinName[0]); } diff --git a/app/element/nor.cpp b/app/element/nor.cpp index 27468a8c5..74c04b9b3 100644 --- a/app/element/nor.cpp +++ b/app/element/nor.cpp @@ -6,9 +6,9 @@ Nor::Nor(QGraphicsItem *parent) : GraphicElement(ElementType::NOR, ElementGroup::GATE, 2, 8, 1, 1, parent) { - pixmapSkinName = {":/basic/nor.png"}; + m_pixmapSkinName = {":/basic/nor.png"}; setOutputsOnTop(true); - setPixmap(pixmapSkinName[0]); + setPixmap(m_pixmapSkinName[0]); setCanChangeSkin(true); updatePorts(); setPortName("NOR"); @@ -17,9 +17,9 @@ Nor::Nor(QGraphicsItem *parent) void Nor::setSkin(bool defaultSkin, const QString &filename) { if (defaultSkin) { - pixmapSkinName[0] = ":/basic/nor.png"; + m_pixmapSkinName[0] = ":/basic/nor.png"; } else { - pixmapSkinName[0] = filename; + m_pixmapSkinName[0] = filename; } - setPixmap(pixmapSkinName[0]); + setPixmap(m_pixmapSkinName[0]); } diff --git a/app/element/not.cpp b/app/element/not.cpp index f86bb343d..0a2ca2f6e 100644 --- a/app/element/not.cpp +++ b/app/element/not.cpp @@ -6,9 +6,9 @@ Not::Not(QGraphicsItem *parent) : GraphicElement(ElementType::NOT, ElementGroup::GATE, 1, 1, 1, 1, parent) { - pixmapSkinName = {":/basic/not.png"}; + m_pixmapSkinName = {":/basic/not.png"}; setOutputsOnTop(true); - setPixmap(pixmapSkinName[0]); + setPixmap(m_pixmapSkinName[0]); setCanChangeSkin(true); updatePorts(); setPortName("NOT"); @@ -17,9 +17,9 @@ Not::Not(QGraphicsItem *parent) void Not::setSkin(bool defaultSkin, const QString &filename) { if (defaultSkin) { - pixmapSkinName[0] = ":/basic/not.png"; + m_pixmapSkinName[0] = ":/basic/not.png"; } else { - pixmapSkinName[0] = filename; + m_pixmapSkinName[0] = filename; } - setPixmap(pixmapSkinName[0]); + setPixmap(m_pixmapSkinName[0]); } diff --git a/app/element/or.cpp b/app/element/or.cpp index 9db4ed8e4..5e9bdf796 100644 --- a/app/element/or.cpp +++ b/app/element/or.cpp @@ -6,10 +6,10 @@ Or::Or(QGraphicsItem *parent) : GraphicElement(ElementType::OR, ElementGroup::GATE, 2, 8, 1, 1, parent) { - pixmapSkinName = {":/basic/or.png"}; + m_pixmapSkinName = {":/basic/or.png"}; setOutputsOnTop(true); - setPixmap(pixmapSkinName[0]); + setPixmap(m_pixmapSkinName[0]); setCanChangeSkin(true); updatePorts(); setPortName("OR"); @@ -18,9 +18,9 @@ Or::Or(QGraphicsItem *parent) void Or::setSkin(bool defaultSkin, const QString &filename) { if (defaultSkin) { - pixmapSkinName[0] = ":/basic/or.png"; + m_pixmapSkinName[0] = ":/basic/or.png"; } else { - pixmapSkinName[0] = filename; + m_pixmapSkinName[0] = filename; } - setPixmap(pixmapSkinName[0]); + setPixmap(m_pixmapSkinName[0]); } diff --git a/app/element/srflipflop.cpp b/app/element/srflipflop.cpp index 0e7affcdb..6e152608a 100644 --- a/app/element/srflipflop.cpp +++ b/app/element/srflipflop.cpp @@ -8,8 +8,8 @@ SRFlipFlop::SRFlipFlop(QGraphicsItem *parent) : GraphicElement(ElementType::SRFLIPFLOP, ElementGroup::MEMORY, 5, 5, 2, 2, parent) { - pixmapSkinName = {":/memory/SR-flipflop.png"}; - setPixmap(pixmapSkinName[0]); + m_pixmapSkinName = {":/memory/SR-flipflop.png"}; + setPixmap(m_pixmapSkinName[0]); setRotatable(false); setCanChangeSkin(true); updatePorts(); @@ -50,9 +50,9 @@ void SRFlipFlop::updatePorts() void SRFlipFlop::setSkin(bool defaultSkin, const QString &filename) { if (defaultSkin) { - pixmapSkinName[0] = ":/memory/SR-flipflop.png"; + m_pixmapSkinName[0] = ":/memory/SR-flipflop.png"; } else { - pixmapSkinName[0] = filename; + m_pixmapSkinName[0] = filename; } - setPixmap(pixmapSkinName[0]); + setPixmap(m_pixmapSkinName[0]); } diff --git a/app/element/tflipflop.cpp b/app/element/tflipflop.cpp index 1bc61e9a8..ec7ba7d84 100644 --- a/app/element/tflipflop.cpp +++ b/app/element/tflipflop.cpp @@ -8,9 +8,9 @@ TFlipFlop::TFlipFlop(QGraphicsItem *parent) : GraphicElement(ElementType::TFLIPFLOP, ElementGroup::MEMORY, 4, 4, 2, 2, parent) { - pixmapSkinName = {":/memory/T-flipflop.png"}; + m_pixmapSkinName = {":/memory/T-flipflop.png"}; - setPixmap(pixmapSkinName[0]); + setPixmap(m_pixmapSkinName[0]); setRotatable(false); setCanChangeSkin(true); updatePorts(); @@ -50,9 +50,9 @@ void TFlipFlop::updatePorts() void TFlipFlop::setSkin(bool defaultSkin, const QString &filename) { if (defaultSkin) { - pixmapSkinName[0] = ":/memory/T-flipflop.png"; + m_pixmapSkinName[0] = ":/memory/T-flipflop.png"; } else { - pixmapSkinName[0] = filename; + m_pixmapSkinName[0] = filename; } - setPixmap(pixmapSkinName[0]); + setPixmap(m_pixmapSkinName[0]); } diff --git a/app/element/xnor.cpp b/app/element/xnor.cpp index 63c3c298b..b03c1596c 100644 --- a/app/element/xnor.cpp +++ b/app/element/xnor.cpp @@ -6,11 +6,11 @@ Xnor::Xnor(QGraphicsItem *parent) : GraphicElement(ElementType::XNOR, ElementGroup::GATE, 2, 8, 1, 1, parent) { - pixmapSkinName = {":/basic/xnor.png"}; + m_pixmapSkinName = {":/basic/xnor.png"}; setOutputsOnTop(true); setCanChangeSkin(true); - setPixmap(pixmapSkinName[0]); + setPixmap(m_pixmapSkinName[0]); updatePorts(); setPortName("XNOR"); } @@ -18,9 +18,9 @@ Xnor::Xnor(QGraphicsItem *parent) void Xnor::setSkin(bool defaultSkin, const QString &filename) { if (defaultSkin) { - pixmapSkinName[0] = ":/basic/xnor.png"; + m_pixmapSkinName[0] = ":/basic/xnor.png"; } else { - pixmapSkinName[0] = filename; + m_pixmapSkinName[0] = filename; } - setPixmap(pixmapSkinName[0]); + setPixmap(m_pixmapSkinName[0]); } diff --git a/app/element/xor.cpp b/app/element/xor.cpp index 4d9c0cd46..62bc47125 100644 --- a/app/element/xor.cpp +++ b/app/element/xor.cpp @@ -6,10 +6,10 @@ Xor::Xor(QGraphicsItem *parent) : GraphicElement(ElementType::XOR, ElementGroup::GATE, 2, 8, 1, 1, parent) { - pixmapSkinName.append(":/basic/xor.png"); + m_pixmapSkinName.append(":/basic/xor.png"); setOutputsOnTop(true); setCanChangeSkin(true); - setPixmap(pixmapSkinName[0]); + setPixmap(m_pixmapSkinName[0]); updatePorts(); setPortName("XOR"); } @@ -17,9 +17,9 @@ Xor::Xor(QGraphicsItem *parent) void Xor::setSkin(bool defaultSkin, const QString &filename) { if (defaultSkin) { - pixmapSkinName[0] = ":/basic/xor.png"; + m_pixmapSkinName[0] = ":/basic/xor.png"; } else { - pixmapSkinName[0] = filename; + m_pixmapSkinName[0] = filename; } - setPixmap(pixmapSkinName[0]); + setPixmap(m_pixmapSkinName[0]); } diff --git a/app/elementfactory.h b/app/elementfactory.h index 15f3d2e8d..154a4ec8c 100644 --- a/app/elementfactory.h +++ b/app/elementfactory.h @@ -22,7 +22,6 @@ class ElementFactory : public QObject public: static ElementFactory *instance; - QMap m_map; static ElementType textToType(QString text); static QString typeToText(ElementType type); @@ -41,6 +40,7 @@ class ElementFactory : public QObject void clear(); private: + QMap m_map; size_t m_lastId; ElementFactory(); }; diff --git a/app/graphicelement.cpp b/app/graphicelement.cpp index 533b4fae5..74ce5a325 100644 --- a/app/graphicelement.cpp +++ b/app/graphicelement.cpp @@ -220,8 +220,8 @@ void GraphicElement::save(QDataStream &ds) const ds << port->portFlags(); } /* <\Version2.7> */ - ds << static_cast(pixmapSkinName.size()); - for (const QString &skinName : pixmapSkinName) { + ds << static_cast(m_pixmapSkinName.size()); + for (const QString &skinName : m_pixmapSkinName) { ds << skinName; } COMMENT("Finished saving element.", 4); @@ -422,12 +422,12 @@ void GraphicElement::loadPixmapSkinName(QDataStream &ds, size_t skin) { QString name; ds >> name; - if ((skin < static_cast(pixmapSkinName.size()))) { + if ((skin < static_cast(m_pixmapSkinName.size()))) { QFileInfo fileInfo(name); if (!fileInfo.isFile()) { std::cout << "Could not load skins: " << name.toStdString() << std::endl; } else - pixmapSkinName[skin] = name; + m_pixmapSkinName[skin] = name; } else { std::cout << "Could not load some of the skins." << std::endl; } @@ -435,17 +435,17 @@ void GraphicElement::loadPixmapSkinName(QDataStream &ds, size_t skin) void GraphicElement::updateSkinsPath(const QString &newSkinPath) { - for (int i = 0; i < pixmapSkinName.size(); ++i) { - QString name = pixmapSkinName[i]; + for (int i = 0; i < m_pixmapSkinName.size(); ++i) { + QString name = m_pixmapSkinName[i]; if (name[0] != ':') { COMMENT("Detecting non-default skin name " << name.toStdString(), 0); QString newSkinName = newSkinPath + QFileInfo(name).fileName(); QFile fl(newSkinName); if (!fl.exists()) { COMMENT("Copying skin to local dir. File does not exist yet.", 0); - QFile::copy(pixmapSkinName[i], newSkinName); + QFile::copy(m_pixmapSkinName[i], newSkinName); } - pixmapSkinName[i] = newSkinName; + m_pixmapSkinName[i] = newSkinName; } } } @@ -561,7 +561,7 @@ void GraphicElement::updatePorts() void GraphicElement::refresh() { - setPixmap(pixmapSkinName[0]); + setPixmap(m_pixmapSkinName[0]); } QVariant GraphicElement::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value) diff --git a/app/graphicelement.h b/app/graphicelement.h index 8878baf07..0a3bbbc10 100644 --- a/app/graphicelement.h +++ b/app/graphicelement.h @@ -32,19 +32,13 @@ typedef QVector ElementVector; class GraphicElement : public QGraphicsObject, public ItemWithId { Q_OBJECT + public: enum : uint32_t { Type = QGraphicsItem::UserType + 3 }; GraphicElement(ElementType type, ElementGroup group, int minInputSz, int maxInputSz, int minOutputSz, int maxOutputSz, QGraphicsItem *parent = nullptr); -protected: - /** - * @brief Path to all current skins. The default skin is in a research file. Custom skin names are system file paths defined by the user. - */ - QVector pixmapSkinName; - /* GraphicElement interface. */ -public: ElementType elementType() const; ElementGroup elementGroup() const; @@ -68,7 +62,6 @@ class GraphicElement : public QGraphicsObject, public ItemWithId virtual void refresh(); /* QGraphicsItem interface */ -public: int type() const override { return Type; @@ -191,25 +184,6 @@ class GraphicElement : public QGraphicsObject, public ItemWithId void updateLabel(); void updateSkinsPath(const QString &newSkinPath); -protected: - void setRotatable(bool rotatable); - void setHasLabel(bool hasLabel); - void setHasFrequency(bool hasFrequency); - void setHasColors(bool hasColors); - void setCanChangeSkin(bool canChangeSkin); - void setHasTrigger(bool hasTrigger); - void setMinInputSz(const int minInputSz); - void setMinOutputSz(int minOutputSz); - void setHasAudio(bool hasAudio); - void setOutputsOnTop(bool outputsOnTop); - void setMaxOutputSz(int maxOutputSz); - void setMaxInputSz(int maxInputSz); - void setTopPosition(int topPosition); - void setBottomPosition(int bottomPosition); - - QVariant itemChange(GraphicsItemChange change, const QVariant &value) override; - bool usingDefaultSkin; - private: /** * @brief Current pixmap displayed for this GraphicElement. @@ -258,8 +232,30 @@ class GraphicElement : public QGraphicsObject, public ItemWithId void removeSurplusInputs(quint64 inputSz, QMap &portMap); void removeSurplusOutputs(quint64 outputSz, QMap &portMap); - protected: + /** + * @brief Path to all current skins. The default skin is in a research file. Custom skin names are system file paths defined by the user. + */ + QVector m_pixmapSkinName; + + void setRotatable(bool rotatable); + void setHasLabel(bool hasLabel); + void setHasFrequency(bool hasFrequency); + void setHasColors(bool hasColors); + void setCanChangeSkin(bool canChangeSkin); + void setHasTrigger(bool hasTrigger); + void setMinInputSz(const int minInputSz); + void setMinOutputSz(int minOutputSz); + void setHasAudio(bool hasAudio); + void setOutputsOnTop(bool outputsOnTop); + void setMaxOutputSz(int maxOutputSz); + void setMaxInputSz(int maxInputSz); + void setTopPosition(int topPosition); + void setBottomPosition(int bottomPosition); + + QVariant itemChange(GraphicsItemChange change, const QVariant &value) override; + bool m_usingDefaultSkin; + /** * @brief m_inputs: input port vector */ diff --git a/app/ic.cpp b/app/ic.cpp index 3563b167b..59094dd84 100644 --- a/app/ic.cpp +++ b/app/ic.cpp @@ -29,9 +29,9 @@ IC::IC(QGraphicsItem *parent) : GraphicElement(ElementType::IC, ElementGroup::IC, 0, 0, 0, 0, parent) { - pixmapSkinName.append(":/basic/box.png"); + m_pixmapSkinName.append(":/basic/box.png"); setHasLabel(true); - setPixmap(pixmapSkinName[0], QRect(0, 0, 64, 64)); + setPixmap(m_pixmapSkinName[0], QRect(0, 0, 64, 64)); setOutputsOnTop(true); setPortName("IC"); } @@ -148,9 +148,9 @@ void IC::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) void IC::setSkin(bool defaultSkin, const QString &filename) { if (defaultSkin) { - pixmapSkinName[0] = ":/basic/box.png"; + m_pixmapSkinName[0] = ":/basic/box.png"; } else { - pixmapSkinName[0] = filename; + m_pixmapSkinName[0] = filename; } - setPixmap(pixmapSkinName[0]); + setPixmap(m_pixmapSkinName[0]); } diff --git a/app/icprototype.cpp b/app/icprototype.cpp index 6d4621cf8..e09d542e0 100644 --- a/app/icprototype.cpp +++ b/app/icprototype.cpp @@ -60,27 +60,27 @@ int ICPrototype::outputSize() const QString ICPrototype::inputLabel(int index) const { - return m_ICImpl.inputLabels[index]; + return m_ICImpl.getInputLabel(index); } QString ICPrototype::outputLabel(int index) const { - return m_ICImpl.outputLabels[index]; + return m_ICImpl.getOutputLabel(index); } bool ICPrototype::defaultInputValue(int index) { - return m_ICImpl.inputs[index]->value(); + return m_ICImpl.getInput(index)->value(); } bool ICPrototype::isInputRequired(int index) { - return m_ICImpl.inputs[index]->isRequired(); + return m_ICImpl.getInput(index)->isRequired(); } ICMapping *ICPrototype::generateMapping() const { - return new ICMapping(fileName(), m_ICImpl.elements, m_ICImpl.inputs, m_ICImpl.outputs); + return m_ICImpl.generateMapping(fileName()); } void ICPrototype::clear() diff --git a/app/icprototypeimpl.cpp b/app/icprototypeimpl.cpp index 8abb79b48..d709e8c0d 100644 --- a/app/icprototypeimpl.cpp +++ b/app/icprototypeimpl.cpp @@ -10,13 +10,14 @@ #include "elementfactory.h" #include "ic.h" #include "icprototype.h" +#include "icmapping.h" #include "qneconnection.h" #include "qneport.h" #include "serializationfunctions.h" ICPrototypeImpl::~ICPrototypeImpl() { - qDeleteAll(elements); + qDeleteAll(m_elements); } bool comparePorts(QNEPort *port1, QNEPort *port2) @@ -39,7 +40,7 @@ void ICPrototypeImpl::sortPorts(QVector &map) bool ICPrototypeImpl::updateLocalIC(const QString &fileName, const QString &dirName) { COMMENT("Recursive call to sub ics.", 0); - for (GraphicElement *elm : qAsConst(elements)) { + for (GraphicElement *elm : qAsConst(m_elements)) { if (elm->elementType() == ElementType::IC) { IC *ic = dynamic_cast(elm); QString originalSubICName = ic->getFile(); @@ -86,10 +87,10 @@ void ICPrototypeImpl::loadFile(const QString &fileName) loadItem(item); } } - setInputSize(inputs.size()); - setOutputSize(outputs.size()); - sortPorts(inputs); - sortPorts(outputs); + setInputSize(m_inputs.size()); + setOutputSize(m_outputs.size()); + sortPorts(m_inputs); + sortPorts(m_outputs); loadInputs(); loadOutputs(); COMMENT("Finished Reading ic", 0); @@ -98,38 +99,38 @@ void ICPrototypeImpl::loadFile(const QString &fileName) void ICPrototypeImpl::loadInputs() { for (int portIndex = 0; portIndex < getInputSize(); ++portIndex) { - GraphicElement *elm = inputs.at(portIndex)->graphicElement(); + GraphicElement *elm = m_inputs.at(portIndex)->graphicElement(); QString lb = elm->getLabel(); if (lb.isEmpty()) { lb = elm->objectName(); } - if (!inputs.at(portIndex)->portName().isEmpty()) { + if (!m_inputs.at(portIndex)->portName().isEmpty()) { lb += " "; - lb += inputs.at(portIndex)->portName(); + lb += m_inputs.at(portIndex)->portName(); } if (!elm->genericProperties().isEmpty()) { lb += " [" + elm->genericProperties() + "]"; } - inputLabels[portIndex] = lb; + m_inputLabels[portIndex] = lb; } } void ICPrototypeImpl::loadOutputs() { for (int portIndex = 0; portIndex < getOutputSize(); ++portIndex) { - GraphicElement *elm = outputs.at(portIndex)->graphicElement(); + GraphicElement *elm = m_outputs.at(portIndex)->graphicElement(); QString lb = elm->getLabel(); if (lb.isEmpty()) { lb = elm->objectName(); } - if (!outputs.at(portIndex)->portName().isEmpty()) { + if (!m_outputs.at(portIndex)->portName().isEmpty()) { lb += " "; - lb += outputs.at(portIndex)->portName(); + lb += m_outputs.at(portIndex)->portName(); } if (!elm->genericProperties().isEmpty()) { lb += " [" + elm->genericProperties() + "]"; } - outputLabels[portIndex] = lb; + m_outputLabels[portIndex] = lb; } } @@ -150,8 +151,8 @@ void ICPrototypeImpl::loadInputElement(GraphicElement *elm) if (elm->elementType() == ElementType::CLOCK) { nodeInput->setRequired(true); } - inputs.append(nodeInput); - elements.append(nodeElm); + m_inputs.append(nodeInput); + m_elements.append(nodeElm); QList conns = port->connections(); for (QNEConnection *conn : conns) { // Solution 3. Revert this process before saving and then make it again after saving... if (port == conn->start()) { @@ -172,8 +173,8 @@ void ICPrototypeImpl::loadOutputElement(GraphicElement *elm) QNEOutputPort *nodeOutput = nodeElm->output(); nodeOutput->setPos(port->pos()); nodeOutput->setName(port->getName()); - outputs.append(nodeOutput); - elements.append(nodeElm); + m_outputs.append(nodeOutput); + m_elements.append(nodeElm); QList conns = port->connections(); for (QNEConnection *conn : conns) { if (port == conn->end()) { @@ -193,7 +194,7 @@ void ICPrototypeImpl::loadItem(QGraphicsItem *item) } else if (elm->elementGroup() == ElementGroup::OUTPUT) { loadOutputElement(elm); } else { - elements.append(elm); + m_elements.append(elm); } } } @@ -201,30 +202,60 @@ void ICPrototypeImpl::loadItem(QGraphicsItem *item) void ICPrototypeImpl::clear() { - inputs.clear(); - outputs.clear(); + m_inputs.clear(); + m_outputs.clear(); setInputSize(0); setOutputSize(0); - qDeleteAll(elements); - elements.clear(); + qDeleteAll(m_elements); + m_elements.clear(); } int ICPrototypeImpl::getInputSize() const { - return inputs.size(); + return m_inputs.size(); } int ICPrototypeImpl::getOutputSize() const { - return outputs.size(); + return m_outputs.size(); } void ICPrototypeImpl::setOutputSize(int outputSize) { - outputLabels = QVector(outputSize); + m_outputLabels = QVector(outputSize); } void ICPrototypeImpl::setInputSize(int inputSize) { - inputLabels = QVector(inputSize); + m_inputLabels = QVector(inputSize); +} + +GraphicElement *ICPrototypeImpl::getElement(int index) +{ + return m_elements[index]; +} + +QString ICPrototypeImpl::getInputLabel(int index) const +{ + return m_inputLabels[index]; +} + +QString ICPrototypeImpl::getOutputLabel(int index) const +{ + return m_outputLabels[index]; +} + +QNEPort *ICPrototypeImpl::getInput(int index) +{ + return m_inputs[index]; +} + +QNEPort *ICPrototypeImpl::getOutput(int index) +{ + return m_outputs[index]; +} + +ICMapping *ICPrototypeImpl::generateMapping(const QString &fileName) const +{ + return new ICMapping(fileName, m_elements, m_inputs, m_outputs); } diff --git a/app/icprototypeimpl.h b/app/icprototypeimpl.h index 49d2e05e7..322ac86ee 100644 --- a/app/icprototypeimpl.h +++ b/app/icprototypeimpl.h @@ -11,17 +11,11 @@ class GraphicElement; class QGraphicsItem; class QNEPort; +class ICMapping; class ICPrototypeImpl { public: - QVector elements; - QVector inputLabels; - QVector outputLabels; - - QVector inputs; - QVector outputs; - ~ICPrototypeImpl(); void loadFile(const QString &fileName); void clear(); @@ -35,11 +29,25 @@ class ICPrototypeImpl void loadOutputElement(GraphicElement *elm); bool updateLocalIC(const QString &fileName, const QString &icDirName); + GraphicElement *getElement(int index); + QString getInputLabel(int index) const; + QString getOutputLabel(int index) const; + QNEPort *getInput(int index); + QNEPort *getOutput(int index); + ICMapping *generateMapping(const QString &fileName) const; + private: void sortPorts(QVector &map); void loadItem(QGraphicsItem *item); void loadInputs(); void loadOutputs(); + + QVector m_elements; + QVector m_inputLabels; + QVector m_outputLabels; + + QVector m_inputs; + QVector m_outputs; }; #endif // ICPROTOTYPEIMPL_H diff --git a/app/logicelement/CMakeLists.txt b/app/logicelement/CMakeLists.txt index 6efd1384f..a447a9b9d 100644 --- a/app/logicelement/CMakeLists.txt +++ b/app/logicelement/CMakeLists.txt @@ -22,3 +22,4 @@ set ( add_library(wpandalogicelement ${WPANDA_LOGICELEMENT} ) target_link_libraries(wpandalogicelement PUBLIC ${WPANDA_LIBS} ) +target_compile_options(wpandalogicelement PRIVATE ${COMPILE_WARNS} ) diff --git a/app/logicelement/logicdflipflop.cpp b/app/logicelement/logicdflipflop.cpp index 11c78df9f..d23a650a0 100644 --- a/app/logicelement/logicdflipflop.cpp +++ b/app/logicelement/logicdflipflop.cpp @@ -6,6 +6,7 @@ LogicDFlipFlop::LogicDFlipFlop() : LogicElement(4, 2) , lastClk(false) + , lastValue(true) { setOutputValue(0, false); setOutputValue(1, true); diff --git a/app/logicelement/logicjkflipflop.cpp b/app/logicelement/logicjkflipflop.cpp index 850f32267..7b62c13ed 100644 --- a/app/logicelement/logicjkflipflop.cpp +++ b/app/logicelement/logicjkflipflop.cpp @@ -6,6 +6,8 @@ LogicJKFlipFlop::LogicJKFlipFlop() : LogicElement(5, 2) , lastClk(false) + , lastJ(true) + , lastK(true) { setOutputValue(0, false); setOutputValue(1, true); diff --git a/app/logicelement/logictflipflop.cpp b/app/logicelement/logictflipflop.cpp index 66236d043..5013846af 100644 --- a/app/logicelement/logictflipflop.cpp +++ b/app/logicelement/logictflipflop.cpp @@ -6,6 +6,7 @@ LogicTFlipFlop::LogicTFlipFlop() : LogicElement(4, 2) , lastClk(false) + , lastValue(true) { setOutputValue(0, false); setOutputValue(1, true); diff --git a/cmake/Format.cmake b/cmake/Format.cmake index c9f6e4252..6dafdda2d 100644 --- a/cmake/Format.cmake +++ b/cmake/Format.cmake @@ -1,3 +1,8 @@ +if(NOT ECM_FOUND) + message(WARNING "Can't use KDE_CLANG_FORMAT, ECM not available.") + return() +endif() + include(KDEClangFormat) file(