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/footerwidget.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 "footerwidget.h"
22 #include "headerwidget.h"
23 #include "buttonarea.h"
24 #include "aerobutton.h"
25
26 #include "mainwindow.h"
27
28 #include <QApplication>
29 #include <QMouseEvent>
30 #include <QHBoxLayout>
31
32 namespace SIFPrivate {
33
34 FooterWidget::FooterWidget(HeaderWidget *header, QWidget *parent)
35 : QWidget(parent), m_header(header), m_dragging(false)
36 {
37 setAutoFillBackground(true);
38
39 m_buttonArea = new ButtonArea;
40
41 QHBoxLayout *layout = new QHBoxLayout;
42 layout->addStretch(1);
43 layout->addWidget(m_buttonArea);
44 layout->addStretch(1);
45 }
46
47
48 FooterWidget::~FooterWidget()
49 {
50 }
51
52 void FooterWidget::setBackground(const QBrush &background)
53 {
54 QPalette palette = this->palette();
55 palette.setBrush(QPalette::Window, background);
56
57 setPalette(palette);
58 }
59
60 SIF::AeroButton *FooterWidget::addButton(const QString &title, const QIcon &icon)
61 {
62 SIF::AeroButton *button = m_buttonArea->addButton(title, icon);
63 button->setIconSize(QSize(22,22));
64
65 return button;
66 }
67
68 void FooterWidget::resizeEvent(QResizeEvent *e)
69 {
70 QWidget::resizeEvent(e);
71
72 QRect br = rect();
73 QLinearGradient gradient(0, 0, 0, br.height());
74
75 gradient.setColorAt(0.0, m_header->borderColor());
76 gradient.setColorAt(0.1, m_header->shadowColor());
77
78
79 gradient.setColorAt(0.5, m_header->borderColor());
80 gradient.setColorAt(0.55, m_header->borderColor());
81
82 gradient.setColorAt(0.9, m_header->shadowColor());
83 gradient.setColorAt(1.0, m_header->borderColor());
84
85 setBackground(gradient);
86 }
87
88 void FooterWidget::mousePressEvent(QMouseEvent *e)
89 {
90 if (e->button() == Qt::LeftButton)
91 {
92 SIF::MainWindow *mw = qobject_cast<SIF::MainWindow *>(qApp->activeWindow());
93
94 if(mw)
95 {
96 m_dragging = true;
97 m_dragPosition = e->globalPos() - mw->frameGeometry().topLeft();
98 e->accept();
99 }
100 }
101
102 QWidget::mousePressEvent(e);
103 }
104
105 void FooterWidget::mouseMoveEvent(QMouseEvent *e)
106 {
107 if(m_dragging && e->buttons() & Qt::LeftButton)
108 {
109 SIF::MainWindow *mw = qobject_cast<SIF::MainWindow *>(qApp->activeWindow());
110
111 if(mw)
112 {
113 mw->move(e->globalPos() - m_dragPosition);
114 e->accept();
115 }
116 }
117
118 QWidget::mousePressEvent(e);
119 }
120
121 void FooterWidget::mouseReleaseEvent(QMouseEvent *e)
122 {
123 m_dragging = false;
124 QWidget::mouseReleaseEvent(e);
125 }
126
127 }