MainWindow::MainWindow(const QUrl& url) { QNetworkProxyFactory::setUseSystemConfiguration(true); view = new QWebView(this); connect(view, SIGNAL(linkClicked()), SLOT(updateLocation())); locationEdit = new QLineEdit(this); locationEdit->setText(url.toString()); locationEdit->setSizePolicy(QSizePolicy::Expanding, locationEdit->sizePolicy().verticalPolicy()); connect(locationEdit, SIGNAL(returnPressed()), SLOT(changeLocation())); QToolBar *toolBar = addToolBar(tr("Navigation")); toolBar->addAction(view->pageAction(QWebPage::Back)); toolBar->addAction(view->pageAction(QWebPage::Forward)); toolBar->addAction(view->pageAction(QWebPage::Reload)); toolBar->addAction(view->pageAction(QWebPage::Stop)); toolBar->addWidget(locationEdit); showFullScreen(); setCentralWidget(view); setUnifiedTitleAndToolBarOnMac(true); changeLocation(); }
void MainWindow::buildUI() { #if defined(Q_OS_SYMBIAN) delete urlEdit; #endif delete m_toolBar; m_toolBar = addToolBar("Navigation"); #if defined(Q_OS_SYMBIAN) m_toolBar->setIconSize(QSize(16, 16)); #endif QAction* reloadAction = page()->action(QWebPage::Reload); connect(reloadAction, SIGNAL(triggered()), this, SLOT(changeLocation())); m_toolBar->addAction(page()->action(QWebPage::Back)); m_toolBar->addAction(page()->action(QWebPage::Forward)); m_toolBar->addAction(reloadAction); m_toolBar->addAction(page()->action(QWebPage::Stop)); urlEdit = new LocationEdit(m_toolBar); urlEdit->setSizePolicy(QSizePolicy::Expanding, urlEdit->sizePolicy().verticalPolicy()); connect(urlEdit, SIGNAL(returnPressed()), SLOT(changeLocation())); QCompleter* completer = new QCompleter(m_toolBar); urlEdit->setCompleter(completer); completer->setModel(&urlModel); #if defined(Q_OS_SYMBIAN) addToolBarBreak(); addToolBar("Location")->addWidget(urlEdit); #else m_toolBar->addWidget(urlEdit); #endif connect(page()->mainFrame(), SIGNAL(titleChanged(const QString&)), this, SLOT(setWindowTitle(const QString&))); connect(page()->mainFrame(), SIGNAL(urlChanged(QUrl)), this, SLOT(setAddressUrl(QUrl))); connect(page(), SIGNAL(loadProgress(int)), urlEdit, SLOT(setProgress(int))); connect(page(), SIGNAL(windowCloseRequested()), this, SLOT(close())); // short-cuts page()->action(QWebPage::Back)->setShortcut(QKeySequence::Back); page()->action(QWebPage::Stop)->setShortcut(Qt::Key_Escape); page()->action(QWebPage::Forward)->setShortcut(QKeySequence::Forward); page()->action(QWebPage::Reload)->setShortcut(QKeySequence::Refresh); page()->action(QWebPage::Undo)->setShortcut(QKeySequence::Undo); page()->action(QWebPage::Redo)->setShortcut(QKeySequence::Redo); page()->action(QWebPage::Cut)->setShortcut(QKeySequence::Cut); page()->action(QWebPage::Copy)->setShortcut(QKeySequence::Copy); page()->action(QWebPage::Paste)->setShortcut(QKeySequence::Paste); page()->action(QWebPage::ToggleBold)->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_B)); page()->action(QWebPage::ToggleItalic)->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_I)); page()->action(QWebPage::ToggleUnderline)->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_U)); }
void MainWindow::buildUI() { delete m_toolBar; m_toolBar = addToolBar("Navigation"); QAction* reloadAction = page()->action(QWebPage::Reload); connect(reloadAction, SIGNAL(triggered()), this, SLOT(changeLocation())); m_toolBar->addAction(page()->action(QWebPage::Back)); m_toolBar->addAction(page()->action(QWebPage::Forward)); m_toolBar->addAction(reloadAction); m_toolBar->addAction(page()->action(QWebPage::Stop)); #ifndef QT_NO_INPUTDIALOG urlEdit = new LocationEdit(m_toolBar); urlEdit->setSizePolicy(QSizePolicy::Expanding, urlEdit->sizePolicy().verticalPolicy()); connect(urlEdit, SIGNAL(returnPressed()), SLOT(changeLocation())); QCompleter* completer = new QCompleter(m_toolBar); urlEdit->setCompleter(completer); completer->setModel(&urlModel); m_toolBar->addWidget(urlEdit); connect(page()->mainFrame(), SIGNAL(urlChanged(QUrl)), this, SLOT(setAddressUrl(QUrl))); connect(page(), SIGNAL(loadProgress(int)), urlEdit, SLOT(setProgress(int))); #endif connect(page()->mainFrame(), SIGNAL(loadStarted()), this, SLOT(onLoadStarted())); connect(page()->mainFrame(), SIGNAL(iconChanged()), this, SLOT(onIconChanged())); connect(page()->mainFrame(), SIGNAL(titleChanged(QString)), this, SLOT(onTitleChanged(QString))); connect(page(), SIGNAL(windowCloseRequested()), this, SLOT(close())); #ifndef QT_NO_SHORTCUT // short-cuts page()->action(QWebPage::Back)->setShortcut(QKeySequence::Back); page()->action(QWebPage::Stop)->setShortcut(Qt::Key_Escape); page()->action(QWebPage::Forward)->setShortcut(QKeySequence::Forward); page()->action(QWebPage::Reload)->setShortcut(QKeySequence::Refresh); #ifndef QT_NO_UNDOSTACK page()->action(QWebPage::Undo)->setShortcut(QKeySequence::Undo); page()->action(QWebPage::Redo)->setShortcut(QKeySequence::Redo); #endif page()->action(QWebPage::Cut)->setShortcut(QKeySequence::Cut); page()->action(QWebPage::Copy)->setShortcut(QKeySequence::Copy); page()->action(QWebPage::Paste)->setShortcut(QKeySequence::Paste); page()->action(QWebPage::SelectAll)->setShortcut(QKeySequence::SelectAll); page()->action(QWebPage::ToggleBold)->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_B)); page()->action(QWebPage::ToggleItalic)->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_I)); page()->action(QWebPage::ToggleUnderline)->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_U)); #endif }
void Parallaction::runGameFrame(int event) { if (_input->_inputMode != Input::kInputModeGame) { return; } if (!processGameEvent(event)) { return; } _gfx->beginFrame(); runPendingZones(); if (shouldQuit()) return; if (_engineFlags & kEngineChangeLocation) { changeLocation(); } _programExec->runScripts(_location._programs.begin(), _location._programs.end()); _char._ani->resetZ(); updateWalkers(); updateZones(); }
void WebTab::searchOnline() { QString search = "http://www.google.com/search?as_q=" + m_findEdit->text(); setLocation(search); changeLocation(); m_find->hide(); m_view->setFocus(); }
MainWindow::MainWindow() { progress = 0; QNetworkProxyFactory::setUseSystemConfiguration(true); view = new WebView(this); view->load(QUrl("http://www.sina.com.cn/")); connect(view, SIGNAL(loadFinished(bool)), SLOT(adjustLocation())); connect(view, SIGNAL(titleChanged(QString)), SLOT(adjustTitle())); connect(view, SIGNAL(loadProgress(int)), SLOT(setProgress(int))); connect(view, SIGNAL(loadFinished(bool)), SLOT(finishLoading(bool))); locationEdit = new QLineEdit(this); locationEdit->setSizePolicy(QSizePolicy::Expanding, locationEdit->sizePolicy().verticalPolicy()); connect(locationEdit, SIGNAL(returnPressed()), SLOT(changeLocation())); QToolBar *toolBar = addToolBar(tr("Navigation")); toolBar->addAction(view->pageAction(QWebPage::Back)); toolBar->addAction(view->pageAction(QWebPage::Forward)); toolBar->addAction(view->pageAction(QWebPage::Reload)); toolBar->addAction(view->pageAction(QWebPage::Stop)); toolBar->addWidget(locationEdit); setCentralWidget(view); setUnifiedTitleAndToolBarOnMac(true); setContextMenuPolicy(Qt::NoContextMenu); }
//! [Window constructor] Window::Window(QWidget *parent) : QMainWindow(parent) { setupUi(this); connect(webView, SIGNAL(loadFinished(bool)), SLOT(adjustLocation())); connect(addressLine, SIGNAL(returnPressed()), SLOT(changeLocation())); }
MainWindow::MainWindow(const QUrl& url) { progress = 0; QFile file; file.setFileName(":/jquery.min.js"); file.open(QIODevice::ReadOnly); jQuery = file.readAll(); file.close(); //! [1] QNetworkProxyFactory::setUseSystemConfiguration(true); //! [2] view = new QWebView(this); view->load(url); connect(view, SIGNAL(loadFinished(bool)), SLOT(adjustLocation())); connect(view, SIGNAL(titleChanged(QString)), SLOT(adjustTitle())); connect(view, SIGNAL(loadProgress(int)), SLOT(setProgress(int))); connect(view, SIGNAL(loadFinished(bool)), SLOT(finishLoading(bool))); locationEdit = new QLineEdit(this); locationEdit->setSizePolicy(QSizePolicy::Expanding, locationEdit->sizePolicy().verticalPolicy()); connect(locationEdit, SIGNAL(returnPressed()), SLOT(changeLocation())); QToolBar *toolBar = addToolBar(tr("Navigation")); toolBar->addAction(view->pageAction(QWebPage::Back)); toolBar->addAction(view->pageAction(QWebPage::Forward)); toolBar->addAction(view->pageAction(QWebPage::Reload)); toolBar->addAction(view->pageAction(QWebPage::Stop)); toolBar->addWidget(locationEdit); //! [2] QMenu *viewMenu = menuBar()->addMenu(tr("&View")); QAction* viewSourceAction = new QAction("Page Source", this); connect(viewSourceAction, SIGNAL(triggered()), SLOT(viewSource())); viewMenu->addAction(viewSourceAction); //! [3] QMenu *effectMenu = menuBar()->addMenu(tr("&Effect")); effectMenu->addAction("Highlight all links", this, SLOT(highlightAllLinks())); rotateAction = new QAction(this); rotateAction->setIcon(style()->standardIcon(QStyle::SP_FileDialogDetailedView)); rotateAction->setCheckable(true); rotateAction->setText(tr("Turn images upside down")); connect(rotateAction, SIGNAL(toggled(bool)), this, SLOT(rotateImages(bool))); effectMenu->addAction(rotateAction); QMenu *toolsMenu = menuBar()->addMenu(tr("&Tools")); toolsMenu->addAction(tr("Remove GIF images"), this, SLOT(removeGifImages())); toolsMenu->addAction(tr("Remove all inline frames"), this, SLOT(removeInlineFrames())); toolsMenu->addAction(tr("Remove all object elements"), this, SLOT(removeObjectElements())); toolsMenu->addAction(tr("Remove all embedded elements"), this, SLOT(removeEmbeddedElements())); setCentralWidget(view); setUnifiedTitleAndToolBarOnMac(true); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); progress = 0; view = new QWebView(this); setCentralWidget(view); resize(800, 600); // 关联信号和槽 connect(view, SIGNAL(loadProgress(int)), this, SLOT(setProgress(int))); connect(view, SIGNAL(titleChanged(QString)), this, SLOT(adjustTitle())); connect(view, SIGNAL(loadFinished(bool)), this, SLOT(finishLoading(bool))); locationEdit = new QLineEdit(this); connect(locationEdit, SIGNAL(returnPressed()), this, SLOT(changeLocation())); // 向工具栏添加动作和部件 ui->mainToolBar->addAction(view->pageAction(QWebPage::Back)); ui->mainToolBar->addAction(view->pageAction(QWebPage::Forward)); ui->mainToolBar->addAction(view->pageAction(QWebPage::Reload)); ui->mainToolBar->addAction(view->pageAction(QWebPage::Stop)); // 添加历史动作 ui->mainToolBar->addAction(tr("历史"), this, SLOT(showHistory())); ui->mainToolBar->addWidget(locationEdit); // 设置并加载初始网页地址 locationEdit->setText("http://www.baidu.com"); view->load(QUrl("http://www.baidu.com")); // 必须先设置图标数据库路径 view->settings()->setIconDatabasePath("./"); connect(view, SIGNAL(iconChanged()), this, SLOT(changeIcon())); historyList = new QListWidget; historyList->setWindowTitle(tr("历史记录")); historyList->setMinimumWidth(300); connect(historyList, SIGNAL(clicked(QModelIndex)), this, SLOT(gotoHistory(QModelIndex))); }
WebKitBrowser::WebKitBrowser(LiteApi::IApplication *app, QWidget *parent) : QWidget(parent), m_liteApp(app) { QNetworkProxyFactory::setUseSystemConfiguration(true); m_view = new QWebView; m_view->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks); m_locationEdit = new QLineEdit(this); m_locationEdit->setSizePolicy(QSizePolicy::Expanding, m_locationEdit->sizePolicy().verticalPolicy()); connect(m_locationEdit, SIGNAL(returnPressed()), this,SLOT(changeLocation())); connect(m_view, SIGNAL(loadFinished(bool)), this, SLOT(loadFinished(bool))); connect(m_view, SIGNAL(linkClicked(QUrl)),this, SLOT(linkClicked(QUrl))); connect(m_view->page(), SIGNAL(linkHovered(QString,QString,QString)),this,SLOT(linkHovered(QString,QString,QString))); connect(m_view,SIGNAL(statusBarMessage(QString)),this,SLOT(statusBarMessage(QString))); connect(m_view,SIGNAL(loadStarted()),this,SLOT(loadStarted())); connect(m_view,SIGNAL(loadProgress(int)),this,SLOT(loadProgress(int))); QToolBar *toolBar = new QToolBar(tr("Navigation")); toolBar->setIconSize(QSize(16,16)); toolBar->addAction(m_view->pageAction(QWebPage::Back)); toolBar->addAction(m_view->pageAction(QWebPage::Forward)); toolBar->addAction(m_view->pageAction(QWebPage::Reload)); toolBar->addAction(m_view->pageAction(QWebPage::Stop)); toolBar->addWidget(m_locationEdit); m_progressBar = new QProgressBar; m_progressBar->hide(); m_progressBar->setRange(0,100); QVBoxLayout *layout = new QVBoxLayout; layout->setMargin(0); layout->setSpacing(0); layout->addWidget(toolBar); layout->addWidget(m_view); layout->addWidget(m_progressBar); this->setLayout(layout); }
/** * Class constructor. * @param pParent The parent widget */ WebTab::WebTab(QWidget* pParent) : QGroupBox(pParent) , m_search_type(SCUT_SEARCH_PAGE) { m_tool = new QToolBar(); m_view = new ScutView(); connect(m_view, SIGNAL(titleChanged(QString)), SLOT(adjustTitle())); QVBoxLayout *layout = new QVBoxLayout(); // TODO: CREATE SCUT EDIT SO WE CAN FWD CTRL-F and so on to the mainwindow... m_locationEdit = new QLineEdit(this); m_locationEdit->setSizePolicy(QSizePolicy::Expanding, m_locationEdit->sizePolicy().verticalPolicy()); connect(m_locationEdit, SIGNAL(returnPressed()), SLOT(changeLocation())); m_tool->addAction(m_view->pageAction(QWebPage::Back)); m_tool->addAction(m_view->pageAction(QWebPage::Forward)); m_tool->addAction(m_view->pageAction(QWebPage::Reload)); m_tool->addAction(m_view->pageAction(QWebPage::Stop)); m_tool->addWidget(m_locationEdit); m_find = new QToolBar(); m_findEdit = new QLineEdit(this); m_findEdit->setSizePolicy(QSizePolicy::Expanding, m_findEdit->sizePolicy().verticalPolicy()); m_find->addWidget(m_findEdit); QIcon closeIcon = QIcon::fromTheme("window-close"); QAction *closeAct = new QAction(closeIcon, "", this); m_find->addAction(closeAct); connect(m_findEdit, SIGNAL(returnPressed()), SLOT(startSearch())); connect(m_view, SIGNAL(loadFinished(bool)), SLOT(adjustLocation())); connect(closeAct, SIGNAL(triggered()), SLOT(hideSearchBar())); m_find->hide(); setLayout(layout); layout->addWidget(m_tool); layout->addWidget(m_view); layout->addWidget(m_find); }
MainWindow::MainWindow( ) { m_progress = 0; QNetworkProxyFactory::setUseSystemConfiguration(true); m_view = new QWebView(this); // m_view-> setPage( new CustomWebPage(this)); connect(m_view, SIGNAL(loadFinished(bool)), SLOT(adjustLocation())); connect(m_view, SIGNAL(titleChanged(QString)), SLOT(adjustTitle())); connect(m_view, SIGNAL(loadProgress(int)), SLOT(setProgress(int))); connect(m_view, SIGNAL(loadFinished(bool)), SLOT(finishLoading(bool))); m_locationEdit = new QLineEdit(this); m_locationEdit->setSizePolicy(QSizePolicy::Expanding, m_locationEdit->sizePolicy().verticalPolicy()); connect(m_locationEdit, SIGNAL(returnPressed()), SLOT(changeLocation())); QToolBar *toolBar = addToolBar(tr("Navigation")); toolBar->addAction(m_view->pageAction(QWebPage::Back)); toolBar->addAction(m_view->pageAction(QWebPage::Forward)); toolBar->addAction(m_view->pageAction(QWebPage::Reload)); toolBar->addAction(QIcon("://icons/inspector.png"), "Inspector", this, SLOT(showJsConsole())); toolBar->addWidget(m_locationEdit); m_inspector = new QWebInspector( nullptr); m_inspector-> setPage( m_view-> page()); m_inspector-> resize( 800, 600); QMenu *toolsMenu = menuBar()->addMenu(tr("&Tools")); toolsMenu->addAction(tr("Show JS Console"), this, SLOT(showJsConsole())); setCentralWidget(m_view); setUnifiedTitleAndToolBarOnMac(true); connect( m_view->page()->mainFrame(), & QWebFrame::javaScriptWindowObjectCleared, this, & MainWindow::addToJavaScript ); }
PageScreen::PageScreen(WebView* view, QWidget* parent) : QDialog(parent) , ui(new Ui::PageScreen) , m_view(view) , m_imageScaling(0) { setAttribute(Qt::WA_DeleteOnClose); ui->setupUi(this); m_formats[0] = QLatin1String("PNG"); m_formats[1] = QLatin1String("BMP"); m_formats[2] = QLatin1String("JPG"); m_formats[3] = QLatin1String("PPM"); m_formats[4] = QLatin1String("TIFF"); m_formats[5] = QLatin1String("PDF"); QHashIterator<int, QString> i(m_formats); while (i.hasNext()) { i.next(); ui->formats->addItem(tr("Save as %1").arg(i.value())); } // Set png as a default format m_pageTitle = m_view->title(); ui->location->setText(QString("%1/%2.png").arg(QDir::homePath(), QzTools::filterCharsFromFilename(m_pageTitle))); QMovie* mov = new QMovie(":html/loading.gif"); ui->label->setMovie(mov); mov->start(); connect(ui->changeLocation, SIGNAL(clicked()), this, SLOT(changeLocation())); connect(ui->formats, SIGNAL(currentIndexChanged(int)), this, SLOT(formatChanged())); connect(ui->buttonBox->button(QDialogButtonBox::Save), SIGNAL(clicked()), this, SLOT(dialogAccepted())); connect(ui->buttonBox->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), this, SLOT(close())); QTimer::singleShot(200, this, SLOT(createThumbnail())); }
MainWindow::MainWindow(const QUrl& url) { progress = 0; QFile file; file.setFileName(":/jquery.min.js"); file.open(QIODevice::ReadOnly); jQuery = file.readAll(); jQuery.append("\nvar qt = { 'jQuery': jQuery.noConflict(true) };"); file.close(); //! [1] QNetworkProxyFactory::setUseSystemConfiguration(true); //! [2] view = new QWebView(this); view->load(url); connect(view, SIGNAL(loadFinished(bool)), SLOT(adjustLocation())); connect(view, SIGNAL(titleChanged(QString)), SLOT(adjustTitle())); connect(view, SIGNAL(loadProgress(int)), SLOT(setProgress(int))); connect(view, SIGNAL(loadFinished(bool)), SLOT(finishLoading(bool))); locationEdit = new QLineEdit(this); locationEdit->setSizePolicy(QSizePolicy::Expanding, locationEdit->sizePolicy().verticalPolicy()); connect(locationEdit, SIGNAL(returnPressed()), SLOT(changeLocation())); QToolBar *toolBar = addToolBar(tr("导航")); toolBar->addAction(view->pageAction(QWebPage::Back)); toolBar->addAction(view->pageAction(QWebPage::Forward)); toolBar->addAction(view->pageAction(QWebPage::Reload)); toolBar->addAction(view->pageAction(QWebPage::Stop)); toolBar->addWidget(locationEdit); //! [2] QMenu *fileMenu = menuBar()->addMenu(tr("文件(&F)")); QAction *newWindowAction = new QAction(tr("新建窗口"),this); connect(newWindowAction, SIGNAL(triggered()),SLOT(newWindow())); fileMenu->addAction(newWindowAction); QAction *closeWindowAction = new QAction(tr("关闭窗口"),this); connect(closeWindowAction, SIGNAL(triggered()),SLOT(closeWindow())); fileMenu->addAction(closeWindowAction); QMenu *viewMenu = menuBar()->addMenu(tr("查看(&V)")); QAction* viewSourceAction = new QAction(tr("页面源代码"), this); connect(viewSourceAction, SIGNAL(triggered()), SLOT(viewSource())); viewMenu->addAction(view->pageAction(QWebPage::Stop)); viewMenu->addAction(view->pageAction(QWebPage::Reload)); viewMenu->addSeparator(); viewMenu->addAction(viewSourceAction); //! [3] QMenu *historyMenu = menuBar()->addMenu(tr("历史(&H)")); historyMenu->addAction(view->pageAction(QWebPage::Back)); historyMenu->addAction(view->pageAction(QWebPage::Forward)); QMenu *effectMenu = menuBar()->addMenu(tr("效果(&E)")); effectMenu->addAction(tr("高亮所有链接"), this, SLOT(highlightAllLinks())); rotateAction = new QAction(this); rotateAction->setIcon(style()->standardIcon(QStyle::SP_FileDialogDetailedView)); rotateAction->setCheckable(true); rotateAction->setText(tr("倒转图像")); connect(rotateAction, SIGNAL(toggled(bool)), this, SLOT(rotateImages(bool))); effectMenu->addAction(rotateAction); QMenu *toolsMenu = menuBar()->addMenu(tr("工具(&T)")); toolsMenu->addAction(tr("移除 GIF 动画"), this, SLOT(removeGifImages())); toolsMenu->addAction(tr("移除所有内联框架"), this, SLOT(removeInlineFrames())); toolsMenu->addAction(tr("移除所有对象元素"), this, SLOT(removeObjectElements())); toolsMenu->addAction(tr("移除所有嵌入元素"), this, SLOT(removeEmbeddedElements())); QMenu *helpMenu = menuBar()->addMenu(tr("帮助(&H)")); helpMenu->addAction(tr("关于 Looplorer"), this, SLOT(aboutLooplorer())); setCentralWidget(view); setUnifiedTitleAndToolBarOnMac(true); view->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks); clickLink(); windowNum++; }
int Context::resolved() { int ok = 1; apLog_Verbose((LOG_CHANNEL, LOG_CONTEXT, "" ApHandleFormat " for %s", ApHandlePrintf(apHandle()), _sz(sDocumentUrl_))); String sZone; // Is there a "zone"? if (ok) { Msg_Vpi_GetDetailXml msg; msg.sLocationXml = sLocationXml_; msg.sPath = "zone"; msg.bInnerXml = 1; if (!msg.Request()) { apLog_Verbose((LOG_CHANNEL, LOG_CONTEXT, "Msg_Vpi_GetDetailXml(%s) failed: %s for %s", _sz(msg.sPath), _sz(msg.sComment), _sz(sDocumentUrl_))); } else { sZone = msg.sXml; } } // Or at least a "destination"? if (ok && sZone.empty()) { Msg_Vpi_GetDetailXml msg; msg.sLocationXml = sLocationXml_; msg.sPath = "destination"; msg.bInnerXml = 1; if (!msg.Request()) { apLog_Verbose((LOG_CHANNEL, LOG_CONTEXT, "Msg_Vpi_GetDetailXml(%s) failed: %s for %s", _sz(msg.sPath), _sz(msg.sComment), _sz(sDocumentUrl_))); } else { sZone = msg.sXml; } } // Otherwise use the base URL as zone name if (ok && sZone.empty()) { Apollo::URL url = sDocumentUrl_; sZone = url.base(); } String sSuffix; if (ok) { Msg_DB_Get msg; String sEscapedZone = sZone; sEscapedZone.escape(String::EscapeSlash); msg.sName = DB_NAME; msg.sKey.appendf("zone/%s/suffix", _sz(sEscapedZone)); if (!msg.Request()) { apLog_Error((LOG_CHANNEL, LOG_CONTEXT, "Msg_DB_Get failed: db=%s key=%s", _sz(msg.sName), _sz(msg.sKey))); } else { sSuffix = msg.sValue; } } String sOldSuffix; int bOldSuffixSaved = 0; if (ok && !sSuffix.empty()) { Msg_Vpi_GetSuffix msg; if (!msg.Request()) { apLog_Error((LOG_CHANNEL, LOG_CONTEXT, "Msg_Vpi_GetSuffix")); } else { sOldSuffix = msg.sSuffix; bOldSuffixSaved = 1; } } if (ok && !sSuffix.empty()) { Msg_Vpi_SetSuffix msg; msg.sSuffix = sSuffix; if (!msg.Request()) { apLog_Error((LOG_CHANNEL, LOG_CONTEXT, "Msg_Vpi_SetSuffix failed: suffix=%s", _sz(msg.sSuffix))); } } if (ok) { Msg_Vpi_GetLocationUrl msg; msg.sLocationXml = sLocationXml_; ok = msg.Request(); if (!ok) { apLog_Error((LOG_CHANNEL, LOG_CONTEXT, "Msg_Vpi_GetLocationUrl failed: %s for %s", _sz(msg.sComment), _sz(sDocumentUrl_))); } else { if (sLocationUrl_ == msg.sLocationUrl) { ok = sameLocation(msg.sLocationUrl); } else { ok = changeLocation(msg.sLocationUrl); } } } if (bOldSuffixSaved) { Msg_Vpi_SetSuffix msg; msg.sSuffix = sOldSuffix; if (!msg.Request()) { apLog_Error((LOG_CHANNEL, LOG_CONTEXT, "Msg_Vpi_SetSuffix failed: suffix=%s", _sz(msg.sSuffix))); } } return ok; }
RWebBrowser::RWebBrowser(ICore *api, QWidget *parent) : QWidget(parent), m_core(api), m_webView(new QWebView), m_locationEdit(new QLineEdit), m_buttonLayout(new QVBoxLayout), m_progress(0) { //make sure we use application wide NetworkAccessManager: m_webView->page()->setNetworkAccessManager(m_core->networkAccessManager()); //TODO: make this configurable via settings m_webView->settings()->setAttribute(QWebSettings::PluginsEnabled, true); m_locationEdit->setSizePolicy(QSizePolicy::Expanding, m_locationEdit->sizePolicy().verticalPolicy()); QToolBar *toolBar = new QToolBar; toolBar->addAction(m_webView->pageAction(QWebPage::Back)); toolBar->addAction(m_webView->pageAction(QWebPage::Forward)); toolBar->addAction(m_webView->pageAction(QWebPage::Reload)); toolBar->addAction(m_webView->pageAction(QWebPage::Stop)); toolBar->addWidget(m_locationEdit); QObject::connect(m_webView, SIGNAL(loadFinished(bool)), SLOT(adjustLocation())); QObject::connect(m_webView, SIGNAL(titleChanged(QString)), SLOT(adjustTitle())); QObject::connect(m_webView, SIGNAL(loadProgress(int)), SLOT(setProgress(int))); QObject::connect(m_webView, SIGNAL(loadFinished(bool)), SLOT(finishLoading(bool))); QObject::connect(m_locationEdit, SIGNAL(returnPressed()), SLOT(changeLocation())); //TODO: load webpage given in user settings m_webView->load(QUrl("http://www.radiofrei.de/")); ///test zoom QSpinBox *sbox = new QSpinBox; sbox->setValue(100); sbox->setRange(30,200); sbox->setSingleStep(1); QObject::connect(sbox, SIGNAL(valueChanged(int)), SLOT(setZoom(int))); toolBar->addWidget(sbox); /// //create webView layout: QVBoxLayout *webLayout = new QVBoxLayout; webLayout->setSpacing(3); webLayout->setContentsMargins(0,0,0,0); webLayout->addWidget(toolBar); webLayout->addWidget(m_webView); //create main layout: QHBoxLayout *layout = new QHBoxLayout; layout->setSpacing(3); layout->setContentsMargins(0,0,0,0); layout->addLayout(webLayout); layout->addLayout(m_buttonLayout); setLayout(layout); }