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  {
18  setMinimumSize(100, 100);
21 
23  //debug code, delete later
24  QIcon temp;
25  temp.addFile(QStringLiteral(":/icons/start"), QSize(), QIcon::Normal, QIcon::Off);
26  setIcon(temp);
27  }
28 
30  {
31  if (mAnchor)
32  {
33  mAnchor->remove(this);
34  Q_EMIT removed();
35  }
36  }
37 
39  {
40  if (mAnchor)
41  {
42  mAnchor->detach(this);
43  Q_EMIT detached();
44  }
45  }
46 
48  {
49  if (mAnchor)
50  {
51  mAnchor->reattach(this);
53  }
54  }
55 
57  {
58  if (mAnchor)
59  {
60  mAnchor->open(this);
61  Q_EMIT opened();
62  }
63  }
64 
66  {
67  if (mAnchor)
68  {
69  mAnchor->close(this);
70  Q_EMIT closed();
71  }
72  }
73 
74  void ContentWidget::closeEvent(QCloseEvent* event){Q_UNUSED(event)}
75 
77  {
78  return mName;
79  }
80 
82  {
83  return mIcon;
84  }
85 
87  {
88  mAnchor = anchor;
89  }
90 
92  {
93  mIcon = icon;
94  }
95 
97  {
98  mName = name;
100  }
101 
103 
105  {
106  return QList<QShortcut*>();
107  }
108 
110  {
111  QStyle* s = style();
112 
113  s->unpolish(this);
114  s->polish(this);
115 
116  // if (!mIconPath.isEmpty())
117  // mIconLabel->setPixmap(gui_utility::getStyledSvgIcon(mIconStyle, mIconPath).pixmap(QSize(20, 20)));
118  }
119 
121  {
122  return mIconStyle;
123  }
124 
126  {
127  return mIconPath;
128  }
129 
131  {
132  if (mIconStyle == style)
133  return;
134 
135  mIconStyle = style;
136  repolish();
137  }
138 
140  {
141  if (mIconPath == path)
142  return;
143 
144  mIconPath = path;
145  repolish();
146  }
147 
149  {
150  mSearchKeysequence = seq;
152  }
153 }
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 void open(ContentWidget *widget)=0
virtual void detach(ContentWidget *widget)=0
virtual void setupToolbar(Toolbar *Toolbar)
QKeySequence mSearchKeysequence
void set_name(const QString &name)
void setIconPath(const QString &path)
void setAnchor(ContentAnchor *anchor)
QShortcut * mSearchShortcut
void name_changed(const QString &name)
void setIconStyle(const QString &style)
void handleSearchKeysequenceChanged(QKeySequence seq)
ContentWidget(QString name, QWidget *parent=nullptr)
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 &)