OTHER: move togglePlaytime to Application class and some other small fixes

This commit is contained in:
Thomas Frauendorfer 2008-11-04 14:26:19 +01:00
parent 461106eb43
commit 786b745d55
17 changed files with 59 additions and 45 deletions

View file

@ -1,4 +1,10 @@
DEFINES += PROMOE_VERSION="\"\\\"0.1-dev\\\"\"" DEFINES += PROMOE_VERSION="\"\\\"0.1-dev\\\"\""
isEmpty(PREFIX): PREFIX = /usr/local
isEmpty(BINDIR): BINDIR = $$PREFIX/bin
isEmpty(DATADIR): DATADIR = $$PREFIX/share/promoe
DEFINES += DATADIR="\"\\\"$$DATADIR\\\"\""
DEPENDPATH += $PWD/src $PWD/lib DEPENDPATH += $PWD/src $PWD/lib
INCLUDEPATH += $$PWD/src $$PWD/lib INCLUDEPATH += $$PWD/src $$PWD/lib

View file

@ -4,11 +4,9 @@ SUBDIRS = lib src
include (config.pri) include (config.pri)
isEmpty(PREFIX): PREFIX = /usr/local
isEmpty(BINDIR): BINDIR = $$PREFIX/bin
message ( "Install path set to:" $$PREFIX ) message ( "Install path set to:" $$PREFIX )
binarys.path = $$BINDIR binary.path = $$BINDIR
binarys.files = promoe binary.files = promoe
INSTALLS += binarys
INSTALLS += binary

View file

