~keithsalisbury/mixxx/mixxx

« back to all changes in this revision

Viewing changes to mixxx/src/mixxx.cpp

  • Committer: Keith Salisbury
  • Date: 2012-05-06 13:44:20 UTC
  • mfrom: (2994.1.100 mixxx-trunk)
  • Revision ID: keithsalisbury@gmail.com-20120506134420-8k1dqq10aqmx0ecq
merge with trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
#include <QTranslator>
22
22
 
23
23
#include "mixxx.h"
24
 
#include "controlnull.h"
 
24
 
 
25
#include "analyserqueue.h"
 
26
#include "build.h" // Generated by SCons
 
27
#include "controlobjectthreadmain.h"
25
28
#include "controlpotmeter.h"
26
 
#include "controlobjectthreadmain.h"
 
29
#include "defs_urls.h"
 
30
#include "defs_version.h"
 
31
#include "dlgabout.h"
 
32
#include "dlgpreferences.h"
27
33
#include "engine/enginemaster.h"
28
34
#include "engine/enginemicrophone.h"
29
 
#include "trackinfoobject.h"
30
 
#include "dlgabout.h"
31
 
 
32
 
#include "soundsourceproxy.h"
33
 
 
34
 
#include "analyserqueue.h"
35
 
#include "playermanager.h"
36
 
 
37
35
#include "library/library.h"
 
36
#include "library/libraryscanner.h"
38
37
#include "library/librarytablemodel.h"
39
 
#include "library/libraryscanner.h"
40
 
 
 
38
#include "controllers/controllermanager.h"
 
39
#include "mixxxkeyboard.h"
 
40
#include "playermanager.h"
 
41
#include "recording/defs_recording.h"
 
42
#include "recording/recordingmanager.h"
 
43
#include "skin/legacyskinparser.h"
 
44
#include "skin/skinloader.h"
41
45
#include "soundmanager.h"
42
46
#include "soundmanagerutil.h"
43
 
#include "defs_urls.h"
44
 
#include "recording/defs_recording.h"
45
 
 
46
 
 
47
 
#include "midi/mididevicemanager.h"
48
 
 
 
47
#include "soundsourceproxy.h"
 
48
#include "trackinfoobject.h"
49
49
#include "upgrade.h"
50
 
#include "mixxxkeyboard.h"
51
 
#include "skin/skinloader.h"
52
 
#include "skin/legacyskinparser.h"
53
50
#include "waveform/waveformwidgetfactory.h"
54
51
 
55
 
 
56
 
#include "build.h" // #defines of details of the build set up (flags,
57
 
// repo number, etc). This isn't a real file, SConscript generates it and it
58
 
// probably gets placed in $PLATFORM_build/. By including this file here and
59
 
// only here we make sure that updating src or changing the build flags doesn't
60
 
// force a rebuild of everything
61
 
 
62
 
#include "defs_version.h"
63
 
 
64
52
#ifdef __VINYLCONTROL__
65
53
#include "vinylcontrol/vinylcontrol.h"
66
54
#include "vinylcontrol/vinylcontrolmanager.h"
73
61
}
74
62
 
75
63
 
 
64
bool loadTranslations(const QLocale& systemLocale, QString userLocale,
 
65
                      QString translation, QString prefix,
 
66
                      QString translationPath, QTranslator* pTranslator) {
 
67
 
 
68
    if (userLocale.size() == 0) {
 
69
#if QT_VERSION >= 0x040800
 
70
        return pTranslator->load(systemLocale, translation, prefix, translationPath);
 
71
#else
 
72
        userLocale = systemLocale.name();
 
73
#endif  // QT_VERSION
 
74
    }
 
75
    return pTranslator->load(translation + prefix + userLocale, translationPath);
 
76
}
 
77
 
 
78
 
