OTHER: Some cleanups

Whitespace cleanups and small changes to SkinChooser
This commit is contained in:
Thomas Frauendorfer 2008-09-22 20:47:10 +02:00
parent 15677bdf39
commit 63def9b10b
4 changed files with 42 additions and 48 deletions

View file

@ -32,7 +32,7 @@
// Used to check for Protocolversion at compiletime
#include <xmmsc/xmmsc_idnumbers.h>
PlaylistModel::PlaylistModel (QObject *parent, XClient *client, const QString &name) : QAbstractItemModel (parent)
PlaylistModel::PlaylistModel (QObject *parent, XClient *client, const QString &name) : QAbstractItemModel (parent), m_current_pos (0)
{
// m_columns.append ("#");
m_columns.append ("Artist");
@ -50,16 +50,14 @@ PlaylistModel::PlaylistModel (QObject *parent, XClient *client, const QString &n
connect (client, SIGNAL(gotConnection (XClient *)), this, SLOT (got_connection (XClient *)));
connect (client->cache (), SIGNAL(entryChanged (uint32_t)), this, SLOT (entry_changed (uint32_t)));
if (name == QLatin1String ("_active")) {
m_isactive = true;
m_isactive = (name == QLatin1String ("_active"));
m_name = name;
if (client->isConnected ()) {
got_connection (client);
}
m_name = name;
if (client->isConnected ()) {
got_connection (client);
}
}
void

View file

@ -140,7 +140,6 @@ class PlaylistModel : public QAbstractItemModel
void getInfo (unsigned int id) const;
uint32_t m_current_pos;
bool m_isactive;

View file

@ -13,7 +13,6 @@
* GNU General Public License for more details.
*/
#include "mainwindow.h"
#include "Skin.h"
#include "SkinChooser.h"
@ -24,27 +23,22 @@
#include <QSettings>
#include <QVBoxLayout>
SkinChooser::SkinChooser (QWidget *parent) : QMainWindow (parent)
SkinChooser::SkinChooser (QWidget *parent) : QDialog (parent)
{
#ifndef _WIN32
setWindowIcon (QIcon (":icon.png"));
#endif
setWindowFlags (Qt::Dialog);
setWindowModality (Qt::ApplicationModal);
setAttribute (Qt::WA_DeleteOnClose);
m_mw = dynamic_cast<MainWindow *>(parent);
m_c = new QWidget (this);
setCentralWidget (m_c);
QVBoxLayout *vbox = new QVBoxLayout (this);
QLabel *label = new QLabel ("Available skins...", this);
label->setFont (QFont ("Helvetica", 16));
vbox->addWidget (label);
m_vbox = new QVBoxLayout (m_c);
m_label = new QLabel ("Available skins...", m_c);
m_label->setFont (QFont ("Helvetica", 16));
m_vbox->addWidget (m_label);
m_skin = new SkinList (m_c);
m_vbox->addWidget (m_skin);
m_skin = new SkinList (this);
vbox->addWidget (m_skin);
resize (500, 300);
@ -52,30 +46,42 @@ SkinChooser::SkinChooser (QWidget *parent) : QMainWindow (parent)
SkinList::SkinList (QWidget *parent) : QListWidget (parent)
{
setIconSize (QSize (137, 58));
QString path;
path.append (QDir::homePath());
path.append ("/.config/xmms2/clients/promoe/skins/");
new SkinChooserItem (QIcon (":CleanAMP/main.png"), "CleanAMP (default)",
":CleanAMP/", this);
QSettings settings;
QStringList searchpath;
if (settings.contains ("skin/searchpath") ) {
searchpath = settings.value ("skin/searchpath").toStringList ();
} else {
QString path;
path.append (QDir::homePath());
path.append ("/.config/xmms2/clients/promoe/skins/");
searchpath.append (path);
settings.setValue ("skin/searchpath", searchpath);
}
QFileInfoList list;
QDir d;
new SkinChooserItem (QIcon (":CleanAMP/main.png"), "CleanAMP (default)", ":CleanAMP/", this);
d.setPath (path);
d.setFilter (QDir::Dirs);
foreach (QString path, searchpath) {
d.setPath (path);
list += d.entryInfoList();
}
QFileInfoList list = d.entryInfoList();
for (int i = 0; i < list.size(); ++i) {
QFileInfo fileInfo = list.at(i);
foreach (QFileInfo fileInfo, list) {
QDir dir (fileInfo.filePath());
QPixmap p = Skin::getPixmap ("main", dir);
if (!p.isNull()) {
new SkinChooserItem (QIcon (p), dir.dirName(), dir.absolutePath(), this);
new SkinChooserItem (QIcon (p), dir.dirName(), dir.absolutePath(),
this);
}
}
connect (this, SIGNAL (itemClicked (QListWidgetItem *)), this, SLOT (changeSkin (QListWidgetItem *)));
connect (this, SIGNAL (itemClicked (QListWidgetItem *)),
this, SLOT (changeSkin (QListWidgetItem *)));
}
void

View file

@ -15,11 +15,7 @@
#include <QListWidget>
#include <QMainWindow>
class QLabel;
class QVBoxLayout;
class MainWindow;
#include <QDialog>
class SkinList : public QListWidget
{
@ -46,19 +42,14 @@ class SkinChooserItem : public QListWidgetItem
};
class SkinChooser : public QMainWindow
class SkinChooser : public QDialog
{
public:
SkinChooser (QWidget *parent);
~SkinChooser (void) {}
MainWindow *getMW (void) { return m_mw; }
private:
QVBoxLayout *m_vbox;
SkinList *m_skin;
QLabel *m_label;
QWidget *m_c;
MainWindow *m_mw;
};