diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemodeviceconfigurations.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemodeviceconfigurations.cpp new file mode 100644 index 0000000000000000000000000000000000000000..93de6c28406b2597a2afe6c0250928f8abe2feaa --- /dev/null +++ b/src/plugins/qt4projectmanager/qt-maemo/maemodeviceconfigurations.cpp @@ -0,0 +1,124 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of Qt Creator. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, 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. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "maemodeviceconfigurations.h" + +#include + +#include + +namespace Qt4ProjectManager { +namespace Internal { + +namespace { + const QLatin1String SettingsGroup("MaemoDeviceConfigs"); + const QLatin1String ConfigListKey("ConfigList"); + const QLatin1String NameKey("Name"); + const QLatin1String TypeKey("Type"); + const QLatin1String HostKey("Host"); + const QLatin1String PortKey("Port"); + const QLatin1String UserNameKey("Uname"); + const QLatin1String PasswordKey("Password"); + const QLatin1String TimeoutKey("Timeout"); +}; + +MaemoDeviceConfigurations::DeviceConfig::DeviceConfig(const QString &name) + : name(name), type(Physical) +{ +} + +MaemoDeviceConfigurations::DeviceConfig::DeviceConfig(const QSettings &settings) + : name(settings.value(NameKey).toString()), + type(static_cast(settings.value(TypeKey, Physical).toInt())), + host(settings.value(HostKey).toString()), + port(settings.value(PortKey, 22).toInt()), + uname(settings.value(UserNameKey).toString()), + pwd(settings.value(PasswordKey).toString()), + timeout(settings.value(TimeoutKey, 30).toInt()) +{ +} + +void MaemoDeviceConfigurations::DeviceConfig::save(QSettings &settings) const +{ + settings.setValue(NameKey, name); + settings.setValue(TypeKey, type); + settings.setValue(HostKey, host); + settings.setValue(PortKey, port); + settings.setValue(UserNameKey, uname); + settings.setValue(PasswordKey, pwd); + settings.setValue(TimeoutKey, timeout); +} + +void MaemoDeviceConfigurations::setDevConfigs(const QList &devConfigs) +{ + m_devConfigs = devConfigs; + save(); +} + +MaemoDeviceConfigurations &MaemoDeviceConfigurations::instance() +{ + static MaemoDeviceConfigurations configs; + return configs; +} + +void MaemoDeviceConfigurations::save() +{ + QSettings *settings = Core::ICore::instance()->settings(); + settings->beginGroup(SettingsGroup); + settings->beginWriteArray(ConfigListKey, m_devConfigs.count()); + foreach (const DeviceConfig &devConfig, m_devConfigs) + devConfig.save(*settings); + settings->endArray(); + settings->endGroup(); +} + +MaemoDeviceConfigurations::MaemoDeviceConfigurations() +{ + load(); +} + + +void MaemoDeviceConfigurations::load() +{ + QSettings *settings = Core::ICore::instance()->settings(); + settings->beginGroup(SettingsGroup); + int count = settings->beginReadArray(ConfigListKey); + for (int i = 0; i < count; ++i) + m_devConfigs.append(DeviceConfig(*settings)); + settings->endArray(); + settings->endGroup(); +} + +} // namespace Internal +} // namespace Qt4ProjectManager diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemodeviceconfigurations.h b/src/plugins/qt4projectmanager/qt-maemo/maemodeviceconfigurations.h new file mode 100644 index 0000000000000000000000000000000000000000..cccd166222f82c2047c3c938e364d89ea571d7c7 --- /dev/null +++ b/src/plugins/qt4projectmanager/qt-maemo/maemodeviceconfigurations.h @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Creator. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, 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. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef MAEMODEVICECONFIGURATIONS_H +#define MAEMODEVICECONFIGURATIONS_H + +#include +#include +#include + +QT_BEGIN_NAMESPACE +class QSettings; +QT_END_NAMESPACE + +namespace Qt4ProjectManager { +namespace Internal { + +class MaemoDeviceConfigurations +{ +public: + class DeviceConfig + { + public: + enum DeviceType { Physical, Simulator }; + DeviceConfig(const QString &name); + DeviceConfig(const QSettings &settings); + void save(QSettings &settings) const; + QString name; + DeviceType type; + QString host; + int port; + QString uname; + QString pwd; + int timeout; + }; + + static MaemoDeviceConfigurations &instance(); + QList devConfigs() const { return m_devConfigs; } + void setDevConfigs(const QList &devConfigs); + +private: + MaemoDeviceConfigurations(); + MaemoDeviceConfigurations(const MaemoDeviceConfigurations &); + MaemoDeviceConfigurations& operator=(const MaemoDeviceConfigurations &); + void load(); + void save(); + + QList m_devConfigs; +}; + +} // namespace Internal +} // namespace Qt4ProjectManager + +#endif // MAEMODEVICECONFIGURATIONS_H diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemomanager.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemomanager.cpp index 2d1049ee5da8314b303870a20f01fc3087e9272b..72f20ccde866add1ace73db0843f91c85130a92d 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemomanager.cpp +++ b/src/plugins/qt4projectmanager/qt-maemo/maemomanager.cpp @@ -29,6 +29,7 @@ #include "maemomanager.h" +#include "maemosettingspage.h" #include "maemotoolchain.h" #include "maemorunconfiguration.h" @@ -56,6 +57,7 @@ MaemoManager::MaemoManager() : QObject(0) , m_runControlFactory(new MaemoRunControlFactory(this)) , m_runConfigurationFactory(new MaemoRunConfigurationFactory(this)) + , m_settingsPage(new MaemoSettingsPage(this)) , m_qemuCommand(0) { @@ -65,12 +67,14 @@ MaemoManager::MaemoManager() ExtensionSystem::PluginManager::instance()->addObject(m_runControlFactory); ExtensionSystem::PluginManager::instance()->addObject(m_runConfigurationFactory); + ExtensionSystem::PluginManager::instance()->addObject(m_settingsPage); } MaemoManager::~MaemoManager() { ExtensionSystem::PluginManager::instance()->removeObject(m_runControlFactory); ExtensionSystem::PluginManager::instance()->removeObject(m_runConfigurationFactory); + ExtensionSystem::PluginManager::instance()->removeObject(m_settingsPage); } MaemoManager *MaemoManager::instance() diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemomanager.h b/src/plugins/qt4projectmanager/qt-maemo/maemomanager.h index f76c83346ab4e0238ec82931d8d4c33b8cc9df0a..445cd63648036cfcc9afe4ee832900e9a708e7bc 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/maemomanager.h +++ b/src/plugins/qt4projectmanager/qt-maemo/maemomanager.h @@ -57,6 +57,7 @@ namespace Qt4ProjectManager { class MaemoRunControlFactory; class MaemoRunConfigurationFactory; +class MaemoSettingsPage; class MaemoManager : public QObject { @@ -90,6 +91,7 @@ private: MaemoRunControlFactory *m_runControlFactory; MaemoRunConfigurationFactory *m_runConfigurationFactory; + MaemoSettingsPage *m_settingsPage; QIcon icon; int m_runCount; diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemosettingspage.cpp b/src/plugins/qt4projectmanager/qt-maemo/maemosettingspage.cpp new file mode 100644 index 0000000000000000000000000000000000000000..bc5b35bf5f410eba8db8e2a5c437d80cfc6fe8c6 --- /dev/null +++ b/src/plugins/qt4projectmanager/qt-maemo/maemosettingspage.cpp @@ -0,0 +1,189 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Assistant of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, 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. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include + +#include "maemodeviceconfigurations.h" + +#include "ui_maemosettingswidget.h" +#include "maemosettingspage.h" + +#include + +namespace Qt4ProjectManager { +namespace Internal { + +#define PAGE_ID "Maemo Device Configurations" + +class DevConfMatcher +{ +public: + DevConfMatcher(const QString &name) : m_name(name) {} + bool operator()(const MaemoDeviceConfigurations::DeviceConfig &devConfig) + { + return devConfig.name == m_name; + } +private: + const QString m_name; +}; + + +class MaemoSettingsWidget : public QWidget +{ + Q_OBJECT +public: + MaemoSettingsWidget(QWidget *parent); + void saveSettings(); +private: + void initGui(); + void addConfig(); + void display(const MaemoDeviceConfigurations::DeviceConfig &devConfig); + + Ui_maemoSettingsWidget *m_ui; + QList m_devConfs; +}; + +MaemoSettingsPage::MaemoSettingsPage(QObject *parent) + : Core::IOptionsPage(parent), m_widget(0) +{ + +} + +MaemoSettingsPage::~MaemoSettingsPage() +{ +} + +QString MaemoSettingsPage::id() const +{ + return QLatin1String(PAGE_ID); +} + +QString MaemoSettingsPage::trName() const +{ + return tr(PAGE_ID); +} + +QString MaemoSettingsPage::category() const +{ + return Constants::QT_CATEGORY; +} + +QString MaemoSettingsPage::trCategory() const +{ + return tr(Constants::QT_CATEGORY); +} + +QWidget *MaemoSettingsPage::createPage(QWidget *parent) +{ + if (m_widget != 0) + delete m_widget; + m_widget = new MaemoSettingsWidget(parent); + return m_widget; +} + +void MaemoSettingsPage::apply() +{ + m_widget->saveSettings(); +} + +void MaemoSettingsPage::finish() +{ + apply(); +} + +MaemoSettingsWidget::MaemoSettingsWidget(QWidget *parent) + : QWidget(parent), + m_ui(new Ui_maemoSettingsWidget), + m_devConfs(MaemoDeviceConfigurations::instance().devConfigs()) + +{ + initGui(); +} + +void MaemoSettingsWidget::initGui() +{ + m_ui->setupUi(this); + foreach(const MaemoDeviceConfigurations::DeviceConfig &devConf, m_devConfs) + m_ui->configListWidget->addItem(devConf.name); +} + +void MaemoSettingsWidget::addConfig() +{ + QLatin1String prefix("New Device Configuration "); + int suffix = 1; + QString newName; + bool isUnique = false; + do { + newName = prefix + QString::number(suffix++); + isUnique = std::find_if(m_devConfs.constBegin(), m_devConfs.constEnd(), + DevConfMatcher(newName)) == m_devConfs.constEnd(); + } while (!isUnique); + + m_devConfs.append(MaemoDeviceConfigurations::DeviceConfig(newName)); + m_ui->configListWidget->addItem(newName); + // TODO: select and display new item (selection should automatically lead to display) + // also mark configuration name to suggest overwriting +} + +void MaemoSettingsWidget::display(const MaemoDeviceConfigurations::DeviceConfig &devConfig) +{ + m_ui->nameLineEdit->setText(devConfig.name); + if (devConfig.type == MaemoDeviceConfigurations::DeviceConfig::Physical) + m_ui->deviceButton->setEnabled(true); + else + m_ui->simulatorButton->setEnabled(true); + m_ui->hostLineEdit->setText(devConfig.host); + m_ui->portLineEdit->setText(QString::number(devConfig.port)); + m_ui->timeoutLineEdit->setText(QString::number(devConfig.timeout)); + m_ui->userLineEdit->setText(devConfig.uname); + m_ui->pwdLineEdit->setText(devConfig.pwd); + m_ui->detailsWidget->setEnabled(true); +} + +void MaemoSettingsWidget::saveSettings() +{ + MaemoDeviceConfigurations::instance().setDevConfigs(m_devConfs); +} + +} // namespace Internal +} // namespace Qt4ProjectManager + +#include "maemosettingspage.moc" diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemosettingspage.h b/src/plugins/qt4projectmanager/qt-maemo/maemosettingspage.h new file mode 100644 index 0000000000000000000000000000000000000000..0b9171ad8d7fa6e5461b31836c6b2298c9daf51e --- /dev/null +++ b/src/plugins/qt4projectmanager/qt-maemo/maemosettingspage.h @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Assistant of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, 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. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef MAEMOSETTINGSPAGE_H +#define MAEMOSETTINGSPAGE_H + +#include + +namespace Qt4ProjectManager{ +namespace Internal { + +class MaemoSettingsWidget; + +class MaemoSettingsPage : public Core::IOptionsPage +{ + Q_OBJECT +public: + MaemoSettingsPage(QObject *parent); + ~MaemoSettingsPage(); + + virtual QString id() const; + virtual QString trName() const; + virtual QString category() const; + virtual QString trCategory() const; + virtual QWidget *createPage(QWidget *parent); + virtual void apply(); + virtual void finish(); + +private: + MaemoSettingsWidget *m_widget; +}; + +} // namespace Internal +} // namespace Qt4ProjectManager + +#endif // MAEMOSETTINGSPAGE_H diff --git a/src/plugins/qt4projectmanager/qt-maemo/maemosettingswidget.ui b/src/plugins/qt4projectmanager/qt-maemo/maemosettingswidget.ui new file mode 100644 index 0000000000000000000000000000000000000000..d073cd856612658a470339c93140b7421da1043c --- /dev/null +++ b/src/plugins/qt4projectmanager/qt-maemo/maemosettingswidget.ui @@ -0,0 +1,173 @@ + + + maemoSettingsWidget + + + + 0 + 0 + 515 + 372 + + + + Maemo Device Configurations + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + + + false + + + + + + Configuration Name: + + + + + + + + + + Device type: + + + + + + + + 0 + + + 0 + + + + + Remote Device + + + + + + + Local Simulator + + + + + + + + + + Host Name: + + + + + + + + + + Port: + + + + + + + + + + Connection Timeout: + + + + + + + + + + User Name: + + + + + + + + + + Password: + + + + + + + QLineEdit::Password + + + + + + + + + + + + + + + Add + + + + + + + Remove + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + diff --git a/src/plugins/qt4projectmanager/qt-maemo/qt-maemo.pri b/src/plugins/qt4projectmanager/qt-maemo/qt-maemo.pri index 31d800c74a4ff3311aa3232d305dad8e5082cc5c..ddece1230dc7cfb0816f347a02de59b6513e3a53 100644 --- a/src/plugins/qt4projectmanager/qt-maemo/qt-maemo.pri +++ b/src/plugins/qt4projectmanager/qt-maemo/qt-maemo.pri @@ -1,14 +1,18 @@ SUPPORT_QT_MAEMO = $$(QTCREATOR_WITH_MAEMO) -!isEmpty(SUPPORT_QT_MAEMO) { +!isEmpty(SUPPORT_QT_MAEMO) { message("Adding experimental support for Qt/Maemo applications.") DEFINES += QTCREATOR_WITH_MAEMO - HEADERS += \ - $$PWD/maemorunconfiguration.h \ + HEADERS += $$PWD/maemorunconfiguration.h \ $$PWD/maemomanager.h \ - $$PWD/maemotoolchain.h - SOURCES += \ - $$PWD/maemorunconfiguration.cpp \ + $$PWD/maemotoolchain.h \ + $$PWD/maemodeviceconfigurations.h \ + $$PWD/maemosettingspage.h + SOURCES += $$PWD/maemorunconfiguration.cpp \ $$PWD/maemomanager.cpp \ - $$PWD/maemotoolchain.cpp + $$PWD/maemotoolchain.cpp \ + $$PWD/maemodeviceconfigurations.cpp \ + $$PWD/maemosettingspage.cpp + FORMS += $$PWD/maemosettingswidget.ui + RESOURCES += $$PWD/qt-maemo.qrc }