KNLinearSenseWidget::KNLinearSenseWidget(QWidget *parent) : QWidget(parent), m_highLight(QLinearGradient(QPoint(0,0), QPoint(0, height()))), m_highLightColor(QColor(255,255,255,0)), m_mouseIn(generateTimeLine(maximumBrightness)), m_mouseOut(generateTimeLine(0)) { //Set properties. setAutoFillBackground(true); //Initial the gradient background color and mouse timeline. m_highLightColor.setAlpha(0); m_highLight.setColorAt(0, m_highLightColor); m_highLightColor.setAlpha(minimalBrightness); m_highLight.setColorAt(1, m_highLightColor); }
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); }
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(); }