diff --git a/mscore/inspector/inspector.cpp b/mscore/inspector/inspector.cpp index 2cea22754f801..577d13973f335 100644 --- a/mscore/inspector/inspector.cpp +++ b/mscore/inspector/inspector.cpp @@ -86,7 +86,7 @@ void MuseScore::showInspector(bool visible) addDockWidget(Qt::RightDockWidgetArea, _inspector); } if (_inspector) - reDisplayDockWidget(_inspector, visible); + _inspector->setVisible(visible); if (visible) updateInspector(); } diff --git a/mscore/menus.cpp b/mscore/menus.cpp index 689b4f90541f1..20486ccb97b10 100644 --- a/mscore/menus.cpp +++ b/mscore/menus.cpp @@ -1173,7 +1173,7 @@ void MuseScore::showPalette(bool visible) updateIcons(); } if (paletteBox) // read failed? - reDisplayDockWidget(paletteBox, visible); + paletteBox->setVisible(visible); a->setChecked(visible); } diff --git a/mscore/mixer.cpp b/mscore/mixer.cpp index b9fc8786eee56..90ce1521611ea 100644 --- a/mscore/mixer.cpp +++ b/mscore/mixer.cpp @@ -76,12 +76,11 @@ Mixer::Mixer(QWidget* parent) showDetails(true), trackHolder(nullptr) { - - // note: because of setupUi side-effects (generating a showEvent) it's critical - // that enablePlay is created first. - enablePlay = new EnablePlayForWidget(this); + setupUi(this); - setupUi(this); // + setWindowFlags(Qt::Tool); + setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint); + setAllowedAreas(Qt::DockWidgetAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea)); trackAreaLayout = new QHBoxLayout; trackAreaLayout->setMargin(0); @@ -89,7 +88,7 @@ Mixer::Mixer(QWidget* parent) trackArea->setLayout(trackAreaLayout); mixerDetails = new MixerDetails(this); - detailsLayout = new QGridLayout(); + detailsLayout = new QGridLayout(this); detailsLayout->addWidget(mixerDetails); detailsLayout->setContentsMargins(0, 0, 0, 0); @@ -121,6 +120,8 @@ Mixer::Mixer(QWidget* parent) connect(tracks_scrollArea->horizontalScrollBar(), SIGNAL(rangeChanged(int, int)), SLOT(adjustScrollPosition(int, int))); connect(tracks_scrollArea->horizontalScrollBar(), SIGNAL(valueChanged(int)), SLOT(checkKeptScrollValue(int))); + enablePlay = new EnablePlayForWidget(this); + readSettings(); retranslate(true); } @@ -199,10 +200,6 @@ void Mixer::masterVolumeChanged(double decibels) void Mixer::on_partOnlyCheckBox_toggled(bool checked) { - - if (!_activeScore) // cope with case of no score being present - return; - if (!_activeScore->excerpt()) return; @@ -250,17 +247,8 @@ void Mixer::showEvent(QShowEvent* e) { enablePlay->showEvent(e); QWidget::showEvent(e); - getAction("toggle-mixer")->setChecked(true); - } - -//--------------------------------------------------------- -// hideEvent -//--------------------------------------------------------- - -void Mixer::hideEvent(QHideEvent* e) - { - QWidget::hideEvent(e); - getAction("toggle-mixer")->setChecked(false); + activateWindow(); + setFocus(); } //--------------------------------------------------------- @@ -473,28 +461,47 @@ void Mixer::notifyTrackSelected(MixerTrack* track) mixerDetails->setTrack(track->mti()); } + +//--------------------------------------------------------- +// writeSettings +//--------------------------------------------------------- + +void Mixer::writeSettings() + { + MuseScore::saveGeometry(this); + } + +//--------------------------------------------------------- +// readSettings +//--------------------------------------------------------- + +void Mixer::readSettings() + { + resize(QSize(480, 600)); //ensure default size if no geometry in settings + MuseScore::restoreGeometry(this); + } + + //--------------------------------------------------------- // showMixer //--------------------------------------------------------- -void MuseScore::showMixer(bool visible) +void MuseScore::showMixer(bool val) { + if (!cs) + return; - QAction* toggleMixerAction = getAction("toggle-mixer"); + QAction* a = getAction("toggle-mixer"); if (mixer == 0) { mixer = new Mixer(this); mscore->stackUnder(mixer); if (synthControl) connect(synthControl, SIGNAL(soundFontChanged()), mixer, SLOT(updateTrack())); connect(synti, SIGNAL(soundFontChanged()), mixer, SLOT(updateTracks())); - connect(mixer, SIGNAL(closed(bool)), toggleMixerAction, SLOT(setChecked(bool))); - mixer->setFloating(false); - addDockWidget(Qt::RightDockWidgetArea, mixer); - } - - reDisplayDockWidget(mixer, visible); - toggleMixerAction->setChecked(visible); + connect(mixer, SIGNAL(closed(bool)), a, SLOT(setChecked(bool))); + } mixer->setScore(cs); + mixer->setVisible(val); } } diff --git a/mscore/mixer.h b/mscore/mixer.h index 536b9460bc4fc..449ada7c60e8f 100644 --- a/mscore/mixer.h +++ b/mscore/mixer.h @@ -81,9 +81,9 @@ class Mixer : public QDockWidget, public Ui::Mixer, public MixerTrackGroup virtual void closeEvent(QCloseEvent*) override; virtual void showEvent(QShowEvent*) override; - virtual void hideEvent(QHideEvent*) override; virtual bool eventFilter(QObject*, QEvent*) override; virtual void keyPressEvent(QKeyEvent*) override; + void readSettings(); void keepScrollPosition(); void setPlaybackScore(Score*); @@ -109,6 +109,7 @@ class Mixer : public QDockWidget, public Ui::Mixer, public MixerTrackGroup Mixer(QWidget* parent); void setScore(Score*); PartEdit* getPartAtIndex(int index); + void writeSettings(); void expandToggled(Part* part, bool expanded) override; void notifyTrackSelected(MixerTrack* track) override; void showDetailsToggled(bool shown); diff --git a/mscore/mixer.ui b/mscore/mixer.ui index 40c0d87160de6..bf4febaedfd37 100644 --- a/mscore/mixer.ui +++ b/mscore/mixer.ui @@ -5,28 +5,25 @@ true + + false + + + QDockWidget::AllDockWidgetFeatures + 0 0 648 - 495 + 431 Qt::ClickFocus - - false - - - QDockWidget::AllDockWidgetFeatures - - - Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea - - Mixer + @@ -149,8 +146,8 @@ 0 0 - 528 - 368 + 554 + 371 diff --git a/mscore/musescore.cpp b/mscore/musescore.cpp index 544270799b897..4f8d9f5a4a70e 100644 --- a/mscore/musescore.cpp +++ b/mscore/musescore.cpp @@ -2812,24 +2812,6 @@ void MuseScore::showElementContext(Element* el) debugger->setElement(el); } - -//--------------------------------------------------------- -// reDisplayDockWidget -// -// Helper function to ensure when un-docked widgets are -// re-displayed, they are also re-dockable -//--------------------------------------------------------- - -void MuseScore::reDisplayDockWidget(QDockWidget* widget, bool visible) - { - widget->setVisible(visible); - if (widget->isFloating()) { - // Ensure the widget is re-dockable if it has been closed and re-opened when un-docked - widget->setFloating(false); - widget->setFloating(true); - } - } - //--------------------------------------------------------- // showPlayPanel //--------------------------------------------------------- @@ -2858,7 +2840,7 @@ void MuseScore::showPlayPanel(bool visible) playPanel->setFloating(false); } else - reDisplayDockWidget(playPanel, visible); + playPanel->setVisible(visible); playId->setChecked(visible); } @@ -4392,6 +4374,8 @@ void MuseScore::writeSettings() if (synthControl) synthControl->writeSettings(); settings.setValue("synthControlVisible", synthControl && synthControl->isVisible()); + if (mixer) + mixer->writeSettings(); settings.setValue("mixerVisible", mixer && mixer->isVisible()); if (seq) { seq->exit(); @@ -4439,12 +4423,7 @@ void MuseScore::readSettings() } MuseScore::restoreGeometry(this); - - // grab the visible state before the beginGroup - // this awkwardness to ensure state saved before code changes should - // still work OK. - bool mixerVisibleFlag = settings.value("mixerVisible", "0").toBool(); - + settings.beginGroup("MainWindow"); mainWindow->restoreState(settings.value("debuggerSplitter").toByteArray()); mainWindow->setOpaqueResize(false); @@ -4459,8 +4438,7 @@ void MuseScore::readSettings() mscore->showInspector(settings.value("showInspector", "1").toBool()); mscore->showPianoKeyboard(settings.value("showPianoKeyboard", "0").toBool()); mscore->showSelectionWindow(settings.value("showSelectionWindow", "0").toBool()); - mscore->showMixer(mixerVisibleFlag); - + restoreState(settings.value("state").toByteArray()); //if we were in full screen mode, go to maximized mode if (isFullScreen()) { @@ -5261,7 +5239,7 @@ void MuseScore::editRaster() // showPianoKeyboard //--------------------------------------------------------- -void MuseScore::showPianoKeyboard(bool visible) +void MuseScore::showPianoKeyboard(bool on) { if (_pianoTools == 0) { QAction* a = getAction("toggle-piano"); @@ -5271,8 +5249,8 @@ void MuseScore::showPianoKeyboard(bool visible) connect(_pianoTools, SIGNAL(keyReleased(int, bool, int)), SLOT(midiNoteReceived(int, bool, int))); connect(_pianoTools, SIGNAL(visibilityChanged(bool)), a, SLOT(setChecked(bool))); } - if (visible) { - reDisplayDockWidget(_pianoTools, visible); + if (on) { + _pianoTools->show(); if (currentScore()) _pianoTools->changeSelection(currentScore()->selection()); else @@ -6087,7 +6065,7 @@ void MuseScore::cmd(QAction* a, const QString& cmd) else if (cmd == "toggle-piano") showPianoKeyboard(a->isChecked()); else if (cmd == "toggle-scorecmp-tool") - reDisplayDockWidget(scoreCmpTool, a->isChecked()); + scoreCmpTool->setVisible(a->isChecked()); #ifdef MSCORE_UNSTABLE else if (cmd == "toggle-script-recorder") scriptRecorder->setVisible(a->isChecked()); @@ -7685,6 +7663,8 @@ int main(int argc, char* av[]) QSettings settings; if (settings.value("synthControlVisible", false).toBool()) mscore->showSynthControl(true); + if (settings.value("mixerVisible", false).toBool()) + mscore->showMixer(true); return qApp->exec(); } diff --git a/mscore/musescore.h b/mscore/musescore.h index d6cc8d99c0036..d4f8c171f1db7 100644 --- a/mscore/musescore.h +++ b/mscore/musescore.h @@ -820,7 +820,6 @@ class MuseScore : public QMainWindow, public MuseScoreCore { void unregisterPlugin(PluginDescription*); Q_INVOKABLE void showStartcenter(bool); - void reDisplayDockWidget(QDockWidget* widget, bool visible); void showPlayPanel(bool); QFileInfoList recentScores() const; diff --git a/mscore/selectionwindow.cpp b/mscore/selectionwindow.cpp index 91e6a4f9a68b9..480e1d152e5ce 100644 --- a/mscore/selectionwindow.cpp +++ b/mscore/selectionwindow.cpp @@ -178,7 +178,7 @@ void SelectionWindow::changeCheckbox(QListWidgetItem* item) // showSelectionWindow //--------------------------------------------------------- -void MuseScore::showSelectionWindow(bool visible) +void MuseScore::showSelectionWindow(bool val) { QAction* a = getAction("toggle-selection-window"); if (selectionWindow == 0) { @@ -189,8 +189,8 @@ void MuseScore::showSelectionWindow(bool visible) tabifyDockWidget(paletteBox, selectionWindow); } } - reDisplayDockWidget(selectionWindow, visible); - if (visible) { + selectionWindow->setVisible(val); + if (val) { selectionWindow->raise(); } } diff --git a/mscore/timeline.cpp b/mscore/timeline.cpp index 2325c59941fcf..82f429857c897 100644 --- a/mscore/timeline.cpp +++ b/mscore/timeline.cpp @@ -57,7 +57,7 @@ void MuseScore::showTimeline(bool visible) } connect(_timeline, SIGNAL(visibilityChanged(bool)), act, SLOT(setChecked(bool))); connect(_timeline, SIGNAL(closed(bool)), act, SLOT(setChecked(bool))); - reDisplayDockWidget(_timeline, visible); + _timeline->setVisible(visible); getAction("toggle-timeline")->setChecked(visible); if (visible)