SessionDlg::SessionDlg(QWidget* parent) : QDialog(parent), result_(0) { ui.setupUi(this); ui.sessionTree->header()->hide(); QStringList sList = sessionList(); foreach (QString session, sList) { if (session.compare("_empty_session_") != 0) { QStringList items; items << session; QTreeWidgetItem* it = new QTreeWidgetItem(items); ui.sessionTree->addTopLevelItem(it); } } if (sList.count() > 0) { ui.sessionTree->setCurrentItem(ui.sessionTree->topLevelItem(0)); } else { ui.openSessionBtn->setEnabled(false); ui.removeSessionBtn->setEnabled(false); } connect(ui.openSessionBtn, SIGNAL(clicked()), SLOT(openSession())); connect(ui.newSessionBtn, SIGNAL(clicked()), SLOT(newSession())); connect(ui.removeSessionBtn, SIGNAL(clicked()), SLOT(removeSession())); connect(ui.sessionTree, SIGNAL(itemActivated(QTreeWidgetItem*, int)), SLOT(activated(QTreeWidgetItem*, int))); }
Session SessionPool::get() { Poco::Mutex::ScopedLock lock(_mutex); if (_shutdown) throw InvalidAccessException("Session pool has been shut down."); purgeDeadSessions(); if (_idleSessions.empty()) { if (_nSessions < _maxSessions) { Session newSession(SessionFactory::instance().create(_connector, _connectionString)); applySettings(newSession.impl()); customizeSession(newSession); PooledSessionHolderPtr pHolder(new PooledSessionHolder(*this, newSession.impl())); _idleSessions.push_front(pHolder); ++_nSessions; } else throw SessionPoolExhaustedException(_connector); } PooledSessionHolderPtr pHolder(_idleSessions.front()); PooledSessionImplPtr pPSI(new PooledSessionImpl(pHolder)); _activeSessions.push_front(pHolder); _idleSessions.pop_front(); return Session(pPSI); }
void AtSessionManager::incoming( QSerialSocket *socket ) { // Arrange for the socket object to be destroyed when it is closed. connect( socket, SIGNAL(closed()), socket, SLOT(deleteLater()) ); // Hang the socket from this object so that it will get cleaned // up when the manager is destroyed because the destructor for // AtSessionManagerPrivate cannot see such sockets normally. socket->setParent( this ); // Find the options for the server that sent us this socket. QSerialSocketServer *server = qobject_cast<QSerialSocketServer *>( sender() ); int port = 0; if ( server ) port = server->port(); QString startupOptions; if ( d->tcpPortOptions.contains( port ) ) startupOptions = d->tcpPortOptions[port]; // Wrap the socket in a new session handler. We hang it off the // socket so it will get cleaned up automatically upon closing. AtFrontEnd *session = new AtFrontEnd( startupOptions, socket ); session->setDevice( socket ); emit newSession( session ); // Register the socket as a task so that atinterface stays alive // while the socket is active even if removeTcpPort() is called // on the main listening port. QString name = "AtInterfaceSocket" + QString::number( d->nextTaskId++ ); ((QtopiaApplication *)qApp)->registerRunningTask( name, session ); }
bool AtSessionManager::addSerialPort ( const QString& deviceName, const QString& options ) { // Bail out if the device is already bound. if ( d->serialPorts.contains( deviceName ) ) return true; // Attempt to open the device. QSerialPort *port = QSerialPort::create( deviceName, 115200, true ); if ( !port ) return false; connect( port, SIGNAL(destroyed()), this, SLOT(serialPortDestroyed()) ); // Zero reads on RFCOMM sockets should cause a close to occur. port->setKeepOpen( false ); // Add the device to our list. d->serialPorts.insert( deviceName, port ); registerTaskIfNecessary(); // Wrap the device in a new session handler. We hang it off the // serial port object so it will get cleaned up automatically // when removeSerialPort is called. AtFrontEnd *session = new AtFrontEnd( options, port ); session->setDevice( port ); emit newSession( session ); return true; }
Session SessionPool::get(SessionPool::SessionDataPtr &session_data_ptr) { Poco::Mutex::ScopedLock lock(_mutex); if (_shutdown) throw InvalidAccessException("Session pool has been shut down."); purgeDeadSessions(); if (_idleSessions.empty()) { Session newSession(SessionFactory::instance().create(_connector, _connectionString)); applySettings(newSession.impl()); PooledSessionHolderPtr pHolder(new PooledSessionHolder(*this, newSession.impl())); session_data_ptr.assign(new SessionData); session_data_ptr->session = pHolder; _idleSessions.push_front(session_data_ptr); ++_nSessions; } PooledSessionHolderPtr pHolder(_idleSessions.front()->session); PooledSessionImplPtr pPSI(new PooledSessionImpl(pHolder)); _activeSessions.push_front(std::move(_idleSessions.front())); _idleSessions.pop_front(); if (session_data_ptr.isNull()) { session_data_ptr.assign(_activeSessions.front()); } return Session(pPSI); }
bool Game::startLocalGame() { network->startServer(); network->connectToLobbyServer("localhost", 13337); newSession("localhost"); return true; }
void GameServer::startAccept() { PlayerSession::ptr newSession(new PlayerSession(io_service, game)); acceptor.async_accept(newSession->getSocket(), boost::bind(&GameServer::handleAccept, this, newSession, boost::asio::placeholders::error)); }
LocalSock::LocalSock(const string &_sockFile) : m_acceptor(m_ioService, local::stream_protocol::endpoint(_sockFile)) { // accept new connection SessionPtr newSession(new Session(m_ioService)); m_acceptor.async_accept(newSession->socket(), boost::bind(&LocalSock::handleAccept, this, newSession, boost::asio::placeholders::error)); }
void StreamSessionAdapter::SessionHolder::reborn() const { if (!session_->isSick()) return; std::auto_ptr<SAM::StreamSession> newSession(new SAM::StreamSession(*session_)); if (!newSession->isSick() && session_->isSick()) session_ = newSession; }
SessionManager::SessionManager(Window* parent) : QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint), m_session(0), m_window(parent) { setWindowTitle(tr("Manage Sessions")); // Create session lists m_sessions_menu = new QMenu(this); m_sessions_menu->setTitle(tr("S&essions")); m_sessions_actions = new QActionGroup(this); connect(m_sessions_actions, SIGNAL(triggered(QAction*)), this, SLOT(switchSession(QAction*))); m_sessions_list = new QListWidget(this); m_sessions_list->setIconSize(QSize(16,16)); m_sessions_list->setMovement(QListWidget::Static); m_sessions_list->setResizeMode(QListWidget::Adjust); m_sessions_list->setSelectionMode(QListWidget::SingleSelection); connect(m_sessions_list, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), this, SLOT(selectedSessionChanged(QListWidgetItem*))); connect(m_sessions_list, SIGNAL(itemActivated(QListWidgetItem*)), this, SLOT(switchSession())); // Create buttons QPushButton* new_button = new QPushButton(tr("New"), this); connect(new_button, SIGNAL(clicked()), this, SLOT(newSession())); m_rename_button = new QPushButton(tr("Rename"), this); connect(m_rename_button, SIGNAL(clicked()), this, SLOT(renameSession())); QPushButton* clone_button = new QPushButton(tr("Clone"), this); connect(clone_button, SIGNAL(clicked()), this, SLOT(cloneSession())); m_delete_button = new QPushButton(tr("Delete"), this); connect(m_delete_button, SIGNAL(clicked()), this, SLOT(deleteSession())); m_switch_button = new QPushButton(tr("Switch To"), this); connect(m_switch_button, SIGNAL(clicked()), this, SLOT(switchSession())); QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Close, Qt::Horizontal, this); connect(buttons, SIGNAL(rejected()), this, SLOT(reject())); // Lay out window QGridLayout* layout = new QGridLayout(this); layout->setColumnStretch(0, 1); layout->setRowStretch(5, 1); layout->addWidget(m_sessions_list, 0, 0, 6, 1); layout->addWidget(new_button, 0, 1); layout->addWidget(m_rename_button, 1, 1); layout->addWidget(clone_button, 2, 1); layout->addWidget(m_delete_button, 3, 1); layout->addWidget(m_switch_button, 4, 1); layout->addWidget(buttons, 7, 1); // Restore size resize(QSettings().value("SessionManager/Size", sizeHint()).toSize()); }
bool Game::startOnlineGame() { cvar* var = Config::shared().getCvar("serveraddress"); const char* serveraddr = (var ? var->value.c_str() : "localhost"); network->connectToLobbyServer(serveraddr, 13337); newSession(serveraddr); return true; }
MainWindow::MainWindow(QWidget *parent, Qt::WindowFlags f) : QMainWindow(parent,f) { _sessionCount = 0; // setup the ui #ifdef QTOPIA_PHONE QMenu *m = QSoftMenuBar::menuFor(this); #else resize(800,600); QMenu *m = menuBar()->addMenu(tr("Options")); #endif acNewSession = m->addAction(tr("New Session")); acCloseSession = m->addAction(tr("Close Session")); acPreferences = m->addAction(tr("Preferences")); #ifndef QTOPIA_PHONE m->addSeparator(); QAction *m_exit = m->addAction(tr("Exit")); connect(m_exit, SIGNAL(triggered()), this, SLOT(closeAll())); #endif // FIXME: need this to close, and hide the input method #ifdef QTOPIA_APPLICATION connect(QtopiaApplication::instance(), SIGNAL(aboutToQuit()), this, SLOT(closeAll())); #else connect(QApplication::instance(), SIGNAL(aboutToQuit()), this, SLOT(closeAll())); #endif connect(acNewSession, SIGNAL(triggered()), this, SLOT(newSession())); connect(acCloseSession, SIGNAL(triggered()), this, SLOT(closeSession())); connect(acPreferences, SIGNAL(triggered()), this, SLOT(showPreferences())); tabs = new QTabWidget(); setCentralWidget(tabs); setWindowTitle(tr("qterminal")); #ifdef QTOPIA_PHONE if (Qtopia::mousePreferred) { // not sure which one is preferrable //QtopiaApplication::setInputMethodHint(this, QtopiaApplication::AlwaysOn); setAttribute(Qt::WA_InputMethodEnabled, true); QtopiaApplication::instance()->showInputMethod(); } #endif connect(tabs,SIGNAL(currentChanged(int)), this, SLOT(currentChanged(int))); newSession(); }
/*! \fn AppContext::getSession(const std::string& sid, bool create) @param sid Session ID. If empty string, new session is created @param create Whether to create session if it doesn't exist @return Pointer to the session. @note sets session state to not-new when sid is not empty This presumes session is only retrieved from Context once per request */ container::HttpSessionImpl* AppContext::getSession(const std::string& sid, bool create) { sptk::CGuard guard(m_sessionLock); if(sid.empty()) { container::HttpSessionImpl *s = 0; if(create) s = newSession(); return s; } sessionlist_t::iterator s=m_sessions.find(sid); if(s==m_sessions.end()||!s->second->validP()){ HttpSessionImpl* s = 0; if(create) s = newSession(); return s; } s->second->notNew(); return s->second; }
void MainWindow::toggleRun(bool buttonPressed) { if (buttonPressed) { ui->pushButtonRun->setText("stop"); params->setOutputDir(ui->lineEdit->text()); qDebug() << "Setting output dir: " << params->getOutDir().absolutePath(); emit startListening(); } else { emit stopListening(); ui->pushButtonRun->setText("run "); newSession(); } }
void MainWindow::initActions() { m_sessionNew = new QAction(this); m_sessionNew->setShortcut( tr( "Ctrl+N" ) ); connect ( m_sessionNew , SIGNAL ( triggered() ), this , SLOT ( newSession() ) ); m_sessionList = new QAction(this); m_sessionList->setShortcut( tr( "Ctrl+L" ) ); connect ( m_sessionList , SIGNAL ( triggered() ), this , SLOT ( sessionList() ) ); m_closeFullScreenAction = new QAction(this); m_closeFullScreenAction -> setIcon( QIcon( ":/shellicons/Restore") ); connect ( m_closeFullScreenAction , SIGNAL ( triggered() ), this , SLOT ( showNormal() ) ); //TODO: Fix fullscreen action behaviour m_fullScreenAction = new QAction(this); m_fullScreenAction -> setIcon( QIcon( ":/icons/FullScreen") ); m_fullScreenAction->setShortcut( tr( "F11" ) ); connect ( m_fullScreenAction, SIGNAL ( triggered() ), this , SLOT ( fullScreen() ) ); m_quitAction = new QAction(this); m_quitAction->setShortcut(tr("Ctrl+Q")); m_quitAction -> setIcon( QIcon( ":/icons/Quit") ); connect ( m_quitAction, SIGNAL ( triggered() ), this , SLOT ( close() ) ); m_updateAllMonitorsActions = new QAction(this); m_updateAllMonitorsActions->setShortcut( tr("F5") ); connect ( m_updateAllMonitorsActions, SIGNAL ( triggered() ),this, SLOT ( update() ) ); m_selectStyleAction = new QAction(this); connect ( m_selectStyleAction , SIGNAL (triggered()), this , SLOT ( selectStyle() ) ); m_preferencesAction = new QAction( this ); connect ( m_preferencesAction, SIGNAL ( triggered() ),this, SLOT ( showPreferences() ) ); aboutAction = new QAction(this); aboutQtAction = new QAction(this); connect ( aboutAction, SIGNAL ( triggered () ), this, SLOT ( aboutDialog() ) ); connect ( aboutQtAction, SIGNAL ( triggered () ), qApp, SLOT ( aboutQt() ) ); }
//---------------------------------------------------------------------------- // //---------------------------------------------------------------------------- int CaClientNotifierProxy::registerNotifier( const CaNotifierFilter *notifierFilter, CaNotifierPrivate::NotifierType notifierType, const IDataObserver *observer) { qDebug() << "CaClientProxy::registerNotifier notifierType:" << notifierType; CCaInnerNotifierFilter::TNotifierType innerNotifierType( CCaInnerNotifierFilter::EEntryChangedWithId); CaObjectAdapter::convert(notifierType, innerNotifierType); CCaInnerNotifierFilter *innerNotifierFilter(NULL); TRAPD(error, innerNotifierFilter = CCaInnerNotifierFilter::NewLC(innerNotifierType); CaObjectAdapter::convertL(*notifierFilter, *innerNotifierFilter); CleanupStack::Pop(innerNotifierFilter) ); if (!error) { // Lock the access to mSessions. // It will be automatically unlocked at the end of the current range. QMutexLocker locker(&mMutex); RCaClientNotifierSession *session = findSession(); if (!session) { session = newSession(error); } if (!error) { error = session->RegisterNotifier(innerNotifierFilter, notifierFilter, observer); } } qDebug() << "CaClientProxy::registerNotifier result:" << error; return error; }
Session SessionPool::get() { Poco::FastMutex::ScopedLock lock(_mutex); purgeDeadSessions(); if (_idleSessions.empty()) { if (_nSessions < _maxSessions) { Session newSession(SessionFactory::instance().create(_sessionKey, _connectionString)); PooledSessionHolderPtr pHolder(new PooledSessionHolder(*this, newSession.impl())); _idleSessions.push_front(pHolder); ++_nSessions; } else throw SessionPoolExhaustedException(_sessionKey, _connectionString); } PooledSessionHolderPtr pHolder(_idleSessions.front()); PooledSessionImplPtr pPSI(new PooledSessionImpl(pHolder)); _activeSessions.push_front(pHolder); _idleSessions.pop_front(); return Session(pPSI); }
void MainWindow::initMenuFile() { //connect menu "File" Action connect(actionNew, SIGNAL(triggered()), _documentManager, SLOT(newDocument())); connect(actionOpen, SIGNAL(triggered()), _documentManager, SLOT(open())); connect(actionSave, SIGNAL(triggered()), _documentManager, SLOT(save())); connect(actionSaveAs, SIGNAL(triggered()), _documentManager, SLOT(saveAs())); connect(actionSaveACopyAs, SIGNAL(triggered()), _documentManager, SLOT(saveACopyAs())); connect(actionSaveAll, SIGNAL(triggered()), _documentManager, SLOT(saveAll())); connect(actionClose, SIGNAL(triggered()), _documentManager, SLOT(close())); connect(actionCloseAll, SIGNAL(triggered()), _documentManager, SLOT(closeAll())); connect(actionCloseAllExceptCurrentDocument, SIGNAL(triggered()), _documentManager, SLOT(closeAllExceptCurrentDocument())); connect(actionReload, SIGNAL(triggered()), _documentManager, SLOT(reload())); connect(actionPrint, SIGNAL(triggered()), _documentManager, SLOT(print())); connect(actionExit, SIGNAL(triggered()), qApp, SLOT(closeAllWindows())); connect(actionExportAsHTML, SIGNAL(triggered()), this, SLOT(exportDocument())); connect(actionNewSession, SIGNAL(triggered()), _sessionManager, SLOT(newSession())); connect(actionOpenSession, SIGNAL(triggered()), _sessionManager, SLOT(openSession())); connect(actionSwitchSession, SIGNAL(triggered()), _sessionManager, SLOT(switchSession())); connect(actionSaveSession, SIGNAL(triggered()), _sessionManager, SLOT(saveSession())); connect(actionSaveSessionAs, SIGNAL(triggered()), _sessionManager, SLOT(saveSessionAs())); connect(actionManageSessions, SIGNAL(triggered()), _sessionManager, SLOT(manageSessions())); //recent file actions connect(actionEmptyRecentFilesList, SIGNAL(triggered()), this, SLOT(clearRecentFile())); connect(actionOpenAllRecentFiles, SIGNAL(triggered()), this, SLOT(openAllRecentFile())); _recentFileSeparator = menuRecentFiles->addSeparator(); for (int i = 0; i < MaxRecentFiles; ++i) { _recentFileActions[i] = new QAction(this); _recentFileActions[i]->setVisible(false); connect(_recentFileActions[i], SIGNAL(triggered()),this, SLOT(openRecentFile())); menuRecentFiles->addAction(_recentFileActions[i]); } updateRecentFileActions(); }
int monte_carlo_menu(void) { static int r=0; int mode=1; void * pscr=NULL; void (*quit)(int)=f3_key[7]; char menutxt[]="\030" " Subprocess " " IN state " " Model parameters " " Constraints " " QCD alpha & scales " " Breit-Wigner " " Aliases " " Cuts " " Phase space mapping " " Monte Carlo simulation " " Easy "; if(nout_int!=2 ) menutxt[menutxt[0]*10+1]=0; if(nin_int==1) improveStr(menutxt,"Easy", "Total width"); else improveStr(menutxt,"Easy", "1D integration"); wrtprc_(); for(;;) { infor(); f3_key[7]=quit; menu1(54,4,"",menutxt,"n_mc_*",&pscr, &mode); if(mode==1||mode==2||mode==3||mode==5||mode==7)f3_key[7]=NULL; switch (mode) { case 0: return 0; case 1: r=r|3*sub_men__(); break; case 2: r=r|in_setting(); break; case 3: r=r|change_parameter(54,7,0); break; case 4: { int modeC=1; for(;;) { char menuC[]="\030" " All Constraints " " Masses,Widths,Branching"; void * pscrC=NULL; menu1(54,6,"",menuC,"n_constr_*",&pscrC, &modeC); switch(modeC) { case 0: break; case 1: show_depend(54,7); break; case 2: show_spectrum(54,9); break; } if(!modeC) break; } break; } case 5: r=r|qcdmen_(); break; case 6: r=r|w_men__(); break; case 7: do r=r|(3*edittable(1,4,&compTab,1,"n_comp",0)); while (fillCompositeArray()); break; case 8: do r=r|(3*edittable(1,4,&cutTab,1,"n_cut",0)); while (fillCutArray()); break; case 9: r=r|mappingMenu(); break; case 10: if(nout_int==1 && !sf_num[0] && !sf_num[1] ) { if(blind) return 1; messanykey(15,15,"Phase space integration for 2->1 processes\n needs distribution functions."); break; } if(checkEnergy()) { if(blind==1) { char fname[50]; int i,j; sprintf(fname,"events_%d.txt", nSess); FILE * f=fopen(fname,"w"); fprintf(f,"#%s\n", VERSION_); fprintf(f,"#Type %d -> %d\n", nin_int,nout_int); fprintf(f,"#Initial_state "); if(nin_int==1) fprintf(f," P1=0\n"); else { fprintf(f," P1_3=0 P2_3=0\n"); wrt_sf__(f); } fprintf(f,"#PROCESS "); for(i=1;i<=nin_int+nout_int; i++) { int pcode; char * pname=pinf_int(Nsub,i,NULL,&pcode); fprintf(f," %d(%s)", pcode, pname); if(i==nin_int) fprintf(f," ->"); } fprintf(f,"\n"); fprintf(f,"#MASSES "); for(i=0;i<nin_int+nout_int;i++) { REAL m; pinf_int(Nsub,i+1,&m,NULL); fprintf(f," %.10E", (double)m); } fprintf(f,"\n"); fprintf(f,"#Cross_section(Width) %E\n",0.); fprintf(f,"#Number_of_events %10d\n",0); fprintf(f,"#Sum_of_weights %12.4E %12.4E \n",0.,0.); fprintf(f,"#Events "); if(nin_int==2) fprintf(f," P1_3 [Gev] P2_3 [Gev] "); for(i=1;i<=nout_int; i++) for(j=1;j<=3;j++) fprintf(f," P%d_%d [Gev] ",i+nin_int,j); integral.old=1; fclose(f); return 1; } messanykey(15,15,"Energy is too small!"); break; } if(fillCutArray()) { if(blind) return 2; messanykey(15,15,"Can not evaluate cut limits"); break; } case 11: if(mode==11) { void (*f10_tmp)(int); w_sess__(NULL); f10_tmp=f3_key[7]; f3_key[7]=f10_key_prog_for22; if(nin_int==1) decay12(); else { REAL m1,m2, Pcm; pinf_int(Nsub,1,&m1,NULL); pinf_int(Nsub,2,&m2,NULL); if(sf_num[0] && sf_mass[0]>m1) m1= sf_mass[0]; if(sf_num[1] && sf_mass[1]>m2) m2= sf_mass[1]; incomkin(m1,m2,inP1,inP2,NULL,&Pcm,NULL); if(sf_num[0]||sf_num[1]||nCuts) messanykey(10,10,"Structure functions and cuts are ignored\n"); cs_numcalc(Pcm); } f3_key[7]= f10_tmp; r_sess__(NULL); break; } else if(fillRegArray()) { if(blind) return 3; messanykey(15,15, "Can not evaluate regularization paremeters"); break; } if(mode==10) runVegas(); r=0; break; } //printf("r=%d\n",r); if(r) clearEventMax(); if(r&2) clearGrid(); if(r&1)newSession(); } }
int monte_carlo_menu(void) { static int r=0; int mode=1; void * pscr=NULL; void * pscr_mem=NULL; void (*quit)(int)=f3_key[7]; char menutxt[]="\030" " Subprocess " " IN state " " Model parameters " " Constraints " " QCD coupling " " Breit-Wigner " " Aliases " " Cuts " " Phase space mapping " " Monte Carlo simulation " " Easy "; if(nout_int!=2 ) menutxt[menutxt[0]*10+1]=0; if(nin_int==1) improveStr(menutxt,"Easy", "Total width"); else improveStr(menutxt,"Easy", "1D intergration"); get_text(1,10,80,24,&pscr_mem); wrtprc_(); for(;;) { infor(); f3_key[7]=quit; menu1(54,4,"",menutxt,"n_mc_*",&pscr, &mode); if(mode==1||mode==2||mode==3||mode==5||mode==7)f3_key[7]=NULL; switch (mode) { case 0: put_text(&pscr_mem); return 0; case 1: r=r|3*sub_men__(); break; case 2: r=r|in_setting(); break; case 3: r=r|change_parameter(54,7,0); break; case 4: { int modeC=1; for(;;) { char menuC[]="\030" " All Constraints " " Masses,Widths,Branching"; void * pscrC=NULL; menu1(54,6,"",menuC,"n_constr_*",&pscrC, &modeC); switch(modeC) { case 0: put_text(&pscr_mem); break; case 1: show_depend(54,7); break; case 2: show_spectrum(54,9); break; } if(!modeC) break; } break; } case 5: r=r|qcdmen_(); break; case 6: r=r|w_men__(); break; case 7: do r=r|(3*edittable(1,4,&compTab,1,"n_comp",0)); while (fillCompositeArray()); break; case 8: do r=r|(3*edittable(1,4,&cutTab,1,"n_cut",0)); while (fillCutArray()); break; case 9: r=r|mappingMenu(); break; case 10: if(nout_int==1 && !sf_num[0] && !sf_num[1] ) { if(blind) return 1; messanykey(15,15,"Phase space integration for 2->1 processes\n needs distribution functions."); break; } if(checkEnergy()) { if(blind) return 1; messanykey(15,15,"Energy is too small!"); break; } if(fillCutArray()) { if(blind) return 2; messanykey(15,15,"Can not evaluate cuts limlts"); break; } case 11: if(mode==11) { void (*f10_tmp)(int); w_sess__(NULL); f10_tmp=f3_key[7]; f3_key[7]=f10_key_prog_for22; if(nin_int==1) decay12(); else { REAL m1,m2, Pcm; pinf_int(Nsub,1,&m1,NULL); pinf_int(Nsub,2,&m2,NULL); incomkin(m1,m2,inP1,inP2,NULL,&Pcm,NULL); if(sf_num[0]||sf_num[1]||nCuts) messanykey(10,10,"Structure functions and cuts are ignored\n"); cs_numcalc(Pcm); } f3_key[7]= f10_tmp; r_sess__(NULL); break; } else if(fillRegArray()) { if(blind) return 3; messanykey(15,15, "Can not evaluate regularization paremeters"); break; } if(mode==10) runVegas(); r=0; break; } if(r) clearEventMax(); if(r&2) clearGrid(); if(r&1)newSession(); } }
bool GuiApp::perform (const InvocationInfo& info) { if (Commands::devicePadPress <= info.commandID && (Commands::devicePadPress + 13) > info.commandID) { const uint16 pad = info.commandID - Commands::devicePadPress; //ModifierKeys modKeys = ModifierKeys::getCurrentModifiersRealtime(); //unsigned long modifiers = 13;//kNoModifiers; if (info.isKeyDown) std::clog << "Pad pressed: " << pad << std::endl; else std::clog << "Pad released: " << pad << std::endl; } if (Commands::isDeviceTrackCommand (info.commandID)) { // pattern->setTrackIndex (info.commandID - Commands::deviceTrack); return true; } SessionRef sr (session()); switch (info.commandID) { case Commands::mediaSave: { //if (MediaManager::Document* doc = sr->media().openFile (sr.get(), pattern->getFile())) // doc->save(); return true; } case Commands::sessionClose: return true; break; case Commands::sessionNew: newSession(); return true; break; case Commands::sessionOpen: openSession(); return true; break; case Commands::sessionSave: { saveSession(); return true; break; } case Commands::sessionSaveAs: saveSession (true); return true; break; case Commands::showAbout: return true; break; case Commands::showLegacyView: openWindow (ELEMENT_LEGACY_WINDOW); return true; break; case Commands::showPluginManager: openWindow (ELEMENT_PLUGIN_MANAGER); return true; break; case Commands::showPreferences: runDialog (ELEMENT_PREFERENCES); return true; break; case Commands::transportRewind: break; case Commands::transportForward: break; case Commands::transportPlay: sr->testSetPlaying (true); break; case Commands::transportRecord: break; case Commands::transportSeekZero: break; case Commands::transportStop: sr->testSetRecording (false); sr->testSetPlaying (false); break; } return true; }
/*! * Handles incoming HTTP requests and dispatches them to the appropriate service. * * The \a requestID is an opaque value generated by the connector. * * Subclasses may override this function to perform preprocessing on each * request, but they must call the base class implementation in order to * generate and dispatch the appropriate events. * * To facilitate use with multi-threaded applications, the event will remain * valid until a response is posted. */ void QxtHttpSessionManager::incomingRequest(quint32 requestID, const QHttpRequestHeader& header, QxtWebContent* content) { QMultiHash<QString, QString> cookies; foreach(const QString& cookie, header.allValues("cookie")) // QHttpHeader is case-insensitive, thankfully { foreach(const QString& kv, cookie.split("; ")) { int pos = kv.indexOf('='); if (pos == -1) continue; cookies.insert(kv.left(pos), kv.mid(pos + 1)); } } int sessionID; QString sessionCookie = cookies.value(qxt_d().sessionCookieName); qxt_d().sessionLock.lock(); if (qxt_d().sessionKeys.contains(sessionCookie)) { sessionID = qxt_d().sessionKeys[sessionCookie]; if(!sessionID && header.majorVersion() > 0 && qxt_d().autoCreateSession) sessionID = newSession(); } else if (header.majorVersion() > 0 && qxt_d().autoCreateSession) { sessionID = newSession(); } else { sessionID = 0; } QIODevice* device = connector()->getRequestConnection(requestID); QxtHttpSessionManagerPrivate::ConnectionState& state = qxt_d().connectionState[device]; state.sessionID = sessionID; state.httpMajorVersion = header.majorVersion(); state.httpMinorVersion = header.minorVersion(); if (state.httpMajorVersion == 0 || (state.httpMajorVersion == 1 && state.httpMinorVersion == 0) || header.value("connection").toLower() == "close") state.keepAlive = false; else state.keepAlive = true; qxt_d().sessionLock.unlock(); QxtWebRequestEvent* event = new QxtWebRequestEvent(sessionID, requestID, QUrl::fromEncoded(header.path().toUtf8())); qxt_d().eventLock.lock(); qxt_d().pendingRequests.insert(QPair<int,int>(sessionID, requestID), event); qxt_d().eventLock.unlock(); QTcpSocket* socket = qobject_cast<QTcpSocket*>(device); if (socket) { event->remoteAddress = socket->peerAddress(); #if defined(QT_SECURETRANSPORT) || !defined(QT_NO_OPENSSL) QSslSocket* sslSocket = qobject_cast<QSslSocket*>(socket); if(sslSocket) { event->isSecure = true; event->clientCertificate = sslSocket->peerCertificate(); } #endif } event->method = header.method(); event->cookies = cookies; event->url.setScheme("http"); if (event->url.host().isEmpty()) event->url.setHost(header.value("host")); if (event->url.port() == -1) event->url.setPort(port()); event->contentType = header.contentType(); event->content = content; typedef QPair<QString, QString> StringPair; foreach(const StringPair& line, header.values()) { if (line.first.toLower() == "cookie") continue; event->headers.insert(line.first, line.second); } event->headers.insert("X-Request-Protocol", "HTTP/" + QString::number(state.httpMajorVersion) + '.' + QString::number(state.httpMinorVersion)); if (sessionID && session(sessionID)) { QxtAbstractWebService *service = session(sessionID); if(content) content->setParent(service); // Set content ownership to the service service->pageRequestedEvent(event); } else if (qxt_d().staticService) { qxt_d().staticService->pageRequestedEvent(event); } else { postEvent(new QxtWebErrorEvent(0, requestID, 500, "Internal Configuration Error")); } }
void MainMenu::init() { #define ADD_ACTION(name, menu, icon, trName, slot, shortcut) \ action = menu->addAction(icon, trName); \ action->setShortcut(QKeySequence(QSL(shortcut))); \ connect(action, SIGNAL(triggered()), this, slot); \ m_actions[QSL(name)] = action #define ADD_CHECKABLE_ACTION(name, menu, icon, trName, slot, shortcut) \ action = menu->addAction(icon, trName); \ action->setShortcut(QKeySequence(QSL(shortcut))); \ action->setCheckable(true); \ connect(action, SIGNAL(triggered(bool)), this, slot); \ m_actions[QSL(name)] = action // Standard actions - needed on Mac to be placed correctly in "application" menu QAction* action = new QAction(QIcon::fromTheme(QSL("help-about")), tr("&About QupZilla"), this); action->setMenuRole(QAction::AboutRole); connect(action, SIGNAL(triggered()), this, SLOT(showAboutDialog())); m_actions[QSL("Standard/About")] = action; action = new QAction(IconProvider::settingsIcon(), tr("Pr&eferences"), this); action->setMenuRole(QAction::PreferencesRole); action->setShortcut(QKeySequence(QKeySequence::Preferences)); connect(action, SIGNAL(triggered()), this, SLOT(showPreferences())); m_actions[QSL("Standard/Preferences")] = action; action = new QAction(QIcon::fromTheme(QSL("application-exit")), tr("Quit"), this); action->setMenuRole(QAction::QuitRole); // shortcut set from browserwindow connect(action, SIGNAL(triggered()), this, SLOT(quitApplication())); m_actions[QSL("Standard/Quit")] = action; // File menu m_menuFile = new QMenu(tr("&File")); connect(m_menuFile, SIGNAL(aboutToShow()), this, SLOT(aboutToShowFileMenu())); connect(m_menuFile, SIGNAL(aboutToHide()), this, SLOT(aboutToHideFileMenu())); ADD_ACTION("File/NewTab", m_menuFile, IconProvider::newTabIcon(), tr("New Tab"), SLOT(newTab()), "Ctrl+T"); ADD_ACTION("File/NewWindow", m_menuFile, IconProvider::newWindowIcon(), tr("&New Window"), SLOT(newWindow()), "Ctrl+N"); ADD_ACTION("File/NewPrivateWindow", m_menuFile, IconProvider::privateBrowsingIcon(), tr("New &Private Window"), SLOT(newPrivateWindow()), "Ctrl+Shift+P"); ADD_ACTION("File/OpenLocation", m_menuFile, QIcon::fromTheme(QSL("document-open-remote")), tr("Open Location"), SLOT(openLocation()), "Ctrl+L"); ADD_ACTION("File/OpenFile", m_menuFile, QIcon::fromTheme(QSL("document-open")), tr("Open &File..."), SLOT(openFile()), "Ctrl+O"); ADD_ACTION("File/CloseWindow", m_menuFile, QIcon::fromTheme(QSL("window-close")), tr("Close Window"), SLOT(closeWindow()), "Ctrl+Shift+W"); m_menuFile->addSeparator(); if (!mApp->isPrivate()) { action = new QAction(tr("New Session..."), this); connect(action, SIGNAL(triggered()), mApp->sessionManager(), SLOT(newSession())); m_actions[QSL("File/NewSession")] = action; m_menuFile->addAction(action); action = new QAction(tr("Save Session..."), this); connect(action, SIGNAL(triggered()), mApp->sessionManager(), SLOT(saveSession())); m_actions[QSL("File/SaveSession")] = action; m_menuFile->addAction(action); QMenu* sessionsSubmenu = new QMenu(tr("Sessions")); connect(sessionsSubmenu, SIGNAL(aboutToShow()), mApp->sessionManager(), SLOT(aboutToShowSessionsMenu())); m_menuFile->addMenu(sessionsSubmenu); m_menuFile->addSeparator(); } ADD_ACTION("File/SavePageAs", m_menuFile, QIcon::fromTheme(QSL("document-save")), tr("&Save Page As..."), SLOT(savePageAs()), "Ctrl+S"); ADD_ACTION("File/SendLink", m_menuFile, QIcon::fromTheme(QSL("mail-message-new")), tr("Send Link..."), SLOT(sendLink()), ""); ADD_ACTION("File/Print", m_menuFile, QIcon::fromTheme(QSL("document-print")), tr("&Print..."), SLOT(printPage()), "Ctrl+P"); m_menuFile->addSeparator(); m_menuFile->addAction(m_actions[QSL("Standard/Quit")]); // Edit menu m_menuEdit = new QMenu(tr("&Edit")); connect(m_menuEdit, SIGNAL(aboutToShow()), this, SLOT(aboutToShowEditMenu())); connect(m_menuEdit, SIGNAL(aboutToHide()), this, SLOT(aboutToHideEditMenu())); ADD_ACTION("Edit/Undo", m_menuEdit, QIcon::fromTheme(QSL("edit-undo")), tr("&Undo"), SLOT(editUndo()), "Ctrl+Z"); ADD_ACTION("Edit/Redo", m_menuEdit, QIcon::fromTheme(QSL("edit-redo")), tr("&Redo"), SLOT(editRedo()), "Ctrl+Shift+Z"); m_menuEdit->addSeparator(); ADD_ACTION("Edit/Cut", m_menuEdit, QIcon::fromTheme(QSL("edit-cut")), tr("&Cut"), SLOT(editCut()), "Ctrl+X"); ADD_ACTION("Edit/Copy", m_menuEdit, QIcon::fromTheme(QSL("edit-copy")), tr("C&opy"), SLOT(editCopy()), "Ctrl+C"); ADD_ACTION("Edit/Paste", m_menuEdit, QIcon::fromTheme(QSL("edit-paste")), tr("&Paste"), SLOT(editPaste()), "Ctrl+V"); m_menuEdit->addSeparator(); ADD_ACTION("Edit/SelectAll", m_menuEdit, QIcon::fromTheme(QSL("edit-select-all")), tr("Select &All"), SLOT(editSelectAll()), "Ctrl+A"); ADD_ACTION("Edit/Find", m_menuEdit, QIcon::fromTheme(QSL("edit-find")), tr("&Find"), SLOT(editFind()), "Ctrl+F"); m_menuEdit->addSeparator(); // View menu m_menuView = new QMenu(tr("&View")); connect(m_menuView, SIGNAL(aboutToShow()), this, SLOT(aboutToShowViewMenu())); connect(m_menuView, SIGNAL(aboutToHide()), this, SLOT(aboutToHideViewMenu())); QMenu* toolbarsMenu = new QMenu(tr("Toolbars")); connect(toolbarsMenu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowToolbarsMenu())); QMenu* sidebarMenu = new QMenu(tr("Sidebar")); connect(sidebarMenu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowSidebarsMenu())); QMenu* encodingMenu = new QMenu(tr("Character &Encoding")); connect(encodingMenu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowEncodingMenu())); // Create menus to make shortcuts available even before first showing the menu m_window->createToolbarsMenu(toolbarsMenu); m_window->createSidebarsMenu(sidebarMenu); m_menuView->addMenu(toolbarsMenu); m_menuView->addMenu(sidebarMenu); ADD_CHECKABLE_ACTION("View/ShowStatusBar", m_menuView, QIcon(), tr("Sta&tus Bar"), SLOT(showStatusBar()), ""); m_menuView->addSeparator(); ADD_ACTION("View/Stop", m_menuView, QIcon::fromTheme(QSL("process-stop")), tr("&Stop"), SLOT(stop()), "Esc"); ADD_ACTION("View/Reload", m_menuView, QIcon::fromTheme(QSL("view-refresh")), tr("&Reload"), SLOT(reload()), "F5"); m_menuView->addSeparator(); ADD_ACTION("View/ZoomIn", m_menuView, QIcon::fromTheme(QSL("zoom-in")), tr("Zoom &In"), SLOT(zoomIn()), "Ctrl++"); ADD_ACTION("View/ZoomOut", m_menuView, QIcon::fromTheme(QSL("zoom-out")), tr("Zoom &Out"), SLOT(zoomOut()), "Ctrl+-"); ADD_ACTION("View/ZoomReset", m_menuView, QIcon::fromTheme(QSL("zoom-original")), tr("Reset"), SLOT(zoomReset()), "Ctrl+0"); m_menuView->addSeparator(); m_menuView->addMenu(encodingMenu); m_menuView->addSeparator(); ADD_ACTION("View/PageSource", m_menuView, QIcon::fromTheme(QSL("text-html")), tr("&Page Source"), SLOT(showPageSource()), "Ctrl+U"); ADD_CHECKABLE_ACTION("View/FullScreen", m_menuView, QIcon(), tr("&FullScreen"), SLOT(showFullScreen()), "F11"); // Tools menu m_menuTools = new QMenu(tr("&Tools")); connect(m_menuTools, SIGNAL(aboutToShow()), this, SLOT(aboutToShowToolsMenu())); connect(m_menuTools, SIGNAL(aboutToHide()), this, SLOT(aboutToHideToolsMenu())); ADD_ACTION("Tools/WebSearch", m_menuTools, QIcon(), tr("&Web Search"), SLOT(webSearch()), "Ctrl+K"); ADD_ACTION("Tools/SiteInfo", m_menuTools, QIcon::fromTheme(QSL("dialog-information")), tr("Site &Info"), SLOT(showSiteInfo()), "Ctrl+I"); m_menuTools->addSeparator(); ADD_ACTION("Tools/DownloadManager", m_menuTools, QIcon(), tr("&Download Manager"), SLOT(showDownloadManager()), "Ctrl+Y"); ADD_ACTION("Tools/CookiesManager", m_menuTools, QIcon(), tr("&Cookies Manager"), SLOT(showCookieManager()), ""); ADD_ACTION("Tools/AdBlock", m_menuTools, QIcon(), tr("&AdBlock"), SLOT(showAdBlockDialog()), ""); ADD_ACTION("Tools/WebInspector", m_menuTools, QIcon(), tr("Web In&spector"), SLOT(toggleWebInspector()), "Ctrl+Shift+I"); ADD_ACTION("Tools/ClearRecentHistory", m_menuTools, QIcon::fromTheme(QSL("edit-clear")), tr("Clear Recent &History"), SLOT(showClearRecentHistoryDialog()), "Ctrl+Shift+Del"); if (!WebInspector::isEnabled()) m_actions.value(QSL("Tools/WebInspector"))->setVisible(false); m_submenuExtensions = new QMenu(tr("&Extensions")); m_submenuExtensions->menuAction()->setVisible(false); m_menuTools->addMenu(m_submenuExtensions); m_menuTools->addSeparator(); // Help menu m_menuHelp = new QMenu(tr("&Help")); #ifndef Q_OS_MACOS ADD_ACTION("Help/AboutQt", m_menuHelp, QIcon(), tr("About &Qt"), SLOT(aboutQt()), ""); m_menuHelp->addAction(m_actions[QSL("Standard/About")]); m_menuHelp->addSeparator(); #endif ADD_ACTION("Help/InfoAboutApp", m_menuHelp, QIcon::fromTheme(QSL("help-contents")), tr("Information about application"), SLOT(showInfoAboutApp()), ""); ADD_ACTION("Help/ConfigInfo", m_menuHelp, QIcon(), tr("Configuration Information"), SLOT(showConfigInfo()), ""); ADD_ACTION("Help/ReportIssue", m_menuHelp, QIcon(), tr("Report &Issue"), SLOT(reportIssue()), ""); m_actions[QSL("Help/InfoAboutApp")]->setShortcut(QKeySequence(QKeySequence::HelpContents)); // History menu m_menuHistory = new HistoryMenu(); m_menuHistory->setMainWindow(m_window); // Bookmarks menu m_menuBookmarks = new BookmarksMenu(); m_menuBookmarks->setMainWindow(m_window); // Other actions action = new QAction(QIcon::fromTheme(QSL("user-trash")), tr("Restore &Closed Tab"), this); action->setShortcut(QKeySequence(QSL("Ctrl+Shift+T"))); connect(action, SIGNAL(triggered()), this, SLOT(restoreClosedTab())); m_actions[QSL("Other/RestoreClosedTab")] = action; #ifdef Q_OS_MACOS m_actions[QSL("View/FullScreen")]->setShortcut(QKeySequence(QSL("Ctrl+Meta+F"))); // Add standard actions to File Menu (as it won't be ever cleared) and Mac menubar should move them to "Application" menu m_menuFile->addAction(m_actions[QSL("Standard/About")]); m_menuFile->addAction(m_actions[QSL("Standard/Preferences")]); // Prevent ConfigInfo action to be detected as "Preferences..." action in Mac menubar m_actions[QSL("Help/ConfigInfo")]->setMenuRole(QAction::NoRole); // Create Dock menu QMenu* dockMenu = new QMenu(0); dockMenu->addAction(m_actions[QSL("File/NewTab")]); dockMenu->addAction(m_actions[QSL("File/NewWindow")]); dockMenu->addAction(m_actions[QSL("File/NewPrivateWindow")]); qt_mac_set_dock_menu(dockMenu); #endif #if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS) m_menuEdit->addAction(m_actions[QSL("Standard/Preferences")]); #elif !defined(Q_OS_MACOS) m_menuTools->addAction(m_actions[QSL("Standard/Preferences")]); #endif // Menus are hidden by default aboutToHideFileMenu(); aboutToHideViewMenu(); aboutToHideEditMenu(); aboutToHideToolsMenu(); addActionsToWindow(); }
void SessionManager::updateList(const QString& selected) { m_sessions_menu->clear(); m_sessions_list->clear(); QStringList files = QDir(Session::path(), "*.session").entryList(QDir::Files, QDir::Name | QDir::IgnoreCase); files.prepend(Session::tr("Default")); for (int i = 0; i < files.count(); ++i) { QString name = Session::pathToName(files.at(i)); if ((name == Session::tr("Default")) && (i > 0)) { continue; } QAction* action = m_sessions_menu->addAction(name); action->setData(name); action->setCheckable(true); m_sessions_actions->addAction(action); QListWidgetItem* item = new QListWidgetItem(QIcon::fromTheme("folder"), name, m_sessions_list); item->setData(Qt::UserRole, name); if (name == m_session->name()) { action->setChecked(true); item->setIcon(QIcon::fromTheme("folder-open")); } if (name == selected) { m_sessions_list->setCurrentItem(item); m_sessions_list->scrollToItem(item); } } m_sessions_menu->addSeparator(); m_sessions_menu->addAction(QIcon::fromTheme("window-new"), tr("&New..."), this, SLOT(newSession()), tr("Ctrl+Shift+N")); m_sessions_menu->addAction(QIcon::fromTheme("view-choose"), tr("&Manage..."), this, SLOT(exec()), tr("Ctrl+Shift+M")); }