Remember docks settings.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2016-04-06 14:40:44 +03:00
parent 9c63c4f794
commit fe3bd88c17
5 changed files with 69 additions and 12 deletions

View File

@ -112,7 +112,10 @@ MainWindow::MainWindow(QWidget *parent)
dialogTable(nullptr), dialogTable(nullptr),
dialogTool(nullptr), dialogTool(nullptr),
dialogHistory(nullptr), comboBoxDraws(nullptr), patternPieceLabel(nullptr), mode(Draw::Calculation), dialogHistory(nullptr), comboBoxDraws(nullptr), patternPieceLabel(nullptr), mode(Draw::Calculation),
currentDrawIndex(0), currentToolBoxIndex(0), drawMode(true), recentFileActs(), currentDrawIndex(0), currentToolBoxIndex(0),
isDockToolOptionsVisible(true),
isDockGroupsVisible(true),
drawMode(true), recentFileActs(),
separatorAct(nullptr), separatorAct(nullptr),
leftGoToStage(nullptr), rightGoToStage(nullptr), autoSaveTimer(nullptr), guiEnabled(true), leftGoToStage(nullptr), rightGoToStage(nullptr), autoSaveTimer(nullptr), guiEnabled(true),
gradationHeights(nullptr), gradationSizes(nullptr), gradationHeightsLabel(nullptr), gradationSizesLabel(nullptr), gradationHeights(nullptr), gradationSizes(nullptr), gradationHeightsLabel(nullptr), gradationSizesLabel(nullptr),
@ -2061,7 +2064,8 @@ void MainWindow::ActionDraw(bool checked)
} }
ui->dockWidgetLayoutPages->setVisible(false); ui->dockWidgetLayoutPages->setVisible(false);
ui->dockWidgetToolOptions->setVisible(true); ui->dockWidgetToolOptions->setVisible(isDockToolOptionsVisible);
ui->dockWidgetGroups->setVisible(isDockGroupsVisible);
} }
else else
{ {
@ -2130,7 +2134,8 @@ void MainWindow::ActionDetails(bool checked)
} }
ui->dockWidgetLayoutPages->setVisible(false); ui->dockWidgetLayoutPages->setVisible(false);
ui->dockWidgetToolOptions->setVisible(true); ui->dockWidgetToolOptions->setVisible(isDockToolOptionsVisible);
ui->dockWidgetGroups->setVisible(isDockGroupsVisible);
helpLabel->setText(""); helpLabel->setText("");
} }
@ -2207,7 +2212,14 @@ void MainWindow::ActionLayout(bool checked)
} }
ui->dockWidgetLayoutPages->setVisible(true); ui->dockWidgetLayoutPages->setVisible(true);
ui->dockWidgetToolOptions->blockSignals(true);
ui->dockWidgetToolOptions->setVisible(false); ui->dockWidgetToolOptions->setVisible(false);
ui->dockWidgetToolOptions->blockSignals(false);
ui->dockWidgetGroups->blockSignals(true);
ui->dockWidgetGroups->setVisible(false);
ui->dockWidgetGroups->blockSignals(false);
ShowPaper(ui->listWidget->currentRow()); ShowPaper(ui->listWidget->currentRow());
@ -2704,6 +2716,7 @@ void MainWindow::SetEnableWidgets(bool enable)
ui->actionUnloadMeasurements->setEnabled(enable && designStage); ui->actionUnloadMeasurements->setEnabled(enable && designStage);
actionDockWidgetToolOptions->setEnabled(enable && designStage); actionDockWidgetToolOptions->setEnabled(enable && designStage);
actionDockWidgetGroups->setEnabled(enable && designStage);
undoAction->setEnabled(enable && designStage && qApp->getUndoStack()->canUndo()); undoAction->setEnabled(enable && designStage && qApp->getUndoStack()->canUndo());
redoAction->setEnabled(enable && designStage && qApp->getUndoStack()->canRedo()); redoAction->setEnabled(enable && designStage && qApp->getUndoStack()->canRedo());
@ -2911,6 +2924,18 @@ void MainWindow::ChangedHeight(const QString &text)
} }
} }
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::DockToolOptionsVisibilityChanged(bool visible)
{
isDockToolOptionsVisible = visible;
}
//---------------------------------------------------------------------------------------------------------------------
void MainWindow::DockGropsVisibilityChanged(bool visible)
{
isDockGroupsVisible = visible;
}
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void MainWindow::SetDefaultHeight() void MainWindow::SetDefaultHeight()
{ {
@ -3229,6 +3254,9 @@ void MainWindow::ReadSettings()
// Text under tool buton icon // Text under tool buton icon
ToolBarStyles(); ToolBarStyles();
isDockToolOptionsVisible = ui->dockWidgetToolOptions->isVisible();
isDockGroupsVisible = ui->dockWidgetGroups->isVisible();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -3335,13 +3363,6 @@ void MainWindow::CreateMenus()
separatorAct->setSeparator(true); separatorAct->setSeparator(true);
ui->menuPatternPiece->insertAction(ui->actionPattern_properties, separatorAct); ui->menuPatternPiece->insertAction(ui->actionPattern_properties, separatorAct);
//Add dock
actionDockWidgetToolOptions = ui->dockWidgetToolOptions->toggleViewAction();
ui->menuPatternPiece->insertAction(ui->actionPattern_properties, actionDockWidgetToolOptions);
separatorAct = new QAction(this);
separatorAct->setSeparator(true);
ui->menuPatternPiece->insertAction(ui->actionPattern_properties, separatorAct);
AddDocks(); AddDocks();
} }
@ -3514,7 +3535,15 @@ void MainWindow::LastUsedTool()
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void MainWindow::AddDocks() void MainWindow::AddDocks()
{ {
ui->menuPatternPiece->insertAction(ui->actionPattern_properties, ui->dockWidgetToolOptions->toggleViewAction()); //Add dock
actionDockWidgetToolOptions = ui->dockWidgetToolOptions->toggleViewAction();
ui->menuPatternPiece->insertAction(ui->actionPattern_properties, actionDockWidgetToolOptions);
connect(ui->dockWidgetToolOptions, &QDockWidget::visibilityChanged, this,
&MainWindow::DockToolOptionsVisibilityChanged);
actionDockWidgetGroups = ui->dockWidgetGroups->toggleViewAction();
ui->menuPatternPiece->insertAction(ui->actionPattern_properties, actionDockWidgetGroups);
connect(ui->dockWidgetGroups, &QDockWidget::visibilityChanged, this, &MainWindow::DockGropsVisibilityChanged);
separatorAct = new QAction(this); separatorAct = new QAction(this);
separatorAct->setSeparator(true); separatorAct->setSeparator(true);

View File

@ -204,6 +204,9 @@ private slots:
void ChangedSize(const QString &text); void ChangedSize(const QString &text);
void ChangedHeight(const QString & text); void ChangedHeight(const QString & text);
void DockToolOptionsVisibilityChanged(bool visible);
void DockGropsVisibilityChanged(bool visible);
private: private:
Q_DISABLE_COPY(MainWindow) Q_DISABLE_COPY(MainWindow)
/** @brief ui keeps information about user interface */ /** @brief ui keeps information about user interface */
@ -255,6 +258,9 @@ private:
/** @brief currentToolBoxIndex save current set of tools. */ /** @brief currentToolBoxIndex save current set of tools. */
qint32 currentToolBoxIndex; qint32 currentToolBoxIndex;
bool isDockToolOptionsVisible;
bool isDockGroupsVisible;
/** @brief drawMode true if we current draw scene. */ /** @brief drawMode true if we current draw scene. */
bool drawMode; bool drawMode;

View File

@ -938,6 +938,14 @@
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="page_7"> <widget class="QWidget" name="page_7">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>130</width>
<height>356</height>
</rect>
</property>
<attribute name="icon"> <attribute name="icon">
<iconset resource="../../libs/vmisc/share/resources/icon.qrc"> <iconset resource="../../libs/vmisc/share/resources/icon.qrc">
<normaloff>:/icon/16x16/operations.png</normaloff>:/icon/16x16/operations.png</iconset> <normaloff>:/icon/16x16/operations.png</normaloff>:/icon/16x16/operations.png</iconset>
@ -1455,6 +1463,18 @@
</layout> </layout>
</widget> </widget>
</widget> </widget>
<widget class="QDockWidget" name="dockWidgetGroups">
<property name="enabled">
<bool>true</bool>
</property>
<property name="windowTitle">
<string>Groups</string>
</property>
<attribute name="dockWidgetArea">
<number>2</number>
</attribute>
<widget class="QWidget" name="dockWidgetContents_2"/>
</widget>
<action name="actionNew"> <action name="actionNew">
<property name="icon"> <property name="icon">
<iconset theme="document-new"> <iconset theme="document-new">

View File

@ -60,7 +60,8 @@ MainWindowsNoGUI::MainWindowsNoGUI(QWidget *parent)
: QMainWindow(parent), listDetails(QVector<VLayoutDetail>()), currentScene(nullptr), tempSceneLayout(nullptr), : QMainWindow(parent), listDetails(QVector<VLayoutDetail>()), currentScene(nullptr), tempSceneLayout(nullptr),
pattern(new VContainer(qApp->TrVars(), qApp->patternUnitP())), doc(nullptr), papers(QList<QGraphicsItem *>()), pattern(new VContainer(qApp->TrVars(), qApp->patternUnitP())), doc(nullptr), papers(QList<QGraphicsItem *>()),
shadows(QList<QGraphicsItem *>()), scenes(QList<QGraphicsScene *>()), details(QList<QList<QGraphicsItem *> >()), shadows(QList<QGraphicsItem *>()), scenes(QList<QGraphicsScene *>()), details(QList<QList<QGraphicsItem *> >()),
undoAction(nullptr), redoAction(nullptr), actionDockWidgetToolOptions(nullptr), curFile(QString()), undoAction(nullptr), redoAction(nullptr), actionDockWidgetToolOptions(nullptr), actionDockWidgetGroups(nullptr),
curFile(QString()),
isLayoutStale(true), margins(), paperSize(), isTiled(false) isLayoutStale(true), margins(), paperSize(), isTiled(false)
{ {
InitTempLayoutScene(); InitTempLayoutScene();

View File

@ -83,6 +83,7 @@ protected:
QAction *undoAction; QAction *undoAction;
QAction *redoAction; QAction *redoAction;
QAction *actionDockWidgetToolOptions; QAction *actionDockWidgetToolOptions;
QAction *actionDockWidgetGroups;
/** @brief fileName name current pattern file. */ /** @brief fileName name current pattern file. */
QString curFile; QString curFile;