Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Tobias Hunger
qt-creator
Commits
4688634f
Commit
4688634f
authored
Nov 27, 2009
by
ck
Browse files
Maemo: Add initial version of settings page.
parent
0a3b9ed4
Changes
8
Hide whitespace changes
Inline
Side-by-side
src/plugins/qt4projectmanager/qt-maemo/maemodeviceconfigurations.cpp
0 → 100644
View file @
4688634f
/****************************************************************************
**
** 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
<coreplugin/icore.h>
#include
<QtCore/QSettings>
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
<
DeviceType
>
(
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
<
DeviceConfig
>
&
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
src/plugins/qt4projectmanager/qt-maemo/maemodeviceconfigurations.h
0 → 100644
View file @
4688634f
/****************************************************************************
**
** 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
<QtCore/QList>
#include
<QtCore/QString>
#include
<QtCore/QtGlobal>
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
<
DeviceConfig
>
devConfigs
()
const
{
return
m_devConfigs
;
}
void
setDevConfigs
(
const
QList
<
DeviceConfig
>
&
devConfigs
);
private:
MaemoDeviceConfigurations
();
MaemoDeviceConfigurations
(
const
MaemoDeviceConfigurations
&
);
MaemoDeviceConfigurations
&
operator
=
(
const
MaemoDeviceConfigurations
&
);
void
load
();
void
save
();
QList
<
DeviceConfig
>
m_devConfigs
;
};
}
// namespace Internal
}
// namespace Qt4ProjectManager
#endif // MAEMODEVICECONFIGURATIONS_H
src/plugins/qt4projectmanager/qt-maemo/maemomanager.cpp
View file @
4688634f
...
...
@@ -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
()
...
...
src/plugins/qt4projectmanager/qt-maemo/maemomanager.h
View file @
4688634f
...
...
@@ -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
;
...
...
src/plugins/qt4projectmanager/qt-maemo/maemosettingspage.cpp
0 → 100644
View file @
4688634f
/****************************************************************************
**
** 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
<qt4projectmanager/qt4projectmanagerconstants.h>
#include
"maemodeviceconfigurations.h"
#include
"ui_maemosettingswidget.h"
#include
"maemosettingspage.h"
#include
<algorithm>
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
<
MaemoDeviceConfigurations
::
DeviceConfig
>
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"
src/plugins/qt4projectmanager/qt-maemo/maemosettingspage.h
0 → 100644
View file @
4688634f
/****************************************************************************
**
** 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
<coreplugin/dialogs/ioptionspage.h>
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
src/plugins/qt4projectmanager/qt-maemo/maemosettingswidget.ui
0 → 100644
View file @
4688634f
<?xml version="1.0" encoding="UTF-8"?>
<ui
version=
"4.0"
>
<class>
maemoSettingsWidget
</class>
<widget
class=
"QWidget"
name=
"maemoSettingsWidget"
>
<property
name=
"geometry"
>
<rect>
<x>
0
</x>
<y>
0
</y>
<width>
515
</width>
<height>
372
</height>
</rect>
</property>
<property
name=
"windowTitle"
>
<string>
Maemo Device Configurations
</string>
</property>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout"
>
<item>
<widget
class=
"QFrame"
name=
"frame"
>
<property
name=
"frameShape"
>
<enum>
QFrame::StyledPanel
</enum>
</property>
<property
name=
"frameShadow"
>
<enum>
QFrame::Raised
</enum>
</property>
<layout
class=
"QVBoxLayout"
name=
"verticalLayout_2"
>
<item>
<widget
class=
"QListWidget"
name=
"configListWidget"
/>
</item>
<item>
<widget
class=
"QWidget"
name=
"detailsWidget"
native=
"true"
>
<property
name=
"enabled"
>
<bool>
false
</bool>
</property>
<layout
class=
"QFormLayout"
name=
"formLayout"
>
<item
row=
"0"
column=
"0"
>
<widget
class=
"QLabel"
name=
"label"
>
<property
name=
"text"
>
<string>
Configuration Name:
</string>
</property>
</widget>
</item>
<item
row=
"0"
column=
"1"
>
<widget
class=
"QLineEdit"
name=
"nameLineEdit"
/>
</item>
<item
row=
"1"
column=
"0"
>
<widget
class=
"QLabel"
name=
"label_2"
>
<property
name=
"text"
>
<string>
Device type:
</string>
</property>
</widget>
</item>
<item
row=
"1"
column=
"1"
>
<widget
class=
"QWidget"
name=
"widget_2"
native=
"true"
>
<layout
class=
"QHBoxLayout"
name=
"horizontalLayout_2"
>
<property
name=
"topMargin"
>
<number>
0
</number>
</property>
<property
name=
"bottomMargin"
>
<number>
0
</number>
</property>
<item>
<widget
class=
"QRadioButton"
name=
"deviceButton"
>
<property
name=
"text"
>
<string>
Remote Device
</string>
</property>
</widget>
</item>
<item>
<widget
class=
"QRadioButton"
name=
"simulatorButton"
>
<property
name=
"text"
>
<string>
Local Simulator
</string>
</property>
</widget>
</item>
</layout>