~mkas/mixxx/mysql

« back to all changes in this revision

Viewing changes to mixxx/src/mixxx.cpp

  • Committer: MKas
  • Date: 2012-11-03 12:55:54 UTC
  • Revision ID: mkas@tux.lt-20121103125554-ez5ajqyk7bwehrp2
merge with trunk + sql fixes

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
#include "trackinfoobject.h"
49
49
#include "upgrade.h"
50
50
#include "waveform/waveformwidgetfactory.h"
 
51
#include "widget/wwaveformviewer.h"
 
52
#include "widget/wwidget.h"
51
53
 
52
54
#ifdef __VINYLCONTROL__
53
55
#include "vinylcontrol/vinylcontrol.h"
193
195
        delete mixxxTranslator;
194
196
    }
195
197
 
 
198
    // Set the visibility of tooltips
 
199
    m_tooltips = m_pConfig->getValueString(ConfigKey("[Controls]", "Tooltips")).toInt();
 
200
 
196
201
    // Store the path in the config database
197
202
    m_pConfig->set(ConfigKey("[Config]", "Path"), ConfigValue(resourcePath));
198
203
 
302
307
                             m_pRecordingManager);
303
308
    qRegisterMetaType<TrackPointer>("TrackPointer");
304
309
 
305
 
    // Create the player manager.
306
 
    m_pPlayerManager = new PlayerManager(m_pConfig, m_pEngine, m_pLibrary);
307
 
    m_pPlayerManager->addDeck();
308
 
    m_pPlayerManager->addDeck();
309
 
    m_pPlayerManager->addDeck();
310
 
    m_pPlayerManager->addDeck();
311
 
    m_pPlayerManager->addSampler();
312
 
    m_pPlayerManager->addSampler();
313
 
    m_pPlayerManager->addSampler();
314
 
    m_pPlayerManager->addSampler();
315
 
 
316
 
    // register the engine's outputs
317
 
    m_pSoundManager->registerOutput(AudioOutput(AudioOutput::MASTER),
318
 
        m_pEngine);
319
 
    m_pSoundManager->registerOutput(AudioOutput(AudioOutput::HEADPHONES),
320
 
        m_pEngine);
321
 
    for (unsigned int deck = 0; deck < m_pPlayerManager->numDecks(); ++deck) {
322
 
        // TODO(bkgood) make this look less dumb by putting channelBase after
323
 
        // index in the AudioOutput() params
324
 
        m_pSoundManager->registerOutput(
325
 
            AudioOutput(AudioOutput::DECK, 0, deck), m_pEngine);
326
 
    }
327
 
 
328
310
#ifdef __VINYLCONTROL__
329
311
    m_pVCManager = new VinylControlManager(this, m_pConfig);
330
 
    for (unsigned int deck = 0; deck < m_pPlayerManager->numDecks(); ++deck) {
331
 
        m_pSoundManager->registerInput(
332
 
            AudioInput(AudioInput::VINYLCONTROL, 0, deck),
333
 
            m_pVCManager);
334
 
    }
335
312
#else
336
313
    m_pVCManager = NULL;
337
314
#endif
338
315
 
339
 
    //Scan the library directory.
340
 
    m_pLibraryScanner = new LibraryScanner(m_pLibrary->getTrackCollection());
341
 
 
342
 
    //Refresh the library models when the library (re)scan is finished.
343
 
    connect(m_pLibraryScanner, SIGNAL(scanFinished()),
344
 
            m_pLibrary, SLOT(slotRefreshLibraryModels()));
345
 
 
346
 
    //Scan the library for new files and directories
347
 
    bool rescan = (bool)m_pConfig->getValueString(ConfigKey("[Library]","RescanOnStartup")).toInt();
348
 
    // rescan the library if we get a new plugin
349
 
    QSet<QString> prev_plugins = QSet<QString>::fromList(m_pConfig->getValueString(
350
 
        ConfigKey("[Library]", "SupportedFileExtensions")).split(",", QString::SkipEmptyParts));
351
 
    QSet<QString> curr_plugins = QSet<QString>::fromList(
352
 
        SoundSourceProxy::supportedFileExtensions());
