Skip to content

Commit

Permalink
Merge pull request #5011 from Obliquely/palette-docking-issue
Browse files Browse the repository at this point in the history
Fix #287528 - Side panels not dockable after undock and close
  • Loading branch information
anatoly-os committed May 22, 2019
2 parents 797cfa6 + c9025ac commit 19f51cf
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 66 deletions.
2 changes: 1 addition & 1 deletion mscore/inspector/inspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ void MuseScore::showInspector(bool visible)
addDockWidget(Qt::RightDockWidgetArea, _inspector);
}
if (_inspector)
_inspector->setVisible(visible);
reDisplayDockWidget(_inspector, visible);
if (visible)
updateInspector();
}
Expand Down
2 changes: 1 addition & 1 deletion mscore/menus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1173,7 +1173,7 @@ void MuseScore::showPalette(bool visible)
updateIcons();
}
if (paletteBox) // read failed?
paletteBox->setVisible(visible);
reDisplayDockWidget(paletteBox, visible);
a->setChecked(visible);
}

Expand Down
67 changes: 30 additions & 37 deletions mscore/mixer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,19 +76,20 @@ Mixer::Mixer(QWidget* parent)
showDetails(true),
trackHolder(nullptr)
{
setupUi(this);

// note: because of setupUi side-effects (generating a showEvent) it's critical
// that enablePlay is created first.
enablePlay = new EnablePlayForWidget(this);

setWindowFlags(Qt::Tool);
setWindowFlags(this->windowFlags() & ~Qt::WindowContextHelpButtonHint);
setAllowedAreas(Qt::DockWidgetAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea));
setupUi(this); //

trackAreaLayout = new QHBoxLayout;
trackAreaLayout->setMargin(0);
trackAreaLayout->setSpacing(0);
trackArea->setLayout(trackAreaLayout);

mixerDetails = new MixerDetails(this);
detailsLayout = new QGridLayout(this);
detailsLayout = new QGridLayout();

detailsLayout->addWidget(mixerDetails);
detailsLayout->setContentsMargins(0, 0, 0, 0);
Expand Down Expand Up @@ -120,8 +121,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);
}

Expand Down Expand Up @@ -200,6 +199,10 @@ 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;

Expand Down Expand Up @@ -247,8 +250,17 @@ void Mixer::showEvent(QShowEvent* e)
{
enablePlay->showEvent(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);
}

//---------------------------------------------------------
Expand Down Expand Up @@ -461,47 +473,28 @@ 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 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);
}

}
3 changes: 1 addition & 2 deletions mscore/mixer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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*);

Expand All @@ -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);
Expand Down
23 changes: 13 additions & 10 deletions mscore/mixer.ui
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,28 @@
<property name="enabled">
<bool>true</bool>
</property>
<property name="floating">
<bool>false</bool>
</property>
<property name="features">
<set>QDockWidget::AllDockWidgetFeatures</set>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>648</width>
<height>431</height>
<height>495</height>
</rect>
</property>
<property name="focusPolicy">
<enum>Qt::ClickFocus</enum>
</property>
<property name="floating">
<bool>false</bool>
</property>
<property name="features">
<set>QDockWidget::AllDockWidgetFeatures</set>
</property>
<property name="allowedAreas">
<set>Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea</set>
</property>
<property name="windowTitle">
<string/>
<string>Mixer</string>
</property>
<widget class="QWidget" name="dockWidgetContents">
<layout class="QVBoxLayout" name="verticalLayout">
Expand Down Expand Up @@ -146,8 +149,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>554</width>
<height>371</height>
<width>528</width>
<height>368</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
Expand Down
42 changes: 31 additions & 11 deletions mscore/musescore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2812,6 +2812,24 @@ 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
//---------------------------------------------------------
Expand Down Expand Up @@ -2840,7 +2858,7 @@ void MuseScore::showPlayPanel(bool visible)
playPanel->setFloating(false);
}
else
playPanel->setVisible(visible);
reDisplayDockWidget(playPanel, visible);
playId->setChecked(visible);
}

Expand Down Expand Up @@ -4374,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();
Expand Down Expand Up @@ -4423,7 +4439,12 @@ 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);
Expand All @@ -4438,7 +4459,8 @@ 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()) {
Expand Down Expand Up @@ -5239,7 +5261,7 @@ void MuseScore::editRaster()
// showPianoKeyboard
//---------------------------------------------------------

void MuseScore::showPianoKeyboard(bool on)
void MuseScore::showPianoKeyboard(bool visible)
{
if (_pianoTools == 0) {
QAction* a = getAction("toggle-piano");
Expand All @@ -5249,8 +5271,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
Expand Down Expand Up @@ -6065,7 +6087,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());
Expand Down Expand Up @@ -7663,8 +7685,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();
}
Expand Down
1 change: 1 addition & 0 deletions mscore/musescore.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions mscore/selectionwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -189,8 +189,8 @@ void MuseScore::showSelectionWindow(bool val)
tabifyDockWidget(paletteBox, selectionWindow);
}
}
selectionWindow->setVisible(val);
if (val) {
reDisplayDockWidget(selectionWindow, visible);
if (visible) {
selectionWindow->raise();
}
}
Expand Down
2 changes: 1 addition & 1 deletion mscore/timeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 19f51cf

Please sign in to comment.