System notice: In light of the Debian OpenSSL security issue we've regenerated the server keys. See this thread for instructions and the new key fingerprints.

Blob of src/sif/private/centralwidget.cpp (raw blob data)

1 /***************************************************************************
2 * Copyright (C) 2008 by David Cuadrado *
3 * krawek@gmail.com *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
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 }