mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-20 04:41:36 +02:00
Semi-working ACL state.
This commit is contained in:
@@ -26,6 +26,7 @@
|
|||||||
#include "accounts/Account.h"
|
#include "accounts/Account.h"
|
||||||
|
|
||||||
#include "utils/TomahawkUtils.h"
|
#include "utils/TomahawkUtils.h"
|
||||||
|
#include "utils/TomahawkUtilsGui.h"
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
|
|
||||||
#define CHILD_ACCOUNT_HEIGHT 24
|
#define CHILD_ACCOUNT_HEIGHT 24
|
||||||
@@ -523,53 +524,10 @@ AccountDelegate::editorEvent( QEvent* event, QAbstractItemModel* model, const QS
|
|||||||
void
|
void
|
||||||
AccountDelegate::drawRoundedButton( QPainter* painter, const QRect& btnRect, bool red ) const
|
AccountDelegate::drawRoundedButton( QPainter* painter, const QRect& btnRect, bool red ) const
|
||||||
{
|
{
|
||||||
QPainterPath btnPath;
|
|
||||||
const int radius = 3;
|
|
||||||
// draw top half gradient
|
|
||||||
const int btnCenter = btnRect.bottom() - ( btnRect.height() / 2 );
|
|
||||||
btnPath.moveTo( btnRect.left(), btnCenter );
|
|
||||||
btnPath.lineTo( btnRect.left(), btnRect.top() + radius );
|
|
||||||
btnPath.quadTo( QPoint( btnRect.topLeft() ), QPoint( btnRect.left() + radius, btnRect.top() ) );
|
|
||||||
btnPath.lineTo( btnRect.right() - radius, btnRect.top() );
|
|
||||||
btnPath.quadTo( QPoint( btnRect.topRight() ), QPoint( btnRect.right(), btnRect.top() + radius ) );
|
|
||||||
btnPath.lineTo( btnRect.right(),btnCenter );
|
|
||||||
btnPath.lineTo( btnRect.left(), btnCenter );
|
|
||||||
|
|
||||||
QLinearGradient g;
|
|
||||||
if ( !red )
|
if ( !red )
|
||||||
{
|
TomahawkUtils::drawRoundedButton( painter, btnRect, QColor(54, 127, 211), QColor(43, 104, 182), QColor(34, 85, 159), QColor(35, 79, 147) );
|
||||||
g.setColorAt( 0, QColor(54, 127, 211) );
|
|
||||||
g.setColorAt( 0.5, QColor(43, 104, 182) );
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
TomahawkUtils::drawRoundedButton( painter, btnRect, QColor(206, 63, 63), QColor(170, 52, 52), QColor(150, 50, 50), QColor(130, 40, 40) );
|
||||||
g.setColorAt( 0, QColor(206, 63, 63) );
|
|
||||||
g.setColorAt( 0.5, QColor(170, 52, 52) );
|
|
||||||
}
|
|
||||||
//painter->setPen( bg.darker() );
|
|
||||||
painter->fillPath( btnPath, g );
|
|
||||||
//painter->drawPath( btnPath );
|
|
||||||
|
|
||||||
btnPath = QPainterPath();
|
|
||||||
btnPath.moveTo( btnRect.left(), btnCenter );
|
|
||||||
btnPath.lineTo( btnRect.left(), btnRect.bottom() - radius );
|
|
||||||
btnPath.quadTo( QPoint( btnRect.bottomLeft() ), QPoint( btnRect.left() + radius, btnRect.bottom() ) );
|
|
||||||
btnPath.lineTo( btnRect.right() - radius, btnRect.bottom() );
|
|
||||||
btnPath.quadTo( QPoint( btnRect.bottomRight() ), QPoint( btnRect.right(), btnRect.bottom() - radius ) );
|
|
||||||
btnPath.lineTo( btnRect.right(), btnCenter );
|
|
||||||
btnPath.lineTo( btnRect.left(), btnCenter );
|
|
||||||
|
|
||||||
if ( !red )
|
|
||||||
{
|
|
||||||
g.setColorAt( 0, QColor(34, 85, 159) );
|
|
||||||
g.setColorAt( 0.5, QColor(35, 79, 147) );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
g.setColorAt( 0, QColor(150, 50, 50) );
|
|
||||||
g.setColorAt( 0.5, QColor(130, 40, 40) );
|
|
||||||
}
|
|
||||||
painter->fillPath( btnPath, g );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -70,8 +70,8 @@ ACLRegistry::isAuthorizedUser( const QString& dbid, const QString &username, ACL
|
|||||||
}
|
}
|
||||||
|
|
||||||
//FIXME: Remove when things are working
|
//FIXME: Remove when things are working
|
||||||
emit aclResult( dbid, username, ACLRegistry::Stream );
|
// emit aclResult( dbid, username, ACLRegistry::Stream );
|
||||||
return ACLRegistry::NotFound;
|
// return ACLRegistry::NotFound;
|
||||||
|
|
||||||
bool found = false;
|
bool found = false;
|
||||||
QMutableListIterator< ACLRegistry::User > i( m_cache );
|
QMutableListIterator< ACLRegistry::User > i( m_cache );
|
||||||
@@ -156,9 +156,11 @@ ACLRegistry::userDecision( ACLRegistry::User user )
|
|||||||
void
|
void
|
||||||
ACLRegistry::queueNextJob()
|
ACLRegistry::queueNextJob()
|
||||||
{
|
{
|
||||||
|
tDebug() << Q_FUNC_INFO << "jobCount = " << m_jobCount;
|
||||||
if ( m_jobCount != 0 )
|
if ( m_jobCount != 0 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
tDebug() << Q_FUNC_INFO << "jobQueue size = " << m_jobQueue.length();
|
||||||
if ( !m_jobQueue.isEmpty() )
|
if ( !m_jobQueue.isEmpty() )
|
||||||
{
|
{
|
||||||
AclJobItem* job = m_jobQueue.dequeue();
|
AclJobItem* job = m_jobQueue.dequeue();
|
||||||
@@ -169,18 +171,21 @@ ACLRegistry::queueNextJob()
|
|||||||
ACLRegistry::ACL acl = isAuthorizedUser( dbid, job->username(), ACLRegistry::NotFound, true );
|
ACLRegistry::ACL acl = isAuthorizedUser( dbid, job->username(), ACLRegistry::NotFound, true );
|
||||||
if ( acl != ACLRegistry::NotFound )
|
if ( acl != ACLRegistry::NotFound )
|
||||||
{
|
{
|
||||||
|
tDebug() << Q_FUNC_INFO << "Found existing acl entry for = " << user.knownAccountIds.first();
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( found )
|
if ( found )
|
||||||
{
|
{
|
||||||
|
tDebug() << Q_FUNC_INFO << "deleting job, already have ACL for " << user.knownAccountIds.first();
|
||||||
delete job;
|
delete job;
|
||||||
QTimer::singleShot( 0, this, SLOT( queueNextJob() ) );
|
QTimer::singleShot( 0, this, SLOT( queueNextJob() ) );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
tDebug() << Q_FUNC_INFO << "activating job for user" << user.knownAccountIds.first();
|
||||||
m_jobCount++;
|
m_jobCount++;
|
||||||
JobStatusView::instance()->model()->addJob( job );
|
JobStatusView::instance()->model()->addJob( job );
|
||||||
connect( job, SIGNAL( userDecision( ACLRegistry::User ) ), this, SLOT( userDecision( ACLRegistry::User ) ) );
|
connect( job, SIGNAL( userDecision( ACLRegistry::User ) ), this, SLOT( userDecision( ACLRegistry::User ) ) );
|
||||||
|
@@ -21,30 +21,31 @@
|
|||||||
|
|
||||||
#include "JobStatusModel.h"
|
#include "JobStatusModel.h"
|
||||||
#include "utils/TomahawkUtils.h"
|
#include "utils/TomahawkUtils.h"
|
||||||
|
#include "utils/TomahawkUtilsGui.h"
|
||||||
|
#include "libtomahawk/infosystem/InfoSystem.h"
|
||||||
|
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QListView>
|
#include <QListView>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
#include <QMouseEvent>
|
||||||
|
|
||||||
|
|
||||||
#define ROW_HEIGHT 40
|
#define ROW_HEIGHT 20
|
||||||
#define ICON_PADDING 1
|
#define ICON_PADDING 1
|
||||||
#define PADDING 2
|
#define PADDING 2
|
||||||
|
|
||||||
|
|
||||||
AclJobDelegate::AclJobDelegate( QObject* parent )
|
AclJobDelegate::AclJobDelegate( QObject* parent )
|
||||||
: QStyledItemDelegate ( parent )
|
: QStyledItemDelegate ( parent )
|
||||||
, m_parentView( qobject_cast< QListView* >( parent ) )
|
|
||||||
{
|
{
|
||||||
Q_ASSERT( m_parentView );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AclJobDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const
|
AclJobDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const
|
||||||
{
|
{
|
||||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO;
|
//tDebug( LOGVERBOSE ) << Q_FUNC_INFO;
|
||||||
QStyleOptionViewItemV4 opt = option;
|
QStyleOptionViewItemV4 opt = option;
|
||||||
initStyleOption( &opt, index );
|
initStyleOption( &opt, index );
|
||||||
QFontMetrics fm( opt.font );
|
QFontMetrics fm( opt.font );
|
||||||
@@ -54,95 +55,90 @@ AclJobDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, co
|
|||||||
|
|
||||||
painter->setRenderHint( QPainter::Antialiasing );
|
painter->setRenderHint( QPainter::Antialiasing );
|
||||||
|
|
||||||
|
painter->fillRect( opt.rect, Qt::lightGray );
|
||||||
|
|
||||||
QString mainText;
|
QString mainText;
|
||||||
AclJobItem* item = dynamic_cast< AclJobItem* >( index.data( JobStatusModel::JobDataRole ).value< JobStatusItem* >() );
|
AclJobItem* item = dynamic_cast< AclJobItem* >( index.data( JobStatusModel::JobDataRole ).value< JobStatusItem* >() );
|
||||||
if ( !item )
|
if ( !item )
|
||||||
mainText = tr( "Error displaying ACL info" );
|
mainText = tr( "Error displaying ACL info" );
|
||||||
else
|
else
|
||||||
mainText = QString( tr( "Allow %1 to\nconnect and stream from you?" ) ).arg( item->username() );
|
mainText = QString( tr( "Allow %1 to\nconnect and stream from you?" ) ).arg( item->username() );
|
||||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Displaying text:" << mainText;
|
//tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Displaying text:" << mainText;
|
||||||
|
|
||||||
const QString text = QString( tr( "Allow %1 to\nconnect and stream from you?" ) ).arg( item->username() );
|
const QString text = QString( tr( "Allow %1 to\nconnect and stream from you?" ) ).arg( item->username() );
|
||||||
const int w = fm.width( text );
|
const QRect rRect( opt.rect.left() + PADDING, opt.rect.top() + 4*PADDING, opt.rect.width() - 2*PADDING, opt.rect.height() - 2*PADDING );
|
||||||
const QRect rRect( opt.rect.left() + PADDING, ROW_HEIGHT + PADDING, opt.rect.width() - 2*PADDING, opt.rect.height() - 2*PADDING );
|
painter->drawText( rRect, Qt::AlignHCenter, text );
|
||||||
painter->drawText( rRect, Qt::AlignCenter, text );
|
|
||||||
|
|
||||||
|
//tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Using rect " << rRect << ", opt rect is " << opt.rect;
|
||||||
|
|
||||||
/*
|
int totalwidth = opt.rect.width();
|
||||||
QStyleOptionViewItemV4 opt = option;
|
int thirds = totalwidth/3;
|
||||||
initStyleOption( &opt, index );
|
QRect btnRect;
|
||||||
QFontMetrics fm( opt.font );
|
painter->setPen( Qt::white );
|
||||||
const bool allowMultiLine = index.data( JobStatusModel::AllowMultiLineRole ).toBool();
|
|
||||||
|
|
||||||
opt.state &= ~QStyle::State_MouseOver;
|
QString btnText = tr( "Allow Streaming" );
|
||||||
QApplication::style()->drawPrimitive( QStyle::PE_PanelItemViewItem, &opt, painter, opt.widget );
|
int btnWidth = fm.width( btnText ) + 2*PADDING;
|
||||||
|
btnRect = QRect( opt.rect.left() + thirds - btnWidth/2, opt.rect.bottom() - fm.height() - 4*PADDING, btnWidth + 2*PADDING, fm.height() + 2*PADDING );
|
||||||
|
drawRoundedButton( painter, btnRect, btnRect.contains( m_savedHoverPos ) );
|
||||||
|
painter->drawText( btnRect, Qt::AlignCenter, btnText );
|
||||||
|
m_savedAcceptRect = btnRect;
|
||||||
|
|
||||||
// painter->drawLine( opt.rect.topLeft(), opt.rect.topRight() );
|
btnText = tr( "Deny Access" );
|
||||||
|
btnWidth = fm.width( btnText ) + 2*PADDING;
|
||||||
painter->setRenderHint( QPainter::Antialiasing );
|
btnRect = QRect( opt.rect.right() - thirds - btnWidth/2, opt.rect.bottom() - fm.height() - 4*PADDING, btnWidth + 2*PADDING, fm.height() + 2*PADDING );
|
||||||
QRect iconRect( ICON_PADDING, ICON_PADDING + opt.rect.y(), ROW_HEIGHT - 2*ICON_PADDING, ROW_HEIGHT - 2*ICON_PADDING );
|
drawRoundedButton( painter, btnRect, btnRect.contains( m_savedHoverPos ) );
|
||||||
if ( allowMultiLine )
|
painter->drawText( btnRect, Qt::AlignCenter, btnText );
|
||||||
iconRect.moveTop( opt.rect.top() + opt.rect.height() / 2 - iconRect.height() / 2);
|
m_savedDenyRect = btnRect;
|
||||||
QPixmap p = index.data( Qt::DecorationRole ).value< QPixmap >();
|
|
||||||
p = p.scaledToHeight( iconRect.height(), Qt::SmoothTransformation );
|
|
||||||
painter->drawPixmap( iconRect, p );
|
|
||||||
|
|
||||||
// draw right column if there is one
|
|
||||||
const QString rCol = index.data( JobStatusModel::RightColumnRole ).toString();
|
|
||||||
int rightEdge = opt.rect.right();
|
|
||||||
if ( !rCol.isEmpty() )
|
|
||||||
{
|
|
||||||
const int w = fm.width( rCol );
|
|
||||||
const QRect rRect( opt.rect.right() - PADDING - w, PADDING + opt.rect.y(), w, opt.rect.height() - 2*PADDING );
|
|
||||||
painter->drawText( rRect, Qt::AlignCenter, rCol );
|
|
||||||
|
|
||||||
rightEdge = rRect.left();
|
|
||||||
}
|
|
||||||
|
|
||||||
QString mainText;
|
|
||||||
AclJobItem* item = dynamic_cast< AclJobItem* >( index.data( JobStatusModel::JobDataRole ).value< JobStatusItem* >() );
|
|
||||||
//QString mainText = index.data( Qt::DisplayRole ).toString();
|
|
||||||
if ( !item )
|
|
||||||
mainText = tr( "Error displaying ACL info" );
|
|
||||||
else
|
|
||||||
mainText = QString( tr( "Allow %1 to\nconnect and stream from you?" ) ).arg( item->username() );
|
|
||||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Displaying text:" << mainText;
|
|
||||||
const int mainW = rightEdge - 3*PADDING - iconRect.right();
|
|
||||||
QTextOption to( Qt::AlignLeft | Qt::AlignVCenter );
|
|
||||||
if ( !allowMultiLine )
|
|
||||||
mainText = fm.elidedText( mainText, Qt::ElideRight, mainW );
|
|
||||||
else
|
|
||||||
to.setWrapMode( QTextOption::WrapAtWordBoundaryOrAnywhere );
|
|
||||||
painter->drawText( QRect( iconRect.right() + 2*PADDING, PADDING + opt.rect.y(), mainW, opt.rect.height() - 2*PADDING ), mainText, to );
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QSize
|
QSize
|
||||||
AclJobDelegate::sizeHint( const QStyleOptionViewItem& option, const QModelIndex& index ) const
|
AclJobDelegate::sizeHint( const QStyleOptionViewItem& option, const QModelIndex& index ) const
|
||||||
|
{
|
||||||
|
QSize size( QStyledItemDelegate::sizeHint ( option, index ).width(), ROW_HEIGHT * 3 );
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
AclJobDelegate::drawRoundedButton( QPainter* painter, const QRect& btnRect, bool red ) const
|
||||||
|
{
|
||||||
|
if ( !red )
|
||||||
|
TomahawkUtils::drawRoundedButton( painter, btnRect, QColor(54, 127, 211), QColor(43, 104, 182), QColor(34, 85, 159), QColor(35, 79, 147) );
|
||||||
|
else
|
||||||
|
TomahawkUtils::drawRoundedButton( painter, btnRect, QColor(206, 63, 63), QColor(170, 52, 52), QColor(150, 50, 50), QColor(130, 40, 40) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
AclJobDelegate::editorEvent( QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& index )
|
||||||
{
|
{
|
||||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO;
|
tDebug( LOGVERBOSE ) << Q_FUNC_INFO;
|
||||||
return QSize( QStyledItemDelegate::sizeHint ( option, index ).width(), ROW_HEIGHT );
|
if ( event->type() != QEvent::MouseButtonPress &&
|
||||||
|
event->type() != QEvent::MouseButtonRelease &&
|
||||||
|
event->type() != QEvent::MouseButtonDblClick &&
|
||||||
|
event->type() != QEvent::MouseMove )
|
||||||
|
return false;
|
||||||
|
|
||||||
/*
|
if ( event->type() == QEvent::MouseMove )
|
||||||
const bool allowMultiLine = index.data( JobStatusModel::AllowMultiLineRole ).toBool();
|
{
|
||||||
|
QMouseEvent* me = static_cast< QMouseEvent* >( event );
|
||||||
|
m_savedHoverPos = me->pos();
|
||||||
|
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Setting position to " << m_savedHoverPos;
|
||||||
|
emit update( index );
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if ( !allowMultiLine )
|
if ( event->type() == QEvent::MouseButtonRelease || event->type() == QEvent::MouseButtonDblClick )
|
||||||
return QSize( QStyledItemDelegate::sizeHint ( option, index ).width(), ROW_HEIGHT );
|
{
|
||||||
else if ( m_cachedMultiLineHeights.contains( index ) )
|
QMouseEvent* me = static_cast< QMouseEvent* >( event );
|
||||||
return QSize( QStyledItemDelegate::sizeHint ( option, index ).width(), m_cachedMultiLineHeights[ index ] );
|
if ( m_savedAcceptRect.contains( me->pos() ) )
|
||||||
|
emit aclResult( ACLRegistry::Stream );
|
||||||
|
else if ( m_savedDenyRect.contains( me->pos() ) )
|
||||||
|
emit aclResult( ACLRegistry::Deny );
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// Don't elide, but stretch across as many rows as required
|
return false;
|
||||||
QStyleOptionViewItemV4 opt = option;
|
|
||||||
initStyleOption( &opt, index );
|
|
||||||
|
|
||||||
const QString text = index.data( Qt::DisplayRole ).toString();
|
|
||||||
const int leftEdge = ICON_PADDING + ROW_HEIGHT + 2*PADDING;
|
|
||||||
const QRect rect = opt.fontMetrics.boundingRect( leftEdge, opt.rect.top(), m_parentView->width() - leftEdge, 200, Qt::AlignLeft | Qt::AlignTop | Qt::TextWordWrap, text );
|
|
||||||
|
|
||||||
m_cachedMultiLineHeights.insert( index, rect.height() + 4*PADDING );
|
|
||||||
|
|
||||||
return QSize( QStyledItemDelegate::sizeHint ( option, index ).width(), rect.height() + 4*PADDING );
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -167,6 +163,25 @@ AclJobItem::createDelegate( QObject* parent )
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
m_delegate = new AclJobDelegate( parent );
|
m_delegate = new AclJobDelegate( parent );
|
||||||
|
|
||||||
|
Tomahawk::InfoSystem::InfoPushData pushData( "AclJobItem", Tomahawk::InfoSystem::InfoNotifyUser, tr( "Tomahawk needs you to decide whether %1 is allowed to connect." ).arg( m_username ), Tomahawk::InfoSystem::PushNoFlag );
|
||||||
|
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo( pushData );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
AclJobDelegate::emitSizeHintChanged( const QModelIndex& index )
|
||||||
|
{
|
||||||
|
emit sizeHintChanged( index );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
AclJobItem::aclResult( ACLRegistry::ACL result )
|
||||||
|
{
|
||||||
|
m_user.acl = result;
|
||||||
|
emit userDecision( m_user );
|
||||||
|
done();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -38,9 +38,21 @@ public:
|
|||||||
virtual void paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const;
|
virtual void paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const;
|
||||||
virtual QSize sizeHint( const QStyleOptionViewItem& option, const QModelIndex& index ) const;
|
virtual QSize sizeHint( const QStyleOptionViewItem& option, const QModelIndex& index ) const;
|
||||||
|
|
||||||
|
virtual void emitSizeHintChanged( const QModelIndex &index );
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void update( const QModelIndex& idx );
|
||||||
|
void aclResult( ACLRegistry::ACL result );
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual bool editorEvent( QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& index );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
mutable QHash< QPersistentModelIndex, int > m_cachedMultiLineHeights;
|
void drawRoundedButton( QPainter* painter, const QRect& btnRect, bool red = false ) const;
|
||||||
QListView* m_parentView;
|
|
||||||
|
QPoint m_savedHoverPos;
|
||||||
|
mutable QRect m_savedAcceptRect;
|
||||||
|
mutable QRect m_savedDenyRect;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -70,6 +82,9 @@ public:
|
|||||||
signals:
|
signals:
|
||||||
void userDecision( ACLRegistry::User user );
|
void userDecision( ACLRegistry::User user );
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void aclResult( ACLRegistry::ACL result );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QStyledItemDelegate* m_delegate;
|
QStyledItemDelegate* m_delegate;
|
||||||
ACLRegistry::User m_user;
|
ACLRegistry::User m_user;
|
||||||
|
@@ -20,6 +20,7 @@
|
|||||||
#include "JobStatusView.h"
|
#include "JobStatusView.h"
|
||||||
|
|
||||||
#include "Pipeline.h"
|
#include "Pipeline.h"
|
||||||
|
#include "AclJobItem.h"
|
||||||
#include "JobStatusModel.h"
|
#include "JobStatusModel.h"
|
||||||
#include "JobStatusItem.h"
|
#include "JobStatusItem.h"
|
||||||
#include "JobStatusDelegate.h"
|
#include "JobStatusDelegate.h"
|
||||||
@@ -74,6 +75,9 @@ JobStatusView::JobStatusView( AnimatedSplitter* parent )
|
|||||||
new PipelineStatusManager( this );
|
new PipelineStatusManager( this );
|
||||||
new TransferStatusManager( this );
|
new TransferStatusManager( this );
|
||||||
new LatchedStatusManager( this );
|
new LatchedStatusManager( this );
|
||||||
|
|
||||||
|
setMouseTracking( true );
|
||||||
|
m_view->setMouseTracking( true );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -103,6 +107,13 @@ JobStatusView::customDelegateJobInserted( int row, JobStatusItem* item )
|
|||||||
item->createDelegate( m_view );
|
item->createDelegate( m_view );
|
||||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "item delegate is " << item->customDelegate();
|
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "item delegate is " << item->customDelegate();
|
||||||
m_view->setItemDelegateForRow( row, item->customDelegate() );
|
m_view->setItemDelegateForRow( row, item->customDelegate() );
|
||||||
|
AclJobDelegate* delegate = qobject_cast< AclJobDelegate* >( item->customDelegate() );
|
||||||
|
if ( delegate )
|
||||||
|
{
|
||||||
|
connect( delegate, SIGNAL( update( const QModelIndex& ) ), m_view, SLOT( update( const QModelIndex & ) ) );
|
||||||
|
connect( delegate, SIGNAL( aclResult( ACLRegistry::ACL ) ), item, SLOT( aclResult( ACLRegistry::ACL ) ) );
|
||||||
|
delegate->emitSizeHintChanged( m_model->index( row ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -536,6 +536,8 @@ Servent::connectToPeer( const QString& ha, int port, const QString &key, const Q
|
|||||||
if( id.length() )
|
if( id.length() )
|
||||||
conn->setId( id );
|
conn->setId( id );
|
||||||
|
|
||||||
|
conn->setProperty( "nodeid", id );
|
||||||
|
|
||||||
connectToPeer( ha, port, key, conn );
|
connectToPeer( ha, port, key, conn );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -414,4 +414,54 @@ prepareStyleOption( QStyleOptionViewItemV4* option, const QModelIndex& index, Tr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
drawRoundedButton( QPainter* painter, const QRect& btnRect, const QColor& color, const QColor &gradient1bottom, const QColor& gradient2top, const QColor& gradient2bottom )
|
||||||
|
{
|
||||||
|
QPainterPath btnPath;
|
||||||
|
const int radius = 3;
|
||||||
|
// draw top half gradient
|
||||||
|
const int btnCenter = btnRect.bottom() - ( btnRect.height() / 2 );
|
||||||
|
btnPath.moveTo( btnRect.left(), btnCenter );
|
||||||
|
btnPath.lineTo( btnRect.left(), btnRect.top() + radius );
|
||||||
|
btnPath.quadTo( QPoint( btnRect.topLeft() ), QPoint( btnRect.left() + radius, btnRect.top() ) );
|
||||||
|
btnPath.lineTo( btnRect.right() - radius, btnRect.top() );
|
||||||
|
btnPath.quadTo( QPoint( btnRect.topRight() ), QPoint( btnRect.right(), btnRect.top() + radius ) );
|
||||||
|
btnPath.lineTo( btnRect.right(),btnCenter );
|
||||||
|
btnPath.lineTo( btnRect.left(), btnCenter );
|
||||||
|
|
||||||
|
QLinearGradient g;
|
||||||
|
if ( gradient1bottom.isValid() )
|
||||||
|
{
|
||||||
|
g.setColorAt( 0, color );
|
||||||
|
g.setColorAt( 0.5, gradient1bottom );
|
||||||
|
painter->fillPath( btnPath, g );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
painter->fillPath( btnPath, color );
|
||||||
|
//painter->setPen( bg.darker() );
|
||||||
|
|
||||||
|
//painter->drawPath( btnPath );
|
||||||
|
|
||||||
|
btnPath = QPainterPath();
|
||||||
|
btnPath.moveTo( btnRect.left(), btnCenter );
|
||||||
|
btnPath.lineTo( btnRect.left(), btnRect.bottom() - radius );
|
||||||
|
btnPath.quadTo( QPoint( btnRect.bottomLeft() ), QPoint( btnRect.left() + radius, btnRect.bottom() ) );
|
||||||
|
btnPath.lineTo( btnRect.right() - radius, btnRect.bottom() );
|
||||||
|
btnPath.quadTo( QPoint( btnRect.bottomRight() ), QPoint( btnRect.right(), btnRect.bottom() - radius ) );
|
||||||
|
btnPath.lineTo( btnRect.right(), btnCenter );
|
||||||
|
btnPath.lineTo( btnRect.left(), btnCenter );
|
||||||
|
|
||||||
|
if ( gradient2top.isValid() && gradient2bottom.isValid() )
|
||||||
|
{
|
||||||
|
g.setColorAt( 0, gradient2top );
|
||||||
|
g.setColorAt( 0.5, gradient2bottom );
|
||||||
|
painter->fillPath( btnPath, g );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
painter->fillPath( btnPath, color );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // ns
|
} // ns
|
||||||
|
@@ -22,6 +22,8 @@
|
|||||||
|
|
||||||
#include <QSize>
|
#include <QSize>
|
||||||
#include <QModelIndex>
|
#include <QModelIndex>
|
||||||
|
#include <QColor>
|
||||||
|
#include <QRect>
|
||||||
|
|
||||||
#include "TomahawkUtils.h"
|
#include "TomahawkUtils.h"
|
||||||
#include "DllMacro.h"
|
#include "DllMacro.h"
|
||||||
@@ -29,11 +31,9 @@
|
|||||||
class TrackModelItem;
|
class TrackModelItem;
|
||||||
class QStyleOptionViewItemV4;
|
class QStyleOptionViewItemV4;
|
||||||
class QPainter;
|
class QPainter;
|
||||||
class QColor;
|
|
||||||
class QPixmap;
|
class QPixmap;
|
||||||
class QLayout;
|
class QLayout;
|
||||||
class QPalette;
|
class QPalette;
|
||||||
class QRect;
|
|
||||||
|
|
||||||
namespace TomahawkUtils
|
namespace TomahawkUtils
|
||||||
{
|
{
|
||||||
@@ -57,6 +57,7 @@ namespace TomahawkUtils
|
|||||||
|
|
||||||
DLLEXPORT void prepareStyleOption( QStyleOptionViewItemV4* option, const QModelIndex& index, TrackModelItem* item );
|
DLLEXPORT void prepareStyleOption( QStyleOptionViewItemV4* option, const QModelIndex& index, TrackModelItem* item );
|
||||||
|
|
||||||
|
DLLEXPORT void drawRoundedButton( QPainter* painter, const QRect& btnRect, const QColor& color, const QColor &gradient1bottom = QColor(), const QColor& gradient2top = QColor(), const QColor& gradient2bottom = QColor() );
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // TOMAHAWKUTILSGUI_H
|
#endif // TOMAHAWKUTILSGUI_H
|
||||||
|
Reference in New Issue
Block a user