From b4e5959f2da22df93117e0cf14e563a45ba07762 Mon Sep 17 00:00:00 2001 From: Thomas Frauendorfer Date: Mon, 22 Mar 2010 13:51:41 +0100 Subject: [PATCH] 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. --- src/equalizer/equalizershade.cpp | 73 +++++++++++++++++++++++++++++++ src/equalizer/equalizershade.h | 49 +++++++++++++++++++++ src/equalizer/equalizerwidget.cpp | 13 ++++++ src/equalizer/equalizerwidget.h | 2 + src/equalizer/equalizerwindow.cpp | 35 ++++++++++++--- src/equalizer/equalizerwindow.h | 3 +- src/playlist/playlistshade.cpp | 2 +- src/skin/skin.cpp | 12 +++-- src/skin/skin.h | 2 + 9 files changed, 180 insertions(+), 11 deletions(-) create mode 100644 src/equalizer/equalizershade.cpp create mode 100644 src/equalizer/equalizershade.h diff --git a/src/equalizer/equalizershade.cpp b/src/equalizer/equalizershade.cpp new file mode 100644 index 0000000..aae8569 --- /dev/null +++ b/src/equalizer/equalizershade.cpp @@ -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 +#include +#include + +#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(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" diff --git a/src/equalizer/equalizershade.h b/src/equalizer/equalizershade.h new file mode 100644 index 0000000..9603174 --- /dev/null +++ b/src/equalizer/equalizershade.h @@ -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 +#include + +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 diff --git a/src/equalizer/equalizerwidget.cpp b/src/equalizer/equalizerwidget.cpp index 6202af8..34ef5de 100644 --- a/src/equalizer/equalizerwidget.cpp +++ b/src/equalizer/equalizerwidget.cpp @@ -24,10 +24,12 @@ #include "pixmapslider.h" #include "skin.h" #include "skinmanager.h" +#include "equalizerwindow.h" #include #include +#include EqualizerSlider::EqualizerSlider (QWidget *parent, int id) : PixmapSlider (parent) @@ -121,6 +123,8 @@ EqualizerWidget::EqualizerWidget (QWidget *parent) : QWidget (parent) if (m_xconfig->isReady()) { loadServerConfig (); } + + setFixedSize (275, 116); } EqualizerWidget::~EqualizerWidget (void) @@ -177,6 +181,15 @@ EqualizerWidget::setActive (bool active) update (); } +void +EqualizerWidget::mouseDoubleClickEvent (QMouseEvent *event) +{ + EqualizerWindow *ew = dynamic_cast(window ()); + if (event->y() < 14) { + ew->switchDisplay (); + } +} + void EqualizerWidget::paintEvent (QPaintEvent *event) { diff --git a/src/equalizer/equalizerwidget.h b/src/equalizer/equalizerwidget.h index 2413ed7..276d531 100644 --- a/src/equalizer/equalizerwidget.h +++ b/src/equalizer/equalizerwidget.h @@ -21,6 +21,7 @@ class QString; class QVariant; class QPixmap; class QPaintEvent; +class QMouseEvent; #include "pixmapslider.h" class XConfig; @@ -56,6 +57,7 @@ class EqualizerWidget : public QWidget void setActive (bool); void paintEvent (QPaintEvent *event); + void mouseDoubleClickEvent (QMouseEvent *event); public slots: void setPixmaps(Skin *skin); diff --git a/src/equalizer/equalizerwindow.cpp b/src/equalizer/equalizerwindow.cpp index 010cbfa..a88c709 100644 --- a/src/equalizer/equalizerwindow.cpp +++ b/src/equalizer/equalizerwindow.cpp @@ -20,27 +20,36 @@ #include "mainwindow.h" #include "equalizerwidget.h" +#include "equalizershade.h" EqualizerWindow::EqualizerWindow (QWidget *parent) : BaseWindow (parent) { setObjectName ("equalizer"); - m_mw = dynamic_cast(parent); setWindowFlags (Qt::Dialog | Qt::FramelessWindowHint); setAttribute (Qt::WA_DeleteOnClose); - m_equalizer = new EqualizerWidget (this); - m_equalizer->show(); + QSettings s; + s.beginGroup (objectName ()); + m_equalizer = new EqualizerWidget (this); + m_shaded = new EqualizerShade (this); 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 EqualizerWindow::activeWindowInEvent (QEvent *event) { m_equalizer->setActive (true); + m_shaded->setActive (true); BaseWindow::activeWindowInEvent (event); } @@ -48,13 +57,29 @@ void EqualizerWindow::activeWindowOutEvent (QEvent *event) { m_equalizer->setActive (false); + m_shaded->setActive (false); BaseWindow::activeWindowOutEvent (event); } 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" diff --git a/src/equalizer/equalizerwindow.h b/src/equalizer/equalizerwindow.h index ea3e6d2..9e9be03 100644 --- a/src/equalizer/equalizerwindow.h +++ b/src/equalizer/equalizerwindow.h @@ -21,6 +21,7 @@ class QWidget; class MainWindow; class EqualizerWidget; +class EqualizerShade; class EqualizerWindow : public BaseWindow { @@ -37,8 +38,8 @@ class EqualizerWindow : public BaseWindow void activeWindowOutEvent (QEvent *event); private: - MainWindow *m_mw; EqualizerWidget *m_equalizer; + EqualizerShade *m_shaded; }; #endif // __EQUALIZERWINDOW_H__ diff --git a/src/playlist/playlistshade.cpp b/src/playlist/playlistshade.cpp index f52ebd2..c94f370 100644 --- a/src/playlist/playlistshade.cpp +++ b/src/playlist/playlistshade.cpp @@ -132,7 +132,7 @@ PlaylistShade::setActive (bool b) update (); } -void +void PlaylistShade::mouseDoubleClickEvent (QMouseEvent *event) { PlaylistWindow *pw = dynamic_cast(window ()); diff --git a/src/skin/skin.cpp b/src/skin/skin.cpp index 728ddcb..3ecc65b 100644 --- a/src/skin/skin.cpp +++ b/src/skin/skin.cpp @@ -517,6 +517,9 @@ Skin::handle_eq_ex (const QPixmap &img) if (img.isNull ()) 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), 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_balance = false, b_cbuttons = false, b_monoster = false; bool b_playpaus = false, b_shufrep = false, b_text = false; - bool b_numbers = false, b_eqmain = false, b_pledit = false; - bool b_pledit_txt = false; + bool b_numbers = false, b_eqmain = false, b_eq_ex = false; + bool b_pledit = false, b_pledit_txt = false; QPixmap p_eq_ex; QPixmap p_numbers; @@ -778,12 +781,12 @@ Skin::setSkin (const QString& path) // handle_eq_ex must be called after handle_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 && 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 QStringList list; @@ -798,6 +801,7 @@ Skin::setSkin (const QString& path) if (!b_text) { list << "text"; } if (!b_numbers) { list << "numbers/nums_ex"; } if (!b_eqmain) { list << "equmain"; } + if (!b_eq_ex) { list << "eq_ex"; } if (!b_pledit) { list << "pledit"; } if (!b_pledit_txt) { list << "pledit.txt"; } diff --git a/src/skin/skin.h b/src/skin/skin.h index ce32a87..83858a1 100644 --- a/src/skin/skin.h +++ b/src/skin/skin.h @@ -189,6 +189,8 @@ class Skin : public QObject EQ_WIN_GRAPH_BG, EQ_WIN_BAR_BTN_0, EQ_WIN_BAR_BTN_1, + EQ_WIN_SHADE_ACTIVE, + EQ_WIN_SHADE_INACTIVE, POSBAR, };