OTHER: add Equalizer shade pixmaps.

For now the equalizer shade mode is without any function, only the background
image is displayed.
This change disables skins that have no eq_ex bitmap.
This commit is contained in:
Thomas Frauendorfer 2010-03-22 13:51:41 +01:00
parent 7614e9ed81
commit b4e5959f2d
9 changed files with 180 additions and 11 deletions

View file

@ -0,0 +1,73 @@
/**
* This file is a part of Promoe, an XMMS2 Client.
*
* Copyright (C) 2010 XMMS2 Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "equalizershade.h"
#include <QPainter>
#include <QPaintEvent>
#include <QMouseEvent>
#include "skin.h"
#include "skinmanager.h"
#include "equalizerwindow.h"
EqualizerShade::EqualizerShade (EqualizerWindow *parent) : QWidget (parent),
m_active (false)
{
setFixedSize (275, 14);
Skin *skin = SkinManager::instance ()->activeSkin ();
connect (SkinManager::instance (), SIGNAL (skinChanged (Skin *)),
this, SLOT (setPixmaps(Skin *)));
}
void
EqualizerShade::setPixmaps (Skin *skin)
{
p_active = skin->getItem (Skin::EQ_WIN_SHADE_ACTIVE);
p_inactive = skin->getItem (Skin::EQ_WIN_SHADE_INACTIVE);
update ();
}
void
EqualizerShade::mouseDoubleClickEvent (QMouseEvent *event)
{
EqualizerWindow *ew = dynamic_cast<EqualizerWindow *>(window ());
ew->switchDisplay ();
}
void
EqualizerShade::paintEvent (QPaintEvent *event)
{
QPainter p(this);
if (m_active) {
p.drawPixmap (rect (), p_active, p_active.rect ());
} else {
p.drawPixmap (rect (), p_inactive, p_inactive.rect ());
}
}
void
EqualizerShade::setActive (bool active)
{
m_active = active;
update ();
}
#include "equalizershade.moc"

View file

@ -0,0 +1,49 @@
/**
* This file is a part of Promoe, an XMMS2 Client.
*
* Copyright (C) 2010 XMMS2 Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef __EQUALIZERSHADE_H__
#define __EQUALIZERSHADE_H__
#include <QWidget>
#include <QPixmap>
class QPaintEvent;
class QMouseEvent;
class EqualizerWindow;
class Skin;
class EqualizerShade : public QWidget
{
Q_OBJECT
public:
EqualizerShade (EqualizerWindow *parent);
void paintEvent (QPaintEvent *event);
void mouseDoubleClickEvent (QMouseEvent *event);
void setActive (bool);
public slots:
void setPixmaps (Skin *);
private:
bool m_active;
QPixmap p_active;
QPixmap p_inactive;
};
#endif

View file

@ -24,10 +24,12 @@
#include "pixmapslider.h" #include "pixmapslider.h"
#include "skin.h" #include "skin.h"
#include "skinmanager.h" #include "skinmanager.h"
#include "equalizerwindow.h"
#include <QPainter> #include <QPainter>
#include <QMessageBox> #include <QMessageBox>
#include <QMouseEvent>
EqualizerSlider::EqualizerSlider (QWidget *parent, int id) : EqualizerSlider::EqualizerSlider (QWidget *parent, int id) :
PixmapSlider (parent) PixmapSlider (parent)
@ -121,6 +123,8 @@ EqualizerWidget::EqualizerWidget (QWidget *parent) : QWidget (parent)
if (m_xconfig->isReady()) { if (m_xconfig->isReady()) {
loadServerConfig (); loadServerConfig ();
} }
setFixedSize (275, 116);
} }
EqualizerWidget::~EqualizerWidget (void) EqualizerWidget::~EqualizerWidget (void)
@ -177,6 +181,15 @@ EqualizerWidget::setActive (bool active)
update (); update ();
} }
void
EqualizerWidget::mouseDoubleClickEvent (QMouseEvent *event)
{
EqualizerWindow *ew = dynamic_cast<EqualizerWindow *>(window ());
if (event->y() < 14) {
ew->switchDisplay ();
}
}
void void
EqualizerWidget::paintEvent (QPaintEvent *event) EqualizerWidget::paintEvent (QPaintEvent *event)
{ {

View file

@ -21,6 +21,7 @@ class QString;
class QVariant; class QVariant;
class QPixmap; class QPixmap;
class QPaintEvent; class QPaintEvent;
class QMouseEvent;
#include "pixmapslider.h" #include "pixmapslider.h"
class XConfig; class XConfig;
@ -56,6 +57,7 @@ class EqualizerWidget : public QWidget
void setActive (bool); void setActive (bool);
void paintEvent (QPaintEvent *event); void paintEvent (QPaintEvent *event);
void mouseDoubleClickEvent (QMouseEvent *event);
public slots: public slots:
void setPixmaps(Skin *skin); void setPixmaps(Skin *skin);

View file

@ -20,27 +20,36 @@
#include "mainwindow.h" #include "mainwindow.h"
#include "equalizerwidget.h" #include "equalizerwidget.h"
#include "equalizershade.h"
EqualizerWindow::EqualizerWindow (QWidget *parent) : BaseWindow (parent) EqualizerWindow::EqualizerWindow (QWidget *parent) : BaseWindow (parent)
{ {
setObjectName ("equalizer"); setObjectName ("equalizer");
m_mw = dynamic_cast<MainWindow *>(parent);
setWindowFlags (Qt::Dialog | Qt::FramelessWindowHint); setWindowFlags (Qt::Dialog | Qt::FramelessWindowHint);
setAttribute (Qt::WA_DeleteOnClose); setAttribute (Qt::WA_DeleteOnClose);
m_equalizer = new EqualizerWidget (this); QSettings s;
m_equalizer->show(); s.beginGroup (objectName ());
m_equalizer = new EqualizerWidget (this);
m_shaded = new EqualizerShade (this);
setCentralWidget (m_equalizer); setCentralWidget (m_equalizer);
setFixedSize (275, 116); if (!s.contains ("shaded"))
s.setValue ("shaded", false);
else
s.setValue ("shaded", !s.value("shaded").toBool ());
switchDisplay ();
s.endGroup ();
} }
void void
EqualizerWindow::activeWindowInEvent (QEvent *event) EqualizerWindow::activeWindowInEvent (QEvent *event)
{ {
m_equalizer->setActive (true); m_equalizer->setActive (true);
m_shaded->setActive (true);
BaseWindow::activeWindowInEvent (event); BaseWindow::activeWindowInEvent (event);
} }
@ -48,13 +57,29 @@ void
EqualizerWindow::activeWindowOutEvent (QEvent *event) EqualizerWindow::activeWindowOutEvent (QEvent *event)
{ {
m_equalizer->setActive (false); m_equalizer->setActive (false);
m_shaded->setActive (false);
BaseWindow::activeWindowOutEvent (event); BaseWindow::activeWindowOutEvent (event);
} }
void void
EqualizerWindow::switchDisplay (void) EqualizerWindow::switchDisplay (void)
{ {
qDebug("switchDisplay not implemented for equalizer"); QSettings s;
s.beginGroup (objectName ());
if (s.value("shaded").toBool ()) {
m_shaded->hide ();
m_equalizer->show ();
setFixedSize (m_equalizer->size ());
s.setValue ("shaded", false);
} else {
m_equalizer->hide ();
m_shaded->show ();
setFixedSize (m_shaded->size ());
s.setValue ("shaded", true);
}
s.endGroup ();
} }
#include "equalizerwindow.moc" #include "equalizerwindow.moc"

View file

@ -21,6 +21,7 @@
class QWidget; class QWidget;
class MainWindow; class MainWindow;
class EqualizerWidget; class EqualizerWidget;
class EqualizerShade;
class EqualizerWindow : public BaseWindow class EqualizerWindow : public BaseWindow
{ {
@ -37,8 +38,8 @@ class EqualizerWindow : public BaseWindow
void activeWindowOutEvent (QEvent *event); void activeWindowOutEvent (QEvent *event);
private: private:
MainWindow *m_mw;
EqualizerWidget *m_equalizer; EqualizerWidget *m_equalizer;
EqualizerShade *m_shaded;
}; };
#endif // __EQUALIZERWINDOW_H__ #endif // __EQUALIZERWINDOW_H__

View file

@ -132,7 +132,7 @@ PlaylistShade::setActive (bool b)
update (); update ();
} }
void void
PlaylistShade::mouseDoubleClickEvent (QMouseEvent *event) PlaylistShade::mouseDoubleClickEvent (QMouseEvent *event)
{ {
PlaylistWindow *pw = dynamic_cast<PlaylistWindow*>(window ()); PlaylistWindow *pw = dynamic_cast<PlaylistWindow*>(window ());

View file

@ -517,6 +517,9 @@ Skin::handle_eq_ex (const QPixmap &img)
if (img.isNull ()) if (img.isNull ())
return false; return false;
m_items[EQ_WIN_SHADE_ACTIVE] = img.copy (0, 0, 275, 14);
m_items[EQ_WIN_SHADE_INACTIVE] = img.copy (0, 15, 275, 14);
m_buttons[BUTTON_EQ_SHADE].addPixmap (img.copy ( 1, 38, 9, 9), m_buttons[BUTTON_EQ_SHADE].addPixmap (img.copy ( 1, 38, 9, 9),
PBPixmaps::Pressed); PBPixmaps::Pressed);
@ -702,8 +705,8 @@ Skin::setSkin (const QString& path)
bool b_main = false, b_titlebar = false, b_posbar = false, b_volume = false; bool b_main = false, b_titlebar = false, b_posbar = false, b_volume = false;
bool b_balance = false, b_cbuttons = false, b_monoster = false; bool b_balance = false, b_cbuttons = false, b_monoster = false;
bool b_playpaus = false, b_shufrep = false, b_text = false; bool b_playpaus = false, b_shufrep = false, b_text = false;
bool b_numbers = false, b_eqmain = false, b_pledit = false; bool b_numbers = false, b_eqmain = false, b_eq_ex = false;
bool b_pledit_txt = false; bool b_pledit = false, b_pledit_txt = false;
QPixmap p_eq_ex; QPixmap p_eq_ex;
QPixmap p_numbers; QPixmap p_numbers;
@ -778,12 +781,12 @@ Skin::setSkin (const QString& path)
// handle_eq_ex must be called after handle_eqmain // handle_eq_ex must be called after handle_eqmain
if (b_eqmain) { if (b_eqmain) {
handle_eq_ex (p_eq_ex); b_eq_ex = handle_eq_ex (p_eq_ex);
} }
if (!(b_main && b_titlebar && b_posbar && b_volume && b_cbuttons && if (!(b_main && b_titlebar && b_posbar && b_volume && b_cbuttons &&
b_monoster && b_playpaus && b_shufrep && b_text && b_numbers && b_monoster && b_playpaus && b_shufrep && b_text && b_numbers &&
b_eqmain && b_pledit && b_pledit_txt)) { b_eqmain && b_eq_ex && b_pledit && b_pledit_txt)) {
// Some debug information to find out why a skin failed to load // Some debug information to find out why a skin failed to load
QStringList list; QStringList list;
@ -798,6 +801,7 @@ Skin::setSkin (const QString& path)
if (!b_text) { list << "text"; } if (!b_text) { list << "text"; }
if (!b_numbers) { list << "numbers/nums_ex"; } if (!b_numbers) { list << "numbers/nums_ex"; }
if (!b_eqmain) { list << "equmain"; } if (!b_eqmain) { list << "equmain"; }
if (!b_eq_ex) { list << "eq_ex"; }
if (!b_pledit) { list << "pledit"; } if (!b_pledit) { list << "pledit"; }
if (!b_pledit_txt) { list << "pledit.txt"; } if (!b_pledit_txt) { list << "pledit.txt"; }

View file

@ -189,6 +189,8 @@ class Skin : public QObject
EQ_WIN_GRAPH_BG, EQ_WIN_GRAPH_BG,
EQ_WIN_BAR_BTN_0, EQ_WIN_BAR_BTN_0,
EQ_WIN_BAR_BTN_1, EQ_WIN_BAR_BTN_1,
EQ_WIN_SHADE_ACTIVE,
EQ_WIN_SHADE_INACTIVE,
POSBAR, POSBAR,
}; };