| | |
| | | #include "WindowBar.h" |
| | | #include "WindowBar_p.h" |
| | | #include "windowbar.h" |
| | | #include "windowbar_p.h" |
| | | |
| | | #include <QtCore/QDebug> |
| | | #include <QtGui/QtEvents> |
| | |
| | | autoIcon = false; |
| | | } |
| | | |
| | | WindowBarPrivate::~WindowBarPrivate() { |
| | | } |
| | | WindowBarPrivate::~WindowBarPrivate() = default; |
| | | |
| | | void WindowBarPrivate::init() { |
| | | Q_Q(WindowBar); |
| | | layout = new QHBoxLayout(); |
| | | layout->setMargin(0); |
| | | layout->setContentsMargins(QMargins()); |
| | | layout->setSpacing(0); |
| | | for (int i = IconButton; i <= CloseButton; ++i) { |
| | | insertDefaultSpace(i); |
| | |
| | | WindowBar::WindowBar(QWidget *parent) : WindowBar(*new WindowBarPrivate(), parent) { |
| | | } |
| | | |
| | | WindowBar::~WindowBar() { |
| | | } |
| | | WindowBar::~WindowBar() = default; |
| | | |
| | | QMenuBar *WindowBar::menuBar() const { |
| | | Q_D(const WindowBar); |
| | |
| | | QLabel *label = titleLabel(); |
| | | QAbstractButton *maxBtn = maxButton(); |
| | | switch (event->type()) { |
| | | case QEvent::WindowIconChange: |
| | | case QEvent::WindowIconChange: { |
| | | if (d_ptr->autoIcon && iconBtn) { |
| | | iconBtn->setIcon(w->windowIcon()); |
| | | iconChanged(w->windowIcon()); |
| | | } |
| | | break; |
| | | case QEvent::WindowTitleChange: |
| | | } |
| | | case QEvent::WindowTitleChange: { |
| | | if (d_ptr->autoTitle && label) { |
| | | label->setText(w->windowTitle()); |
| | | titleChanged(w->windowTitle()); |
| | | } |
| | | break; |
| | | case QEvent::WindowStateChange: |
| | | } |
| | | case QEvent::WindowStateChange: { |
| | | if (maxBtn) { |
| | | maxBtn->setChecked(w->isMaximized()); |
| | | } |
| | | break; |
| | | } |
| | | default: |
| | | break; |
| | | } |