Git commit db29d3a738342df25c18c7e527f4a12df487ad83 by Michael Pyne. Committed on 30/09/2017 at 14:49. Pushed by mpyne into branch 'frameworks'. Port systemtray.cpp away from K{H,V}Box. M +45 -33 systemtray.cpp M +6 -9 systemtray.h https://commits.kde.org/juk/db29d3a738342df25c18c7e527f4a12df487ad83 diff --git a/systemtray.cpp b/systemtray.cpp index 96e3e6b..28b16a8 100644 --- a/systemtray.cpp +++ b/systemtray.cpp @@ -20,13 +20,12 @@ = #include #include -#include #include #include -#include -#include #include = +#include +#include #include #include #include @@ -34,7 +33,6 @@ #include #include #include -#include #include #include #include // Qt::escape() @@ -48,7 +46,7 @@ using namespace ActionCollection; = PassiveInfo::PassiveInfo() : - QFrame(static_cast(0), + QFrame(nullptr, Qt::ToolTip | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint ), m_timer(new QTimer(this)), @@ -319,27 +317,28 @@ void SystemTray::slotMouseInPopup() // private methods //////////////////////////////////////////////////////////////////////////= ////// = -KVBox *SystemTray::createPopupLayout(QWidget *parent, const FileHandle &fi= le) +QWidget *SystemTray::createInfoBox(QBoxLayout *parentLayout, const FileHan= dle &file) { - KVBox *infoBox =3D 0; - // We always show the popup on the right side of the current screen, so - // this logic assumes that. Earlier revisions has logic for popup bei= ng + // this logic assumes that. Earlier revisions had logic for popup bei= ng // wherever the systray icon is, so if it's decided to go that route a= gain, // dig into the source control history. --mpyne = if(file.coverInfo()->hasCover()) { - addCoverButton(parent, file.coverInfo()->pixmap(CoverInfo::Thumbna= il)); - addSeparatorLine(parent); + addCoverButton(parentLayout, file.coverInfo()->pixmap(CoverInfo::T= humbnail)); + addSeparatorLine(parentLayout); } = - infoBox =3D new KVBox(parent); + auto infoBox =3D new QWidget; + auto infoBoxVLayout =3D new QVBoxLayout(infoBox); + infoBoxVLayout->setSpacing(3); + infoBoxVLayout->setMargin(3); + + parentLayout->addWidget(infoBox); = - addSeparatorLine(parent); - createButtonBox(parent); + addSeparatorLine(parentLayout); + createButtonBox(parentLayout); = - infoBox->setSpacing(3); - infoBox->setMargin(3); return infoBox; } = @@ -368,15 +367,19 @@ void SystemTray::createPopup() connect(m_popup, SIGNAL(nextSong()), SLOT(slotForward())); connect(m_popup, SIGNAL(previousSong()), SLOT(slotBack())); = - KHBox *box =3D new KHBox(m_popup); - box->setSpacing(15); // Add space between text and buttons + auto box =3D new QWidget; + auto boxHLayout =3D new QHBoxLayout(box); = - KVBox *infoBox =3D createPopupLayout(box, playingFile); + boxHLayout->setSpacing(15); // Add space between text and buttons + + QWidget *infoBox =3D createInfoBox(boxHLayout, playingFile); + QLayout *infoBoxLayout =3D infoBox->layout(); = for(int i =3D 0; i < m_labels.size(); ++i) { - QLabel *l =3D new QLabel(" ", infoBox); + QLabel *l =3D new QLabel(" "); l->setAlignment(Qt::AlignRight | Qt::AlignVCenter); m_labels[i] =3D l; + infoBoxLayout->addWidget(l); } = // We have to set the text of the labels after all of the @@ -403,19 +406,24 @@ void SystemTray::createPopup() m_popup->show(); } = -void SystemTray::createButtonBox(QWidget *parent) +void SystemTray::createButtonBox(QBoxLayout *parentLayout) { - KVBox *buttonBox =3D new KVBox(parent); + auto buttonBox =3D new QWidget; + auto buttonBoxVLayout =3D new QVBoxLayout(buttonBox); = - buttonBox->setSpacing(3); + buttonBoxVLayout->setSpacing(3); = - QPushButton *forwardButton =3D new QPushButton(m_forwardPix, 0, button= Box); - forwardButton->setObjectName( QLatin1String("popup_forward" )); + QPushButton *forwardButton =3D new QPushButton(m_forwardPix, QString()= ); + forwardButton->setObjectName(QLatin1String("popup_forward")); connect(forwardButton, SIGNAL(clicked()), SLOT(slotForward())); = - QPushButton *backButton =3D new QPushButton(m_backPix, 0, buttonBox); - backButton->setObjectName( QLatin1String("popup_back" )); + QPushButton *backButton =3D new QPushButton(m_backPix, QString()); + backButton->setObjectName(QLatin1String("popup_back")); connect(backButton, SIGNAL(clicked()), SLOT(slotBack())); + + buttonBoxVLayout->addWidget(forwardButton); + buttonBoxVLayout->addWidget(backButton); + parentLayout->addWidget(buttonBox); } = /** @@ -435,20 +443,22 @@ void SystemTray::slotForward() m_fade =3D false; } = -void SystemTray::addSeparatorLine(QWidget *parent) +void SystemTray::addSeparatorLine(QBoxLayout *parentLayout) { - QFrame *line =3D new QFrame(parent); + QFrame *line =3D new QFrame; line->setFrameShape(QFrame::VLine); = // Cover art takes up 80 pixels, make sure we take up at least 80 pixe= ls // even if we don't show the cover art for consistency. = line->setMinimumHeight(80); + + parentLayout->addWidget(line); } = -void SystemTray::addCoverButton(QWidget *parent, const QPixmap &cover) +void SystemTray::addCoverButton(QBoxLayout *parentLayout, const QPixmap &c= over) { - QPushButton *coverButton =3D new QPushButton(parent); + QPushButton *coverButton =3D new QPushButton; = coverButton->setIconSize(cover.size()); coverButton->setIcon(cover); @@ -456,6 +466,8 @@ void SystemTray::addCoverButton(QWidget *parent, const = QPixmap &cover) coverButton->setFlat(true); = connect(coverButton, SIGNAL(clicked()), this, SLOT(slotPopupLargeCover= ())); + + parentLayout->addWidget(coverButton); } = QColor SystemTray::interpolateColor(int step, int steps) @@ -469,9 +481,9 @@ QColor SystemTray::interpolateColor(int step, int steps) // make sense to go rather quickly from start to end and then slow down // the progression. return QColor( - (step * m_endColor.red() + (steps - step) * m_startColor.red()= ) / steps, + (step * m_endColor.red() + (steps - step) * m_startColor.red= ()) / steps, (step * m_endColor.green() + (steps - step) * m_startColor.gre= en()) / steps, - (step * m_endColor.blue() + (steps - step) * m_startColor.blue= ()) / steps + (step * m_endColor.blue() + (steps - step) * m_startColor.blu= e()) / steps ); } = diff --git a/systemtray.h b/systemtray.h index b02d259..dc313c0 100644 --- a/systemtray.h +++ b/systemtray.h @@ -26,14 +26,13 @@ #include #include #include +#include = class SystemTray; class PlayerManager; class QLabel; class QTimer; -class KVBox; class FileHandle; -class QVBoxLayout; = /** * Workalike of KPassivePopup intended to more easily support JuK's partic= ular @@ -102,15 +101,13 @@ private: void createPopup(); void setToolTip(const QString &tip =3D QString(), const QPixmap &cover= =3D QPixmap()); = - void createButtonBox(QWidget *parent); - - // Creates the widget layout for the popup, returning the QVBox that + // Creates the widget layout for the popup, returning the QWidget that // holds the text labels. = - KVBox *createPopupLayout(QWidget *parent, const FileHandle &file); - - void addSeparatorLine(QWidget *parent); - void addCoverButton(QWidget *parent, const QPixmap &cover); + QWidget *createInfoBox(QBoxLayout *parentLayout, const FileHandle &fil= e); + void addSeparatorLine(QBoxLayout *parentLayout); + void addCoverButton(QBoxLayout *parentLayout, const QPixmap &cover); + void createButtonBox(QBoxLayout *parentLayout); = // Interpolates from start color to end color. If @p step =3D=3D 0, t= hen // m_startColor is returned, while @p step =3D=3D @steps returns