Merge pull request #5086 from Obliquely/palette-docking-2nd-go

fix #287528, fix #283258 & fix #289773: panels not dockable after undock & close
This commit is contained in:
Dmitri Ovodok 2019-06-17 09:54:01 +02:00 committed by GitHub
commit 91ae302441
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 66 additions and 51 deletions

View file

@ -86,7 +86,7 @@ void MuseScore::showInspector(bool visible)
addDockWidget(Qt::RightDockWidgetArea, _inspector);
}
if (_inspector)
_inspector->setVisible(visible);
reDisplayDockWidget(_inspector, visible);
if (visible)
updateInspector();
}

View file

@ -1173,7 +1173,7 @@ void MuseScore::showPalette(bool visible)
updateIcons();
}
if (paletteBox) // read failed?
paletteBox->setVisible(visible);
reDisplayDockWidget(paletteBox, visible);
a->setChecked(visible);
}

View file

@ -76,10 +76,12 @@ Mixer::Mixer(QWidget* parent)
showDetails(true),
trackHolder(nullptr)
{
setupUi(this);
setWindowFlags(Qt::Tool);
setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint);
// note: because of setupUi side-effects (generating a showEvent) it's critical
// that enablePlay is created first.
enablePlay = new EnablePlayForWidget(this);
setupUi(this);
setAllowedAreas(Qt::DockWidgetAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea));
trackAreaLayout = new QHBoxLayout;
@ -88,7 +90,7 @@ Mixer::Mixer(QWidget* parent)
trackArea->setLayout(trackAreaLayout);
mixerDetails = new MixerDetails(this);
detailsLayout = new QGridLayout(this);
detailsLayout = new QGridLayout();
detailsLayout->addWidget(mixerDetails);
detailsLayout->setContentsMargins(0, 0, 0, 0);
@ -120,8 +122,6 @@ 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);
}
@ -200,7 +200,8 @@ void Mixer::masterVolumeChanged(double decibels)
void Mixer::on_partOnlyCheckBox_toggled(bool checked)
{
if (!_activeScore->excerpt())
if (!_activeScore || !_activeScore->excerpt())
return;
mscore->setPlayPartOnly(checked);
@ -249,8 +250,21 @@ void Mixer::showEvent(QShowEvent* e)
QWidget::showEvent(e);
activateWindow();
setFocus();
getAction("toggle-mixer")->setChecked(true);
}
//---------------------------------------------------------
// hideEvent
//---------------------------------------------------------
void Mixer::hideEvent(QHideEvent* e)
{
QWidget::hideEvent(e);
getAction("toggle-mixer")->setChecked(false);
}
//---------------------------------------------------------
// eventFilter
//---------------------------------------------------------
@ -462,46 +476,27 @@ void Mixer::notifyTrackSelected(MixerTrack* track)
}
//---------------------------------------------------------
// 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 val)
void MuseScore::showMixer(bool visible)
{
if (!cs)
return;
QAction* a = getAction("toggle-mixer");
QAction* toggleMixerAction = 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)), a, SLOT(setChecked(bool)));
connect(mixer, SIGNAL(closed(bool)), toggleMixerAction, SLOT(setChecked(bool)));
mixer->setFloating(false);
addDockWidget(Qt::RightDockWidgetArea, mixer);
}
reDisplayDockWidget(mixer, visible);
toggleMixerAction->setChecked(visible);
mixer->setScore(cs);
mixer->setVisible(val);
}
}

View file

@ -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,7 +109,6 @@ 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);

View file

@ -23,7 +23,7 @@
<enum>Qt::ClickFocus</enum>
</property>
<property name="windowTitle">
<string/>
<string>Mixer</string>
</property>
<widget class="QWidget" name="dockWidgetContents">
<layout class="QVBoxLayout" name="verticalLayout">

View file

@ -2813,6 +2813,23 @@ 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)
{
if (widget->isFloating() && !widget->isVisible()) {
// Ensure the widget is re-dockable if it has been closed and re-opened when un-docked. This is a workaround for a known QT bug. See QTBUG-69922.
widget->setFloating(false);
widget->setFloating(true);
}
widget->setVisible(visible);
}
//---------------------------------------------------------
// showPlayPanel
//---------------------------------------------------------
@ -2841,7 +2858,7 @@ void MuseScore::showPlayPanel(bool visible)
playPanel->setFloating(false);
}
else
playPanel->setVisible(visible);
reDisplayDockWidget(playPanel, visible);
playId->setChecked(visible);
}
@ -4375,8 +4392,6 @@ 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();
@ -4425,6 +4440,12 @@ void MuseScore::readSettings()
MuseScore::restoreGeometry(this);
// Grab the mixer visible state before the beginGroup.
// Previously the showMixer() call was made at the end of
// main(). Now it's made inside this beginGroup / endGroup.
// This code ensures user previous setting is respected when
// updating their version of MuseScore.
bool mixerVisible = settings.value("mixerVisible", "0").toBool();
settings.beginGroup("MainWindow");
mainWindow->restoreState(settings.value("debuggerSplitter").toByteArray());
mainWindow->setOpaqueResize(false);
@ -4439,6 +4460,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(mixerVisible);
restoreState(settings.value("state").toByteArray());
//if we were in full screen mode, go to maximized mode
@ -5240,7 +5262,7 @@ void MuseScore::editRaster()
// showPianoKeyboard
//---------------------------------------------------------
void MuseScore::showPianoKeyboard(bool on)
void MuseScore::showPianoKeyboard(bool visible)
{
if (_pianoTools == 0) {
QAction* a = getAction("toggle-piano");
@ -5250,8 +5272,8 @@ void MuseScore::showPianoKeyboard(bool on)
connect(_pianoTools, SIGNAL(keyReleased(int, bool, int)), SLOT(midiNoteReceived(int, bool, int)));
connect(_pianoTools, SIGNAL(visibilityChanged(bool)), a, SLOT(setChecked(bool)));
}
if (on) {
_pianoTools->show();
if (visible) {
reDisplayDockWidget(_pianoTools, visible);
if (currentScore())
_pianoTools->changeSelection(currentScore()->selection());
else
@ -6066,7 +6088,7 @@ void MuseScore::cmd(QAction* a, const QString& cmd)
else if (cmd == "toggle-piano")
showPianoKeyboard(a->isChecked());
else if (cmd == "toggle-scorecmp-tool")
scoreCmpTool->setVisible(a->isChecked());
reDisplayDockWidget(scoreCmpTool, a->isChecked());
#ifdef MSCORE_UNSTABLE
else if (cmd == "toggle-script-recorder")
scriptRecorder->setVisible(a->isChecked());
@ -7664,8 +7686,6 @@ 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();
}

View file

@ -820,6 +820,7 @@ 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;

View file

@ -178,7 +178,7 @@ void SelectionWindow::changeCheckbox(QListWidgetItem* item)
// showSelectionWindow
//---------------------------------------------------------
void MuseScore::showSelectionWindow(bool val)
void MuseScore::showSelectionWindow(bool visible)
{
QAction* a = getAction("toggle-selection-window");
if (selectionWindow == 0) {
@ -189,8 +189,8 @@ void MuseScore::showSelectionWindow(bool val)
tabifyDockWidget(paletteBox, selectionWindow);
}
}
selectionWindow->setVisible(val);
if (val) {
reDisplayDockWidget(selectionWindow, visible);
if (visible) {
selectionWindow->raise();
}
}

View file

@ -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)));
_timeline->setVisible(visible);
reDisplayDockWidget(_timeline, visible);
getAction("toggle-timeline")->setChecked(visible);
if (visible)