1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-04-05 00:22:31 +02:00

Merge branch 'stable' of github.com:tomahawk-player/tomahawk into stable

This commit is contained in:
Christian Muehlhaeuser 2011-03-26 07:21:02 +01:00
commit 581814f482
9 changed files with 115 additions and 32 deletions

View File

@ -23,6 +23,7 @@
#include "dynamic/GeneratorInterface.h"
#include "dynamic/DynamicControl.h"
#include "utils/tomahawkutils.h"
#include "utils/elidedlabel.h"
#include <QLabel>
#include <QStackedLayout>
@ -85,7 +86,7 @@ CollapsibleControls::init()
m_summaryLayout->setMargin( 0 );
m_summaryWidget->setContentsMargins( 3, 0, 0, 0 );
m_summary = new QLabel( m_summaryWidget );
m_summary = new ElidedLabel( m_summaryWidget );
QFont f = m_summary->font();
f.setPointSize( f.pointSize() + 1 );
f.setBold( true );

View File

@ -27,7 +27,7 @@ class QPaintEvent;
class QHBoxLayout;
class QTimeLine;
class QToolButton;
class QLabel;
class ElidedLabel;
class QStackedLayout;
namespace Tomahawk
{
@ -67,7 +67,7 @@ private:
QWidget* m_summaryWidget;
QHBoxLayout* m_summaryLayout;
QLabel* m_summary;
ElidedLabel* m_summary;
QStackedLayout* m_expandL;
QToolButton* m_summaryExpand;

View File

@ -43,7 +43,7 @@ InfoBar::InfoBar( QWidget* parent )
boldFont.setPixelSize( 12 );
ui->descriptionLabel->setFont( boldFont );
ui->descriptionLabel->setMargin( 2 );
ui->descriptionLabel->setMargin( 10 );
QPalette whitePal = ui->captionLabel->palette();
whitePal.setColor( QPalette::Foreground, Qt::white );
@ -52,6 +52,8 @@ InfoBar::InfoBar( QWidget* parent )
ui->descriptionLabel->setPalette( whitePal );
ui->captionLabel->setText( QString() );
ui->captionLabel->setMargin( 6 );
ui->descriptionLabel->setText( QString() );
ui->imageLabel->setText( QString() );

View File

@ -74,7 +74,7 @@
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="captionLabel">
<widget class="ElidedLabel" name="captionLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -87,7 +87,7 @@
</widget>
</item>
<item>
<widget class="QLabel" name="descriptionLabel">
<widget class="ElidedLabel" name="descriptionLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
@ -119,6 +119,13 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>ElidedLabel</class>
<extends>QLabel</extends>
<header>utils/elidedlabel.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@ -22,6 +22,7 @@
#include <QPainter>
#include <QFontMetrics>
#include <QApplication>
#include <QRect>
ElidedLabel::ElidedLabel( QWidget* parent, Qt::WindowFlags flags )
@ -65,16 +66,16 @@ ElidedLabel::setText( const QString& text )
Qt::Alignment
ElidedLabel::alignment() const
{
return align;
return m_align;
}
void
ElidedLabel::setAlignment( Qt::Alignment alignment )
{
if ( this->align != alignment )
if ( m_align != alignment )
{
this->align = alignment;
m_align = alignment;
update(); // no geometry change, repaint is sufficient
}
}
@ -83,27 +84,40 @@ ElidedLabel::setAlignment( Qt::Alignment alignment )
Qt::TextElideMode
ElidedLabel::elideMode() const
{
return mode;
return m_mode;
}
void
ElidedLabel::setElideMode( Qt::TextElideMode mode )
{
if ( this->mode != mode )
if ( m_mode != mode )
{
this->mode = mode;
m_mode = mode;
updateLabel();
}
}
void
ElidedLabel::setMargin( int margin )
{
m_margin = margin;
}
int
ElidedLabel::margin() const
{
return m_margin;
}
void
ElidedLabel::init( const QString& txt )
{
m_text = txt;
align = Qt::AlignLeft;
mode = Qt::ElideMiddle;
m_align = Qt::AlignLeft;
m_mode = Qt::ElideMiddle;
m_margin = 0;
setContentsMargins( 0, 0, 0, 0 );
}
@ -128,7 +142,7 @@ ElidedLabel::sizeHint() const
QSize
ElidedLabel::minimumSizeHint() const
{
switch ( mode )
switch ( m_mode )
{
case Qt::ElideNone:
return sizeHint();
@ -149,8 +163,10 @@ ElidedLabel::paintEvent( QPaintEvent* event )
QFrame::paintEvent( event );
QPainter p( this );
QRect r = contentsRect();
const QString elidedText = fontMetrics().elidedText( m_text, mode, r.width() );
p.drawText( r, align, elidedText );
r.adjust( m_margin, m_margin, -m_margin, -m_margin );
const QString elidedText = fontMetrics().elidedText( m_text, m_mode, r.width() );
p.drawText( r, m_align, elidedText );
}
@ -176,7 +192,7 @@ void
ElidedLabel::mousePressEvent( QMouseEvent* event )
{
QFrame::mousePressEvent( event );
time.start();
m_time.start();
}
@ -184,6 +200,6 @@ void
ElidedLabel::mouseReleaseEvent( QMouseEvent* event )
{
QFrame::mouseReleaseEvent( event );
if ( time.elapsed() < qApp->doubleClickInterval() )
if ( m_time.elapsed() < qApp->doubleClickInterval() )
emit clicked();
}

View File

@ -44,6 +44,9 @@ public:
Qt::TextElideMode elideMode() const;
void setElideMode( Qt::TextElideMode mode );
void setMargin( int margin );
int margin() const;
virtual QSize sizeHint() const;
virtual QSize minimumSizeHint() const;
@ -64,10 +67,11 @@ protected:
virtual void paintEvent( QPaintEvent* event );
private:
QTime time;
QTime m_time;
QString m_text;
Qt::Alignment align;
Qt::TextElideMode mode;
Qt::Alignment m_align;
Qt::TextElideMode m_mode;
int m_margin;
};
#endif // ELIDEDLABEL_H

View File

@ -130,16 +130,30 @@ TwitterPlugin::connectPlugin( bool /*startup*/ )
return m_cachedPeers.isEmpty();
}
delete m_twitterAuth.data();
if ( refreshTwitterAuth() )
{
QTweetAccountVerifyCredentials *credVerifier = new QTweetAccountVerifyCredentials( m_twitterAuth.data(), this );
connect( credVerifier, SIGNAL( parsedUser(const QTweetUser &) ), SLOT( connectAuthVerifyReply(const QTweetUser &) ) );
credVerifier->verify();
}
return true;
}
bool
TwitterPlugin::refreshTwitterAuth()
{
m_twitterAuth = QWeakPointer<TomahawkOAuthTwitter>( new TomahawkOAuthTwitter( this ) );
TomahawkSettings *settings = TomahawkSettings::instance();
if ( m_twitterAuth.isNull() )
return false;
m_twitterAuth.data()->setNetworkAccessManager( TomahawkUtils::nam() );
m_twitterAuth.data()->setOAuthToken( settings->twitterOAuthToken().toLatin1() );
m_twitterAuth.data()->setOAuthTokenSecret( settings->twitterOAuthTokenSecret().toLatin1() );
QTweetAccountVerifyCredentials *credVerifier = new QTweetAccountVerifyCredentials( m_twitterAuth.data(), this );
connect( credVerifier, SIGNAL( parsedUser(const QTweetUser &) ), SLOT( connectAuthVerifyReply(const QTweetUser &) ) );
credVerifier->verify();
return true;
}
@ -189,8 +203,17 @@ TwitterPlugin::connectAuthVerifyReply( const QTweetUser &user )
}
else
{
qDebug() << "TwitterPlugin auth pointer was null!";
m_isAuthed = false;
if ( refreshTwitterAuth() )
{
QTweetAccountVerifyCredentials *credVerifier = new QTweetAccountVerifyCredentials( m_twitterAuth.data(), this );
connect( credVerifier, SIGNAL( parsedUser(const QTweetUser &) ), SLOT( connectAuthVerifyReply(const QTweetUser &) ) );
credVerifier->verify();
}
else
{
qDebug() << "TwitterPlugin auth pointer was null!";
m_isAuthed = false;
}
}
}
}
@ -201,6 +224,21 @@ TwitterPlugin::checkTimerFired()
if ( !isValid() )
return;
if ( m_twitterAuth.isNull() )
{
if ( refreshTwitterAuth() )
{
QTweetAccountVerifyCredentials *credVerifier = new QTweetAccountVerifyCredentials( m_twitterAuth.data(), this );
connect( credVerifier, SIGNAL( parsedUser(const QTweetUser &) ), SLOT( connectAuthVerifyReply(const QTweetUser &) ) );
credVerifier->verify();
}
else
{
qDebug() << "TwitterPlugin auth went null somehow and could not refresh";
return;
}
}
if ( m_cachedFriendsSinceId == 0 )
m_cachedFriendsSinceId = TomahawkSettings::instance()->twitterCachedFriendsSinceId();
@ -224,6 +262,21 @@ TwitterPlugin::connectTimerFired()
{
if ( !isValid() || m_cachedPeers.isEmpty() )
return;
if ( m_twitterAuth.isNull() )
{
if ( refreshTwitterAuth() )
{
QTweetAccountVerifyCredentials *credVerifier = new QTweetAccountVerifyCredentials( m_twitterAuth.data(), this );
connect( credVerifier, SIGNAL( parsedUser(const QTweetUser &) ), SLOT( connectAuthVerifyReply(const QTweetUser &) ) );
credVerifier->verify();
}
else
{
qDebug() << "TwitterPlugin auth went null somehow and could not refresh";
return;
}
}
QString myScreenName = TomahawkSettings::instance()->twitterScreenName();
QList<QString> peerlist = m_cachedPeers.keys();

View File

@ -91,6 +91,8 @@ private slots:
void makeConnection( const QString &screenName, const QHash< QString, QVariant > &peerdata );
private:
bool refreshTwitterAuth();
QWeakPointer< TomahawkOAuthTwitter > m_twitterAuth;
QWeakPointer< QTweetFriendsTimeline > m_friendsTimeline;
QWeakPointer< QTweetMentions > m_mentions;

View File

@ -102,5 +102,3 @@ target_link_libraries( qxtweb-standalone
# ${QT_LIBRARIES}
# "${CMAKE_CURRENT_SOURCE_DIR}/libqxtweb-standalone.a"
# )
INSTALL( TARGETS qxtweb-standalone DESTINATION lib${LIB_SUFFIX} )