Commit dae4dccac1b35dd53a2e52a108deb7a5a2e7a6dc

Support footer buttons

Commit diff

examples/frameless/main.cpp

 
3737int main(int argc, char **argv)
3838{
3939 QApplication app(argc, argv);
40 app.setApplicationName("Example 2");
40 app.setApplicationName("Player");
4141
4242 SIF::MainWindow mw;
4343 mw.setWindowFlags(mw.windowFlags() | Qt::FramelessWindowHint);
4444 QObject::connect(&mw, SIGNAL(titleClicked()), qApp, SLOT(aboutQt()));
4545
46 mw.addPage("View", new QGraphicsView);
47
48
4649 SIF::View *view1 = new SIF::View;
47 view1->addPage("Calendar", new QCalendarWidget);
48 view1->addPage("Table", new QTableWidget(10, 10));
50 view1->addPage("Collection", new QCalendarWidget);
51 view1->addPage("Information", new QTableWidget(10, 10));
4952
50 mw.addPage("Data", view1);
53 mw.addPage("Music", view1);
5154
5255
5356 SIF::View *view2 = new SIF::View;
54 view2->addPage("Editor", new QTextEdit("An editor"));
55 view2->addPage("Dial", new QDial);
57 view2->addPage("Collection", new QTextEdit("An editor"));
58 view2->addPage("Information", new QDial);
5659
5760 QGraphicsView *qgv = new QGraphicsView;
5861 qgv->setRenderHints(QPainter::Antialiasing);
6868 view2->addPage("Graphics", qgv);
6969
7070
71 mw.addPage("View", view2);
71 mw.addPage("Video", view2);
7272
7373
7474 QObject::connect(mw.addButton("Quit"), SIGNAL(clicked()), &app, SLOT(closeAllWindows()));
toggle raw diff

src/sif/private/footerwidget.cpp

 
2020
2121#include "footerwidget.h"
2222#include "headerwidget.h"
23#include "buttonarea.h"
24#include "aerobutton.h"
2325
2426#include "mainwindow.h"
2527
2628#include <QApplication>
2729#include <QMouseEvent>
30#include <QHBoxLayout>
2831
2932namespace SIFPrivate {
3033
3535 : QWidget(parent), m_header(header), m_dragging(false)
3636{
3737 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);
3845}
3946
4047
5757 setPalette(palette);
5858}
5959
60SIF::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
6068void FooterWidget::resizeEvent(QResizeEvent *e)
6169{
6270 QWidget::resizeEvent(e);
toggle raw diff

src/sif/private/footerwidget.h

 
2121#define SIFPRIVATEFOOTERWIDGET_H
2222
2323#include <QWidget>
24#include <QIcon>
25
26namespace SIF {
27 class AeroButton;
28}
2429
2530namespace SIFPrivate {
2631class HeaderWidget;
32class ButtonArea;
2733
2834/**
2935 @author David Cuadrado <krawek@gmail.com>
4343
4444 void setBackground(const QBrush &background);
4545
46 SIF::AeroButton *addButton(const QString &title, const QIcon &icon = QIcon());
47
4648 protected:
4749 void resizeEvent(QResizeEvent *e);
4850 virtual void mousePressEvent(QMouseEvent *e);
5252 virtual void mouseReleaseEvent(QMouseEvent *e);
5353
5454 private:
55 ButtonArea *m_buttonArea;
5556 HeaderWidget *m_header;
5657 QPoint m_dragPosition;
5758 bool m_dragging;
toggle raw diff

src/sif/private/headerwidget.cpp

 
5050 m_buttonArea = new ButtonArea;
5151
5252 layout->addWidget(m_title);
53 layout->addStretch(2);
5354 layout->addWidget(m_buttonArea);
5455
5556 setAutoFillBackground(true);
toggle raw diff