mirror of https://github.com/vitalif/openscad
Fix status handling for docked windows.
Especially for the case where the windows are docked as tabs in the same position, the "visibility-changed" signal does not work as close indicator. The window is also treated as invisible when just the tab is invisible, not only in case the window is closed.master
parent
b66fb597fa
commit
ebb7dde012
|
@ -307,6 +307,7 @@ src/FontCache.h \
|
|||
src/system-gl.h \
|
||||
src/CsgInfo.h \
|
||||
\
|
||||
src/Dock.h \
|
||||
src/AutoUpdater.h \
|
||||
src/launchingscreen.h \
|
||||
src/legacyeditor.h \
|
||||
|
@ -397,6 +398,7 @@ SOURCES += src/version_check.cc \
|
|||
src/openscad.cc \
|
||||
src/mainwin.cc \
|
||||
src/UIUtils.cc \
|
||||
src/Dock.cc \
|
||||
src/FontListDialog.cc \
|
||||
src/launchingscreen.cc \
|
||||
src/legacyeditor.cc \
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
#include <iostream>
|
||||
#include <QSettings>
|
||||
|
||||
#include "Dock.h"
|
||||
|
||||
Dock::Dock(QWidget *parent) : QDockWidget(parent), action(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
Dock::~Dock()
|
||||
{
|
||||
}
|
||||
|
||||
void Dock::setVisible(bool visible)
|
||||
{
|
||||
QSettings settings;
|
||||
settings.setValue(configKey, !visible);
|
||||
if (action != NULL) {
|
||||
action->setChecked(!visible);
|
||||
}
|
||||
QDockWidget::setVisible(visible);
|
||||
}
|
||||
|
||||
void Dock::setConfigKey(const QString configKey)
|
||||
{
|
||||
this->configKey = configKey;
|
||||
}
|
||||
|
||||
void Dock::setAction(QAction *action)
|
||||
{
|
||||
this->action = action;
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
#include <QAction>
|
||||
#include <QDockWidget>
|
||||
|
||||
class Dock : public QDockWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Dock(QWidget *parent = NULL);
|
||||
virtual ~Dock();
|
||||
void setConfigKey(const QString configKey);
|
||||
void setAction(QAction *action);
|
||||
|
||||
public slots:
|
||||
void setVisible(bool visible);
|
||||
|
||||
private:
|
||||
QString configKey;
|
||||
QAction *action;
|
||||
};
|
|
@ -239,7 +239,6 @@ private:
|
|||
|
||||
char const * afterCompileSlot;
|
||||
bool procevents;
|
||||
bool isClosing;
|
||||
class QTemporaryFile *tempFile;
|
||||
class ProgressWidget *progresswidget;
|
||||
class CGALWorker *cgalworker;
|
||||
|
|
|
@ -142,6 +142,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1397</width>
|
||||
<height>33</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menu_File">
|
||||
|
@ -287,7 +289,7 @@
|
|||
<addaction name="menuHelp"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
<widget class="QDockWidget" name="editorDock">
|
||||
<widget class="Dock" name="editorDock">
|
||||
<attribute name="dockWidgetArea">
|
||||
<number>1</number>
|
||||
</attribute>
|
||||
|
@ -410,7 +412,7 @@
|
|||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QDockWidget" name="consoleDock">
|
||||
<widget class="Dock" name="consoleDock">
|
||||
<attribute name="dockWidgetArea">
|
||||
<number>8</number>
|
||||
</attribute>
|
||||
|
@ -1092,6 +1094,12 @@
|
|||
<header>QGLView.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Dock</class>
|
||||
<extends>QDockWidget</extends>
|
||||
<header>Dock.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../openscad.qrc"/>
|
||||
|
|
|
@ -225,7 +225,6 @@ MainWindow::MainWindow(const QString &filename)
|
|||
tval = 0;
|
||||
fps = 0;
|
||||
fsteps = 1;
|
||||
isClosing = false;
|
||||
|
||||
const QString importStatement = "import(\"%1\");\n";
|
||||
const QString surfaceStatement = "surface(\"%1\");\n";
|
||||
|
@ -532,6 +531,10 @@ MainWindow::MainWindow(const QString &filename)
|
|||
editor->setInitialSizeHint(QSize((5 * this->width() / 11), 100));
|
||||
}
|
||||
|
||||
this->editorDock->setConfigKey("view/hideEditor");
|
||||
this->editorDock->setAction(this->viewActionHideEditor);
|
||||
this->consoleDock->setConfigKey("view/hideConsole");
|
||||
this->consoleDock->setAction(this->viewActionHideConsole);
|
||||
connect(this->editorDock, SIGNAL(topLevelChanged(bool)), this, SLOT(editorTopLevelChanged(bool)));
|
||||
connect(this->consoleDock, SIGNAL(topLevelChanged(bool)), this, SLOT(consoleTopLevelChanged(bool)));
|
||||
|
||||
|
@ -2265,25 +2268,13 @@ void MainWindow::viewAll()
|
|||
this->qglview->updateGL();
|
||||
}
|
||||
|
||||
void MainWindow::on_editorDock_visibilityChanged(bool visible)
|
||||
void MainWindow::on_editorDock_visibilityChanged(bool)
|
||||
{
|
||||
if (isClosing) {
|
||||
return;
|
||||
}
|
||||
QSettings settings;
|
||||
settings.setValue("view/hideEditor", !visible);
|
||||
viewActionHideEditor->setChecked(!visible);
|
||||
editorTopLevelChanged(editorDock->isFloating());
|
||||
}
|
||||
|
||||
void MainWindow::on_consoleDock_visibilityChanged(bool visible)
|
||||
void MainWindow::on_consoleDock_visibilityChanged(bool)
|
||||
{
|
||||
if (isClosing) {
|
||||
return;
|
||||
}
|
||||
QSettings settings;
|
||||
settings.setValue("view/hideConsole", !visible);
|
||||
viewActionHideConsole->setChecked(!visible);
|
||||
consoleTopLevelChanged(consoleDock->isFloating());
|
||||
}
|
||||
|
||||
|
@ -2453,7 +2444,6 @@ void MainWindow::closeEvent(QCloseEvent *event)
|
|||
delete this->tempFile;
|
||||
this->tempFile = NULL;
|
||||
}
|
||||
isClosing = true;
|
||||
event->accept();
|
||||
} else {
|
||||
event->ignore();
|
||||
|
|
Loading…
Reference in New Issue