Skip to content
Browse files

Refactor scrobble controls to not call global app instance before it …

…is initialised(crashed on OSX release build.)

New menubar icon on osx.
  • Loading branch information...
1 parent 31b735f commit 525b09ba32bc850138e4e2e592595a2999e2b519 @jonocole jonocole committed Sep 10, 2009
View
13 app/audioscrobbler/Application.cpp
@@ -20,6 +20,7 @@
*/
#include "Application.h"
#include "MetadataWindow.h"
+#include "ScrobbleControls.h"
#include "StopWatch.h"
#include "lib/listener/DBusListener.h"
#include "lib/listener/PlayerConnection.h"
@@ -33,23 +34,25 @@
#include <QMenu>
#include "TagDialog.h"
#include "ShareDialog.h"
-
using audioscrobbler::Application;
#define ELLIPSIS QString::fromUtf8("")
#ifdef Q_WS_X11
#define AS_TRAY_ICON ":16x16.png"
-#else
+#elif defined( Q_WS_WIN )
#define AS_TRAY_ICON ":22x22.png"
+#elif defined( Q_WS_MAC )
+ #define AS_TRAY_ICON ":19x15.png"
#endif
Application::Application(int& argc, char** argv) : unicorn::Application(argc, argv)
{
/// tray
tray = new QSystemTrayIcon(this);
connect(tray, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), SLOT(onTrayActivated(QSystemTrayIcon::ActivationReason)));
- tray->setIcon(QIcon(AS_TRAY_ICON));
+ QIcon trayIcon( AS_TRAY_ICON );
+ tray->setIcon(trayIcon);
tray->show();
/// tray menu
@@ -80,6 +83,10 @@ Application::Application(int& argc, char** argv) : unicorn::Application(argc, ar
/// MetadataWindow
mw = new MetadataWindow;
+ ScrobbleControls* sc = mw->scrobbleControls();
+ sc->setLoveAction( m_love_action );
+ sc->setTagAction( m_tag_action );
+ sc->setShareAction( m_share_action );
/// scrobbler
as = new Audioscrobbler("ass");
View
13 app/audioscrobbler/MetadataWindow.cpp
@@ -150,7 +150,7 @@ MetadataWindow::MetadataWindow()
//Seemingly the only way to get a central widget in a QStatusBar
//is to add an empty widget either side with a stretch value.
status->addWidget( new QWidget( status), 1 );
- status->addWidget( new ScrobbleControls());
+ status->addWidget( ui.sc = new ScrobbleControls());
status->addWidget( new QWidget( status), 1 );
setStatusBar( status );
}
@@ -167,6 +167,12 @@ MetadataWindow::MetadataWindow()
resize(20, 500);
}
+//ScrobbleControls*
+//MetadataWindow::scrobbleControls() const
+//{
+// return ui.sc;
+//}
+
void
MetadataWindow::onAnchorClicked( const QUrl& link )
{
@@ -217,9 +223,10 @@ MetadataWindow::onArtistGotInfo()
ui.listeners->setText(QString("%L1").arg(listeners));
ui.tags->setText(tags);
- //TODO if empty suggest they edit it
- QString style = "<style>" + ((audioscrobbler::Application*)qApp)->loadedStyleSheet() + styleSheet() + "</style>";
+ QString stylesheet = ((audioscrobbler::Application*)qApp)->loadedStyleSheet() + styleSheet();
+ QString style = "<style>" + stylesheet + "</style>";
+ //TODO if empty suggest they edit it
QString bio;
{
QStringList bioList = lfm["artist"]["bio"]["content"].text().trimmed().split( "\r" );
View
2 app/audioscrobbler/MetadataWindow.h
@@ -39,11 +39,13 @@ class MetadataWindow : public unicorn::MainWindow
class QPushButton* love;
class QPushButton* tag;
class QPushButton* share;
+ class ScrobbleControls* sc;
} ui;
public:
MetadataWindow();
const Track& currentTrack() const{ return m_currentTrack; }
+ class ScrobbleControls* scrobbleControls() const{ return ui.sc; }
public slots:
void onTrackStarted(const Track&, const Track&);
View
35 app/audioscrobbler/ScrobbleControls.cpp
@@ -28,17 +28,30 @@
ScrobbleControls::ScrobbleControls()
{
new QHBoxLayout( this );
- QPushButton* b;
- layout()->addWidget(b = new QPushButton(tr("love")));
- b->setObjectName("love");
- connect( b, SIGNAL(clicked()), ((audioscrobbler::Application*)qApp)->loveAction(), SLOT(trigger()));
- b->setAutoFillBackground( true );
+ layout()->addWidget(ui.love = new QPushButton(tr("love")));
+ ui.love->setObjectName("love");
- layout()->addWidget(b = new QPushButton(tr("tag")));
- b->setObjectName("tag");
- connect( b, SIGNAL(clicked()), ((audioscrobbler::Application*)qApp)->tagAction(), SLOT(trigger()));
+ layout()->addWidget(ui.tag = new QPushButton(tr("tag")));
+ ui.tag->setObjectName("tag");
- layout()->addWidget(b = new QPushButton(tr("share")));
- b->setObjectName("share");
- connect( b, SIGNAL(clicked()), ((audioscrobbler::Application*)qApp)->shareAction(), SLOT(trigger()));
+ layout()->addWidget(ui.share = new QPushButton(tr("share")));
+ ui.share->setObjectName("share");
+}
+
+void
+ScrobbleControls::setLoveAction( const QAction* a )
+{
+ connect( ui.love, SIGNAL(clicked()), a, SLOT(trigger()));
+}
+
+void
+ScrobbleControls::setTagAction( const QAction* a )
+{
+ connect( ui.tag, SIGNAL(clicked()), a, SLOT(trigger()));
+}
+
+void
+ScrobbleControls::setShareAction( const QAction* a )
+{
+ connect( ui.share, SIGNAL(clicked()), a, SLOT(trigger()));
}
View
13 app/audioscrobbler/ScrobbleControls.h
@@ -23,12 +23,23 @@
#include "lib/unicorn/StylableWidget.h"
+class QPushButton;
class ScrobbleControls : public StylableWidget
{
Q_OBJECT
public:
ScrobbleControls();
-
+
+ void setLoveAction( const QAction* a );
+ void setTagAction( const QAction* a );
+ void setShareAction( const QAction* a );
+
+protected:
+ struct {
+ QPushButton* love;
+ QPushButton* tag;
+ QPushButton* share;
+ } ui;
};
#endif //SCROBBLE_CONTROLS_H
View
4 app/audioscrobbler/audioscrobbler.pro.in
@@ -2,7 +2,7 @@ TEMPLATE = app
TARGET = audioscrobbler
VERSION = 2.0.0
QT = core gui xml network
-CONFIG += lastfm unicorn
-LIBS += -llistener
+CONFIG += lastfm unicorn listener
DEFINES += LASTFM_COLLAPSE_NAMESPACE
include( $$ROOT_DIR/admin/include.qmake )
+ICON = ../client/mac/client.icns
View
BIN app/audioscrobbler/qrc/19x15.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN app/audioscrobbler/qrc/19x15_selected.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 525b09b

Please sign in to comment.
Something went wrong with that request. Please try again.