mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 22:26:32 +02:00
Split TomahawkWindow into TomahawkWindow and TomahawkDesktopWindow which now contains everything specific to the main tomahawk gui
This commit is contained in:
@@ -78,6 +78,7 @@ SET( tomahawkSourcesGui ${tomahawkSourcesGui}
|
||||
settingslistdelegate.cpp
|
||||
resolversmodel.cpp
|
||||
tomahawkwindow.cpp
|
||||
tomahawkdesktopwindow.cpp
|
||||
)
|
||||
|
||||
SET( tomahawkHeaders ${tomahawkHeaders}
|
||||
@@ -126,10 +127,11 @@ SET( tomahawkHeadersGui ${tomahawkHeadersGui}
|
||||
resolversmodel.h
|
||||
delegateconfigwrapper.h
|
||||
tomahawkwindow.h
|
||||
tomahawkdesktopwindow.h
|
||||
)
|
||||
|
||||
SET( tomahawkUI ${tomahawkUI}
|
||||
tomahawkwindow.ui
|
||||
tomahawkdesktopwindow.ui
|
||||
diagnosticsdialog.ui
|
||||
stackedsettingsdialog.ui
|
||||
proxydialog.ui
|
||||
|
@@ -30,6 +30,8 @@
|
||||
#include "utils/logger.h"
|
||||
#include "dropjob.h"
|
||||
|
||||
#include "tomahawkdesktopwindow.h"
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
|
||||
@@ -78,7 +80,7 @@ CategoryAddItem::activate()
|
||||
break;
|
||||
}
|
||||
case SourcesModel::StationsCategory:
|
||||
APP->mainWindow()->createStation();
|
||||
APP->desktopWindow()->createStation();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -100,7 +102,7 @@ CategoryAddItem::dialogClosed( int ret )
|
||||
|
||||
} else if ( playlistSelectorDlg->playlistTypeIsAuto() && ret ) {
|
||||
// create Auto Playlist
|
||||
APP->mainWindow()->createAutomaticPlaylist( playlistName );
|
||||
APP->desktopWindow()->createAutomaticPlaylist( playlistName );
|
||||
} else if ( !ret ) {
|
||||
model()->viewPageActivated( ViewManager::instance()->currentPage() );
|
||||
}
|
||||
@@ -281,7 +283,7 @@ CategoryAddItem::parsedDroppedTracks( const QList< query_ptr >& tracks )
|
||||
ViewManager::instance()->show( newpl );
|
||||
|
||||
// Give a shot to try to rename it. The playlist has to be created first. ugly.
|
||||
QTimer::singleShot( 300, APP->mainWindow()->sourceTreeView(), SLOT( renamePlaylist() ) );
|
||||
QTimer::singleShot( 300, APP->desktopWindow()->sourceTreeView(), SLOT( renamePlaylist() ) );
|
||||
} else if( m_categoryType == SourcesModel::StationsCategory ) {
|
||||
// seed the playlist with these song filters
|
||||
QString name = tracks.isEmpty() ? tr( "New Station" ) : tr( "%1 Station" ).arg( tracks.first()->track() );
|
||||
@@ -300,7 +302,7 @@ CategoryAddItem::parsedDroppedTracks( const QList< query_ptr >& tracks )
|
||||
|
||||
ViewManager::instance()->show( newpl );
|
||||
// Give a shot to try to rename it. The playlist has to be created first. ugly.
|
||||
QTimer::singleShot( 300, APP->mainWindow()->sourceTreeView(), SLOT( renamePlaylist() ) );
|
||||
QTimer::singleShot( 300, APP->desktopWindow()->sourceTreeView(), SLOT( renamePlaylist() ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -64,7 +64,7 @@
|
||||
#include "config.h"
|
||||
|
||||
#ifndef TOMAHAWK_HEADLESS
|
||||
#include "tomahawkwindow.h"
|
||||
#include "tomahawkdesktopwindow.h"
|
||||
#include "settingsdialog.h"
|
||||
#include <QMessageBox>
|
||||
#endif
|
||||
@@ -223,7 +223,7 @@ TomahawkApp::init()
|
||||
if ( !m_headless )
|
||||
{
|
||||
tDebug() << "Init MainWindow.";
|
||||
m_mainwindow = new TomahawkWindow();
|
||||
m_mainwindow = new TomahawkDesktopWindow();
|
||||
m_mainwindow->setWindowTitle( "Tomahawk" );
|
||||
m_mainwindow->setObjectName( "TH_Main_Window" );
|
||||
|
||||
@@ -340,6 +340,20 @@ TomahawkApp::audioControls()
|
||||
{
|
||||
return m_mainwindow->audioControls();
|
||||
}
|
||||
|
||||
|
||||
TomahawkWindow*
|
||||
TomahawkApp::mainWindow() const
|
||||
{
|
||||
// why does static_casdt<TomahawkWindow*> not work here?!
|
||||
return (TomahawkWindow*) ( m_mainwindow );
|
||||
}
|
||||
|
||||
TomahawkDesktopWindow*
|
||||
TomahawkApp::desktopWindow() const
|
||||
{
|
||||
return m_mainwindow;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
@@ -65,7 +65,8 @@ namespace Tomahawk
|
||||
#endif
|
||||
|
||||
#ifndef TOMAHAWK_HEADLESS
|
||||
class TomahawkWindow;
|
||||
class TomahawkDesktopWindow;
|
||||
class AudioControls;
|
||||
#endif
|
||||
|
||||
#ifdef TOUCHMAHAWK
|
||||
@@ -91,7 +92,8 @@ public:
|
||||
|
||||
#ifndef TOMAHAWK_HEADLESS
|
||||
AudioControls* audioControls();
|
||||
TomahawkWindow* mainWindow() const { return m_mainwindow; }
|
||||
TomahawkWindow* mainWindow() const;
|
||||
TomahawkDesktopWindow* desktopWindow() const;
|
||||
#endif
|
||||
|
||||
#ifdef TOUCHMAHAWK
|
||||
@@ -144,7 +146,7 @@ private:
|
||||
#endif
|
||||
|
||||
#ifndef TOMAHAWK_HEADLESS
|
||||
TomahawkWindow* m_mainwindow;
|
||||
TomahawkDesktopWindow* m_mainwindow;
|
||||
#endif
|
||||
|
||||
#ifdef TOUCHMAHAWK
|
||||
|
609
src/tomahawkdesktopwindow.cpp
Normal file
609
src/tomahawkdesktopwindow.cpp
Normal file
@@ -0,0 +1,609 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Tomahawk is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "tomahawkdesktopwindow.h"
|
||||
#include "ui_tomahawkdesktopwindow.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QCloseEvent>
|
||||
#include <QShowEvent>
|
||||
#include <QHideEvent>
|
||||
#include <QInputDialog>
|
||||
#include <QPixmap>
|
||||
#include <QPropertyAnimation>
|
||||
#include <QLineEdit>
|
||||
#include <QMessageBox>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkReply>
|
||||
#include <QTimer>
|
||||
#include <QToolBar>
|
||||
|
||||
#include "playlist.h"
|
||||
#include "query.h"
|
||||
#include "artist.h"
|
||||
|
||||
#include "audio/audioengine.h"
|
||||
#include "viewmanager.h"
|
||||
#include "sip/SipHandler.h"
|
||||
#include "sourcetree/sourcetreeview.h"
|
||||
#include "widgets/animatedsplitter.h"
|
||||
#include "utils/proxystyle.h"
|
||||
#include "utils/widgetdragfilter.h"
|
||||
#include "utils/xspfloader.h"
|
||||
#include "widgets/newplaylistwidget.h"
|
||||
#include "widgets/searchwidget.h"
|
||||
#include "widgets/playlisttypeselectordlg.h"
|
||||
|
||||
#include "audiocontrols.h"
|
||||
#include "settingsdialog.h"
|
||||
#include "diagnosticsdialog.h"
|
||||
#include "tomahawksettings.h"
|
||||
#include "sourcelist.h"
|
||||
#include "PipelineStatusView.h"
|
||||
#include "transferview.h"
|
||||
#include "tomahawktrayicon.h"
|
||||
#include "playlist/dynamic/GeneratorInterface.h"
|
||||
#include "scanmanager.h"
|
||||
#include "tomahawkapp.h"
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
#include <qtsparkle/Updater>
|
||||
#endif
|
||||
|
||||
#include "utils/logger.h"
|
||||
#include "thirdparty/Qocoa/qsearchfield.h"
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
|
||||
TomahawkDesktopWindow::TomahawkDesktopWindow( QWidget* parent )
|
||||
: TomahawkWindow( parent )
|
||||
, ui( new Ui::TomahawkDesktopWindow )
|
||||
, m_searchWidget( 0 )
|
||||
, m_audioControls( new AudioControls( this ) )
|
||||
{
|
||||
ViewManager* vm = new ViewManager( this );
|
||||
connect( vm, SIGNAL( showQueueRequested() ), SLOT( showQueue() ) );
|
||||
connect( vm, SIGNAL( hideQueueRequested() ), SLOT( hideQueue() ) );
|
||||
|
||||
ui->setupUi( this );
|
||||
applyPlatformTweaks();
|
||||
|
||||
ui->centralWidget->setContentsMargins( 0, 0, 0, 0 );
|
||||
TomahawkUtils::unmarginLayout( ui->centralWidget->layout() );
|
||||
|
||||
setupSideBar();
|
||||
statusBar()->addPermanentWidget( m_audioControls, 1 );
|
||||
|
||||
setupUpdateCheck();
|
||||
loadSettings();
|
||||
setupSignals();
|
||||
|
||||
// set initial state
|
||||
onSipDisconnected();
|
||||
vm->setQueue( m_queueView );
|
||||
ViewManager::instance()->showWelcomePage();
|
||||
}
|
||||
|
||||
|
||||
TomahawkDesktopWindow::~TomahawkDesktopWindow()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkDesktopWindow::retranslateUi()
|
||||
{
|
||||
ui->retranslateUi( this );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkDesktopWindow::loadSettings()
|
||||
{
|
||||
TomahawkSettings* s = TomahawkSettings::instance();
|
||||
|
||||
if ( !s->mainWindowSplitterState().isEmpty() )
|
||||
ui->splitter->restoreState( s->mainWindowSplitterState() );
|
||||
|
||||
TomahawkWindow::loadSettings();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkDesktopWindow::saveSettings()
|
||||
{
|
||||
TomahawkSettings* s = TomahawkSettings::instance();
|
||||
s->setMainWindowSplitterState( ui->splitter->saveState() );
|
||||
|
||||
TomahawkWindow::saveSettings();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkDesktopWindow::applyPlatformTweaks()
|
||||
{
|
||||
// HACK QtCurve causes an infinite loop on startup. This is because setStyle calls setPalette, which calls ensureBaseStyle,
|
||||
// which loads QtCurve. QtCurve calls setPalette, which creates an infinite loop. The UI will look like CRAP with QtCurve, but
|
||||
// the user is asking for it explicitly... so he's gonna be stuck with an ugly UI.
|
||||
if ( !QString( qApp->style()->metaObject()->className() ).toLower().contains( "qtcurve" ) )
|
||||
qApp->setStyle( new ProxyStyle() );
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
setUnifiedTitleAndToolBarOnMac( true );
|
||||
delete ui->hline1;
|
||||
delete ui->hline2;
|
||||
#else
|
||||
ui->hline1->setStyleSheet( "border: 1px solid gray;" );
|
||||
ui->hline2->setStyleSheet( "border: 1px solid gray;" );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkDesktopWindow::setupSideBar()
|
||||
{
|
||||
// Delete fake designer widgets
|
||||
delete ui->sidebarWidget;
|
||||
delete ui->playlistWidget;
|
||||
|
||||
QWidget* sidebarWidget = new QWidget();
|
||||
sidebarWidget->setLayout( new QVBoxLayout() );
|
||||
|
||||
m_sidebar = new AnimatedSplitter();
|
||||
m_sidebar->setOrientation( Qt::Vertical );
|
||||
m_sidebar->setChildrenCollapsible( false );
|
||||
|
||||
m_searchWidget = new QSearchField( m_sidebar );
|
||||
m_searchWidget->setPlaceholderText( "Global Search..." );
|
||||
connect( m_searchWidget, SIGNAL( returnPressed() ), this, SLOT( onFilterEdited() ) );
|
||||
|
||||
m_sourcetree = new SourceTreeView();
|
||||
TransferView* transferView = new TransferView( m_sidebar );
|
||||
PipelineStatusView* pipelineView = new PipelineStatusView( m_sidebar );
|
||||
|
||||
m_queueView = new QueueView( m_sidebar );
|
||||
m_queueModel = new PlaylistModel( m_queueView );
|
||||
m_queueModel->setStyle( PlaylistModel::Short );
|
||||
m_queueView->queue()->setPlaylistModel( m_queueModel );
|
||||
m_queueView->queue()->playlistModel()->setReadOnly( false );
|
||||
AudioEngine::instance()->setQueue( m_queueView->queue()->proxyModel() );
|
||||
|
||||
m_sidebar->addWidget( m_searchWidget );
|
||||
m_sidebar->addWidget( m_sourcetree );
|
||||
m_sidebar->addWidget( transferView );
|
||||
m_sidebar->addWidget( pipelineView );
|
||||
m_sidebar->addWidget( m_queueView );
|
||||
|
||||
m_sidebar->setGreedyWidget( 1 );
|
||||
m_sidebar->hide( 1, false );
|
||||
m_sidebar->hide( 2, false );
|
||||
m_sidebar->hide( 3, false );
|
||||
m_sidebar->hide( 4, false );
|
||||
|
||||
sidebarWidget->layout()->addWidget( m_sidebar );
|
||||
sidebarWidget->setContentsMargins( 0, 0, 0, 0 );
|
||||
sidebarWidget->layout()->setContentsMargins( 0, 0, 0, 0 );
|
||||
sidebarWidget->layout()->setMargin( 0 );
|
||||
|
||||
#ifndef Q_OS_MAC
|
||||
sidebarWidget->layout()->setSpacing( 0 );
|
||||
#endif
|
||||
|
||||
ui->splitter->addWidget( sidebarWidget );
|
||||
ui->splitter->addWidget( ViewManager::instance()->widget() );
|
||||
|
||||
ui->splitter->setStretchFactor( 0, 1 );
|
||||
ui->splitter->setStretchFactor( 1, 3 );
|
||||
ui->splitter->setCollapsible( 1, false );
|
||||
ui->splitter->setHandleWidth( 1 );
|
||||
|
||||
ui->actionShowOfflineSources->setChecked( TomahawkSettings::instance()->showOfflineSources() );
|
||||
}
|
||||
|
||||
void
|
||||
TomahawkDesktopWindow::setupUpdateCheck()
|
||||
{
|
||||
#ifndef Q_WS_MAC
|
||||
ui->menu_Help->insertSeparator( ui->actionAboutTomahawk );
|
||||
#endif
|
||||
|
||||
#if defined( Q_OS_DARWIN ) && defined( HAVE_SPARKLE )
|
||||
QAction* checkForUpdates = ui->menu_Help->addAction( tr( "Check For Updates..." ) );
|
||||
checkForUpdates->setMenuRole( QAction::ApplicationSpecificRole );
|
||||
connect( checkForUpdates, SIGNAL( triggered( bool ) ), SLOT( checkForUpdates() ) );
|
||||
#elif defined( WIN32 )
|
||||
QUrl updaterUrl;
|
||||
|
||||
if ( qApp->arguments().contains( "--debug" ) )
|
||||
updaterUrl.setUrl( "http://download.tomahawk-player.org/sparklewin-debug" );
|
||||
else
|
||||
updaterUrl.setUrl( "http://download.tomahawk-player.org/sparklewin" );
|
||||
|
||||
qtsparkle::Updater* updater = new qtsparkle::Updater( updaterUrl, this );
|
||||
Q_ASSERT( TomahawkUtils::nam() != 0 );
|
||||
updater->SetNetworkAccessManager( TomahawkUtils::nam() );
|
||||
updater->SetVersion( TomahawkUtils::appFriendlyVersion() );
|
||||
|
||||
ui->menu_Help->addSeparator();
|
||||
QAction* checkForUpdates = ui->menu_Help->addAction( tr( "Check For Updates..." ) );
|
||||
connect( checkForUpdates, SIGNAL( triggered() ), updater, SLOT( CheckNow() ) );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkDesktopWindow::setupSignals()
|
||||
{
|
||||
// <From PlaylistManager>
|
||||
connect( ViewManager::instance(), SIGNAL( repeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode ) ),
|
||||
m_audioControls, SLOT( onRepeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode ) ) );
|
||||
connect( ViewManager::instance(), SIGNAL( shuffleModeChanged( bool ) ),
|
||||
m_audioControls, SLOT( onShuffleModeChanged( bool ) ) );
|
||||
|
||||
// <From AudioEngine>
|
||||
connect( AudioEngine::instance(), SIGNAL( loading( const Tomahawk::result_ptr& ) ),
|
||||
SLOT( onPlaybackLoading( const Tomahawk::result_ptr& ) ) );
|
||||
connect( AudioEngine::instance(), SIGNAL( started( Tomahawk::result_ptr ) ), SLOT( audioStarted() ) );
|
||||
connect( AudioEngine::instance(), SIGNAL( resumed()), SLOT( audioStarted() ) );
|
||||
connect( AudioEngine::instance(), SIGNAL( paused() ), SLOT( audioStopped() ) );
|
||||
connect( AudioEngine::instance(), SIGNAL( stopped() ), SLOT( audioStopped() ) );
|
||||
|
||||
// <Menu Items>
|
||||
// connect( ui->actionAddPeerManually, SIGNAL( triggered() ), SLOT( addPeerManually() ) );
|
||||
connect( ui->actionPreferences, SIGNAL( triggered() ), SLOT( showSettingsDialog() ) );
|
||||
connect( ui->actionDiagnostics, SIGNAL( triggered() ), SLOT( showDiagnosticsDialog() ) );
|
||||
connect( ui->actionToggleConnect, SIGNAL( triggered() ), SipHandler::instance(), SLOT( toggleConnect() ) );
|
||||
connect( ui->actionUpdateCollection, SIGNAL( triggered() ), SLOT( updateCollectionManually() ) );
|
||||
connect( ui->actionRescanCollection, SIGNAL( triggered() ), SLOT( rescanCollectionManually() ) );
|
||||
connect( ui->actionLoadXSPF, SIGNAL( triggered() ), SLOT( loadSpiff() ));
|
||||
connect( ui->actionCreatePlaylist, SIGNAL( triggered() ), SLOT( createPlaylist() ));
|
||||
connect( ui->actionCreate_New_Station, SIGNAL( triggered() ), SLOT( createStation() ));
|
||||
connect( ui->actionAboutTomahawk, SIGNAL( triggered() ), SLOT( showAboutTomahawk() ) );
|
||||
connect( ui->actionExit, SIGNAL( triggered() ), qApp, SLOT( quit() ) );
|
||||
connect( ui->actionShowOfflineSources, SIGNAL( triggered() ), SLOT( showOfflineSources() ) );
|
||||
|
||||
connect( ui->actionPlay, SIGNAL( triggered() ), AudioEngine::instance(), SLOT( playPause() ) );
|
||||
connect( ui->actionNext, SIGNAL( triggered() ), AudioEngine::instance(), SLOT( next() ) );
|
||||
connect( ui->actionPrevious, SIGNAL( triggered() ), AudioEngine::instance(), SLOT( previous() ) );
|
||||
|
||||
#if defined( Q_WS_MAC )
|
||||
connect( ui->actionMinimize, SIGNAL( triggered() ), SLOT( minimize() ) );
|
||||
connect( ui->actionZoom, SIGNAL( triggered() ), SLOT( maximize() ) );
|
||||
#else
|
||||
ui->menuWindow->clear();
|
||||
ui->menuWindow->menuAction()->setVisible( false );
|
||||
#endif
|
||||
|
||||
// <SipHandler>
|
||||
connect( SipHandler::instance(), SIGNAL( connected( SipPlugin* ) ), SLOT( onSipConnected() ) );
|
||||
connect( SipHandler::instance(), SIGNAL( disconnected( SipPlugin* ) ), SLOT( onSipDisconnected() ) );
|
||||
connect( SipHandler::instance(), SIGNAL( authError( SipPlugin* ) ), SLOT( onSipError() ) );
|
||||
|
||||
// <SipMenu>
|
||||
connect( SipHandler::instance(), SIGNAL( pluginAdded( SipPlugin* ) ), this, SLOT( onSipPluginAdded( SipPlugin* ) ) );
|
||||
connect( SipHandler::instance(), SIGNAL( pluginRemoved( SipPlugin* ) ), this, SLOT( onSipPluginRemoved( SipPlugin* ) ) );
|
||||
foreach( SipPlugin *plugin, SipHandler::instance()->allPlugins() )
|
||||
{
|
||||
connect( plugin, SIGNAL( addMenu( QMenu* ) ), this, SLOT( pluginMenuAdded( QMenu* ) ) );
|
||||
connect( plugin, SIGNAL( removeMenu( QMenu* ) ), this, SLOT( pluginMenuRemoved( QMenu* ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
TomahawkDesktopWindow::showSettingsDialog()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
SettingsDialog win;
|
||||
win.exec();
|
||||
}
|
||||
|
||||
|
||||
void TomahawkDesktopWindow::showDiagnosticsDialog()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
DiagnosticsDialog win;
|
||||
win.exec();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkDesktopWindow::updateCollectionManually()
|
||||
{
|
||||
if ( TomahawkSettings::instance()->hasScannerPaths() )
|
||||
ScanManager::instance()->runScan();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkDesktopWindow::rescanCollectionManually()
|
||||
{
|
||||
if ( TomahawkSettings::instance()->hasScannerPaths() )
|
||||
ScanManager::instance()->runScan( true );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkDesktopWindow::addPeerManually()
|
||||
{
|
||||
TomahawkSettings* s = TomahawkSettings::instance();
|
||||
bool ok;
|
||||
QString addr = QInputDialog::getText( this, tr( "Connect To Peer" ),
|
||||
tr( "Enter peer address:" ), QLineEdit::Normal,
|
||||
s->value( "connip" ).toString(), &ok ); // FIXME
|
||||
if ( !ok )
|
||||
return;
|
||||
|
||||
s->setValue( "connip", addr );
|
||||
QString ports = QInputDialog::getText( this, tr( "Connect To Peer" ),
|
||||
tr( "Enter peer port:" ), QLineEdit::Normal,
|
||||
s->value( "connport", "50210" ).toString(), &ok );
|
||||
if ( !ok )
|
||||
return;
|
||||
|
||||
s->setValue( "connport", ports );
|
||||
int port = ports.toInt();
|
||||
QString key = QInputDialog::getText( this, tr( "Connect To Peer" ),
|
||||
tr( "Enter peer key:" ), QLineEdit::Normal,
|
||||
"whitelist", &ok );
|
||||
if ( !ok )
|
||||
return;
|
||||
|
||||
qDebug() << "Attempting to connect to" << addr;
|
||||
Servent::instance()->connectToPeer( addr, port, key );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkDesktopWindow::pluginMenuAdded( QMenu* menu )
|
||||
{
|
||||
ui->menuNetwork->addMenu( menu );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkDesktopWindow::pluginMenuRemoved( QMenu* menu )
|
||||
{
|
||||
foreach( QAction* action, ui->menuNetwork->actions() )
|
||||
{
|
||||
if( action->menu() == menu )
|
||||
{
|
||||
ui->menuNetwork->removeAction( action );
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
TomahawkDesktopWindow::showOfflineSources()
|
||||
{
|
||||
m_sourcetree->showOfflineSources( ui->actionShowOfflineSources->isChecked() );
|
||||
TomahawkSettings::instance()->setShowOfflineSources( ui->actionShowOfflineSources->isChecked() );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkDesktopWindow::loadSpiff()
|
||||
{
|
||||
bool ok;
|
||||
QString urlstr = QInputDialog::getText( this, tr( "Load XSPF" ), tr( "Path:" ), QLineEdit::Normal, "http://ws.audioscrobbler.com/1.0/tag/metal/toptracks.xspf", &ok );
|
||||
if ( !ok || urlstr.isEmpty() )
|
||||
return;
|
||||
|
||||
XSPFLoader* loader = new XSPFLoader;
|
||||
loader->load( QUrl::fromUserInput( urlstr ) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkDesktopWindow::createAutomaticPlaylist( QString playlistName )
|
||||
{
|
||||
QString name = playlistName;
|
||||
|
||||
if ( name.isEmpty() )
|
||||
return;
|
||||
|
||||
source_ptr author = SourceList::instance()->getLocal();
|
||||
QString id = uuid();
|
||||
QString info = ""; // FIXME
|
||||
QString creator = "someone"; // FIXME
|
||||
dynplaylist_ptr playlist = DynamicPlaylist::create( author, id, name, info, creator, Static, false );
|
||||
playlist->setMode( Static );
|
||||
playlist->createNewRevision( uuid(), playlist->currentrevision(), playlist->type(), playlist->generator()->controls(), playlist->entries() );
|
||||
ViewManager::instance()->show( playlist );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkDesktopWindow::createStation()
|
||||
{
|
||||
bool ok;
|
||||
QString name = QInputDialog::getText( this, tr( "Create New Station" ), tr( "Name:" ), QLineEdit::Normal, tr( "New Station" ), &ok );
|
||||
if ( !ok || name.isEmpty() )
|
||||
return;
|
||||
|
||||
source_ptr author = SourceList::instance()->getLocal();
|
||||
QString id = uuid();
|
||||
QString info = ""; // FIXME
|
||||
QString creator = "someone"; // FIXME
|
||||
dynplaylist_ptr playlist = DynamicPlaylist::create( author, id, name, info, creator, OnDemand, false );
|
||||
playlist->setMode( OnDemand );
|
||||
playlist->createNewRevision( uuid(), playlist->currentrevision(), playlist->type(), playlist->generator()->controls() );
|
||||
ViewManager::instance()->show( playlist );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkDesktopWindow::createPlaylist()
|
||||
{
|
||||
PlaylistTypeSelectorDlg* playlistSelectorDlg = new PlaylistTypeSelectorDlg( TomahawkApp::instance()->mainWindow(), Qt::Sheet );
|
||||
#ifndef Q_OS_MAC
|
||||
playlistSelectorDlg->setModal( true );
|
||||
#endif
|
||||
connect( playlistSelectorDlg, SIGNAL( finished( int ) ), this, SLOT( playlistCreateDialogFinished( int ) ) );
|
||||
|
||||
playlistSelectorDlg->show();
|
||||
}
|
||||
|
||||
void TomahawkDesktopWindow::playlistCreateDialogFinished( int ret )
|
||||
{
|
||||
PlaylistTypeSelectorDlg* playlistSelectorDlg = qobject_cast< PlaylistTypeSelectorDlg* >( sender() );
|
||||
Q_ASSERT( playlistSelectorDlg );
|
||||
|
||||
QString playlistName = playlistSelectorDlg->playlistName();
|
||||
if ( playlistName.isEmpty() )
|
||||
playlistName = tr( "New Playlist" );
|
||||
|
||||
if ( !playlistSelectorDlg->playlistTypeIsAuto() && ret ) {
|
||||
|
||||
playlist_ptr playlist = Tomahawk::Playlist::create( SourceList::instance()->getLocal(), uuid(), playlistName, "", "", false, QList< query_ptr>() );
|
||||
ViewManager::instance()->show( playlist );
|
||||
} else if ( playlistSelectorDlg->playlistTypeIsAuto() && ret ) {
|
||||
// create Auto Playlist
|
||||
createAutomaticPlaylist( playlistName );
|
||||
}
|
||||
playlistSelectorDlg->deleteLater();
|
||||
}
|
||||
|
||||
void
|
||||
TomahawkDesktopWindow::audioStarted()
|
||||
{
|
||||
ui->actionPlay->setText( tr( "Pause" ) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkDesktopWindow::audioStopped()
|
||||
{
|
||||
|
||||
ui->actionPlay->setText( tr( "Play" ) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkDesktopWindow::onPlaybackLoading( const Tomahawk::result_ptr& result )
|
||||
{
|
||||
m_currentTrack = result;
|
||||
setWindowTitle( m_windowTitle );
|
||||
}
|
||||
|
||||
void
|
||||
TomahawkDesktopWindow::onSipConnected()
|
||||
{
|
||||
ui->actionToggleConnect->setText( tr( "Go &offline" ) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkDesktopWindow::onSipDisconnected()
|
||||
{
|
||||
ui->actionToggleConnect->setText( tr( "Go &online" ) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkDesktopWindow::onSipPluginAdded( SipPlugin* p )
|
||||
{
|
||||
connect( p, SIGNAL( addMenu( QMenu* ) ), this, SLOT( pluginMenuAdded( QMenu* ) ) );
|
||||
connect( p, SIGNAL( removeMenu( QMenu* ) ), this, SLOT( pluginMenuRemoved( QMenu* ) ) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkDesktopWindow::onSipPluginRemoved( SipPlugin* p )
|
||||
{
|
||||
Q_UNUSED( p );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkDesktopWindow::onSipError()
|
||||
{
|
||||
onSipDisconnected();
|
||||
|
||||
QMessageBox::warning( this,
|
||||
tr( "Authentication Error" ),
|
||||
QString( "Error connecting to SIP: Authentication failed!" ),
|
||||
QMessageBox::Ok );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkDesktopWindow::showAboutTomahawk()
|
||||
{
|
||||
QMessageBox::about( this, tr( "About Tomahawk" ),
|
||||
tr( "<h2><b>Tomahawk %1<br/>(%2)</h2>Copyright 2010, 2011<br/>Christian Muehlhaeuser <muesli@tomahawk-player.org><br/><br/>"
|
||||
"Thanks to: Leo Franchi, Jeff Mitchell, Dominik Schmidt, Jason Herskowitz, Alejandro Wainzinger, Michael Zanetti, Harald Sitter and Steve Robertson" )
|
||||
.arg( TomahawkUtils::appFriendlyVersion() )
|
||||
.arg( qApp->applicationVersion() ) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkDesktopWindow::checkForUpdates()
|
||||
{
|
||||
#ifdef Q_WS_MAC
|
||||
Tomahawk::checkForUpdates();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkDesktopWindow::onSearch( const QString& search )
|
||||
{
|
||||
if ( !search.trimmed().isEmpty() )
|
||||
ViewManager::instance()->show( new SearchWidget( search, this ) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkDesktopWindow::onFilterEdited()
|
||||
{
|
||||
onSearch( m_searchWidget->text() );
|
||||
m_searchWidget->clear();
|
||||
}
|
||||
|
||||
void
|
||||
TomahawkDesktopWindow::showQueue()
|
||||
{
|
||||
if ( QThread::currentThread() != thread() )
|
||||
{
|
||||
qDebug() << "Reinvoking in correct thread:" << Q_FUNC_INFO;
|
||||
QMetaObject::invokeMethod( this, "showQueue", Qt::QueuedConnection );
|
||||
return;
|
||||
}
|
||||
|
||||
m_queueView->show();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkDesktopWindow::hideQueue()
|
||||
{
|
||||
if ( QThread::currentThread() != thread() )
|
||||
{
|
||||
qDebug() << "Reinvoking in correct thread:" << Q_FUNC_INFO;
|
||||
QMetaObject::invokeMethod( this, "hideQueue", Qt::QueuedConnection );
|
||||
return;
|
||||
}
|
||||
|
||||
m_queueView->hide();
|
||||
}
|
125
src/tomahawkdesktopwindow.h
Normal file
125
src/tomahawkdesktopwindow.h
Normal file
@@ -0,0 +1,125 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Tomahawk is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef TOMAHAWKDESKTOPWINDOW_H
|
||||
#define TOMAHAWKDESKTOPWINDOW_H
|
||||
|
||||
#include "result.h"
|
||||
#include "tomahawkwindow.h"
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QVariantMap>
|
||||
#include <QPushButton>
|
||||
#include <QString>
|
||||
#include <QStackedWidget>
|
||||
|
||||
class QSearchField;
|
||||
class SipPlugin;
|
||||
class SourceTreeView;
|
||||
class QAction;
|
||||
|
||||
class MusicScanner;
|
||||
class AudioControls;
|
||||
class TomahawkTrayIcon;
|
||||
class PlaylistModel;
|
||||
class QueueView;
|
||||
class AnimatedSplitter;
|
||||
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class TomahawkDesktopWindow;
|
||||
class GlobalSearchWidget;
|
||||
}
|
||||
|
||||
class TomahawkDesktopWindow : public TomahawkWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TomahawkDesktopWindow( QWidget* parent = 0 );
|
||||
~TomahawkDesktopWindow();
|
||||
|
||||
AudioControls* audioControls() { return m_audioControls; }
|
||||
SourceTreeView* sourceTreeView() const { return m_sourcetree; }
|
||||
|
||||
protected:
|
||||
virtual void retranslateUi();
|
||||
|
||||
public slots:
|
||||
void createAutomaticPlaylist( QString );
|
||||
void createStation();
|
||||
void createPlaylist();
|
||||
void loadSpiff();
|
||||
void showSettingsDialog();
|
||||
void showDiagnosticsDialog();
|
||||
void updateCollectionManually();
|
||||
void rescanCollectionManually();
|
||||
void pluginMenuAdded(QMenu*);
|
||||
void pluginMenuRemoved(QMenu*);
|
||||
void showOfflineSources();
|
||||
|
||||
private slots:
|
||||
void onSipConnected();
|
||||
void onSipDisconnected();
|
||||
void onSipError();
|
||||
|
||||
void addPeerManually();
|
||||
|
||||
void onPlaybackLoading( const Tomahawk::result_ptr& result );
|
||||
|
||||
void audioStarted();
|
||||
void audioStopped();
|
||||
|
||||
void showAboutTomahawk();
|
||||
void checkForUpdates();
|
||||
|
||||
void onSipPluginAdded( SipPlugin* p );
|
||||
void onSipPluginRemoved( SipPlugin* p );
|
||||
|
||||
void onSearch( const QString& search );
|
||||
void onFilterEdited();
|
||||
|
||||
void showQueue();
|
||||
void hideQueue();
|
||||
|
||||
void playlistCreateDialogFinished( int ret );
|
||||
private:
|
||||
virtual void loadSettings();
|
||||
virtual void saveSettings();
|
||||
|
||||
void applyPlatformTweaks();
|
||||
void setupSignals();
|
||||
void setupSideBar();
|
||||
void setupUpdateCheck();
|
||||
|
||||
Ui::TomahawkDesktopWindow* ui;
|
||||
QSearchField* m_searchWidget;
|
||||
AudioControls* m_audioControls;
|
||||
SourceTreeView* m_sourcetree;
|
||||
QPushButton* m_statusButton;
|
||||
QPushButton* m_queueButton;
|
||||
PlaylistModel* m_queueModel;
|
||||
QueueView* m_queueView;
|
||||
AnimatedSplitter* m_sidebar;
|
||||
|
||||
Tomahawk::result_ptr m_currentTrack;
|
||||
QString m_windowTitle;
|
||||
};
|
||||
|
||||
#endif // TOMAHAWKDESKTOPWINDOW_H
|
267
src/tomahawkdesktopwindow.ui
Normal file
267
src/tomahawkdesktopwindow.ui
Normal file
@@ -0,0 +1,267 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>TomahawkDesktopWindow</class>
|
||||
<widget class="QMainWindow" name="TomahawkDesktopWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1000</width>
|
||||
<height>660</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Tomahawk</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralWidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QFrame" name="hline1">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>1</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::HLine</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSplitter" name="splitter">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="handleWidth">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="sidebarWidget" native="true"/>
|
||||
<widget class="QWidget" name="playlistWidget" native="true"/>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QFrame" name="hline2">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>1</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::HLine</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menuBar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1000</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuSettings">
|
||||
<property name="title">
|
||||
<string>&Settings</string>
|
||||
</property>
|
||||
<addaction name="actionPreferences"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuApp">
|
||||
<property name="title">
|
||||
<string>&Music Player</string>
|
||||
</property>
|
||||
<addaction name="actionPlay"/>
|
||||
<addaction name="actionPrevious"/>
|
||||
<addaction name="actionNext"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionUpdateCollection"/>
|
||||
<addaction name="actionRescanCollection"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionShowOfflineSources"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionExit"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuNetwork">
|
||||
<property name="title">
|
||||
<string>&Network</string>
|
||||
</property>
|
||||
<addaction name="actionToggleConnect"/>
|
||||
<addaction name="separator"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuWindow">
|
||||
<property name="title">
|
||||
<string>&Window</string>
|
||||
</property>
|
||||
<addaction name="actionMinimize"/>
|
||||
<addaction name="actionZoom"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menu_Help">
|
||||
<property name="title">
|
||||
<string>&Help</string>
|
||||
</property>
|
||||
<addaction name="actionDiagnostics"/>
|
||||
<addaction name="actionAboutTomahawk"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuPlaylist">
|
||||
<property name="title">
|
||||
<string>&Playlist</string>
|
||||
</property>
|
||||
<addaction name="actionCreatePlaylist"/>
|
||||
<addaction name="actionCreate_New_Station"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionLoadXSPF"/>
|
||||
</widget>
|
||||
<addaction name="menuApp"/>
|
||||
<addaction name="menuPlaylist"/>
|
||||
<addaction name="menuNetwork"/>
|
||||
<addaction name="menuSettings"/>
|
||||
<addaction name="menuWindow"/>
|
||||
<addaction name="menu_Help"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusBar"/>
|
||||
<action name="actionExit">
|
||||
<property name="text">
|
||||
<string>&Quit</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+Q</string>
|
||||
</property>
|
||||
<property name="menuRole">
|
||||
<enum>QAction::QuitRole</enum>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionToggleConnect">
|
||||
<property name="text">
|
||||
<string>Go &Online</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionAddFriendManually">
|
||||
<property name="text">
|
||||
<string>Add &Friend...</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionUpdateCollection">
|
||||
<property name="text">
|
||||
<string>U&pdate Collection</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Update Collection</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionPreferences">
|
||||
<property name="text">
|
||||
<string>&Configure Tomahawk...</string>
|
||||
</property>
|
||||
<property name="menuRole">
|
||||
<enum>QAction::PreferencesRole</enum>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionLoadXSPF">
|
||||
<property name="text">
|
||||
<string>Load &XSPF...</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionCreatePlaylist">
|
||||
<property name="text">
|
||||
<string>Create &New Playlist...</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionAboutTomahawk">
|
||||
<property name="text">
|
||||
<string>About &Tomahawk...</string>
|
||||
</property>
|
||||
<property name="menuRole">
|
||||
<enum>QAction::AboutRole</enum>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionCreateAutomaticPlaylist">
|
||||
<property name="text">
|
||||
<string>Create New &Automatic Playlist</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionCreate_New_Station">
|
||||
<property name="text">
|
||||
<string>Create New &Station</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionShowOfflineSources">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Show Offline Sources</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionHideOfflineSources">
|
||||
<property name="text">
|
||||
<string>Hide Offline Sources</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionMinimize">
|
||||
<property name="text">
|
||||
<string>Minimize</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+M</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionZoom">
|
||||
<property name="text">
|
||||
<string>Zoom</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Meta+Ctrl+Z</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionDiagnostics">
|
||||
<property name="text">
|
||||
<string>Diagnostics...</string>
|
||||
</property>
|
||||
<property name="menuRole">
|
||||
<enum>QAction::ApplicationSpecificRole</enum>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionRescanCollection">
|
||||
<property name="text">
|
||||
<string>Fully &Rescan Collection</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Fully Rescan Collection</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionPlay">
|
||||
<property name="text">
|
||||
<string>Play</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Space</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionPrevious">
|
||||
<property name="text">
|
||||
<string>Previous</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionNext">
|
||||
<property name="text">
|
||||
<string>Next</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources/>
|
||||
<connections/>
|
||||
<slots>
|
||||
<slot>on_btnResolve_clicked()</slot>
|
||||
</slots>
|
||||
</ui>
|
@@ -17,97 +17,29 @@
|
||||
*/
|
||||
|
||||
#include "tomahawkwindow.h"
|
||||
#include "ui_tomahawkwindow.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QCloseEvent>
|
||||
#include <QShowEvent>
|
||||
#include <QHideEvent>
|
||||
#include <QInputDialog>
|
||||
#include <QPixmap>
|
||||
#include <QPropertyAnimation>
|
||||
#include <QLineEdit>
|
||||
#include <QMessageBox>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkReply>
|
||||
#include <QTimer>
|
||||
#include <QToolBar>
|
||||
|
||||
#include "playlist.h"
|
||||
#include "query.h"
|
||||
#include "artist.h"
|
||||
|
||||
#include "audio/audioengine.h"
|
||||
#include "viewmanager.h"
|
||||
#include "sip/SipHandler.h"
|
||||
#include "sourcetree/sourcetreeview.h"
|
||||
#include "utils/proxystyle.h"
|
||||
#include "utils/xspfloader.h"
|
||||
#include "widgets/animatedsplitter.h"
|
||||
#include "widgets/newplaylistwidget.h"
|
||||
#include "widgets/searchwidget.h"
|
||||
#include "widgets/playlisttypeselectordlg.h"
|
||||
#include "thirdparty/Qocoa/qsearchfield.h"
|
||||
|
||||
#include "audiocontrols.h"
|
||||
#include "settingsdialog.h"
|
||||
#include "diagnosticsdialog.h"
|
||||
#include "tomahawksettings.h"
|
||||
#include "sourcelist.h"
|
||||
#include "PipelineStatusView.h"
|
||||
#include "transferview.h"
|
||||
#include "tomahawktrayicon.h"
|
||||
#include "playlist/dynamic/GeneratorInterface.h"
|
||||
#include "scanmanager.h"
|
||||
#include "playlist/queueview.h"
|
||||
#include "tomahawkapp.h"
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
#include <qtsparkle/Updater>
|
||||
#endif
|
||||
|
||||
#include "utils/logger.h"
|
||||
#include <QCloseEvent>
|
||||
|
||||
using namespace Tomahawk;
|
||||
|
||||
|
||||
TomahawkWindow::TomahawkWindow( QWidget* parent )
|
||||
: QMainWindow( parent )
|
||||
, ui( new Ui::TomahawkWindow )
|
||||
, m_searchWidget( 0 )
|
||||
, m_audioControls( new AudioControls( this ) )
|
||||
, m_trayIcon( new TomahawkTrayIcon( this ) )
|
||||
{
|
||||
setWindowIcon( QIcon( RESPATH "icons/tomahawk-icon-128x128.png" ) );
|
||||
|
||||
ViewManager* vm = new ViewManager( this );
|
||||
connect( vm, SIGNAL( showQueueRequested() ), SLOT( showQueue() ) );
|
||||
connect( vm, SIGNAL( hideQueueRequested() ), SLOT( hideQueue() ) );
|
||||
|
||||
ui->setupUi( this );
|
||||
applyPlatformTweaks();
|
||||
|
||||
ui->centralWidget->setContentsMargins( 0, 0, 0, 0 );
|
||||
TomahawkUtils::unmarginLayout( ui->centralWidget->layout() );
|
||||
|
||||
setupSideBar();
|
||||
statusBar()->addPermanentWidget( m_audioControls, 1 );
|
||||
|
||||
setupUpdateCheck();
|
||||
loadSettings();
|
||||
setupSignals();
|
||||
|
||||
// set initial state
|
||||
onSipDisconnected();
|
||||
vm->setQueue( m_queueView );
|
||||
vm->showWelcomePage();
|
||||
}
|
||||
|
||||
|
||||
TomahawkWindow::~TomahawkWindow()
|
||||
{
|
||||
saveSettings();
|
||||
delete ui;
|
||||
}
|
||||
|
||||
|
||||
@@ -135,8 +67,6 @@ TomahawkWindow::loadSettings()
|
||||
restoreGeometry( s->mainWindowGeometry() );
|
||||
if ( !s->mainWindowState().isEmpty() )
|
||||
restoreState( s->mainWindowState() );
|
||||
if ( !s->mainWindowSplitterState().isEmpty() )
|
||||
ui->splitter->restoreState( s->mainWindowSplitterState() );
|
||||
|
||||
#ifdef QT_MAC_USE_COCOA
|
||||
if ( workaround )
|
||||
@@ -154,179 +84,6 @@ TomahawkWindow::saveSettings()
|
||||
TomahawkSettings* s = TomahawkSettings::instance();
|
||||
s->setMainWindowGeometry( saveGeometry() );
|
||||
s->setMainWindowState( saveState() );
|
||||
s->setMainWindowSplitterState( ui->splitter->saveState() );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkWindow::applyPlatformTweaks()
|
||||
{
|
||||
// HACK QtCurve causes an infinite loop on startup. This is because setStyle calls setPalette, which calls ensureBaseStyle,
|
||||
// which loads QtCurve. QtCurve calls setPalette, which creates an infinite loop. The UI will look like CRAP with QtCurve, but
|
||||
// the user is asking for it explicitly... so he's gonna be stuck with an ugly UI.
|
||||
if ( !QString( qApp->style()->metaObject()->className() ).toLower().contains( "qtcurve" ) )
|
||||
qApp->setStyle( new ProxyStyle() );
|
||||
|
||||
#ifdef Q_OS_MAC
|
||||
setUnifiedTitleAndToolBarOnMac( true );
|
||||
delete ui->hline1;
|
||||
delete ui->hline2;
|
||||
#else
|
||||
ui->hline1->setStyleSheet( "border: 1px solid gray;" );
|
||||
ui->hline2->setStyleSheet( "border: 1px solid gray;" );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkWindow::setupSideBar()
|
||||
{
|
||||
// Delete fake designer widgets
|
||||
delete ui->sidebarWidget;
|
||||
delete ui->playlistWidget;
|
||||
|
||||
QWidget* sidebarWidget = new QWidget();
|
||||
sidebarWidget->setLayout( new QVBoxLayout() );
|
||||
|
||||
m_sidebar = new AnimatedSplitter();
|
||||
m_sidebar->setOrientation( Qt::Vertical );
|
||||
m_sidebar->setChildrenCollapsible( false );
|
||||
|
||||
m_searchWidget = new QSearchField( m_sidebar );
|
||||
m_searchWidget->setPlaceholderText( tr( "Global Search..." ) );
|
||||
connect( m_searchWidget, SIGNAL( returnPressed() ), this, SLOT( onFilterEdited() ) );
|
||||
|
||||
m_sourcetree = new SourceTreeView();
|
||||
TransferView* transferView = new TransferView( m_sidebar );
|
||||
PipelineStatusView* pipelineView = new PipelineStatusView( m_sidebar );
|
||||
|
||||
m_queueView = new QueueView( m_sidebar );
|
||||
m_queueModel = new PlaylistModel( m_queueView );
|
||||
m_queueModel->setStyle( PlaylistModel::Short );
|
||||
m_queueView->queue()->setPlaylistModel( m_queueModel );
|
||||
m_queueView->queue()->playlistModel()->setReadOnly( false );
|
||||
AudioEngine::instance()->setQueue( m_queueView->queue()->proxyModel() );
|
||||
|
||||
m_sidebar->addWidget( m_searchWidget );
|
||||
m_sidebar->addWidget( m_sourcetree );
|
||||
m_sidebar->addWidget( transferView );
|
||||
m_sidebar->addWidget( pipelineView );
|
||||
m_sidebar->addWidget( m_queueView );
|
||||
|
||||
m_sidebar->setGreedyWidget( 1 );
|
||||
m_sidebar->hide( 1, false );
|
||||
m_sidebar->hide( 2, false );
|
||||
m_sidebar->hide( 3, false );
|
||||
m_sidebar->hide( 4, false );
|
||||
|
||||
sidebarWidget->layout()->addWidget( m_sidebar );
|
||||
sidebarWidget->setContentsMargins( 0, 0, 0, 0 );
|
||||
sidebarWidget->layout()->setContentsMargins( 0, 0, 0, 0 );
|
||||
sidebarWidget->layout()->setMargin( 0 );
|
||||
|
||||
#ifndef Q_OS_MAC
|
||||
sidebarWidget->layout()->setSpacing( 0 );
|
||||
#endif
|
||||
|
||||
ui->splitter->addWidget( sidebarWidget );
|
||||
ui->splitter->addWidget( ViewManager::instance()->widget() );
|
||||
|
||||
ui->splitter->setStretchFactor( 0, 1 );
|
||||
ui->splitter->setStretchFactor( 1, 3 );
|
||||
ui->splitter->setCollapsible( 1, false );
|
||||
ui->splitter->setHandleWidth( 1 );
|
||||
|
||||
ui->actionShowOfflineSources->setChecked( TomahawkSettings::instance()->showOfflineSources() );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkWindow::setupUpdateCheck()
|
||||
{
|
||||
#ifndef Q_WS_MAC
|
||||
ui->menu_Help->insertSeparator( ui->actionAboutTomahawk );
|
||||
#endif
|
||||
|
||||
#if defined( Q_OS_DARWIN ) && defined( HAVE_SPARKLE )
|
||||
QAction* checkForUpdates = ui->menu_Help->addAction( tr( "Check For Updates..." ) );
|
||||
checkForUpdates->setMenuRole( QAction::ApplicationSpecificRole );
|
||||
connect( checkForUpdates, SIGNAL( triggered( bool ) ), SLOT( checkForUpdates() ) );
|
||||
#elif defined( WIN32 )
|
||||
QUrl updaterUrl;
|
||||
|
||||
if ( qApp->arguments().contains( "--debug" ) )
|
||||
updaterUrl.setUrl( "http://download.tomahawk-player.org/sparklewin-debug" );
|
||||
else
|
||||
updaterUrl.setUrl( "http://download.tomahawk-player.org/sparklewin" );
|
||||
|
||||
qtsparkle::Updater* updater = new qtsparkle::Updater( updaterUrl, this );
|
||||
Q_ASSERT( TomahawkUtils::nam() != 0 );
|
||||
updater->SetNetworkAccessManager( TomahawkUtils::nam() );
|
||||
updater->SetVersion( TomahawkUtils::appFriendlyVersion() );
|
||||
|
||||
ui->menu_Help->addSeparator();
|
||||
QAction* checkForUpdates = ui->menu_Help->addAction( tr( "Check For Updates..." ) );
|
||||
connect( checkForUpdates, SIGNAL( triggered() ), updater, SLOT( CheckNow() ) );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkWindow::setupSignals()
|
||||
{
|
||||
// <From PlaylistManager>
|
||||
connect( ViewManager::instance(), SIGNAL( repeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode ) ),
|
||||
m_audioControls, SLOT( onRepeatModeChanged( Tomahawk::PlaylistInterface::RepeatMode ) ) );
|
||||
connect( ViewManager::instance(), SIGNAL( shuffleModeChanged( bool ) ),
|
||||
m_audioControls, SLOT( onShuffleModeChanged( bool ) ) );
|
||||
|
||||
// <From AudioEngine>
|
||||
connect( AudioEngine::instance(), SIGNAL( loading( const Tomahawk::result_ptr& ) ),
|
||||
SLOT( onPlaybackLoading( const Tomahawk::result_ptr& ) ) );
|
||||
connect( AudioEngine::instance(), SIGNAL( started( Tomahawk::result_ptr ) ), SLOT( audioStarted() ) );
|
||||
connect( AudioEngine::instance(), SIGNAL( resumed()), SLOT( audioStarted() ) );
|
||||
connect( AudioEngine::instance(), SIGNAL( paused() ), SLOT( audioStopped() ) );
|
||||
connect( AudioEngine::instance(), SIGNAL( stopped() ), SLOT( audioStopped() ) );
|
||||
|
||||
// <Menu Items>
|
||||
// connect( ui->actionAddPeerManually, SIGNAL( triggered() ), SLOT( addPeerManually() ) );
|
||||
connect( ui->actionPreferences, SIGNAL( triggered() ), SLOT( showSettingsDialog() ) );
|
||||
connect( ui->actionDiagnostics, SIGNAL( triggered() ), SLOT( showDiagnosticsDialog() ) );
|
||||
connect( ui->actionToggleConnect, SIGNAL( triggered() ), SipHandler::instance(), SLOT( toggleConnect() ) );
|
||||
connect( ui->actionUpdateCollection, SIGNAL( triggered() ), SLOT( updateCollectionManually() ) );
|
||||
connect( ui->actionRescanCollection, SIGNAL( triggered() ), SLOT( rescanCollectionManually() ) );
|
||||
connect( ui->actionLoadXSPF, SIGNAL( triggered() ), SLOT( loadSpiff() ));
|
||||
connect( ui->actionCreatePlaylist, SIGNAL( triggered() ), SLOT( createPlaylist() ));
|
||||
connect( ui->actionCreate_New_Station, SIGNAL( triggered() ), SLOT( createStation() ));
|
||||
connect( ui->actionAboutTomahawk, SIGNAL( triggered() ), SLOT( showAboutTomahawk() ) );
|
||||
connect( ui->actionExit, SIGNAL( triggered() ), qApp, SLOT( quit() ) );
|
||||
connect( ui->actionShowOfflineSources, SIGNAL( triggered() ), SLOT( showOfflineSources() ) );
|
||||
|
||||
connect( ui->actionPlay, SIGNAL( triggered() ), AudioEngine::instance(), SLOT( playPause() ) );
|
||||
connect( ui->actionNext, SIGNAL( triggered() ), AudioEngine::instance(), SLOT( next() ) );
|
||||
connect( ui->actionPrevious, SIGNAL( triggered() ), AudioEngine::instance(), SLOT( previous() ) );
|
||||
|
||||
#if defined( Q_OS_DARWIN )
|
||||
connect( ui->actionMinimize, SIGNAL( triggered() ), SLOT( minimize() ) );
|
||||
connect( ui->actionZoom, SIGNAL( triggered() ), SLOT( maximize() ) );
|
||||
#else
|
||||
ui->menuWindow->clear();
|
||||
ui->menuWindow->menuAction()->setVisible( false );
|
||||
#endif
|
||||
|
||||
// <SipHandler>
|
||||
connect( SipHandler::instance(), SIGNAL( connected( SipPlugin* ) ), SLOT( onSipConnected() ) );
|
||||
connect( SipHandler::instance(), SIGNAL( disconnected( SipPlugin* ) ), SLOT( onSipDisconnected() ) );
|
||||
connect( SipHandler::instance(), SIGNAL( authError( SipPlugin* ) ), SLOT( onSipError() ) );
|
||||
|
||||
// <SipMenu>
|
||||
connect( SipHandler::instance(), SIGNAL( pluginAdded( SipPlugin* ) ), this, SLOT( onSipPluginAdded( SipPlugin* ) ) );
|
||||
connect( SipHandler::instance(), SIGNAL( pluginRemoved( SipPlugin* ) ), this, SLOT( onSipPluginRemoved( SipPlugin* ) ) );
|
||||
foreach( SipPlugin *plugin, SipHandler::instance()->allPlugins() )
|
||||
{
|
||||
connect( plugin, SIGNAL( addMenu( QMenu* ) ), this, SLOT( pluginMenuAdded( QMenu* ) ) );
|
||||
connect( plugin, SIGNAL( removeMenu( QMenu* ) ), this, SLOT( pluginMenuRemoved( QMenu* ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -338,7 +95,7 @@ TomahawkWindow::changeEvent( QEvent* e )
|
||||
switch ( e->type() )
|
||||
{
|
||||
case QEvent::LanguageChange:
|
||||
ui->retranslateUi( this );
|
||||
retranslateUi();
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -388,245 +145,6 @@ TomahawkWindow::hideEvent( QHideEvent* e )
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkWindow::showSettingsDialog()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
SettingsDialog win;
|
||||
win.exec();
|
||||
}
|
||||
|
||||
|
||||
void TomahawkWindow::showDiagnosticsDialog()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
DiagnosticsDialog win;
|
||||
win.exec();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkWindow::updateCollectionManually()
|
||||
{
|
||||
if ( TomahawkSettings::instance()->hasScannerPaths() )
|
||||
ScanManager::instance()->runScan();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkWindow::rescanCollectionManually()
|
||||
{
|
||||
if ( TomahawkSettings::instance()->hasScannerPaths() )
|
||||
ScanManager::instance()->runScan( true );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkWindow::addPeerManually()
|
||||
{
|
||||
TomahawkSettings* s = TomahawkSettings::instance();
|
||||
bool ok;
|
||||
QString addr = QInputDialog::getText( this, tr( "Connect To Peer" ),
|
||||
tr( "Enter peer address:" ), QLineEdit::Normal,
|
||||
s->value( "connip" ).toString(), &ok ); // FIXME
|
||||
if ( !ok )
|
||||
return;
|
||||
|
||||
s->setValue( "connip", addr );
|
||||
QString ports = QInputDialog::getText( this, tr( "Connect To Peer" ),
|
||||
tr( "Enter peer port:" ), QLineEdit::Normal,
|
||||
s->value( "connport", "50210" ).toString(), &ok );
|
||||
if ( !ok )
|
||||
return;
|
||||
|
||||
s->setValue( "connport", ports );
|
||||
int port = ports.toInt();
|
||||
QString key = QInputDialog::getText( this, tr( "Connect To Peer" ),
|
||||
tr( "Enter peer key:" ), QLineEdit::Normal,
|
||||
"whitelist", &ok );
|
||||
if ( !ok )
|
||||
return;
|
||||
|
||||
qDebug() << "Attempting to connect to" << addr;
|
||||
Servent::instance()->connectToPeer( addr, port, key );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkWindow::pluginMenuAdded( QMenu* menu )
|
||||
{
|
||||
ui->menuNetwork->addMenu( menu );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkWindow::pluginMenuRemoved( QMenu* menu )
|
||||
{
|
||||
foreach( QAction* action, ui->menuNetwork->actions() )
|
||||
{
|
||||
if( action->menu() == menu )
|
||||
{
|
||||
ui->menuNetwork->removeAction( action );
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
TomahawkWindow::showOfflineSources()
|
||||
{
|
||||
m_sourcetree->showOfflineSources( ui->actionShowOfflineSources->isChecked() );
|
||||
TomahawkSettings::instance()->setShowOfflineSources( ui->actionShowOfflineSources->isChecked() );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkWindow::loadSpiff()
|
||||
{
|
||||
bool ok;
|
||||
QString urlstr = QInputDialog::getText( this, tr( "Load XSPF" ), tr( "Path:" ), QLineEdit::Normal, "http://ws.audioscrobbler.com/1.0/tag/metal/toptracks.xspf", &ok );
|
||||
if ( !ok || urlstr.isEmpty() )
|
||||
return;
|
||||
|
||||
XSPFLoader* loader = new XSPFLoader;
|
||||
loader->load( QUrl::fromUserInput( urlstr ) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkWindow::createAutomaticPlaylist( QString playlistName )
|
||||
{
|
||||
QString name = playlistName;
|
||||
|
||||
if ( name.isEmpty() )
|
||||
return;
|
||||
|
||||
source_ptr author = SourceList::instance()->getLocal();
|
||||
QString id = uuid();
|
||||
QString info = ""; // FIXME
|
||||
QString creator = "someone"; // FIXME
|
||||
dynplaylist_ptr playlist = DynamicPlaylist::create( author, id, name, info, creator, Static, false );
|
||||
playlist->setMode( Static );
|
||||
playlist->createNewRevision( uuid(), playlist->currentrevision(), playlist->type(), playlist->generator()->controls(), playlist->entries() );
|
||||
ViewManager::instance()->show( playlist );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkWindow::createStation()
|
||||
{
|
||||
bool ok;
|
||||
QString name = QInputDialog::getText( this, tr( "Create New Station" ), tr( "Name:" ), QLineEdit::Normal, tr( "New Station" ), &ok );
|
||||
if ( !ok || name.isEmpty() )
|
||||
return;
|
||||
|
||||
source_ptr author = SourceList::instance()->getLocal();
|
||||
QString id = uuid();
|
||||
QString info = ""; // FIXME
|
||||
QString creator = "someone"; // FIXME
|
||||
dynplaylist_ptr playlist = DynamicPlaylist::create( author, id, name, info, creator, OnDemand, false );
|
||||
playlist->setMode( OnDemand );
|
||||
playlist->createNewRevision( uuid(), playlist->currentrevision(), playlist->type(), playlist->generator()->controls() );
|
||||
ViewManager::instance()->show( playlist );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkWindow::createPlaylist()
|
||||
{
|
||||
PlaylistTypeSelectorDlg* playlistSelectorDlg = new PlaylistTypeSelectorDlg( TomahawkApp::instance()->mainWindow(), Qt::Sheet );
|
||||
#ifndef Q_OS_MAC
|
||||
playlistSelectorDlg->setModal( true );
|
||||
#endif
|
||||
connect( playlistSelectorDlg, SIGNAL( finished( int ) ), this, SLOT( playlistCreateDialogFinished( int ) ) );
|
||||
|
||||
playlistSelectorDlg->show();
|
||||
}
|
||||
|
||||
void TomahawkWindow::playlistCreateDialogFinished( int ret )
|
||||
{
|
||||
PlaylistTypeSelectorDlg* playlistSelectorDlg = qobject_cast< PlaylistTypeSelectorDlg* >( sender() );
|
||||
Q_ASSERT( playlistSelectorDlg );
|
||||
|
||||
QString playlistName = playlistSelectorDlg->playlistName();
|
||||
if ( playlistName.isEmpty() )
|
||||
playlistName = tr( "New Playlist" );
|
||||
|
||||
if ( !playlistSelectorDlg->playlistTypeIsAuto() && ret ) {
|
||||
|
||||
playlist_ptr playlist = Tomahawk::Playlist::create( SourceList::instance()->getLocal(), uuid(), playlistName, "", "", false, QList< query_ptr>() );
|
||||
ViewManager::instance()->show( playlist );
|
||||
} else if ( playlistSelectorDlg->playlistTypeIsAuto() && ret ) {
|
||||
// create Auto Playlist
|
||||
createAutomaticPlaylist( playlistName );
|
||||
}
|
||||
playlistSelectorDlg->deleteLater();
|
||||
}
|
||||
|
||||
void
|
||||
TomahawkWindow::audioStarted()
|
||||
{
|
||||
ui->actionPlay->setText( tr( "Pause" ) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkWindow::audioStopped()
|
||||
{
|
||||
|
||||
ui->actionPlay->setText( tr( "Play" ) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkWindow::onPlaybackLoading( const Tomahawk::result_ptr& result )
|
||||
{
|
||||
m_currentTrack = result;
|
||||
setWindowTitle( m_windowTitle );
|
||||
}
|
||||
|
||||
void
|
||||
TomahawkWindow::onSipConnected()
|
||||
{
|
||||
ui->actionToggleConnect->setText( tr( "Go &offline" ) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkWindow::onSipDisconnected()
|
||||
{
|
||||
ui->actionToggleConnect->setText( tr( "Go &online" ) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkWindow::onSipPluginAdded( SipPlugin* p )
|
||||
{
|
||||
connect( p, SIGNAL( addMenu( QMenu* ) ), this, SLOT( pluginMenuAdded( QMenu* ) ) );
|
||||
connect( p, SIGNAL( removeMenu( QMenu* ) ), this, SLOT( pluginMenuRemoved( QMenu* ) ) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkWindow::onSipPluginRemoved( SipPlugin* p )
|
||||
{
|
||||
Q_UNUSED( p );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkWindow::onSipError()
|
||||
{
|
||||
onSipDisconnected();
|
||||
|
||||
QMessageBox::warning( this,
|
||||
tr( "Authentication Error" ),
|
||||
QString( "Error connecting to SIP: Authentication failed!" ),
|
||||
QMessageBox::Ok );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkWindow::setWindowTitle( const QString& title )
|
||||
{
|
||||
@@ -642,70 +160,6 @@ TomahawkWindow::setWindowTitle( const QString& title )
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkWindow::showAboutTomahawk()
|
||||
{
|
||||
QMessageBox::about( this, tr( "About Tomahawk" ),
|
||||
tr( "<h2><b>Tomahawk %1<br/>(%2)</h2>Copyright 2010, 2011<br/>Christian Muehlhaeuser <muesli@tomahawk-player.org><br/><br/>"
|
||||
"Thanks to: Leo Franchi, Jeff Mitchell, Dominik Schmidt, Jason Herskowitz, Alejandro Wainzinger, Michael Zanetti, Harald Sitter and Steve Robertson" )
|
||||
.arg( TomahawkUtils::appFriendlyVersion() )
|
||||
.arg( qApp->applicationVersion() ) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkWindow::checkForUpdates()
|
||||
{
|
||||
#ifdef Q_WS_MAC
|
||||
Tomahawk::checkForUpdates();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkWindow::onSearch( const QString& search )
|
||||
{
|
||||
if ( !search.trimmed().isEmpty() )
|
||||
ViewManager::instance()->show( new SearchWidget( search, this ) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkWindow::onFilterEdited()
|
||||
{
|
||||
onSearch( m_searchWidget->text() );
|
||||
m_searchWidget->clear();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkWindow::showQueue()
|
||||
{
|
||||
if ( QThread::currentThread() != thread() )
|
||||
{
|
||||
qDebug() << "Reinvoking in correct thread:" << Q_FUNC_INFO;
|
||||
QMetaObject::invokeMethod( this, "showQueue", Qt::QueuedConnection );
|
||||
return;
|
||||
}
|
||||
|
||||
m_queueView->show();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkWindow::hideQueue()
|
||||
{
|
||||
if ( QThread::currentThread() != thread() )
|
||||
{
|
||||
qDebug() << "Reinvoking in correct thread:" << Q_FUNC_INFO;
|
||||
QMetaObject::invokeMethod( this, "hideQueue", Qt::QueuedConnection );
|
||||
return;
|
||||
}
|
||||
|
||||
m_queueView->hide();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkWindow::minimize()
|
||||
{
|
||||
@@ -732,3 +186,10 @@ TomahawkWindow::maximize()
|
||||
showMaximized();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkWindow::retranslateUi()
|
||||
{
|
||||
|
||||
}
|
||||
|
@@ -20,112 +20,38 @@
|
||||
#define TOMAHAWKWINDOW_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QVariantMap>
|
||||
#include <QPushButton>
|
||||
#include <QString>
|
||||
#include <QStackedWidget>
|
||||
|
||||
#include "result.h"
|
||||
|
||||
class QSearchField;
|
||||
class SipPlugin;
|
||||
class SourceTreeView;
|
||||
class QAction;
|
||||
|
||||
class MusicScanner;
|
||||
class AudioControls;
|
||||
class TomahawkTrayIcon;
|
||||
class PlaylistModel;
|
||||
class QueueView;
|
||||
class AnimatedSplitter;
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
class TomahawkWindow;
|
||||
class GlobalSearchWidget;
|
||||
}
|
||||
|
||||
class TomahawkWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TomahawkWindow( QWidget* parent = 0 );
|
||||
~TomahawkWindow();
|
||||
|
||||
AudioControls* audioControls() { return m_audioControls; }
|
||||
SourceTreeView* sourceTreeView() const { return m_sourcetree; }
|
||||
|
||||
void setWindowTitle( const QString& title );
|
||||
virtual void setWindowTitle( const QString& title );
|
||||
|
||||
protected:
|
||||
void changeEvent( QEvent* e );
|
||||
void closeEvent( QCloseEvent* e );
|
||||
void showEvent( QShowEvent* e );
|
||||
void hideEvent( QHideEvent* e );
|
||||
virtual void changeEvent( QEvent* e );
|
||||
virtual void closeEvent( QCloseEvent* e );
|
||||
virtual void showEvent( QShowEvent* e );
|
||||
virtual void hideEvent( QHideEvent* e );
|
||||
|
||||
public slots:
|
||||
void createAutomaticPlaylist( QString );
|
||||
void createStation();
|
||||
void createPlaylist();
|
||||
void loadSpiff();
|
||||
void showSettingsDialog();
|
||||
void showDiagnosticsDialog();
|
||||
void updateCollectionManually();
|
||||
void rescanCollectionManually();
|
||||
void pluginMenuAdded(QMenu*);
|
||||
void pluginMenuRemoved(QMenu*);
|
||||
void showOfflineSources();
|
||||
virtual void retranslateUi();
|
||||
virtual void loadSettings();
|
||||
virtual void saveSettings();
|
||||
|
||||
private slots:
|
||||
void onSipConnected();
|
||||
void onSipDisconnected();
|
||||
void onSipError();
|
||||
|
||||
void addPeerManually();
|
||||
|
||||
void onPlaybackLoading( const Tomahawk::result_ptr& result );
|
||||
|
||||
void audioStarted();
|
||||
void audioStopped();
|
||||
|
||||
void showAboutTomahawk();
|
||||
void checkForUpdates();
|
||||
|
||||
void onSipPluginAdded( SipPlugin* p );
|
||||
void onSipPluginRemoved( SipPlugin* p );
|
||||
|
||||
void onSearch( const QString& search );
|
||||
void onFilterEdited();
|
||||
|
||||
void showQueue();
|
||||
void hideQueue();
|
||||
|
||||
void minimize();
|
||||
void maximize();
|
||||
|
||||
void playlistCreateDialogFinished( int ret );
|
||||
virtual void minimize();
|
||||
virtual void maximize();
|
||||
|
||||
private:
|
||||
void loadSettings();
|
||||
void saveSettings();
|
||||
|
||||
void applyPlatformTweaks();
|
||||
void setupSignals();
|
||||
void setupSideBar();
|
||||
void setupUpdateCheck();
|
||||
|
||||
Ui::TomahawkWindow* ui;
|
||||
QSearchField* m_searchWidget;
|
||||
AudioControls* m_audioControls;
|
||||
TomahawkTrayIcon* m_trayIcon;
|
||||
SourceTreeView* m_sourcetree;
|
||||
QPushButton* m_statusButton;
|
||||
QPushButton* m_queueButton;
|
||||
PlaylistModel* m_queueModel;
|
||||
QueueView* m_queueView;
|
||||
AnimatedSplitter* m_sidebar;
|
||||
|
||||
Tomahawk::result_ptr m_currentTrack;
|
||||
QString m_windowTitle;
|
||||
};
|
||||
|
Reference in New Issue
Block a user