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
0e6b6c39
Commit
0e6b6c39
authored
1 year ago
by
Wuttke, Joachim
Browse files
Options
Downloads
Patches
Plain Diff
rm remaining action to toolbar
parent
d7100fa6
No related branches found
No related tags found
1 merge request
!2387
unify code for list views
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
GUI/View/List/SamplesQListView.cpp
+0
-20
0 additions, 20 deletions
GUI/View/List/SamplesQListView.cpp
GUI/View/List/SamplesQListView.h
+0
-5
0 additions, 5 deletions
GUI/View/List/SamplesQListView.h
GUI/View/Views/SampleView.cpp
+21
-4
21 additions, 4 deletions
GUI/View/Views/SampleView.cpp
with
21 additions
and
29 deletions
GUI/View/List/SamplesQListView.cpp
+
0
−
20
View file @
0e6b6c39
...
...
@@ -14,7 +14,6 @@
#include
"GUI/View/List/SamplesQListView.h"
#include
"Base/Util/SysUtil.h"
#include
"GUI/Model/FromCore/GUIExamplesFactory.h"
#include
"GUI/Model/Project/ProjectDocument.h"
#include
"GUI/Model/Sample/SampleItem.h"
#include
"GUI/Model/Sample/SamplesSet.h"
...
...
@@ -27,7 +26,6 @@
SamplesQListView
::
SamplesQListView
()
:
m_model
(
new
SamplesQModel
(
this
))
,
m_choose_from_library_action
(
new
QAction
(
this
))
{
setMaximumWidth
(
200
);
setVerticalScrollMode
(
QAbstractItemView
::
ScrollPerPixel
);
...
...
@@ -44,24 +42,6 @@ SamplesQListView::SamplesQListView()
connect
(
this
,
&
QWidget
::
customContextMenuRequested
,
this
,
&
SamplesQListView
::
showContextMenu
);
m_choose_from_library_action
->
setText
(
"Choose from sample examples"
);
m_choose_from_library_action
->
setIcon
(
QIcon
(
":/images/library.svg"
));
m_choose_from_library_action
->
setIconText
(
"Examples"
);
m_choose_from_library_action
->
setToolTip
(
"Choose from sample examples"
);
auto
*
menu
=
new
QMenu
(
this
);
m_choose_from_library_action
->
setMenu
(
menu
);
for
(
const
auto
&
exampleName
:
GUI
::
ExamplesFactory
::
exampleNames
())
{
QString
title
,
description
;
std
::
tie
(
title
,
description
)
=
GUI
::
ExamplesFactory
::
exampleInfo
(
exampleName
);
auto
icon
=
QIcon
(
":/images/sample_layers2.png"
);
auto
*
action
=
menu
->
addAction
(
icon
,
title
);
action
->
setToolTip
(
description
);
connect
(
action
,
&
QAction
::
triggered
,
[
this
,
exampleName
,
title
,
description
]
{
createSampleFromLibrary
(
exampleName
,
title
,
description
);
});
}
}
void
SamplesQListView
::
createNewSample
()
...
...
This diff is collapsed.
Click to expand it.
GUI/View/List/SamplesQListView.h
+
0
−
5
View file @
0e6b6c39
...
...
@@ -26,8 +26,6 @@ class SamplesQListView : public QListView {
public:
SamplesQListView
();
QAction
*
chooseFromLibraryAction
()
{
return
m_choose_from_library_action
;
}
void
createNewSample
();
void
createSampleFromLibrary
(
const
QString
&
classname
,
const
QString
&
title
,
const
QString
&
description
);
...
...
@@ -35,7 +33,6 @@ public:
void
onCurrentChanged
(
const
QModelIndex
&
index
);
void
removeSample
(
SampleItem
*
item
);
void
copySample
(
SampleItem
*
item
);
signals:
void
currentSampleChanged
(
SampleItem
*
current
);
...
...
@@ -46,8 +43,6 @@ private:
void
showContextMenu
(
const
QPoint
&
pos
);
SamplesQModel
*
m_model
;
QAction
*
m_import_sample_action
;
QAction
*
m_choose_from_library_action
;
};
#endif // BORNAGAIN_GUI_VIEW_LIST_SAMPLESQLISTVIEW_H
This diff is collapsed.
Click to expand it.
GUI/View/Views/SampleView.cpp
+
21
−
4
View file @
0e6b6c39
...
...
@@ -14,6 +14,7 @@
#include
"GUI/View/Views/SampleView.h"
#include
"Base/Util/Vec.h"
#include
"GUI/Model/FromCore/GUIExamplesFactory.h"
#include
"GUI/Model/Project/ProjectDocument.h"
#include
"GUI/Model/Sample/ItemWithParticles.h"
#include
"GUI/Model/Sample/LayerItem.h"
...
...
@@ -31,6 +32,7 @@
#include
<QBoxLayout>
#include
<QCheckBox>
#include
<QDockWidget>
#include
<QMenu>
#include
<QMessageBox>
#include
<QSettings>
#include
<QSplitter>
...
...
@@ -111,12 +113,27 @@ SampleView::SampleView()
&
SamplesQListView
::
importSampleFromPython
);
#endif
//... Finish
toolbar
->
addAction
(
m_listing
->
chooseFromLibraryAction
());
auto
*
choose_from_library_action
=
new
QAction
(
"Examples"
,
this
);
toolbar
->
addAction
(
choose_from_library_action
);
if
(
auto
*
btn
=
dynamic_cast
<
QToolButton
*>
(
toolbar
->
widgetForAction
(
m_listing
->
choose
F
rom
L
ibrary
A
ction
()
)))
toolbar
->
widgetForAction
(
choose
_f
rom
_l
ibrary
_a
ction
)))
btn
->
setPopupMode
(
QToolButton
::
InstantPopup
);
choose_from_library_action
->
setIcon
(
QIcon
(
":/images/library.svg"
));
choose_from_library_action
->
setToolTip
(
"Choose from sample examples"
);
auto
*
import_menu
=
new
QMenu
(
this
);
choose_from_library_action
->
setMenu
(
import_menu
);
for
(
const
auto
&
exampleName
:
GUI
::
ExamplesFactory
::
exampleNames
())
{
QString
title
,
description
;
std
::
tie
(
title
,
description
)
=
GUI
::
ExamplesFactory
::
exampleInfo
(
exampleName
);
auto
icon
=
QIcon
(
":/images/sample_layers2.png"
);
auto
*
action
=
import_menu
->
addAction
(
icon
,
title
);
action
->
setToolTip
(
description
);
connect
(
action
,
&
QAction
::
triggered
,
[
this
,
exampleName
,
title
,
description
]
{
m_listing
->
createSampleFromLibrary
(
exampleName
,
title
,
description
);
});
}
//... Finish
connect
(
m_listing
,
&
SamplesQListView
::
currentSampleChanged
,
editor
,
&
SampleEditor
::
setCurrentSample
);
...
...
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