SideBar::SideBar(QWidget *parent) :QFrame(parent), m_lastButton( 0 ) { QVBoxLayout* layout = new QVBoxLayout( this ); layout->setContentsMargins( 0, 0, 0, 0 ); layout->setSpacing( 0 ); m_buttonGroup = new QButtonGroup( this ); m_buttonGroup->setExclusive( true ); layout->addWidget( ui.nowPlaying = newButton( tr( "Now Playing" ), m_buttonGroup, this ), Qt::AlignHCenter ); ui.nowPlaying->setObjectName( "nowPlaying" ); layout->addWidget( ui.scrobbles = newButton( tr( "Scrobbles" ), m_buttonGroup, this ), Qt::AlignHCenter); ui.scrobbles->setObjectName( "scrobbles" ); layout->addWidget( ui.profile = newButton( tr( "Profile" ), m_buttonGroup, this ), Qt::AlignHCenter); ui.profile->setObjectName( "profile" ); layout->addWidget( ui.friends = newButton( tr( "Friends" ), m_buttonGroup, this ), Qt::AlignHCenter); ui.friends->setObjectName( "friends" ); layout->addWidget( ui.radio = newButton( tr( "Radio" ), m_buttonGroup, this ), Qt::AlignHCenter); ui.radio->setObjectName( "radio" ); layout->addStretch( 1 ); connect( m_buttonGroup, SIGNAL(buttonClicked(QAbstractButton*)), SLOT(onButtonClicked(QAbstractButton*))); ui.nowPlaying->click(); connect( aApp, SIGNAL(sessionChanged(unicorn::Session)), SLOT(onSessionChanged(unicorn::Session)) ); onSessionChanged( aApp->currentSession() ); }
ScrobblesListWidget::ScrobblesListWidget( QWidget* parent ) :QListWidget( parent ), m_trackItem( 0 ) { setVerticalScrollMode( QAbstractItemView::ScrollPerPixel ); #ifdef Q_OS_MAC connect( verticalScrollBar(), SIGNAL(valueChanged(int)), SLOT(scroll()) ); #endif setAttribute( Qt::WA_MacNoClickThrough ); setAttribute( Qt::WA_MacShowFocusRect, false ); setUniformItemSizes( false ); setSortingEnabled( false ); setSelectionMode( QAbstractItemView::NoSelection ); setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); connect( qApp, SIGNAL( sessionChanged(unicorn::Session)), SLOT(onSessionChanged(unicorn::Session))); connect( &ScrobbleService::instance(), SIGNAL(scrobblesCached(QList<lastfm::Track>)), SLOT(onScrobblesSubmitted(QList<lastfm::Track>) ) ); connect( &ScrobbleService::instance(), SIGNAL(scrobblesSubmitted(QList<lastfm::Track>)), SLOT(onScrobblesSubmitted(QList<lastfm::Track>) ) ); connect( &ScrobbleService::instance(), SIGNAL(trackStarted(lastfm::Track,lastfm::Track)), SLOT(onTrackStarted(lastfm::Track,lastfm::Track))); connect( &ScrobbleService::instance(), SIGNAL(paused()), SLOT(onPaused())); connect( &ScrobbleService::instance(), SIGNAL(resumed()), SLOT(onResumed())); connect( &ScrobbleService::instance(), SIGNAL(stopped()), SLOT(onStopped())); onSessionChanged( aApp->currentSession() ); }
RadioWidget::RadioWidget(QWidget *parent) :QFrame( parent ), ui( new Ui::RadioWidget ) { ui->setupUi( this ); ui->lastStationLabel->setObjectName( "title" ); ui->personalLabel->setObjectName( "title" ); ui->networkLabel->setObjectName( "title" ); ui->recentLabel->setObjectName( "title" ); ui->splitter->setObjectName( "splitter" ); ui->splitter_2->setObjectName( "splitter" ); ui->splitter_3->setObjectName( "splitter" ); ui->splitter_4->setObjectName( "splitter" ); connect( ui->subscribe, SIGNAL(clicked()), SLOT(onSubscribeClicked()) ); connect( ui->listen, SIGNAL(clicked()), SLOT(onListenClicked()) ); // need to know when we are playing the radio so we can switch between now playing and last playing connect( &RadioService::instance(), SIGNAL(tuningIn(RadioStation)), SLOT(onTuningIn(RadioStation) ) ); connect( &RadioService::instance(), SIGNAL(stopped()), SLOT(onRadioStopped())); connect( &ScrobbleService::instance(), SIGNAL(trackStarted(Track,Track)), SLOT(onTrackStarted(Track,Track)) ); connect( aApp, SIGNAL(sessionChanged(unicorn::Session)), SLOT(onSessionChanged(unicorn::Session) ) ); m_movie = new QMovie( ":/loading_meta.gif", "GIF", this ); m_movie->setCacheMode( QMovie::CacheAll ); ui->spinner->setMovie( m_movie ); refresh( aApp->currentSession() ); }
/*----------------------------------------------------------------------------*/ MeasureWindow::MeasureWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MeasureWindow) { m_created = false; ui->setupUi(this); ui->profileCombo->addItems(config->profileList()); ui->profileCombo->setCurrentIndex(config->profileIndex()); m_created = true; m_newMeasure = true; onProfileChanged(config->profileIndex()); connect(database, SIGNAL(dbError(QString)), this, SLOT(onDatabaseError())); connect(controller, SIGNAL(cmdSendError()), this, SLOT(onCmdSendError())); connect(controller, SIGNAL(cmdSendOk()), this, SLOT(onCmdSendOk())); connect(controller, SIGNAL(currentStretch(double)), this, SLOT(onCurrentStretch(double))); connect(controller, SIGNAL(endOfMeasuring()), this, SLOT(onEndOfMeasuring())); connect(controller, SIGNAL(measure(double,double,int)), this, SLOT(onMeasure(double,double,int))); connect(controller, SIGNAL(nextCasseteRequest()), this, SLOT(onNextCasseteRequest())); connect(controller, SIGNAL(noParticle()), this, SLOT(onNoParticle())); connect(controller, SIGNAL(serialReceived(QString)), this, SLOT(onSerialReceived(QString))); connect(controller, SIGNAL(statusChanged(int)), this, SLOT(onStatusChanged(int))); connect(controller, SIGNAL(sizeReceived(double)), this, SLOT(onSizeReceived(double))); connect(session, SIGNAL(sessionChanged()), this, SLOT(onSessionChanged())); connect(session, SIGNAL(measureListChanged()), this, SLOT(onMeasureListChanged())); ui->sessionBox->setSession(session); measureModel = new MeasureModel(this); ui->measureTable->setModel(measureModel); //connect(session, SIGNAL(measureListChanged()), measureModel, SLOT(update())); histogrammPlotter = new HistogrammPlotter(); // ui->currentHPlotWidget->setPlotter(histogrammPlotter); curvePlotter = new CurvePlotter(); curvePlotter->x.setShowValues(false); curvePlotter->x.setText(tr("[s]")); curvePlotter->x.setDecimals(0); curvePlotter->x.setSteps(3); curvePlotter->x.setMax(3000); curvePlotter->y.setShowValues(true); curvePlotter->y.setText(tr("[N]")); curvePlotter->y.setDecimals(1); curvePlotter->setFiled(false); curvePlotter->setPointSize(4); curvePlotter->setStyle(AxisPlotter::StrokeStyle); ui->currentValuePlotWidget->setPlotter(curvePlotter); intervalCount = 6; controller->start(); }
UserMenu::UserMenu( QWidget* p ) :QMenu( p ) { connect( qApp, SIGNAL(rosterUpdated()), SLOT(refresh())); connect( qApp, SIGNAL(sessionChanged(unicorn::Session) ), SLOT( onSessionChanged( unicorn::Session) ) ); refresh(); }
NothingPlayingWidget::NothingPlayingWidget( QWidget* parent ) :QFrame( parent ), ui( new Ui::NothingPlayingWidget ) { ui->setupUi( this ); setAttribute( Qt::WA_LayoutUsesWidgetRect ); ui->top->setAttribute( Qt::WA_LayoutUsesWidgetRect ); ui->contents->setAttribute( Qt::WA_LayoutUsesWidgetRect ); onSessionChanged( aApp->currentSession() ); ui->scrobble->setText( tr( "<h2>Scrobble from your music player</h2>" "<p>Start listening to some music in your media player. You can see more information about the tracks you play on the Now Playing tab.</p>") ); ui->itunes->hide(); ui->wmp->hide(); ui->winamp->hide(); ui->foobar->hide(); #if defined( Q_OS_WIN ) || defined( Q_OS_MAC ) ui->itunes->setVisible( true ); // always show iTunes on Mac ui->itunes->setAttribute( Qt::WA_LayoutUsesWidgetRect ); connect( ui->itunes, SIGNAL(clicked()), SLOT(oniTunesClicked())); #ifndef Q_OS_MAC unicorn::PluginList pluginList; ui->itunes->setVisible( pluginList.pluginById( "itw" )->isAppInstalled() ); ui->wmp->setVisible( pluginList.pluginById( "wmp" )->isAppInstalled() ); ui->wmp->setAttribute( Qt::WA_LayoutUsesWidgetRect ); ui->winamp->setVisible( pluginList.pluginById( "wa2" )->isAppInstalled() ); ui->winamp->setAttribute( Qt::WA_LayoutUsesWidgetRect ); ui->foobar->setVisible( pluginList.pluginById( "foo3" )->isAppInstalled() ); ui->foobar->setAttribute( Qt::WA_LayoutUsesWidgetRect ); connect( ui->wmp, SIGNAL(clicked()), SLOT(onWMPClicked())); connect( ui->winamp, SIGNAL(clicked()), SLOT(onWinampClicked())); connect( ui->foobar, SIGNAL(clicked()), SLOT(onFoobarClicked())); #endif #endif connect( aApp, SIGNAL(sessionChanged(unicorn::Session)), SLOT(onSessionChanged(unicorn::Session)) ); }
/*----------------------------------------------------------------------------*/ SelSessionBox::SelSessionBox(QWidget *parent) : QGroupBox(parent), ui(new Ui::SelSessionBox) { ui->setupUi(this); timeFormat = QObject::tr("yyyy-MM-dd hh:mm", "Session model date-time format"); dateFormat = QObject::tr("yyyy-MM-dd", "Session model date format"); m_manualMode = true; m_session = new DDAMeasureSession(this); connect(ui->filterCheck, SIGNAL(toggled(bool)), ui->dateLabel, SLOT(setEnabled(bool))); connect(ui->filterCheck, SIGNAL(toggled(bool)), ui->dateCombo, SLOT(setEnabled(bool))); connect(ui->filterCheck, SIGNAL(toggled(bool)), ui->serialLabel, SLOT(setEnabled(bool))); connect(ui->filterCheck, SIGNAL(toggled(bool)), ui->serialCombo, SLOT(setEnabled(bool))); connect(ui->filterCheck, SIGNAL(toggled(bool)), ui->userLabel, SLOT(setEnabled(bool))); connect(ui->filterCheck, SIGNAL(toggled(bool)), ui->userCombo, SLOT(setEnabled(bool))); connect(ui->filterCheck, SIGNAL(toggled(bool)), ui->productLabel, SLOT(setEnabled(bool))); connect(ui->filterCheck, SIGNAL(toggled(bool)), ui->productCombo, SLOT(setEnabled(bool))); connect(ui->filterCheck, SIGNAL(toggled(bool)), ui->gritLabel, SLOT(setEnabled(bool))); connect(ui->filterCheck, SIGNAL(toggled(bool)), ui->gritCombo, SLOT(setEnabled(bool))); connect(ui->filterCheck, SIGNAL(toggled(bool)), ui->markLabel, SLOT(setEnabled(bool))); connect(ui->filterCheck, SIGNAL(toggled(bool)), ui->markCombo, SLOT(setEnabled(bool))); connect(database, SIGNAL(userChanged(int)), this, SLOT(onUsersChanged())); sessionModel = new SelSessionModel(this); ui->sessionView->setModel(sessionModel); ui->sessionView->setSelectionBehavior(QAbstractItemView::SelectRows); ui->sessionView->setSelectionMode(QAbstractItemView::SingleSelection); connect(ui->sessionView->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)), this, SLOT(onSessionChanged(QModelIndex))); sessionModel->setQuery(database->selectSessions(m_filter)); if(database->isError()) QMessageBox::critical(this, tr("Database error"), database->message()); for(int i = 0; i < ColCount - 1; i++) { QString txt = sessionModel->headerData(i, Qt::Horizontal).toString(); ui->sessionView->setColumnWidth(i, ui->sessionView->fontMetrics().boundingRect(txt).width() + 20); } ui->sessionView->setColumnWidth(StartCol - 1, ui->sessionView->fontMetrics().boundingRect(timeFormat).width()); //ui->sessionView->setColumnWidth(UserCol, ui->sessionView->fontMetrics().boundingRect("000000000").width()); //ui->sessionView->resizeColumnsToContents(); onSessionsChanged(); onUsersChanged(); onSerialsChanged(); m_manualMode = false; ui->sessionView->selectRow(0); onSessionChanged(sessionModel->index(0, 0)); }
ProfileWidget::ProfileWidget(QWidget *parent) :QFrame(parent), ui( new Ui::ProfileWidget ) { ui->setupUi( this ); connect( aApp, SIGNAL(sessionChanged(unicorn::Session*)), SLOT(onSessionChanged(unicorn::Session*)) ); connect( aApp, SIGNAL(gotUserInfo(lastfm::User)), SLOT(onGotUserInfo(lastfm::User)) ); connect( &ScrobbleService::instance(), SIGNAL(scrobblesCached(QList<lastfm::Track>)), SLOT(onScrobblesCached(QList<lastfm::Track>))); onSessionChanged( aApp->currentSession() ); }
ProfileWidget::ProfileWidget(QWidget *parent) :StylableWidget(parent) { QVBoxLayout* layout = new QVBoxLayout( this ); layout->setContentsMargins( 0, 0, 0, 0 ); layout->setSpacing( 0 ); connect( aApp, SIGNAL(sessionChanged(unicorn::Session*)), SLOT(onSessionChanged(unicorn::Session*)) ); connect( aApp, SIGNAL(gotUserInfo(lastfm::User)), SLOT(onGotUserInfo(lastfm::User)) ); connect( &ScrobbleService::instance(), SIGNAL(scrobblesCached(QList<lastfm::Track>)), SLOT(onScrobblesCached(QList<lastfm::Track>))); onSessionChanged( aApp->currentSession() ); }
FriendListWidget::FriendListWidget(QWidget *parent) : QWidget(parent), ui( new Ui::FriendListWidget ) { ui->setupUi( this ); #ifdef Q_OS_MAC connect( ui->friends->verticalScrollBar(), SIGNAL(valueChanged(int)), SLOT(scroll()) ); #endif ui->noFriends->setText( tr( "<h3>You haven't made any friends on Last.fm yet.</h3>" "<p>Find your Facebook friends and email contacts on Last.fm quickly and easily using the friend finder.</p>" ) ); connect( ui->findFriends, SIGNAL(clicked()), SLOT(onFindFriends()) ); #if QT_VERSION >= 0x040700 // The placeholder property was introduced in Qt 4.7 ui->filter->setPlaceholderText( tr( "Search for a friend by username or real name" ) ); #endif ui->filter->setAttribute( Qt::WA_MacShowFocusRect, false ); ui->friends->setObjectName( "friends" ); ui->friends->setAttribute( Qt::WA_MacShowFocusRect, false ); connect( ui->filter, SIGNAL(textChanged(QString)), SLOT(onTextChanged(QString))); connect( aApp, SIGNAL(sessionChanged(unicorn::Session)), SLOT(onSessionChanged(unicorn::Session)) ); m_movie = new QMovie( ":/loading_meta.gif", "GIF", this ); m_movie->setCacheMode( QMovie::CacheAll ); ui->spinner->setMovie( m_movie ); ui->stackedWidget->setCurrentWidget( ui->spinnerPage ); m_movie->start(); onSessionChanged( aApp->currentSession() ); }
ScrobbleService::ScrobbleService() { qRegisterMetaType<Track>("Track"); /// mediator m_mediator = new PlayerMediator(this); connect( m_mediator, SIGNAL(activeConnectionChanged( PlayerConnection* )), SLOT(setConnection( PlayerConnection* )) ); /// listeners try{ #ifdef Q_OS_MAC ITunesListener* itunes = new ITunesListener(m_mediator); connect(itunes, SIGNAL(newConnection(PlayerConnection*)), m_mediator, SLOT(follow(PlayerConnection*))); SpotifyListenerMac* spotify = new SpotifyListenerMac(m_mediator); connect(spotify, SIGNAL(newConnection(PlayerConnection*)), m_mediator, SLOT(follow(PlayerConnection*))); #endif #ifdef Q_OS_WIN SpotifyListenerWin* spotify = new SpotifyListenerWin(m_mediator); connect(spotify, SIGNAL(newConnection(PlayerConnection*)), m_mediator, SLOT(follow(PlayerConnection*))); #endif QObject* o = new PlayerListener(m_mediator); connect(o, SIGNAL(newConnection(PlayerConnection*)), m_mediator, SLOT(follow(PlayerConnection*))); #if defined(Q_OS_WIN) || defined(Q_OS_MAC) o = new LegacyPlayerListener(m_mediator); connect(o, SIGNAL(newConnection(PlayerConnection*)), m_mediator, SLOT(follow(PlayerConnection*))); #else Mpris2Listener* mpris2 = new Mpris2Listener(m_mediator); connect(mpris2, SIGNAL(newConnection(PlayerConnection*)), m_mediator, SLOT(follow(PlayerConnection*))); mpris2->createConnection(); #endif } catch(std::runtime_error& e){ qWarning() << e.what(); //TODO user visible warning } m_mediator->follow( new RadioConnection( this ) ); connect( aApp, SIGNAL(sessionChanged(unicorn::Session)), SLOT(onSessionChanged(unicorn::Session)) ); resetScrobbler(); }
ScrobbleService::ScrobbleService() { /// mediator m_mediator = new PlayerMediator(this); connect( m_mediator, SIGNAL(activeConnectionChanged( PlayerConnection* )), SLOT(setConnection( PlayerConnection* )) ); /// listeners try{ #ifdef Q_OS_MAC ITunesListener* itunes = new ITunesListener(m_mediator); connect(itunes, SIGNAL(newConnection(PlayerConnection*)), m_mediator, SLOT(follow(PlayerConnection*))); itunes->start(); SpotifyListenerMac* spotify = new SpotifyListenerMac(m_mediator); connect(spotify, SIGNAL(newConnection(PlayerConnection*)), m_mediator, SLOT(follow(PlayerConnection*))); #endif #ifdef Q_OS_WIN SpotifyListenerWin* spotify = new SpotifyListenerWin(m_mediator); connect(spotify, SIGNAL(newConnection(PlayerConnection*)), m_mediator, SLOT(follow(PlayerConnection*))); #endif QObject* o = new PlayerListener(m_mediator); connect(o, SIGNAL(newConnection(PlayerConnection*)), m_mediator, SLOT(follow(PlayerConnection*))); #if defined(Q_OS_WIN) || defined(Q_OS_MAC) o = new LegacyPlayerListener(m_mediator); connect(o, SIGNAL(newConnection(PlayerConnection*)), m_mediator, SLOT(follow(PlayerConnection*))); #endif #ifdef QT_DBUS_LIB DBusListener* dbus = new DBusListener(mediator); connect(dbus, SIGNAL(newConnection(PlayerConnection*)), m_mediator, SLOT(follow(PlayerConnection*))); #endif } catch(std::runtime_error& e){ qWarning() << e.what(); //TODO user visible warning } m_mediator->follow( new RadioConnection( this ) ); connect( aApp, SIGNAL(sessionChanged(unicorn::Session)), SLOT(onSessionChanged(unicorn::Session)) ); resetScrobbler(); }
void ScrobblesListWidget::onSessionChanged( unicorn::Session* session ) { onSessionChanged( session->userInfo().name() ); }