Skip to content
Browse files

Merge branch 'master' of git://github.com/jonocole/lastfm-desktop

Conflicts:
	app/radio/MainWindow.cpp
  • Loading branch information...
2 parents b9f9371 + 525b09b commit 35eb4f7a562e01a2b3808b83bd1be85d5e4f8051 @dougma 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.
View
22 app/radio/MainWindow.cpp
@@ -26,7 +26,6 @@
#include <QLineEdit>
#include <QSizeGrip>
#include <QStatusBar>
-#include <QStackedLayout>
#include <QMenuBar>
MainWindow::MainWindow()
@@ -58,12 +57,12 @@ MainWindow::MainWindow()
MainWidget* mw;
QWidget* w = new QWidget();
- // a stacked layout so the messagebar can intrude over the top
- QStackedLayout* sl = new QStackedLayout(w);
- sl->setStackingMode(QStackedLayout::StackAll);
- sl->addWidget(m_messageBar = new MessageBar());
- sl->addWidget(mw = new MainWidget());
- sl->setCurrentWidget(m_messageBar); // make sure it's on top.
+
+ new QVBoxLayout( w );
+ w->layout()->addWidget(mw = new MainWidget());
+
+ m_messageBar = new MessageBar( this );
+
connect(mw, SIGNAL(startRadio(RadioStation)), SIGNAL(startRadio(RadioStation)));
AuthenticatedUser user;
@@ -78,6 +77,8 @@ MainWindow::MainWindow()
//todo: bury this:
menuBar()->addMenu("Normania")->addAction( tr("RQL"), mw, SLOT(rawrql()), QKeySequence(tr("Ctrl+r")) );
+
+ m_messageBar->raise();
}
void
@@ -109,3 +110,10 @@ MainWindow::onRadioError(int code, const QVariant& data)
break;
}
}
+
+#include <QResizeEvent>
+void
+MainWindow::resizeEvent(QResizeEvent* event)
+{
+ m_messageBar->resize( event->size().width(), m_messageBar->height());
+}
View
3 app/radio/MainWindow.h
@@ -38,6 +38,9 @@ class MainWindow : public unicorn::MainWindow
public slots:
void onRadioError(int code, const QVariant& data);
+protected:
+ virtual void resizeEvent(QResizeEvent* event);
+
private:
MessageBar* m_messageBar;
};
View
10 app/radio/widgets/MessageBar.cpp
@@ -22,12 +22,14 @@
#include <QtGui>
-MessageBar::MessageBar()
+MessageBar::MessageBar( QWidget* parent )
+ :QWidget( parent )
{
+ setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed );
+ updateGeometry();
setFixedHeight( 0 );
-
ui.papyrus = new QWidget( this );
-
+
QPalette p = palette();
p.setColor( QPalette::Text, Qt::black );
p.setColor( QPalette::Window, QColor( 0xfa, 0xfa, 0xc7 ) );
@@ -130,7 +132,7 @@ MessageBar::onLabelDestroyed()
void
-MessageBar::resizeEvent( QResizeEvent* )
+MessageBar::resizeEvent( QResizeEvent* e )
{
ui.papyrus->setFixedWidth( width() );
foreach (QLabel* l, findChildren<QLabel*>())
View
2 app/radio/widgets/MessageBar.h
@@ -39,7 +39,7 @@ class MessageBar : public QWidget
void doLayout();
public:
- MessageBar();
+ MessageBar( QWidget* parent = 0 );
public slots:
void show( const QString&, const QString& id = QString() );
View
15 lib/unicorn/UnicornApplication.cpp
@@ -39,6 +39,8 @@
#include <QDebug>
#include <QLocale>
#include <QTranslator>
+#include <QFile>
+#include <QFileInfo>
unicorn::Application::Application( int& argc, char** argv ) throw( StubbornUserException )
@@ -56,6 +58,19 @@ unicorn::Application::Application( int& argc, char** argv ) throw( StubbornUserE
AEInstallEventHandler( kCoreEventClass, kAEReopenApplication, h, 0, false );
#endif
+ #ifdef Q_WS_MAC
+ #define CSS_PATH "/../Resources/"
+ #else
+ #define CSS_PATH "/"
+ #endif
+ if( styleSheet().isEmpty()) {
+ QString cssFileName = QFileInfo(applicationFilePath()).baseName() + ".css";
+ QFile stylesheetFile( applicationDirPath() + CSS_PATH + cssFileName );
+ stylesheetFile.open( QIODevice::ReadOnly );
+ QString stylesheet( stylesheetFile.readAll() );
+ setStyleSheet( stylesheet );
+ }
+
translate();
GlobalSettings s;

0 comments on commit 35eb4f7

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