Example #1
0
void StatusEdit::shortenUrl()
{ 
  if( hasSelectedText() ) {
    selectedUrl = selectedText();
    emit shortenUrl( selectedUrl );
  } else {
    QRegExp rx( "((ftp|http|https)://(\\w+:{0,1}\\w*@)?([^ ]+)(:[0-9]+)?(/|/([\\w#!:.?+=&%@!-/]))?)", Qt::CaseInsensitive );

    int position = rx.indexIn( text() );
    QString url = rx.capturedTexts().at( 1 );
    if( cursorPosition() >= position && cursorPosition() <= url.length() + position ) {
      selectedUrl = url;
      emit shortenUrl( selectedUrl );
    }
  }
}
Example #2
0
Qtwitter::Qtwitter( QWidget *parent ) : MainWindow( parent )
{
  connect( this, SIGNAL(switchModel(QString)), SLOT(setCurrentModel(QString)) );
  connect( this, SIGNAL(switchToPublicTimelineModel()), SLOT(setPublicTimelineModel()) );

  core = new Core( this );
  connect( this, SIGNAL(updateTweets()), core, SLOT(forceGet()) );
  connect( this, SIGNAL(openBrowser(QUrl)), core, SLOT(openBrowser(QUrl)) );
  connect( this, SIGNAL(post(QString,QString,int)), core, SLOT(post(QString,QString,int)) );
  connect( this, SIGNAL(resizeView(int,int)), core, SIGNAL(resizeData(int,int)));
  connect( this, SIGNAL(shortenUrl(QString)), core, SLOT(shortenUrl(QString)));
  connect( core, SIGNAL(twitterAccountsChanged(QList<TwitterAccount>,bool)), this, SLOT(setupTwitterAccounts(QList<TwitterAccount>,bool)) );
  connect( core, SIGNAL(urlShortened(QString)), this, SLOT(replaceUrl(QString)));
  connect( core, SIGNAL(about()), this, SLOT(about()) );
  connect( core, SIGNAL(addReplyString(QString,int)), this, SIGNAL(addReplyString(QString,int)) );
  connect( core, SIGNAL(addRetweetString(QString)), this, SIGNAL(addRetweetString(QString)) );
  connect( core, SIGNAL(errorMessage(QString)), this, SLOT(popupError(QString)) );
  connect( core, SIGNAL(resetUi()), this, SLOT(resetStatusEdit()) );
  connect( core, SIGNAL(requestStarted()), this, SLOT(showProgressIcon()) );
  if ( QSystemTrayIcon::supportsMessages() )
    connect( core, SIGNAL(sendNewsReport(QString)), this, SLOT(popupMessage(QString)) );

  twitpic = new TwitPicView( this );
  connect( twitpic, SIGNAL(uploadPhoto(QString,QString,QString)), core, SLOT(uploadPhoto(QString,QString,QString)) );
  connect( twitpic, SIGNAL(abortUpload()), core, SLOT(abortUploadPhoto()) );
  connect( this, SIGNAL(openTwitPicDialog()), twitpic, SLOT(show()) );
  connect( core, SIGNAL(twitPicResponseReceived()), twitpic, SLOT(resetForm()) );
  connect( core, SIGNAL(twitPicDataSendProgress(int,int)), twitpic, SLOT(showUploadProgress(int,int)) );

  settingsDialog = new Settings( this, core, twitpic, this );
  connect( this, SIGNAL(settingsDialogRequested()), settingsDialog, SLOT( show() ) );

  QSignalMapper *mapper = new QSignalMapper( this );
  mapper->setMapping( qApp, 1 );
  connect( qApp, SIGNAL(aboutToQuit()), mapper, SLOT(map()) );
  connect( mapper, SIGNAL(mapped(int)), settingsDialog, SLOT(saveConfig(int)) );
}
Example #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);
}