BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
detailsbutton.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2016 The Qt Company Ltd.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of Qt Creator.
7 **
8 ** Commercial License Usage
9 ** Licensees holding valid commercial Qt licenses may use this file in
10 ** accordance with the commercial license agreement provided with the
11 ** Software or, alternatively, in accordance with the terms contained in
12 ** a written agreement between you and The Qt Company. For licensing terms
13 ** and conditions see https://www.qt.io/terms-conditions. For further
14 ** information use the contact form at https://www.qt.io/contact-us.
15 **
16 ** GNU General Public License Usage
17 ** Alternatively, this file may be used under the terms of the GNU
18 ** General Public License version 3 as published by the Free Software
19 ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
20 ** included in the packaging of this file. Please review the following
21 ** information to ensure the GNU General Public License requirements will
22 ** be met: https://www.gnu.org/licenses/gpl-3.0.html.
23 **
24 ****************************************************************************/
25 
26 #ifndef BORNAGAIN_GUI_COREGUI_VIEWS_COMMONWIDGETS_DETAILSBUTTON_H
27 #define BORNAGAIN_GUI_COREGUI_VIEWS_COMMONWIDGETS_DETAILSBUTTON_H
28 
29 #include <QAbstractButton>
30 
31 class QGraphicsOpacityEffect;
32 
33 namespace Utils {
34 class FadingPanel : public QWidget {
35  Q_OBJECT
36 
37 public:
38  FadingPanel(QWidget* parent = 0) : QWidget(parent) {}
39  virtual void fadeTo(qreal value) = 0;
40  virtual void setOpacity(qreal value) = 0;
41 };
42 
43 class FadingWidget : public FadingPanel {
44  Q_OBJECT
45 public:
46  FadingWidget(QWidget* parent = 0);
47  void fadeTo(qreal value);
48  qreal opacity();
49  void setOpacity(qreal value);
50 
51 protected:
52  QGraphicsOpacityEffect* m_opacityEffect;
53 };
54 
55 class DetailsButton : public QAbstractButton {
56  Q_OBJECT
57  Q_PROPERTY(float fader READ fader WRITE setFader)
58 
59 public:
60  DetailsButton(QWidget* parent = 0);
61 
62  QSize sizeHint() const;
63  float fader() { return m_fader; }
64  void setFader(float value)
65  {
66  m_fader = value;
67  update();
68  }
69 
70 protected:
71  void paintEvent(QPaintEvent* e);
72  bool event(QEvent* e);
73 
74 private:
75  QPixmap cacheRendering(const QSize& size, bool checked);
76  QPixmap m_checkedPixmap;
78  float m_fader;
79 };
80 } // namespace Utils
81 
82 #endif // BORNAGAIN_GUI_COREGUI_VIEWS_COMMONWIDGETS_DETAILSBUTTON_H
bool event(QEvent *e)
void paintEvent(QPaintEvent *e)
DetailsButton(QWidget *parent=0)
QPixmap cacheRendering(const QSize &size, bool checked)
void setFader(float value)
Definition: detailsbutton.h:64
QSize sizeHint() const
FadingPanel(QWidget *parent=0)
Definition: detailsbutton.h:38
virtual void setOpacity(qreal value)=0
virtual void fadeTo(qreal value)=0
QGraphicsOpacityEffect * m_opacityEffect
Definition: detailsbutton.h:52
void fadeTo(qreal value)
void setOpacity(qreal value)
FadingWidget(QWidget *parent=0)