Exemple #1
0
void StatusWidget::setStatusData( const Status &status )
{
    statusData = &status.entry;
    m_ui->favoriteReplyButton->disconnect();

    setDisplayMode( StatusModel::instance()->displayMode() );
    m_ui->userStatus->setHtml( statusData->text );
    m_ui->userImage->setPixmap( status.image );


    if ( statusData->type == Entry::Status ) {
        //adjust tooltip for reply/delete button
        if ( statusData->isOwn ) {
            m_ui->replyDeleteButton->setIcon( QIcon(":/icons/cross_16.png") );
            m_ui->replyDeleteButton->setToolTip( tr( "Delete status" ) );
        } else {
            m_ui->replyDeleteButton->setIcon( QIcon(":/icons/reply_16.png") );
            m_ui->replyDeleteButton->setToolTip( tr( "Reply to %1" ).arg( statusData->userInfo.screenName ) );
        }

        // favorite button
        if ( statusData->favorited ) {
            m_ui->favoriteReplyButton->setIcon( QIcon( ":/icons/star_on_16.png" ) );
            m_ui->favoriteReplyButton->setToolTip( tr( "Remove from Favorites" ) );
        } else {
            m_ui->favoriteReplyButton->setIcon( QIcon( ":/icons/star_off_16.png" ) );
            m_ui->favoriteReplyButton->setToolTip( tr( "Add to Favorites" ) );
        }
        connect( m_ui->favoriteReplyButton, SIGNAL(clicked()), this, SLOT(slotFavorite()) );

        // delete action
    } else {
        //adjust tooltip for reply/delete button and delete action
        m_ui->replyDeleteButton->setIcon( QIcon(":/icons/cross_16.png") );
        if ( currentServiceUrl == Account::NetworkUrlTwitter ) {
            m_ui->replyDeleteButton->setToolTip( tr( "Delete message" ) );
            m_ui->replyDeleteButton->setEnabled( true );
        } else {
            m_ui->replyDeleteButton->setToolTip( tr( "Deleting messages is not supported by StatusNet" ) );
            m_ui->replyDeleteButton->setEnabled( false );
        }

        // favorite button
        m_ui->favoriteReplyButton->setIcon( QIcon( ":/icons/reply_16.png" ) );
        m_ui->favoriteReplyButton->setToolTip( tr( "Reply to %1" ).arg( statusData->userInfo.screenName ) );
        connect( m_ui->favoriteReplyButton, SIGNAL(clicked()), this, SLOT(slotDM()) );

    }


    //display status's send time
    if( statusData->localTime.date() >= QDateTime::currentDateTime().date()) //today
        m_ui->timeStamp->setText( statusData->localTime.time().toString(Qt::SystemLocaleShortDate) );
    else  //yesterday or earlier
        m_ui->timeStamp->setText( statusData->localTime.toString(Qt::SystemLocaleShortDate) );

    //display in_reply_to link
    if( statusData->hasInReplyToStatusId ) {
        QString inReplyToUrl = currentServiceUrl;
        inReplyToUrl.remove( QRegExp("/api$", Qt::CaseInsensitive) );
        if ( currentServiceUrl == Account::NetworkUrlTwitter ) {
            inReplyToUrl.append( "/" + statusData->inReplyToScreenName + "/statuses/" + QString::number( statusData->inReplyToStatusId ) );
        }
        else {
            //for identica it works as is
            inReplyToUrl.append( "/notice/" + QString::number( statusData->inReplyToStatusId ) );
        }
        m_ui->timeStamp->setText( m_ui->timeStamp->text().append( " " )
                                  .append( tr( "in reply to %1" )
                                           .arg( QString( "<a style=\"color:rgb(255, 248, 140)\" href=%1>%2</a>" )
                                                 .arg( inReplyToUrl, statusData->inReplyToScreenName ) ) ) );
    }

    m_ui->infoButton->setData( &status );


    setState( status.state );
    setupMenu();
    adjustSize();
}
Exemple #2
0
void StatusWidget::createMenu()
{
    menu = new QMenu( this );
    signalMapper = new QSignalMapper( this );

    replyAction = new QAction( this );
    replyAction->setShortcut( QKeySequence( Qt::CTRL + Qt::SHIFT + Qt::Key_R ) );
    menu->addAction( replyAction );
    connect( replyAction, SIGNAL(triggered()), this, SLOT(slotReply()) );
    connect( this, SIGNAL(reply(QString,quint64)), StatusModel::instance(), SIGNAL(reply(QString,quint64)) );

    retweetAction = new QAction( tr( "Retweet" ), this );
    retweetAction->setShortcut( QKeySequence( Qt::CTRL + Qt::Key_T ) );
    menu->addAction( retweetAction );
    connect( retweetAction, SIGNAL(triggered()), this, SLOT(slotRetweet()) );
    connect( this, SIGNAL(retweet(QString)), StatusModel::instance(), SIGNAL(retweet(QString)) );

    dmAction = new QAction( this );
    dmAction->setShortcut( QKeySequence( Qt::CTRL + Qt::SHIFT + Qt::Key_D ) );
    menu->addAction( dmAction );
    connect( dmAction, SIGNAL(triggered()), this, SLOT(slotDM()) );

    menu->addSeparator();

    favoriteAction = new QAction( tr( "Add to Favorites" ), this );
    favoriteAction->setShortcut( QKeySequence( Qt::CTRL + Qt::SHIFT + Qt::Key_F ) );
    menu->addAction( favoriteAction );
    connect( favoriteAction, SIGNAL(triggered()), this, SLOT(slotFavorite()) );

    copylinkAction = new QAction( tr( "Copy link to this status" ), this );
    copylinkAction->setShortcut( QKeySequence( Qt::CTRL + Qt::SHIFT + Qt::Key_C ) );
    menu->addAction( copylinkAction );
    connect( copylinkAction, SIGNAL(triggered()), this, SLOT(slotCopyLink()) );

    deleteAction = new QAction( this );
    deleteAction->setShortcut( QKeySequence( Qt::CTRL + Qt::SHIFT + Qt::Key_Backspace ) );
    menu->addAction( deleteAction );
    connect( deleteAction, SIGNAL(triggered()), this, SLOT(slotDelete()) );

    markallasreadAction = new QAction( tr( "Mark list as read" ), this );
    markallasreadAction->setShortcut( QKeySequence( Qt::CTRL + Qt::SHIFT + Qt::Key_A ) );
    menu->addAction( markallasreadAction );
    connect( markallasreadAction, SIGNAL(triggered()), StatusModel::instance(), SLOT(markAllAsRead()) );

    markeverythingasreadAction = new QAction( tr( "Mark everything as read" ), this );
    markeverythingasreadAction->setShortcut( QKeySequence( Qt::CTRL + Qt::ALT + Qt::Key_A ) );
    menu->addAction( markeverythingasreadAction );
    connect( markeverythingasreadAction, SIGNAL(triggered()), StatusModel::instance(), SIGNAL(markEverythingAsRead()) );

    menu->addSeparator();

    gototwitterpageAction = new QAction( this );
    gototwitterpageAction->setShortcut( QKeySequence( Qt::CTRL + Qt::SHIFT + Qt::Key_T ) );
    menu->addAction( gototwitterpageAction );
    connect( gototwitterpageAction, SIGNAL(triggered()), signalMapper, SLOT(map()) );
    connect( signalMapper, SIGNAL(mapped(QString)), StatusModel::instance(), SLOT(emitOpenBrowser(QString)) );

    gotohomepageAction = new QAction( tr( "Go to User's homepage" ), this);
    gotohomepageAction->setShortcut( QKeySequence( Qt::CTRL + Qt::SHIFT + Qt::Key_H ) );
    menu->addAction( gotohomepageAction );
    connect( gotohomepageAction, SIGNAL(triggered()), signalMapper, SLOT(map()) );
}
Exemple #3
0
void StatusWidget::setStatusData( const Status &status )
{
  statusData = &status.entry;
  retranslateUi();
  m_ui->favoriteReplyButton->disconnect();

  m_ui->userName->setText( statusData->userInfo.name );
  m_ui->userStatus->setText( statusData->text );
  m_ui->userImage->setPixmap( status.image );


  //adjust tooltip for reply/delete button
  if ( statusData->type == Entry::Status ) {
    if ( statusData->isOwn ) {
      m_ui->replyDeleteButton->setIcon( QIcon(":/icons/cross_16.png") );
      m_ui->replyDeleteButton->setToolTip( tr( "Delete status" ) );
    } else {
      m_ui->replyDeleteButton->setIcon( QIcon(":/icons/reply_16.png") );
      m_ui->replyDeleteButton->setToolTip( tr( "Reply to %1" ).arg( statusData->userInfo.screenName ) );
    }
  } else {
    m_ui->replyDeleteButton->setIcon( QIcon(":/icons/cross_16.png") );
    m_ui->replyDeleteButton->setToolTip( tr( "Delete message" ) );
  }

  if ( statusData->type == Entry::Status )
    deleteAction->setText( tr( "Delete status" ) );
  else
    deleteAction->setText( tr( "Delete message" ) );

  if ( currentLogin != TwitterAPI::PUBLIC_TIMELINE ) {

    if ( statusData->type == Entry::DirectMessage ) {

      m_ui->favoriteReplyButton->setIcon( QIcon( ":/icons/reply_16.png" ) );
      m_ui->favoriteReplyButton->setToolTip( tr( "Reply to %1" ).arg( statusData->userInfo.screenName ) );
      connect( m_ui->favoriteReplyButton, SIGNAL(clicked()), this, SLOT(slotDM()) );

    } else {

      if ( statusData->favorited ) {
        m_ui->favoriteReplyButton->setIcon( QIcon( ":/icons/star_on_16.png" ) );
        if ( currentNetwork == TwitterAPI::SOCIALNETWORK_IDENTICA ) {
          m_ui->favoriteReplyButton->setToolTip( QString() );
          favoriteAction->setText( tr( "Remove from Favorites" ) );
          favoriteAction->setEnabled( false );
        } else {
          m_ui->favoriteReplyButton->setToolTip( tr( "Remove from Favorites" ) );
          favoriteAction->setText( m_ui->favoriteReplyButton->toolTip() );
          favoriteAction->setEnabled( true );
        }
      } else {
        m_ui->favoriteReplyButton->setIcon( QIcon( ":/icons/star_off_16.png" ) );
        m_ui->favoriteReplyButton->setToolTip( tr( "Add to Favorites" ) );
        favoriteAction->setText( m_ui->favoriteReplyButton->toolTip() );
        favoriteAction->setEnabled( true );
      }
      connect( m_ui->favoriteReplyButton, SIGNAL(clicked()), this, SLOT(slotFavorite()) );

    }

  } else {
    favoriteAction->setEnabled( false );
  }

  //display status's send time
  if( statusData->localTime.date() >= QDateTime::currentDateTime().date()) //today
    m_ui->timeStamp->setText( statusData->localTime.time().toString(Qt::SystemLocaleShortDate) );
  else  //yesterday or earlier
    m_ui->timeStamp->setText( statusData->localTime.toString(Qt::SystemLocaleShortDate) );

  //display in_reply_to link
  if( statusData->hasInReplyToStatusId ) {
    QString inReplyToUrl;
    if ( this->currentNetwork == TwitterAPI::SOCIALNETWORK_TWITTER ) {
      inReplyToUrl = "http://twitter.com/" + statusData->inReplyToScreenName + "/statuses/" + QString::number( statusData->inReplyToStatusId );
    }
    else if ( this->currentNetwork == TwitterAPI::SOCIALNETWORK_IDENTICA )
      //for identica it works as is
      inReplyToUrl = "http://identi.ca/notice/" + QString::number( statusData->inReplyToStatusId );

    m_ui->timeStamp->setText( m_ui->timeStamp->text().append( " " )
                              .append( tr( "in reply to %1" )
                                       // TODO: links theming
                                       .arg( QString( "<a style=\"color:rgb(255, 248, 140)\" href=%1>%2</a>" )
                                             .arg( inReplyToUrl, statusData->inReplyToScreenName ) ) ) );
  }

  m_ui->infoButton->setData( &status );


  setState( status.state );
  setupMenu();
  adjustSize();
}