Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
BornAgain
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mlz
BornAgain
Commits
39c6bd55
Commit
39c6bd55
authored
2 years ago
by
Ludwig Jaeck
Browse files
Options
Downloads
Patches
Plain Diff
MainWindow: Sidebar Toolbuttons are now visible from the beginning
parent
743e96b3
No related branches found
No related tags found
1 merge request
!1332
Resolve "GUI: don't redraw everything upon leaving Welcome view."
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
GUI/View/Main/MainWindow.cpp
+50
-23
50 additions, 23 deletions
GUI/View/Main/MainWindow.cpp
GUI/View/Main/MainWindow.h
+3
-2
3 additions, 2 deletions
GUI/View/Main/MainWindow.h
with
53 additions
and
25 deletions
GUI/View/Main/MainWindow.cpp
+
50
−
23
View file @
39c6bd55
...
...
@@ -23,8 +23,8 @@
#include
"GUI/View/Project/ProjectManager.h"
#include
"GUI/View/SampleDesigner/SampleView.h"
#include
"GUI/View/Tool/mainwindow_constants.h"
#include
"GUI/View/Toplevel/SimulationView.h"
#include
"GUI/View/Toplevel/ProjectsView.h"
#include
"GUI/View/Toplevel/SimulationView.h"
#include
<QAction>
#include
<QApplication>
#include
<QBoxLayout>
...
...
@@ -82,6 +82,7 @@ MainWindow::MainWindow()
initApplication
();
readSettings
();
initProgressBar
();
initButtons
();
initViews
();
connect
(
m_projectManager
,
&
ProjectManager
::
documentOpenedOrClosed
,
this
,
...
...
@@ -207,13 +208,35 @@ void MainWindow::initProgressBar()
m_viewSelectionButtonsLayout
->
addWidget
(
m_progressBar
);
}
void
MainWindow
::
init
View
s
()
void
MainWindow
::
init
Button
s
()
{
if
(
m_projectsView
==
nullptr
)
{
m_projectsView
=
new
ProjectsView
(
this
);
addView
(
ViewId
::
PROJECTS
,
QIcon
(
":/images/main_welcomeview.svg"
),
"Projects"
,
"Switch to Projects View"
,
m_projectsView
);
addButton
(
ViewId
::
PROJECTS
,
QIcon
(
":/images/main_welcomeview.svg"
),
"Projects"
,
"Switch to Projects View"
);
addButton
(
ViewId
::
INSTRUMENT
,
QIcon
(
":/images/main_instrumentview.svg"
),
"Instrument"
,
"Define the beam and the detector"
);
addButton
(
ViewId
::
SAMPLE
,
QIcon
(
":/images/main_sampleview.svg"
),
"Sample"
,
"Build the sample"
);
addButton
(
ViewId
::
IMPORT
,
QIcon
(
":/images/main_importview.svg"
),
"Data"
,
"Import intensity data to fit"
);
addButton
(
ViewId
::
SIMULATION
,
QIcon
(
":/images/main_simulationview.svg"
),
"Simulation"
,
"Run simulation"
);
addButton
(
ViewId
::
JOB
,
QIcon
(
":/images/main_jobview.svg"
),
"Jobs"
,
"Switch to see job results, tune parameters real time,
\n
fit the data"
);
for
(
auto
*
button
:
m_viewSelectionButtons
->
buttons
())
{
if
(
button
==
m_viewSelectionButtons
->
button
(
ViewId
::
PROJECTS
))
continue
;
button
->
setEnabled
(
false
);
}
}
void
MainWindow
::
initViews
()
{
m_projectsView
=
new
ProjectsView
(
this
);
resetView
(
ViewId
::
PROJECTS
,
m_projectsView
);
if
(
gProjectDocument
.
has_value
())
{
auto
*
doc
=
gProjectDocument
.
value
();
...
...
@@ -223,20 +246,15 @@ void MainWindow::initViews()
m_simulationView
=
new
SimulationView
(
this
,
doc
);
m_jobView
=
new
JobView
(
this
,
doc
);
addView
(
ViewId
::
INSTRUMENT
,
QIcon
(
":/images/main_instrumentview.svg"
),
"Instrument"
,
"Define the beam and the detector"
,
m_instrumentView
);
resetView
(
ViewId
::
INSTRUMENT
,
m_instrumentView
);
addView
(
ViewId
::
SAMPLE
,
QIcon
(
":/images/main_sampleview.svg"
),
"Sample"
,
"Build the sample"
,
m_sampleView
);
resetView
(
ViewId
::
SAMPLE
,
m_sampleView
);
addView
(
ViewId
::
IMPORT
,
QIcon
(
":/images/main_importview.svg"
),
"Data"
,
"Import intensity data to fit"
,
m_importDataView
);
resetView
(
ViewId
::
IMPORT
,
m_importDataView
);
addView
(
ViewId
::
SIMULATION
,
QIcon
(
":/images/main_simulationview.svg"
),
"Simulation"
,
"Run simulation"
,
m_simulationView
);
resetView
(
ViewId
::
SIMULATION
,
m_simulationView
);
addView
(
ViewId
::
JOB
,
QIcon
(
":/images/main_jobview.svg"
),
"Jobs"
,
"Switch to see job results, tune parameters real time,
\n
fit the data"
,
m_jobView
);
resetView
(
ViewId
::
JOB
,
m_jobView
);
connect
(
m_jobView
,
&
JobView
::
focusRequest
,
this
,
&
MainWindow
::
onFocusRequest
);
...
...
@@ -244,6 +262,8 @@ void MainWindow::initViews()
if
(
gProjectDocument
.
has_value
())
setCurrentView
(
gProjectDocument
.
value
()
->
viewId
());
else
raiseView
(
ViewId
::
PROJECTS
);
}
}
...
...
@@ -270,8 +290,8 @@ void MainWindow::writeSettings()
settings
.
sync
();
}
void
MainWindow
::
add
View
(
ViewId
id
,
const
QIcon
&
icon
,
const
QString
&
title
,
const
QString
&
tooltip
,
QWidget
*
view
)
void
MainWindow
::
add
Button
(
ViewId
id
,
const
QIcon
&
icon
,
const
QString
&
title
,
const
QString
&
tooltip
)
{
QToolButton
*
btn
=
createViewSelectionButton
();
m_viewSelectionButtonsLayout
->
insertWidget
(
id
,
btn
);
...
...
@@ -282,7 +302,10 @@ void MainWindow::addView(ViewId id, const QIcon& icon, const QString& title, con
m_viewSelectionButtons
->
addButton
(
btn
,
id
);
updateViewSelectionButtonsGeometry
();
}
void
MainWindow
::
resetView
(
ViewId
id
,
QWidget
*
view
)
{
m_viewsStack
->
insertWidget
(
id
,
view
);
}
...
...
@@ -329,9 +352,16 @@ void MainWindow::onDocumentOpenedOrClosed(bool open)
initViews
();
updateTitle
();
if
(
open
)
{
if
(
gProjectDocument
.
has_value
())
if
(
gProjectDocument
.
has_value
())
{
for
(
auto
*
button
:
m_viewSelectionButtons
->
buttons
())
button
->
setEnabled
(
true
);
auto
*
filler
=
m_viewSelectionButtonsLayout
->
itemAt
(
m_viewSelectionButtons
->
buttons
().
size
());
if
(
filler
)
if
(
auto
*
fillerBtn
=
dynamic_cast
<
QToolButton
*>
(
filler
->
widget
());
fillerBtn
)
fillerBtn
->
setEnabled
(
true
);
setCurrentView
(
gProjectDocument
.
value
()
->
viewId
());
else
}
else
setCurrentView
(
MainWindow
::
INSTRUMENT
);
}
}
...
...
@@ -345,9 +375,6 @@ void MainWindow::onAboutToCloseDocument()
{
setCurrentView
(
PROJECTS
);
while
(
m_viewSelectionButtons
->
buttons
().
size
()
>
1
)
delete
m_viewSelectionButtons
->
buttons
().
last
();
updateViewSelectionButtonsGeometry
();
delete
m_instrumentView
;
...
...
This diff is collapsed.
Click to expand it.
GUI/View/Main/MainWindow.h
+
3
−
2
View file @
39c6bd55
...
...
@@ -66,12 +66,13 @@ protected:
private
:
void
initApplication
();
void
initProgressBar
();
void
initButtons
();
void
initViews
();
void
readSettings
();
void
writeSettings
();
void
add
View
(
ViewId
id
,
const
QIcon
&
icon
,
const
QString
&
title
,
const
QString
&
tooltip
,
QWidget
*
view
);
void
add
Button
(
ViewId
id
,
const
QIcon
&
icon
,
const
QString
&
title
,
const
QString
&
tooltip
);
void
resetView
(
ViewId
id
,
QWidget
*
view
);
QToolButton
*
createViewSelectionButton
()
const
;
//! Recalculate the size of the view selection buttons to show complete button text
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment