| |   |
| 5 | 5 | #include <QPainter> |
| 6 | 6 | #include <QApplication> |
| 7 | 7 | |
| 8 | namespace SIF { |
| 9 | |
| 10 | |
| 8 | 11 | struct AeroButton::Private { |
| 9 | 12 | bool hovered; |
| 10 | 13 | bool pressed; |
| … | … | |
| 60 | 60 | AeroButton::AeroButton(QWidget * parent) |
| 61 | 61 | : QPushButton(parent), d(new Private) |
| 62 | 62 | { |
| 63 | QPalette pal = palette(); |
| 64 | pal.setBrush(QPalette::WindowText, Qt::white); |
| 65 | pal.setBrush(QPalette::Text, Qt::white); |
| 66 | pal.setBrush(QPalette::ButtonText, Qt::white); |
| 67 | setPalette(pal); |
| 63 | 68 | } |
| 64 | 69 | |
| 65 | 70 | AeroButton::AeroButton(const QString & text, QWidget * parent) |
| 66 | 71 | : QPushButton(text, parent), d(new Private) |
| 67 | 72 | { |
| 73 | QPalette pal = palette(); |
| 74 | pal.setBrush(QPalette::WindowText, Qt::white); |
| 75 | pal.setBrush(QPalette::Text, Qt::white); |
| 76 | pal.setBrush(QPalette::ButtonText, Qt::white); |
| 77 | setPalette(pal); |
| 68 | 78 | } |
| 69 | 79 | |
| 70 | 80 | AeroButton::AeroButton(const QIcon & icon, const QString & text, QWidget * parent) |
| 71 | 81 | : QPushButton(icon, text, parent), d(new Private) |
| 72 | 82 | { |
| 83 | QPalette pal = palette(); |
| 84 | pal.setBrush(QPalette::WindowText, Qt::white); |
| 85 | pal.setBrush(QPalette::Text, Qt::white); |
| 86 | pal.setBrush(QPalette::ButtonText, Qt::white); |
| 87 | setPalette(pal); |
| 73 | 88 | } |
| 74 | 89 | |
| 75 | 90 | AeroButton::~AeroButton() |
| 76 | 91 | { |
| 92 | delete d; |
| 77 | 93 | } |
| 78 | 94 | |
| 79 | 95 | void AeroButton::setColor(const QColor &color) |
| … | … | |
| 130 | 130 | |
| 131 | 131 | QPainter painter(this); |
| 132 | 132 | painter.setRenderHint(QPainter::Antialiasing); |
| 133 | | |
| 133 | |
| 134 | painter.save(); |
| 135 | |
| 136 | painter.fillRect(rect(), Qt::transparent); |
| 137 | |
| 134 | 138 | //test for state changes |
| 135 | 139 | QColor button_color; |
| 136 | 140 | if(this->isEnabled()) |
| … | … | |
| 170 | 170 | |
| 171 | 171 | QBrush brush(gradient); |
| 172 | 172 | painter.setBrush(brush); |
| 173 | | painter.setPen(QPen(QBrush(button_color), 2.0)); |
| 173 | painter.setPen(QPen(QBrush(button_color), 2.0, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin )); |
| 174 | 174 | |
| 175 | 175 | //main button |
| 176 | 176 | QPainterPath painter_path; |
| … | … | |
| 182 | 182 | |
| 183 | 183 | //glass highlight |
| 184 | 184 | painter.setBrush(QBrush(Qt::white)); |
| 185 | | painter.setPen(QPen(QBrush(Qt::white), 0.01)); |
| 185 | painter.setPen(QPen(QBrush(Qt::white), 0.01, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); |
| 186 | 186 | painter.setOpacity(0.30); |
| 187 | 187 | painter.drawRect(1, 1, button_rect.width() - 2, (button_rect.height() / 2) - 2); |
| 188 | 188 | |
| 189 | painter.restore(); |
| 190 | |
| 189 | 191 | //button text |
| 190 | 192 | QString text = this->text(); |
| 191 | 193 | if(!text.isNull()) |
| 192 | 194 | { |
| 193 | 195 | QFont font = this->font(); |
| 196 | font.setBold(true); |
| 194 | 197 | painter.setFont(font); |
| 195 | | painter.setPen(Qt::white); |
| 198 | |
| 199 | // painter.setPen(Qt::white); |
| 200 | |
| 196 | 201 | painter.setOpacity(1.0); |
| 197 | 202 | painter.drawText(0, 0, button_rect.width(), button_rect.height(), Qt::AlignCenter, text); |
| 198 | 203 | } |
| … | … | |
| 218 | 218 | Q_UNUSED(e); |
| 219 | 219 | |
| 220 | 220 | d->hovered = true; |
| 221 | | this->repaint(); |
| 221 | this->update(); |
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | void AeroButton::leaveEvent(QEvent * e) |
| … | … | |
| 226 | 226 | Q_UNUSED(e); |
| 227 | 227 | |
| 228 | 228 | d->hovered = false; |
| 229 | | this->repaint(); |
| 229 | this->update(); |
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | void AeroButton::mousePressEvent(QMouseEvent * e) |
| 233 | 233 | { |
| 234 | 234 | Q_UNUSED(e); |
| 235 | | |
| 236 | | this->click(); |
| 237 | | |
| 235 | |
| 238 | 236 | d->pressed = true; |
| 239 | | this->repaint(); |
| 237 | this->update(); |
| 238 | |
| 239 | QPushButton::mousePressEvent(e); |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | void AeroButton::mouseReleaseEvent(QMouseEvent * e) |
| 243 | 243 | { |
| 244 | 244 | Q_UNUSED(e); |
| 245 | | |
| 245 | |
| 246 | 246 | d->pressed = false; |
| 247 | | this->repaint(); |
| 247 | this->update(); |
| 248 | |
| 249 | QPushButton::mouseReleaseEvent(e); |
| 248 | 250 | } |
| 249 | 251 | |
| 250 | 252 | |
| 253 | } |
| toggle raw diff |
--- a/src/sif/aerobutton.cpp
+++ b/src/sif/aerobutton.cpp
@@ -5,6 +5,9 @@
#include <QPainter>
#include <QApplication>
+namespace SIF {
+
+
struct AeroButton::Private {
bool hovered;
bool pressed;
@@ -57,20 +60,36 @@ AeroButton::Private::~Private()
AeroButton::AeroButton(QWidget * parent)
: QPushButton(parent), d(new Private)
{
+ QPalette pal = palette();
+ pal.setBrush(QPalette::WindowText, Qt::white);
+ pal.setBrush(QPalette::Text, Qt::white);
+ pal.setBrush(QPalette::ButtonText, Qt::white);
+ setPalette(pal);
}
AeroButton::AeroButton(const QString & text, QWidget * parent)
: QPushButton(text, parent), d(new Private)
{
+ QPalette pal = palette();
+ pal.setBrush(QPalette::WindowText, Qt::white);
+ pal.setBrush(QPalette::Text, Qt::white);
+ pal.setBrush(QPalette::ButtonText, Qt::white);
+ setPalette(pal);
}
AeroButton::AeroButton(const QIcon & icon, const QString & text, QWidget * parent)
: QPushButton(icon, text, parent), d(new Private)
{
+ QPalette pal = palette();
+ pal.setBrush(QPalette::WindowText, Qt::white);
+ pal.setBrush(QPalette::Text, Qt::white);
+ pal.setBrush(QPalette::ButtonText, Qt::white);
+ setPalette(pal);
}
AeroButton::~AeroButton()
{
+ delete d;
}
void AeroButton::setColor(const QColor &color)
@@ -111,7 +130,11 @@ void AeroButton::paintEvent(QPaintEvent * pe)
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
-
+
+ painter.save();
+
+ painter.fillRect(rect(), Qt::transparent);
+
//test for state changes
QColor button_color;
if(this->isEnabled())
@@ -147,7 +170,7 @@ void AeroButton::paintEvent(QPaintEvent * pe)
QBrush brush(gradient);
painter.setBrush(brush);
- painter.setPen(QPen(QBrush(button_color), 2.0));
+ painter.setPen(QPen(QBrush(button_color), 2.0, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin ));
//main button
QPainterPath painter_path;
@@ -159,17 +182,22 @@ void AeroButton::paintEvent(QPaintEvent * pe)
//glass highlight
painter.setBrush(QBrush(Qt::white));
- painter.setPen(QPen(QBrush(Qt::white), 0.01));
+ painter.setPen(QPen(QBrush(Qt::white), 0.01, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
painter.setOpacity(0.30);
painter.drawRect(1, 1, button_rect.width() - 2, (button_rect.height() / 2) - 2);
+ painter.restore();
+
//button text
QString text = this->text();
if(!text.isNull())
{
QFont font = this->font();
+ font.setBold(true);
painter.setFont(font);
- painter.setPen(Qt::white);
+
+// painter.setPen(Qt::white);
+
painter.setOpacity(1.0);
painter.drawText(0, 0, button_rect.width(), button_rect.height(), Qt::AlignCenter, text);
}
@@ -190,7 +218,7 @@ void AeroButton::enterEvent(QEvent * e)
Q_UNUSED(e);
d->hovered = true;
- this->repaint();
+ this->update();
}
void AeroButton::leaveEvent(QEvent * e)
@@ -198,25 +226,28 @@ void AeroButton::leaveEvent(QEvent * e)
Q_UNUSED(e);
d->hovered = false;
- this->repaint();
+ this->update();
}
void AeroButton::mousePressEvent(QMouseEvent * e)
{
Q_UNUSED(e);
-
- this->click();
-
+
d->pressed = true;
- this->repaint();
+ this->update();
+
+ QPushButton::mousePressEvent(e);
}
void AeroButton::mouseReleaseEvent(QMouseEvent * e)
{
Q_UNUSED(e);
-
+
d->pressed = false;
- this->repaint();
+ this->update();
+
+ QPushButton::mouseReleaseEvent(e);
}
+}
|
| |   |
| 17 | 17 | * Free Software Foundation, Inc., * |
| 18 | 18 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
| 19 | 19 | ***************************************************************************/ |
| 20 | |
| 20 | 21 | #include "mainwindow.h" |
| 21 | 22 | |
| 23 | #include "private/centralwidget.h" |
| 24 | |
| 22 | 25 | namespace SIF { |
| 23 | 26 | |
| 27 | struct MainWindow::Private { |
| 28 | SIFPrivate::CentralWidget *central; |
| 29 | }; |
| 30 | |
| 24 | 31 | MainWindow::MainWindow(QWidget *parent) |
| 25 | | : QMainWindow(parent) |
| 32 | : QMainWindow(parent), d(new Private) |
| 26 | 33 | { |
| 34 | d->central = new SIFPrivate::CentralWidget; |
| 35 | |
| 36 | |
| 37 | setCentralWidget(d->central); |
| 27 | 38 | } |
| 28 | 39 | |
| 29 | | |
| 30 | 40 | MainWindow::~MainWindow() |
| 31 | 41 | { |
| 42 | delete d; |
| 32 | 43 | } |
| 33 | 44 | |
| 34 | 45 | |
| toggle raw diff |
--- a/src/sif/mainwindow.cpp
+++ b/src/sif/mainwindow.cpp
@@ -17,18 +17,29 @@
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
+
#include "mainwindow.h"
+#include "private/centralwidget.h"
+
namespace SIF {
+struct MainWindow::Private {
+ SIFPrivate::CentralWidget *central;
+};
+
MainWindow::MainWindow(QWidget *parent)
- : QMainWindow(parent)
+ : QMainWindow(parent), d(new Private)
{
+ d->central = new SIFPrivate::CentralWidget;
+
+
+ setCentralWidget(d->central);
}
-
MainWindow::~MainWindow()
{
+ delete d;
}
|
| |   |
| 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 "buttonarea.h" |
| 22 | |
| 23 | #include <QHBoxLayout> |
| 24 | |
| 25 | #include "aerobutton.h" |
| 26 | |
| 27 | namespace SIFPrivate { |
| 28 | |
| 29 | ButtonArea::ButtonArea(QWidget *parent) |
| 30 | : QWidget(parent) |
| 31 | { |
| 32 | QHBoxLayout *layout = new QHBoxLayout(this); |
| 33 | |
| 34 | SIF::AeroButton *b1 = new SIF::AeroButton("Button 1"); |
| 35 | b1->setRoundness(10); |
| 36 | |
| 37 | SIF::AeroButton *b2 = new SIF::AeroButton("Button 2"); |
| 38 | b2->setRoundness(10); |
| 39 | |
| 40 | SIF::AeroButton *b3 = new SIF::AeroButton("Button 3"); |
| 41 | b3->setRoundness(10); |
| 42 | |
| 43 | layout->addWidget(b1); |
| 44 | layout->addWidget(b2); |
| 45 | layout->addWidget(b3); |
| 46 | } |
| 47 | |
| 48 | |
| 49 | ButtonArea::~ButtonArea() |
| 50 | { |
| 51 | } |
| 52 | |
| 53 | |
| 54 | } |
| toggle raw diff |
--- /dev/null
+++ b/src/sif/private/buttonarea.cpp
@@ -0,0 +1,54 @@
+/***************************************************************************
+ * 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 "buttonarea.h"
+
+#include <QHBoxLayout>
+
+#include "aerobutton.h"
+
+namespace SIFPrivate {
+
+ButtonArea::ButtonArea(QWidget *parent)
+ : QWidget(parent)
+{
+ QHBoxLayout *layout = new QHBoxLayout(this);
+
+ SIF::AeroButton *b1 = new SIF::AeroButton("Button 1");
+ b1->setRoundness(10);
+
+ SIF::AeroButton *b2 = new SIF::AeroButton("Button 2");
+ b2->setRoundness(10);
+
+ SIF::AeroButton *b3 = new SIF::AeroButton("Button 3");
+ b3->setRoundness(10);
+
+ layout->addWidget(b1);
+ layout->addWidget(b2);
+ layout->addWidget(b3);
+}
+
+
+ButtonArea::~ButtonArea()
+{
+}
+
+
+} |
| |   |
| 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 | #ifndef SIFPRIVATEBUTTONAREA_H |
| 21 | #define SIFPRIVATEBUTTONAREA_H |
| 22 | |
| 23 | #include <QWidget> |
| 24 | |
| 25 | namespace SIFPrivate { |
| 26 | |
| 27 | /** |
| 28 | @author David Cuadrado <krawek@gmail.com> |
| 29 | */ |
| 30 | class ButtonArea : public QWidget |
| 31 | { |
| 32 | Q_OBJECT; |
| 33 | public: |
| 34 | ButtonArea(QWidget *parent = 0); |
| 35 | ~ButtonArea(); |
| 36 | |
| 37 | private: |
| 38 | |
| 39 | }; |
| 40 | |
| 41 | } |
| 42 | |
| 43 | #endif |
| toggle raw diff |
--- /dev/null
+++ b/src/sif/private/buttonarea.h
@@ -0,0 +1,43 @@
+/***************************************************************************
+ * 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. *
+ ***************************************************************************/
+#ifndef SIFPRIVATEBUTTONAREA_H
+#define SIFPRIVATEBUTTONAREA_H
+
+#include <QWidget>
+
+namespace SIFPrivate {
+
+/**
+ @author David Cuadrado <krawek@gmail.com>
+*/
+class ButtonArea : public QWidget
+{
+ Q_OBJECT;
+ public:
+ ButtonArea(QWidget *parent = 0);
+ ~ButtonArea();
+
+ private:
+
+};
+
+}
+
+#endif |
| |   |
| 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 "stackedwidget.h" |
| 25 | |
| 26 | #include <QVBoxLayout> |
| 27 | |
| 28 | namespace SIFPrivate { |
| 29 | |
| 30 | CentralWidget::CentralWidget(QWidget *parent) |
| 31 | : QWidget(parent) |
| 32 | { |
| 33 | QVBoxLayout *layout = new QVBoxLayout(this); |
| 34 | layout->setMargin(0); |
| 35 | |
| 36 | m_header = new HeaderWidget; |
| 37 | m_stack = new StackedWidget; |
| 38 | |
| 39 | layout->addWidget(m_header); |
| 40 | layout->addWidget(m_stack); |
| 41 | |
| 42 | |
| 43 | } |
| 44 | |
| 45 | |
| 46 | CentralWidget::~CentralWidget() |
| 47 | { |
| 48 | } |
| 49 | |
| 50 | |
| 51 | } |
| toggle raw diff |
--- /dev/null
+++ b/src/sif/private/centralwidget.cpp
@@ -0,0 +1,51 @@
+/***************************************************************************
+ * 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 "centralwidget.h"
+
+#include "headerwidget.h"
+#include "stackedwidget.h"
+
+#include <QVBoxLayout>
+
+namespace SIFPrivate {
+
+CentralWidget::CentralWidget(QWidget *parent)
+ : QWidget(parent)
+{
+ QVBoxLayout *layout = new QVBoxLayout(this);
+ layout->setMargin(0);
+
+ m_header = new HeaderWidget;
+ m_stack = new StackedWidget;
+
+ layout->addWidget(m_header);
+ layout->addWidget(m_stack);
+
+
+}
+
+
+CentralWidget::~CentralWidget()
+{
+}
+
+
+} |
| |   |
| 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 | #ifndef SIFPRIVATECENTRALWIDGET_H |
| 21 | #define SIFPRIVATECENTRALWIDGET_H |
| 22 | |
| 23 | #include <QWidget> |
| 24 | |
| 25 | namespace SIFPrivate { |
| 26 | |
| 27 | class HeaderWidget; |
| 28 | class StackedWidget; |
| 29 | |
| 30 | /** |
| 31 | @author David Cuadrado <krawek@gmail.com> |
| 32 | */ |
| 33 | class CentralWidget : public QWidget |
| 34 | { |
| 35 | Q_OBJECT; |
| 36 | public: |
| 37 | CentralWidget(QWidget *parent = 0); |
| 38 | ~CentralWidget(); |
| 39 | |
| 40 | private: |
| 41 | HeaderWidget *m_header; |
| 42 | StackedWidget *m_stack; |
| 43 | }; |
| 44 | |
| 45 | } |
| 46 | |
| 47 | #endif |
| toggle raw diff |
--- /dev/null
+++ b/src/sif/private/centralwidget.h
@@ -0,0 +1,47 @@
+/***************************************************************************
+ * 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. *
+ ***************************************************************************/
+#ifndef SIFPRIVATECENTRALWIDGET_H
+#define SIFPRIVATECENTRALWIDGET_H
+
+#include <QWidget>
+
+namespace SIFPrivate {
+
+class HeaderWidget;
+class StackedWidget;
+
+/**
+ @author David Cuadrado <krawek@gmail.com>
+*/
+class CentralWidget : public QWidget
+{
+ Q_OBJECT;
+ public:
+ CentralWidget(QWidget *parent = 0);
+ ~CentralWidget();
+
+ private:
+ HeaderWidget *m_header;
+ StackedWidget *m_stack;
+};
+
+}
+
+#endif |
| |   |
| 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 | #include "clickablelabel.h" |
| 21 | |
| 22 | namespace SIFPrivate { |
| 23 | |
| 24 | ClickableLabel::ClickableLabel(QWidget *parent) |
| 25 | : QLabel(parent) |
| 26 | { |
| 27 | setCursor(Qt::PointingHandCursor); |
| 28 | } |
| 29 | |
| 30 | ClickableLabel::ClickableLabel(const QString &text, QWidget *parent) : QLabel(text, parent) |
| 31 | { |
| 32 | setCursor(Qt::PointingHandCursor); |
| 33 | } |
| 34 | |
| 35 | ClickableLabel::~ClickableLabel() |
| 36 | { |
| 37 | } |
| 38 | |
| 39 | void ClickableLabel::mouseReleaseEvent(QMouseEvent *e) |
| 40 | { |
| 41 | QLabel::mouseReleaseEvent(e); |
| 42 | emit clicked(); |
| 43 | } |
| 44 | |
| 45 | } |
| toggle raw diff |
--- /dev/null
+++ b/src/sif/private/clickablelabel.cpp
@@ -0,0 +1,45 @@
+/***************************************************************************
+ * 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 "clickablelabel.h"
+
+namespace SIFPrivate {
+
+ClickableLabel::ClickableLabel(QWidget *parent)
+ : QLabel(parent)
+{
+ setCursor(Qt::PointingHandCursor);
+}
+
+ClickableLabel::ClickableLabel(const QString &text, QWidget *parent) : QLabel(text, parent)
+{
+ setCursor(Qt::PointingHandCursor);
+}
+
+ClickableLabel::~ClickableLabel()
+{
+}
+
+void ClickableLabel::mouseReleaseEvent(QMouseEvent *e)
+{
+ QLabel::mouseReleaseEvent(e);
+ emit clicked();
+}
+
+} |
| |   |
| 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 | #ifndef SIFPRIVATECLICKABLELABEL_H |
| 21 | #define SIFPRIVATECLICKABLELABEL_H |
| 22 | |
| 23 | #include <QLabel> |
| 24 | |
| 25 | namespace SIFPrivate { |
| 26 | |
| 27 | /** |
| 28 | @author David Cuadrado <krawek@gmail.com> |
| 29 | */ |
| 30 | class ClickableLabel : public QLabel |
| 31 | { |
| 32 | Q_OBJECT; |
| 33 | public: |
| 34 | ClickableLabel(QWidget *parent = 0); |
| 35 | ClickableLabel(const QString &text, QWidget *parent = 0); |
| 36 | ~ClickableLabel(); |
| 37 | |
| 38 | signals: |
| 39 | void clicked(); |
| 40 | |
| 41 | protected: |
| 42 | void mouseReleaseEvent(QMouseEvent *e); |
| 43 | }; |
| 44 | |
| 45 | } |
| 46 | |
| 47 | #endif |
| toggle raw diff |
--- /dev/null
+++ b/src/sif/private/clickablelabel.h
@@ -0,0 +1,47 @@
+/***************************************************************************
+ * 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. *
+ ***************************************************************************/
+#ifndef SIFPRIVATECLICKABLELABEL_H
+#define SIFPRIVATECLICKABLELABEL_H
+
+#include <QLabel>
+
+namespace SIFPrivate {
+
+/**
+ @author David Cuadrado <krawek@gmail.com>
+*/
+class ClickableLabel : public QLabel
+{
+ Q_OBJECT;
+ public:
+ ClickableLabel(QWidget *parent = 0);
+ ClickableLabel(const QString &text, QWidget *parent = 0);
+ ~ClickableLabel();
+
+ signals:
+ void clicked();
+
+ protected:
+ void mouseReleaseEvent(QMouseEvent *e);
+};
+
+}
+
+#endif |
| |   |
| 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 "headerwidget.h" |
| 22 | #include "buttonarea.h" |
| 23 | #include "clickablelabel.h" |
| 24 | |
| 25 | #include <QLinearGradient> |
| 26 | #include <QHBoxLayout> |
| 27 | |
| 28 | namespace SIFPrivate { |
| 29 | |
| 30 | HeaderWidget::HeaderWidget(QWidget *parent) |
| 31 | : QWidget(parent), m_border(Qt::black), m_shadow(Qt::darkGray) |
| 32 | { |
| 33 | QHBoxLayout *layout = new QHBoxLayout(this); |
| 34 | |
| 35 | m_title = new ClickableLabel("<H1>SIF</H1>"); |
| 36 | m_title->setIndent(20); |
| 37 | setFontColor(Qt::gray); |
| 38 | |
| 39 | m_buttonArea = new ButtonArea; |
| 40 | |
| 41 | layout->addWidget(m_title); |
| 42 | layout->addStretch(1); |
| 43 | layout->addWidget(m_buttonArea); |
| 44 | |
| 45 | setAutoFillBackground(true); |
| 46 | |
| 47 | connect(m_title, SIGNAL(clicked()), this, SIGNAL(titleClicked())); |
| 48 | } |
| 49 | |
| 50 | |
| 51 | HeaderWidget::~HeaderWidget() |
| 52 | { |
| 53 | } |
| 54 | |
| 55 | void HeaderWidget::setTitle(const QString &title) |
| 56 | { |
| 57 | m_title->setText(title); |
| 58 | } |
| 59 | |
| 60 | void HeaderWidget::setTitle(const QPixmap &title) |
| 61 | { |
| 62 | m_title->setPixmap(title); |
| 63 | } |
| 64 | |
| 65 | |
| 66 | void HeaderWidget::setBackground(const QBrush &background) |
| 67 | { |
| 68 | QPalette palette = this->palette(); |
| 69 | palette.setBrush(QPalette::Window, background); |
| 70 | |
| 71 | setPalette(palette); |
| 72 | } |
| 73 | |
| 74 | void HeaderWidget::setFontColor(const QColor &color) |
| 75 | { |
| 76 | QPalette palette = m_title->palette(); |
| 77 | palette.setBrush(QPalette::WindowText, color); |
| 78 | |
| 79 | m_title->setPalette(palette); |
| 80 | } |
| 81 | |
| 82 | void HeaderWidget::resizeEvent(QResizeEvent *e) |
| 83 | { |
| 84 | QWidget::resizeEvent(e); |
| 85 | |
| 86 | QRect br = rect(); |
| 87 | QLinearGradient gradient(0, 0, 0, br.height()); |
| 88 | |
| 89 | gradient.setColorAt(0.0, m_border); |
| 90 | gradient.setColorAt(0.1, m_shadow); |
| 91 | |
| 92 | |
| 93 | gradient.setColorAt(0.5, m_border); |
| 94 | gradient.setColorAt(0.55, m_border); |
| 95 | |
| 96 | gradient.setColorAt(0.9, m_shadow); |
| 97 | gradient.setColorAt(1.0, m_border); |
| 98 | |
| 99 | setBackground(gradient); |
| 100 | } |
| 101 | |
| 102 | } |
| toggle raw diff |
--- /dev/null
+++ b/src/sif/private/headerwidget.cpp
@@ -0,0 +1,102 @@
+/***************************************************************************
+ * 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, o |