| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 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 |
} |