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
3e3f2825
Commit
3e3f2825
authored
8 years ago
by
Pospelov, Gennady
Browse files
Options
Downloads
Patches
Plain Diff
New controller for WarningSign to unify the usage across the project.
parent
22683d03
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
GUI/coregui/Views/InfoWidgets/WarningSign.cpp
+111
-0
111 additions, 0 deletions
GUI/coregui/Views/InfoWidgets/WarningSign.cpp
GUI/coregui/Views/InfoWidgets/WarningSign.h
+54
-0
54 additions, 0 deletions
GUI/coregui/Views/InfoWidgets/WarningSign.h
with
165 additions
and
0 deletions
GUI/coregui/Views/InfoWidgets/WarningSign.cpp
0 → 100644
+
111
−
0
View file @
3e3f2825
// ************************************************************************** //
//
// BornAgain: simulate and fit scattering at grazing incidence
//
//! @file GUI/coregui/Views/InfoWidgets/WarningSign.cpp
//! @brief Implements class WarningSign
//!
//! @homepage http://www.bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2016
//! @authors Scientific Computing Group at MLZ Garching
//! @authors Céline Durniak, Marina Ganeva, David Li, Gennady Pospelov
//! @authors Walter Van Herck, Joachim Wuttke
//
// ************************************************************************** //
#include
"WarningSign.h"
#include
"WarningSignWidget.h"
#include
<QAbstractScrollArea>
#include
<QEvent>
#include
<QScrollBar>
namespace
{
const
int
xpos_offset
=
38
;
const
int
ypos_offset
=
38
;
}
WarningSign
::
WarningSign
(
QWidget
*
parent
)
:
QObject
(
parent
)
,
m_warning_header
(
QStringLiteral
(
"Houston, we have a problem."
))
,
m_warningWidget
(
0
)
,
m_area
(
nullptr
)
{
setArea
(
parent
);
}
//! Clears warning message;
void
WarningSign
::
clear
()
{
delete
m_warningWidget
;
m_warningWidget
=
0
;
m_warning_message
.
clear
();
}
void
WarningSign
::
setWarningHeader
(
const
QString
&
warningHeader
)
{
m_warning_header
=
warningHeader
;
}
void
WarningSign
::
setWarningMessage
(
const
QString
&
warningMessage
)
{
Q_ASSERT
(
m_area
);
m_warning_message
=
warningMessage
;
if
(
!
m_warningWidget
)
m_warningWidget
=
new
WarningSignWidget
(
m_area
);
m_warningWidget
->
setWarningMessage
(
m_warning_message
);
updateLabelGeometry
();
m_warningWidget
->
show
();
}
void
WarningSign
::
setArea
(
QWidget
*
area
)
{
m_area
=
area
;
m_area
->
installEventFilter
(
this
);
}
bool
WarningSign
::
eventFilter
(
QObject
*
obj
,
QEvent
*
event
)
{
if
(
event
->
type
()
==
QEvent
::
Resize
)
updateLabelGeometry
();
return
QObject
::
eventFilter
(
obj
,
event
);
}
void
WarningSign
::
updateLabelGeometry
()
{
if
(
!
m_warningWidget
||
!
m_area
)
return
;
QPoint
pos
=
positionForWarningSign
();
m_warningWidget
->
setPosition
(
pos
.
x
(),
pos
.
y
());
}
QPoint
WarningSign
::
positionForWarningSign
()
const
{
Q_ASSERT
(
m_area
);
int
x
=
m_area
->
width
()
-
xpos_offset
;
int
y
=
m_area
->
height
()
-
ypos_offset
;
if
(
QAbstractScrollArea
*
scrollArea
=
dynamic_cast
<
QAbstractScrollArea
*>
(
m_area
))
{
if
(
QScrollBar
*
horizontal
=
scrollArea
->
horizontalScrollBar
())
{
if
(
horizontal
->
isVisible
())
y
-=
horizontal
->
height
();
}
if
(
QScrollBar
*
vertical
=
scrollArea
->
verticalScrollBar
())
{
if
(
vertical
->
isVisible
())
x
-=
vertical
->
width
();
}
}
return
QPoint
(
x
,
y
);
}
This diff is collapsed.
Click to expand it.
GUI/coregui/Views/InfoWidgets/WarningSign.h
0 → 100644
+
54
−
0
View file @
3e3f2825
// ************************************************************************** //
//
// BornAgain: simulate and fit scattering at grazing incidence
//
//! @file GUI/coregui/Views/InfoWidgets/WarningSign.h
//! @brief Defines class WarningSign
//!
//! @homepage http://www.bornagainproject.org
//! @license GNU General Public License v3 or higher (see COPYING)
//! @copyright Forschungszentrum Jülich GmbH 2016
//! @authors Scientific Computing Group at MLZ Garching
//! @authors Céline Durniak, Marina Ganeva, David Li, Gennady Pospelov
//! @authors Walter Van Herck, Joachim Wuttke
//
// ************************************************************************** //
#ifndef WARNINGSIGN_H
#define WARNINGSIGN_H
#include
"WinDllMacros.h"
#include
<QObject>
class
WarningSignWidget
;
class
QWidget
;
//! The WarningSign controls appearance of WarningSignWidget on top of parent widget.
class
WarningSign
:
public
QObject
{
public:
WarningSign
(
QWidget
*
parent
);
void
clear
();
void
setWarningHeader
(
const
QString
&
warningHeader
);
void
setWarningMessage
(
const
QString
&
warningMessage
);
void
setArea
(
QWidget
*
area
);
protected:
bool
eventFilter
(
QObject
*
obj
,
QEvent
*
event
);
private:
void
updateLabelGeometry
();
QPoint
positionForWarningSign
()
const
;
QString
m_warning_header
;
QString
m_warning_message
;
WarningSignWidget
*
m_warningWidget
;
QWidget
*
m_area
;
};
#endif // WARNINGSIGN_H
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