34
|
1 |
/****************************************************************************
|
|
2 |
**
|
|
3 |
** Copyright (C) 2008-2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
4 |
** All rights reserved.
|
|
5 |
** Contact: Nokia Corporation (developer.feedback@nokia.com)
|
|
6 |
**
|
|
7 |
** This file is part of the HbApps module of the UI Extensions for Mobile.
|
|
8 |
**
|
|
9 |
** GNU Lesser General Public License Usage
|
|
10 |
** This file may be used under the terms of the GNU Lesser General Public
|
|
11 |
** License version 2.1 as published by the Free Software Foundation and
|
|
12 |
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
|
13 |
** Please review the following information to ensure the GNU Lesser General
|
|
14 |
** Public License version 2.1 requirements will be met:
|
|
15 |
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
16 |
**
|
|
17 |
** In addition, as a special exception, Nokia gives you certain additional
|
|
18 |
** rights. These rights are described in the Nokia Qt LGPL Exception
|
|
19 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
20 |
**
|
|
21 |
** If you have questions regarding the use of this file, please contact
|
|
22 |
** Nokia at developer.feedback@nokia.com.
|
|
23 |
**
|
|
24 |
****************************************************************************/
|
|
25 |
|
|
26 |
#include <hbdocumentloader.h>
|
|
27 |
#include <hbdeviceprofile.h>
|
|
28 |
#include <hblabel.h>
|
|
29 |
#include <hbmainwindow.h>
|
|
30 |
|
|
31 |
#include <hbmenu.h>
|
|
32 |
#include <hbaction.h>
|
|
33 |
#include <hbapplication.h>
|
|
34 |
#include <hbtoolbar.h>
|
|
35 |
|
|
36 |
#include "infoview.h"
|
|
37 |
|
|
38 |
InfoView::InfoView(HbDocumentLoader* loader, HbMainWindow *window) :
|
|
39 |
mWindow(window),
|
|
40 |
mLoader(loader),
|
|
41 |
mResolutionLabel(0),
|
|
42 |
mOrientationLabel(0),
|
|
43 |
mLayoutDirectionLabel(0)
|
|
44 |
{
|
|
45 |
setupLayout();
|
|
46 |
refreshLabels();
|
|
47 |
connect(mWindow, SIGNAL(orientationChanged(Qt::Orientation)), this, SLOT(updateLayout()));
|
|
48 |
connect(mWindow, SIGNAL(currentViewChanged(HbView*)), this, SLOT(refreshLabels()));
|
|
49 |
setTitle("Current values");
|
|
50 |
|
|
51 |
HbToolBar *toolbar = new HbToolBar;
|
|
52 |
HbAction *action = new HbAction("settings");
|
|
53 |
connect(action, SIGNAL(triggered()), SLOT(goToSettingsView()));
|
|
54 |
toolbar->addAction(action);
|
|
55 |
setToolBar(toolbar);
|
|
56 |
}
|
|
57 |
|
|
58 |
void InfoView::setupLayout()
|
|
59 |
{
|
|
60 |
HbDeviceProfile currentProfile = HbDeviceProfile::profile(mWindow);
|
|
61 |
QString section = currentProfile.orientation() == Qt::Horizontal ? "landscape" : "portrait";
|
|
62 |
mLoader->load(QString(":/appxml/hbs60deviceconfigapp.docml"), section);
|
|
63 |
QGraphicsWidget* infoWidget = mLoader->findWidget("infoView");
|
|
64 |
if (infoWidget) {
|
|
65 |
QGraphicsWidget* oldWidget = takeWidget();
|
|
66 |
if (oldWidget)
|
|
67 |
oldWidget->setVisible(false);
|
|
68 |
infoWidget->setVisible(true);
|
|
69 |
setWidget(infoWidget);
|
|
70 |
}
|
|
71 |
|
|
72 |
mResolutionLabel = qobject_cast<HbLabel *>(mLoader->findWidget("resolutionInfoValue"));
|
|
73 |
mOrientationLabel = qobject_cast<HbLabel *>(mLoader->findWidget("orientationInfoValue"));
|
|
74 |
mLayoutDirectionLabel = qobject_cast<HbLabel *>(mLoader->findWidget("directionInfoValue"));
|
|
75 |
}
|
|
76 |
|
|
77 |
void InfoView::refreshLabels()
|
|
78 |
{
|
|
79 |
HbDeviceProfile currentProfile = HbDeviceProfile::profile(mWindow);
|
|
80 |
mResolutionLabel->setPlainText(currentProfile.name());
|
|
81 |
mOrientationLabel->setPlainText(currentProfile.orientation() == Qt::Vertical ? QString("Portrait") : QString("Landscape"));
|
|
82 |
mLayoutDirectionLabel->setPlainText(HbApplication::layoutDirection() == Qt::LeftToRight ? "Left to Right" : "Right to Left");
|
|
83 |
}
|
|
84 |
|
|
85 |
void InfoView::updateLayout()
|
|
86 |
{
|
|
87 |
setupLayout();
|
|
88 |
refreshLabels();
|
|
89 |
}
|
|
90 |
|
|
91 |
void InfoView::goToSettingsView()
|
|
92 |
{
|
|
93 |
mainWindow()->setCurrentView(mSettingsView);
|
|
94 |
}
|
|
95 |
|
|
96 |
void InfoView::setSettingsView(HbView *view)
|
|
97 |
{
|
|
98 |
mSettingsView = view;
|
|
99 |
}
|