HAL
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(new QShortcut(this)), 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  QStyle* s = style();
126 
127  s->unpolish(this);
128  s->polish(this);
129 
130  // if (!mIconPath.isEmpty())
131  // mIconLabel->setPixmap(gui_utility::getStyledSvgIcon(mIconStyle, mIconPath).pixmap(QSize(20, 20)));
132  }
133 
135  {
136  return mIconStyle;
137  }
138 
140  {
141  return mIconPath;
142  }
143 
145  {
146  if (mIconStyle == style)
147  return;
148 
149  mIconStyle = style;
150  repolish();
151  }
152 
154  {
155  if (mIconPath == path)
156  return;
157 
158  mIconPath = path;
159  repolish();
160  }
161 
163  {
164  mSearchKeysequence = seq;
166  }
167 }
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:41
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)
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 &)