OTHER: Modified buttons in PlaylistWindow

Moved positions and sizes of close and shade buttons to Skin
changed buttons to use PixmapButton
moved buttons from PlaylistWindow to PlaylistWidget and PlaylistShade
removed now unused Button
fixed position of shadebutton (was off by 1)
fixed icon of shade button in shaded mode
This commit is contained in:
Thomas Frauendorfer 2008-05-16 16:46:07 +02:00
parent f0211e3958
commit 4eb7762009
10 changed files with 119 additions and 241 deletions

View file

@ -1,123 +0,0 @@
/**
* This file is a part of Promoe, an XMMS2 Client.
*
* Copyright (C) 2005-2008 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; version 2 of the License.
*
* 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 "Button.h"
#include "Skin.h"
#include <QIcon>
#include <QPixmap>
#include <QMouseEvent>
Button::Button (QWidget *parent) : PixmapButton (parent)
{
m_name_normal = 0;
m_name_pressed = 0;
Skin *skin = Skin::getInstance();
connect (skin, SIGNAL (skinChanged (Skin *)),
this, SLOT (setPixmaps(Skin *)));
}
Button::Button (QWidget *parent, uint normal, uint pressed, bool pls) : PixmapButton (parent)
{
m_name_normal = normal;
m_name_pressed = pressed;
m_pls = pls;
Skin *skin = Skin::getInstance();
connect (skin, SIGNAL (skinChanged (Skin *)),
this, SLOT (setPixmaps(Skin *)));
}
Button::~Button ()
{
}
void
Button::setPixmaps(Skin *skin)
{
if (!m_name_normal && !m_name_pressed) {
return;
}
QIcon icon;
QPixmap m_pixmap_normal, m_pixmap_pressed;
if (m_pls) {
m_pixmap_normal = skin->getPls (m_name_normal);
m_pixmap_pressed = skin->getPls (m_name_pressed);
} else {
m_pixmap_normal = skin->getItem (m_name_normal);
m_pixmap_pressed = skin->getItem (m_name_pressed);
}
icon.addPixmap(m_pixmap_normal);
icon.addPixmap(m_pixmap_pressed, QIcon::Active);
if (!m_pixmap_normal || m_pixmap_normal.isNull()) {
qDebug ("OPPP! %d return NULL!", m_name_normal);
}
if (!m_pixmap_pressed || m_pixmap_pressed.isNull()) {
qDebug ("OPPP! %d return NULL!", m_name_pressed);
}
setIcon(icon);
setFixedSize (m_pixmap_normal.size ());
update();
}
/*
*
* ToggleButton
*
*/
ToggleButton::ToggleButton (QWidget *parent, uint on_normal, uint on_pressed,
uint off_normal, uint off_pressed) :
PixmapButton (parent)
{
setCheckable (true);
m_name_on_normal = on_normal;
m_name_on_pressed = on_pressed;
m_name_off_normal = off_normal;
m_name_off_pressed = off_pressed;
Skin *skin = Skin::getInstance();
connect (skin, SIGNAL (skinChanged (Skin *)),
this, SLOT (setPixmaps(Skin *)));
}
void
ToggleButton::setPixmaps(Skin *skin)
{
QIcon icon;
QPixmap p = skin->getItem( m_name_on_normal );
icon.addPixmap( p, QIcon::Normal, QIcon::On );
icon.addPixmap( skin->getItem(m_name_on_pressed), QIcon::Active,
QIcon::On );
icon.addPixmap( skin->getItem(m_name_off_normal), QIcon::Normal,
QIcon::Off );
icon.addPixmap( skin->getItem(m_name_off_pressed), QIcon::Active,
QIcon::Off );
setIcon(icon);
setFixedSize (p.size ());
update();
}

View file

@ -1,58 +0,0 @@
/**
* This file is a part of Promoe, an XMMS2 Client.
*
* Copyright (C) 2005-2008 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; version 2 of the License.
*
* 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 __BUTTON_H__
#define __BUTTON_H__
#include "pixmapbutton.h"
class Skin;
class Button : public PixmapButton
{
Q_OBJECT
public:
Button (QWidget *parent, uint btn1, uint btn2, bool pls=false);
Button (QWidget *parent);
~Button ();
public slots:
void setPixmaps (Skin *skin);
protected:
uint m_name_normal;
uint m_name_pressed;
bool m_pls;
};
class ToggleButton : public PixmapButton
{
Q_OBJECT
public:
ToggleButton (QWidget *parent, uint, uint, uint, uint);
~ToggleButton () {}
public slots:
void setPixmaps(Skin *skin);
private:
uint m_name_on_normal;
uint m_name_on_pressed;
uint m_name_off_normal;
uint m_name_off_pressed;
};
#endif

View file

@ -65,7 +65,7 @@ Skin::setSizes ()
<< QSize () // BUTTON_EQ_SHADED_UNSHADE
<< QSize ( 9, 9) // BUTTON_PLS_CLOSE
<< QSize ( 9, 9) // BUTTON_PLS_SHADE
<< QSize () // BUTTON_PLS_SHADED_UNSHADE
<< QSize ( 9, 9) // BUTTON_PLS_SHADED_UNSHADE
<< QSize () // SLIDER_POSBAR
<< QSize (248, 10) // SLIDER_POSBAR_BGS
<< QSize (14, 11) // SLIDER_VOLUMEBAR
@ -103,9 +103,10 @@ Skin::setPositions ()
<< QPoint (217, 18) // BUTTON_EQ_PRESET
<< QPoint () // BUTTON_EQ_SHADED_CLOSE
<< QPoint () // BUTTON_EQ_SHADED_UNSHADE
<< QPoint () // BUTTON_PLS_CLOSE
<< QPoint () // BUTTON_PLS_SHADE
<< QPoint () // BUTTON_PLS_SHADED_UNSHADE
// The next 3 widgets are placed from the right
<< QPoint (-11, 3) // BUTTON_PLS_CLOSE
<< QPoint (-20, 3) // BUTTON_PLS_SHADE
<< QPoint (-20, 3) // BUTTON_PLS_SHADED_UNSHADE
<< QPoint () // SLIDER_POSBAR
<< QPoint ( 16, 72) // SLIDER_POSBAR_BGS
<< QPoint () // SLIDER_VOLUMEBAR
@ -187,22 +188,37 @@ Skin::BuildPlaylist (void)
if(img)
{
QIcon icon;
icon.addPixmap (img->copy (167, 3, 9, 9), QIcon::Normal, QIcon::Off);
icon.addPixmap (img->copy ( 52, 42, 9, 9), QIcon::Active, QIcon::Off);
m_icons[BUTTON_PLS_CLOSE] = icon;
icon = QIcon ();
icon.addPixmap (img->copy (158, 3, 9, 9), QIcon::Normal, QIcon::Off);
icon.addPixmap (img->copy ( 62, 42, 9, 9), QIcon::Active, QIcon::Off);
m_icons[BUTTON_PLS_SHADE] = icon;
icon = QIcon ();
icon.addPixmap (img->copy (129, 45, 9, 9), QIcon::Normal, QIcon::Off);
icon.addPixmap (img->copy (150, 42, 9, 9), QIcon::Active, QIcon::Off);
m_icons[BUTTON_PLS_SHADED_UNSHADE] = icon;
m_playlist[PLS_CORNER_UL_0] = img->copy(0, 0, 25, 20);
m_playlist[PLS_CORNER_UL_1] = img->copy(0, 21, 25, 20);
m_playlist[PLS_TBAR_0] = img->copy (26, 0, 100, 20);
m_playlist[PLS_TBAR_1] = img->copy (26, 21, 100, 20);
m_playlist[PLS_CORNER_UR_0] = img->copy(153, 0, 25, 20);
m_playlist[PLS_CORNER_UR_1] = img->copy(153, 21, 25, 20);
m_playlist[PLS_TFILL_0] = img->copy(127, 0, 25, 20);
m_playlist[PLS_TFILL_1] = img->copy(127, 21, 25, 20);
m_playlist[PLS_BFILL_0] = img->copy(179, 0, 25, 38);
m_playlist[PLS_VISMINI_0] = img->copy(205, 0, 75, 38);
m_playlist[PLS_LFILL_0] = img->copy(0, 42, 12, 29);
m_playlist[PLS_RFILL_0] = img->copy(31, 42, 5, 29);
@ -211,89 +227,89 @@ Skin::BuildPlaylist (void)
tmp = m_playlist[PLS_CORNER_UR_0];
m_playlist[PLS_CLOSE_BTN_0] = tmp.copy(14, 3, 9, 9);
m_playlist[PLS_CLOSE_BTN_1] = img->copy(52, 42, 9, 9);
m_playlist[PLS_SHADE_BTN_0] = tmp.copy(5, 3, 9, 9);
m_playlist[PLS_SHADE_BTN_1] = img->copy(62, 42, 9, 9);
// m_playlist[PLS_CLOSE_BTN_0] = tmp.copy(14, 3, 9, 9);
// m_playlist[PLS_CLOSE_BTN_1] = img->copy(52, 42, 9, 9);
// m_playlist[PLS_SHADE_BTN_0] = tmp.copy(5, 3, 9, 9);
// m_playlist[PLS_SHADE_BTN_1] = img->copy(62, 42, 9, 9);
m_playlist[PLS_MAX_BTN_0] = img->copy(150, 42, 9, 9);
m_playlist[PLS_SCROLL_0] = img->copy(52, 53, 8, 18);
m_playlist[PLS_SCROLL_1] = img->copy(61, 53, 8, 18);
m_playlist[PLS_WS_LE_0] = img->copy(72, 42, 25, 14);
m_playlist[PLS_WS_RE_0] = img->copy(99, 42, 50, 14);
m_playlist[PLS_WS_RE_1] = img->copy(99, 57, 50, 14);
m_playlist[PLS_WS_MID_0] = img->copy(72, 57, 25, 14);
m_playlist[PLS_LCBAR] = img->copy(0, 72, 125, 38);
m_playlist[PLS_RCBAR] = img->copy(126, 72, 150, 38);
/* extract the buttons */
m_playlist[PLS_ADD] = img->copy(11, 80, 25, 18);
m_playlist[PLS_ADD_DEC] = img->copy(48, 111, 3, 54);
m_playlist[PLS_ADD_URL_0] = img->copy(0, 111, 22, 18);
m_playlist[PLS_ADD_URL_1] = img->copy(23, 111, 22, 18);
m_playlist[PLS_ADD_DIR_0] = img->copy(0, 130, 22, 18);
m_playlist[PLS_ADD_DIR_1] = img->copy(23, 130, 22, 18);
m_playlist[PLS_ADD_FIL_0] = img->copy(0, 149, 22, 18);
m_playlist[PLS_ADD_FIL_1] = img->copy(23, 149, 22, 18);
/* Delete buttons */
m_playlist[PLS_DEL] = img->copy(40, 80, 25, 18);
m_playlist[PLS_DEL_DEC] = img->copy(100, 111, 3, 72);
m_playlist[PLS_DEL_ALL_0] = img->copy(54, 111, 22, 18);
m_playlist[PLS_DEL_ALL_1] = img->copy(77, 111, 22, 18);
m_playlist[PLS_DEL_CRP_0] = img->copy(54, 130, 22, 18);
m_playlist[PLS_DEL_CRP_1] = img->copy(77, 130, 22, 18);
m_playlist[PLS_DEL_FIL_0] = img->copy(54, 149, 22, 18);
m_playlist[PLS_DEL_FIL_1] = img->copy(77, 149, 22, 18);
/* Select buttons */
m_playlist[PLS_SEL] = img->copy(69, 80, 25, 18);
m_playlist[PLS_SEL_DEC] = img->copy(150, 111, 3, 54);
m_playlist[PLS_SEL_INV_0] = img->copy(104, 111, 22, 18);
m_playlist[PLS_SEL_INV_1] = img->copy(127, 111, 22, 18);
m_playlist[PLS_SEL_NIL_0] = img->copy(104, 130, 22, 18);
m_playlist[PLS_SEL_NIL_1] = img->copy(127, 130, 22, 18);
m_playlist[PLS_SEL_ALL_0] = img->copy(104, 149, 22, 18);
m_playlist[PLS_SEL_ALL_1] = img->copy(127, 149, 22, 18);
/* misc buttons */
m_playlist[PLS_MSC] = img->copy(98, 80, 25, 18);
m_playlist[PLS_MSC_DEC] = img->copy(200, 111, 3, 54);
m_playlist[PLS_MSC_SRT_0] = img->copy(154, 111, 22, 18);
m_playlist[PLS_MSC_SRT_1] = img->copy(177, 111, 22, 18);
m_playlist[PLS_MSC_INF_0] = img->copy(154, 130, 22, 18);
m_playlist[PLS_MSC_INF_1] = img->copy(177, 130, 22, 18);
m_playlist[PLS_MSC_OPT_0] = img->copy(154, 149, 22, 18);
m_playlist[PLS_MSC_OPT_1] = img->copy(177, 149, 22, 18);
/* list buttons */
m_playlist[PLS_LST] = img->copy(229, 80, 25, 18);
m_playlist[PLS_LST_DEC] = img->copy(250, 111, 3, 54);
m_playlist[PLS_LST_NEW_0] = img->copy(204, 111, 22, 18);
m_playlist[PLS_LST_NEW_1] = img->copy(227, 111, 22, 18);
m_playlist[PLS_LST_SAV_0] = img->copy(204, 130, 22, 18);
m_playlist[PLS_LST_SAV_1] = img->copy(227, 130, 22, 18);
m_playlist[PLS_LST_OPN_0] = img->copy(204, 149, 22, 18);
m_playlist[PLS_LST_OPN_1] = img->copy(227, 149, 22, 18);
/* misc button */
m_playlist[PLS_MSC_BTN_0] = img->copy(54, 168, 22, 18);
m_playlist[PLS_MSC_BTN_1] = img->copy(77, 168, 22, 18);
delete img;
}
else

View file

@ -18,11 +18,13 @@
#include "playlistshade.h"
#include "playlistwindow.h"
#include "pixmapbutton.h"
#include <QSettings>
#include <QPainter>
#include <QPoint>
PlaylistShade::PlaylistShade (QWidget *parent) : QWidget (parent)
PlaylistShade::PlaylistShade (PlaylistWindow *parent) : QWidget (parent)
{
QSettings s;
XMMSHandler &xmmsh = XMMSHandler::getInstance ();
@ -31,10 +33,18 @@ PlaylistShade::PlaylistShade (QWidget *parent) : QWidget (parent)
s.setValue ("playlist/shadedsize", 8);
Skin *skin = Skin::getInstance ();
setMinimumSize (275, 14);
connect (skin, SIGNAL (skinChanged (Skin *)),
this, SLOT (setPixmaps(Skin *)));
m_closebtn = new PixmapButton (this);
m_closebtn->resize (skin->getSize (Skin::BUTTON_PLS_CLOSE));
connect (m_closebtn, SIGNAL (clicked ()), parent, SLOT (hide ()));
m_unshadebtn = new PixmapButton (this);
m_unshadebtn->resize (skin->getSize (Skin::BUTTON_PLS_SHADED_UNSHADE));
connect (m_unshadebtn, SIGNAL (clicked ()),
parent, SLOT (switchDisplay ()));
connect (&xmmsh, SIGNAL(currentSong (const Xmms::PropDict &)),
this, SLOT(setMediainfo (const Xmms::PropDict &)));
@ -42,6 +52,7 @@ PlaylistShade::PlaylistShade (QWidget *parent) : QWidget (parent)
this, SLOT(settingsSaved ()));
m_text = "Promoe " PROMOE_VERSION " - A very neat XMMS2 client";
setMinimumSize (275, 14);
}
void
@ -72,11 +83,26 @@ PlaylistShade::setMediainfo (const Xmms::PropDict &info)
update ();
}
void
PlaylistShade::resizeEvent (QResizeEvent *event)
{
Skin *skin = Skin::getInstance ();
QPoint p = skin->getPos (Skin::BUTTON_PLS_CLOSE);
m_closebtn->move (p.x () + width (), p.y());
p = skin->getPos (Skin::BUTTON_PLS_SHADED_UNSHADE);
m_unshadebtn->move (p.x () + width (), p.y());
}
void
PlaylistShade::setPixmaps (Skin *skin)
{
QSettings s;
m_closebtn->setIcon (skin->getIcon (Skin::BUTTON_PLS_CLOSE));
m_unshadebtn->setIcon (skin->getIcon (Skin::BUTTON_PLS_SHADED_UNSHADE));
m_pixmap_le = skin->getPls (Skin::PLS_WS_LE_0);
m_pixmap_re_0 = skin->getPls (Skin::PLS_WS_RE_0);
m_pixmap_re_1 = skin->getPls (Skin::PLS_WS_RE_1);

View file

@ -22,11 +22,15 @@
#include <QWidget>
#include <QHash>
class QResizeEvent;
class PixmapButton;
class PlaylistWindow;
class PlaylistShade : public QWidget {
Q_OBJECT
public:
PlaylistShade (QWidget *parent);
PlaylistShade (PlaylistWindow *parent);
~PlaylistShade () {}
void paintEvent (QPaintEvent *event);
@ -37,8 +41,12 @@ class PlaylistShade : public QWidget {
void setPixmaps (Skin *skin);
void setMediainfo (const Xmms::PropDict &info);
void settingsSaved ();
void resizeEvent (QResizeEvent *);
private:
PixmapButton *m_closebtn;
PixmapButton *m_unshadebtn;
QPixmap m_pixmap_le;
QPixmap m_pixmap_re;
QPixmap m_pixmap_mid;

View file

@ -24,6 +24,7 @@
#include "playlistmodel.h"
#include "xcollection.h"
#include "pixmapbutton.h"
#include "playlistshade.h"
#include "playlistmenu.h"
#include "FileDialog.h"
@ -32,6 +33,7 @@
#include <QMouseEvent>
#include <QPaintEvent>
#include <QPoint>
#include <QRect>
#include <QIcon>
#include <QApplication>
@ -171,7 +173,7 @@ PlaylistScrollBar::sliderValueFromPosition (int position)
/*
* PlaylistWidget
*/
PlaylistWidget::PlaylistWidget (QWidget *parent) : QWidget (parent)
PlaylistWidget::PlaylistWidget (PlaylistWindow *parent) : QWidget (parent)
{
Skin *skin = Skin::getInstance ();
@ -180,6 +182,14 @@ PlaylistWidget::PlaylistWidget (QWidget *parent) : QWidget (parent)
setActive (underMouse ());
m_closebtn = new PixmapButton (this);
m_closebtn->resize (skin->getSize (Skin::BUTTON_PLS_CLOSE));
connect (m_closebtn, SIGNAL (clicked ()), parent, SLOT (hide ()));
m_shadebtn = new PixmapButton (this);
m_shadebtn->resize (skin->getSize (Skin::BUTTON_PLS_SHADE));
connect (m_shadebtn, SIGNAL (clicked ()), parent, SLOT (switchDisplay ()));
m_view = new PlaylistView (this);
m_view->move (10, 20);
// m_view->resize (size().width()-30, size().height()-20-38);
@ -215,7 +225,7 @@ PlaylistWidget::PlaylistWidget (QWidget *parent) : QWidget (parent)
}
void
PlaylistWidget::addButtons (void)
PlaylistWidget::addButtons ()
{
PlaylistMenuButton *b;
@ -377,6 +387,14 @@ PlaylistWidget::menuAddPls ()
void
PlaylistWidget::resizeEvent (QResizeEvent *event)
{
Skin *skin = Skin::getInstance ();
QPoint p = skin->getPos (Skin::BUTTON_PLS_CLOSE);
m_closebtn->move (p.x () + width (), p.y());
p = skin->getPos (Skin::BUTTON_PLS_SHADE);
m_shadebtn->move (p.x () + width (), p.y());
m_view->resize (size().width()-30, size().height()-20-38);
/* since the sizes has changed we need to move the scrollbar */
@ -405,6 +423,9 @@ PlaylistWidget::resizeEvent (QResizeEvent *event)
void
PlaylistWidget::setPixmaps (Skin *skin)
{
m_closebtn->setIcon (skin->getIcon (Skin::BUTTON_PLS_CLOSE));
m_shadebtn->setIcon (skin->getIcon (Skin::BUTTON_PLS_SHADE));
setActive (m_active);
update ();

View file

@ -20,13 +20,16 @@
#include <QScrollBar>
#include <QSizeGrip>
#include <QWidget>
class PlaylistWidget;
class PlaylistWindow;
class PlaylistScroller;
class Skin;
class PlaylistView;
class PlaylistMenu;
class PixmapButton;
class PlaylistSizeGrip : public QSizeGrip {
@ -70,7 +73,7 @@ class PlaylistWidget : public QWidget {
Q_OBJECT
public:
PlaylistWidget (QWidget *parent);
PlaylistWidget (PlaylistWindow *parent);
~PlaylistWidget () {}
void setActive (bool);
@ -94,6 +97,9 @@ class PlaylistWidget : public QWidget {
void addButtons (void);
void diveDir (const QString &);
PixmapButton *m_closebtn;
PixmapButton *m_shadebtn;
QPixmap m_corner1;
QPixmap m_corner2;
QPixmap m_corner3;

View file

@ -21,7 +21,6 @@
#include <QResizeEvent>
#include <QPoint>
#include "Button.h"
#include "playlistwidget.h"
#include "playlistshade.h"
@ -47,14 +46,6 @@ PlaylistWindow::PlaylistWindow (QWidget *parent) : BaseWindow (parent)
setCentralWidget (m_playlist);
m_shaded = new PlaylistShade (this);
m_shadebtn = new Button (this, Skin::PLS_SHADE_BTN_0, Skin::PLS_SHADE_BTN_1, true);
connect (m_shadebtn, SIGNAL (clicked()), this, SLOT (switchDisplay ()));
m_shadebtn->move(size().width() - 21, 3);
m_closebtn = new Button (this, Skin::PLS_CLOSE_BTN_0, Skin::PLS_CLOSE_BTN_1, true);
connect (m_closebtn, SIGNAL (clicked()), this, SLOT (hide ()));
m_closebtn->move(size().width() - 11, 3);
if (!s.contains ("shaded"))
s.setValue ("shaded", false);
else
@ -123,9 +114,6 @@ PlaylistWindow::resizeEvent (QResizeEvent *event)
{
QSettings s;
m_shadebtn->move(size().width() - 21, 3);
m_closebtn->move(size().width() - 11, 3);
if (s.value("playlist/shaded").toBool ()) {
s.setValue ("playlist/size", size ());
}

View file

@ -27,7 +27,6 @@ class QShowEvent;
class QPoint;
// our own classes
class Button;
class MainWindow;
class PlaylistWidget;
class PlaylistShade;
@ -58,9 +57,6 @@ class PlaylistWindow : public BaseWindow {
private:
PlaylistWidget *m_playlist;
PlaylistShade *m_shaded;
Button *m_shadebtn;
Button *m_closebtn;
};
#endif // __PLAYLISTWINDOW_H__

View file

@ -8,7 +8,6 @@ HEADERS += PixWidget.h \
Skin.h \
Display.h \
TitleBar.h \
Button.h \
TextBar.h \
NumberDisplay.h \
TimeDisplay.h \
@ -26,7 +25,6 @@ SOURCES += main.cpp \
Skin.cpp \
Display.cpp \
TitleBar.cpp \
Button.cpp \
TextBar.cpp \
NumberDisplay.cpp \
TimeDisplay.cpp \