353
 
    rescan = rescan || (prev_plugins != curr_plugins);
354
 
 
355
 
    if(rescan || hasChanged_MusicDir){
356
 
        m_pLibraryScanner->scan(
357
 
            m_pConfig->getValueString(ConfigKey("[Playlist]", "Directory")));
358
 
        qDebug() << "Rescan finished";
359
 
    }
360
 
    m_pConfig->set(ConfigKey("[Library]", "SupportedFileExtensions"),
361
 
        QStringList(SoundSourceProxy::supportedFileExtensions()).join(","));
 
316
    // Create the player manager.
 
317
    m_pPlayerManager = new PlayerManager(m_pConfig, m_pSoundManager, m_pEngine,
 
318
                                         m_pLibrary, m_pVCManager);
 
319
    m_pPlayerManager->addDeck();
 
320
    m_pPlayerManager->addDeck();
 
321
    m_pPlayerManager->addSampler();
 
322
    m_pPlayerManager->addSampler();
 
323
    m_pPlayerManager->addSampler();
 
324
    m_pPlayerManager->addSampler();
362
325
 
363
326
    // Call inits to invoke all other construction parts
364
327
 
393
356
    WaveformWidgetFactory::instance()->setConfig(m_pConfig);
394
357
 
395
358
    m_pSkinLoader = new SkinLoader(m_pConfig);
 
359
    connect(this, SIGNAL(newSkinLoaded()),
 
360
            this, SLOT(onNewSkinLoaded()));
396
361
 
397
362
    // Initialize preference dialog
