HAL  v4.5.0-283-g3f42a39fa
The Hardware Analyzer - a comprehensive reverse engineering and manipulation framework for gate-level netlists.
content_widget.cpp
Go to the documentation of this file.
2 
5 #include "gui/toolbar/toolbar.h"
6 
7 #include <QShortcut>
8 #include <QStyle>
9 #include <QVBoxLayout>
10 
11 namespace hal
12 {
13  ContentWidget::ContentWidget(QString name, QWidget* parent) : Widget(parent), mName(name), mContentLayout(new QVBoxLayout()),
14  mSearchAction(new QAction(this)), mSearchShortcut(nullptr),mSearchKeysequence(tr("Ctrl+F")),
15  mDetachedFrame(nullptr)
16  {
19  setMinimumSize(100, 100);
22 
24  //debug code, delete later
25  QIcon temp;
26  temp.addFile(QStringLiteral(":/icons/start"), QSize(), QIcon::Normal, QIcon::Off);
27  setIcon(temp);
28  }
29 
31  {
32  if (mAnchor)
33  {
34  mAnchor->remove(this);
35  Q_EMIT removed();
36  }
37  }
38 
40  {
41  if (mAnchor)
42  {
43  ContentFrame* cf = mAnchor->detach(this);
44  mDetachedFrame = cf;
45  Q_EMIT detached();
46  }
47  }
48 
50  {
51  if (mAnchor)
52  {
53  mDetachedFrame = nullptr;
54  mAnchor->reattach(this);
56  }
57  }
58 
60  {
61  if (mAnchor)
62  {
63  mAnchor->open(this);
64  Q_EMIT opened();
65  }
66  }
67 
69  {
70  if (mAnchor)
71  {
72  mDetachedFrame = nullptr;
73  mAnchor->close(this);
74  Q_EMIT closed();
75  }
76  }
77 
78  void ContentWidget::closeEvent(QCloseEvent* event){Q_UNUSED(event)}
79 
81  {
82  return mName;
83  }
84 
86  {
87  return mIcon;
88  }
89 
91  {
92  return mDetachedFrame;
93  }
94 
96  {
97  mDetachedFrame = df;
98  }
99 
101  {
102  mAnchor = anchor;
103  }
104 
106  {
107  mIcon = icon;
108  }
109 
111  {
112  mName = name;
114  }
115 
117 
119  {
120  return QList<QShortcut*>();
121  }
122 
124  {
125  if (mShortcutsCreated)
126  return;
127  mShortcutsCreated = true;
128 
129  for (QShortcut* s : createShortcuts())
130  {
131  // shortcuts must stay owned by this widget: derived classes keep pointers to them (e.g. mSearchShortcut)
132  s->setParent(this);
133  s->setContext(Qt::WidgetWithChildrenShortcut);
134  s->setEnabled(true);
135  }
136  }
137 
139  {
140  QStyle* s = style();
141 
142  s->unpolish(this);
143  s->polish(this);
144 
145  // if (!mIconPath.isEmpty())
146  // mIconLabel->setPixmap(gui_utility::getStyledSvgIcon(mIconStyle, mIconPath).pixmap(QSize(20, 20)));
147  }
148 
150  {
151  return mIconStyle;
152  }
153 
155  {
156  return mIconPath;
157  }
158 
160  {
161  if (mIconStyle == style)
162  return;
163 
164  mIconStyle = style;
165  repolish();
166  }
167 
169  {
170  if (mIconPath == path)
171  return;
172 
173  mIconPath = path;
174  repolish();
175  }
176 
178  {
179  mSearchKeysequence = seq;
180  // shortcut does not exist before the widget was shown for the first time, it will then be created with the new key sequence
181  if (mSearchShortcut)
183  }
184 }
An abstract class that provides the interface for specific anchors (see SplitterAnchor or TabWidget )...
virtual void reattach(ContentWidget *widget)=0
virtual void close(ContentWidget *widget)=0
virtual void remove(ContentWidget *widget)=0
virtual ContentFrame * detach(ContentWidget *widget)=0
virtual void open(ContentWidget *widget)=0
Wraps the ContentWidget class.
Definition: content_frame.h:45
virtual void setupToolbar(Toolbar *Toolbar)
QKeySequence mSearchKeysequence
QString name() const
void set_name(const QString &name)
void setIconPath(const QString &path)
ContentFrame * mDetachedFrame
void setAnchor(ContentAnchor *anchor)
QIcon icon() const
QShortcut * mSearchShortcut
void name_changed(const QString &name)
void setIconStyle(const QString &style)
void handleSearchKeysequenceChanged(QKeySequence seq)
void setDetachedFrame(ContentFrame *df)
ContentWidget(QString name, QWidget *parent=nullptr)
ContentFrame * detachedFrame() const
void setIcon(QIcon icon)
virtual QList< QShortcut * > createShortcuts()
QVBoxLayout * mContentLayout
Toolbar for all ContentFrames and ContentWidgets.
Definition: toolbar.h:39
A QWidget customized for hal.
Definition: widget.h:42
Definition: defines.h:45
std::string name
void setSpacing(int spacing)
void addFile(const QString &fileName, const QSize &size, QIcon::Mode mode, QIcon::State state)
void setContentsMargins(int left, int top, int right, int bottom)
Q_EMITQ_EMIT
void setKey(const QKeySequence &key)
virtual void polish(QWidget *widget)
virtual void unpolish(QWidget *widget)
WidgetWithChildrenShortcut
virtual bool event(QEvent *event) override
void setMinimumSize(const QSize &)
void setLayout(QLayout *layout)
void setSizePolicy(QSizePolicy)
QStyle * style() const const
void setWindowTitle(const QString &)