maemosettingspages.cpp 6.91 KB
Newer Older
hjk's avatar
hjk committed
1
/**************************************************************************
2
**
hjk's avatar
hjk committed
3
** This file is part of Qt Creator
4
**
hjk's avatar
hjk committed
5
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
6
**
hjk's avatar
hjk committed
7
** Contact: Nokia Corporation (info@qt.nokia.com)
8
9
**
** GNU Lesser General Public License Usage
hjk's avatar
hjk committed
10
11
12
13
14
15
16
**
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17
18
**
** In addition, as a special exception, Nokia gives you certain additional
hjk's avatar
hjk committed
19
** rights. These rights are described in the Nokia Qt LGPL Exception
20
21
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
22
** Other Usage
23
**
hjk's avatar
hjk committed
24
25
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
26
**
hjk's avatar
hjk committed
27
** If you have questions regarding the use of this file, please contact
Tobias Hunger's avatar
Tobias Hunger committed
28
** Nokia at info@qt.nokia.com.
29
**
hjk's avatar
hjk committed
30
**************************************************************************/
31
32
33
34
35

#include "maemosettingspages.h"

#include "maemoconstants.h"
#include "maemodeviceconfigurationssettingswidget.h"
36
#include "maemoqemusettings.h"
37
38
#include "maemoqemusettingswidget.h"

39
40
#include <coreplugin/icore.h>

41
#include <QtCore/QCoreApplication>
42
43
44
45
46
#include <QtGui/QDialog>
#include <QtGui/QDialogButtonBox>
#include <QtGui/QFrame>
#include <QtGui/QLabel>
#include <QtGui/QVBoxLayout>
47
#include <QtGui/QIcon>
48
#include <QtGui/QMainWindow>
49

