~ubuntu-branches/ubuntu/saucy/mountmanager/saucy

« back to all changes in this revision

Viewing changes to sources/gui/menu.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Fabrice Coutadeur
  • Date: 2008-08-20 10:22:14 UTC
  • Revision ID: james.westby@ubuntu.com-20080820102214-fv93myu0ncb1503r
Tags: upstream-0.2.4
ImportĀ upstreamĀ versionĀ 0.2.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//MountManager - the program for easy mounting of storage devices in Linux
 
2
//Copyright (C) 2007-2008 Tikhonov Sergey
 
3
//
 
4
//This file is part of MountManager Gui
 
5
//
 
6
//This program is free software; you can redistribute it and/or
 
7
//modify it under the terms of the GNU General Public License
 
8
//as published by the Free Software Foundation; either version 2
 
9
//of the License, or (at your option) any later version.
 
10
//
 
11
//This program is distributed in the hope that it will be useful,
 
12
//but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
//GNU General Public License for more details.
 
15
//
 
16
//You should have received a copy of the GNU General Public License
 
17
//along with this program; if not, write to the Free Software
 
18
//Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
19
#include <QWidgetAction>
 
20
#include <QFrame>
 
21
#include <QHBoxLayout>
 
22
#include <QFont>
 
23
#include <QLabel>
 
24
#include <QStyle>
 
25
#include <QIcon>
 
26
#include "menu.h"
 
27
 
 
28
Menu::Menu(bool useSpecialHeader) {
 
29
        // Init
 
30
        headerAction = 0;
 
31
        headerActionFrame = 0;
 
32
        headerLabel = 0;
 
33
        iconLabel = 0;
 
34
        // Create header action if useSpecialHeader == true
 
35
        if (useSpecialHeader) {
 
36
                headerAction = new QWidgetAction(this);
 
37
                headerAction->setEnabled(false);
 
38
        
 
39
                headerActionFrame = new QFrame;
 
40
                headerActionFrame->setFrameShape(QFrame::Box);
 
41
        
 
42
                headerAction->setDefaultWidget(headerActionFrame);
 
43
        
 
44
                QHBoxLayout *headerActionFrameLayout = new QHBoxLayout();
 
45
                headerActionFrameLayout->setMargin(3);
 
46
                headerActionFrameLayout->setSpacing(3);
 
47
                headerActionFrame->setLayout(headerActionFrameLayout);
 
48
 
 
49
                iconLabel = new QLabel;
 
50
                headerLabel = new QLabel;
 
51
                
 
52
                iconSize = style()->pixelMetric(QStyle::PM_SmallIconSize);
 
53
                headerActionFrameLayout->insertWidget(-1,iconLabel,0);
 
54
                headerActionFrameLayout->insertWidget(-1,headerLabel,20);
 
55
                QFont font = headerLabel->font();
 
56
                font.setBold(true);
 
57
                headerLabel->setFont(font);
 
58
        
 
59
        
 
60
                addAction(headerAction);
 
61
        }
 
62
}
 
63
 
 
64
Menu::~Menu() {
 
65
        if (headerAction != 0) {
 
66
                delete headerLabel;
 
67
                delete iconLabel;
 
68
                delete headerActionFrame;
 
69
                delete headerAction;
 
70
        }
 
71
}
 
72
 
 
73
void Menu::setHeaderText(const QString &headerText) {
 
74
        if (headerLabel != 0)
 
75
                headerLabel->setText(headerText);
 
76
}
 
77
 
 
78
void Menu::setHeaderIcon(const QIcon &icon) {
 
79
        if (iconLabel != 0)
 
80
                iconLabel->setPixmap(icon.pixmap(iconSize,iconSize));
 
81
}
 
 
b'\\ No newline at end of file'