76
79
MixxxApp::MixxxApp(QApplication *a, struct CmdlineArgs args)
77
80
{
78
81
    m_pApp = a;
121
124
    setWindowIcon(QIcon(":/images/ic_mixxx_window.png"));
122
125
 
123
126
    //Reset pointer to players
124
 
    m_pSoundManager = 0;
125
 
    m_pPrefDlg = 0;
126
 
    m_pMidiDeviceManager = 0;
127
 
    m_pRecordingManager = 0;
 
127
    m_pSoundManager = NULL;
 
128
    m_pPrefDlg = NULL;
 
129
    m_pControllerManager = 0;
 
130
    m_pRecordingManager = NULL;
128
131
 
129
132
    // Check to see if this is the first time this version of Mixxx is run
130
133
    // after an upgrade and make any needed changes.
136
139
    QString translationsFolder = qConfigPath + "translations/";
137
140
 
138
141
    // Load Qt base translations
139
 
    QString locale = args.locale;
140
 
    if (locale == "") {
141
 
        locale = QLocale::system().name();
142
 
    }
 
142
    QString userLocale = args.locale;
 
143
    QLocale systemLocale = QLocale::system();
143
144
 
144
145
    // Load Qt translations for this locale from the system translation
145
146
    // path. This is the lowest precedence QTranslator.
146
147
    QTranslator* qtTranslator = new QTranslator(a);
147
 
    if (qtTranslator->load("qt_" + locale,
148
 
                          QLibraryInfo::location(QLibraryInfo::TranslationsPath))) {
 
148
    if (loadTranslations(systemLocale, userLocale, "qt", "_",
 
149
                         QLibraryInfo::location(QLibraryInfo::TranslationsPath),
 
150
                         qtTranslator)) {
149
151
        a->installTranslator(qtTranslator);
150
152
    } else {
151
153
        delete qtTranslator;
154
156
    // Load Qt translations for this locale from the Mixxx translations
155
157
    // folder.
156
158
    QTranslator* mixxxQtTranslator = new QTranslator(a);
157
 
    if (mixxxQtTranslator->load("qt_" + locale, translationsFolder)) {
 
159
    if (loadTranslations(systemLocale, userLocale, "qt", "_",
 
160
                         translationsFolder,
 
161
                         mixxxQtTranslator)) {
158
162
        a->installTranslator(mixxxQtTranslator);
159
163
    } else {
160
164
        delete mixxxQtTranslator;
163
167
    // Load Mixxx specific translations for this locale from the Mixxx
164
168
    // translations folder.
165
169
    QTranslator* mixxxTranslator = new QTranslator(a);
166
 
    bool mixxxLoaded = mixxxTranslator->load("mixxx_" + locale,
167
 
                                             translationsFolder);
168
 
    qDebug() << "Loading translations for locale" << locale
 
170
    bool mixxxLoaded = loadTranslations(systemLocale, userLocale, "mixxx", "_",
 
171
                                        translationsFolder, mixxxTranslator);
 
172
    qDebug() << "Loading translations for locale"
 
173
             << (userLocale.size() > 0 ? userLocale : systemLocale.name())
169
174
             << "from translations folder" << translationsFolder << ":"
170
175
             << (mixxxLoaded ? "success" : "fail");
171
176
    if (mixxxLoaded) {
177
182
    // Store the path in the config database
178
183
    m_pConfig->set(ConfigKey("[Config]", "Path"), ConfigValue(qConfigPath));
179
184
 
 
185
    // Set the default value in settings file
 
186
    if (m_pConfig->getValueString(ConfigKey("[Keyboard]","Enabled")).length() == 0)
 
187
        m_pConfig->set(ConfigKey("[Keyboard]","Enabled"), ConfigValue(1));
 
188
 
180
189
    // Read keyboard configuration and set kdbConfig object in WWidget
181
190
    // Check first in user's Mixxx directory
182
191
    QString userKeyboard =
183
192
        QDir::homePath().append("/").append(SETTINGS_PATH)
184
193
            .append("Custom.kbd.cfg");
185
194
 
186
 
    ConfigObject<ConfigValueKbd>* pKbdConfig = NULL;
 
195
    //Empty keyboard configuration
 
196
    m_pKbdConfigEmpty = new ConfigObject<ConfigValueKbd>("");
187
197
 
188
198
    if (QFile::exists(userKeyboard)) {
189
199
        qDebug() << "Found and will use custom keyboard preset" << userKeyboard;
190
 
        pKbdConfig = new ConfigObject<ConfigValueKbd>(userKeyboard);
 
200
        m_pKbdConfig = new ConfigObject<ConfigValueKbd>(userKeyboard);
191
201
    }
192
202
    else
193
203
        // Otherwise use the default
194
 
        pKbdConfig =
 
204
        m_pKbdConfig =
195
205
                new ConfigObject<ConfigValueKbd>(
196
206
                    QString(qConfigPath)
197
207
                    .append("keyboard/").append("Standard.kbd.cfg"));
199
209
    // TODO(XXX) leak pKbdConfig, MixxxKeyboard owns it? Maybe roll all keyboard
200
210
    // initialization into MixxxKeyboard
201
211
    // Workaround for today: MixxxKeyboard calls delete
202
 
    m_pKeyboard = new MixxxKeyboard(pKbdConfig);
 
212
    bool keyboardShortcutsEnabled = m_pConfig->getValueString(
 
213
        ConfigKey("[Keyboard]", "Enabled")) == "1";
 
214
    m_pKeyboard = new MixxxKeyboard(keyboardShortcutsEnabled ? m_pKbdConfig : m_pKbdConfigEmpty);
203
215
 
204
216
    //create RecordingManager
205
217
    m_pRecordingManager = new RecordingManager(m_pConfig);
351
363
    //ControlObject::getControl(ConfigKey("[Channel1]","TrackEndMode"))->queueFromThread(m_pConfig->getValueString(ConfigKey("[Controls]","TrackEndModeCh1")).toDouble());
352
364
    //ControlObject::getControl(ConfigKey("[Channel2]","TrackEndMode"))->queueFromThread(m_pConfig->getValueString(ConfigKey("[Controls]","TrackEndModeCh2")).toDouble());
353
365
 
354
 
    qRegisterMetaType<MidiMessage>("MidiMessage");
355
 
    qRegisterMetaType<MidiStatusByte>("MidiStatusByte");
356
 
 
357
 
    // Initialise midi
358
 
    m_pMidiDeviceManager = new MidiDeviceManager(m_pConfig);
359
 
    m_pMidiDeviceManager->setupDevices();
 
366
    // Initialize controller sub-system,
 
367
    //  but do not set up controllers until the end of the application startup
 
368
    qDebug() << "Creating ControllerManager";
 
369
    m_pControllerManager = new ControllerManager(m_pConfig);
360
370
 
361
371
    WaveformWidgetFactory::create();
362
372
    WaveformWidgetFactory::instance()->setConfig(m_pConfig);
365
375
 
366
376
    // Initialize preference dialog
367
377
    m_pPrefDlg = new DlgPreferences(this, m_pSkinLoader, m_pSoundManager, m_pPlayerManager,
368
 
                                 m_pMidiDeviceManager, m_pVCManager, m_pConfig);
 
378
                                    m_pControllerManager, m_pVCManager, m_pConfig);
369
379
    m_pPrefDlg->setWindowIcon(QIcon(":/images/ic_mixxx_window.png"));
370
380
    m_pPrefDlg->setHidden(true);
371
381
 
418
428
    initMenuBar();
419
429
 
420
430
    // Use frame as container for view, needed for fullscreen display
421
 
    m_pView = new QFrame;
 
431
    m_pView = new QFrame();
422
432
 
423
433
    m_pWidgetParent = NULL;
424
434
    // Loads the skin as a child of m_pView
425
435
    // assignment intentional in next line
426
436
    if (!(m_pWidgetParent = m_pSkinLoader->loadDefaultSkin(
427
 
        m_pView, m_pKeyboard, m_pPlayerManager, m_pLibrary, m_pVCManager))) {
428
 
        qDebug() << "Could not load default skin.";
 
437
        m_pView, m_pKeyboard, m_pPlayerManager, m_pControllerManager, m_pLibrary, m_pVCManager))) {
 
438
        qCritical("default skin cannot be loaded see <b>mixxx</b> trace for more information.");
 
439
 
 
440
        //TODO (XXX) add dialog to warn user and launch skin choice page
 
441
        resize(640,480);
 
442
    } else {
 
443
        // this has to be after the OpenGL widgets are created or depending on a
 
444
        // million different variables the first waveform may be horribly
 
445
        // corrupted. See bug 521509 -- bkgood ?? -- vrince
 
446
        setCentralWidget(m_pView);
 
447
 
 
448
        // keep gui centered (esp for fullscreen)
 
449
        m_pView->setLayout( new QHBoxLayout(m_pView));
 
450
        m_pView->layout()->setContentsMargins(0,0,0,0);
 
451
        m_pView->layout()->addWidget(m_pWidgetParent);
 
452
        resize(m_pView->size());
429
453
    }
430
454
 
431
 
    // this has to be after the OpenGL widgets are created or depending on a
432
 
    // million different variables the first waveform may be horribly
433
 
    // corrupted. See bug 521509 -- bkgood
434
 
    setCentralWidget(m_pView);
435
 
 
436
 
    // keep gui centered (esp for fullscreen)
437
 
    // the layout will be deleted whenever m_pView gets deleted
438
 
    QHBoxLayout *pLayout = new QHBoxLayout(m_pView);
439
 
    pLayout->addWidget(m_pWidgetParent);
440
 
    pLayout->setContentsMargins(0, 0, 0, 0); // don't want margins
 
455
    //move the app in the center of the primary screen
 
456
    slotToCenterOfPrimaryScreen();
441
457
 
442
458
    // Check direct rendering and warn user if they don't have it
443
459
    checkDirectRendering();
463
479
            "+bug/521509)";
464
480
        rebootMixxxView();
465
481
    } */
 
482
 
 
483
    // Wait until all other ControlObjects are set up
 
484
    //  before initializing controllers
 
485
    m_pControllerManager->setUpDevices();
466
486
}
467
487
 
468
488
MixxxApp::~MixxxApp()
472
492
 
473
493
    qDebug() << "Destroying MixxxApp";
474
494
 
475
 
    qDebug() << "save config, " << qTime.elapsed();
 
495
    qDebug() << "save config " << qTime.elapsed();
476
496
    m_pConfig->Save();
477
497
 
478
498
    // Save state of End of track controls in config database
480
500
    //m_pConfig->set(ConfigKey("[Controls]","TrackEndModeCh2"), ConfigValue((int)ControlObject::getControl(ConfigKey("[Channel2]","TrackEndMode"))->get()));
481
501
 
482
502
    // SoundManager depend on Engine and Config
483
 
    qDebug() << "delete soundmanager, " << qTime.elapsed();
 
503
    qDebug() << "delete soundmanager " << qTime.elapsed();
484
504
    delete m_pSoundManager;
485
505
 
486
506
#ifdef __VINYLCONTROL__
487
507
    // VinylControlManager depends on a CO the engine owns
488
508
    // (vinylcontrol_enabled in VinylControlControl)
489
 
    qDebug() << "delete vinylcontrolmanager, " << qTime.elapsed();
 
509
    qDebug() << "delete vinylcontrolmanager " << qTime.elapsed();
490
510
    delete m_pVCManager;
491
511
#endif
492
512
 
493
513
    // View depends on MixxxKeyboard, PlayerManager, Library
494
 
    qDebug() << "delete view, " << qTime.elapsed();
 
514
    qDebug() << "delete view " << qTime.elapsed();
495
515
    delete m_pView;
496
516
 
497
517
    // SkinLoader depends on Config
498
 
    qDebug() << "delete SkinLoader";
 
518
    qDebug() << "delete SkinLoader " << qTime.elapsed();
499
519
    delete m_pSkinLoader;
500
520
 
501
 
    // MIDIDeviceManager depends on Config
502
 
    qDebug() << "delete MidiDeviceManager";
503
 
    delete m_pMidiDeviceManager;
 
521
    // ControllerManager depends on Config
 
522
    qDebug() << "shutdown & delete ControllerManager " << qTime.elapsed();
 
523
    m_pControllerManager->shutdown();
 
524
    delete m_pControllerManager;
504
525
 
505
526
    // PlayerManager depends on Engine, Library, and Config
506
 
    qDebug() << "delete playerManager" << qTime.elapsed();
 
527
    qDebug() << "delete playerManager " << qTime.elapsed();
507
528
    delete m_pPlayerManager;
508
529
 
509
530
    // EngineMaster depends on Config
510
 
    qDebug() << "delete m_pEngine, " << qTime.elapsed();
 
531
    qDebug() << "delete m_pEngine " << qTime.elapsed();
511
532
    delete m_pEngine;
512
533
 
513
534
    // LibraryScanner depends on Library
514
 
    qDebug() << "delete library scanner" <<  qTime.elapsed();
 
535
    qDebug() << "delete library scanner " <<  qTime.elapsed();
515
536
    delete m_pLibraryScanner;
516
537
 
517
538
    // Delete the library after the view so there are no dangling pointers to
518
539
    // Depends on RecordingManager
519
540
    // the data models.
520
 
    qDebug() << "delete library" << qTime.elapsed();
 
541
    qDebug() << "delete library " << qTime.elapsed();
521
542
    delete m_pLibrary;
522
543
 
523
544
    // RecordingManager depends on config
524
 
    qDebug() << "delete RecordingManager" << qTime.elapsed();
 
545
    qDebug() << "delete RecordingManager " << qTime.elapsed();
525
546
    delete m_pRecordingManager;
526
547
 
527
548
    // HACK: Save config again. We saved it once before doing some dangerous
534
555
    m_pConfig->Save();
535
556
    delete m_pPrefDlg;
536
557
 
537
 
    qDebug() << "delete config, " << qTime.elapsed();
 
558
    qDebug() << "delete config " << qTime.elapsed();
538
559
    delete m_pConfig;
539
560
 
540
561
    // Check for leaked ControlObjects and give warnings.
627
648
            msgBox.show();
628
649
 
629
650
        } else if (msgBox.clickedButton() == exitButton) {
630
 
            return 1;
 
651
            break;
631
652
        }
