Commit e1501c23 authored by Michael Pyne's avatar Michael Pyne

* Move the buttons in the track announcement popup depending on what side of...

* Move the buttons in the track announcement popup depending on what side of the JuK icon the popup will appear.  This means that the buttons shouldn't move if you click Next or Previous now, no matter where the tray icon is.
* I altered some of my earlier code to conform to the style guide while I was working on the file.

svn path=/trunk/kdemultimedia/juk/; revision=313903
parent b576d5ef
......@@ -20,6 +20,7 @@
#include <kiconeffect.h>
#include <kaction.h>
#include <kpopupmenu.h>
#include <kglobalsettings.h>
#include <kdebug.h>
#include <qhbox.h>
......@@ -124,6 +125,20 @@ void SystemTray::createPopup(bool addButtons)
QHBox *box = new QHBox(m_popup);
box->setSpacing(15); // Add space between text and buttons
// See where to put the buttons
bool onLeft = buttonsToLeft();
QVBox *buttonBox;
if(onLeft) {
// They go to the left because JuK is on that side
buttonBox = new QVBox(box);
buttonBox->setSpacing(3);
// Separator line
QFrame *line = new QFrame(box);
line->setFrameShape(QFrame::VLine);
}
QVBox *infoBox = new QVBox(box);
infoBox->setSpacing(3);
......@@ -145,8 +160,7 @@ void SystemTray::createPopup(bool addButtons)
// Artist info
QString artistStr = playingInfo->artist();
QLabel *artist = 0;
if(!artistStr.isEmpty())
{
if(!artistStr.isEmpty()) {
artist = new QLabel(infoBox);
artist->setAlignment(AlignRight | AlignVCenter);
}
......@@ -156,8 +170,7 @@ void SystemTray::createPopup(bool addButtons)
// Album info
QString albumStr = playingInfo->album();
QLabel *album = 0;
if(!albumStr.isEmpty())
{
if(!albumStr.isEmpty()) {
int year = playingInfo->year();
// See if there is a year.
......@@ -170,8 +183,7 @@ void SystemTray::createPopup(bool addButtons)
else
++numSpacers;
for( ; numSpacers != 0; --numSpacers)
{
for( ; numSpacers != 0; --numSpacers) {
// Add an empty label. QSpacerItems weren't working for
// me for some reason. QBoxLayout->addSpacing() wasn't
// either. mpyne :-(
......@@ -179,12 +191,14 @@ void SystemTray::createPopup(bool addButtons)
}
if(addButtons) {
// Add separator line
QFrame *line = new QFrame(box);
line->setFrameShape(QFrame::VLine);
QVBox *buttonBox = new QVBox(box);
buttonBox->setSpacing(3);
if(!onLeft) {
// Add separator line
QFrame *line = new QFrame(box);
line->setFrameShape(QFrame::VLine);
buttonBox = new QVBox(box);
buttonBox->setSpacing(3);
}
QPushButton *backButton = new QPushButton(m_backPix, 0, buttonBox, "popup_back");
backButton->setFlat(true);
......@@ -213,6 +227,17 @@ void SystemTray::createPopup(bool addButtons)
}
}
bool SystemTray::buttonsToLeft() const
{
QPoint center = mapToGlobal(geometry().center());
QRect bounds = KGlobalSettings::desktopGeometry(center);
int middle = bounds.center().x();
// This seems to accurately guess what side of the icon that
// KPassivePopup will popup on.
return((center.x() - (width() / 2)) < middle);
}
QPixmap SystemTray::createPixmap(const QString &pixName)
{
QPixmap buffer(m_appPix.width(), m_appPix.height());
......
......@@ -36,6 +36,7 @@ private:
void createPopup(bool addButtons = true);
void setToolTip(const QString &tip = QString::null);
void mousePressEvent(QMouseEvent *e);
bool buttonsToLeft() const;
QPixmap createPixmap(const QString &pixName);
private slots:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment