Added beginning of skinchooser.
Drop your skins into ~/.xmms2/clients/promoe/skins
This commit is contained in:
parent
18f87d65d5
commit
4e46089c01
8 changed files with 169 additions and 3 deletions
|
@ -1,6 +1,8 @@
|
||||||
#include <xmmsclient/xmmsclient++.h>
|
#include <xmmsclient/xmmsclient++.h>
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
|
|
||||||
|
#include <QSettings>
|
||||||
|
|
||||||
MainWindow::MainWindow (QWidget *parent) : QMainWindow (parent)
|
MainWindow::MainWindow (QWidget *parent) : QMainWindow (parent)
|
||||||
{
|
{
|
||||||
setWindowFlags(Qt::FramelessWindowHint);
|
setWindowFlags(Qt::FramelessWindowHint);
|
||||||
|
@ -85,6 +87,7 @@ int
|
||||||
main (int argc, char **argv)
|
main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
|
QSettings settings ("XMMS2", "Promoe");
|
||||||
|
|
||||||
MainWindow *mw = new MainWindow (NULL);
|
MainWindow *mw = new MainWindow (NULL);
|
||||||
|
|
||||||
|
@ -96,7 +99,12 @@ main (int argc, char **argv)
|
||||||
* SkinChanged signal that will cause
|
* SkinChanged signal that will cause
|
||||||
* all widgets to get their pixmaps
|
* all widgets to get their pixmaps
|
||||||
*/
|
*/
|
||||||
mw->getSkin ()->setSkin ("./CleanAMP/");
|
if (!settings.contains ("skin/path")) {
|
||||||
|
settings.setValue ("skin/path", "./CleanAMP/");
|
||||||
|
}
|
||||||
|
|
||||||
|
mw->getSkin ()->setSkin (settings.value("skin/path").toString ());
|
||||||
|
|
||||||
mw->show ();
|
mw->show ();
|
||||||
mw->setPL (playlistwin);
|
mw->setPL (playlistwin);
|
||||||
|
|
||||||
|
|
18
Skin.cpp
18
Skin.cpp
|
@ -100,6 +100,24 @@ Skin::setSkin (QString name)
|
||||||
emit skinChanged(this);
|
emit skinChanged(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QPixmap
|
||||||
|
Skin::getPixmap (QString f, QDir dir)
|
||||||
|
{
|
||||||
|
/* check for files in zip and check if file exists */
|
||||||
|
|
||||||
|
dir.setFilter (QDir::Files);
|
||||||
|
|
||||||
|
QFileInfoList list = dir.entryInfoList();
|
||||||
|
for (int i = 0; i < list.size(); ++i) {
|
||||||
|
QFileInfo fileInfo = list.at(i);
|
||||||
|
if (fileInfo.fileName().toLower() == f) {
|
||||||
|
return QPixmap (fileInfo.filePath());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return QPixmap (0,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QPixmap *
|
QPixmap *
|
||||||
Skin::getPixmap (string file)
|
Skin::getPixmap (string file)
|
||||||
|
|
1
Skin.h
1
Skin.h
|
@ -19,6 +19,7 @@ class Skin : public QWidget
|
||||||
~Skin();
|
~Skin();
|
||||||
|
|
||||||
void setSkin (QString name);
|
void setSkin (QString name);
|
||||||
|
static QPixmap getPixmap (QString, QDir);
|
||||||
|
|
||||||
const QPixmap getItem (uint part) const { return m_items->value(part); }
|
const QPixmap getItem (uint part) const { return m_items->value(part); }
|
||||||
const QPixmap getPls (uint part) const { return m_playlist->value(part); }
|
const QPixmap getPls (uint part) const { return m_playlist->value(part); }
|
||||||
|
|
64
SkinChooser.cpp
Normal file
64
SkinChooser.cpp
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
#include "MainWindow.h"
|
||||||
|
#include "Skin.h"
|
||||||
|
#include "SkinChooser.h"
|
||||||
|
|
||||||
|
#include <QDir>
|
||||||
|
#include <QFile>
|
||||||
|
#include <QSettings>
|
||||||
|
|
||||||
|
SkinChooser::SkinChooser (QWidget *parent) : QMainWindow (parent)
|
||||||
|
{
|
||||||
|
m_mw = dynamic_cast<MainWindow *>(parent);
|
||||||
|
QWidget *c = new QWidget (this);
|
||||||
|
setCentralWidget (c);
|
||||||
|
|
||||||
|
m_vbox = new QVBoxLayout (c);
|
||||||
|
QLabel *label = new QLabel ("Available skins...", c);
|
||||||
|
label->setFont (QFont ("Helvetica", 16));
|
||||||
|
m_vbox->addWidget (label);
|
||||||
|
|
||||||
|
m_skin = new SkinList (c);
|
||||||
|
m_vbox->addWidget (m_skin);
|
||||||
|
|
||||||
|
resize (500, 300);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
SkinList::SkinList (QWidget *parent) : QListWidget (parent)
|
||||||
|
{
|
||||||
|
|
||||||
|
setIconSize (QSize (137, 58));
|
||||||
|
|
||||||
|
QString path;
|
||||||
|
path.append (QDir::homePath());
|
||||||
|
path.append ("/.xmms2/clients/promoe/skins/");
|
||||||
|
QDir d;
|
||||||
|
|
||||||
|
d.setPath (path);
|
||||||
|
d.setFilter (QDir::Dirs);
|
||||||
|
|
||||||
|
QFileInfoList list = d.entryInfoList();
|
||||||
|
for (int i = 0; i < list.size(); ++i) {
|
||||||
|
QFileInfo fileInfo = list.at(i);
|
||||||
|
QDir dir (fileInfo.filePath());
|
||||||
|
QPixmap p = Skin::getPixmap ("main.bmp", dir);
|
||||||
|
if (!p.isNull()) {
|
||||||
|
new QListWidgetItem (QIcon (p), dir.dirName(), this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
connect (this, SIGNAL (itemClicked (QListWidgetItem *)), this, SLOT (changeSkin (QListWidgetItem *)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
SkinList::changeSkin (QListWidgetItem *item)
|
||||||
|
{
|
||||||
|
QSettings settings;
|
||||||
|
|
||||||
|
SkinChooser *sc = dynamic_cast<SkinChooser *>(window());
|
||||||
|
qDebug ("change skin to %s", qPrintable (item->text()));
|
||||||
|
sc->getMW()->getSkin ()->setSkin (QDir::homePath()+"/.xmms2/clients/promoe/skins/"+item->text());
|
||||||
|
|
||||||
|
settings.setValue ("skin/path", QDir::homePath()+"/.xmms2/clients/promoe/skins/"+item->text());
|
||||||
|
}
|
||||||
|
|
33
SkinChooser.h
Normal file
33
SkinChooser.h
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
#include "MainWindow.h"
|
||||||
|
|
||||||
|
#include <QListWidget>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include <QMainWindow>
|
||||||
|
|
||||||
|
class SkinList : public QListWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
SkinList (QWidget *parent);
|
||||||
|
~SkinList () {}
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void changeSkin (QListWidgetItem *item);
|
||||||
|
};
|
||||||
|
|
||||||
|
class SkinChooser : public QMainWindow
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SkinChooser (QWidget *parent);
|
||||||
|
~SkinChooser () {}
|
||||||
|
MainWindow *getMW (void) { return m_mw; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
QVBoxLayout *m_vbox;
|
||||||
|
SkinList *m_skin;
|
||||||
|
QLabel *m_label;
|
||||||
|
MainWindow *m_mw;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
38
TitleBar.cpp
38
TitleBar.cpp
|
@ -1,6 +1,9 @@
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
#include "TitleBar.h"
|
#include "TitleBar.h"
|
||||||
#include "Display.h"
|
#include "Display.h"
|
||||||
|
#include "SkinChooser.h"
|
||||||
|
|
||||||
|
#include <QMenu>
|
||||||
|
|
||||||
TitleBar::TitleBar (QWidget *parent, bool shaded) : PixWidget (parent)
|
TitleBar::TitleBar (QWidget *parent, bool shaded) : PixWidget (parent)
|
||||||
{
|
{
|
||||||
|
@ -11,6 +14,7 @@ TitleBar::TitleBar (QWidget *parent, bool shaded) : PixWidget (parent)
|
||||||
setMaximumSize (275, 14);
|
setMaximumSize (275, 14);
|
||||||
|
|
||||||
m_menubtn = new Button (this, Skin::MENUBUTTON_0, Skin::MENUBUTTON_1);
|
m_menubtn = new Button (this, Skin::MENUBUTTON_0, Skin::MENUBUTTON_1);
|
||||||
|
connect (m_menubtn, SIGNAL (clicked ()), this, SLOT (showMenu ()));
|
||||||
m_menubtn->move(6, 3);
|
m_menubtn->move(6, 3);
|
||||||
|
|
||||||
m_minimize = new Button (this, Skin::MINIMIZE_0, Skin::MINIMIZE_1);
|
m_minimize = new Button (this, Skin::MINIMIZE_0, Skin::MINIMIZE_1);
|
||||||
|
@ -27,6 +31,40 @@ TitleBar::TitleBar (QWidget *parent, bool shaded) : PixWidget (parent)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
TitleBar::showMenu (void)
|
||||||
|
{
|
||||||
|
QMenu qm(this);
|
||||||
|
|
||||||
|
QAction *a;
|
||||||
|
|
||||||
|
a = new QAction (tr ("Theme settings"), this);
|
||||||
|
a->setShortcut (tr ("Alt+T"));
|
||||||
|
connect (a, SIGNAL (triggered ()), this, SLOT (showTheme ()));
|
||||||
|
qm.addAction (a);
|
||||||
|
a = new QAction (tr ("Application settings"), this);
|
||||||
|
a->setShortcut (tr ("Alt+A"));
|
||||||
|
qm.addAction (a);
|
||||||
|
a = new QAction (tr ("Server settings"), this);
|
||||||
|
a->setShortcut (tr ("Alt+S"));
|
||||||
|
qm.addAction (a);
|
||||||
|
qm.addSeparator ();
|
||||||
|
a = new QAction (tr ("Quit"), this);
|
||||||
|
a->setShortcut (tr ("Ctrl+Q"));
|
||||||
|
connect (a, SIGNAL (triggered ()), qApp, SLOT (quit ()));
|
||||||
|
qm.addAction (a);
|
||||||
|
|
||||||
|
qm.exec(QPoint (window()->pos().x()+6, window()->pos().y()+3));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
TitleBar::showTheme ()
|
||||||
|
{
|
||||||
|
SkinChooser *sk = new SkinChooser (window());
|
||||||
|
sk->show();
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
TitleBar::setPixmaps (Skin *skin)
|
TitleBar::setPixmaps (Skin *skin)
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,6 +18,8 @@ class TitleBar : public PixWidget
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setPixmaps (Skin *skin);
|
void setPixmaps (Skin *skin);
|
||||||
|
void showMenu (void);
|
||||||
|
void showTheme (void);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void mouseDoubleClickEvent (QMouseEvent *event);
|
void mouseDoubleClickEvent (QMouseEvent *event);
|
||||||
|
|
|
@ -15,7 +15,8 @@ SOURCES += XmmsQT4.cpp \
|
||||||
PlayStatus.cpp \
|
PlayStatus.cpp \
|
||||||
ShadedDisplay.cpp \
|
ShadedDisplay.cpp \
|
||||||
Playlist.cpp \
|
Playlist.cpp \
|
||||||
PlaylistList.cpp
|
PlaylistList.cpp \
|
||||||
|
SkinChooser.cpp
|
||||||
|
|
||||||
HEADERS += XmmsQT4.h \
|
HEADERS += XmmsQT4.h \
|
||||||
PixWidget.h \
|
PixWidget.h \
|
||||||
|
@ -34,7 +35,8 @@ HEADERS += XmmsQT4.h \
|
||||||
PlayStatus.h \
|
PlayStatus.h \
|
||||||
ShadedDisplay.h \
|
ShadedDisplay.h \
|
||||||
Playlist.h \
|
Playlist.h \
|
||||||
PlaylistList.h
|
PlaylistList.h \
|
||||||
|
SkinChooser.h
|
||||||
|
|
||||||
CONFIG += link_pkgconfig
|
CONFIG += link_pkgconfig
|
||||||
CONFIG += debug warn_on
|
CONFIG += debug warn_on
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue