void GoForKick:: Play() { if (1) //ball1.center.y>360 { std::string g = "State == GoForKick y="; stringstream p; p << (int) ball1.center.y; g += p.str(); writeToLog(logFile, g); if (ball1.x_ball_spot > 3 && ball1.x_ball_spot < 7) { GoTo(0, StateList[State].stateString, ball1.x_ball_spot); //forward writeToLog(logFile, "GoForKick forward"); } else if (ball1.x_ball_spot < 4) { GoTo(6, StateList[State].stateString, ball1.x_ball_spot); //right writeToLog(logFile, "GoForKick right"); } else if (ball1.x_ball_spot > 6) { GoTo(-6, StateList[State].stateString, ball1.x_ball_spot); //left writeToLog(logFile, "GoForKick left"); } sleep(4); GoTo(0, StateList[State].stateString, ball1.x_ball_spot); // if (ball1.center.y<420) // sleep(15); // sleep(11) sleep(20); GoStop(); writeToLog(logFile, "Kick"); Action::GetInstance()->Start(4); while (Action::GetInstance()->IsRunning()) usleep(8 * 1000); } State = GoToBall; }
MainUI::MainUI(bool debugmode) : QMainWindow(){ //Setup UI DEBUG = debugmode; AUTHCOMPLETE = false; //not performed yet this->setWindowTitle(tr("AppCafe")); //Need 1024 wide if possible this->resize(1024,600); this->setWindowIcon( QIcon(":icons/appcafe.png") ); if(this->centralWidget()==0){ this->setCentralWidget( new QWidget(this) ); } this->centralWidget()->setLayout( new QVBoxLayout() ); this->centralWidget()->layout()->setContentsMargins(0,0,0,0); this->setStatusBar(new QStatusBar()); //Setup the ToolBar QToolBar *tb = this->addToolBar(""); tb->setMovable(false); tb->setFloatable(false); tb->setContextMenuPolicy(Qt::CustomContextMenu); //disable the built-in visibility context menu backA = tb->addAction(QIcon(":icons/back.png"), tr("Back"), this, SLOT(GoBack()) ); forA = tb->addAction(QIcon(":icons/forward.png"), tr("Forward"), this, SLOT(GoForward()) ); refA = tb->addAction(QIcon(":icons/refresh.png"), tr("Refresh"), this, SLOT(GoRefresh()) ); stopA = tb->addAction(QIcon(":icons/stop.png"), tr("Stop"), this, SLOT(GoStop()) ); // - toolbar spacer QWidget *spacer = new QWidget(this); spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); tb->addWidget(spacer); // - Progress bar progressBar = new QProgressBar(this); progressBar->setRange(0,100); progA = tb->addWidget(progressBar); //add it to the end of the toolbar progA->setVisible(false); //start off invisible // - List Button listB = new QToolButton(this); listB->setIcon( QIcon(":icons/list.png") ); listB->setToolTip( tr("AppCafe Options") ); listB->setStyleSheet( "QToolButton::menu-indicator{ image: none; }" ); listB->setPopupMode(QToolButton::InstantPopup); tb->addWidget(listB); //Setup the menu for this button listMenu = new QMenu(); listMenu->addAction(QIcon(":icons/configure.png"), tr("Configure"), this, SLOT(GoConfigure() ) ); listMenu->addAction(QIcon(":icons/list.png"), tr("Save Pkg List"), this, SLOT(Save_pkglist() ) ); listMenu->addSeparator(); listMenu->addAction(QIcon(":icons/search.png"), tr("Search For Text"), this, SLOT(openSearch() ) ); listMenu->addSeparator(); listMenu->addAction(QIcon(":icons/close.png"), tr("Close AppCafe"), this, SLOT(GoClose() ) ); listB->setMenu(listMenu); //Setup the search options group_search = new QFrame(this); group_search->setLayout( new QHBoxLayout() ); group_search->layout()->setContentsMargins(2,2,2,2); line_search = new QLineEdit(this); group_search->layout()->addWidget(line_search); tool_search = new QToolButton(this); group_search->layout()->addWidget(tool_search); tool_search->setIcon( QIcon(":icons/search.png") ); group_search->layout()->addItem(new QSpacerItem(0,0,QSizePolicy::Expanding, QSizePolicy::Minimum) ); //Setup the Main Interface webview = new QWebView(this); this->centralWidget()->layout()->addWidget(webview); if(webview->page()==0){ webview->setPage(new QWebPage(webview)); } webview->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks); this->centralWidget()->layout()->addWidget(group_search); //Make sure the search bar is hidden to start with group_search->setVisible(false); //Create the special keyboard shortcuts QKeySequence key(QKeySequence::Find); ctrlF = new QShortcut( key, this ); key = QKeySequence(Qt::Key_Escape); esc = new QShortcut( key, this ); //Connect signals/slots connect(webview, SIGNAL(linkClicked(const QUrl&)), this, SLOT(LinkClicked(const QUrl&)) ); connect(webview, SIGNAL(loadStarted()), this, SLOT(PageStartLoading()) ); connect(webview, SIGNAL(loadProgress(int)), this, SLOT(PageLoadProgress(int)) ); connect(webview, SIGNAL(loadFinished(bool)), this, SLOT(PageDoneLoading(bool)) ); connect(webview->page()->networkAccessManager(), SIGNAL(sslErrors(QNetworkReply*, const QList<QSslError>&)), this, SLOT( authenticate(QNetworkReply*) ) ); connect(tool_search, SIGNAL(clicked()), this, SLOT(GoSearch()) ); connect(line_search, SIGNAL(returnPressed()), this, SLOT(GoSearch()) ); connect(ctrlF, SIGNAL(activated()), this, SLOT(openSearch()) ); connect(esc, SIGNAL(activated()), this, SLOT(closeSearch()) ); if(DEBUG){ //connect(webview, SIGNAL(statusBarMessage(const QString&)), this, SLOT(StatusTextChanged(const QString&)) ); connect(webview->page(), SIGNAL(linkHovered(const QString&, const QString&, const QString&)), this, SLOT(StatusTextChanged(const QString&)) ); } this->statusBar()->setVisible(DEBUG); loadHomePage(); webview->show(); }
MainUI::MainUI(bool debugmode, QString fileURL, QString title, QString iconpath) : QMainWindow(){ //Setup UI DEBUG = debugmode; baseURL = fileURL; AUTHCOMPLETE = false; //not performed yet if(title.isEmpty()){ if(baseURL.contains("://")){ this->setWindowTitle(baseURL); }else{ this->setWindowTitle(baseURL.section("/",-1)); } }else{ this->setWindowTitle(title); } this->resize(1024,600); //Check the given icon QIcon ico; if(!iconpath.isEmpty()){ //qDebug() << "Checking icon:" << iconpath; if(iconpath.startsWith("/") && QFile::exists(iconpath)){ico = QIcon(iconpath); } else if( QFile::exists("/usr/local/share/pixmaps/"+iconpath)){ ico = QIcon("/usr/local/share/pixmaps/"+iconpath); } else if( QFile::exists("/usr/local/share/pixmaps/"+iconpath+".png")){ ico = QIcon("/usr/local/share/pixmaps/"+iconpath+".png"); } else{ ico = QIcon::fromTheme(iconpath); } } if(ico.isNull()){ico = QIcon(":icons/webview.png"); } this->setWindowIcon( ico); if(this->centralWidget()==0){ this->setCentralWidget( new QWidget(this) ); } this->centralWidget()->setLayout( new QVBoxLayout() ); this->centralWidget()->layout()->setContentsMargins(0,0,0,0); this->setStatusBar(new QStatusBar()); //Setup the ToolBar QToolBar *tb = this->addToolBar(""); tb->setMovable(false); tb->setFloatable(false); backA = tb->addAction(QIcon(":icons/back.png"), tr("Back"), this, SLOT(GoBack()) ); forA = tb->addAction(QIcon(":icons/forward.png"), tr("Forward"), this, SLOT(GoForward()) ); refA = tb->addAction(QIcon(":icons/refresh.png"), tr("Refresh"), this, SLOT(GoRefresh()) ); stopA = tb->addAction(QIcon(":icons/stop.png"), tr("Stop"), this, SLOT(GoStop()) ); // - toolbar spacer QWidget *spacer = new QWidget(this); spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); tb->addWidget(spacer); // - Progress bar progressBar = new QProgressBar(this); progressBar->setRange(0,100); progA = tb->addWidget(progressBar); //add it to the end of the toolbar progA->setVisible(false); //start off invisible //Setup the search options group_search = new QFrame(this); group_search->setLayout( new QHBoxLayout() ); group_search->layout()->setContentsMargins(2,2,2,2); line_search = new QLineEdit(this); group_search->layout()->addWidget(line_search); tool_search = new QToolButton(this); group_search->layout()->addWidget(tool_search); tool_search->setIcon( QIcon(":icons/search.png") ); group_search->layout()->addItem(new QSpacerItem(0,0,QSizePolicy::Expanding, QSizePolicy::Minimum) ); //Setup the Main Interface webview = new QWebView(this); this->centralWidget()->layout()->addWidget(webview); if(webview->page()==0){ webview->setPage(new QWebPage(webview)); } webview->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks); this->centralWidget()->layout()->addWidget(group_search); //Make sure the search bar is hidden to start with group_search->setVisible(false); //Create the special keyboard shortcuts QKeySequence key(QKeySequence::Find); ctrlF = new QShortcut( key, this ); key = QKeySequence(Qt::Key_Escape); esc = new QShortcut( key, this ); //Connect signals/slots connect(webview, SIGNAL(linkClicked(const QUrl&)), this, SLOT(LinkClicked(const QUrl&)) ); connect(webview, SIGNAL(urlChanged(const QUrl&)), this, SLOT(LinkClicked(const QUrl&)) ); connect(webview, SIGNAL(loadStarted()), this, SLOT(PageStartLoading()) ); connect(webview, SIGNAL(loadProgress(int)), this, SLOT(PageLoadProgress(int)) ); connect(webview, SIGNAL(loadFinished(bool)), this, SLOT(PageDoneLoading(bool)) ); connect(webview->page()->networkAccessManager(), SIGNAL(sslErrors(QNetworkReply*, const QList<QSslError>&)), this, SLOT( authenticate(QNetworkReply*) ) ); connect(tool_search, SIGNAL(clicked()), this, SLOT(GoSearch()) ); connect(line_search, SIGNAL(returnPressed()), this, SLOT(GoSearch()) ); connect(ctrlF, SIGNAL(activated()), this, SLOT(openSearch()) ); connect(esc, SIGNAL(activated()), this, SLOT(closeSearch()) ); if(DEBUG){ //connect(webview, SIGNAL(statusBarMessage(const QString&)), this, SLOT(StatusTextChanged(const QString&)) ); connect(webview->page(), SIGNAL(linkHovered(const QString&, const QString&, const QString&)), this, SLOT(StatusTextChanged(const QString&)) ); } this->statusBar()->setVisible(DEBUG); loadHomePage(); webview->show(); }