1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
|
/*
* File: MainPanel.cpp
*
* Author: Jacob Dekel
* Created on: Aug 7, 2009
*
* Copyright (c) 2009-2013 Jacob Dekel
* $Id$
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "HerculesStudio.h"
#include "MainPanel.h"
#include "MainPanelClassic.h"
#include "Preferences.h"
#include "Environment.h"
#include "ConfigurationEditor.h"
#include <QResizeEvent>
#include <QColor>
#include <iostream>
MainPanel::MainPanel(QWidget *parent)
:QWidget(parent),
mMipsHWM(0)
{
QString iconsPath = Environment::getIconsPath().c_str();
mYellowLow = new QPixmap(iconsPath + "/yellow.png");
mYellowHigh = new QPixmap(iconsPath + "/yellowhigh.png");
}
MainPanel::~MainPanel()
{
}
void MainPanel::doConnect()
{
connect(powerOnButton(), SIGNAL(clicked()), this , SLOT(powerOnClickedSlot()));
connect(powerOffButton(), SIGNAL(clicked()), this , SLOT(powerOffClickedSlot()));
connect(interruptButton(), SIGNAL(clicked()), this , SLOT(interruptClickedSlot()));
connect(loadButton(), SIGNAL(clicked()), this , SLOT(loadClickedSlot()));
connect(stopButton(), SIGNAL(clicked()), this , SLOT(stopClickedSlot()));
checkedConnect(mRestartButton,restartClickedSlot());
checkedConnect(mStoreButton,storeClickedSlot());
checkedConnect(mStartButton,startClickedSlot());
}
void MainPanel::powerOnClickedSlot()
{
emit powerOnClicked();
}
void MainPanel::powerOffClickedSlot()
{
emit powerOffClicked();
}
void MainPanel::loadClickedSlot()
{
emit loadClicked();
}
void MainPanel::restartClickedSlot()
{
emit restartClicked();
}
void MainPanel::storeClickedSlot()
{
emit storeClicked();
}
void MainPanel::startClickedSlot()
{
mStopped=false;
emit startClicked();
}
void MainPanel::stopClickedSlot()
{
mStopped=true;
emit stopClicked();
}
void MainPanel::interruptClickedSlot()
{
emit interruptClicked();
}
ClickLabel::ClickLabel(MainPanel * parent, QObject * lcd)
: QLabel(parent), mPanel(parent), mLcd(lcd)
{
}
void ClickLabel::mousePressEvent(QMouseEvent * event)
{
mPanel->updateLcd((QLCDNumber*)(mLcd), event->x() > 30 ? 1 : -1);
Preferences::getInstance().setIplDevice( std::string(QByteArray::number(mPanel->getLoadAddress(),16).data()) );
}
int MainPanel::getLoadAddress()
{
return mLcd0->intValue() + 16*mLcd1->intValue() +
(16*16)*mLcd2->intValue() + (16*16*16)*mLcd3->intValue();
}
void MainPanel::setLoadAddress(const char *devNo)
{
int addr = ConfigurationEditor::parseNum(devNo,16);
QLCDNumber *nums[4] = {mLcd0, mLcd1, mLcd2, mLcd3};
for (int i=0; i< 4; i++)
{
int dig = addr%16;
addr /= 16;
nums[i]->display(dig);
}
Preferences::getInstance().setIplDevice( std::string(QByteArray::number(getLoadAddress(),16).data()) );
}
|