/** * \file * * * * \author Bernie Innocenti * * \brief Main Qt window for embedded applications emulator (implementation) */ #include "emulwin.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace Qt; EmulWin::EmulWin(Emulator *e) { setWindowTitle(tr("BeRTOS Emul Demo")); setAttribute(Qt::WA_DeleteOnClose); // Create the menu bar QMenu *file_menu = menuBar()->addMenu(tr("&File")); file_menu->addAction(tr("&Quit"), e->emulApp, SLOT(closeAllWindows()), CTRL+Key_Q); menuBar()->addSeparator(); QMenu *help_menu = menuBar()->addMenu(tr("&Help")); help_menu->addAction(tr("&About"), this, SLOT(about()), Key_F1); // Make a central widget to contain the other widgets QWidget *central = new QWidget(this); setCentralWidget(central); // Create a layout to position the widgets QHBoxLayout *box_main = new QHBoxLayout(central); // Main layout QVBoxLayout *box_right = new QVBoxLayout(); box_main->addLayout(box_right); // LCD QHBoxLayout *lay_lcd = new QHBoxLayout(); box_right->addLayout(lay_lcd); lay_lcd->addStretch(1); lay_lcd->addWidget(e->emulLCD = new EmulLCD(central), 8); lay_lcd->addStretch(1); // Keyboard box_right->addWidget(e->emulKbd = new EmulKbd(central)); // Setup keyboard: Label Keycode Row Col MRow MCol e->emulKbd->addKey("^", Key_Up, 0, 0, 0, 0); e->emulKbd->addKey("v", Key_Down, 1, 0, 0, 1); e->emulKbd->addKey("OK", Key_Return, 0, 1, 0, 2); e->emulKbd->addKey("ESC", Key_Escape, 1, 1, 0, 3); } EmulWin::~EmulWin() { emul->quit(); } void EmulWin::closeEvent(QCloseEvent *ce) { emul->quit(); ce->accept(); } void EmulWin::about() { QMessageBox::about(this, "BeRTOS Embedded Application Emulator", "Version 0.1\n" "Copyright 2006, 2008 Develer S.r.l. (http://www.develer.com/)\n" "Copyright 2001, 2002, 2003, 2005 Bernie Innocenti \n" "All rights reserved." ); } #include "emulwin_moc.cpp"