MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow),factor(1), mapImage(NULL), mapItem(NULL),scene(new QGraphicsScene()), control(new Control(this)),disableSimOutput(false), postControl(new PostControl(this)),zBlocks(NULL), eventScene(new QGraphicsScene()), zmap(NULL), eventMapScene(new QGraphicsScene()), PPactiveAgents(NULL), zMapTimer(new QTimer(this)),initializeTimer(new QTimer(this)), runTimer(new QTimer(this)),disableLiveView(true),playingMap(false), running(false) { ui->setupUi(this); ui->progressBar->setMaximum(100); ui->progressBar->setMinimum(0); ui->progressBar->setValue(0); ui->graphicsView->setScene(scene); scene->setBackgroundBrush(Qt::gray); ui->runButton->setDisabled(true); //dr. ui->adv_spinBox->hide(); this->setWindowTitle("Rana 1.8"); qRegisterMetaType<INFOLIST>("INFOLIST"); QObject::connect(this,SIGNAL(map_updateSignal(INFOLIST)), this,SLOT(on_updateMap(INFOLIST))); QObject::connect(this,SIGNAL(writeStringSignal(QString)), this,SLOT(on_writeOutput(QString))); QObject::connect(this,SIGNAL(writeRegularSignal(QString)), this,SLOT(on_writeRegularOutput(QString))); QObject::connect(this,SIGNAL(writeStatusSignal(unsigned long long,unsigned long long)), this,SLOT(on_udateStatus(unsigned long long,unsigned long long))); QObject::connect(this,SIGNAL(addGraphicAgentSignal(int,int,int)), this,SLOT(on_addGraphicAgent(int,int,int))); QObject::connect(this, SIGNAL(removeGraphicAgentSignal(int)), this, SLOT(on_removeGraphicAgent(int))); QObject::connect(this, SIGNAL(changeGraphicAgentColorSignal(int,int,int,int,int)), this, SLOT(on_changeGraphicAgentColor(int,int,int,int,int))); QObject::connect(this,SIGNAL(enableRunButtonSignal(bool)), this, SLOT(on_enableRunButton(bool))); resizeTimer.setSingleShot(true); QObject::connect(&resizeTimer, SIGNAL(timeout()), SLOT(on_resizeTimerTimeout())); initializeTimer->setSingleShot(true); QObject::connect(initializeTimer, SIGNAL(timeout()), SLOT(on_initializeTimerTimeout())); runTimer->setSingleShot(true); QObject::connect(runTimer, SIGNAL(timeout()), SLOT(on_runTimerTimeout())); //connect actions: QObject::connect(ui->action_Exit, SIGNAL(triggered()),this, SLOT(actionExit())); QObject::connect(ui->action_Info, SIGNAL(triggered()),this, SLOT(actionPrintInfo())); //versionString = QString("<b><font color=\"green\">RANA</b></font> version 1.7.14:0.8.2"); //ui->statusBar->addWidget(new QLabel(versionString)); ui->graphicsView->setDragMode(QGraphicsView::ScrollHandDrag); sim_controlTab = ui->simControlTab; sim_viewTab = ui->simLiveView; //sim_advancedTab = ui->simAdvancedTab; sim_general = ui->simGeneralWidget; ppConstruction(); dialogConstruction(); ui->graphicsView->viewport()->installEventFilter(this); Output::Inst()->RanaDir = QCoreApplication::applicationDirPath().toUtf8().constData(); }
SharedPainter::SharedPainter(CSharedPainterScene *canvas, QWidget *parent, Qt::WFlags flags) : QMainWindow(parent, flags), canvas_(canvas), currPaintItemId_(1), currPacketId_(-1), resizeFreezingFlag_(false), screenShotMode_(false), wroteProgressBar_(NULL) { ui.setupUi(this); ui.painterView->setScene( canvas ); canvas_->setEvent( this ); SharePaintManagerPtr()->registerObserver( this ); SharePaintManagerPtr()->setCanvas( canvas_ ); QMenuBar *menuBar = ui.menuBar; // Create Menu bar item { // File Menu QMenu* file = new QMenu( "&File", menuBar ); file->addAction( "&Connect", this, SLOT(actionConnect()), Qt::CTRL+Qt::Key_N ); file->addAction( "&Broadcast Channel", this, SLOT(actionBroadcastChannel()), Qt::CTRL+Qt::Key_H ); QMenu* broadCastTypeMenu = file->addMenu( "BroadCast Type" ); broadCastTypeMenu->addAction( "&Server", this, SLOT(actionServerType()), Qt::CTRL+Qt::Key_1 ); broadCastTypeMenu->addAction( "&Client", this, SLOT(actionClientType()), Qt::CTRL+Qt::Key_2 ); file->addSeparator(); file->addAction( "E&xit", this, SLOT(actionExit()), Qt::CTRL+Qt::Key_Q ); menuBar->addMenu( file ); // Edit Menu QMenu* edit = new QMenu( "&Edit", menuBar ); QMenu* penMenu = edit->addMenu( "Pen Setting" ); penMenu->addAction( "Pen &Width", this, SLOT(actionPenWidth()), Qt::CTRL+Qt::Key_V ); penMenu->addAction( "Pen &Color", this, SLOT(actionPenColor()), Qt::CTRL+Qt::Key_C ); penModeAction_ = edit->addAction( "Pen Mode", this, SLOT(actionPenMode()), Qt::CTRL+Qt::Key_A ); penModeAction_->setCheckable( true ); edit->addAction( "&Text", this, SLOT(actionAddText()), Qt::Key_Enter|Qt::Key_Return ); edit->addAction( "&Screen Shot", this, SLOT(actionScreenShot()), Qt::CTRL+Qt::Key_S ); edit->addSeparator(); edit->addAction( "Clear &Background Image", this, SLOT(actionClearBGImage()), Qt::CTRL+Qt::Key_B ); edit->addAction( "Cl&ear Screen", this, SLOT(actionClearScreen()), Qt::CTRL+Qt::Key_X ); edit->addSeparator(); edit->addAction( "&Undo", this, SLOT(actionUndo()), Qt::CTRL+Qt::Key_Z ); menuBar->addMenu( edit ); } // create status bar { statusBarLabel_ = new QLabel(); broadCastTypeLabel_ = new QLabel(); joinerCountLabel_ = new QLabel(); wroteProgressBar_ = new QProgressBar(); ui.statusBar->addPermanentWidget( broadCastTypeLabel_ ); ui.statusBar->addPermanentWidget( joinerCountLabel_, 1 ); ui.statusBar->addPermanentWidget( wroteProgressBar_ ); ui.statusBar->addPermanentWidget( statusBarLabel_ ); setStatusBar_Network( tr("Not Connected") ); setStatusBar_BroadCastType( tr("None Type") ); setStatusBar_JoinerCnt( 1 ); // my self } ui.painterView->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); ui.painterView->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); setCursor( Qt::ArrowCursor ); // Pen mode activated.. penModeAction_->setChecked( true ); actionPenMode(); // Key Hooking Timer keyHookTimer_ = new QTimer(this); keyHookTimer_->start(20); connect(keyHookTimer_, SIGNAL(timeout()),this, SLOT(onTimer())); installEventFilter(this); // Title QString orgTitle = windowTitle(); QString newTitle = orgTitle; newTitle += " Ver "; newTitle += VERSION_TEXT; newTitle += ", "; newTitle += AUTHOR_TEXT; setWindowTitle( newTitle ); }