Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Q
qt-creator
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tobias Hunger
qt-creator
Commits
d76fa87f
Commit
d76fa87f
authored
Feb 09, 2010
by
Erik Verbruggen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a QML designer settings page.
parent
f796346a
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
427 additions
and
2 deletions
+427
-2
src/plugins/qmldesigner/designersettings.cpp
src/plugins/qmldesigner/designersettings.cpp
+67
-0
src/plugins/qmldesigner/designersettings.h
src/plugins/qmldesigner/designersettings.h
+59
-0
src/plugins/qmldesigner/qmldesignerplugin.cpp
src/plugins/qmldesigner/qmldesignerplugin.cpp
+23
-0
src/plugins/qmldesigner/qmldesignerplugin.h
src/plugins/qmldesigner/qmldesignerplugin.h
+9
-0
src/plugins/qmldesigner/qmldesignerplugin.pro
src/plugins/qmldesigner/qmldesignerplugin.pro
+7
-2
src/plugins/qmldesigner/settingspage.cpp
src/plugins/qmldesigner/settingspage.cpp
+114
-0
src/plugins/qmldesigner/settingspage.h
src/plugins/qmldesigner/settingspage.h
+91
-0
src/plugins/qmldesigner/settingspage.ui
src/plugins/qmldesigner/settingspage.ui
+57
-0
No files found.
src/plugins/qmldesigner/designersettings.cpp
0 → 100644
View file @
d76fa87f
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** 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.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#include "designersettings.h"
#include <QtCore/QSettings>
using
namespace
QmlDesigner
;
static
const
char
*
qmlGroup
=
"Qml"
;
static
const
char
*
qmlDesignerGroup
=
"Designer"
;
static
const
char
*
snapToGridKey
=
"SnapToGrid"
;
static
const
char
*
showBoundingRectanglesKey
=
"ShowBoundingRectangles"
;
void
DesignerSettings
::
fromSettings
(
QSettings
*
settings
)
{
settings
->
beginGroup
(
QLatin1String
(
qmlGroup
));
settings
->
beginGroup
(
QLatin1String
(
qmlDesignerGroup
));
snapToGrid
=
settings
->
value
(
QLatin1String
(
snapToGridKey
),
false
).
toBool
();
showBoundingRectangles
=
settings
->
value
(
QLatin1String
(
showBoundingRectanglesKey
),
false
).
toBool
();
settings
->
endGroup
();
settings
->
endGroup
();
}
void
DesignerSettings
::
toSettings
(
QSettings
*
settings
)
const
{
settings
->
beginGroup
(
QLatin1String
(
qmlGroup
));
settings
->
beginGroup
(
QLatin1String
(
qmlDesignerGroup
));
settings
->
setValue
(
QLatin1String
(
snapToGridKey
),
snapToGrid
);
settings
->
setValue
(
QLatin1String
(
showBoundingRectanglesKey
),
showBoundingRectangles
);
settings
->
endGroup
();
settings
->
endGroup
();
}
bool
DesignerSettings
::
equals
(
const
DesignerSettings
&
other
)
const
{
return
snapToGrid
==
other
.
snapToGrid
&&
showBoundingRectangles
==
other
.
showBoundingRectangles
;
}
src/plugins/qmldesigner/designersettings.h
0 → 100644
View file @
d76fa87f
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** 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.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#ifndef DESIGNERSETTINGS_H
#define DESIGNERSETTINGS_H
#include <QtCore/QtGlobal>
QT_BEGIN_NAMESPACE
class
QSettings
;
QT_END_NAMESPACE
namespace
QmlDesigner
{
struct
DesignerSettings
{
void
fromSettings
(
QSettings
*
);
void
toSettings
(
QSettings
*
)
const
;
bool
equals
(
const
DesignerSettings
&
other
)
const
;
bool
snapToGrid
;
bool
showBoundingRectangles
;
};
inline
bool
operator
==
(
const
DesignerSettings
&
s1
,
const
DesignerSettings
&
s2
)
{
return
s1
.
equals
(
s2
);
}
inline
bool
operator
!=
(
const
DesignerSettings
&
s1
,
const
DesignerSettings
&
s2
)
{
return
!
s1
.
equals
(
s2
);
}
}
// namespace QmlDesigner
#endif // DESIGNERSETTINGS_H
src/plugins/qmldesigner/qmldesignerplugin.cpp
View file @
d76fa87f
...
...
@@ -51,6 +51,8 @@
namespace
QmlDesigner
{
namespace
Internal
{
BauhausPlugin
*
BauhausPlugin
::
m_pluginInstance
=
0
;
BauhausPlugin
::
BauhausPlugin
()
:
m_designerCore
(
0
)
{
...
...
@@ -85,6 +87,8 @@ bool BauhausPlugin::initialize(const QStringList & /*arguments*/, QString *error
m_designerCore
=
new
QmlDesigner
::
IntegrationCore
;
m_pluginInstance
=
this
;
#ifdef Q_OS_MAC
const
QString
pluginPath
=
QCoreApplication
::
applicationDirPath
()
+
"/../PlugIns/QmlDesigner"
;
#else
...
...
@@ -105,6 +109,25 @@ void BauhausPlugin::extensionsInitialized()
{
}
BauhausPlugin
*
BauhausPlugin
::
pluginInstance
()
{
return
m_pluginInstance
;
}
DesignerSettings
BauhausPlugin
::
settings
()
const
{
return
m_settings
;
}
void
BauhausPlugin
::
setSettings
(
const
DesignerSettings
&
s
)
{
if
(
s
!=
m_settings
)
{
m_settings
=
s
;
if
(
QSettings
*
settings
=
Core
::
ICore
::
instance
()
->
settings
())
m_settings
.
toSettings
(
settings
);
}
}
}
}
...
...
src/plugins/qmldesigner/qmldesignerplugin.h
View file @
d76fa87f
...
...
@@ -30,6 +30,8 @@
#ifndef QMLDESIGNERPLUGIN_H
#define QMLDESIGNERPLUGIN_H
#include <qmldesigner/designersettings.h>
#include <extensionsystem/iplugin.h>
namespace
Core
{
...
...
@@ -58,8 +60,15 @@ public:
virtual
bool
initialize
(
const
QStringList
&
arguments
,
QString
*
error_message
=
0
);
virtual
void
extensionsInitialized
();
static
BauhausPlugin
*
pluginInstance
();
DesignerSettings
settings
()
const
;
void
setSettings
(
const
DesignerSettings
&
s
);
private:
QmlDesigner
::
IntegrationCore
*
m_designerCore
;
static
BauhausPlugin
*
m_pluginInstance
;
DesignerSettings
m_settings
;
};
}
// namespace Internal
...
...
src/plugins/qmldesigner/qmldesignerplugin.pro
View file @
d76fa87f
...
...
@@ -19,11 +19,16 @@ HEADERS += qmldesignerconstants.h \
qmldesignerplugin
.
h
\
designmode
.
h
\
designmodewidget
.
h
\
application
.
h
application
.
h
\
designersettings
.
h
\
settingspage
.
h
SOURCES
+=
qmldesignerplugin
.
cpp
\
designmode
.
cpp
\
designmodewidget
.
cpp
\
application
.
cpp
application
.
cpp
\
designersettings
.
cpp
\
settingspage
.
cpp
FORMS
+=
settingspage
.
ui
OTHER_FILES
+=
QmlDesigner
.
pluginspec
RESOURCES
+=
qmldesignerplugin
.
qrc
src/plugins/qmldesigner/settingspage.cpp
0 → 100644
View file @
d76fa87f
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** 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.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#include "designersettings.h"
#include "qmldesignerconstants.h"
#include "qmldesignerplugin.h"
#include "settingspage.h"
#include <QtCore/QTextStream>
#include <QtGui/QCheckBox>
using
namespace
QmlDesigner
;
using
namespace
QmlDesigner
::
Internal
;
SettingsPageWidget
::
SettingsPageWidget
(
QWidget
*
parent
)
:
QWidget
(
parent
)
{
m_ui
.
setupUi
(
this
);
}
DesignerSettings
SettingsPageWidget
::
settings
()
const
{
DesignerSettings
ds
;
ds
.
snapToGrid
=
m_ui
.
snapToGridCheckbox
->
isChecked
();
ds
.
showBoundingRectangles
=
m_ui
.
showBoundingRectanglesCheckbox
->
isChecked
();
return
ds
;
}
void
SettingsPageWidget
::
setSettings
(
const
DesignerSettings
&
s
)
{
m_ui
.
snapToGridCheckbox
->
setChecked
(
s
.
snapToGrid
);
m_ui
.
showBoundingRectanglesCheckbox
->
setChecked
(
s
.
showBoundingRectangles
);
}
QString
SettingsPageWidget
::
searchKeywords
()
const
{
QString
rc
;
QTextStream
(
&
rc
)
<<
m_ui
.
snapToGridCheckbox
->
text
()
<<
m_ui
.
showBoundingRectanglesCheckbox
->
text
()
<<
' '
<<
m_ui
.
groupBox
->
title
();
rc
.
remove
(
QLatin1Char
(
'&'
));
return
rc
;
}
SettingsPage
::
SettingsPage
()
:
m_widget
(
0
)
{
}
QString
SettingsPage
::
id
()
const
{
return
QLatin1String
(
"QmlDesigner"
);
}
QString
SettingsPage
::
displayName
()
const
{
return
tr
(
"Designer"
);
}
QString
SettingsPage
::
category
()
const
{
return
QLatin1String
(
"Qml"
);
}
QString
SettingsPage
::
displayCategory
()
const
{
return
QCoreApplication
::
translate
(
"Qml"
,
"QML"
);
}
QWidget
*
SettingsPage
::
createPage
(
QWidget
*
parent
)
{
m_widget
=
new
SettingsPageWidget
(
parent
);
m_widget
->
setSettings
(
BauhausPlugin
::
pluginInstance
()
->
settings
());
if
(
m_searchKeywords
.
isEmpty
())
m_searchKeywords
=
m_widget
->
searchKeywords
();
return
m_widget
;
}
void
SettingsPage
::
apply
()
{
BauhausPlugin
::
pluginInstance
()
->
setSettings
(
m_widget
->
settings
());
}
bool
SettingsPage
::
matches
(
const
QString
&
s
)
const
{
return
m_searchKeywords
.
contains
(
s
,
Qt
::
CaseInsensitive
);
}
src/plugins/qmldesigner/settingspage.h
0 → 100644
View file @
d76fa87f
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** 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.
**
** If you are unsure which license is appropriate for your use, please
** contact the sales department at http://qt.nokia.com/contact.
**
**************************************************************************/
#ifndef SETTINGSPAGE_H
#define SETTINGSPAGE_H
#include "ui_settingspage.h"
#include <coreplugin/dialogs/ioptionspage.h>
#include <QtGui/QWidget>
QT_BEGIN_NAMESPACE
class
QSettings
;
QT_END_NAMESPACE
namespace
QmlDesigner
{
class
DesignerSettings
;
namespace
Internal
{
class
SettingsPageWidget
:
public
QWidget
{
Q_OBJECT
public:
explicit
SettingsPageWidget
(
QWidget
*
parent
=
0
);
DesignerSettings
settings
()
const
;
void
setSettings
(
const
DesignerSettings
&
);
QString
searchKeywords
()
const
;
private:
Ui
::
SettingsPage
m_ui
;
};
class
SettingsPage
:
public
Core
::
IOptionsPage
{
Q_OBJECT
public:
SettingsPage
();
QString
id
()
const
;
QString
displayName
()
const
;
QString
category
()
const
;
QString
displayCategory
()
const
;
QWidget
*
createPage
(
QWidget
*
parent
);
void
apply
();
void
finish
()
{
}
virtual
bool
matches
(
const
QString
&
)
const
;
private:
QString
m_searchKeywords
;
SettingsPageWidget
*
m_widget
;
};
}
// namespace Internal
}
// namespace QmlDesigner
#endif // SETTINGSPAGE_H
src/plugins/qmldesigner/settingspage.ui
0 → 100644
View file @
d76fa87f
<?xml version="1.0" encoding="UTF-8"?>
<ui
version=
"4.0"
>
<class>
QmlDesigner::Internal::SettingsPage
</class>
<widget
class=
"QWidget"
name=
"QmlDesigner::Internal::SettingsPage"
>
<property
name=
"geometry"
>
<rect>
<x>
0
</x>
<y>
0
</y>
<width>
400
</width>
<height>
300
</height>
</rect>
</property>
<property
name=
"windowTitle"
>
<string>
Form
</string>
</property>
<layout
class=
"QVBoxLayout"
name=
"verticalLayout_2"
>
<item>
<widget
class=
"QGroupBox"
name=
"groupBox"
>
<property
name=
"title"
>
<string>
GroupBox
</string>
</property>
<layout
class=
"QVBoxLayout"
name=
"verticalLayout"
>
<item>
<widget
class=
"QCheckBox"
name=
"snapToGridCheckbox"
>
<property
name=
"text"
>
<string>
&
Snap to Grid
</string>
</property>
</widget>
</item>
<item>
<widget
class=
"QCheckBox"
name=
"showBoundingRectanglesCheckbox"
>
<property
name=
"text"
>
<string>
Show Bounding Rectangles
</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer
name=
"verticalSpacer"
>
<property
name=
"orientation"
>
<enum>
Qt::Vertical
</enum>
</property>
<property
name=
"sizeHint"
stdset=
"0"
>
<size>
<width>
20
</width>
<height>
207
</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment