void CreateEditPage::createContent(void) { MApplicationPage::createContent(); setStyleName("CommonApplicationPage"); setPannable(false); createActions(); QGraphicsAnchorLayout *anchor = new QGraphicsAnchorLayout(); anchor->setContentsMargins(0, 0, 0, 0); anchor->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); ViewHeader *header = new ViewHeader(m_tag == TagStorage::NULL_TAG ? tr("Create tag contents") : tr("Edit tag contents")); anchor->addCornerAnchors(header, Qt::TopLeftCorner, anchor, Qt::TopLeftCorner); #ifdef LABEL_SIZE m_size = new MLabel(); m_size->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); m_size->setAlignment(Qt::AlignRight); anchor->addAnchor(m_size, Qt::AnchorBottom, anchor, Qt::AnchorBottom); anchor->addAnchor(m_size, Qt::AnchorRight, anchor, Qt::AnchorRight); #endif MWidget *layoutContainer = new MWidget(); layoutContainer->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); m_layout = new QGraphicsLinearLayout(Qt::Vertical, layoutContainer); m_layout->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); m_name = new LabeledTextEdit(tr("Ok"), LabeledTextEdit::SingleLineEditAndLabel); m_name->setLabel(tr("Tag name")); m_name->setPrompt(tr("Enter tag name")); m_name->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); m_layout->addItem(m_name); m_layout->setAlignment(m_name, Qt::AlignLeft); connect(m_name, SIGNAL(contentsChanged(void)), this, SLOT(nameChanged(void))); MSeparator *sep = new MSeparator; sep->setStyleName("CommonHorizontalSeparator"); sep->setOrientation(Qt::Horizontal); layout()->addItem(sep); createPageSpecificContent(); MPannableViewport *view = new MPannableViewport(); view->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum); view->setPanDirection(Qt::Vertical); view->setMinimumSize(100, 100); view->setWidget(layoutContainer); anchor->addAnchor(view, Qt::AnchorTop, header, Qt::AnchorBottom); #ifdef LABEL_SIZE anchor->addAnchor(view, Qt::AnchorBottom, m_size, Qt::AnchorTop); #else anchor->addAnchor(view, Qt::AnchorBottom, anchor, Qt::AnchorBottom); #endif anchor->addAnchor(view, Qt::AnchorLeft, anchor, Qt::AnchorLeft); anchor->addAnchor(view, Qt::AnchorRight, anchor, Qt::AnchorRight); centralWidget()->setLayout(anchor); if (m_tag == TagStorage::NULL_TAG) { setContentValidity(false); setNameValidity(false); setupNewData(); } else { load(); } }
void CurrentTrack::init() { DEBUG_BLOCK PERF_LOG( "Begin init" ); // Call the base implementation. Context::Applet::init(); setToolTip( i18n( "Right-click to configure" ) ); m_ratingWidget = new RatingWidget( this ); m_ratingWidget->setSpacing( 2 ); m_ratingWidget->setMinimumSize( m_albumWidth + 10, 30 ); m_ratingWidget->setMaximumSize( m_albumWidth + 10, 30 ); connect( m_ratingWidget, SIGNAL(ratingChanged(int)), SLOT(trackRatingChanged(int)) ); QLabel *collectionLabel = new QLabel( i18n( "Local Collection" ) ); collectionLabel->setAttribute( Qt::WA_NoSystemBackground ); collectionLabel->setAlignment( Qt::AlignCenter ); m_collectionLabel = new QGraphicsProxyWidget( this ); m_collectionLabel->setWidget( collectionLabel ); m_title = new TextScrollingWidget( this ); m_artist = new TextScrollingWidget( this ); m_album = new TextScrollingWidget( this ); m_byText = new QGraphicsSimpleTextItem( i18nc( "What artist is this track by", "By" ), this ); m_onText = new QGraphicsSimpleTextItem( i18nc( "What album is this track on", "On" ), this ); m_recentWidget = new RecentlyPlayedListWidget( this ); m_recentHeader = new TextScrollingWidget( this ); m_recentHeader->setDrawBackground( true ); m_recentHeader->setAlignment( Qt::AlignLeft ); QFont recentHeaderFont; recentHeaderFont.setPointSize( recentHeaderFont.pointSize() + 2 ); m_recentHeader->setFont( recentHeaderFont ); m_title->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); m_artist->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); m_album->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); m_collectionLabel->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); m_recentHeader->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); m_recentWidget->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); m_recentWidget->setMinimumHeight( 10 ); m_albumCover = new DropPixmapLayoutItem( this ); m_albumCover->setPreferredSize( QSizeF( m_albumWidth, m_albumWidth ) ); connect( m_albumCover, SIGNAL(imageDropped(QPixmap)), SLOT(coverDropped(QPixmap)) ); const QBrush brush = normalBrush(); m_title->setBrush( brush ); m_artist->setBrush( brush ); m_album->setBrush( brush ); m_byText->setBrush( brush ); m_onText->setBrush( brush ); const QFont tinyFont = KGlobalSettings::smallestReadableFont(); m_byText->setFont( tinyFont ); m_onText->setFont( tinyFont ); m_actionsLayout = new QGraphicsLinearLayout; m_actionsLayout->setMinimumWidth( 10 ); m_actionsLayout->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); QGraphicsLinearLayout *titlesLayout = new QGraphicsLinearLayout( Qt::Vertical ); titlesLayout->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); titlesLayout->setMinimumWidth( 10 ); titlesLayout->setSpacing( 2 ); titlesLayout->addItem( m_title ); titlesLayout->addItem( m_artist ); titlesLayout->addItem( m_album ); titlesLayout->addItem( m_actionsLayout ); titlesLayout->setItemSpacing( 2, 4 ); // a bit more spacing for the actions row const qreal pad = standardPadding(); QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout( this ); l->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); l->addCornerAnchors( m_ratingWidget, Qt::BottomLeftCorner, l, Qt::BottomLeftCorner ); l->addCornerAnchors( m_ratingWidget, Qt::BottomLeftCorner, m_collectionLabel, Qt::BottomLeftCorner ); l->addCornerAnchors( m_ratingWidget, Qt::TopRightCorner, m_collectionLabel, Qt::TopRightCorner ); l->addCornerAnchors( m_recentHeader, Qt::TopRightCorner, l, Qt::TopRightCorner ); l->addAnchor( m_albumCover, Qt::AnchorBottom, m_ratingWidget, Qt::AnchorTop )->setSpacing( 4 ); l->addAnchor( m_albumCover, Qt::AnchorHorizontalCenter, m_ratingWidget, Qt::AnchorHorizontalCenter ); l->addAnchor( titlesLayout, Qt::AnchorTop, l, Qt::AnchorTop )->setSpacing( 18 ); l->addAnchor( titlesLayout, Qt::AnchorRight, l, Qt::AnchorRight )->setSpacing( pad ); l->addAnchors( m_recentWidget, m_recentHeader, Qt::Horizontal ); l->addAnchor( m_recentWidget, Qt::AnchorTop, m_recentHeader, Qt::AnchorBottom ); l->addAnchor( m_recentWidget, Qt::AnchorRight, m_recentHeader, Qt::AnchorRight ); l->addAnchor( m_recentWidget, Qt::AnchorLeft, m_ratingWidget, Qt::AnchorRight )->setSpacing( pad * 2 ); l->addAnchor( m_recentWidget, Qt::AnchorBottom, m_albumCover, Qt::AnchorBottom )->setSpacing( 20 ); qreal midSpacing = qMax( m_byText->boundingRect().width(), m_onText->boundingRect().width() ) + pad; l->addAnchor( titlesLayout, Qt::AnchorLeft, m_ratingWidget, Qt::AnchorRight )->setSpacing( midSpacing ); l->anchor( m_recentHeader, Qt::AnchorTop, l, Qt::AnchorTop )->setSpacing( 2 ); // Read config KConfigGroup config = Amarok::config("Current Track Applet"); const QString fontDesc = config.readEntry( "Font", QString() ); QFont font; if( !fontDesc.isEmpty() ) font.fromString( fontDesc ); else font.setPointSize( font.pointSize() + 3 ); m_showEditTrackDetailsAction = config.readEntry( "ShowEditTrackAction", true ); m_title->setFont( font ); m_artist->setFont( font ); m_album->setFont( font ); m_title->setAlignment( Qt::AlignLeft ); m_artist->setAlignment( Qt::AlignLeft ); m_album->setAlignment( Qt::AlignLeft ); dataEngine( "amarok-current" )->setProperty( "coverWidth", m_albumWidth ); dataEngine( "amarok-current" )->connectSource( "current", this ); connect( The::paletteHandler(), SIGNAL(newPalette(QPalette)), SLOT(paletteChanged(QPalette)) ); connect( CollectionManager::instance(), SIGNAL(collectionDataChanged(Collections::Collection*)), this, SLOT(queryCollection()), Qt::QueuedConnection ); queryCollection(); setView( Stopped ); PERF_LOG( "Finished init" ); }