632
653
    }
 
654
    return 1;
633
655
}
634
656
 
635
657
int MixxxApp::noOutputDlg(bool *continueClicked)
636
658
{
637
659
    QMessageBox msgBox;
638
660
    msgBox.setIcon(QMessageBox::Warning);
639
 
    msgBox.setWindowTitle("No Output Devices");
640
 
    msgBox.setText( "<html>Mixxx was configured without any output sound devices. "
641
 
                    "Audio processing will be disabled without a configured output device."
 
661
    msgBox.setWindowTitle(tr("No Output Devices"));
 
662
    msgBox.setText( "<html>" + tr("Mixxx was configured without any output sound devices. "
 
663
                    "Audio processing will be disabled without a configured output device.") +
642
664
                    "<ul>"
643
 
                        "<li>"
644
 
                            "<b>Continue</b> without any outputs."
645
 
                        "</li>"
646
 
                        "<li>"
647
 
                            "<b>Reconfigure</b> Mixxx's sound device settings."
648
 
                        "</li>"
649
 
                        "<li>"
650
 
                            "<b>Exit</b> Mixxx."
 
665
                        "<li>" +
 
666
                            tr("<b>Continue</b> without any outputs.") +
 
667
                        "</li>"
 
668
                        "<li>" +
 
669
                            tr("<b>Reconfigure</b> Mixxx's sound device settings.") +
 
670
                        "</li>"
 
671
                        "<li>" +
 
672
                            tr("<b>Exit</b> Mixxx.") +
651
673
                        "</li>"
652
674
                    "</ul></html>"
653
675
    );
678
700
            msgBox.show();
679
701
 
680
702
        } else if (msgBox.clickedButton() == exitButton) {
681
 
            return 1;
 
703
            break;
682
704
        }
683
705
    }
 
706
    return 1;
 
707
}
 
708
 
 
709
QString buildWhatsThis(QString title, QString text) {
 
710
    return QString("%1\n\n%2").arg(title.replace("&", ""), text);
684
711
}
685
712
 
