From 786b745d555cdfefbf2ee5b01bcf1ded7559e7ba Mon Sep 17 00:00:00 2001 From: Thomas Frauendorfer Date: Tue, 4 Nov 2008 14:26:19 +0100 Subject: [PATCH] OTHER: move togglePlaytime to Application class and some other small fixes --- config.pri | 6 ++++++ promoe.pro | 10 ++++------ src/Skin.cpp | 4 ++-- src/SkinChooser.cpp | 3 ++- src/application.cpp | 33 +++++++++++++++++--------------- src/application.h | 13 +++++++++++++ src/mainwindow/maindisplay.cpp | 6 +++--- src/mainwindow/mainwindow.cpp | 4 +--- src/mainwindow/mainwindow.h | 4 ---- src/mainwindow/shadeddisplay.cpp | 5 +++-- src/mainwindow/textbar.cpp | 2 +- src/playlist/playlistshade.cpp | 2 +- src/playlist/playlistview.cpp | 2 +- src/playlist/playlistwidget.cpp | 4 ++-- src/playlist/playlistwindow.h | 2 -- src/settingsdialog.cpp | 2 +- src/timedisplay.cpp | 2 +- 17 files changed, 59 insertions(+), 45 deletions(-) diff --git a/config.pri b/config.pri index 8f33e25..3bbcb2a 100644 --- a/config.pri +++ b/config.pri @@ -1,4 +1,10 @@ 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 INCLUDEPATH += $$PWD/src $$PWD/lib diff --git a/promoe.pro b/promoe.pro index c67d903..1bfa7f2 100644 --- a/promoe.pro +++ b/promoe.pro @@ -4,11 +4,9 @@ SUBDIRS = lib src include (config.pri) -isEmpty(PREFIX): PREFIX = /usr/local -isEmpty(BINDIR): BINDIR = $$PREFIX/bin - message ( "Install path set to:" $$PREFIX ) -binarys.path = $$BINDIR -binarys.files = promoe -INSTALLS += binarys +binary.path = $$BINDIR +binary.files = promoe + +INSTALLS += binary diff --git a/src/Skin.cpp b/src/Skin.cpp index b787541..da29f2b 100644 --- a/src/Skin.cpp +++ b/src/Skin.cpp @@ -76,7 +76,7 @@ Skin::getPixmap (const QString& file, const QString &path) /* check for files in zip and check if file exists */ QDir dir (path); - dir.setFilter (QDir::Files); + dir.setFilter (QDir::Files|QDir::NoDotAndDotDot); QFileInfoList list = dir.entryInfoList(); for (int i = 0; i < list.size(); ++i) { @@ -120,7 +120,7 @@ Skin::ParsePLEdit (void) QString path; dir.setPath (m_path); - dir.setFilter (QDir::Files); + dir.setFilter (QDir::Files|QDir::NoDotAndDotDot); QFileInfoList list = dir.entryInfoList(); for (int i = 0; i < list.size(); ++i) { diff --git a/src/SkinChooser.cpp b/src/SkinChooser.cpp index 9c64375..942ac35 100644 --- a/src/SkinChooser.cpp +++ b/src/SkinChooser.cpp @@ -60,11 +60,12 @@ SkinList::SkinList (QWidget *parent) : QListWidget (parent) path.append (QDir::homePath()); path.append ("/.config/xmms2/clients/promoe/skins/"); searchpath.append (path); + searchpath.append (DATADIR "/skins"); settings.setValue ("skin/searchpath", searchpath); } QDir d; - d.setFilter (QDir::Dirs|QDir::NoDotAndDotDot); + d.setFilter (QDir::AllDirs|QDir::NoDotAndDotDot|QDir::Files); QFileInfoList list; foreach (QString path, searchpath) { d.setPath (path); diff --git a/src/application.cpp b/src/application.cpp index fc7a3a8..c31ef37 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -52,24 +52,35 @@ Application::Application (int &argc, char **argv) : QApplication (argc, argv) * open the skin and send the * SkinChanged signal that will cause * all widgets to get their pixmaps - * TODO: Now the Skin class loads the skin itself. This call is necessarry until - * all widgets that receive the skinChanged signal fetch their pixmaps themself - * on startup + * TODO: Now the Skin class loads the skin itself. This call is necessarry + * until all widgets that receive the skinChanged signal fetch their + * pixmaps themself on startup */ Skin::getInstance()->setSkin (settings.value("skin/path").toString ()); mw->show (); - // The Playlist- and EqualizerWindow has to become visible after the mainwindow - // because metacity (gnome-windowmanager) can't handle them correctly otherwise + // The Playlist- and EqualizerWindow has to become visible after the + // mainwindow because metacity (gnome-windowmanager) can't handle them + // correctly otherwise mw->getEQ ()->setVisible (settings.value ("equalizer/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 Application::cleanupHandler () { QSettings s; + + s.setValue("MainWindow/timemodereverse",m_timemode_reverse); + if (s.value ("promoe/quitonclose", false).toBool ()) XMMSHandler::getInstance ().shutdownServer (); } @@ -91,15 +102,12 @@ Application::handleDisconnected () QApplication::quit (); } -int +int main (int argc, char **argv) { Application app(argc, argv); - - QSettings settings; - -#ifdef Q_OS_MACX +#ifdef Q_OS_MACX /** This is soooo wrong, there must exsist a flag for * static plugins Q_IMPORT_PLUGIN(QJpegPlugin); @@ -107,10 +115,5 @@ main (int argc, char **argv) #endif -#ifdef HAVE_SERVERBROWSER - ServerBrowserWindow *browser = new ServerBrowserWindow (mw); - browser->show (); -#endif - return app.exec(); } diff --git a/src/application.h b/src/application.h index b075f06..9677f95 100644 --- a/src/application.h +++ b/src/application.h @@ -20,6 +20,7 @@ class Application; #undef qApp #endif #define qApp (static_cast(QCoreApplication::instance())) +#define App (static_cast(QCoreApplication::instance())) class Application : public QApplication { @@ -31,7 +32,19 @@ class Application : public QApplication public: Application (int &argc, char **argv); + public slots: void cleanupHandler (); 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; }; diff --git a/src/mainwindow/maindisplay.cpp b/src/mainwindow/maindisplay.cpp index ff0b8ed..6c598ae 100644 --- a/src/mainwindow/maindisplay.cpp +++ b/src/mainwindow/maindisplay.cpp @@ -19,6 +19,7 @@ #include "xplayback.h" #include "xconfig.h" +#include "application.h" #include "maindisplay.h" #include "mainwindow.h" @@ -39,7 +40,6 @@ #include #include #include -#include MainDisplay::MainDisplay (MainWindow *parent) : SkinDisplay(parent) { @@ -64,7 +64,7 @@ MainDisplay::MainDisplay (MainWindow *parent) : SkinDisplay(parent) m_time = new TimeDisplay(this); 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))); m_kbps = new PixmapNumberDisplay (this); @@ -197,7 +197,7 @@ void MainDisplay::setPlaytime (uint32_t time) { int32_t showtime; - if (m_mw->isTimemodeReverse()) { + if (App->isTimemodeReverse()) { uint maxtime = m_posbar->maximum (); showtime = (time/1000 - maxtime/1000); } else { diff --git a/src/mainwindow/mainwindow.cpp b/src/mainwindow/mainwindow.cpp index a86376e..ea7d830 100644 --- a/src/mainwindow/mainwindow.cpp +++ b/src/mainwindow/mainwindow.cpp @@ -81,11 +81,9 @@ MainWindow::MainWindow (QWidget *parent) : BaseWindow (parent) setCentralWidget (m_display); m_display->show (); - //connects for timedisplay in playlistwindow + //connect for timedisplay in playlistwindow connect (m_display, SIGNAL (displayTime (int)), m_playlistwin, SIGNAL (setDisplayTime (int))); - connect (m_playlistwin, SIGNAL (toggleTime()), - this, SLOT (toggleTime ())); /* * MainDisplay's shaded mode diff --git a/src/mainwindow/mainwindow.h b/src/mainwindow/mainwindow.h index 5045d3f..879c750 100644 --- a/src/mainwindow/mainwindow.h +++ b/src/mainwindow/mainwindow.h @@ -43,15 +43,11 @@ class MainWindow : public BaseWindow void raisePL (void); 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 (); public slots: void switchDisplay (); void mouseMoveEvent (QMouseEvent *event); - void toggleTime () { setTimemodeReverse (!isTimemodeReverse ()); } private: bool isShaded (void) { QSettings s; return s.value("MainWindow/shaded").toBool(); } diff --git a/src/mainwindow/shadeddisplay.cpp b/src/mainwindow/shadeddisplay.cpp index 74c6b8a..30a0414 100644 --- a/src/mainwindow/shadeddisplay.cpp +++ b/src/mainwindow/shadeddisplay.cpp @@ -18,6 +18,7 @@ #include "xclientcache.h" #include "xplayback.h" +#include "application.h" #include "shadeddisplay.h" #include "titlebar.h" #include "pixmapbutton.h" @@ -45,7 +46,7 @@ ShadedDisplay::ShadedDisplay (QWidget *parent) : SkinDisplay (parent) m_time = new SmallTimeDisplay (this); 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->move (79, 4); @@ -129,7 +130,7 @@ void ShadedDisplay::setPlaytime (uint32_t time) { int32_t showtime; - if (m_mw->isTimemodeReverse()) { + if (App->isTimemodeReverse()) { showtime = (time/1000 - m_duration/1000); } else { showtime = time/1000; diff --git a/src/mainwindow/textbar.cpp b/src/mainwindow/textbar.cpp index 6021b20..5ec4eb0 100644 --- a/src/mainwindow/textbar.cpp +++ b/src/mainwindow/textbar.cpp @@ -65,7 +65,7 @@ TextScroller::TextScroller (QWidget *parent, uint w, m_timer = new QTimer (this); m_timer->setInterval (40); connect (m_timer, SIGNAL (timeout()), this, SLOT (addOffset ())); - connect (qApp, SIGNAL (settingsChanged ()), + connect (App, SIGNAL (settingsChanged ()), this, SLOT (settingsChanged ())); } diff --git a/src/playlist/playlistshade.cpp b/src/playlist/playlistshade.cpp index 49ed40b..5b6776b 100644 --- a/src/playlist/playlistshade.cpp +++ b/src/playlist/playlistshade.cpp @@ -50,7 +50,7 @@ PlaylistShade::PlaylistShade (PlaylistWindow *parent) : QWidget (parent) connect (xmmsh.cache (), SIGNAL (activeEntryChanged (QVariantHash)), this, SLOT (setMediainfo (QVariantHash))); - connect (qApp, SIGNAL(settingsChanged ()), + connect (App, SIGNAL(settingsChanged ()), this, SLOT(settingsChanged ())); m_text = "Promoe " PROMOE_VERSION " - A very neat XMMS2 client"; diff --git a/src/playlist/playlistview.cpp b/src/playlist/playlistview.cpp index f97ee49..f30278e 100644 --- a/src/playlist/playlistview.cpp +++ b/src/playlist/playlistview.cpp @@ -138,7 +138,7 @@ PlaylistView::PlaylistView (QWidget *parent) : QListView (parent) XMMSHandler &xmmsh = XMMSHandler::getInstance (); - connect (qApp, SIGNAL (settingsChanged ()), + connect (App, SIGNAL (settingsChanged ()), this, SLOT (settingsChanged ())); connect (xmmsh.xplayback (), SIGNAL(playbackStatusChanged(Xmms::Playback::Status)), diff --git a/src/playlist/playlistwidget.cpp b/src/playlist/playlistwidget.cpp index c53d247..237fa9c 100644 --- a/src/playlist/playlistwidget.cpp +++ b/src/playlist/playlistwidget.cpp @@ -15,6 +15,7 @@ #include "XMMSHandler.h" +#include "application.h" #include "mainwindow.h" #include "BrowseDialog.h" #include "playlistwindow.h" @@ -38,7 +39,6 @@ #include #include #include -#include #include #include #include @@ -235,7 +235,7 @@ PlaylistWidget::PlaylistWidget (PlaylistWindow *parent) : QWidget (parent) client.xplayback (), SLOT (next ())); // TODO: eject connect (m_controls, SIGNAL (toggleTime ()), - parent, SIGNAL (toggleTime())); + App, SLOT (toggleTime())); connect (parent, SIGNAL (setDisplayTime (int)), m_controls, SIGNAL (setDisplayTime (int))); diff --git a/src/playlist/playlistwindow.h b/src/playlist/playlistwindow.h index c53cff2..bcdd095 100644 --- a/src/playlist/playlistwindow.h +++ b/src/playlist/playlistwindow.h @@ -43,8 +43,6 @@ class PlaylistWindow : public BaseWindow { signals: void visibilityChanged(bool visible); - // connected to - void toggleTime (); // toggle the playtime // setTime is used to set playtime in playlistcontrols void setDisplayTime (int seconds); diff --git a/src/settingsdialog.cpp b/src/settingsdialog.cpp index 4bd870f..3d56fe3 100644 --- a/src/settingsdialog.cpp +++ b/src/settingsdialog.cpp @@ -39,7 +39,7 @@ SettingsDialog::SettingsDialog (QWidget *parent) : QDialog (parent) resize (400, 500); connect (this, SIGNAL (settingsChanged (void)), - qApp, SIGNAL (settingsChanged (void))); + App, SIGNAL (settingsChanged (void))); QVBoxLayout *vbox = new QVBoxLayout (this); setLayout(vbox); diff --git a/src/timedisplay.cpp b/src/timedisplay.cpp index f4fcbfa..1e6a55d 100644 --- a/src/timedisplay.cpp +++ b/src/timedisplay.cpp @@ -52,7 +52,7 @@ AbstractTimeDisplay::AbstractTimeDisplay (QWidget *parent) : QWidget (parent) void 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 >= 6000) || (time <= -6000)) { time /= 60;