1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
16 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 ** In addition, as a special exception, Nokia gives you certain additional
26 ** rights. These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
32 **************************************************************************/
34 #include "codepastersettings.h"
35 #include "cpasterconstants.h"
37 #include <coreplugin/icore.h>
39 #include <QtCore/QSettings>
40 #include <QtCore/QCoreApplication>
41 #include <QtGui/QLineEdit>
42 #include <QtGui/QFileDialog>
43 #include <QtGui/QGroupBox>
44 #include <QtGui/QFormLayout>
45 #include <QtGui/QVBoxLayout>
46 #include <QtGui/QLabel>
47 #include <QtCore/QDebug>
48 #include <QtCore/QVariant>
50 static const char settingsGroupC[] = "CodePasterSettings";
51 static const char serverKeyC[] = "Server";
53 namespace CodePaster {
55 CodePasterSettingsPage::CodePasterSettingsPage()
57 m_settings = Core::ICore::instance()->settings();
59 const QString keyRoot = QLatin1String(settingsGroupC) + QLatin1Char('/');
60 m_host = m_settings->value(keyRoot + QLatin1String(serverKeyC), QString()).toString();
64 QString CodePasterSettingsPage::id() const
66 return QLatin1String("C.CodePaster");
69 QString CodePasterSettingsPage::displayName() const
71 return tr("CodePaster");
74 QString CodePasterSettingsPage::category() const
76 return QLatin1String(Constants::CPASTER_SETTINGS_CATEGORY);
79 QString CodePasterSettingsPage::displayCategory() const
81 return QCoreApplication::translate("CodePaster", Constants::CPASTER_SETTINGS_TR_CATEGORY);
84 QIcon CodePasterSettingsPage::categoryIcon() const
89 QWidget *CodePasterSettingsPage::createPage(QWidget *parent)
91 QWidget *outerWidget = new QWidget(parent);
92 QVBoxLayout *outerLayout = new QVBoxLayout(outerWidget);
94 QFormLayout *formLayout = new QFormLayout;
95 formLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
96 QLineEdit *lineEdit = new QLineEdit(m_host);
97 connect(lineEdit, SIGNAL(textChanged(QString)), this, SLOT(serverChanged(QString)));
98 formLayout->addRow(tr("Server:"), lineEdit);
99 outerLayout->addLayout(formLayout);
100 outerLayout->addSpacerItem(new QSpacerItem(0, 30, QSizePolicy::Ignored, QSizePolicy::Fixed));
102 QLabel *noteLabel = new QLabel(tr("Note: Specify the host name for the CodePaster service "
103 "without any protocol prepended (e.g. codepaster.mycompany.com)."));
104 noteLabel->setWordWrap(true);
105 outerLayout->addWidget(noteLabel);
107 outerLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding));
111 void CodePasterSettingsPage::apply()
116 m_settings->beginGroup(QLatin1String(settingsGroupC));
117 m_settings->setValue(QLatin1String(serverKeyC), m_host);
118 m_settings->endGroup();
121 void CodePasterSettingsPage::serverChanged(const QString &host)
126 QString CodePasterSettingsPage::hostName() const
130 } // namespace CodePaster