@ -76,7 +76,7 @@ Skin::getPixmap (const QString& file, const QString &path)
/* check for files in zip and check if file exists */ /* check for files in zip and check if file exists */
QDir dir (path); QDir dir (path);
dir.setFilter (QDir::Files); dir.setFilter (QDir::Files|QDir::NoDotAndDotDot);
QFileInfoList list = dir.entryInfoList(); QFileInfoList list = dir.entryInfoList();
for (int i = 0; i < list.size(); ++i) { for (int i = 0; i < list.size(); ++i) {
@ -120,7 +120,7 @@ Skin::ParsePLEdit (void)
QString path; QString path;
dir.setPath (m_path); dir.setPath (m_path);
dir.setFilter (QDir::Files); dir.setFilter (QDir::Files|QDir::NoDotAndDotDot);
QFileInfoList list = dir.entryInfoList(); QFileInfoList list = dir.entryInfoList();
for (int i = 0; i < list.size(); ++i) { for (int i = 0; i < list.size(); ++i) {

View file

@ -60,11 +60,12 @@ SkinList::SkinList (QWidget *parent) : QListWidget (parent)
path.append (QDir::homePath()); path.append (QDir::homePath());
path.append ("/.config/xmms2/clients/promoe/skins/"); path.append ("/.config/xmms2/clients/promoe/skins/");
searchpath.append (path); searchpath.append (path);
searchpath.append (DATADIR "/skins");
settings.setValue ("skin/searchpath", searchpath); settings.setValue ("skin/searchpath", searchpath);
} }
QDir d; QDir d;
d.setFilter (QDir::Dirs|QDir::NoDotAndDotDot); d.setFilter (QDir::AllDirs|QDir::NoDotAndDotDot|QDir::Files);
QFileInfoList list; QFileInfoList list;
foreach (QString path, searchpath) { foreach (QString path, searchpath) {
d.setPath (path); d.setPath (path);

View file

@ -52,24 +52,35 @@ Application::Application (int &argc, char **argv) : QApplication (argc, argv)
* open the skin and send the * open the skin and send the
* SkinChanged signal that will cause * SkinChanged signal that will cause
* all widgets to get their pixmaps * all widgets to get their pixmaps
* TODO: Now the Skin class loads the skin itself. This call is necessarry until * TODO: Now the Skin class loads the skin itself. This call is necessarry
* all widgets that receive the skinChanged signal fetch their pixmaps themself * until all widgets that receive the skinChanged signal fetch their
* on startup * pixmaps themself on startup
*/ */
Skin::getInstance()->setSkin (settings.value("skin/path").toString ()); Skin::getInstance()->setSkin (settings.value("skin/path").toString ());
mw->show (); mw->show ();
// The Playlist- and EqualizerWindow has to become visible after the mainwindow // The Playlist- and EqualizerWindow has to become visible after the
// because metacity (gnome-windowmanager) can't handle them correctly otherwise // mainwindow because metacity (gnome-windowmanager) can't handle them
// correctly otherwise
mw->getEQ ()->setVisible (settings.value ("equalizer/visible", false).toBool ()); mw->getEQ ()->setVisible (settings.value ("equalizer/visible", false).toBool ());
mw->getPL ()->setVisible (settings.value ("playlist/visible", false).toBool ()); mw->getPL ()->setVisible (settings.value ("playlist/visible", false).toBool ());
#ifdef HAVE_SERVERBROWSER
ServerBrowserWindow *browser = new ServerBrowserWindow (mw);
browser->show ();
#endif
m_timemode_reverse = settings.value ("MainWindow/timemodereverse",
false).toBool();
} }
void void
Application::cleanupHandler () Application::cleanupHandler ()
{ {
QSettings s; QSettings s;
s.setValue("MainWindow/timemodereverse",m_timemode_reverse);
if (s.value ("promoe/quitonclose", false).toBool ()) if (s.value ("promoe/quitonclose", false).toBool ())
XMMSHandler::getInstance ().shutdownServer (); XMMSHandler::getInstance ().shutdownServer ();
} }
@ -91,15 +102,12 @@ Application::handleDisconnected ()
QApplication::quit (); QApplication::quit ();
} }
int int
main (int argc, char **argv) main (int argc, char **argv)
{ {
Application app(argc, argv); Application app(argc, argv);
#ifdef Q_OS_MACX
QSettings settings;
#ifdef Q_OS_MACX
/** This is soooo wrong, there must exsist a flag for /** This is soooo wrong, there must exsist a flag for
* static plugins * static plugins
Q_IMPORT_PLUGIN(QJpegPlugin); Q_IMPORT_PLUGIN(QJpegPlugin);
@ -107,10 +115,5 @@ main (int argc, char **argv)
#endif #endif
#ifdef HAVE_SERVERBROWSER
ServerBrowserWindow *browser = new ServerBrowserWindow (mw);
browser->show ();
#endif
return app.exec(); return app.exec();
} }

View file

@ -20,6 +20,7 @@ class Application;
#undef qApp #undef qApp
#endif #endif
#define qApp (static_cast<Application *>(QCoreApplication::instance())) #define qApp (static_cast<Application *>(QCoreApplication::instance()))
#define App (static_cast<Application *>(QCoreApplication::instance()))
class Application : public QApplication class Application : public QApplication
{ {
@ -31,7 +32,19 @@ class Application : public QApplication
public: public:
Application (int &argc, char **argv); Application (int &argc, char **argv);
public slots: public slots:
void cleanupHandler (); void cleanupHandler ();
void handleDisconnected (); void handleDisconnected ();
// TODO: Search some better place for those methods
public:
bool isTimemodeReverse(void) {return m_timemode_reverse;}
void setTimemodeReverse(bool b) {m_timemode_reverse = b;}
public slots:
void toggleTime () {m_timemode_reverse = !m_timemode_reverse;}
private:
bool m_timemode_reverse;
}; };

View file

@ -19,6 +19,7 @@
#include "xplayback.h" #include "xplayback.h"
#include "xconfig.h" #include "xconfig.h"
#include "application.h"
#include "maindisplay.h" #include "maindisplay.h"
#include "mainwindow.h" #include "mainwindow.h"
@ -39,7 +40,6 @@
#include <QFileDialog> #include <QFileDialog>
#include <QSettings> #include <QSettings>
#include <QDebug> #include <QDebug>
#include <QMessageBox>
MainDisplay::MainDisplay (MainWindow *parent) : SkinDisplay(parent) MainDisplay::MainDisplay (MainWindow *parent) : SkinDisplay(parent)
{ {
@ -64,7 +64,7 @@ MainDisplay::MainDisplay (MainWindow *parent) : SkinDisplay(parent)
m_time = new TimeDisplay(this); m_time = new TimeDisplay(this);
m_time->move (36, 26); m_time->move (36, 26);
connect (m_time, SIGNAL(clicked()), m_mw, SLOT(toggleTime())); connect (m_time, SIGNAL(clicked()), App, SLOT(toggleTime()));
connect (this, SIGNAL (displayTime (int)), m_time, SLOT (setTime (int))); connect (this, SIGNAL (displayTime (int)), m_time, SLOT (setTime (int)));
m_kbps = new PixmapNumberDisplay (this); m_kbps = new PixmapNumberDisplay (this);
@ -197,7 +197,7 @@ void
MainDisplay::setPlaytime (uint32_t time) MainDisplay::setPlaytime (uint32_t time)
{ {
int32_t showtime; int32_t showtime;
if (m_mw->isTimemodeReverse()) { if (App->isTimemodeReverse()) {
uint maxtime = m_posbar->maximum (); uint maxtime = m_posbar->maximum ();
showtime = (time/1000 - maxtime/1000); showtime = (time/1000 - maxtime/1000);
} else { } else {

View file

@ -81,11 +81,9 @@ MainWindow::MainWindow (QWidget *parent) : BaseWindow (parent)
setCentralWidget (m_display); setCentralWidget (m_display);
m_display->show (); m_display->show ();
//connects for timedisplay in playlistwindow //connect for timedisplay in playlistwindow
connect (m_display, SIGNAL (displayTime (int)), connect (m_display, SIGNAL (displayTime (int)),
m_playlistwin, SIGNAL (setDisplayTime (int))); m_playlistwin, SIGNAL (setDisplayTime (int)));
connect (m_playlistwin, SIGNAL (toggleTime()),
this, SLOT (toggleTime ()));
/* /*
* MainDisplay's shaded mode * MainDisplay's shaded mode

View file

@ -43,15 +43,11 @@ class MainWindow : public BaseWindow
void raisePL (void); void raisePL (void);
void moveEvent (QMoveEvent *event); void moveEvent (QMoveEvent *event);
bool isTimemodeReverse(void) { QSettings s; return s.value("MainWindow/timemodereverse").toBool(); }
void setTimemodeReverse(bool b) { QSettings s; s.setValue("MainWindow/timemodereverse",b); }
void attachWidgets (); void attachWidgets ();
public slots: public slots:
void switchDisplay (); void switchDisplay ();
void mouseMoveEvent (QMouseEvent *event); void mouseMoveEvent (QMouseEvent *event);
void toggleTime () { setTimemodeReverse (!isTimemodeReverse ()); }
private: private:
bool isShaded (void) { QSettings s; return s.value("MainWindow/shaded").toBool(); } bool isShaded (void) { QSettings s; return s.value("MainWindow/shaded").toBool(); }

View file

@ -18,6 +18,7 @@
#include "xclientcache.h" #include "xclientcache.h"
#include "xplayback.h" #include "xplayback.h"
#include "application.h"
#include "shadeddisplay.h" #include "shadeddisplay.h"
#include "titlebar.h" #include "titlebar.h"
#include "pixmapbutton.h" #include "pixmapbutton.h"
@ -45,7 +46,7 @@ ShadedDisplay::ShadedDisplay (QWidget *parent) : SkinDisplay (parent)
m_time = new SmallTimeDisplay (this); m_time = new SmallTimeDisplay (this);
m_time->move (130, 4); m_time->move (130, 4);
connect (m_time, SIGNAL(clicked()), m_mw, SLOT(toggleTime())); connect (m_time, SIGNAL(clicked()), App, SLOT(toggleTime()));
m_title = new TextScroller (this, 39, 7, "shaded"); m_title = new TextScroller (this, 39, 7, "shaded");
m_title->move (79, 4); m_title->move (79, 4);
@ -129,7 +130,7 @@ void
ShadedDisplay::setPlaytime (uint32_t time) ShadedDisplay::setPlaytime (uint32_t time)
{ {
int32_t showtime; int32_t showtime;
if (m_mw->isTimemodeReverse()) { if (App->isTimemodeReverse()) {
showtime = (time/1000 - m_duration/1000); showtime = (time/1000 - m_duration/1000);
} else { } else {
showtime = time/1000; showtime = time/1000;

View file

@ -65,7 +65,7 @@ TextScroller::TextScroller (QWidget *parent, uint w,
m_timer = new QTimer (this); m_timer = new QTimer (this);
m_timer->setInterval (40); m_timer->setInterval (40);
connect (m_timer, SIGNAL (timeout()), this, SLOT (addOffset ())); connect (m_timer, SIGNAL (timeout()), this, SLOT (addOffset ()));
connect (qApp, SIGNAL (settingsChanged ()), connect (App, SIGNAL (settingsChanged ()),
this, SLOT (settingsChanged ())); this, SLOT (settingsChanged ()));
} }

View file

@ -50,7 +50,7 @@ PlaylistShade::PlaylistShade (PlaylistWindow *parent) : QWidget (parent)
connect (xmmsh.cache (), SIGNAL (activeEntryChanged (QVariantHash)), connect (xmmsh.cache (), SIGNAL (activeEntryChanged (QVariantHash)),
this, SLOT (setMediainfo (QVariantHash))); this, SLOT (setMediainfo (QVariantHash)));
connect (qApp, SIGNAL(settingsChanged ()), connect (App, SIGNAL(settingsChanged ()),
this, SLOT(settingsChanged ())); this, SLOT(settingsChanged ()));
m_text = "Promoe " PROMOE_VERSION " - A very neat XMMS2 client"; m_text = "Promoe " PROMOE_VERSION " - A very neat XMMS2 client";

View file

@ -138,7 +138,7 @@ PlaylistView::PlaylistView (QWidget *parent) : QListView (parent)
XMMSHandler &xmmsh = XMMSHandler::getInstance (); XMMSHandler &xmmsh = XMMSHandler::getInstance ();
connect (qApp, SIGNAL (settingsChanged ()), connect (App, SIGNAL (settingsChanged ()),
this, SLOT (settingsChanged ())); this, SLOT (settingsChanged ()));
connect (xmmsh.xplayback (), SIGNAL(playbackStatusChanged(Xmms::Playback::Status)), connect (xmmsh.xplayback (), SIGNAL(playbackStatusChanged(Xmms::Playback::Status)),

View file

@ -15,6 +15,7 @@
#include "XMMSHandler.h" #include "XMMSHandler.h"
#include "application.h"
#include "mainwindow.h" #include "mainwindow.h"
#include "BrowseDialog.h" #include "BrowseDialog.h"
#include "playlistwindow.h" #include "playlistwindow.h"
@ -38,7 +39,6 @@
#include <QPoint> #include <QPoint>
#include <QRect> #include <QRect>
#include <QIcon> #include <QIcon>
#include <QApplication>
#include <QSettings> #include <QSettings>
#include <QFileDialog> #include <QFileDialog>
#include <QPainter> #include <QPainter>
@ -235,7 +235,7 @@ PlaylistWidget::PlaylistWidget (PlaylistWindow *parent) : QWidget (parent)
client.xplayback (), SLOT (next ())); client.xplayback (), SLOT (next ()));
// TODO: eject // TODO: eject
connect (m_controls, SIGNAL (toggleTime ()), connect (m_controls, SIGNAL (toggleTime ()),
parent, SIGNAL (toggleTime())); App, SLOT (toggleTime()));
connect (parent, SIGNAL (setDisplayTime (int)), connect (parent, SIGNAL (setDisplayTime (int)),
m_controls, SIGNAL (setDisplayTime (int))); m_controls, SIGNAL (setDisplayTime (int)));

View file

@ -43,8 +43,6 @@ class PlaylistWindow : public BaseWindow {
signals: signals:
void visibilityChanged(bool visible); void visibilityChanged(bool visible);
// connected to
void toggleTime (); // toggle the playtime
// setTime is used to set playtime in playlistcontrols // setTime is used to set playtime in playlistcontrols
void setDisplayTime (int seconds); void setDisplayTime (int seconds);

View file

@ -39,7 +39,7 @@ SettingsDialog::SettingsDialog (QWidget *parent) : QDialog (parent)
resize (400, 500); resize (400, 500);
connect (this, SIGNAL (settingsChanged (void)), connect (this, SIGNAL (settingsChanged (void)),
qApp, SIGNAL (settingsChanged (void))); App, SIGNAL (settingsChanged (void)));
QVBoxLayout *vbox = new QVBoxLayout (this); QVBoxLayout *vbox = new QVBoxLayout (this);
setLayout(vbox); setLayout(vbox);

View file

@ -52,7 +52,7 @@ AbstractTimeDisplay::AbstractTimeDisplay (QWidget *parent) : QWidget (parent)
void void
AbstractTimeDisplay::setTime (int time) AbstractTimeDisplay::setTime (int time)
{ {
// Hack to make display hours and seconds instead of seconds and minutes // Hack to make display hours and minutes instead of minutes and seconds
// if time (or reversetime) is 100 Minutes or longer // if time (or reversetime) is 100 Minutes or longer
if ((time >= 6000) || (time <= -6000)) { if ((time >= 6000) || (time <= -6000)) {
time /= 60; time /= 60;