void KNMusicStoreAlbumTreeView::onActionThemeUpdate()
{
    //Get the new palette from theme manager, and set it.
    setPalette(knTheme->getPalette(objectName()));
    //Update the palette.
    onActionMouseInOut(0);
}
Esempio n. 2
0
KNMusicTreeViewBase::KNMusicTreeViewBase(QWidget *parent) :
    QTreeView(parent)
{
    //Set properties.
    setAllColumnsShowFocus(true);
    setAlternatingRowColors(true);
    setContentsMargins(0,0,0,0);
    setDragDropMode(QAbstractItemView::DragOnly);
    setDropIndicatorShown(true);
    setFrameShape(QFrame::NoFrame);
    setIndentation(0);
    setMouseTracking(true);
    setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents);
    setSelectionBehavior(QAbstractItemView::SelectRows);
    setSelectionMode(QAbstractItemView::ExtendedSelection);
    setUniformRowHeights(true);
    setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);

    //Set scroll bar properties.
    horizontalScrollBar()->setSingleStep(5);
    horizontalScrollBar()->setPageStep(5);
    verticalScrollBar()->setSingleStep(4);
    verticalScrollBar()->setPageStep(4);

    //Using frame updater to set palette.
    onActionMouseInOut(0);

    //Set animation header.
    KNMusicTreeViewHeader *header=new KNMusicTreeViewHeader(this);
    connect(header, &KNMusicTreeViewHeader::requireResizeColumnToContents,
            this, &KNMusicTreeViewBase::resizeColumnToContents);
    setHeader(header);

    //Set delegate.
    setItemDelegateForColumn(Rating,
                             new KNMusicRatingDelegate(this));
    setItemDelegateForColumn(AlbumRating,
                             new KNMusicRatingDelegate(this));

    //Initial menu connections.
    m_soloConnections=new KNConnectionHandler(this);
    m_multiConnections=new KNConnectionHandler(this);

    //Initial mouse sense animation.
    m_mouseIn=new QTimeLine(200, this);
    configureTimeLine(m_mouseIn);
    m_mouseIn->setEndFrame(m_maxOpacity);
    m_mouseOut=new QTimeLine(200, this);
    configureTimeLine(m_mouseOut);
    m_mouseOut->setEndFrame(0);

    //Initial reacts.
    connect(this, &KNMusicTreeViewBase::activated,
            this, &KNMusicTreeViewBase::playIndex);

    //Initial actions.
    initialActions();
}
Esempio n. 3
0
void KNMusicDetailTooltip::onActionThemeChanged()
{
    //Backup the current brightness.
    int brightness=palette().color(QPalette::Window).value();
    //Set the latest palette.
    setPalette(knTheme->getPalette(objectName()));
    //Update the brightness.
    onActionMouseInOut(brightness);
}
Esempio n. 4
0
KNCategoryTabBar::KNCategoryTabBar(QWidget *parent) :
    KNAbstractTabGroup(parent),
    m_mouseIn(generateTimeLine(InBrightness)),
    m_mouseOut(generateTimeLine(OutBrightness)),
    m_mainLayout(new QBoxLayout(QBoxLayout::LeftToRight, this))
{
    setObjectName("CategoryTabBar");
    //Set properties.
    setAutoFillBackground(true);
    setContentsMargins(0,0,0,0);
    setFixedHeight(KNCategoryTab::tabHeight());

    //Set layout.
    m_mainLayout->setContentsMargins(0,0,0,0);
    m_mainLayout->setSpacing(0);
    setLayout(m_mainLayout);

    //Register the widget to theme manager.
    knTheme->registerWidget(this);
    //Update the palette using the frame function.
    onActionMouseInOut(OutBrightness);
}
Esempio n. 5
0
KNMusicDetailTooltip::KNMusicDetailTooltip(QWidget *parent) :
    KNMusicDetailTooltipBase(parent),
    m_fadeOutCounter(new QTimer(this)),
    m_mouseIn(generateTimeLine(0x50)),
    m_mouseOut(generateTimeLine(0x20)),
    m_albumArt(new KNMusicAlbumLabel(this)),
    m_playNPause(new KNOpacityButton(this)),
    m_progress(new KNProgressSlider(this)),
    m_playIcon(QIcon(":/plugin/music/player/play_light.png")),
    m_pauseIcon(QIcon(":/plugin/music/player/pause_light.png")),
    m_isPlaying(false),
    m_progressPressed(false),
    m_detailInfo(KNMusicDetailInfo())
{
    setObjectName("MusicDetailTooltip");
    //Set properties.
    setAutoFillBackground(true);
    setWindowFlags(Qt::ToolTip);
    setFixedSize(TooltipWidth, TooltipHeight);

    //Initial the main layout.
    QBoxLayout *mainLayout=new QBoxLayout(QBoxLayout::LeftToRight,
                                          this);
    mainLayout->setContentsMargins(11,11,11,11);
    mainLayout->setSpacing(6);
    setLayout(mainLayout);
    //Initial the album art.
    m_albumArt->setFixedSize(154, 154);
    mainLayout->addWidget(m_albumArt);
    //Generate the label container.
    QWidget *labelContainer=new QWidget(this);
    labelContainer->setContentsMargins(0,0,0,0);
    mainLayout->addWidget(labelContainer, 1);
    //Initial the label layout.
    QBoxLayout *labelLayout=new QBoxLayout(QBoxLayout::TopToBottom,
                                           mainLayout->widget());
    labelLayout->setContentsMargins(0,5,0,5);
    labelLayout->setSpacing(0);
    labelLayout->setSizeConstraint(QLayout::SetMaximumSize);
    labelContainer->setLayout(labelLayout);
    //Initial the detail info labels.
    for(int i=0; i<ToolTipItemsCount; i++)
    {
        //Initial the label.
        m_labels[i]=new KNScrollLabel(this);
        //Configure the label.
        m_labels[i]->setContentsMargins(0,0,0,0);
        //Resize the labels.
        m_labels[i]->setFixedWidth(LabelWidth);
        //Add the label to the layout.
        labelLayout->addWidget(m_labels[i]);
    }
    labelLayout->addStretch();
    //Configure the font of title.
    QFont nameFont=m_labels[ItemTitle]->font();
    nameFont.setBold(true);
    nameFont.setPixelSize(18);
    m_labels[ItemTitle]->setFont(nameFont);
    //Initial the preview player.
    QBoxLayout *previewPlayer=new QBoxLayout(QBoxLayout::LeftToRight,
                                             labelLayout->widget());
    previewPlayer->setContentsMargins(0,0,0,0);
    previewPlayer->setSpacing(0);
    labelLayout->addLayout(previewPlayer);
    //Configure preview player control button.
    m_playNPause->setFocusProxy(this);
    m_playNPause->setFixedSize(20, 20);
    m_playNPause->setIcon(m_playIcon);
    //Link clicked request.
    connect(m_playNPause, &KNOpacityButton::clicked,
            this, &KNMusicDetailTooltip::onActionPlayNPauseClicked);
    //Add to player layout.
    previewPlayer->addWidget(m_playNPause);
    //Configure the progress slider.
    m_progress->setMaximum(0);
    m_progress->setWheelStep(1000);
    m_progress->setFocusProxy(this);
    connect(m_progress, &KNProgressSlider::sliderPressed,
            [=]{m_progressPressed=true;});
    connect(m_progress, &KNProgressSlider::sliderReleased,
            [=]{m_progressPressed=false;});
    previewPlayer->addWidget(m_progress, 1);

    //Configure the timer.
    m_fadeOutCounter->setSingleShot(true);
    connect(m_fadeOutCounter, &QTimer::timeout,
            this, &KNMusicDetailTooltip::onActionHide);

    //Link the theme manager.
    connect(knTheme, &KNThemeManager::themeChange,
            this, &KNMusicDetailTooltip::onActionThemeChanged);
    //Initial the palette.
    onActionMouseInOut(0x20);
    //Update the theme.
    onActionThemeChanged();
}
KMMailComponentContactArea::KMMailComponentContactArea(QWidget *parent) :
    QScrollArea(parent),
    m_mouseAnime(new QTimeLine(200, this)),
    m_scrollBar(new QScrollBar(this)),
    m_contactList(nullptr),
    m_topShadow(new KNSideShadowWidget(KNSideShadowWidget::TopShadow,
                                       this)),
    m_bottomShadow(new KNSideShadowWidget(KNSideShadowWidget::BottomShadow,
                                          this))
{
    //Set properties.
    setFrameStyle(QFrame::NoFrame);
    //Configure the scroll bar policies.
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    //Initial the scroll bar.
    //Configure the scroll bar.
    m_scrollBar->hide();
    m_scrollBar->setStyle(KNSaoStyle::instance());
    m_scrollBar->setSingleStep(27);
    m_scrollBar->setPageStep(27);
    m_scrollBar->setObjectName("MailComponentScrollBar");
    connect(knTheme, &KNThemeManager::themeChange,
            [=]
            {
                //Get the new palette from theme manager, and set it.
                m_scrollBar->setPalette(knTheme->getPalette(
                                            m_scrollBar->objectName()));
                //Update the palette.
                onActionMouseInOut(0);
            });
    //Update the validation.
    m_scrollBar->setPalette(knTheme->getPalette(m_scrollBar->objectName()));
    onActionMouseInOut(0);
    //Configure the shadow widget.
    m_topShadow->hide();
    m_bottomShadow->hide();

    //Update the single step.
    verticalScrollBar()->setSingleStep(27);

    connect(verticalScrollBar(), &QScrollBar::rangeChanged,
            this, &KMMailComponentContactArea::onActionRangeChange);
    connect(verticalScrollBar(), &QScrollBar::valueChanged,
            [=](int value)
            {
                //Block the signal.
                m_scrollBar->blockSignals(true);
                //Reset the value.
                m_scrollBar->setValue(value);
                //Release the block
                m_scrollBar->blockSignals(false);
                //Update shadow opacity.
                updateShadow(value);
            });
    connect(m_scrollBar, &QScrollBar::valueChanged,
            verticalScrollBar(), &QScrollBar::setValue);

    //Configure the time line.
    m_mouseAnime->setEasingCurve(QEasingCurve::OutCubic);
    m_mouseAnime->setUpdateInterval(10);
    //Link the time line.
    connect(m_mouseAnime, &QTimeLine::frameChanged,
            this, &KMMailComponentContactArea::onActionMouseInOut);
}