~ubuntu-branches/ubuntu/precise/gwenview/precise-proposed

« back to all changes in this revision

Viewing changes to lib/hudwidget.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2011-12-15 14:17:54 UTC
  • mto: This revision was merged to the branch mainline in revision 12.
  • Revision ID: package-import@ubuntu.com-20111215141754-z043hyx69dulbggf
Tags: upstream-4.7.90
Import upstream version 4.7.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// vim: set tabstop=4 shiftwidth=4 noexpandtab:
 
1
// vim: set tabstop=4 shiftwidth=4 expandtab:
2
2
/*
3
3
Gwenview: an image viewer
4
4
Copyright 2008 Aurélien Gâteau <agateau@kde.org>
32
32
// Local
33
33
#include "fullscreentheme.h"
34
34
 
35
 
namespace Gwenview {
36
 
 
 
35
namespace Gwenview
 
36
{
37
37
 
38
38
struct HudWidgetPrivate {
39
 
        QWidget* mMainWidget;
40
 
        QToolButton* mCloseButton;
 
39
    QWidget* mMainWidget;
 
40
    QToolButton* mCloseButton;
41
41
};
42
42
 
43
 
 
44
43
HudWidget::HudWidget(QWidget* parent)
45
44
: QFrame(parent)
46
 
, d(new HudWidgetPrivate) {
47
 
        d->mMainWidget = 0;
48
 
        d->mCloseButton = 0;
49
 
}
50
 
 
51
 
 
52
 
HudWidget::~HudWidget() {
53
 
        delete d;
54
 
}
55
 
 
56
 
 
57
 
void HudWidget::init(QWidget* mainWidget, Options options) {
58
 
        d->mMainWidget = mainWidget;
59
 
        if (d->mMainWidget) {
60
 
                d->mMainWidget->setParent(this);
61
 
                if (d->mMainWidget->layout()) {
62
 
                        d->mMainWidget->layout()->setMargin(0);
63
 
                }
64
 
        }
65
 
 
66
 
        if (options & OptionOpaque) {
67
 
                setProperty("opaque", QVariant(true));
68
 
        }
69
 
 
70
 
        FullScreenTheme theme(FullScreenTheme::currentThemeName());
71
 
        setStyleSheet(theme.styleSheet());
72
 
 
73
 
        QHBoxLayout* layout = new QHBoxLayout(this);
74
 
        layout->setMargin(4);
75
 
        if (d->mMainWidget) {
76
 
                layout->addWidget(d->mMainWidget);
77
 
        }
78
 
        if (options & OptionDoNotFollowChildSize) {
79
 
                adjustSize();
80
 
        } else {
81
 
                layout->setSizeConstraint(QLayout::SetFixedSize);
82
 
        }
83
 
 
84
 
        if (options & OptionCloseButton) {
85
 
                d->mCloseButton = new QToolButton(this);
86
 
                d->mCloseButton->setAutoRaise(true);
87
 
                d->mCloseButton->setIcon(SmallIcon("window-close"));
88
 
                layout->addWidget(d->mCloseButton, 0, Qt::AlignTop | Qt::AlignHCenter);
89
 
 
90
 
                connect(d->mCloseButton, SIGNAL(clicked()), SLOT(slotCloseButtonClicked()));
91
 
        }
92
 
}
93
 
 
94
 
 
95
 
QWidget* HudWidget::mainWidget() const {
96
 
        return d->mMainWidget;
97
 
}
98
 
 
99
 
 
100
 
void HudWidget::slotCloseButtonClicked() {
101
 
        close();
102
 
        closed();
103
 
}
104
 
 
 
45
, d(new HudWidgetPrivate)
 
46
{
 
47
    d->mMainWidget = 0;
 
48
    d->mCloseButton = 0;
 
49
}
 
50
 
 
51
HudWidget::~HudWidget()
 
52
{
 
53
    delete d;
 
54
}
 
55
 
 
56
void HudWidget::init(QWidget* mainWidget, Options options)
 
57
{
 
58
    d->mMainWidget = mainWidget;
 
59
    if (d->mMainWidget) {
 
60
        d->mMainWidget->setParent(this);
 
61
        if (d->mMainWidget->layout()) {
 
62
            d->mMainWidget->layout()->setMargin(0);
 
63
        }
 
64
    }
 
65
 
 
66
    if (options & OptionOpaque) {
 
67
        setProperty("opaque", QVariant(true));
 
68
    }
 
69
 
 
70
    FullScreenTheme theme(FullScreenTheme::currentThemeName());
 
71
    setStyleSheet(theme.styleSheet());
 
72
 
 
73
    QHBoxLayout* layout = new QHBoxLayout(this);
 
74
    layout->setMargin(4);
 
75
    if (d->mMainWidget) {
 
76
        layout->addWidget(d->mMainWidget);
 
77
    }
 
78
    if (options & OptionDoNotFollowChildSize) {
 
79
        adjustSize();
 
80
    } else {
 
81
        layout->setSizeConstraint(QLayout::SetFixedSize);
 
82
    }
 
83
 
 
84
    if (options & OptionCloseButton) {
 
85
        d->mCloseButton = new QToolButton(this);
 
86
        d->mCloseButton->setAutoRaise(true);
 
87
        d->mCloseButton->setIcon(SmallIcon("window-close"));
 
88
        layout->addWidget(d->mCloseButton, 0, Qt::AlignTop | Qt::AlignHCenter);
 
89
 
 
90
        connect(d->mCloseButton, SIGNAL(clicked()), SLOT(slotCloseButtonClicked()));
 
91
    }
 
92
}
 
93
 
 
94
QWidget* HudWidget::mainWidget() const
 
95
{
 
96
    return d->mMainWidget;
 
97
}
 
98
 
 
99
void HudWidget::slotCloseButtonClicked()
 
100
{
 
101
    close();
 
102
    closed();
 
103
}
105
104
 
106
105
} // namespace