HAL
dock_button.h
Go to the documentation of this file.
1 // MIT License
2 //
3 // Copyright (c) 2019 Ruhr University Bochum, Chair for Embedded Security. All Rights reserved.
4 // Copyright (c) 2019 Marc Fyrbiak, Sebastian Wallat, Max Hoffmann ("ORIGINAL AUTHORS"). All rights reserved.
5 // Copyright (c) 2021 Max Planck Institute for Security and Privacy. All Rights reserved.
6 // Copyright (c) 2021 Jörn Langheinrich, Julian Speith, Nils Albartus, René Walendy, Simon Klix ("ORIGINAL AUTHORS"). All Rights reserved.
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to deal
10 // in the Software without restriction, including without limitation the rights
11 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 // copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
14 //
15 // The above copyright notice and this permission notice shall be included in all
16 // copies or substantial portions of the Software.
17 //
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 // SOFTWARE.
25 
26 #pragma once
27 
28 #include <QToolButton>
29 
30 namespace hal
31 {
32  class ContentWidget;
33 
40  enum class button_orientation
41  {
42  horizontal = 0,
43  vertical_up = 1,
44  vertical_down = 2
45  };
46 
55  class DockButton : public QToolButton
56  {
57  Q_OBJECT
61 
62  public:
72 
78  void paintEvent(QPaintEvent* event) override;
79 
83 
87 
92 
98 
102 
107  void setTextColor(const QColor& color);
108 
113  void setCheckedColor(const QColor& color);
114 
119  void setHoverColor(const QColor& color);
121 
125  void adjustSize();
126 
132  int relativeWidth();
133 
140 
147  bool hidden();
148 
154  bool available();
155 
162  void setAvailable(bool available);
163 
169  void setRelativeHeight(int height);
170 
171  //overshadowed functions
172 
176  void hide();
177 
181  void show();
182 
183  public Q_SLOTS:
184 
192  void handleClicked(bool mChecked);
193 
194  private:
195  ContentWidget* mWidget;
196  button_orientation mOrientation;
197  int mWidth;
198  int mHeight;
199  int mRelativeWidth;
200  int mRelativeHeight;
201  int mIconSize;
202  int mTextOffset;
203  int mWidthPadding;
204  int mHeightPadding;
205  bool mHidden;
206  bool mAvailable = true;
207 
208  QColor mTextColor;
209  QColor mCheckedColor;
210  QColor mHoverColor;
211  };
212 }
Abstract class for Widgets within HAL's ContentArea.
A button of in the DockerBar.
Definition: dock_button.h:56
void setCheckedColor(const QColor &color)
Definition: dock_button.cpp:83
QColor hoverColor
Definition: dock_button.h:60
void setAvailable(bool available)
QColor textColor()
DockButton(ContentWidget *widget, button_orientation orientation, QObject *eventFilter, QWidget *parent)
Definition: dock_button.cpp:12
QColor textColor
Definition: dock_button.h:58
QColor checkedColor()
QColor hoverColor()
void setRelativeHeight(int height)
QColor checkedColor
Definition: dock_button.h:59
void handleClicked(bool mChecked)
void paintEvent(QPaintEvent *event) override
Definition: dock_button.cpp:29
void setHoverColor(const QColor &color)
Definition: dock_button.cpp:88
ContentWidget * widget()
void setTextColor(const QColor &color)
Definition: dock_button.cpp:78
button_orientation
Definition: dock_button.h:41
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Q_SLOTSQ_SLOTS
virtual bool eventFilter(QObject *watched, QEvent *event)
QObject * parent() const const
virtual bool event(QEvent *event) override