/*************************************************************************** * Copyright (C) 2008 by David Cuadrado * * krawek@gmail.com * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include "footerwidget.h" #include "headerwidget.h" #include "buttonarea.h" #include "aerobutton.h" #include "mainwindow.h" #include #include #include namespace SIFPrivate { FooterWidget::FooterWidget(HeaderWidget *header, QWidget *parent) : QWidget(parent), m_header(header), m_dragging(false) { setAutoFillBackground(true); m_buttonArea = new ButtonArea; QHBoxLayout *layout = new QHBoxLayout; layout->addStretch(1); layout->addWidget(m_buttonArea); layout->addStretch(1); } FooterWidget::~FooterWidget() { } void FooterWidget::setBackground(const QBrush &background) { QPalette palette = this->palette(); palette.setBrush(QPalette::Window, background); setPalette(palette); } SIF::AeroButton *FooterWidget::addButton(const QString &title, const QIcon &icon) { SIF::AeroButton *button = m_buttonArea->addButton(title, icon); button->setIconSize(QSize(22,22)); return button; } void FooterWidget::resizeEvent(QResizeEvent *e) { QWidget::resizeEvent(e); QRect br = rect(); QLinearGradient gradient(0, 0, 0, br.height()); gradient.setColorAt(0.0, m_header->borderColor()); gradient.setColorAt(0.1, m_header->shadowColor()); gradient.setColorAt(0.5, m_header->borderColor()); gradient.setColorAt(0.55, m_header->borderColor()); gradient.setColorAt(0.9, m_header->shadowColor()); gradient.setColorAt(1.0, m_header->borderColor()); setBackground(gradient); } void FooterWidget::mousePressEvent(QMouseEvent *e) { if (e->button() == Qt::LeftButton) { SIF::MainWindow *mw = qobject_cast(qApp->activeWindow()); if(mw) { m_dragging = true; m_dragPosition = e->globalPos() - mw->frameGeometry().topLeft(); e->accept(); } } QWidget::mousePressEvent(e); } void FooterWidget::mouseMoveEvent(QMouseEvent *e) { if(m_dragging && e->buttons() & Qt::LeftButton) { SIF::MainWindow *mw = qobject_cast(qApp->activeWindow()); if(mw) { mw->move(e->globalPos() - m_dragPosition); e->accept(); } } QWidget::mousePressEvent(e); } void FooterWidget::mouseReleaseEvent(QMouseEvent *e) { m_dragging = false; QWidget::mouseReleaseEvent(e); } }