Changeset View
Changeset View
Standalone View
Standalone View
src/MainWindow.cpp
Show All 34 Lines | |||||
35 | #include "amarokurls/AmarokUrlHandler.h" | 35 | #include "amarokurls/AmarokUrlHandler.h" | ||
36 | #include "amarokurls/BookmarkManager.h" | 36 | #include "amarokurls/BookmarkManager.h" | ||
37 | #include "browsers/BrowserDock.h" | 37 | #include "browsers/BrowserDock.h" | ||
38 | #include "browsers/collectionbrowser/CollectionWidget.h" | 38 | #include "browsers/collectionbrowser/CollectionWidget.h" | ||
39 | #include "browsers/filebrowser/FileBrowser.h" | 39 | #include "browsers/filebrowser/FileBrowser.h" | ||
40 | #include "browsers/playlistbrowser/PlaylistBrowser.h" | 40 | #include "browsers/playlistbrowser/PlaylistBrowser.h" | ||
41 | #include "browsers/playlistbrowser/PodcastCategory.h" | 41 | #include "browsers/playlistbrowser/PodcastCategory.h" | ||
42 | #include "browsers/servicebrowser/ServiceBrowser.h" | 42 | #include "browsers/servicebrowser/ServiceBrowser.h" | ||
43 | // #include "context/ContextDock.h" | 43 | #include "context/ContextDock.h" | ||
44 | #include "core/meta/Statistics.h" | 44 | #include "core/meta/Statistics.h" | ||
45 | #include "core/support/Amarok.h" | 45 | #include "core/support/Amarok.h" | ||
46 | #include "core/support/Components.h" | 46 | #include "core/support/Components.h" | ||
47 | #include "core/support/Debug.h" | 47 | #include "core/support/Debug.h" | ||
48 | #include "core-impl/collections/support/CollectionManager.h" | 48 | #include "core-impl/collections/support/CollectionManager.h" | ||
49 | #include "covermanager/CoverManager.h" // for actions | 49 | #include "covermanager/CoverManager.h" // for actions | ||
50 | #include "dialogs/DiagnosticDialog.h" | 50 | #include "dialogs/DiagnosticDialog.h" | ||
51 | #include "dialogs/EqualizerDialog.h" | 51 | #include "dialogs/EqualizerDialog.h" | ||
▲ Show 20 Lines • Show All 172 Lines • ▼ Show 20 Line(s) | 199 | { | |||
224 | PERF_LOG( "Create Playlist" ) | 224 | PERF_LOG( "Create Playlist" ) | ||
225 | m_playlistDock = new Playlist::Dock( this ); | 225 | m_playlistDock = new Playlist::Dock( this ); | ||
226 | m_playlistDock->installEventFilter( this ); | 226 | m_playlistDock->installEventFilter( this ); | ||
227 | //HACK, need to connect after because of order in MainWindow() | 227 | //HACK, need to connect after because of order in MainWindow() | ||
228 | connect( Amarok::actionCollection()->action( "playlist_edit_queue" ), | 228 | connect( Amarok::actionCollection()->action( "playlist_edit_queue" ), | ||
229 | &QAction::triggered, m_playlistDock.data(), &Playlist::Dock::slotEditQueue ); | 229 | &QAction::triggered, m_playlistDock.data(), &Playlist::Dock::slotEditQueue ); | ||
230 | PERF_LOG( "Playlist created" ) | 230 | PERF_LOG( "Playlist created" ) | ||
231 | 231 | | |||
232 | // PERF_LOG( "Creating ContextWidget" ) | 232 | PERF_LOG( "Creating ContextWidget" ) | ||
233 | // m_contextDock = new ContextDock( this ); | 233 | m_contextDock = new ContextDock( this ); | ||
234 | // m_contextDock->installEventFilter( this ); | 234 | m_contextDock->installEventFilter( this ); | ||
235 | // PERF_LOG( "ContextScene created" ) | 235 | PERF_LOG( "ContextScene created" ) | ||
236 | //END Creating Widgets | 236 | //END Creating Widgets | ||
237 | 237 | | |||
238 | createMenus(); | 238 | createMenus(); | ||
239 | 239 | | |||
240 | setDockOptions( QMainWindow::AllowNestedDocks | QMainWindow::AllowTabbedDocks | 240 | setDockOptions( QMainWindow::AllowNestedDocks | QMainWindow::AllowTabbedDocks | ||
241 | | QMainWindow::AnimatedDocks | QMainWindow::VerticalTabs ); | 241 | | QMainWindow::AnimatedDocks | QMainWindow::VerticalTabs ); | ||
242 | 242 | | |||
243 | addDockWidget( Qt::LeftDockWidgetArea, m_browserDock.data() ); | 243 | addDockWidget( Qt::LeftDockWidgetArea, m_browserDock.data() ); | ||
244 | // addDockWidget( Qt::LeftDockWidgetArea, m_contextDock.data(), Qt::Horizontal ); | 244 | addDockWidget( Qt::LeftDockWidgetArea, m_contextDock.data(), Qt::Horizontal ); | ||
245 | addDockWidget( Qt::LeftDockWidgetArea, m_playlistDock.data(), Qt::Horizontal ); | 245 | addDockWidget( Qt::LeftDockWidgetArea, m_playlistDock.data(), Qt::Horizontal ); | ||
246 | 246 | | |||
247 | setLayoutLocked( AmarokConfig::lockLayout() ); | 247 | setLayoutLocked( AmarokConfig::lockLayout() ); | ||
248 | 248 | | |||
249 | //<Browsers> | 249 | //<Browsers> | ||
250 | { | 250 | { | ||
251 | Debug::Block block( "Creating browsers. Please report long start times!" ); | 251 | Debug::Block block( "Creating browsers. Please report long start times!" ); | ||
252 | 252 | | |||
▲ Show 20 Lines • Show All 129 Lines • ▼ Show 20 Line(s) | |||||
382 | { | 382 | { | ||
383 | QString name; | 383 | QString name; | ||
384 | switch( dockId ) | 384 | switch( dockId ) | ||
385 | { | 385 | { | ||
386 | case AmarokDockNavigation: | 386 | case AmarokDockNavigation: | ||
387 | name = m_browserDock->windowTitle(); | 387 | name = m_browserDock->windowTitle(); | ||
388 | break; | 388 | break; | ||
389 | case AmarokDockContext: | 389 | case AmarokDockContext: | ||
390 | // name = m_contextDock->windowTitle(); | 390 | name = m_contextDock->windowTitle(); | ||
391 | break; | 391 | break; | ||
392 | case AmarokDockPlaylist: | 392 | case AmarokDockPlaylist: | ||
393 | name = m_playlistDock->windowTitle(); | 393 | name = m_playlistDock->windowTitle(); | ||
394 | break; | 394 | break; | ||
395 | } | 395 | } | ||
396 | 396 | | |||
397 | QList < QTabBar * > tabList = findChildren < QTabBar * > (); | 397 | QList < QTabBar * > tabList = findChildren < QTabBar * > (); | ||
398 | 398 | | |||
▲ Show 20 Lines • Show All 846 Lines • ▼ Show 20 Line(s) | |||||
1245 | void | 1245 | void | ||
1246 | MainWindow::setLayoutLocked( bool locked ) | 1246 | MainWindow::setLayoutLocked( bool locked ) | ||
1247 | { | 1247 | { | ||
1248 | DEBUG_BLOCK | 1248 | DEBUG_BLOCK | ||
1249 | 1249 | | |||
1250 | if( m_browserDock ) | 1250 | if( m_browserDock ) | ||
1251 | m_browserDock.data()->setMovable( !locked ); | 1251 | m_browserDock.data()->setMovable( !locked ); | ||
1252 | 1252 | | |||
1253 | // if( m_contextDock ) | 1253 | if( m_contextDock ) | ||
1254 | // m_contextDock.data()->setMovable( !locked ); | 1254 | m_contextDock.data()->setMovable( !locked ); | ||
1255 | 1255 | | |||
1256 | if( m_playlistDock ) | 1256 | if( m_playlistDock ) | ||
1257 | m_playlistDock.data()->setMovable( !locked ); | 1257 | m_playlistDock.data()->setMovable( !locked ); | ||
1258 | 1258 | | |||
1259 | if( m_slimToolbar ) | 1259 | if( m_slimToolbar ) | ||
1260 | { | 1260 | { | ||
1261 | m_slimToolbar.data()->setFloatable( !locked ); | 1261 | m_slimToolbar.data()->setFloatable( !locked ); | ||
1262 | m_slimToolbar.data()->setMovable( !locked ); | 1262 | m_slimToolbar.data()->setMovable( !locked ); | ||
Show All 12 Lines | |||||
1275 | void | 1275 | void | ||
1276 | MainWindow::resetLayout() | 1276 | MainWindow::resetLayout() | ||
1277 | { | 1277 | { | ||
1278 | // Store current state, so that we can undo the operation | 1278 | // Store current state, so that we can undo the operation | ||
1279 | const QByteArray state = saveState(); | 1279 | const QByteArray state = saveState(); | ||
1280 | 1280 | | |||
1281 | // Remove all dock widgets, then add them again. This resets their state completely. | 1281 | // Remove all dock widgets, then add them again. This resets their state completely. | ||
1282 | removeDockWidget( m_browserDock.data() ); | 1282 | removeDockWidget( m_browserDock.data() ); | ||
1283 | // removeDockWidget( m_contextDock.data() ); | 1283 | removeDockWidget( m_contextDock.data() ); | ||
1284 | removeDockWidget( m_playlistDock.data() ); | 1284 | removeDockWidget( m_playlistDock.data() ); | ||
1285 | 1285 | | |||
1286 | addDockWidget( Qt::LeftDockWidgetArea, m_browserDock.data() ); | 1286 | addDockWidget( Qt::LeftDockWidgetArea, m_browserDock.data() ); | ||
1287 | // addDockWidget( Qt::LeftDockWidgetArea, m_contextDock.data(), Qt::Horizontal ); | 1287 | addDockWidget( Qt::LeftDockWidgetArea, m_contextDock.data(), Qt::Horizontal ); | ||
1288 | addDockWidget( Qt::LeftDockWidgetArea, m_playlistDock.data(), Qt::Horizontal ); | 1288 | addDockWidget( Qt::LeftDockWidgetArea, m_playlistDock.data(), Qt::Horizontal ); | ||
1289 | 1289 | | |||
1290 | m_browserDock->setFloating( false ); | 1290 | m_browserDock->setFloating( false ); | ||
1291 | // m_contextDock->setFloating( false ); | 1291 | m_contextDock->setFloating( false ); | ||
1292 | m_playlistDock->setFloating( false ); | 1292 | m_playlistDock->setFloating( false ); | ||
1293 | 1293 | | |||
1294 | m_browserDock->show(); | 1294 | m_browserDock->show(); | ||
1295 | // m_contextDock->show(); | 1295 | m_contextDock->show(); | ||
1296 | m_playlistDock->show(); | 1296 | m_playlistDock->show(); | ||
1297 | 1297 | | |||
1298 | // Now set Amarok's default dockwidget sizes | 1298 | // Now set Amarok's default dockwidget sizes | ||
1299 | setDefaultDockSizes(); | 1299 | setDefaultDockSizes(); | ||
1300 | 1300 | | |||
1301 | if( KMessageBox::warningContinueCancel( this, i18n( "Apply this layout change?" ), i18n( "Reset Layout" ) ) == KMessageBox::Cancel ) | 1301 | if( KMessageBox::warningContinueCancel( this, i18n( "Apply this layout change?" ), i18n( "Reset Layout" ) ) == KMessageBox::Cancel ) | ||
1302 | restoreState( state ); | 1302 | restoreState( state ); | ||
1303 | } | 1303 | } | ||
1304 | 1304 | | |||
1305 | void | 1305 | void | ||
1306 | MainWindow::setDefaultDockSizes() // SLOT | 1306 | MainWindow::setDefaultDockSizes() // SLOT | ||
1307 | { | 1307 | { | ||
1308 | int totalWidgetWidth = contentsRect().width(); | 1308 | int totalWidgetWidth = contentsRect().width(); | ||
1309 | 1309 | | |||
1310 | //get the width of the splitter handles, we need to subtract these... | 1310 | //get the width of the splitter handles, we need to subtract these... | ||
1311 | const int splitterHandleWidth = style()->pixelMetric( QStyle::PM_DockWidgetSeparatorExtent, 0, 0 ); | 1311 | const int splitterHandleWidth = style()->pixelMetric( QStyle::PM_DockWidgetSeparatorExtent, 0, 0 ); | ||
1312 | 1312 | | |||
1313 | totalWidgetWidth -= ( splitterHandleWidth * 2 ); | 1313 | totalWidgetWidth -= ( splitterHandleWidth * 2 ); | ||
1314 | 1314 | | |||
1315 | const int widgetWidth = totalWidgetWidth / 3; | 1315 | const int widgetWidth = totalWidgetWidth / 3; | ||
1316 | const int leftover = totalWidgetWidth - 3 * widgetWidth; | 1316 | const int leftover = totalWidgetWidth - 3 * widgetWidth; | ||
1317 | 1317 | | |||
1318 | #pragma message("PORTME KF5")/* | | |||
1319 | //We need to set fixed widths initially, just until the main window has been properly laid out. As soon as this has | 1318 | //We need to set fixed widths initially, just until the main window has been properly laid out. As soon as this has | ||
1320 | //happened, we will unlock these sizes again so that the elements can be resized by the user. | 1319 | //happened, we will unlock these sizes again so that the elements can be resized by the user. | ||
1321 | const int mins[3] = { m_browserDock->minimumWidth(), m_contextDock->minimumWidth(), m_playlistDock->minimumWidth() }; | 1320 | const int mins[3] = { m_browserDock->minimumWidth(), m_contextDock->minimumWidth(), m_playlistDock->minimumWidth() }; | ||
1322 | const int maxs[3] = { m_browserDock->maximumWidth(), m_contextDock->maximumWidth(), m_playlistDock->maximumWidth() }; | 1321 | const int maxs[3] = { m_browserDock->maximumWidth(), m_contextDock->maximumWidth(), m_playlistDock->maximumWidth() }; | ||
1323 | 1322 | | |||
1324 | m_browserDock->setFixedWidth( widgetWidth * 0.65 ); | 1323 | m_browserDock->setFixedWidth( widgetWidth * 0.65 ); | ||
1325 | m_contextDock->setFixedWidth( widgetWidth * 1.7 + leftover ); | 1324 | m_contextDock->setFixedWidth( widgetWidth * 1.7 + leftover ); | ||
1326 | m_playlistDock->setFixedWidth( widgetWidth * 0.65 ); | 1325 | m_playlistDock->setFixedWidth( widgetWidth * 0.65 ); | ||
1327 | 1326 | | |||
1328 | // Important: We need to activate the layout we have just set | 1327 | // Important: We need to activate the layout we have just set | ||
1329 | layout()->activate(); | 1328 | layout()->activate(); | ||
1330 | 1329 | | |||
1331 | m_browserDock->setMinimumWidth( mins[0] ); m_browserDock->setMaximumWidth( maxs[0] ); | 1330 | m_browserDock->setMinimumWidth( mins[0] ); m_browserDock->setMaximumWidth( maxs[0] ); | ||
1332 | m_contextDock->setMinimumWidth( mins[1] ); m_contextDock->setMaximumWidth( maxs[1] ); | 1331 | m_contextDock->setMinimumWidth( mins[1] ); m_contextDock->setMaximumWidth( maxs[1] ); | ||
1333 | m_playlistDock->setMinimumWidth( mins[2] ); m_playlistDock->setMaximumWidth( maxs[2] ); | 1332 | m_playlistDock->setMinimumWidth( mins[2] ); m_playlistDock->setMaximumWidth( maxs[2] ); | ||
1334 | */ | | |||
1335 | } | 1333 | } | ||
1336 | 1334 | | |||
1337 | bool | 1335 | bool | ||
1338 | MainWindow::playAudioCd() | 1336 | MainWindow::playAudioCd() | ||
1339 | { | 1337 | { | ||
1340 | DEBUG_BLOCK | 1338 | DEBUG_BLOCK | ||
1341 | //drop whatever we are doing and play auidocd | 1339 | //drop whatever we are doing and play auidocd | ||
1342 | 1340 | | |||
▲ Show 20 Lines • Show All 49 Lines • Show Last 20 Lines |