50
namespace RemoteLinux {
51
namespace Internal {
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
namespace {
class MaemoQemuCrashDialog : public QDialog
{
    Q_OBJECT
public:
    MaemoQemuCrashDialog(QWidget *parent = 0) : QDialog(parent)
    {
        setWindowTitle(tr("Qemu error"));
        QString message = tr("Qemu crashed.") + QLatin1String(" <p>");
        const MaemoQemuSettings::OpenGlMode openGlMode
            = MaemoQemuSettings::openGlMode();
        const QString linkString = QLatin1String("</p><a href=\"dummy\">")
            + tr("Click here to change the OpenGL mode.")
            + QLatin1String("</a>");
        if (openGlMode == MaemoQemuSettings::HardwareAcceleration) {
            message += tr("You have configured Qemu to use OpenGL "
                "hardware acceleration, which might not be supported by "
                "your system. You could try using software rendering instead.");
            message += linkString;
        } else if (openGlMode == MaemoQemuSettings::AutoDetect) {
            message += tr("Qemu is currently configured to auto-detect the "
                "OpenGL mode, which is known to not work in some cases. "
                "You might want to use software rendering instead.");
            message += linkString;
        }
        QLabel * const messageLabel = new QLabel(message, this);
        messageLabel->setWordWrap(true);
        messageLabel->setTextFormat(Qt::RichText);
        connect(messageLabel, SIGNAL(linkActivated(QString)),
            SLOT(showSettingsPage()));
        QVBoxLayout *mainLayout = new QVBoxLayout(this);
        mainLayout->addWidget(messageLabel);
        QFrame * const separator = new QFrame;
        separator->setFrameShape(QFrame::HLine);
        separator->setFrameShadow(QFrame::Sunken);
        mainLayout->addWidget(separator);
        QDialogButtonBox * const buttonBox = new QDialogButtonBox;
        buttonBox->addButton(QDialogButtonBox::Ok);
        connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
        mainLayout->addWidget(buttonBox);
    }

private:
    Q_SLOT void showSettingsPage()
    {
        Core::ICore::instance()->showOptionsDialog(MaemoQemuSettingsPage::Category,
            MaemoQemuSettingsPage::Id);
        accept();
    }
};

} // anonymous namespace
104
105
106
107
108
109
110
111
112
113
114
115

MaemoDeviceConfigurationsSettingsPage::MaemoDeviceConfigurationsSettingsPage(QObject *parent)
    : Core::IOptionsPage(parent)
{
}

MaemoDeviceConfigurationsSettingsPage::~MaemoDeviceConfigurationsSettingsPage()
{
}

QString MaemoDeviceConfigurationsSettingsPage::id() const
{
116
    return Id;
117
118
119
120
}

QString MaemoDeviceConfigurationsSettingsPage::displayName() const
{
121
    return tr("Device Configurations");
122
123
124
125
}

QString MaemoDeviceConfigurationsSettingsPage::category() const
{
126
    return Category;
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
}

QString MaemoDeviceConfigurationsSettingsPage::displayCategory() const
{
    return QCoreApplication::translate("Qt4ProjectManager",
        Constants::MAEMO_SETTINGS_TR_CATEGORY);
}

QIcon MaemoDeviceConfigurationsSettingsPage::categoryIcon() const
{
    return QIcon(QLatin1String(Constants::MAEMO_SETTINGS_CATEGORY_ICON));
}

bool MaemoDeviceConfigurationsSettingsPage::matches(const QString &searchKeyWord) const
{
    return m_keywords.contains(searchKeyWord, Qt::CaseInsensitive);
}

QWidget *MaemoDeviceConfigurationsSettingsPage::createPage(QWidget *parent)
{
    m_widget = new MaemoDeviceConfigurationsSettingsWidget(parent);
    if (m_keywords.isEmpty())
        m_keywords = m_widget->searchKeywords();
    return m_widget;
}

void MaemoDeviceConfigurationsSettingsPage::apply()
{
    m_widget->saveSettings();
}

void MaemoDeviceConfigurationsSettingsPage::finish()
{
}

162
163
164
165
166
const QString MaemoDeviceConfigurationsSettingsPage::Id
    = QLatin1String("ZZ.Maemo Device Configurations");
const QString MaemoDeviceConfigurationsSettingsPage::Category
    = QLatin1String(Constants::MAEMO_SETTINGS_CATEGORY);

167
168
169
170
171
172
173
174
175
176
177
178

MaemoQemuSettingsPage::MaemoQemuSettingsPage(QObject *parent)
    : Core::IOptionsPage(parent)
{
}

MaemoQemuSettingsPage::~MaemoQemuSettingsPage()
{
}

QString MaemoQemuSettingsPage::id() const
{
179
    return Id;
180
181
182
183
}

QString MaemoQemuSettingsPage::displayName() const
{
184
    return tr("MeeGo Qemu Settings");
185
186
187
188
}

QString MaemoQemuSettingsPage::category() const
{
189
    return Category;
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
}

QString MaemoQemuSettingsPage::displayCategory() const
{
    return QCoreApplication::translate("Qt4ProjectManager",
        Constants::MAEMO_SETTINGS_TR_CATEGORY);
}

QIcon MaemoQemuSettingsPage::categoryIcon() const
{
    return QIcon(QLatin1String(Constants::MAEMO_SETTINGS_CATEGORY_ICON));
}

bool MaemoQemuSettingsPage::matches(const QString &searchKeyWord) const
{
    return m_widget->keywords().contains(searchKeyWord, Qt::CaseInsensitive);
}

QWidget *MaemoQemuSettingsPage::createPage(QWidget *parent)
{
    m_widget = new MaemoQemuSettingsWidget(parent);
    return m_widget;
}

void MaemoQemuSettingsPage::apply()
{
    m_widget->saveSettings();
}

void MaemoQemuSettingsPage::finish()
{
}

223
224
void MaemoQemuSettingsPage::showQemuCrashDialog()
{
225
    MaemoQemuCrashDialog dlg(Core::ICore::instance()->mainWindow());
226
227
228
    dlg.exec();
}

229
230
231
232
const QString MaemoQemuSettingsPage::Id = QLatin1String("ZZ.Qemu Settings");
const QString MaemoQemuSettingsPage::Category
    = QLatin1String(Constants::MAEMO_SETTINGS_CATEGORY);

233
} // namespace Internal
234
} // namespace RemoteLinux
235
236

#include "maemosettingspages.moc"