| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
#include "centralwidget.h" |
| 22 |
|
| 23 |
#include "headerwidget.h" |
| 24 |
#include "footerwidget.h" |
| 25 |
#include "stackedwidget.h" |
| 26 |
#include "aerobutton.h" |
| 27 |
|
| 28 |
#include <QVBoxLayout> |
| 29 |
|
| 30 |
namespace SIFPrivate { |
| 31 |
|
| 32 |
CentralWidget::CentralWidget(QWidget *parent) |
| 33 |
: QWidget(parent) |
| 34 |
{ |
| 35 |
QVBoxLayout *layout = new QVBoxLayout(this); |
| 36 |
layout->setSpacing(3); |
| 37 |
layout->setMargin(0); |
| 38 |
|
| 39 |
m_header = new HeaderWidget; |
| 40 |
m_stack = new StackedWidget; |
| 41 |
m_footer = new FooterWidget(m_header); |
| 42 |
{ |
| 43 |
m_footer->setMinimumHeight(30); |
| 44 |
|
| 45 |
} |
| 46 |
|
| 47 |
layout->addWidget(m_header); |
| 48 |
layout->addWidget(m_stack); |
| 49 |
layout->addWidget(m_footer); |
| 50 |
} |
| 51 |
|
| 52 |
|
| 53 |
CentralWidget::~CentralWidget() |
| 54 |
{ |
| 55 |
} |
| 56 |
|
| 57 |
void CentralWidget::addPage(const QString &title, QWidget *w) |
| 58 |
{ |
| 59 |
SIF::AeroButton *button = m_header->addButton(title); |
| 60 |
m_stack->addWidget(w); |
| 61 |
|
| 62 |
m_pages[button] = w; |
| 63 |
|
| 64 |
connect(button, SIGNAL(clicked()), this, SLOT(onButtonClicked())); |
| 65 |
} |
| 66 |
|
| 67 |
void CentralWidget::addPage(const QIcon &icon, const QString &title, QWidget *w) |
| 68 |
{ |
| 69 |
SIF::AeroButton *button = m_header->addButton(title, icon); |
| 70 |
m_stack->addWidget(w); |
| 71 |
|
| 72 |
m_pages[button] = w; |
| 73 |
|
| 74 |
connect(button, SIGNAL(clicked()), this, SLOT(onButtonClicked())); |
| 75 |
} |
| 76 |
|
| 77 |
SIF::AeroButton *CentralWidget::addButton(const QString &title, const QIcon &icon) |
| 78 |
{ |
| 79 |
SIF::AeroButton *button = m_header->addButton(title, icon); |
| 80 |
|
| 81 |
return button; |
| 82 |
} |
| 83 |
|
| 84 |
HeaderWidget *CentralWidget::header() const |
| 85 |
{ |
| 86 |
return m_header; |
| 87 |
} |
| 88 |
|
| 89 |
StackedWidget *CentralWidget::stack() const |
| 90 |
{ |
| 91 |
return m_stack; |
| 92 |
} |
| 93 |
|
| 94 |
|
| 95 |
void CentralWidget::onButtonClicked() |
| 96 |
{ |
| 97 |
QAbstractButton *button = qobject_cast<QAbstractButton *>(sender()); |
| 98 |
|
| 99 |
if(button) |
| 100 |
{ |
| 101 |
if(m_pages.contains(button)) |
| 102 |
{ |
| 103 |
m_stack->setCurrentWidget(m_pages[button]); |
| 104 |
} |
| 105 |
} |
| 106 |
} |
| 107 |
|
| 108 |
} |