686
713
/** initializes all QActions of the application */
687
714
void MixxxApp::initActions()
688
715
{
689
 
    m_pFileLoadSongPlayer1 = new QAction(tr("Load Song (Player &1)..."), this);
 
716
    QString loadTrackText = tr("Load track to Deck %1");
 
717
    QString loadTrackStatusText = tr("Loads a track in deck %1");
 
718
    QString openText = tr("Open");
 
719
 
 
720
    QString player1LoadStatusText = loadTrackStatusText.arg(QString::number(1));
 
721
    m_pFileLoadSongPlayer1 = new QAction(loadTrackText.arg(QString::number(1)), this);
690
722
    m_pFileLoadSongPlayer1->setShortcut(tr("Ctrl+O"));
691
723
    m_pFileLoadSongPlayer1->setShortcutContext(Qt::ApplicationShortcut);
 
724
    m_pFileLoadSongPlayer1->setStatusTip(player1LoadStatusText);
 
725
    m_pFileLoadSongPlayer1->setWhatsThis(
 
726
        buildWhatsThis(openText, player1LoadStatusText));
 
727
    connect(m_pFileLoadSongPlayer1, SIGNAL(triggered()),
 
728
            this, SLOT(slotFileLoadSongPlayer1()));
692
729
 
693
 
    m_pFileLoadSongPlayer2 = new QAction(tr("Load Song (Player &2)..."), this);
 
730
    QString player2LoadStatusText = loadTrackStatusText.arg(QString::number(2));
 
731
    m_pFileLoadSongPlayer2 = new QAction(loadTrackText.arg(QString::number(2)), this);
694
732
    m_pFileLoadSongPlayer2->setShortcut(tr("Ctrl+Shift+O"));
695
733
    m_pFileLoadSongPlayer2->setShortcutContext(Qt::ApplicationShortcut);
 
734
    m_pFileLoadSongPlayer2->setStatusTip(player2LoadStatusText);
 
735
    m_pFileLoadSongPlayer2->setWhatsThis(
 
736
        buildWhatsThis(openText, player2LoadStatusText));
 
737
    connect(m_pFileLoadSongPlayer2, SIGNAL(triggered()),
 
738
            this, SLOT(slotFileLoadSongPlayer2()));
696
739
 
697
 
    m_pFileQuit = new QAction(tr("&Exit"), this);
 
740
    QString quitTitle = tr("&Exit");
 
741
    QString quitText = tr("Quits Mixxx");
 
742
    m_pFileQuit = new QAction(quitTitle, this);
698
743
    m_pFileQuit->setShortcut(tr("Ctrl+Q"));
699
744
    m_pFileQuit->setShortcutContext(Qt::ApplicationShortcut);
700
 
 
701
 
    m_pLibraryRescan = new QAction(tr("&Rescan Library"), this);
702
 
 
703
 
    m_pPlaylistsNew = new QAction(tr("Add &new playlist"), this);
 
745
    m_pFileQuit->setStatusTip(quitText);
 
746
    m_pFileQuit->setWhatsThis(buildWhatsThis(quitTitle, quitText));
 
747
    connect(m_pFileQuit, SIGNAL(triggered()), this, SLOT(slotFileQuit()));
 
748
 
 
749
    QString rescanTitle = tr("&Rescan Library");
 
750
    QString rescanText = tr("Rescans library folders for changes to tracks.");
 
751
    m_pLibraryRescan = new QAction(rescanTitle, this);
 
752
    m_pLibraryRescan->setStatusTip(rescanText);
 
753
    m_pLibraryRescan->setWhatsThis(buildWhatsThis(rescanTitle, rescanText));
 
754
    m_pLibraryRescan->setCheckable(false);
 
755
    connect(m_pLibraryRescan, SIGNAL(triggered()),
 
756
            this, SLOT(slotScanLibrary()));
 
757
    connect(m_pLibraryScanner, SIGNAL(scanFinished()),
 
758
            this, SLOT(slotEnableRescanLibraryAction()));
 
759
 
 
760
    QString createPlaylistTitle = tr("Add &new playlist");
 
761
    QString createPlaylistText = tr("Create a new playlist");
 
762
    m_pPlaylistsNew = new QAction(createPlaylistTitle, this);
704
763
    m_pPlaylistsNew->setShortcut(tr("Ctrl+N"));
705
764
    m_pPlaylistsNew->setShortcutContext(Qt::ApplicationShortcut);
 
765
    m_pPlaylistsNew->setStatusTip(createPlaylistText);
 
766
    m_pPlaylistsNew->setWhatsThis(buildWhatsThis(createPlaylistTitle, createPlaylistText));
 
767
    connect(m_pPlaylistsNew, SIGNAL(triggered()),
 
768
            m_pLibrary, SLOT(slotCreatePlaylist()));
706
769
 
707
 
    m_pCratesNew = new QAction(tr("Add new &crate"), this);
 
770
    QString createCrateTitle = tr("Add new &crate");
 
771
    QString createCrateText = tr("Create a new crate");
 
772
    m_pCratesNew = new QAction(createCrateTitle, this);
708
773
    m_pCratesNew->setShortcut(tr("Ctrl+C"));
709
774
    m_pCratesNew->setShortcutContext(Qt::ApplicationShortcut);
710
 
 
711
 
    m_pPlaylistsImport = new QAction(tr("&Import playlist"), this);
712
 
    m_pPlaylistsImport->setShortcut(tr("Ctrl+I"));
713
 
    m_pPlaylistsImport->setShortcutContext(Qt::ApplicationShortcut);
714
 
 
715
 
    m_pOptionsFullScreen = new QAction(tr("&Full Screen"), this);
716
 
 
 
775
    m_pCratesNew->setStatusTip(createCrateText);
 
776
    m_pCratesNew->setWhatsThis(buildWhatsThis(createCrateTitle, createCrateText));
 
777
    connect(m_pCratesNew, SIGNAL(triggered()),
 
778
            m_pLibrary, SLOT(slotCreateCrate()));
 
779
 
 
780
    QString fullScreenTitle = tr("&Full Screen");
 
781
    QString fullScreenText = tr("Display Mixxx using the full screen");
 
782
    m_pOptionsFullScreen = new QAction(fullScreenTitle, this);
717
783
#ifdef __APPLE__
718
784
    m_pOptionsFullScreen->setShortcut(tr("Ctrl+Shift+F"));
719
785
#else
720
786
    m_pOptionsFullScreen->setShortcut(tr("F11"));
721
787
#endif
722
 
 
723
788
    m_pOptionsFullScreen->setShortcutContext(Qt::ApplicationShortcut);
724
789
    // QShortcut * shortcut = new QShortcut(QKeySequence(tr("Esc")),  this);
725
790
    // connect(shortcut, SIGNAL(triggered()), this, SLOT(slotQuitFullScreen()));
726
 
 
727
 
    m_pOptionsPreferences = new QAction(tr("&Preferences"), this);
 
791
    m_pOptionsFullScreen->setCheckable(true);
 
792
    m_pOptionsFullScreen->setChecked(false);
 
793
    m_pOptionsFullScreen->setStatusTip(fullScreenText);
 
794
    m_pOptionsFullScreen->setWhatsThis(buildWhatsThis(fullScreenTitle, fullScreenText));
 
795
    connect(m_pOptionsFullScreen, SIGNAL(toggled(bool)),
 
796
            this, SLOT(slotOptionsFullScreen(bool)));
 
797
 
 
798
    QString keyboardShortcutTitle = tr("Enable &keyboard shortcuts");
 
799
    QString keyboardShortcutText = tr("Toggles keyboard shortcuts on or off");
 
800
    bool keyboardShortcutsEnabled = m_pConfig->getValueString(
 
801
        ConfigKey("[Keyboard]", "Enabled")) == "1";
 
802
    m_pOptionsKeyboard = new QAction(keyboardShortcutTitle, this);
 
803
    m_pOptionsKeyboard->setShortcut(tr("Ctrl+`"));
 
804
    m_pOptionsKeyboard->setShortcutContext(Qt::ApplicationShortcut);
 
805
    m_pOptionsKeyboard->setCheckable(true);
 
806
    m_pOptionsKeyboard->setChecked(keyboardShortcutsEnabled);
 
807
    m_pOptionsKeyboard->setStatusTip(keyboardShortcutText);
 
808
    m_pOptionsKeyboard->setWhatsThis(buildWhatsThis(keyboardShortcutTitle, keyboardShortcutText));
 
809
    connect(m_pOptionsKeyboard, SIGNAL(toggled(bool)),
 
810
            this, SLOT(slotOptionsKeyboard(bool)));
 
811
 
 
812
    QString preferencesTitle = tr("&Preferences");
 
813
    QString preferencesText = tr("Change Mixxx settings (e.g. playback, MIDI, controls)");
 
814
    m_pOptionsPreferences = new QAction(preferencesTitle, this);
728
815
    m_pOptionsPreferences->setShortcut(tr("Ctrl+P"));
729
816
    m_pOptionsPreferences->setShortcutContext(Qt::ApplicationShortcut);
730
 
 
731
 
    m_pHelpAboutApp = new QAction(tr("&About"), this);
732
 
    m_pHelpSupport = new QAction(tr("&Community Support"), this);
733
 
    m_pHelpManual = new QAction(tr("&User Manual"), this);
734
 
    m_pHelpFeedback = new QAction(tr("Send Us &Feedback"), this);
735
 
    m_pHelpTranslation = new QAction(tr("&Translate this application"), this);
 
817
    m_pOptionsPreferences->setStatusTip(preferencesText);
 
818
    m_pOptionsPreferences->setWhatsThis(buildWhatsThis(preferencesTitle, preferencesText));
 
819
    connect(m_pOptionsPreferences, SIGNAL(triggered()),
 
820
            this, SLOT(slotOptionsPreferences()));
 
821
 
 
822
    QString aboutTitle = tr("&About");
 
823
    QString aboutText = tr("About the application");
 
824
    m_pHelpAboutApp = new QAction(aboutTitle, this);
 
825
    m_pHelpAboutApp->setStatusTip(aboutText);
 
826
    m_pHelpAboutApp->setWhatsThis(buildWhatsThis(aboutTitle, aboutText));
 
827
    connect(m_pHelpAboutApp, SIGNAL(triggered()),
 
828
            this, SLOT(slotHelpAbout()));
 
829
 
 
830
    QString supportTitle = tr("&Community Support");
 
831
    QString supportText = tr("Get help with Mixxx");
 
832
    m_pHelpSupport = new QAction(supportTitle, this);
 
833
    m_pHelpSupport->setStatusTip(supportText);
 
834
    m_pHelpSupport->setWhatsThis(buildWhatsThis(supportTitle, supportText));
 
835
    connect(m_pHelpSupport, SIGNAL(triggered()), this, SLOT(slotHelpSupport()));
 
836
 
 
837
    QString manualTitle = tr("&User Manual");
 
838
    QString manualText = tr("Read the Mixxx user manual.");
 
839
    m_pHelpManual = new QAction(manualTitle, this);
 
840
    m_pHelpManual->setStatusTip(manualText);
 
841
    m_pHelpManual->setWhatsThis(buildWhatsThis(manualTitle, manualText));
 
842
    connect(m_pHelpManual, SIGNAL(triggered()), this, SLOT(slotHelpManual()));
 
843
 
 
844
    QString feedbackTitle = tr("Send Us &Feedback");
 
845
    QString feedbackText = tr("Send feedback to the Mixxx team.");
 
846
    m_pHelpFeedback = new QAction(feedbackTitle, this);
 
847
    m_pHelpFeedback->setStatusTip(feedbackText);
 
848
    m_pHelpFeedback->setWhatsThis(buildWhatsThis(feedbackTitle, feedbackText));
 
849
    connect(m_pHelpFeedback, SIGNAL(triggered()), this, SLOT(slotHelpFeedback()));
 
850
 
 
851
    QString translateTitle = tr("&Translate this application");
 
852
    QString translateText = tr("Help translate this application into your language.");
 
853
    m_pHelpTranslation = new QAction(translateTitle, this);
 
854
    m_pHelpTranslation->setStatusTip(translateText);
 
855
    m_pHelpTranslation->setWhatsThis(buildWhatsThis(translateTitle, translateText));
 
856
    connect(m_pHelpTranslation, SIGNAL(triggered()), this, SLOT(slotHelpTranslation()));
736
857
 
737
858
#ifdef __VINYLCONTROL__
738
 
    m_pOptionsVinylControl = new QAction(tr("Enable Vinyl Control &1"), this);
 
859
    QString vinylControlText = tr("Use timecoded vinyls on external turntables to control Mixxx");
 
860
    QString vinylControlTitle1 = tr("Enable Vinyl Control &1");
 
861
    QString vinylControlTitle2 = tr("Enable Vinyl Control &2");
 
862
 
 
863
    m_pOptionsVinylControl = new QAction(vinylControlTitle1, this);
739
864
    m_pOptionsVinylControl->setShortcut(tr("Ctrl+Y"));
740
865
    m_pOptionsVinylControl->setShortcutContext(Qt::ApplicationShortcut);
741
 
 
742
 
    m_pOptionsVinylControl2 = new QAction(tr("Enable Vinyl Control &2"), this);
743
 
    m_pOptionsVinylControl2->setShortcut(tr("Ctrl+U"));
744
 
    m_pOptionsVinylControl2->setShortcutContext(Qt::ApplicationShortcut);
745
 
#endif
746
 
 
747
 
#ifdef __SHOUTCAST__
748
 
    m_pOptionsShoutcast = new QAction(tr("Enable live &broadcasting"), this);
749
 
    m_pOptionsShoutcast->setShortcut(tr("Ctrl+L"));
750
 
    m_pOptionsShoutcast->setShortcutContext(Qt::ApplicationShortcut);
751
 
#endif
752
 
 
753
 
    m_pOptionsRecord = new QAction(tr("&Record Mix"), this);
754
 
    m_pOptionsRecord->setShortcut(tr("Ctrl+R"));
755
 
    m_pOptionsRecord->setShortcutContext(Qt::ApplicationShortcut);
756
 
 
757
 
    m_pFileLoadSongPlayer1->setStatusTip(tr("Opens a song in player 1"));
758
 
    m_pFileLoadSongPlayer1->setWhatsThis(
759
 
        tr("Open\n\nOpens a song in player 1"));
760
 
    connect(m_pFileLoadSongPlayer1, SIGNAL(triggered()),
761
 
            this, SLOT(slotFileLoadSongPlayer1()));
762
 
 
763
 
    m_pFileLoadSongPlayer2->setStatusTip(tr("Opens a song in player 2"));
764
 
    m_pFileLoadSongPlayer2->setWhatsThis(
765
 
        tr("Open\n\nOpens a song in player 2"));
766
 
    connect(m_pFileLoadSongPlayer2, SIGNAL(triggered()),
767
 
            this, SLOT(slotFileLoadSongPlayer2()));
768
 
 
769
 
    m_pFileQuit->setStatusTip(tr("Quits the application"));
770
 
    m_pFileQuit->setWhatsThis(tr("Exit\n\nQuits the application"));
771
 
    connect(m_pFileQuit, SIGNAL(triggered()), this, SLOT(slotFileQuit()));
772
 
 
773
 
    m_pLibraryRescan->setStatusTip(tr("Rescans the song library"));
774
 
    m_pLibraryRescan->setWhatsThis(
775
 
        tr("Rescan library\n\nRescans the song library"));
776
 
    m_pLibraryRescan->setCheckable(false);
777
 
    connect(m_pLibraryRescan, SIGNAL(triggered()),
778
 
            this, SLOT(slotScanLibrary()));
779
 
    connect(m_pLibraryScanner, SIGNAL(scanFinished()),
780
 
            this, SLOT(slotEnableRescanLibraryAction()));
781
 
 
782
 
    m_pPlaylistsNew->setStatusTip(tr("Create a new playlist"));
783
 
    m_pPlaylistsNew->setWhatsThis(tr("New playlist\n\nCreate a new playlist"));
784
 
    connect(m_pPlaylistsNew, SIGNAL(triggered()),
785
 
            m_pLibrary, SLOT(slotCreatePlaylist()));
786
 
 
787
 
    m_pCratesNew->setStatusTip(tr("Create a new crate"));
788
 
    m_pCratesNew->setWhatsThis(tr("New crate\n\nCreate a new crate."));
789
 
    connect(m_pCratesNew, SIGNAL(triggered()),
790
 
            m_pLibrary, SLOT(slotCreateCrate()));
791
 
 
792
 
    m_pPlaylistsImport->setStatusTip(tr("Import playlist"));
793
 
    m_pPlaylistsImport->setWhatsThis(tr("Import playlist"));
794
 
    //connect(playlistsImport, SIGNAL(triggered()),
795
 
    //        m_pTrack, SLOT(slotImportPlaylist()));
796
 
    //FIXME: Disabled due to library rework
797
 
 
798
 
#ifdef __VINYLCONTROL__
799
866
    // Either check or uncheck the vinyl control menu item depending on what
800
867
    // it was saved as.
801
868
    m_pOptionsVinylControl->setCheckable(true);
802
869
    m_pOptionsVinylControl->setChecked(false);
803
 
    m_pOptionsVinylControl->setStatusTip(tr("Activate Vinyl Control"));
804
 
    m_pOptionsVinylControl->setWhatsThis(
805
 
        tr("Use timecoded vinyls on external turntables to control Mixxx"));
 
870
    m_pOptionsVinylControl->setStatusTip(vinylControlText);
 
871
    m_pOptionsVinylControl->setWhatsThis(buildWhatsThis(vinylControlTitle1, vinylControlText));
806
872
    connect(m_pOptionsVinylControl, SIGNAL(toggled(bool)), this,
807
873
        SLOT(slotCheckboxVinylControl(bool)));
808
 
 
809
 
   ControlObjectThreadMain* enabled1 = new ControlObjectThreadMain(
 
874
    ControlObjectThreadMain* enabled1 = new ControlObjectThreadMain(
810
875
        ControlObject::getControl(ConfigKey("[Channel1]", "vinylcontrol_enabled")),this);
811
876
    connect(enabled1, SIGNAL(valueChanged(double)), this,
812
877
        SLOT(slotControlVinylControl(double)));
813
878
 
 
879
    m_pOptionsVinylControl2 = new QAction(vinylControlTitle2, this);
 
880
    m_pOptionsVinylControl2->setShortcut(tr("Ctrl+U"));
 
881
    m_pOptionsVinylControl2->setShortcutContext(Qt::ApplicationShortcut);
814
882
    m_pOptionsVinylControl2->setCheckable(true);
815
883
    m_pOptionsVinylControl2->setChecked(false);
816
 
    m_pOptionsVinylControl2->setStatusTip(tr("Activate Vinyl Control"));
817
 
    m_pOptionsVinylControl2->setWhatsThis(
818
 
        tr("Use timecoded vinyls on external turntables to control Mixxx"));
 
884
    m_pOptionsVinylControl2->setStatusTip(vinylControlText);
 
885
    m_pOptionsVinylControl2->setWhatsThis(buildWhatsThis(vinylControlTitle2, vinylControlText));
819
886
    connect(m_pOptionsVinylControl2, SIGNAL(toggled(bool)), this,
820
887
        SLOT(slotCheckboxVinylControl2(bool)));
821
888
 
826
893
#endif
827
894
 
828
895
#ifdef __SHOUTCAST__
 
896
    QString shoutcastTitle = tr("Enable live &broadcasting");
 
897
    QString shoutcastText = tr("Stream your mixes to a shoutcast or icecast server");
 
898
    m_pOptionsShoutcast = new QAction(shoutcastTitle, this);
 
899
    m_pOptionsShoutcast->setShortcut(tr("Ctrl+L"));
 
900
    m_pOptionsShoutcast->setShortcutContext(Qt::ApplicationShortcut);
829
901
    m_pOptionsShoutcast->setCheckable(true);
830
902
    bool broadcastEnabled =
831
903
        (m_pConfig->getValueString(ConfigKey("[Shoutcast]", "enabled"))
832
904
            .toInt() == 1);
833
905
 
834
906
    m_pOptionsShoutcast->setChecked(broadcastEnabled);
835
 
 
836
 
    m_pOptionsShoutcast->setStatusTip(tr("Activate live broadcasting"));
837
 
    m_pOptionsShoutcast->setWhatsThis(
838
 
        tr("Stream your mixes to a shoutcast or icecast server"));
839
 
 
 
907
    m_pOptionsShoutcast->setStatusTip(shoutcastText);
 
908
    m_pOptionsShoutcast->setWhatsThis(buildWhatsThis(shoutcastTitle, shoutcastText));
840
909
    connect(m_pOptionsShoutcast, SIGNAL(toggled(bool)),
841
910
            this, SLOT(slotOptionsShoutcast(bool)));
842
911
#endif
843
912
 
 
913
    QString recordTitle = tr("&Record Mix");
 
914
    QString recordText = tr("Record your mix to a file");
 
915
    m_pOptionsRecord = new QAction(recordTitle, this);
 
916
    m_pOptionsRecord->setShortcut(tr("Ctrl+R"));
 
917
    m_pOptionsRecord->setShortcutContext(Qt::ApplicationShortcut);
844
918
    m_pOptionsRecord->setCheckable(true);
845
 
    m_pOptionsRecord->setStatusTip(tr("Start Recording your Mix"));
846
 
    m_pOptionsRecord->setWhatsThis(tr("Record your mix to a file"));
 
919
    m_pOptionsRecord->setStatusTip(recordText);
 
920
    m_pOptionsRecord->setWhatsThis(buildWhatsThis(recordTitle, recordText));
847
921
    connect(m_pOptionsRecord, SIGNAL(toggled(bool)),
848
922
            this, SLOT(slotOptionsRecord(bool)));
849
 
 
850
 
    m_pOptionsFullScreen->setCheckable(true);
851
 
    m_pOptionsFullScreen->setChecked(false);
852
 
    m_pOptionsFullScreen->setStatusTip(tr("Full Screen"));
853
 
    m_pOptionsFullScreen->setWhatsThis(
854
 
        tr("Display Mixxx using the full screen"));
855
 
    connect(m_pOptionsFullScreen, SIGNAL(toggled(bool)),
856
 
            this, SLOT(slotOptionsFullScreen(bool)));
857
 
 
858
 
    m_pOptionsPreferences->setStatusTip(tr("Preferences"));
859
 
    m_pOptionsPreferences->setWhatsThis(
860
 
        tr("Preferences\nPlayback and MIDI preferences"));
861
 
    connect(m_pOptionsPreferences, SIGNAL(triggered()),
862
 
            this, SLOT(slotOptionsPreferences()));
863
 
 
864
 
    m_pHelpSupport->setStatusTip(tr("Support..."));
865
 
    m_pHelpSupport->setWhatsThis(tr("Support\n\nGet help with Mixxx"));
866
 
    connect(m_pHelpSupport, SIGNAL(triggered()), this, SLOT(slotHelpSupport()));
867
 
 
868
 
    m_pHelpManual->setStatusTip(tr("Read the Mixxx user manual."));
869
 
    m_pHelpManual->setWhatsThis(tr("Support\n\nRead the Mixxx user manual."));
870
 
    connect(m_pHelpManual, SIGNAL(triggered()), this, SLOT(slotHelpManual()));
871
 
 
872
 
    m_pHelpFeedback->setStatusTip(tr("Send feedback to the Mixxx team."));
873
 
    m_pHelpFeedback->setWhatsThis(tr("Support\n\nSend feedback to the Mixxx team."));
874
 
    connect(m_pHelpFeedback, SIGNAL(triggered()), this, SLOT(slotHelpFeedback()));
875
 
 
876
 
    m_pHelpTranslation->setStatusTip(tr("Help translate this application into your language."));
877
 
    m_pHelpTranslation->setWhatsThis(tr("Support\n\nHelp translate this application into your language."));
878
 
    connect(m_pHelpTranslation, SIGNAL(triggered()), this, SLOT(slotHelpTranslation()));
879
 
 
880
 
    m_pHelpAboutApp->setStatusTip(tr("About the application"));
881
 
    m_pHelpAboutApp->setWhatsThis(tr("About\n\nAbout the application"));
882
 
    connect(m_pHelpAboutApp, SIGNAL(triggered()), this, SLOT(slotHelpAbout()));
883
923
}
884
924
 
885
925
void MixxxApp::initMenuBar()
886
926
{
887
927
    // MENUBAR
888
 
   m_pFileMenu = new QMenu(tr("&File"), menuBar());
889
 
   m_pOptionsMenu = new QMenu(tr("&Options"), menuBar());
890
 
   m_pLibraryMenu = new QMenu(tr("&Library"),menuBar());
891
 
   m_pViewMenu = new QMenu(tr("&View"), menuBar());
892
 
   m_pHelpMenu = new QMenu(tr("&Help"), menuBar());
 
928
    m_pFileMenu = new QMenu(tr("&File"), menuBar());
 
929
    m_pOptionsMenu = new QMenu(tr("&Options"), menuBar());
 
930
    m_pLibraryMenu = new QMenu(tr("&Library"),menuBar());
 
931
    m_pViewMenu = new QMenu(tr("&View"), menuBar());
 
932
    m_pHelpMenu = new QMenu(tr("&Help"), menuBar());
893
933
    connect(m_pOptionsMenu, SIGNAL(aboutToShow()),
894
934
            this, SLOT(slotOptionsMenuShow()));
895
935
    // menuBar entry fileMenu
910
950
#ifdef __SHOUTCAST__
911
951
    m_pOptionsMenu->addAction(m_pOptionsShoutcast);
912
952
#endif
 
953
    m_pOptionsMenu->addAction(m_pOptionsKeyboard);
913
954
    m_pOptionsMenu->addAction(m_pOptionsFullScreen);
914
955
    m_pOptionsMenu->addSeparator();
915
956
    m_pOptionsMenu->addAction(m_pOptionsPreferences);
916
957
 
917
 
    //    libraryMenu->setCheckable(true);
918
958
    m_pLibraryMenu->addAction(m_pLibraryRescan);
919
959
    m_pLibraryMenu->addSeparator();
920
960
    m_pLibraryMenu->addAction(m_pPlaylistsNew);
921
961
    m_pLibraryMenu->addAction(m_pCratesNew);
922
 
    //libraryMenu->addAction(playlistsImport);
923
962
 
924
963
    // menuBar entry viewMenu
925
964
    //viewMenu->setCheckable(true);
943
982
    m_NativeMenuBarSupport = menuBar()->isNativeMenuBar();
944
983
}
945
984
 
946
 
void MixxxApp::slotlibraryMenuAboutToShow(){
947
 
}
948
 
 
949
 
bool MixxxApp::queryExit()
950
 
{
951
 
    int exit=QMessageBox::information(this, tr("Quit..."),
952
 
                                      tr("Do your really want to quit?"),
953
 
                                      QMessageBox::Ok, QMessageBox::Cancel);
954
 
 
955
 
    if (exit==1)
956
 
    {
957
 
    }
958
 
    else
959
 
    {
960
 
    };
961
 
 
962
 
    return (exit==1);
963
 
}
964
 
 
965
 
void MixxxApp::slotFileLoadSongPlayer1()
966
 
{
967
 
    ControlObject* play =
968
 
        ControlObject::getControl(ConfigKey("[Channel1]", "play"));
969
 
 
970
 
    if (play->get() == 1.)
971
 
    {
972
 
        int ret = QMessageBox::warning(this, tr("Mixxx"),
973
 
            tr("Player 1 is currently playing a song.\n"
974
 
            "Are you sure you want to load a new song?"),
975
 
            QMessageBox::Yes | QMessageBox::No,
976
 
            QMessageBox::No);
977
 
 
978
 
        if (ret != QMessageBox::Yes)
979
 
            return;
980
 
    }
981
 
 
982
 
    QString s =
983
 
        QFileDialog::getOpenFileName(
984
 
            this,
985
 
            tr("Load Song into Player 1"),
986
 
            m_pConfig->getValueString(ConfigKey("[Playlist]", "Directory")),
987
 
            QString("Audio (%1)")
988
 
                .arg(SoundSourceProxy::supportedFileExtensionsString()));
989
 
 
990
 
    if (s != QString::null) {
991
 
        m_pPlayerManager->slotLoadToDeck(s, 1);
992
 
    }
993
 
}
994
 
 
995
 
void MixxxApp::slotFileLoadSongPlayer2()
996
 
{
997
 
    ControlObject* play =
998
 
        ControlObject::getControl(ConfigKey("[Channel2]", "play"));
999
 
 
1000
 
    if (play->get() == 1.)
1001
 
    {
1002
 
        int ret = QMessageBox::warning(this, tr("Mixxx"),
1003
 
            tr("Player 2 is currently playing a song.\n"
1004
 
            "Are you sure you want to load a new song?"),
1005
 
            QMessageBox::Yes | QMessageBox::No,
1006
 
            QMessageBox::No);
1007
 
 
1008
 
        if (ret != QMessageBox::Yes)
1009
 
            return;
1010
 
    }
1011
 
 
1012
 
    QString s =
1013
 
        QFileDialog::getOpenFileName(
1014
 
            this,
1015
 
            tr("Load Song into Player 2"),
1016
 
            m_pConfig->getValueString(ConfigKey("[Playlist]", "Directory")),
1017
 
            QString("Audio (%1)")
1018
 
                .arg(SoundSourceProxy::supportedFileExtensionsString()));
1019
 
 
1020
 
    if (s != QString::null) {
1021
 
        m_pPlayerManager->slotLoadToDeck(s, 2);
1022
 
    }
 
985
void MixxxApp::slotFileLoadSongPlayer(int deck) {
 
986
    QString group = m_pPlayerManager->groupForDeck(deck-1);
 
987
    ControlObject* play =
 
988
        ControlObject::getControl(ConfigKey(group, "play"));
 
989
 
 
990
    QString loadTrackText = tr("Load track to Deck %1").arg(QString::number(deck));
 
991
    QString deckWarningMessage = tr("Deck %1 is currently playing a track.")
 
992
            .arg(QString::number(deck));
 
993
    QString areYouSure = tr("Are you sure you want to load a new track?");
 
994
 
 
995
    if (play->get() == 1.) {
 
996
        int ret = QMessageBox::warning(this, tr("Mixxx"),
 
997
            deckWarningMessage + "\n" + areYouSure,
 
998
            QMessageBox::Yes | QMessageBox::No,
 
999
            QMessageBox::No);
 
1000
 
 
1001
        if (ret != QMessageBox::Yes)
 
1002
            return;
 
1003
    }
 
1004
 
 
1005
    QString s =
 
1006
        QFileDialog::getOpenFileName(
 
1007
            this,
 
1008
            loadTrackText,
 
1009
            m_pConfig->getValueString(ConfigKey("[Playlist]", "Directory")),
 
1010
            QString("Audio (%1)")
 
1011
                .arg(SoundSourceProxy::supportedFileExtensionsString()));
 
1012
 
 
1013
    if (!s.isNull()) {
 
1014
        m_pPlayerManager->slotLoadToDeck(s, deck);
 
1015
    }
 
1016
}
 
1017
 
 
1018
void MixxxApp::slotFileLoadSongPlayer1() {
 
1019
    slotFileLoadSongPlayer(1);
 
1020
}
 
1021
 
 
1022
void MixxxApp::slotFileLoadSongPlayer2() {
 
1023
    slotFileLoadSongPlayer(1);
1023
1024
}
1024
1025
 
1025
1026
void MixxxApp::slotFileQuit()
1031
1032
    qApp->quit();
1032
1033
}
1033
1034
 
 
1035
void MixxxApp::slotOptionsKeyboard(bool toggle) {
 
1036
    if (toggle) {
 
1037
        //qDebug() << "Enable keyboard shortcuts/mappings";
 
1038
        m_pKeyboard->setKeyboardConfig(m_pKbdConfig);
 
1039
        m_pConfig->set(ConfigKey("[Keyboard]","Enabled"), ConfigValue(1));
 
1040
    } else {
 
1041
        //qDebug() << "Disable keyboard shortcuts/mappings";
 
1042
        m_pKeyboard->setKeyboardConfig(m_pKbdConfigEmpty);
 
1043
        m_pConfig->set(ConfigKey("[Keyboard]","Enabled"), ConfigValue(0));
 
1044
    }
 
1045
}
 
1046
 
1034
1047
void MixxxApp::slotOptionsFullScreen(bool toggle)
1035
1048
{
1036
1049
    if (m_pOptionsFullScreen)
1170
1183
    QString s_pastDevs=tr("Past Developers");
1171
1184
    QString s_pastContribs=tr("Past Contributors");
1172
1185
 
1173
 
    QString credits =
1174
 
    QString("<p align=\"center\"><b>%1</b></p>"
 
1186
    QString credits = QString("<p align=\"center\"><b>%1</b></p>"
1175
1187
"<p align=\"center\">"
1176
1188
"Adam Davison<br>"
1177
1189
"Albert Santoni<br>"
1185
1197
"Owen Williams<br>"
1186
1198
"Vittorio Colao<br>"
1187
1199
"Daniel Sch&uuml;rmann<br>"
 
1200
"Thomas Vincent<br>"
1188
1201
 
1189
1202
"</p>"
1190
1203
"<p align=\"center\"><b>%2</b></p>"
1237
1250
"Maxime Bochon<br>"
1238
1251
"Akash Shetye<br>"
1239
1252
"Pascal Bleser<br>"
 
1253
"Florian Mahlknecht<br>"
 
1254
"Ben Clark<br>"
 
1255
"Ilkka Tuohela<br>"
1240
1256
 
1241
1257
"</p>"
1242
1258
"<p align=\"center\"><b>%3</b></p>"
1367
1383
    if (!m_pWidgetParent || !m_pView)
1368
1384
        return;
1369
1385
 
1370
 
    qDebug() << "Now in Rebootmixxview...";
 
1386
    qDebug() << "Now in rebootMixxxView...";
 
1387
 
 
1388
    QPoint initPosition = pos();
 
1389
    QSize initSize = size();
 
1390
 
 
1391
    m_pView->hide();
1371
1392
 
1372
1393
    WaveformWidgetFactory::instance()->stop();
1373
1394
    WaveformWidgetFactory::instance()->destroyWidgets();
1376
1397
    // mode. If you change skins while in fullscreen (on Linux, at least) the
1377
1398
    // window returns to 0,0 but and the backdrop disappears so it looks as if
1378
1399
    // it is not fullscreen, but acts as if it is.
 
1400
    bool wasFullScreen = m_pOptionsFullScreen->isChecked();
1379
1401
    slotOptionsFullScreen(false);
1380
1402
 
1381
1403
    // TODO(XXX) Make getSkinPath not public
1382
1404
    QString qSkinPath = m_pSkinLoader->getConfiguredSkinPath();
1383
1405
 
1384
 
    QWidget* pNewView = new QFrame();
 
1406
    //delete the view cause swaping central widget do not remove the old one !
 
1407
    if( m_pView)
 
1408
        delete m_pView;
 
1409
 
 
1410
    m_pView = new QFrame();
1385
1411
 
1386
1412
    // assignment in next line intentional
1387
 
    if (!(m_pWidgetParent = m_pSkinLoader->loadDefaultSkin(pNewView,
1388
 
                                        m_pKeyboard,
1389
 
                                        m_pPlayerManager,
1390
 
                                        m_pLibrary,
1391
 
                                        m_pVCManager))) {
1392
 
        qDebug() << "Could not reload the skin.";
1393
 
    }
1394
 
 
1395
 
    // don't move this before loadDefaultSkin above. bug 521509 --bkgood
1396
 
    // this hides and deletes the old CentralWidget
1397
 
    setCentralWidget(pNewView);
1398
 
 
1399
 
    m_pView = pNewView;
1400
 
 
1401
 
    // keep gui centered (esp for fullscreen)
1402
 
    // the layout will be deleted whenever m_pView gets deleted
1403
 
    QHBoxLayout *pLayout = new QHBoxLayout(m_pView);
1404
 
    pLayout->addWidget(m_pWidgetParent);
1405
 
    pLayout->setContentsMargins(0, 0, 0, 0); // don't want margins
1406
 
 
1407
 
    // if we move from big skin to smaller skin, size the window down to fit
1408
 
    // (qt scales up for us if we go the other way) -bkgood
1409
 
    // this doesn't always seem to snap down tight on Windows... sigh -bkgood
1410
 
    setFixedSize(m_pView->width(), m_pView->height());
1411
 
    setFixedSize(QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX));
 
1413
    if (!(m_pWidgetParent = m_pSkinLoader->loadDefaultSkin(m_pView,
 
1414
                                                           m_pKeyboard,
 
1415
                                                           m_pPlayerManager,
 
1416
                                                           m_pControllerManager,
 
1417
                                                           m_pLibrary,
 
1418
                                                           m_pVCManager))) {
 
1419
 
 
1420
        QMessageBox::critical(this,
 
1421
                              tr("Error in skin file"),
 
1422
                              tr("The selected skin cannot be loaded."));
 
1423
    }
 
1424
    else {
 
1425
        // don't move this before loadDefaultSkin above. bug 521509 --bkgood
 
1426
        // NOTE: (vrince) I don't know this comment is relevant now ...
 
1427
        setCentralWidget(m_pView);
 
1428
 
 
1429
        // keep gui centered (esp for fullscreen)
 
1430
        m_pView->setLayout( new QHBoxLayout(m_pView));
 
1431
        m_pView->layout()->setContentsMargins(0,0,0,0);
 
1432
        m_pView->layout()->addWidget(m_pWidgetParent);
 
1433
 
 
1434
         //qDebug() << "view size" << m_pView->size();
 
1435
 
 
1436
        //TODO: (vrince) size is good but resize do not append !!
 
1437
        resize(m_pView->size());
 
1438
    }
 
1439
 
 
1440
    if( wasFullScreen) {
 
1441
        slotOptionsFullScreen(true);
 
1442
    } else {
 
1443
        move(initPosition.x() + (initSize.width() - width()) / 2,
 
1444
             initPosition.y() + (initSize.height() - height()) / 2);
 
1445
    }
1412
1446
 
1413
1447
    WaveformWidgetFactory::instance()->start();
1414
1448
 
1417
1451
#if __OSX__
1418
1452
    menuBar()->setNativeMenuBar(m_NativeMenuBarSupport);
1419
1453
#endif
1420
 
    qDebug() << "rebootgui DONE";
 
1454
    qDebug() << "rebootMixxxView DONE";
1421
1455
}
1422
1456
 
1423
1457
/** Event filter to block certain events. For example, this function is used
1484
1518
#endif
1485
1519
}
1486
1520
 
 
1521
void MixxxApp::slotToCenterOfPrimaryScreen() {
 
1522
    if (!m_pView)
 
1523
        return;
 
1524
 
 
1525
    QDesktopWidget* desktop = QApplication::desktop();
 
1526
    int primaryScreen = desktop->primaryScreen();
 
1527
    QRect primaryScreenRect = desktop->availableGeometry(primaryScreen);
 
1528
 
 
1529
    move(primaryScreenRect.left() + (primaryScreenRect.width() - m_pView->width()) / 2,
 
1530
         primaryScreenRect.top() + (primaryScreenRect.height() - m_pView->height()) / 2);
 
1531
}
 
1532
 
1487
1533
void MixxxApp::checkDirectRendering() {
1488
1534
    // IF
1489
1535
    //  * A waveform viewer exists
1494
1540
    // THEN
1495
1541
    //  * Warn user
1496
1542
 
1497
 
    //TODO vRince replug this kind of warning using ...
 
1543
    WaveformWidgetFactory* factory = WaveformWidgetFactory::instance();
 
1544
    if (!factory)
 
1545
        return;
1498
1546
 
1499
 
    /*
1500
 
    if (WaveformViewerFactory::numViewers(WAVEFORM_GL) > 0 &&
1501
 
        !WaveformViewerFactory::isDirectRenderingEnabled() &&
 
1547
    if (!factory->isOpenGLAvailable() &&
1502
1548
        m_pConfig->getValueString(ConfigKey("[Direct Rendering]", "Warned")) != QString("yes")) {
1503
 
                    QMessageBox::warning(0, "OpenGL Direct Rendering",
1504
 
                             "Direct rendering is not enabled on your machine.\n\nThis means that the waveform displays will be very\nslow and take a lot of CPU time. Either update your\nconfiguration to enable direct rendering, or disable\nthe waveform displays in the control panel by\nselecting \"Simple\" under waveform displays.\nNOTE: In case you run on NVidia hardware,\ndirect rendering may not be present, but you will\nnot experience a degradation in performance.");
1505
 
        m_pConfig->set(ConfigKey("[Direct Rendering]", "Warned"), ConfigValue(QString("yes")));
 
1549
        QMessageBox::warning(
 
1550
            0, tr("OpenGL Direct Rendering"),
 
1551
            tr("Direct rendering is not enabled on your machine.<br><br>"
 
1552
               "This means that the waveform displays will be very<br>"
 
1553
               "<b>slow and may tax your CPU heavily</b>. Either update your<br>"
 
1554
               "configuration to enable direct rendering, or disable<br>"
 
1555
               "the waveform displays in the Mixxx preferences by selecting<br>"
 
1556
               "\"Empty\" as the waveform display in the 'Interface' section.<br><br>"
 
1557
               "NOTE: If you use NVIDIA hardware,<br>"
 
1558
               "direct rendering may not be present, but you should<br>"
 
1559
               "not experience degraded performance."));
 
1560
        m_pConfig->set(ConfigKey("[Direct Rendering]", "Warned"), QString("yes"));
1506
1561
    }
1507
 
    */
1508
1562
}
1509
1563
 
1510
1564
bool MixxxApp::confirmExit() {