398
363
    m_pPrefDlg = new DlgPreferences(this, m_pSkinLoader, m_pSoundManager, m_pPlayerManager,
489
454
    // If we were told to start in fullscreen mode on the command-line,
490
455
    // then turn on fullscreen mode.
491
456
    if (args.getStartInFullscreen()) {
492
 
        slotOptionsFullScreen(true);
 
457
        slotViewFullScreen(true);
493
458
    }
 
459
    emit(newSkinLoaded());
494
460
 
495
461
    // Refresh the GUI (workaround for Qt 4.6 display bug)
496
462
    /* // TODO(bkgood) delete this block if the moving of setCentralWidget
507
473
    // Wait until all other ControlObjects are set up
508
474
    //  before initializing controllers
509
475
    m_pControllerManager->setUpDevices();
 
476
 
 
477
    // Scan the library for new files and directories
 
478
    bool rescan = (bool)m_pConfig->getValueString(ConfigKey("[Library]","RescanOnStartup")).toInt();
 
479
    // rescan the library if we get a new plugin
 
480
    QSet<QString> prev_plugins = QSet<QString>::fromList(m_pConfig->getValueString(
 
481
        ConfigKey("[Library]", "SupportedFileExtensions")).split(",", QString::SkipEmptyParts));
 
482
    QSet<QString> curr_plugins = QSet<QString>::fromList(
 
483
        SoundSourceProxy::supportedFileExtensions());
 
484
    rescan = rescan || (prev_plugins != curr_plugins);
 
485
    m_pConfig->set(ConfigKey("[Library]", "SupportedFileExtensions"),
 
486
        QStringList(SoundSourceProxy::supportedFileExtensions()).join(","));
 
487
 
 
488
    // Scan the library directory. Initialize this after the skinloader has
 
489
    // loaded a skin, see Bug #1047435
 
490
    m_pLibraryScanner = new LibraryScanner(m_pLibrary->getTrackCollection());
 
491
    connect(m_pLibraryScanner, SIGNAL(scanFinished()),
 
492
            this, SLOT(slotEnableRescanLibraryAction()));
 
493
 
 
494
    //Refresh the library models when the library (re)scan is finished.
 
495
    connect(m_pLibraryScanner, SIGNAL(scanFinished()),
 
496
            m_pLibrary, SLOT(slotRefreshLibraryModels()));
 
497
 
 
498
    if (rescan || hasChanged_MusicDir) {
 
499
        m_pLibraryScanner->scan(
 
500
            m_pConfig->getValueString(ConfigKey("[Playlist]", "Directory")));
 
501
        qDebug() << "Rescan finished";
 
502
    }
510
503
}
511
504
 
512
505
MixxxApp::~MixxxApp()
527
520
    qDebug() << "delete soundmanager " << qTime.elapsed();
528
521
    delete m_pSoundManager;
529
522
 
530
 
#ifdef __VINYLCONTROL__
531
 
    // VinylControlManager depends on a CO the engine owns
532
 
    // (vinylcontrol_enabled in VinylControlControl)
533
 
    qDebug() << "delete vinylcontrolmanager " << qTime.elapsed();
534
 
    delete m_pVCManager;
535
 
#endif
536
 
 
537
523
    // View depends on MixxxKeyboard, PlayerManager, Library
538
524
    qDebug() << "delete view " << qTime.elapsed();
539
525
    delete m_pView;
547
533
    m_pControllerManager->shutdown();
548
534
    delete m_pControllerManager;
549
535
 
550
 
    // PlayerManager depends on Engine, Library, and Config
 
536
    // PlayerManager depends on Engine, Library, SoundManager, VinylControlManager, and Config
551
537
    qDebug() << "delete playerManager " << qTime.elapsed();
552
538
    delete m_pPlayerManager;
553
539
 
 
540
#ifdef __VINYLCONTROL__
 
541
    // VinylControlManager depends on a CO the engine owns
 
542
    // (vinylcontrol_enabled in VinylControlControl)
 
543
    qDebug() << "delete vinylcontrolmanager " << qTime.elapsed();
 
544
    delete m_pVCManager;
 
545
#endif
 
546
 
554
547
    // EngineMaster depends on Config
555
548
    qDebug() << "delete m_pEngine " << qTime.elapsed();
556
549
    delete m_pEngine;
606
599
   qDebug() << "~MixxxApp: All leaking controls deleted.";
607
600
 
608
601
   delete m_pKeyboard;
 
602
   delete m_pKbdConfigEmpty;
 
603
 
 
604
   WaveformWidgetFactory::destroy();
 
605
}
 
606
 
 
607
void toggleVisibility(ConfigKey key, bool enable) {
 
608
    ControlObject* pShowControl = ControlObject::getControl(key);
 
609
    if (pShowControl == NULL) {
 
610
        return;
 
611
    }
 
612
    qDebug() << "Setting visibility for" << key.group << key.item << enable;
 
613
    pShowControl->set(enable ? 1.0 : 0.0);
 
614
}
 
615
 
 
616
void MixxxApp::slotViewShowSamplers(bool enable) {
 
617
    toggleVisibility(ConfigKey("[Samplers]", "show_samplers"), enable);
 
618
}
 
619
 
 
620
void MixxxApp::slotViewShowVinylControl(bool enable) {
 
621
    toggleVisibility(ConfigKey("[Vinylcontrol]", "show_vinylcontrol"), enable);
 
622
}
 
623
 
 
624
void MixxxApp::slotViewShowMicrophone(bool enable) {
 
625
    toggleVisibility(ConfigKey("[Microphone]", "show_microphone"), enable);
 
626
}
 
627
 
 
628
void setVisibilityOptionState(QAction* pAction, ConfigKey key) {
 
629
    ControlObject* pVisibilityControl = ControlObject::getControl(key);
 
630
    pAction->setEnabled(pVisibilityControl != NULL);
 
631
    pAction->setChecked(pVisibilityControl != NULL ? pVisibilityControl->get() > 0.0 : false);
 
632
}
 
633
 
 
634
void MixxxApp::onNewSkinLoaded() {
 
635
    setVisibilityOptionState(m_pViewVinylControl,
 
636
                             ConfigKey("[Vinylcontrol]", "show_vinylcontrol"));
 
637
    setVisibilityOptionState(m_pViewShowSamplers,
 
638
                             ConfigKey("[Samplers]", "show_samplers"));
 
639
    setVisibilityOptionState(m_pViewShowMicrophone,
 
640
                             ConfigKey("[Microphone]", "show_microphone"));
609
641
}
610
642
 
611
643
int MixxxApp::noSoundDlg(void)
776
808
    m_pLibraryRescan->setCheckable(false);
777
809
    connect(m_pLibraryRescan, SIGNAL(triggered()),
778
810
            this, SLOT(slotScanLibrary()));
779
 
    connect(m_pLibraryScanner, SIGNAL(scanFinished()),
780
 
            this, SLOT(slotEnableRescanLibraryAction()));
781
811
 
782
812
    QString createPlaylistTitle = tr("Add &New Playlist");
783
813
    QString createPlaylistText = tr("Create a new playlist");
801
831
 
802
832
    QString fullScreenTitle = tr("&Full Screen");
803
833
    QString fullScreenText = tr("Display Mixxx using the full screen");
804
 
    m_pOptionsFullScreen = new QAction(fullScreenTitle, this);
 
834
    m_pViewFullScreen = new QAction(fullScreenTitle, this);
805
835
#ifdef __APPLE__
806
 
    m_pOptionsFullScreen->setShortcut(QKeySequence(tr("Ctrl+Shift+F")));
 
836
    m_pViewFullScreen->setShortcut(QKeySequence(tr("Ctrl+Shift+F")));
807
837
#else
808
 
    m_pOptionsFullScreen->setShortcut(QKeySequence(tr("F11")));
 
838
    m_pViewFullScreen->setShortcut(QKeySequence(tr("F11")));
809
839
#endif
810
 
    m_pOptionsFullScreen->setShortcutContext(Qt::ApplicationShortcut);
 
840
    m_pViewFullScreen->setShortcutContext(Qt::ApplicationShortcut);
811
841
    // QShortcut * shortcut = new QShortcut(QKeySequence(tr("Esc")),  this);
812
842
    // connect(shortcut, SIGNAL(triggered()), this, SLOT(slotQuitFullScreen()));
813
 
    m_pOptionsFullScreen->setCheckable(true);
814
 
    m_pOptionsFullScreen->setChecked(false);
815
 
    m_pOptionsFullScreen->setStatusTip(fullScreenText);
816
 
    m_pOptionsFullScreen->setWhatsThis(buildWhatsThis(fullScreenTitle, fullScreenText));
817
 
    connect(m_pOptionsFullScreen, SIGNAL(toggled(bool)),
818
 
            this, SLOT(slotOptionsFullScreen(bool)));
 
843
    m_pViewFullScreen->setCheckable(true);
 
844
    m_pViewFullScreen->setChecked(false);
 
845
    m_pViewFullScreen->setStatusTip(fullScreenText);
 
846
    m_pViewFullScreen->setWhatsThis(buildWhatsThis(fullScreenTitle, fullScreenText));
 
847
    connect(m_pViewFullScreen, SIGNAL(toggled(bool)),
 
848
            this, SLOT(slotViewFullScreen(bool)));
819
849
 
820
850
    QString keyboardShortcutTitle = tr("Enable &Keyboard Shortcuts");
821
851
    QString keyboardShortcutText = tr("Toggles keyboard shortcuts on or off");
932
962
            this, SLOT(slotOptionsShoutcast(bool)));
933
963
#endif
934
964
 
 
965
    QString mayNotBeSupported = tr("May not be supported on all skins.");
 
966
    QString showSamplersTitle = tr("Show Sample Deck Widgets");
 
967
    QString showSamplersText = tr("Show the sample deck section of the Mixxx interface.") +
 
968
            " " + mayNotBeSupported;
 
969
    m_pViewShowSamplers = new QAction(showSamplersTitle, this);
 
970
    m_pViewShowSamplers->setCheckable(true);
 
971
    m_pViewShowSamplers->setShortcut(tr("Ctrl+S"));
 
972
    m_pViewShowSamplers->setStatusTip(showSamplersText);
 
973
    m_pViewShowSamplers->setWhatsThis(buildWhatsThis(showSamplersTitle, showSamplersText));
 
974
    connect(m_pViewShowSamplers, SIGNAL(toggled(bool)),
 
975
            this, SLOT(slotViewShowSamplers(bool)));
 
976
 
 
977
    QString showVinylControlTitle = tr("Show Vinyl Control Widgets");
 
978
    QString showVinylControlText = tr("Show the vinyl control section of the Mixxx interface.") +
 
979
            " " + mayNotBeSupported;
 
980
    m_pViewVinylControl = new QAction(showVinylControlTitle, this);
 
981
    m_pViewVinylControl->setCheckable(true);
 
982
    m_pViewVinylControl->setShortcut(tr("Ctrl+V"));
 
983
    m_pViewVinylControl->setStatusTip(showVinylControlText);
 
984
    m_pViewVinylControl->setWhatsThis(buildWhatsThis(showVinylControlTitle, showVinylControlText));
 
985
    connect(m_pViewVinylControl, SIGNAL(toggled(bool)),
 
986
            this, SLOT(slotViewShowVinylControl(bool)));
 
987
 
 
988
    QString showMicrophoneTitle = tr("Show Microphone Widgets");
 
989
    QString showMicrophoneText = tr("Show the microphone section of the Mixxx interface.") +
 
990
            " " + mayNotBeSupported;
 
991
    m_pViewShowMicrophone = new QAction(showMicrophoneTitle, this);
 
992
    m_pViewShowMicrophone->setCheckable(true);
 
993
    m_pViewShowMicrophone->setShortcut(tr("Ctrl+M"));
 
994
    m_pViewShowMicrophone->setStatusTip(showMicrophoneText);
 
995
    m_pViewShowMicrophone->setWhatsThis(buildWhatsThis(showMicrophoneTitle, showMicrophoneText));
 
996
    connect(m_pViewShowMicrophone, SIGNAL(toggled(bool)),
 
997
            this, SLOT(slotViewShowMicrophone(bool)));
 
998
 
 
999
 
 
1000
 
935
1001
    QString recordTitle = tr("&Record Mix");
936
1002
    QString recordText = tr("Record your mix to a file");
937
1003
    m_pOptionsRecord = new QAction(recordTitle, this);
966
1032
    m_pVinylControlMenu = new QMenu(tr("&Vinyl Control"), menuBar());
967
1033
    m_pVinylControlMenu->addAction(m_pOptionsVinylControl);
968
1034
    m_pVinylControlMenu->addAction(m_pOptionsVinylControl2);
 
1035
 
969
1036
    m_pOptionsMenu->addMenu(m_pVinylControlMenu);
 
1037
    m_pOptionsMenu->addSeparator();
970
1038
#endif
 
1039
 
971
1040
    m_pOptionsMenu->addAction(m_pOptionsRecord);
972
1041
#ifdef __SHOUTCAST__
973
1042
    m_pOptionsMenu->addAction(m_pOptionsShoutcast);
974
1043
#endif
975
1044
    m_pOptionsMenu->addAction(m_pOptionsKeyboard);
976
 
    m_pOptionsMenu->addAction(m_pOptionsFullScreen);
977
1045
    m_pOptionsMenu->addSeparator();
978
1046
    m_pOptionsMenu->addAction(m_pOptionsPreferences);
979
1047
 
984
1052
 
985
1053
    // menuBar entry viewMenu
986
1054
    //viewMenu->setCheckable(true);
 
1055
    m_pViewMenu->addAction(m_pViewShowSamplers);
 
1056
    m_pViewMenu->addAction(m_pViewShowMicrophone);
 
1057
    m_pViewMenu->addAction(m_pViewVinylControl);
 
1058
    m_pViewMenu->addSeparator();
 
1059
    m_pViewMenu->addAction(m_pViewFullScreen);
987
1060
 
988
1061
    // menuBar entry helpMenu
989
1062
    m_pHelpMenu->addAction(m_pHelpSupport);
995
1068
 
996
1069
    menuBar()->addMenu(m_pFileMenu);
997
1070
    menuBar()->addMenu(m_pLibraryMenu);
 
1071
    menuBar()->addMenu(m_pViewMenu);
998
1072
    menuBar()->addMenu(m_pOptionsMenu);
999
1073
 
1000
 
    //    menuBar()->addMenu(viewMenu);
1001
1074
    menuBar()->addSeparator();
1002
1075
    menuBar()->addMenu(m_pHelpMenu);
1003
1076
 
1066
1139
    }
1067
1140
}
1068
1141
 
1069
 
void MixxxApp::slotOptionsFullScreen(bool toggle)
 
1142
void MixxxApp::slotViewFullScreen(bool toggle)
1070
1143
{
1071
 
    if (m_pOptionsFullScreen)
1072
 
        m_pOptionsFullScreen->setChecked(toggle);
 
1144
    if (m_pViewFullScreen)
 
1145
        m_pViewFullScreen->setChecked(toggle);
1073
1146
 
1074
1147
    if (isFullScreen() == toggle) {
1075
1148
        return;
1282
1355
"Ilkka Tuohela<br>"
1283
1356
"Tom Gascoigne<br>"
1284
1357
"Max Linke<br>"
 
1358
"Neale Pickett<br>"
 
1359
"Aaron Mavrinac<br>"
 
1360
"Markus H&auml;rer<br>"
1285
1361
 
1286
1362
"</p>"
1287
1363
"<p align=\"center\"><b>%3</b></p>"
1407
1483
    QDesktopServices::openUrl(qManualUrl);
1408
1484
}
1409
1485
 
 
1486
void MixxxApp::setToolTips(int tt) {
 
1487
    m_tooltips = tt;
 
1488
}
 
1489
 
1410
1490
void MixxxApp::rebootMixxxView() {
1411
1491
 
1412
1492
    if (!m_pWidgetParent || !m_pView)
1426
1506
    // mode. If you change skins while in fullscreen (on Linux, at least) the
1427
1507
    // window returns to 0,0 but and the backdrop disappears so it looks as if
1428
1508
    // it is not fullscreen, but acts as if it is.
1429
 
    bool wasFullScreen = m_pOptionsFullScreen->isChecked();
1430
 
    slotOptionsFullScreen(false);
 
1509
    bool wasFullScreen = m_pViewFullScreen->isChecked();
 
1510
    slotViewFullScreen(false);
1431
1511
 
1432
1512
    //delete the view cause swaping central widget do not remove the old one !
1433
 
    if( m_pView)
 
1513
    if (m_pView) {
1434
1514
        delete m_pView;
1435
 
 
 
1515
    }
1436
1516
    m_pView = new QFrame();
1437
1517
 
1438
1518
    // assignment in next line intentional
1464
1544
    }
1465
1545
 
1466
1546
    if( wasFullScreen) {
1467
 
        slotOptionsFullScreen(true);
 
1547
        slotViewFullScreen(true);
1468
1548
    } else {
1469
1549
        move(initPosition.x() + (initSize.width() - width()) / 2,
1470
1550
             initPosition.y() + (initSize.height() - height()) / 2);
1480
1560
#endif
1481
1561
 
1482
1562
    qDebug() << "rebootMixxxView DONE";
 
1563
    emit(newSkinLoaded());
1483
1564
}
1484
1565
 
1485
1566
/** Event filter to block certain events. For example, this function is used
1488
1569
  */
1489
1570
bool MixxxApp::eventFilter(QObject *obj, QEvent *event)
1490
1571
{
1491
 
    static int tooltips =
1492
 
        m_pConfig->getValueString(ConfigKey("[Controls]", "Tooltips")).toInt();
1493
 
 
1494
1572
    if (event->type() == QEvent::ToolTip) {
1495
 
        // QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
1496
 
        // unused, remove? TODO(bkgood)
1497
 
        if (tooltips == 1)
 
1573
        // return true for no tool tips
 
1574
        if (m_tooltips == 1) {
 
1575
            // ON (only in Library)
 
1576
            WWidget* pWidget = dynamic_cast<WWidget*>(obj);
 
1577
            WWaveformViewer* pWfViewer = dynamic_cast<WWaveformViewer*>(obj);
 
1578
            QLabel* pLabel = dynamic_cast<QLabel*>(obj);
 
1579
            return (pWidget || pWfViewer || pLabel);
 
1580
        } else if (m_tooltips == 0) {
 
1581
            // ON
1498
1582
            return false;
1499
 
        else
 
1583
        } else {
 
1584
            // OFF
1500
1585
            return true;
 
1586
        }
1501
1587
    } else {
1502
1588
        // standard event processing
1503
1589
        return QObject::eventFilter(obj, event);