void MainWindow::slotConnectTo() { pserial->close(); answerFlag = true; pb->delPair(currPair.port); availablePorts.clear(); m_sde = SerialDeviceEnumerator::instance(); availablePorts = m_sde->devicesAvailable(); //if(!pserial->isOpen() || !pserial->isReadable() || !pserial->isWritable()) initConnectParams(); dsc = new DialogSelectConnection(pb); connect(dsc, SIGNAL(tryConnSignal(QString, QString)), this, SLOT(sendTryConn(QString, QString))); dsc->getFirstPort(); disconnect(this, SIGNAL(signPackReceive(QByteArray)), this, SLOT(parceAnswerPack(QByteArray))); connect(this, SIGNAL(signPackReceive(QByteArray)), this, SLOT(onPackReceiver(QByteArray))); connect(pserial, SIGNAL(readyRead()), this, SLOT(onProcSerialReceive())); pserial->enableEmitStatus(true); lblPort->setText(currPair.port + "\n" + currPair.baud); lblStatus->setText("Connected"); MainWindow::setWindowTitle(currPair.port + " Конфигуратор Ладога-РК"); if(dsc->exec() == dsc->Accepted) createStartCommands(); else if(headersLst.size() == 0) closeApp("<u><b>Приложение будет закрыто.</b></u><i> Подключение не выбрано.</i>"); }
void CntDefaultViewManager::back(const CntViewParameters aArgs, bool toRoot) { CNT_ENTRY mArgs.clear(); QFlags<Hb::ViewSwitchFlag> flags; int back = mNavigator->back( flags, toRoot ); foreach( int k, aArgs.keys() ) { mArgs.insert( k, aArgs.value(k) ); } mArgs.insert(EViewId, back ); if (mArgs.value(EViewId).toInt() != noView) { switchView( mArgs, flags ); } else { // exiting application cleanup(); closeApp(); } CNT_EXIT }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { iTrytoClose = false; iDownloader = new FileDownloader(this); iAudioExtractor = new AudioExtractor(this); ui->setupUi(this); ui->progressBar->setMinimum(0); ui->progressBar->setMaximum(100); ui->progressBar->setValue(0); connect(ui->startButton, SIGNAL(clicked()), this, SLOT(startDownload())); connect(ui->cancelButton, SIGNAL(clicked()), this, SLOT(cancelDownload())); connect(iDownloader, SIGNAL(downloadProgress(int)), this, SLOT(updateProgress(int))); connect(iDownloader, SIGNAL(stateChanged(DownloadState)), this, SLOT(stateChanged(DownloadState))); connect(ui->extractButton, SIGNAL(clicked()), this, SLOT(extractAudio())); connect(ui->codecButton, SIGNAL(clicked()), this, SLOT(codecInfo())); connect(ui->encodeButton, SIGNAL(clicked()), this, SLOT(encodeX264())); connect(ui->closeButton, SIGNAL(clicked()), this, SLOT(closeApp())); connect(iDownloader, SIGNAL(infoChanged(const QString&)), this, SLOT(infoChanged(const QString&))); connect(ui->clearButton, SIGNAL(clicked()), this, SLOT(clearInfoText())); connect(ui->actionSettings, SIGNAL(triggered()), this, SLOT(openSettings())); connect(ui->actionAbout, SIGNAL(triggered()), this, SLOT(openAbout())); connect(iAudioExtractor, SIGNAL(infoChanged(const QString&)), this, SLOT(infoChanged(const QString&))); connect(iAudioExtractor, SIGNAL(extractStateChanged(int)), this, SLOT(extractStateChanged(int))); connect(iAudioExtractor, SIGNAL(encodeStateChanged(int)), this, SLOT(extractStateChanged(int))); ui->videoIdEdit->setText("nVjsGKrE6E8"); }
MyWidget::MyWidget(QWidget *parent) : QWidget(parent) { //setFixedSize(150, 200); button_power = new QPower(this); // aerobutton_test = new AeroButton("Test", this); QPushButton *quit = new QPushButton(tr("Quit")); QVBoxLayout *layout = new QVBoxLayout; // QHBoxLayout *layout = new QHBoxLayout; quit->setFont(QFont("Times", 25, QFont::Bold)); //aerobutton_test->setFont(QFont("Times", 12, QFont::Bold)); //aerobutton_quit->setGeometry(10, 20, 230, 40); //aerobutton_test->setGeometry(10, 70, 230, 40); /* QGridLayout *grid = new QGridLayout; for (int row = 0; row < 3; ++row) { for (int column = 0; column < 2; ++column) { LCDRange *lcdRange = new LCDRange; grid->addWidget(lcdRange, row, column); } } */ QLCDNumber *lcd = new QLCDNumber(2); lcd->setSegmentStyle(QLCDNumber::Filled); QSlider *slider = new QSlider(Qt::Horizontal); slider->setRange(0, 99); slider->setValue(0); //QVBoxLayout *layout = new QVBoxLayout; layout->addWidget(lcd); layout->addWidget(slider); //setLayout(layout); // layout->addWidget(aerobutton_test); // layout->addLayout(grid); layout->addWidget(button_power); layout->addWidget(quit); //layout->addWidget(slider); setLayout(layout); //QObject::connect(aerobutton_quit, SIGNAL(clicked()), &app, SLOT(quit())); // connect(aerobutton_quit, SIGNAL(clicked()), qApp, SLOT(quit())); // connect(aerobutton_quit, SIGNAL(clicked()), this, SLOT(closeApp() )); //connect(aerobutton_test, SIGNAL(clicked()), this, SLOT(showMessageBox() )); connect(quit, SIGNAL(clicked()), this, SLOT(closeApp() )); connect(button_power, SIGNAL(clicked()), this, SLOT(showMessageBox() )); connect(slider, SIGNAL(valueChanged(int)), lcd, SLOT(display(int))); //connect(quit, SIGNAL(clicked()), this, SLOT(close() )); // connect(button_power, SIGNAL(mousePressEvent()), this, SLOT(close() )); }
void MainDlg::downloadError(QString error) { Q_UNUSED(error); Message::showMessage(this, "Uhoh...", StringDictionnary::getInstance()->getMsg("ER_NO_INTERNET")); hasError = true; closeApp(); }
static void closing_timer(void* data) { if (!closingMode) return; closeApp(); app_timer_register(3000, closing_timer, NULL); }
int main(int argc, char *argv[]) { QApplication::setAttribute(Qt::AA_UseOpenGLES,true); QApplication a(argc, argv); // MODEL SubteState * m_subte = new SubteState(); // CONTROLLER DISPATCHER EventHandler *m_eventHandler = new EventHandler(); // VIEWS BoardCenter * m_c = new BoardCenter(0); BoardAtp *m_a = new BoardAtp(0); BoardMac *m_m = new BoardMac(0,m_subte,m_eventHandler); BoardBottom *m_b = new BoardBottom(0); BoardHardware *m_h = new BoardHardware(0,m_subte,m_eventHandler); QTabWidget *m_tabs = new QTabWidget(0); m_tabs->addTab(m_h,QObject::tr("HARDWARE")); m_tabs->addTab(m_b,QObject::tr("BOTTOM")); m_tabs->setMinimumWidth(1024); m_tabs->setMinimumHeight(768); QDesktopWidget *desktop = a.desktop(); if(desktop->screenCount() == 4){ QRect s0 = desktop->screenGeometry(0); QRect s1 = desktop->screenGeometry(1); QRect s2 = desktop->screenGeometry(2); QRect s3 = desktop->screenGeometry(3); m_c->showFullScreen(); m_a->showFullScreen(); m_m->showFullScreen(); m_tabs->showFullScreen(); m_c->move(s0.topLeft()); m_a->move(s2.topLeft()); m_m->move(s3.topLeft()); m_tabs->move(s1.topLeft()); }else{ m_c->showNormal(); m_a->showNormal(); m_m->showNormal(); m_tabs->showNormal(); } m_eventHandler->setModel(m_subte); m_subte->setHandler(m_eventHandler); m_eventHandler->initConnection(qApp->applicationDirPath()); QObject::connect(m_eventHandler,SIGNAL(closeApp()),qApp,SLOT(quit())); return a.exec(); }
MainDlg::MainDlg(QWidget *parent) : QDialog(parent), ui(new Ui::MainDlg) { ui->setupUi(this); this->setWindowFlags(Qt::FramelessWindowHint); this->setWindowOpacity(0.95); this->setFixedSize(this->geometry().size()); //prepare system tray icon trayIcon = new QSystemTrayIcon(this); trayIcon->setIcon(QIcon(":/rsc/package.png")); trayIcon->setVisible(true); connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(trayIconActivated(QSystemTrayIcon::ActivationReason))); //prepare nice wait layer waitLayer = new QLabel(this); waitLayer->setGraphicsEffect(new QGraphicsBlurEffect()); waitLayer->setPixmap(this->grab()); waitLayer->hide(); //connect minimize and close signals connect(ui->titleBar, SIGNAL(closeApp()), this, SLOT(closeApp())); connect(ui->titleBar, SIGNAL(minimizeApp()), this, SLOT(minimizeApp())); connect(ui->titleBar, SIGNAL(aboutApp()), this, SLOT(about())); //show waitLayer while working showWaitLayer(true); //retrieve once-for-all tmpPath tmpDir = FileTools::getInstance()->getTmpPath(); //retrieve and parse list.xml dfh = new DownloadFileHandler(listDotZipPath, tmpDir, false); qDebug()<<tmpDir; connect(dfh, SIGNAL(fileDownloadFinished()), this, SLOT(parseListDotXml())); connect(dfh, SIGNAL(fileDownloadError(QString)), this, SLOT(downloadError(QString))); dfh->beginDownload(); }
void SampleContext::go(Sample* initialSample) { while (!mLastRun) { mLastRun = TRUE; initApp(initialSample); if (mEngine->getRenderSystem() != NULL) { mEngine->startRendering(); } closeApp(); mFirstRun = FALSE; } }
static void window_appears(Window *me) { if (closingMode) { closeApp(); app_timer_register(3000, closing_timer, NULL); } else if (menuLoaded) { main_menu_show_menu(); } else { show_loading(); } setCurWindow(0); }
static void window_unload(Window *window) { numOfNotifications = 0; nw_ui_unload(); #ifdef PBL_COLOR if (bitmapReceivingBuffer != NULL) { free(bitmapReceivingBuffer); bitmapReceivingBuffer = NULL; } if (notificationBitmap != NULL) { gbitmap_destroy(notificationBitmap); notificationBitmap = NULL; } #endif #ifdef PBL_MICROPHONE if (dictationSession != NULL) dictation_session_destroy(dictationSession); #endif accel_tap_service_unsubscribe(); bluetooth_connection_service_unsubscribe(); tick_timer_service_unsubscribe(); window_destroy(window); if (main_noMenu && config_dontClose) { closeApp(); } if (main_noMenu) closingMode = true; for (int i = 0; i < NOTIFICATION_SLOTS; i++) { destroy_notification(notificationData[i]); } }
void normalKey(unsigned char key, int x, int y) { printf("pressed normal key is %c\n", key); int mod = glutGetModifiers(); if (mod != 0) { //ALT=4 SHIFT=1 CTRL=2 switch(mod) { case 1 : printf("SHIFT key %d\n",mod); break; case 2 : printf("CTRL key %d\n",mod); break; case 4 : printf("ALT key %d\n",mod); break; mod=0; } } switch(key) { case(27): { closeApp(); break; } } }
void MainWindow::startFunctions() { headersLst.append("ОУ"); headersLst.append("Адрес"); headersLst.append("Класс"); treeMdl = new TreeModel(headersLst); ui->progressBarTree->hide(); lblSN = new QLabel; lblPOVer = new QLabel(); lblNetNum = new QLabel(); lblNumLiter = new QLabel(); lblStatus = new QLabel(); lblPort = new QLabel(); lblSysAddress = new QLabel(); lblCoverStat = new QLabel(); lblBindStat = new QLabel(); lblIn1 = new QLabel(); lblIn2 = new QLabel(); lblNoize = new QLabel(); lblInterView = new QLabel(); statusBar()->addWidget(lblArrow, 0); statusBar()->addWidget(lblStatus, 0); statusBar()->addWidget(lblPort, 0); statusBar()->addWidget(lblCoverStat, 0); statusBar()->addWidget(lblBindStat, 0); statusBar()->addWidget(lblIn1, 0); statusBar()->addWidget(lblIn2, 0); statusBar()->addWidget(lblNoize, 0); statusBar()->addWidget(lblPOVer, 0); statusBar()->addWidget(lblSN, 0); statusBar()->addWidget(lblNetNum, 0); statusBar()->addWidget(lblNumLiter, 0); statusBar()->addWidget(lblSysAddress, 0); statusBar()->addWidget(chckBxInterView, 0); statusBar()->addWidget(lblInterView, 0); lblBindStat->setFixedSize(61, 26); lblNoize->setFixedSize(40, 26); lblCoverStat->setFixedSize(77, 26); lblBindStat->setStyleSheet("QLabel { background-color : white; }"); lblNetNum->setText("Сеть:\n"); lblNetNum->setToolTip("Номер сети"); lblNumLiter->setText("Литера:\n"); lblNumLiter->setToolTip("Номер литеры"); lblSN->setText("S/N:\n"); lblSN->setToolTip("Серийный номер контроллера"); lblSysAddress->setText("Системный\nадрес: "); lblSysAddress->setToolTip("Системный адрес контроллера"); lblPOVer->setText("Версия прошивки:\n"); lblPOVer->setToolTip("Версия прошивки контроллера:"); lblInterView->setText("Опрос"); connect(ui->actUpdate, SIGNAL(triggered()), this, SLOT(slotActUpdate())); connect(ui->actExit, SIGNAL(triggered()), this, SLOT(close())); connect(ui->actHelp, SIGNAL(triggered()), this, SLOT(help())); connect(ui->actSetNetParams, SIGNAL(triggered()), this, SLOT(slotSetParams())); connect(ui->actExit, SIGNAL(triggered()), this, SLOT(close())); connect(ui->actAbout, SIGNAL(triggered()), this, SLOT(slotAboutApp())); connect(ui->actRestart, SIGNAL(triggered()), this, SLOT(slotReboot())); connect(ui->actConnectPort, SIGNAL(triggered()), this, SLOT(slotConnectTo())); connect(ui->pbBind, SIGNAL(clicked()), this, SLOT(slotBind())); connect(ui->actTree, SIGNAL(triggered()), this, SLOT(slotAskTree())); connect(chckBxInterView, SIGNAL(clicked(bool)), this, SLOT(slotInterview(bool))); connect(ui->pbSet, SIGNAL(clicked()), this, SLOT(slotSetSettings())); connect(ui->pbCancel, SIGNAL(clicked()), this, SLOT(slotCancelSettings())); connect(ui->act_showHideLog, SIGNAL(triggered(bool)), this, SLOT(slotShowHideLogAct(bool))); connect(ui->pbClear, SIGNAL(clicked(bool)), this, SLOT(clearTxtEdit(bool))); connect(ui->cmbBxCls, SIGNAL(currentIndexChanged(int)), this, SLOT(slotChangeCls(int))); connect(ui->cmbBxCmnd, SIGNAL(currentIndexChanged(QString)), this, SLOT(slotChangeCmnd(QString))); connect(ui->pbSend, SIGNAL(clicked()), this, SLOT(slotPBSend())); connect(ui->pages, SIGNAL(currentChanged(int)), this, SLOT(slotTabChanged(int))); connect(ui->pbLoad, SIGNAL(clicked()), this, SLOT(slotAskTree())); connect(treeMdl, SIGNAL(signalDropTreeNode(int, int, int, int, unsigned char)), this, SLOT(slotDropTreeNode(int, int, int, int, unsigned char))); answerFlag = true; writeInLogFlag = false; customCommFlag = false; lblCoverStat->setText("Крышка\nзакрыта"); lblBindStat->setText("Связывания\nнет"); lblIn1->setText("Вход 1"); lblIn2->setText("Вход 2"); /*this->setMouseTracking(true); ui->tabs->setMouseTracking(true);*/ createDev(); loadCommLst(); loadDevSpecMap(); ui->treeView->setModel(treeMdl); ui->treeView->setSelectionMode(QAbstractItemView::ExtendedSelection); ui->treeView->setDragEnabled(true); ui->treeView->setAcceptDrops(true); ui->treeView->setDropIndicatorShown(true); ui->treeView->setSelectionBehavior(QAbstractItemView::SelectRows); ui->treeView->expandAll(); updateActions(); QVBoxLayout *vbl = new QVBoxLayout(); vbl->addWidget(lgWgt); ui->logTab->setLayout(vbl); //connect(this, SIGNAL(signal_log_click()), logWgt, SLOT(slot_log_clicked())); qDebug() << "start"; if(pb->pairObjArr.isEmpty()) //closeApp("<u><b>Приложение будет закрыто.</b></u><i> Нет доступных подключений.</i>"); qDebug() << "No connection"; else { connect(m_sde, SIGNAL(hasChanged(QStringList)), this, SLOT(printDevices(QStringList))); if(pb->pairObjArr.size() > 1) { dsc = new DialogSelectConnection(pb); connect(dsc, SIGNAL(tryConnSignal(QString, QString)), this, SLOT(sendTryConn(QString, QString))); if(dsc->exec() != dsc->Accepted) closeApp("<u><b>Приложение будет закрыто.</b></u><i> Подключение не выбрано.</i>"); delete dsc; } else { currPair.port = pb->pairObjArr.first().port; currPair.baud = pb->pairObjArr.first().baud; pserial = new AbstractSerial(this); if(!tryConnect(pserial, currPair.port, currPair.baud)) qDebug() << "serial port is not open"; } disconnect(this, SIGNAL(signPackReceive(QByteArray)), this, SLOT(parceAnswerPack(QByteArray))); connect(this, SIGNAL(signPackReceive(QByteArray)), this, SLOT(onPackReceiver(QByteArray))); connect(pserial, SIGNAL(readyRead()), this, SLOT(onProcSerialReceive())); pserial->enableEmitStatus(true); lblPort->setText(currPair.port + "\n" + currPair.baud); lblStatus->setText("Connected"); //lblStatus->setBackgroundRole(QColor(Qt::green)); MainWindow::setWindowTitle(currPair.port + " Конфигуратор Ладога-РК"); commLst.clear(); QTimer::singleShot(50, this, SLOT(createStartCommands())); } }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { //TODELETE ui->setupUi(this); this->setMinimumSize(800,650); /******************************************************************************************************/ // Instanciation of differents windows /******************************************************************************************************/ createListWindow_ = new CreateListWindow(); createProjectWindow_ = new CreateProjectWindow(); modifyListWindow_ = new ModifyListWindow(); modifyTaskWindow_ = new ModifyTaskWindow(); aboutWindow_ = new AboutWindow(); createTaskWindow_ = new CreateTaskWindow(); /* QListView definition for the history */ myListView = new QListView(); historyModel = new QStandardItemModel; myListView->setModel(historyModel); myListView->setAlternatingRowColors(true); /******************************************************************************************************/ /* Creats layouts */ /******************************************************************************************************/ QLayout * projectLayout = new QVBoxLayout(); QLayout * taskLayout = new QVBoxLayout(); QLayout * listLayout = new QVBoxLayout(); QLayout * actionsLayout = new QVBoxLayout(); QLayout * historyLayout = new QVBoxLayout(); /******************************************************************************************************/ /* Creats groupBox */ /******************************************************************************************************/ QGroupBox * projectGroup = new QGroupBox("Projet"); QGroupBox * taskGroup = new QGroupBox("Tâches"); QGroupBox * listGroup = new QGroupBox("Listes"); QGroupBox * actionsGroup = new QGroupBox("Actions"); QGroupBox * historyGroup = new QGroupBox("Historique"); /******************************************************************************************************/ /* Creats buttons */ /******************************************************************************************************/ createProject = new QPushButton("Créer un nouveau projet"); this->setButtonIcon(createProject,(std::string)":Images/project_icon"); createTask = new QPushButton("Créer une tâche"); this->setButtonIcon(createTask,(std::string)":Images/tache_icon"); modifyTask = new QPushButton("Modifier une tâche"); this->setButtonIcon(modifyTask,(std::string)":Images/engrenage_icon"); createList = new QPushButton("Créer une liste"); this->setButtonIcon(createList,(std::string)":Images/liste_icon"); modifyList = new QPushButton("Modifier une liste"); this->setButtonIcon(modifyList,(std::string)":Images/engrenage_icon"); deleteItem = new QPushButton("Supprimer un élément"); this->setButtonIcon(deleteItem,(std::string)":Images/minus_icon"); up = new QPushButton("Monter"); this->setButtonIcon(up,(std::string)":Images/up_icon"); down = new QPushButton("Descendre"); this->setButtonIcon(down,(std::string)":Images/down_icon"); history = new QPushButton("Historique"); this->setButtonIcon(history,(std::string)":Images/history_icon"); /******************************************************************************************************/ /* Adding buttons to layouts */ /******************************************************************************************************/ projectLayout->addWidget(createProject); listLayout->addWidget(createList); listLayout->addWidget(modifyList); taskLayout->addWidget(createTask); taskLayout->addWidget(modifyTask); actionsLayout->addWidget(deleteItem); actionsLayout->addWidget(up); actionsLayout->addWidget(down); historyLayout->addWidget(history); historyLayout->addWidget(myListView); /******************************************************************************************************/ /* Adding layouts to GroupBox */ /******************************************************************************************************/ projectGroup->setLayout(projectLayout); taskGroup->setLayout(taskLayout); listGroup->setLayout(listLayout); actionsGroup->setLayout(actionsLayout); historyGroup->setLayout(historyLayout); /******************************************************************************************************/ /* Adding QGroupBox to QToolBar */ /******************************************************************************************************/ ui->mainToolBar->addWidget(projectGroup); ui->mainToolBar->addWidget(taskGroup); ui->mainToolBar->addWidget(listGroup); ui->mainToolBar->addWidget(actionsGroup); /* Adding buttons to ToolBar */ ui->toolBar->addWidget(historyGroup); /******************************************************************************************************/ // Slots and signals definition /******************************************************************************************************/ //Create a project QObject::connect(ui->actionNewProject, SIGNAL(triggered()), this, SLOT(slotCreateProjectWindow())); QObject::connect(createProject, SIGNAL(clicked()), this, SLOT(slotCreateProjectWindow())); QObject::connect(createProjectWindow_, SIGNAL(createProject(Liste *)), this, SLOT(addProject(Liste *))); //Loading Project QObject::connect(ui->actionOpenProject, SIGNAL(triggered()), this, SLOT(slotOpenProjectWindow())); //Loading Template QObject::connect(ui->actionOpenTemplate, SIGNAL(triggered()), this, SLOT(slotOpenTemplateWindow())); //Create a task QObject::connect(ui->actionCreateTask, SIGNAL(triggered()), this, SLOT(slotCreateTaskWindow())); QObject::connect(createTask, SIGNAL(clicked()), this, SLOT(slotCreateTaskWindow())); QObject::connect(createTaskWindow_, SIGNAL(transferTask(Tache *)), this, SLOT(addTask(Tache *))); //Delete an element QObject::connect(deleteItem, SIGNAL(clicked()), this, SLOT(deleteElement())); //Modify a task QObject::connect(ui->actionModifyTask, SIGNAL(triggered()), this, SLOT(slotModifyTaskWindow())); QObject::connect(modifyTask, SIGNAL(clicked()), this, SLOT(slotModifyTaskWindow())); QObject::connect(modifyTaskWindow_, SIGNAL(modifyTask(Tache*,Tache*)), this, SLOT(modifyTaskAt(Tache*,Tache*))); //Create a list of tasks QObject::connect(ui->actionCreateList, SIGNAL(triggered()), this, SLOT(slotCreateListWindow())); QObject::connect(createList, SIGNAL(clicked()), this, SLOT(slotCreateListWindow())); QObject::connect(createListWindow_, SIGNAL(createList(Liste *)), this, SLOT(addList(Liste *))); //Modify a list of tasks QObject::connect(ui->actionModifyList, SIGNAL(triggered()), this, SLOT(slotModifyListWindow())); QObject::connect(modifyList, SIGNAL(clicked()), this, SLOT(slotModifyListWindow())); QObject::connect(modifyListWindow_, SIGNAL(modifyList(Liste*,Liste*)), this, SLOT(modifyListAt(Liste*,Liste*))); //Save project QObject::connect(ui->actionSaveUnList, SIGNAL(triggered()), this, SLOT(saveProject())); //Save template QObject::connect(ui->actionSaveTemplate, SIGNAL(triggered()), this, SLOT(saveTemplate())); //About Window QObject::connect(ui->actionAboutPeaceTache, SIGNAL(triggered()), this, SLOT(slotAboutWindow())); //UP element QObject::connect(ui->actionUp, SIGNAL(triggered()), this, SLOT(upElement())); QObject::connect(up, SIGNAL(clicked()), this, SLOT(upElement())); //DOWN element QObject::connect(ui->actionDown, SIGNAL(triggered()), this, SLOT(downElement())); QObject::connect(down, SIGNAL(clicked()), this, SLOT(downElement())); //history button QObject::connect(history, SIGNAL(clicked()), this, SLOT(showOrHideHistory())); //close window QObject::connect((ui->actionQuit), SIGNAL(triggered()), this, SLOT(closeApp())); QObject::connect((ui->treeView), SIGNAL(itemSelectionChanged()), this, SLOT(selectionChanged())); ui->treeView->setAnimated(true); ui->treeView->setHeaderHidden(true); /******************************************************************************************************/ //Disable buttons and menus /******************************************************************************************************/ createList->setEnabled(false); createTask->setEnabled(false); modifyTask->setEnabled(false); modifyList->setEnabled(false); deleteItem->setEnabled(false); up->setEnabled(false); down->setEnabled(false); this->loadCache(); }
void EventHandler::processValueChanged(std::string host, std::string key, std::string value){ qDebug() << "value - key:: host:" << host.c_str() << " key:"<< key.c_str() << " value:" << value.c_str() << "time: " << QTime::currentTime().toString() ; if(key.compare("i_iniciar_simulador") == 0){ if (value.compare("con") == 0){ qDebug() << "i_iniciar_simulador con recibido" ; m_eNetHelper->client()->CambiarValorClave("c_listo","0"); emit controlReady(); m_eNetHelper->client()->Suscribirse(m_eNetHelper->instructionsHostName(),"i_estado_simulador"); m_eNetHelper->client()->Suscribirse(m_eNetHelper->visualHostName(),"v_velocidad"); m_eNetHelper->client()->Suscribirse(m_eNetHelper->visualHostName(),"v_voltaje"); m_eNetHelper->client()->Suscribirse(m_eNetHelper->visualHostName(),"v_esfuerzo"); m_eNetHelper->client()->Suscribirse(m_eNetHelper->visualHostName(),"v_estado_puertas"); emit controlReset(); m_eNetHelper->client()->CambiarValorClave("c_rana","at"); m_eNetHelper->client()->CambiarValorClave("c_regulador_mando","0"); m_eNetHelper->client()->CambiarValorClave("c_traccion","0"); m_eNetHelper->client()->CambiarValorClave("c_freno_emergencia","des"); emit controlDisable(); m_eNetHelper->client()->CambiarValorClave("c_listo","1"); }else if (value.compare("des") == 0){ m_eNetHelper->client()->CambiarValorClave("c_listo","0"); m_eNetHelper->client()->CambiarValorClave("c_regulador_mando"," "); m_eNetHelper->client()->CambiarValorClave("c_llave_atp"," "); m_eNetHelper->client()->CambiarValorClave("c_modo_conduccion"," "); Sleep(1000); emit closeApp(); } } else if(key.compare("i_estado_simulador") == 0){ if (value.compare("0") == 0){ qDebug() << "i_estado_simulador 0 recibido" ; m_eNetHelper->client()->CambiarValorClave("c_listo","0"); emit controlReset(); m_eNetHelper->client()->CambiarValorClave("c_rana","at"); m_eNetHelper->client()->CambiarValorClave("c_regulador_de_mando","0"); m_eNetHelper->client()->CambiarValorClave("c_traccion","0"); emit controlDisable(); m_eNetHelper->client()->CambiarValorClave("c_listo","1"); } else if(value.compare("1") == 0){ emit controlEnable(); } else if(value.compare("2") == 0){ emit controlDisable(); } } else if(key.compare("v_velocidad") == 0){ m_subte->updateSpeed(std::stod(value)); qDebug() << "Velocidad ingresa velocidad correcta." ; } else if(key.compare("v_voltaje") == 0){ try{ m_subte->updateVolt(std::stod(value)); } catch (...) { qDebug() << "voltaje incorrecta." ; } } else if(key.compare("v_voltaje") == 0){ try{ m_subte->updateVolt(std::stod(value)); } catch (...) { qDebug() << "voltaje incorrecta." ; } } else if(key.compare("v_esfuerzo") == 0){ try{ m_subte->updateAmm(std::stod(value)); } catch (...) { qDebug() << "esfuerzo incorrecta." ; } } else if(key.compare("v_estado_puertas") == 0){ try{ qDebug() << "cambio de estado de puertas"; QString message = value.c_str(); QStringList parameters = message.split(";"); std::string side = parameters.at(0).toStdString(); std::string state = parameters.at(1).toStdString(); if(side.compare("derecha") == 0){ if(state.compare("abierto") == 0){ m_subte->openRightDoors(); qDebug() << "puertas derechas abiertas"; } else if(state.compare("cerrado") == 0){ m_subte->closeRightDoors(); qDebug() << "puertas derechas cerradas"; } } else { if(state.compare("abierto") == 0){ m_subte->openLeftDoors(); qDebug() << "puertas izquierdas abiertas"; } else if(state.compare("cerrado") == 0){ m_subte->closeLeftDoors(); qDebug() << "puertas izquierdas cerrado"; } } } catch (...) { qDebug() << "valor puertas incorrecto." ; } } }
// The network commandMessage method void commandMessage(std::string text, IClientSocket *socket) { std::string command, option, data; decodeMessage(text,command,option,data); fusion->errlog << "command = " << command << ", option = " << option << ", data = " << data << std::endl; // If all strings are empty, error occured, a blank // string, or messed up string cannot be processed if(command.empty() == true && option.empty() == true && data.empty() == true) return; if(socket == state.client) clientMessage(command,option,data,socket); else serverMessage(command,option,data,socket); /* Client/Server commands go here, where they are not resolved in the specific clientMessage/serverMessage methods */ // Client/Server command: both can change their userName they are chatting with if(command == "setUsername") { if(option.empty() == true){ // No ID passed with this command // WAITING CLIENT if(state.enableClient == true && getConnected() == "Connect"){ remoteMessage("/newClient,"+data); }else{ std::string name; std::string idcode = state.id; if(state.enableClient == true){ if(getConnected() == "Disconnect") name = state.username; else socket = state.client; }else if(state.enableServer == true){ if(socket == NULL) name = state.username; else idcode = idstring(socket); } clientMessage("/info,socket = "+idcode); remoteMessage("/setUsername,"+name+";"+data+":"+idcode,socket); } }else{ // ID was passed with this command size_t pos = option.find(";"); if(pos > 0){ std::string oldUser = option.substr(0,pos); std::string newUser = option.substr(pos+1); if(renameUser(oldUser,newUser,data) == true){ broadcastMessage("/setUsername,"+option+":"+data, socket); }else{ clientMessage("/error,userFound"); } }else{ updateUsername(option.substr(1)); } } } if(command == "quit") closeApp(); }
int main ( int argc, char *argv[] ) { struct option long_opts[] = { { "help", 0, 0, 'H' }, { "version", 0, 0, 'V' }, { "nastiness", 0, 0, 'n' }, { "bell", 0, 0, 'b' }, { "flash", 0, 0, 'f' }, { "ugly", 0, 0, 'u' }, { "hidekeys", 0, 0, 'k' }, { 0, 0, 0, 0 } }; int opt_index = 0; int c; while (1) { c = getopt_long(argc, argv, "HVnbfuk", long_opts, &opt_index); if (c == -1) { break; } switch (c) { case 'H': showHelp(); return 1; case 'V': showVersionInfo(); return 1; case 'b': beepsArentIrritating = 1; break; case 'f': flashesArentIrritating = 1; break; case 'n': nastiness = 1; break; case 'u': tryToBePretty = 0; break; case 'k': hideKeys = 1; break; } } initApp(); if (optind < argc) { while (optind < argc) { if (playFile(argv[optind]) < 0) { closeApp(); printf ("%s: %s: %s\n", argv[0], argv[optind], postmortem); return 1; } ++optind; } } else { menuInteractive(); } closeApp(); showVersionInfo(); return 0; }
PublisherDialog::PublisherDialog(QWidget *parent) : QMainWindow(parent), ui(new Ui::PublisherDialog), publisher(0) { ui->setupUi(this); #if defined(Q_OS_SYMBIAN) || defined(Q_WS_SIMULATOR) QPushButton* button = ui->buttonBox->button(QDialogButtonBox::Close); if (button) { ui->buttonBox->removeButton(button); } QPushButton *switchButton = ui->buttonBox->addButton(tr("Switch"), QDialogButtonBox::ActionRole); connect(switchButton, SIGNAL(clicked()), this, SIGNAL(switchRequested())); #elif defined(MEEGO_EDITION_HARMATTAN) connect(ui->buttonBox->button(QDialogButtonBox::Close), SIGNAL(clicked()), this, SIGNAL(closeApp())); #endif //! [1] connect(ui->connectButton, SIGNAL(clicked()), this, SLOT(createNewObject())); connect(ui->intValue, SIGNAL(valueChanged(int)), this, SLOT(intValueChanged(int))); connect(ui->unsetIntButton, SIGNAL(clicked()), this, SLOT(unsetIntValue())); connect(ui->setStringButton, SIGNAL(clicked()), this, SLOT(setStringValue())); connect(ui->setByteArrayButton, SIGNAL(clicked()), this, SLOT(setByteArrayValue())); //! [1] //! [3] createNewObject(); //! [3] }
int main(int argc, char *argv[]) { QApplication app(argc, argv); app.setOrganizationDomain("qt.nokia.com"); app.setApplicationName("Publish Subscribe Example"); bool createDefault = true; bool createPublisher = false; bool createSubscriber = false; for (int i = 1; i < argc; ++i) { if (argv[i] == QLatin1String("-server")) { QValueSpace::initValueSpaceServer(); } else if (argv[i] == QLatin1String("-publisher")) { createPublisher = true; createDefault = false; } else if (argv[i] == QLatin1String("-subscriber")) { createSubscriber = true; createDefault = false; } } PublisherDialog *publisher = 0; if (createDefault || createPublisher) { publisher = new PublisherDialog; #if defined(MEEGO_EDITION_HARMATTAN) publisher->show(); #endif } SubscriberDialog *subscriber = 0; if (createDefault || createSubscriber) { subscriber = new SubscriberDialog; #if defined(MEEGO_EDITION_HARMATTAN) subscriber->show(); #elif defined(Q_OS_SYMBIAN) || defined(Q_WS_SIMULATOR) subscriber->showMaximized(); #endif } #if defined(Q_OS_SYMBIAN) || defined(Q_WS_SIMULATOR) QObject::connect(publisher, SIGNAL(switchRequested()), subscriber, SLOT(showMaximized())); QObject::connect(publisher, SIGNAL(switchRequested()), subscriber, SLOT(repaint())); QObject::connect(publisher, SIGNAL(switchRequested()), publisher, SLOT(hide())); QObject::connect(subscriber, SIGNAL(switchRequested()), publisher, SLOT(showMaximized())); QObject::connect(subscriber, SIGNAL(switchRequested()), publisher, SLOT(repaint())); QObject::connect(subscriber, SIGNAL(switchRequested()), subscriber, SLOT(hide())); #elif defined(MEEGO_EDITION_HARMATTAN) QObject::connect(publisher, SIGNAL(closeApp()), &app, SLOT(quit())); QObject::connect(subscriber, SIGNAL(closeApp()), &app, SLOT(quit())); #endif int result = app.exec(); if (publisher) delete publisher; if (subscriber) delete subscriber; return result; }
SubscriberDialog::SubscriberDialog(QWidget *parent) : QMainWindow(parent), ui(new Ui::SubscriberDialog), subscriber(0), tableWidget(0), listWidget(0) { ui->setupUi(this); #if defined(Q_OS_SYMBIAN) || defined(Q_WS_SIMULATOR) QPushButton* button = ui->buttonBox->button(QDialogButtonBox::Close); if (button) { ui->buttonBox->removeButton(button); } QPushButton *switchButton = ui->buttonBox->addButton(tr("Switch"), QDialogButtonBox::ActionRole); connect(switchButton, SIGNAL(clicked()), this, SIGNAL(switchRequested())); #elif defined(MEEGO_EDITION_HARMATTAN) connect(ui->buttonBox->button(QDialogButtonBox::Close), SIGNAL(clicked()), this, SIGNAL(closeApp())); #endif QDesktopWidget desktopWidget; if (desktopWidget.availableGeometry().width() < 400) { // Screen is too small to fit a table widget without scrolling, use a list widget instead. listWidget = new QListWidget; listWidget->setAlternatingRowColors(true); ui->verticalLayout->insertWidget(2, listWidget); } else { tableWidget = new QTableWidget; QStringList headerLabels; headerLabels << tr("Key") << tr("Value") << tr("Type"); tableWidget->setColumnCount(3); tableWidget->setHorizontalHeaderLabels(headerLabels); tableWidget->horizontalHeader()->setStretchLastSection(true); tableWidget->verticalHeader()->setVisible(false); ui->verticalLayout->insertWidget(2, tableWidget); } connect(ui->connectButton, SIGNAL(clicked()), this, SLOT(changeSubscriberPath())); changeSubscriberPath(); // if the default path does not exist reset it to / QVariant value = subscriber->value(); if (!subscriber->value().isValid() && subscriber->subPaths().isEmpty()) { ui->basePath->setText(QLatin1String("/")); changeSubscriberPath(); } }
void TitleBar::quit() { emit closeApp(); }