Exemple #1
0
void KCCodeEditor::showReplaceBar()
{
    if(searchBar->isVisible())
    {
        hideSearchBar();
        searcherConnections.disConnectAll();
    }

    if(!replaceBar->isVisible())
    {
        replaceBar->showAnime();

        connectSearchWidgetWithEditor(replaceBar);

        searcherConnections+=connect(replaceBar,&KCReplaceWindow::requireReplace,
                                     editor,&KCTextEditor::replace);
        searcherConnections+=connect(replaceBar,&KCReplaceWindow::requireReplaceAndFind,
                                     editor,&KCTextEditor::replaceAndFind);
        searcherConnections+=connect(replaceBar,&KCReplaceWindow::requireReplaceAll,
                                     editor,&KCTextEditor::replaceAll);
    }

    QTextCursor _textCursor=editor->textCursor();
    if(_textCursor.hasSelection())
    {
        replaceBar->setText(_textCursor.selectedText());
    }
    replaceBar->setTextFocus();
}
Exemple #2
0
/**
 * 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);
}
Exemple #3
0
WebBrowser::WebBrowser()
{
    layout = new QGridLayout();

    prevBtn = new QPushButton();
    nextBtn = new QPushButton();
    refreshBtn = new QPushButton();
    closeSearchBarBtn = new QPushButton();
    shortenerBtn = new QPushButton();

    searchBar = new QLineEdit();

    prevBtn->setFixedSize(30,30);
    prevBtn->setFlat(true);
    prevBtn->setIcon(QIcon(":/prev.gif"));
    nextBtn->setFixedSize(30,30);
    nextBtn->setFlat(true);
    nextBtn->setIcon(QIcon(":/next.gif"));
    refreshBtn->setFixedSize(30,30);
    refreshBtn->setFlat(true);
    refreshBtn->setIcon(QIcon(":/refresh.gif"));
    closeSearchBarBtn->setFixedSize(30,30);
    closeSearchBarBtn->setIcon(QIcon(":/close.gif"));
    shortenerBtn->setFixedSize(30,30);
    shortenerBtn->setIcon(QIcon(":/shorten.png"));
    shortenerBtn->setToolTip("Google URL Shortener");

    this->hideSearchBar();

    webview = new QWebView();
    webview->page()->settings()->setAttribute(QWebSettings::PluginsEnabled, true);

    omnibox = new OmniBox();

    omnibox->setFixedHeight(30);
    omnibox->setWebView(webview);

    layout->setMargin(1);
    layout->addWidget(prevBtn,0,0);
    layout->addWidget(nextBtn,0,1);
    layout->addWidget(refreshBtn,0,2);
    layout->addWidget(omnibox,0,3,1,4);
    layout->addWidget(shortenerBtn,0,7,1,1);
    layout->addWidget(webview,1,0,4,8);
    layout->addWidget(closeSearchBarBtn,5,0,1,1);
    layout->addWidget(searchBar,5,1,1,7);

    QObject::connect(webview,SIGNAL(titleChanged(QString)),this,SLOT(setWindowTitle(QString)));
    QObject::connect(prevBtn,SIGNAL(pressed()),webview,SLOT(back()));
    QObject::connect(nextBtn,SIGNAL(pressed()),webview,SLOT(forward()));
    QObject::connect(refreshBtn,SIGNAL(pressed()),webview,SLOT(reload()));
    QObject::connect(closeSearchBarBtn,SIGNAL(pressed()),this,SLOT(hideSearchBar()));
    QObject::connect(shortenerBtn,SIGNAL(clicked()),this,SLOT(shortenUrl()));
    QObject::connect(webview,SIGNAL(loadFinished(bool)),this,SLOT(setBtnStat()));
    //QObject::connect(webview,SIGNAL(loadFinished(bool)),omnibox,SLOT(setUrl()));
    QObject::connect(webview,SIGNAL(loadFinished(bool)),omnibox,SLOT(cleanProgress()));
    QObject::connect(webview->page()->networkAccessManager(),SIGNAL(finished(QNetworkReply*)),this,SLOT(handleWebPageError(QNetworkReply*)));
    QObject::connect(webview,SIGNAL(loadProgress(int)),omnibox,SLOT(paintProgress(int)));
    QObject::connect(searchBar,SIGNAL(textChanged(QString)),this,SLOT(findTextInPage()));
    QObject::connect(searchBar,SIGNAL(returnPressed()),this,SLOT(findTextInPage()));

    webview->setUrl(QUrl("http://www.google.com.tw"));

    this->setLayout(layout);
    this->resize(800,600);
}