Merge remote-tracking branch 'origin/3.0'
Conflicts: qtcreator.pri qtcreator.qbs Change-Id: I91b9ceba836d01086e9ccdb4499436d17195b729
4
dist/gdb/Makefile.linux
vendored
@@ -66,9 +66,7 @@ ${staging}/gdb-${version}/configure: ${source}/gdb-${version}.tar.bz2 | makestag
|
||||
echo "Extracting gdb..." && \
|
||||
tar xf ${source}/gdb-${version}.tar.bz2 && \
|
||||
cd gdb-${version} && \
|
||||
touch configure && \
|
||||
patch -p1 < ${broot}/patches/pythonhome.patch && \
|
||||
patch -p2 < ${broot}/patches/gdb-ipv6.patch
|
||||
touch configure
|
||||
|
||||
${gdbtargets}: ${targetdir}/gdb-%: ${staging}/gdb-${version}/configure ${staging}/lib/libpython${pyversion}.a ${staging}/lib/libexpat.a | maketargetdir
|
||||
test -e ${staging}/gdb-${version}-$* || mkdir ${staging}/gdb-${version}-$*
|
||||
|
||||
4
dist/gdb/Makefile.mingw
vendored
@@ -72,9 +72,7 @@ ${staging}/gdb-${version}/configure: ${source}/gdb-${version}.tar.bz2 | makestag
|
||||
echo "Extracting gdb..." && \
|
||||
tar xf ${source}/gdb-${version}.tar.bz2 && \
|
||||
cd gdb-${version} && \
|
||||
touch configure && \
|
||||
patch -p2 < ${broot}/patches/gdb-ipv6.patch && \
|
||||
patch -p1 < ${broot}/patches/datadir.patch
|
||||
touch configure
|
||||
|
||||
${staging}/lib/libiconv.a: ${source}/libiconv-${iconvversion}.tar.gz | makestagingdir
|
||||
cd ${staging} && \
|
||||
|
||||
3
dist/gdb/Makefile.osx
vendored
@@ -65,8 +65,7 @@ ${staging}/gdb-${version}/configure: ${source}/gdb-${version}.tar.bz2 | makestag
|
||||
echo "Extracting gdb..." && \
|
||||
tar xf ${source}/gdb-${version}.tar.bz2 && \
|
||||
cd gdb-${version} && \
|
||||
touch configure && \
|
||||
patch -p2 < ${broot}/patches/gdb-ipv6.patch
|
||||
touch configure
|
||||
|
||||
${gdbtargets}: ${targetdir}/gdb-%: ${staging}/gdb-${version}/configure ${staging}/lib/libpython${pyversion}.a ${staging}/lib/libexpat.a | maketargetdir
|
||||
test -e ${staging}/gdb-${version}-$* || mkdir ${staging}/gdb-${version}-$*
|
||||
|
||||
142
dist/gdb/patches/datadir.patch
vendored
@@ -1,142 +0,0 @@
|
||||
Source: http://sourceware-org.1504.n7.nabble.com/PATCH-Try-to-initialize-data-directory-by-first-searching-for-quot-data-directory-quot-in-the-same-dy-td73462.html
|
||||
|
||||
orgads: Removed last dir separator before calling stat
|
||||
diff --git a/gdb/main.c b/gdb/main.c
|
||||
--- a/gdb/main.c
|
||||
+++ b/gdb/main.c
|
||||
@@ -98,17 +98,38 @@ static char *gdb_program_name;
|
||||
|
||||
static void print_gdb_help (struct ui_file *);
|
||||
|
||||
-/* Relocate a file or directory. PROGNAME is the name by which gdb
|
||||
- was invoked (i.e., argv[0]). INITIAL is the default value for the
|
||||
- file or directory. FLAG is true if the value is relocatable, false
|
||||
- otherwise. Returns a newly allocated string; this may return NULL
|
||||
- under the same conditions as make_relative_prefix. */
|
||||
+/* Relocate a file or directory, checking if it exists. PROGNAME is the
|
||||
+ name by which gdb was invoked (i.e., argv[0]). INITIAL is the default
|
||||
+ value for the file or directory. ISDIR is true if INITIAL is a
|
||||
+ directory. FLAG is true if the value is relocatable, false otherwise.
|
||||
+ Returns a newly allocated string; this may return NULL under the same
|
||||
+ conditions as make_relative_prefix, or if the relocated path does not
|
||||
+ exist. */
|
||||
|
||||
static char *
|
||||
-relocate_path (const char *progname, const char *initial, int flag)
|
||||
+relocate_path (const char *progname, const char *initial, int isdir,
|
||||
+ int flag)
|
||||
{
|
||||
if (flag)
|
||||
- return make_relative_prefix (progname, BINDIR, initial);
|
||||
+ {
|
||||
+ char *path;
|
||||
+ path = make_relative_prefix (progname, BINDIR, initial);
|
||||
+ if (path)
|
||||
+ {
|
||||
+ struct stat s;
|
||||
+
|
||||
+ char *last = path + strlen(path) - 1;
|
||||
+ if (IS_DIR_SEPARATOR(*last))
|
||||
+ *last = '\0';
|
||||
+
|
||||
+ if (*path == 0 || stat (path, &s) != 0 || (!isdir != !S_ISDIR (s.st_mode)))
|
||||
+ {
|
||||
+ xfree (path);
|
||||
+ path = NULL;
|
||||
+ }
|
||||
+ }
|
||||
+ return path;
|
||||
+ }
|
||||
return xstrdup (initial);
|
||||
}
|
||||
|
||||
@@ -123,19 +144,52 @@ relocate_gdb_directory (const char *init
|
||||
{
|
||||
char *dir;
|
||||
|
||||
- dir = relocate_path (gdb_program_name, initial, flag);
|
||||
- if (dir)
|
||||
+ dir = relocate_path (gdb_program_name, initial, 1, flag);
|
||||
+ if (!dir)
|
||||
+ dir = xstrdup (initial);
|
||||
+
|
||||
+ /* Canonicalize the directory. */
|
||||
+ if (*dir)
|
||||
{
|
||||
- struct stat s;
|
||||
+ char *canon_sysroot = lrealpath (dir);
|
||||
|
||||
- if (*dir == '\0' || stat (dir, &s) != 0 || !S_ISDIR (s.st_mode))
|
||||
+ if (canon_sysroot)
|
||||
{
|
||||
xfree (dir);
|
||||
- dir = NULL;
|
||||
+ dir = canon_sysroot;
|
||||
}
|
||||
}
|
||||
+
|
||||
+ return dir;
|
||||
+}
|
||||
+
|
||||
+/* Like relocate_gdb_path, but specifically for data-directory. */
|
||||
+
|
||||
+static char *
|
||||
+relocate_gdb_data_directory (void)
|
||||
+{
|
||||
+ char *dir;
|
||||
+
|
||||
+ /* First try to find "data-directory" in the same directory as gdb.
|
||||
+
|
||||
+ Use relocate_path only to resolve the parent directory of
|
||||
+ gdb_program_name (i.e., based on PATH if necessary); relocate_path
|
||||
+ (gdb_program_name, BINDIR "/data-directory") cannot be used to resolve
|
||||
+ data-directory as it returns a path relative to the _grandparent
|
||||
+ directory_ of gdb_program_name (munging the parent directory). */
|
||||
+
|
||||
+ dir = relocate_path (gdb_program_name, BINDIR, 1, 1);
|
||||
+ if (dir)
|
||||
+ dir = reconcat (dir, dir, SLASH_STRING, "data-directory", NULL);
|
||||
+
|
||||
+ /* Then try to find GDB_DATADIR relocated relative to gdb. */
|
||||
if (!dir)
|
||||
- dir = xstrdup (initial);
|
||||
+ dir = relocate_path (gdb_program_name, GDB_DATADIR, 1,
|
||||
+ GDB_DATADIR_RELOCATABLE);
|
||||
+
|
||||
+ /* Otherwise use GDB_DATADIR as is. */
|
||||
+ if (!dir)
|
||||
+ dir = xstrdup (GDB_DATADIR);
|
||||
|
||||
/* Canonicalize the directory. */
|
||||
if (*dir)
|
||||
@@ -169,7 +223,7 @@ get_init_files (char **system_gdbinit,
|
||||
|
||||
if (!initialized)
|
||||
{
|
||||
- struct stat homebuf, cwdbuf, s;
|
||||
+ struct stat homebuf, cwdbuf;
|
||||
char *homedir;
|
||||
|
||||
if (SYSTEM_GDBINIT[0])
|
||||
@@ -200,9 +254,10 @@ get_init_files (char **system_gdbinit,
|
||||
{
|
||||
relocated_sysgdbinit = relocate_path (gdb_program_name,
|
||||
SYSTEM_GDBINIT,
|
||||
+ 0,
|
||||
SYSTEM_GDBINIT_RELOCATABLE);
|
||||
}
|
||||
- if (relocated_sysgdbinit && stat (relocated_sysgdbinit, &s) == 0)
|
||||
+ if (relocated_sysgdbinit)
|
||||
sysgdbinit = relocated_sysgdbinit;
|
||||
else
|
||||
xfree (relocated_sysgdbinit);
|
||||
@@ -404,8 +459,7 @@ captured_main (void *data)
|
||||
debug_file_directory = relocate_gdb_directory (DEBUGDIR,
|
||||
DEBUGDIR_RELOCATABLE);
|
||||
|
||||
- gdb_datadir = relocate_gdb_directory (GDB_DATADIR,
|
||||
- GDB_DATADIR_RELOCATABLE);
|
||||
+ gdb_datadir = relocate_gdb_data_directory ();
|
||||
|
||||
#ifdef WITH_PYTHON_PATH
|
||||
{
|
||||
2426
dist/gdb/patches/gdb-buildid-locate.patch
vendored
1037
dist/gdb/patches/gdb-ipv6.patch
vendored
19
dist/gdb/patches/pythonhome.patch
vendored
@@ -1,19 +0,0 @@
|
||||
--- a/gdb/python/python.c 2013-03-28 18:46:53.000000000 +0200
|
||||
+++ b/gdb/python/python.c 2013-10-27 05:28:35.761204091 +0200
|
||||
@@ -1568,6 +1568,16 @@ message == an error message without a st
|
||||
#endif
|
||||
#endif
|
||||
|
||||
+
|
||||
+ char readlinkbuffer[BUFSIZ];
|
||||
+ int readlinks = readlink("/proc/self/exe", readlinkbuffer, BUFSIZ - 1);
|
||||
+ readlinkbuffer[readlinks] = 0;
|
||||
+ char *executeablepath = dirname(readlinkbuffer);
|
||||
+ char *pythonhome = malloc(strlen(executeablepath) + strlen("/python/") + 2);
|
||||
+ strcpy(pythonhome, executeablepath);
|
||||
+ strcat(pythonhome, "/python/");
|
||||
+ setenv("PYTHONHOME", pythonhome, 1);
|
||||
+
|
||||
Py_Initialize ();
|
||||
PyEval_InitThreads ();
|
||||
|
||||
@@ -7,7 +7,10 @@ imagedirs = $SRCDIR/images $SRCDIR/templates/images
|
||||
outputdir = $OUTDIR
|
||||
exampledirs = $SRCDIR/examples \
|
||||
$SRCDIR/snippets
|
||||
indexes = qt.index
|
||||
indexes += $QT_INSTALL_DOCS/qtwidgets/qtwidgets.index \
|
||||
$QT_INSTALL_DOCS/qtcore/qtcore.index \
|
||||
$QT_INSTALL_DOCS/qtqml/qtqml.index \
|
||||
$QT_INSTALL_DOCS/qtquick/qtquick.index
|
||||
|
||||
include(macros.qdocconf)
|
||||
include(qt-cpp-ignore.qdocconf)
|
||||
|
||||
@@ -51,7 +51,7 @@ my %next_define_skips = ();
|
||||
my %prev_polarity_skips = ();
|
||||
my %next_polarity_skips = ();
|
||||
for my $file (@files) {
|
||||
my ($curpage, $inhdr, $intoc, $inif) = ("", 0, 0, 0);
|
||||
my ($curpage, $inhdr, $havetoc, $intoc, $inif) = ("", 0, 0, 0, 0);
|
||||
my ($define_skip, $polarity_skip, $skipping) = ("", 0, 0);
|
||||
my ($prev_define_skip, $prev_polarity_skip, $prev_skip,
|
||||
$next_define_skip, $next_polarity_skip, $next_skip) = ("", 0, "", "", 0, "");
|
||||
@@ -73,7 +73,9 @@ for my $file (@files) {
|
||||
$inif = 0;
|
||||
$skipping = 0;
|
||||
$define_skip = "";
|
||||
} elsif (keys(%title2page) == 1 && /^\h*\\list/) {
|
||||
} elsif (keys(%title2page) == 1 && /^\h*\\section1 Table Of Contents/) {
|
||||
$havetoc = 1;
|
||||
} elsif ($havetoc && /^\h*\\list/) {
|
||||
$intoc++;
|
||||
} elsif ($intoc) {
|
||||
if (/^\h*\\endlist/) {
|
||||
@@ -111,6 +113,7 @@ for my $file (@files) {
|
||||
}
|
||||
} else {
|
||||
if (/^\h*\\contentspage\b/) {
|
||||
$havetoc = 0;
|
||||
$inhdr = 1;
|
||||
}
|
||||
}
|
||||
@@ -123,10 +126,14 @@ for my $file (@files) {
|
||||
my %prev = ();
|
||||
my %next = ();
|
||||
my $last = $doctitle;
|
||||
my $lastpage = $title2page{$last};
|
||||
for my $title (@toc) {
|
||||
$next{$last} = $title2page{$title};
|
||||
$prev{$title} = $title2page{$last};
|
||||
my $page = $title2page{$title};
|
||||
defined($page) or die "TOC refers to unknown page '$title'.\n";
|
||||
$next{$last} = $page;
|
||||
$prev{$title} = $lastpage;
|
||||
$last = $title;
|
||||
$lastpage = $page;
|
||||
}
|
||||
|
||||
for my $file (@files) {
|
||||
|
||||
|
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 58 KiB |
BIN
doc/images/qt-creator-debugging-helpers.png
Normal file
|
After Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 64 KiB |
BIN
doc/images/qtcreator-custom-parser.png
Normal file
|
After Width: | Height: | Size: 37 KiB |
|
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 33 KiB |
|
Before Width: | Height: | Size: 60 KiB After Width: | Height: | Size: 82 KiB |
|
Before Width: | Height: | Size: 79 KiB After Width: | Height: | Size: 58 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 57 KiB |
|
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 61 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 67 KiB |
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 88 KiB |
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 69 KiB |
|
Before Width: | Height: | Size: 5.9 KiB After Width: | Height: | Size: 12 KiB |
88243
doc/qt.index
@@ -239,7 +239,7 @@
|
||||
\contentspage index.html
|
||||
\previouspage creator-cache-profiler.html
|
||||
\page creator-running-valgrind-remotely.html
|
||||
\nextpage creator-publish-ovi.html
|
||||
\nextpage creator-advanced.html
|
||||
|
||||
\title Running Valgrind Tools Remotely
|
||||
|
||||
|
||||
@@ -106,8 +106,7 @@
|
||||
|
||||
\li To create an application, select \gui File >
|
||||
\gui {New File or Project} > \gui Applications >
|
||||
\gui {Qt Quick Application 1 (Built-in Elements)} or
|
||||
\gui {Qt Quick Application 2 (Built-in Elements)} > \gui Choose, and
|
||||
\gui {Qt Quick Application} > \gui Choose, and
|
||||
follow the instructions of the wizard. For more information, see
|
||||
\l{Creating Qt Quick Projects}.
|
||||
|
||||
@@ -149,7 +148,7 @@
|
||||
warning if it cannot find a suitable Qt version.
|
||||
|
||||
\li Select \gui File > \gui {New File or Project} > \gui Applications >
|
||||
\gui {Qt Quick Application 2 (Built-in Elements)} > \gui Choose, and
|
||||
\gui {Qt Quick Application} > \gui Choose, and
|
||||
follow the instructions of the wizard. For more information, see
|
||||
\l{Creating Qt Quick Projects}.
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
\list 1
|
||||
|
||||
\li Select \gui File > \gui {New File or Project} > \gui Applications >
|
||||
\gui {Qt Quick 2 Application (Qt Quick Controls)} > \gui Choose.
|
||||
\gui {Qt Quick Application} > \gui Choose.
|
||||
|
||||
\li In the \gui{Name} field, type \b{accelbubble}.
|
||||
|
||||
@@ -52,6 +52,9 @@
|
||||
For example, \c {C:\Qt\examples}, and then click \gui{Next} (or
|
||||
\gui Continue on Mac OS X).
|
||||
|
||||
\li In the \gui {Qt Quick component set} field, select
|
||||
\gui {Qt Quick Controls 1.0}.
|
||||
|
||||
\li Select an Android \l{glossary-buildandrun-kit}{kit} for ARM,
|
||||
and click \gui{Next}.
|
||||
|
||||
|
||||
@@ -31,9 +31,6 @@
|
||||
Linux device plugin. However, if the device does not have Qt libraries, you
|
||||
need a fake Qt installation.
|
||||
|
||||
Currently, you must use qmake to generate Makefiles for building the
|
||||
application.
|
||||
|
||||
The bare metal device type accepts custom GDB commands that you specify in
|
||||
the device options.
|
||||
|
||||
|
||||
@@ -1183,18 +1183,6 @@
|
||||
d.putSubItem("value", value)
|
||||
\endcode
|
||||
|
||||
|
||||
\section1 Debugging Helpers for QML
|
||||
|
||||
The debugging helpers for QML provide you with code completion for custom modules
|
||||
(\c qmldump) and debugging Qt Quick UI projects (\c qmlobserver).
|
||||
|
||||
You have to build the QML Inspector once for each Qt version that you want
|
||||
to debug
|
||||
with. Select \gui{Tools > Options > Build & Run > Qt Versions}.
|
||||
|
||||
\note QML Inspector requires Qt 4.7.1 or later.
|
||||
|
||||
\section1 Enabling Debugging Helpers for Qt's Bootstrapped Applications
|
||||
|
||||
Qt's bootstrapped applications (such as moc and qmake) are built in a way
|
||||
|
||||
@@ -30,12 +30,7 @@
|
||||
|
||||
\title Debugging Qt Quick Projects
|
||||
|
||||
\note You need Qt 4.7.1 or later to debug Qt Quick projects. Debugging
|
||||
projects not created with the Qt Quick wizards is only supported with
|
||||
Qt 4.8, or later.
|
||||
|
||||
To debug Qt Quick applications running on devices, you must install
|
||||
Qt 4.7.4, or later, libraries on devices.
|
||||
\note You need Qt 4.8 or later to debug Qt Quick projects.
|
||||
|
||||
For an example of how to debug Qt Quick Projects, see
|
||||
\l{Debugging a Qt Quick Example Application}.
|
||||
|
||||
@@ -34,13 +34,14 @@
|
||||
\e session. To restore the session automatically when you start \QC,
|
||||
select \gui {File > Session Manager > Restore last session on startup}.
|
||||
|
||||
A session is an arbitrary collection of:
|
||||
When you open or create any of the following items, they automatically
|
||||
become a part of the session:
|
||||
|
||||
\list
|
||||
|
||||
\li Open projects with their dependencies (including SUBDIRS projects)
|
||||
\li Projects with their dependencies (including SUBDIRS projects)
|
||||
|
||||
\li Open editors
|
||||
\li Editors
|
||||
|
||||
\li Breakpoints and expressions
|
||||
|
||||
@@ -54,8 +55,11 @@
|
||||
developers working on the same projects.
|
||||
|
||||
For example, if you work on a project and need to switch to another project
|
||||
for a while, you can save your workspace as a session. This makes it easier
|
||||
to return to working on the first project later.
|
||||
for a while, you can save your workspace as a session and then close the
|
||||
project and all the files in it. Everything that you open after saving the
|
||||
session becomes a part of a new session. When you want to return to working
|
||||
on the first project, open the saved session. \QC opens the projects and
|
||||
files that belong to the session.
|
||||
|
||||
To create a new session or remove existing sessions, select \gui File >
|
||||
\gui{Session Manager}.
|
||||
@@ -66,12 +70,12 @@
|
||||
not create or select a session, \QC always uses the default session, which
|
||||
was created the last time you exited \QC.
|
||||
|
||||
When you launch \QC, a list of existing sessions is displayed on the
|
||||
\gui{Welcome screen}.
|
||||
When you launch \QC, a list of existing sessions is displayed in the
|
||||
\gui Welcome mode.
|
||||
|
||||
\image qtcreator-welcome-session.png
|
||||
|
||||
When you start \QC from the command prompt, you can give the name of
|
||||
When you start \QC from the command line, you can give the name of
|
||||
a session as argument and \QC will start with this session.
|
||||
|
||||
For more information, see \l{Using Command Line Options}.
|
||||
|
||||
@@ -140,6 +140,11 @@
|
||||
For example, \c ssh-askpass or \c x11-ssh-askpass, depending on the
|
||||
ssh-askpass implementation that you use.
|
||||
|
||||
\li \gui {Patch command} specifies the path to the patch utility that is
|
||||
used to apply changes in the format used to represent the diff
|
||||
output. The \gui Revert command uses the patch utility to revert
|
||||
partial changes.
|
||||
|
||||
\endlist
|
||||
|
||||
\section1 Creating VCS Repositories for New Projects
|
||||
@@ -192,9 +197,10 @@
|
||||
\image qtcreator-vcs-diff.png
|
||||
|
||||
With Git, the diff is displayed side-by-side in a \l{Comparing Files}
|
||||
{diff editor} by default. To use the old diff view instead, select
|
||||
\gui Tools > \gui Options > \gui {Version Control} > \gui Git, and deselect
|
||||
the \gui {Show diff side-by-side} option.
|
||||
{diff editor} by default. To use the inline diff view instead, select the
|
||||
\gui {Switch to Text Diff Editor} option from the toolbar. In the inline
|
||||
diff view, you can use context menu commands to apply, revert, stage, and
|
||||
unstage hunks, as well as send them to a code pasting service.
|
||||
|
||||
\section2 Viewing Versioning History and Change Details
|
||||
|
||||
@@ -238,12 +244,13 @@
|
||||
|
||||
The \gui{Diff Selected Files} button brings up a diff view of the
|
||||
files selected in the file list. Since the commit page is just another
|
||||
editor, you can go back to it by closing the diff view. You can also check
|
||||
a diff view from the editor combo box showing the \gui{Opened files}.
|
||||
editor, you can go back to it by closing the diff view. You can also switch
|
||||
to an open diff view by selecting it in the \gui{Open Documents} pane in the
|
||||
sidebar.
|
||||
|
||||
\section2 Reverting Changes
|
||||
|
||||
All supported version control system support reverting your project to
|
||||
All supported version control systems support reverting your project to
|
||||
known states. This functionality is generally called \e reverting.
|
||||
|
||||
The changes discarded depend on the version control system.
|
||||
@@ -445,6 +452,12 @@
|
||||
\row
|
||||
\li \gui Rebase
|
||||
\li Copy local commits to the updated upstream head.
|
||||
\row
|
||||
\li \gui {Cherry Pick}
|
||||
\li Cherry pick the top commit from the selected branch.
|
||||
\row
|
||||
\li \gui Track
|
||||
\li Set the current branch to track the selected one.
|
||||
\endtable
|
||||
|
||||
\section4 Applying Patches
|
||||
@@ -568,6 +581,14 @@
|
||||
|
||||
\section3 Working with Git Tools
|
||||
|
||||
To start a graphical interface to Git, select \gui Tools > \gui Git >
|
||||
\gui {Git Tools} > \gui {Git Gui}.
|
||||
|
||||
\note On Mac OS X, the default Git installation does not contain Git Gui. To
|
||||
use Git Gui, install it separately. To start Git Gui from \QC, select
|
||||
\gui Preferences > \gui {Version Control} > \gui Git, and set the path to
|
||||
the environment that contains Git Gui in the \gui {Prepend to PATH} field.
|
||||
|
||||
To start the commit viewer for Git, select \gui Tools > \gui Git >
|
||||
\gui {Git Tools} > \gui Gitk. You can also start the tool to view commits in
|
||||
the current document or in the folder that contains the current document.
|
||||
|
||||
@@ -50,12 +50,8 @@
|
||||
|
||||
\li qtc-debugging-helper
|
||||
|
||||
\li qtc-qmldbg
|
||||
|
||||
\li qtc-qmldump
|
||||
|
||||
\li qtc-qmlobserver
|
||||
|
||||
\endlist
|
||||
|
||||
The location depends on the platform. On Linux and other Unix platforms, the files
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
/*!
|
||||
\contentspage index.html
|
||||
\previouspage creator-publish-ovi.html
|
||||
\previouspage creator-running-valgrind-remotely.html
|
||||
\page creator-advanced.html
|
||||
\nextpage creator-os-supported-platforms.html
|
||||
|
||||
|
||||
@@ -60,15 +60,4 @@
|
||||
the application files to the connected device. You can test and
|
||||
debug the application on the device.
|
||||
\endlist
|
||||
|
||||
\section1 Related Topics
|
||||
|
||||
\list
|
||||
\li \l{Publishing}
|
||||
|
||||
When you are ready to publish the application on a publishing
|
||||
channel, you must make sure that the installation file meets the
|
||||
requirements for publishing on the channel.
|
||||
\endlist
|
||||
|
||||
*/
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (c) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
**
|
||||
** GNU Free Documentation License
|
||||
**
|
||||
** Alternatively, this file may be used under the terms of the GNU Free
|
||||
** Documentation License version 1.3 as published by the Free Software
|
||||
** Foundation and appearing in the file included in the packaging of this
|
||||
** file.
|
||||
**
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
// **********************************************************************
|
||||
// NOTE: the sections are not ordered by their logical order to avoid
|
||||
// reshuffling the file each time the index order changes (i.e., often).
|
||||
// Run the fixnavi.pl script to adjust the links to the index order.
|
||||
// **********************************************************************
|
||||
|
||||
/*!
|
||||
\contentspage index.html
|
||||
\previouspage creator-running-valgrind-remotely.html
|
||||
\page creator-publish-ovi.html
|
||||
\nextpage creator-advanced.html
|
||||
|
||||
\title Publishing
|
||||
|
||||
\image creator_publishing.png
|
||||
|
||||
You can publish applications to app stores.
|
||||
|
||||
\endlist
|
||||
|
||||
*/
|
||||
@@ -39,8 +39,8 @@
|
||||
|
||||
\li \l{Developing Qt Quick Applications}
|
||||
|
||||
You can either create Qt Quick projects from scratch or import
|
||||
existing projects to \QC. You can use the code editor (Edit mode)
|
||||
You can use wizards to create Qt Quick projects that contain
|
||||
boiler-plate code. You can use the code editor (Edit mode)
|
||||
or the visual editor (Design mode) to develop Qt Quick applications.
|
||||
\li \l{Developing Widget Based Applications}
|
||||
|
||||
@@ -57,15 +57,4 @@
|
||||
applications for them.
|
||||
|
||||
\endlist
|
||||
|
||||
\section1 Related Topics
|
||||
|
||||
\list
|
||||
|
||||
\li \l{Adding Qt Designer Plugins}
|
||||
|
||||
You can use Qt APIs to create plugins that extend Qt applications.
|
||||
This enables you to add your own widgets to \QD.
|
||||
|
||||
\endlist
|
||||
*/
|
||||
|
||||
@@ -106,12 +106,12 @@
|
||||
Qt Quick applications.
|
||||
|
||||
For more information, see \l{Debugging and Analyzing}.
|
||||
\li \b {\l{Publishing}}
|
||||
\li \b {Publishing}
|
||||
|
||||
\QC allows you to create installation packages for mobile
|
||||
devices that are suitable for publishing to application stores
|
||||
and other channels. For more information, see
|
||||
\l{Publishing}.
|
||||
and other channels. You must make sure that the package contents
|
||||
meet the requirements for publishing on the channel.
|
||||
\endtable
|
||||
|
||||
*/
|
||||
|
||||
@@ -83,6 +83,14 @@
|
||||
\li In the \gui{Compiler path} field, enter the path to the directory
|
||||
where the compiler is located.
|
||||
|
||||
\li In the \gui {Platform codegen flags} field, check the flags passed
|
||||
to the compiler that specify the architecture on the target
|
||||
platform.
|
||||
|
||||
\li In the \gui {Platform linker flags} field, check the flags passed to
|
||||
the linker that specify the architecture on the target platform.
|
||||
The linker flags are used only when building with Qbs.
|
||||
|
||||
The other settings to specify depend on the compiler.
|
||||
|
||||
\endlist
|
||||
@@ -127,6 +135,31 @@
|
||||
where mkspecs are located. Usually, the path is specified relative
|
||||
to the Qt mkspecs directory.
|
||||
|
||||
\li In the \gui {Error parser} field, select the error parser to use.
|
||||
Select \gui Custom, and then select \gui {Customer Parser Settings}
|
||||
to specify settings for a custom parser:
|
||||
|
||||
\image qtcreator-custom-parser.png
|
||||
|
||||
\list 1
|
||||
|
||||
\li In the \gui {Error message capture pattern} field, specify
|
||||
a regular expression to define what is an error. The custom
|
||||
parser matches the compile output line by line against the
|
||||
regular expression and displays errors in the \gui Issues
|
||||
output pane. Create regular expression groups that contain
|
||||
the file name, line number and error message.
|
||||
|
||||
\li In the \gui {Capture Positions} field, map the regular
|
||||
expression groups to \gui {File name}, \gui {Line number},
|
||||
and \gui Message.
|
||||
|
||||
\li In the \gui {Test} group, you can test how the message that
|
||||
you enter in the \gui {Error message} field is matched when
|
||||
using the current settings.
|
||||
|
||||
\endlist
|
||||
|
||||
\endlist
|
||||
|
||||
\section1 Troubleshooting MinGW Compilation Errors
|
||||
|
||||
@@ -103,24 +103,12 @@
|
||||
Use \QD forms to design a Qt widget based user interface for the
|
||||
desktop and C++ to implement the application logic
|
||||
|
||||
\li Mobile Qt Application
|
||||
\li Qt Quick Application
|
||||
|
||||
Use \QD forms to design a Qt widget based user interface for
|
||||
mobile devices and C++ to implement the application logic.
|
||||
Select this template to develop for devices that support only
|
||||
Qt 4.6.x
|
||||
|
||||
\li Qt Quick Application (Built-in Types)
|
||||
|
||||
Use built-in QML types to design user interfaces based on
|
||||
Qt Quick 1 (Qt 4.7.1, or later) or Qt Quick 2 (Qt 5) with a
|
||||
custom look and feel and QML and C++ code to implement the
|
||||
application logic
|
||||
|
||||
\li Qt Quick Application (from Existing QML File)
|
||||
|
||||
Convert existing Qt Quick applications to projects that you
|
||||
can run in \QC or deploy to mobile devices
|
||||
Create a Qt Quick application that contains both QML and C++
|
||||
code. The project includes a QDeclarativeView or a QQuickView.
|
||||
You can build the application and deploy it to desktop and
|
||||
mobile target platforms.
|
||||
|
||||
\li Qt Console Application
|
||||
|
||||
|
||||
@@ -53,22 +53,27 @@
|
||||
|
||||
\li Select \gui {Tools > Options > Build & Run > Qt Versions > Add}.
|
||||
|
||||
\li Select the qmake executable for the Qt version that you want to
|
||||
add.
|
||||
|
||||
\li Select the Qt version to view and edit it.
|
||||
|
||||
\image qtcreator-qt4-qtversions-add.png
|
||||
|
||||
\li Select the directory where the qmake executable is located.
|
||||
|
||||
\QC automatically determines the path to the binaries in
|
||||
the Qt installation and displays it in the \gui{qmake location}
|
||||
field.
|
||||
|
||||
\li In the \gui{Version name} field, edit the name that \QC
|
||||
suggests for the Qt version.
|
||||
|
||||
\li In the \gui Helpers section, you can build the debugging
|
||||
\li In the \gui{qmake location} field, you can change the qmake
|
||||
location.
|
||||
|
||||
\li In the \gui Helpers section, select \gui Details to build the debugging
|
||||
helpers that are available for the Qt version. This is
|
||||
necessary, because the internal data structures of Qt can
|
||||
change between versions. For more information, see
|
||||
\l{Using Debugging Helpers}.
|
||||
|
||||
\image qt-creator-debugging-helpers.png
|
||||
|
||||
\li If the Qt version is for Blackberry or QNX, enter the path
|
||||
to your installed Blackberry NDK or QNX SDK in the
|
||||
\gui {Blackberry Native SDK} or \gui{QNX SDK} field respectively.
|
||||
|
||||
@@ -67,6 +67,8 @@
|
||||
|
||||
\li \l{Configuring Fonts}
|
||||
|
||||
\li \l{Viewing Function Tooltips}
|
||||
|
||||
\endlist
|
||||
|
||||
*/
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
\section2 Specifying Analyzer Settings
|
||||
\section2 Specifying Valgrind Settings
|
||||
|
||||
\QC integrates \l{Analyzing Code}{Valgrind code analysis tools} for
|
||||
detecting memory leaks and profiling function execution. You can configure
|
||||
the tools according to your needs.
|
||||
|
||||
You can specify analyzer settings either globally for all projects or separately for each
|
||||
You can specify Valgrind settings either globally for all projects or separately for each
|
||||
project.
|
||||
|
||||
To specify analyzer settings for the current project:
|
||||
To specify Valgrind settings for the current project:
|
||||
|
||||
\list 1
|
||||
|
||||
\li In the \gui {Analyzer Settings} section, select \gui Custom.
|
||||
\li In the \gui {Valgrind Settings} section, select \gui Custom.
|
||||
|
||||
\li Specify analyzer settings for the project.
|
||||
\li Specify Valgrind settings for the project.
|
||||
|
||||
\image qtcreator-analyzer-settings.png "Analyzer Settings"
|
||||
\image qtcreator-analyzer-settings.png "Valgrind Settings"
|
||||
|
||||
\endlist
|
||||
|
||||
@@ -23,14 +23,14 @@
|
||||
|
||||
\list
|
||||
|
||||
\li \l{Selecting Options for Memory Analysis}
|
||||
|
||||
\li \l{Selecting Profiling Options}
|
||||
|
||||
\li \l{Selecting Options for Memory Analysis}
|
||||
|
||||
\endlist
|
||||
|
||||
Click \gui {Restore Global} to revert to the global settings.
|
||||
|
||||
To specify global analyzer settings, select \gui {Tools > Options >
|
||||
To specify global Valgrind settings, select \gui {Tools > Options >
|
||||
Analyzer}.
|
||||
|
||||
|
||||
@@ -44,10 +44,16 @@
|
||||
|
||||
\li Android Device
|
||||
|
||||
\li Bare Metal Device
|
||||
|
||||
\li BlackBerry 10 Device
|
||||
|
||||
\li Generic Linux Device
|
||||
|
||||
\li iOS Device
|
||||
|
||||
\li iOS Simulator
|
||||
|
||||
\li QNX Device
|
||||
|
||||
\endlist
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
/*!
|
||||
\contentspage{index.html}{Qt Creator}
|
||||
\page index.html
|
||||
\nextpage creator-overview.html
|
||||
\nextpage creator-getting-started.html
|
||||
|
||||
\title Qt Creator Manual
|
||||
|
||||
@@ -251,7 +251,6 @@
|
||||
\endlist
|
||||
|
||||
\endlist
|
||||
\li \l{Publishing}
|
||||
\li \l{Advanced Use}
|
||||
\list
|
||||
\li \l{Supported Platforms}
|
||||
|
||||
@@ -35,8 +35,7 @@
|
||||
|
||||
\li \l {Creating Qt Quick Projects}
|
||||
|
||||
You can either create Qt Quick projects from scratch or import
|
||||
existing projects to \QC.
|
||||
You can use wizards to create Qt Quick projects.
|
||||
\li \l {Using Qt Quick Designer}
|
||||
|
||||
You can use the code editor (Edit mode) or the visual editor (Design
|
||||
|
||||
@@ -48,11 +48,7 @@
|
||||
\list 1
|
||||
|
||||
\li Select \gui{File > New File or Project > Applications >
|
||||
Qt Quick 2 Application (Built-in Types) > Choose}.
|
||||
|
||||
\note The QML types used in this example are also supported in Qt Quick 1. To create
|
||||
this example application for platforms that run Qt 4, select \gui {Qt Quick 1
|
||||
Application (Built-in Types)}.
|
||||
Qt Quick Application > Choose}.
|
||||
|
||||
\li In the \gui{Name} field, type \b {Transitions}.
|
||||
|
||||
@@ -60,6 +56,13 @@
|
||||
For example, \c {C:\Qt\examples}, and then click \gui{Next} (on
|
||||
Windows and Linux) or \gui Continue (on Mac OS).
|
||||
|
||||
\li In the \gui {Qt Quick component set} field, select
|
||||
\gui {Qt Quick 2.0}.
|
||||
|
||||
\note The QML types used in this example are also supported in
|
||||
Qt Quick 1.1. To create this example application for platforms that
|
||||
run Qt 4, select \gui {Qt Quick 1.1}.
|
||||
|
||||
\li Select \l{glossary-buildandrun-kit}{kits} for running and building your project,
|
||||
and then click \gui{Next}.
|
||||
|
||||
|
||||
@@ -40,23 +40,10 @@
|
||||
|
||||
\li \gui {Qt Quick Application} creates a Qt Quick application project
|
||||
that can contain both QML and C++ code. The project includes a
|
||||
QDeclarativeView. You can build the application and deploy it to
|
||||
QDeclarativeView or QQuickView. You can build the application and
|
||||
deploy it to
|
||||
desktop and mobile target platforms.
|
||||
|
||||
You can select a template that uses either the built-in QML types
|
||||
or Qt Quick components for a particular platform. The built-in QML
|
||||
types enable you to create cross-platform applications with a
|
||||
custom look and feel, whereas the components provide the look and
|
||||
feel for a particular platform.
|
||||
|
||||
The Qt Quick 1 Application wizard imports Qt Quick 1.1, and
|
||||
therefore, you can use it without changes to develop for platforms
|
||||
that run Qt 4.7.4. To develop for platforms that run
|
||||
Qt 4.7.3, you must change the import statement to
|
||||
import Qt Quick 1.0.
|
||||
|
||||
The Qt Quick 2 Application wizard imports Qt Quick 2.0. Use it to
|
||||
develop for platforms that run Qt 5.
|
||||
\li \gui {Qt Quick UI} creates a Qt Quick UI project with a single QML
|
||||
file that contains the main view. You can review Qt Quick UI
|
||||
projects in a \l{Previewing QML Files}{preview tool} and you need
|
||||
@@ -68,11 +55,6 @@
|
||||
This project requires that you have installed the Qt Quick Controls
|
||||
for your Qt version (5.1 or later).
|
||||
|
||||
\li \gui {Qt Quick Application (from Existing QML File)} converts
|
||||
existing Qt Quick applications to Qt Quick application projects.
|
||||
This enables you to run them from \QC and to deploy them to mobile
|
||||
devices.
|
||||
|
||||
\li \gui {Qt Quick Extension Plugins} (in the \gui Libraries category)
|
||||
create C++ plugins that make it possible to offer extensions that
|
||||
can be loaded dynamically into Qt Quick applications. Select
|
||||
@@ -111,9 +93,39 @@
|
||||
|
||||
\section1 Creating Qt Quick Applications
|
||||
|
||||
Select \gui File > \gui {New File or Project} > \gui Applications >
|
||||
\gui {Qt Quick Application 1 (Built-in Types)} or \gui {Qt Quick Application 2 (Built-in Types)}
|
||||
> \gui Choose, and follow the instructions of the wizard.
|
||||
\list 1
|
||||
|
||||
\li Select \gui File > \gui {New File or Project} > \gui Applications >
|
||||
\gui {Qt Quick Application} > \gui Choose.
|
||||
|
||||
\li In the \gui {Qt Quick component set} field, select the component set
|
||||
to use for the project. The Qt Quick imports enable you to create
|
||||
cross-platform applications with a custom look and feel, whereas the
|
||||
Qt Quick Controls provide the look and feel for a particular
|
||||
platform:
|
||||
|
||||
\list 1
|
||||
|
||||
\li Select \gui {Qt Quick Controls 1.0} or \gui {Qt Quick 2.0} to
|
||||
develop for platforms that run Qt 5.
|
||||
|
||||
\li Select \gui {Qt Quick 1.1} to develop for platforms that run
|
||||
Qt 4.7.4. To develop for platforms that run Qt 4.7.1, 4.7.2, or
|
||||
4.7.3, you must change the import statement to import Qt Quick
|
||||
1.0.
|
||||
|
||||
\endlist
|
||||
|
||||
\li Select \l{glossary-buildandrun-kit}{kits} for running and building
|
||||
your project, and then click \gui{Next}.
|
||||
|
||||
\note Kits are listed if they have been specified in \gui Tools >
|
||||
\gui Options > \gui {Build & Run} > \gui Kits.
|
||||
|
||||
\li Review the project settings, and click \gui{Finish} (on Windows and
|
||||
Linux) or \gui Done (on Mac OS) to create the project.
|
||||
|
||||
\endlist
|
||||
|
||||
\note The SDK for a particular target platform might install additional
|
||||
templates for that platform. For example, the BlackBerry 10 and QNX templates are installed
|
||||
@@ -122,18 +134,4 @@
|
||||
\QC creates the necessary boilerplate files. Some of the files are
|
||||
specific to a particular target platform.
|
||||
|
||||
\section1 Importing QML Applications
|
||||
|
||||
If you have existing QML applications that you want to run in \QC or deploy
|
||||
to mobile devices, select \gui File > \gui {New File or Project} > \gui Applications >
|
||||
\gui {Qt Quick 1 Application (from Existing QML file} or \gui {Qt Quick 2 Application
|
||||
(from Existing QML File)} > \gui Choose to import the main .qml file in your project.
|
||||
|
||||
\image qmldesigner-import-project.png "Select Existing QML File dialog"
|
||||
|
||||
All the other files in the project are automatically added to the
|
||||
application project.
|
||||
\QC adds references to the QML files to a project and creates the additional
|
||||
files necessary for deploying applications to mobile devices.
|
||||
|
||||
*/
|
||||
|
||||
@@ -119,4 +119,10 @@
|
||||
the context menu.
|
||||
|
||||
\endlist
|
||||
|
||||
\section1 Adding Widgets
|
||||
|
||||
You can use Qt APIs to create plugins that extend Qt applications. This
|
||||
enables you to add your own widgets to \QD. For more information, see
|
||||
\l{Adding Qt Designer Plugins}
|
||||
*/
|
||||
|
||||
@@ -371,6 +371,31 @@ class DumperBase:
|
||||
def putStringValue(self, value):
|
||||
return self.putValue(self.encodeString(value), Hex4EncodedLittleEndian)
|
||||
|
||||
def putAddressItem(self, name, value, type = ""):
|
||||
with SubItem(self, name):
|
||||
self.putValue("0x%x" % value)
|
||||
self.putType(type)
|
||||
self.putNumChild(0)
|
||||
|
||||
def putIntItem(self, name, value):
|
||||
with SubItem(self, name):
|
||||
self.putValue(value)
|
||||
self.putType("int")
|
||||
self.putNumChild(0)
|
||||
|
||||
def putBoolItem(self, name, value):
|
||||
with SubItem(self, name):
|
||||
self.putValue(value)
|
||||
self.putType("bool")
|
||||
self.putNumChild(0)
|
||||
|
||||
def putGenericItem(self, name, type, value, encoding = None):
|
||||
with SubItem(self, name):
|
||||
self.putValue(value, encoding)
|
||||
self.putType(type)
|
||||
self.putNumChild(0)
|
||||
|
||||
|
||||
def putMapName(self, value):
|
||||
ns = self.qtNamespace()
|
||||
if str(value.type) == ns + "QString":
|
||||
@@ -432,6 +457,23 @@ class DumperBase:
|
||||
def encodeChar4Array(self, p):
|
||||
return self.encodeCArray(p, "unsigned int", "2e0000002e0000002e000000")
|
||||
|
||||
def putItemCount(self, count, maximum = 1000000000):
|
||||
# This needs to override the default value, so don't use 'put' directly.
|
||||
if count > maximum:
|
||||
self.putValue('<>%s items>' % maximum)
|
||||
else:
|
||||
self.putValue('<%s items>' % count)
|
||||
|
||||
def putNoType(self):
|
||||
# FIXME: replace with something that does not need special handling
|
||||
# in SubItem.__exit__().
|
||||
self.putBetterType(" ")
|
||||
|
||||
def putInaccessible(self):
|
||||
#self.putBetterType(" ")
|
||||
self.putNumChild(0)
|
||||
self.currentValue = None
|
||||
|
||||
def putQObjectNameValue(self, value):
|
||||
try:
|
||||
intSize = self.intSize()
|
||||
|
||||
@@ -520,7 +520,6 @@ class Dumper(DumperBase):
|
||||
#warn("WATCHERS: %s" % watchers)
|
||||
#warn("PARTIAL: %s" % self.partialUpdate)
|
||||
#warn("NO LOCALS: %s" % self.noLocals)
|
||||
module = sys.modules[__name__]
|
||||
|
||||
#
|
||||
# Locals
|
||||
@@ -1010,30 +1009,12 @@ class Dumper(DumperBase):
|
||||
self.qtVersion = lambda: self.cachedQtVersion
|
||||
return self.cachedQtVersion
|
||||
|
||||
# Convenience function.
|
||||
def putItemCount(self, count, maximum = 1000000000):
|
||||
# This needs to override the default value, so don't use 'put' directly.
|
||||
if count > maximum:
|
||||
self.putValue('<>%s items>' % maximum)
|
||||
else:
|
||||
self.putValue('<%s items>' % count)
|
||||
|
||||
def putType(self, type, priority = 0):
|
||||
# Higher priority values override lower ones.
|
||||
if priority >= self.currentTypePriority:
|
||||
self.currentType = str(type)
|
||||
self.currentTypePriority = priority
|
||||
|
||||
def putNoType(self):
|
||||
# FIXME: replace with something that does not need special handling
|
||||
# in SubItem.__exit__().
|
||||
self.putBetterType(" ")
|
||||
|
||||
def putInaccessible(self):
|
||||
#self.putBetterType(" ")
|
||||
self.putNumChild(0)
|
||||
self.currentValue = None
|
||||
|
||||
def putBetterType(self, type):
|
||||
self.currentType = str(type)
|
||||
self.currentTypePriority = self.currentTypePriority + 1
|
||||
@@ -1117,24 +1098,6 @@ class Dumper(DumperBase):
|
||||
return True
|
||||
return self.isKnownMovableType(self.stripNamespaceFromType(str(type)))
|
||||
|
||||
def putIntItem(self, name, value):
|
||||
with SubItem(self, name):
|
||||
self.putValue(value)
|
||||
self.putType("int")
|
||||
self.putNumChild(0)
|
||||
|
||||
def putBoolItem(self, name, value):
|
||||
with SubItem(self, name):
|
||||
self.putValue(value)
|
||||
self.putType("bool")
|
||||
self.putNumChild(0)
|
||||
|
||||
def putGenericItem(self, name, type, value, encoding = None):
|
||||
with SubItem(self, name):
|
||||
self.putValue(value, encoding)
|
||||
self.putType(type)
|
||||
self.putNumChild(0)
|
||||
|
||||
def putSubItem(self, component, value, tryDynamic=True):
|
||||
with SubItem(self, component):
|
||||
self.putItem(value, tryDynamic)
|
||||
@@ -1759,13 +1722,12 @@ class Dumper(DumperBase):
|
||||
self.qqFormats = {}
|
||||
self.qqEditable = {}
|
||||
self.typeCache = {}
|
||||
module = sys.modules[__name__]
|
||||
|
||||
#warn("KEYS: %s " % module.__dict__.keys())
|
||||
for name in module.__dict__.keys():
|
||||
#warn("KEY: %s " % name)
|
||||
#warn("FUNCT: %s " % module.__dict__[name])
|
||||
self.registerDumper(name, module.__dict__[name])
|
||||
# It's __main__ from gui, gdbbridge from test. Brush over it...
|
||||
for modname in ['__main__', 'gdbbridge']:
|
||||
dic = sys.modules[modname].__dict__
|
||||
for name in dic.keys():
|
||||
self.registerDumper(name, dic[name])
|
||||
|
||||
result = "dumpers=["
|
||||
for key, value in self.qqFormats.items():
|
||||
|
||||
@@ -48,24 +48,26 @@ from misctypes import *
|
||||
from boosttypes import *
|
||||
from creatortypes import *
|
||||
|
||||
lldbCmd = 'lldb'
|
||||
if len(sys.argv) > 1:
|
||||
lldbCmd = sys.argv[1]
|
||||
|
||||
proc = subprocess.Popen(args=[sys.argv[1], '-P'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
proc = subprocess.Popen(args=[lldbCmd, '-P'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
(path, error) = proc.communicate()
|
||||
|
||||
if error.startswith('lldb: invalid option -- P'):
|
||||
sys.stdout.write('msg=\'Could not run "%s -P". Trying to find lldb.so from Xcode.\'\n' % sys.argv[1])
|
||||
sys.stdout.write('msg=\'Could not run "%s -P". Trying to find lldb.so from Xcode.\'@\n' % lldbCmd)
|
||||
proc = subprocess.Popen(args=['xcode-select', '--print-path'],
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
(path, error) = proc.communicate()
|
||||
if len(error):
|
||||
path = '/Applications/Xcode.app/Contents/SharedFrameworks/LLDB.framework/Versions/A/Resources/Python/'
|
||||
sys.stdout.write('msg=\'Could not run "xcode-select --print-path"\n')
|
||||
sys.stdout.write('msg=\'Using hardcoded fallback at %s\'\n' % path)
|
||||
sys.stdout.write('msg=\'Could not run "xcode-select --print-path"@\n')
|
||||
sys.stdout.write('msg=\'Using hardcoded fallback at %s\'@\n' % path)
|
||||
else:
|
||||
path = path.strip() + '/../SharedFrameworks/LLDB.framework/Versions/A/Resources/Python/'
|
||||
sys.stdout.write('msg=\'Using fallback at %s\'\n' % path)
|
||||
sys.stdout.write('msg=\'Using fallback at %s\'@\n' % path)
|
||||
|
||||
#sys.path.append(path)
|
||||
sys.path.insert(1, path.strip())
|
||||
|
||||
import lldb
|
||||
@@ -88,16 +90,10 @@ def showException(msg, exType, exValue, exTraceback):
|
||||
lines = [line for line in traceback.format_exception(exType, exValue, exTraceback)]
|
||||
warn('\n'.join(lines))
|
||||
|
||||
def registerCommand(name, func):
|
||||
pass
|
||||
|
||||
def fileName(file):
|
||||
return str(file) if file.IsValid() else ''
|
||||
|
||||
|
||||
# Data members
|
||||
PointerCode = 102
|
||||
|
||||
# Breakpoints. Keep synchronized with BreakpointType in breakpoint.h
|
||||
UnknownType = 0
|
||||
BreakpointByFileAndLine = 1
|
||||
@@ -121,7 +117,7 @@ stateNames = ["invalid", "unloaded", "connected", "attaching", "launching", "sto
|
||||
def loggingCallback(args):
|
||||
s = args.strip()
|
||||
s = s.replace('"', "'")
|
||||
sys.stdout.write('log="%s"\n' % s)
|
||||
sys.stdout.write('log="%s"@\n' % s)
|
||||
|
||||
def check(exp):
|
||||
if not exp:
|
||||
@@ -260,15 +256,20 @@ class Dumper(DumperBase):
|
||||
#self.debugger.EnableLog("lldb", ["all"])
|
||||
self.debugger.Initialize()
|
||||
self.debugger.HandleCommand("settings set auto-confirm on")
|
||||
if not hasattr(lldb.SBType, 'GetCanonicalType'): # "Test" for 179.5
|
||||
warn("DISABLING DEFAULT FORMATTERS")
|
||||
|
||||
# FIXME: warn("DISABLING DEFAULT FORMATTERS")
|
||||
# It doesn't work at all with 179.5 and we have some bad
|
||||
# interactonn in 3000
|
||||
# if not hasattr(lldb.SBType, 'GetCanonicalType'): # "Test" for 179.5
|
||||
self.debugger.HandleCommand('type category delete gnu-libstdc++')
|
||||
self.debugger.HandleCommand('type category delete libcxx')
|
||||
#for i in range(self.debugger.GetNumCategories()):
|
||||
# self.debugger.GetCategoryAtIndex(i).SetEnabled(False)
|
||||
|
||||
self.isLldb = True
|
||||
self.process = None
|
||||
self.target = None
|
||||
self.eventState = lldb.eStateInvalid
|
||||
self.options = {}
|
||||
self.expandedINames = {}
|
||||
self.passExceptions = False
|
||||
self.useLldbDumpers = False
|
||||
@@ -368,7 +369,6 @@ class Dumper(DumperBase):
|
||||
|
||||
def isSimpleType(self, typeobj):
|
||||
typeClass = typeobj.GetTypeClass()
|
||||
#warn("TYPECLASS: %s" % typeClass)
|
||||
return typeClass == lldb.eTypeClassBuiltin
|
||||
|
||||
def childAt(self, value, index):
|
||||
@@ -519,24 +519,6 @@ class Dumper(DumperBase):
|
||||
return True
|
||||
return self.isKnownMovableType(self.stripNamespaceFromType(type.GetName()))
|
||||
|
||||
def putIntItem(self, name, value):
|
||||
with SubItem(self, name):
|
||||
self.putValue(value)
|
||||
self.putType("int")
|
||||
self.putNumChild(0)
|
||||
|
||||
def putBoolItem(self, name, value):
|
||||
with SubItem(self, name):
|
||||
self.putValue(value)
|
||||
self.putType("bool")
|
||||
self.putNumChild(0)
|
||||
|
||||
def putGenericItem(self, name, type, value, encoding = None):
|
||||
with SubItem(self, name):
|
||||
self.putValue(value, encoding)
|
||||
self.putType(type)
|
||||
self.putNumChild(0)
|
||||
|
||||
def putNumChild(self, numchild):
|
||||
#warn("NUM CHILD: '%s' '%s'" % (numchild, self.currentChildNumChild))
|
||||
#if numchild != self.currentChildNumChild:
|
||||
@@ -559,14 +541,6 @@ class Dumper(DumperBase):
|
||||
self.currentValueEncoding = encoding
|
||||
#self.put('value="%s",' % value)
|
||||
|
||||
# Convenience function.
|
||||
def putItemCount(self, count, maximum = 1000000000):
|
||||
# This needs to override the default value, so don't use 'put' directly.
|
||||
if count > maximum:
|
||||
self.putValue('<>%s items>' % maximum)
|
||||
else:
|
||||
self.putValue('<%s items>' % count)
|
||||
|
||||
def putName(self, name):
|
||||
self.put('name="%s",' % name)
|
||||
|
||||
@@ -651,9 +625,12 @@ class Dumper(DumperBase):
|
||||
self.attachPid_ = args.get('attachPid', 0)
|
||||
self.sysRoot_ = args.get('sysRoot', '')
|
||||
self.remoteChannel_ = args.get('remoteChannel', '')
|
||||
self.platform_ = args.get('platform', '')
|
||||
|
||||
if len(self.sysRoot_)>0:
|
||||
if self.sysRoot_:
|
||||
self.debugger.SetCurrentPlatformSDKRoot(self.sysRoot_)
|
||||
if self.platform_:
|
||||
self.debugger.SetCurrentPlatform(self.platform_)
|
||||
self.target = self.debugger.CreateTarget(self.executable_, None, None, True, error)
|
||||
self.importDumpers()
|
||||
|
||||
@@ -671,16 +648,18 @@ class Dumper(DumperBase):
|
||||
if self.attachPid_ > 0:
|
||||
attachInfo = lldb.SBAttachInfo(self.attachPid_)
|
||||
self.process = self.target.Attach(attachInfo, error)
|
||||
if not err.Success():
|
||||
if not error.Success():
|
||||
self.report('state="inferiorrunfailed"')
|
||||
return
|
||||
self.report('pid="%s"' % self.process.GetProcessID())
|
||||
self.report('state="enginerunandinferiorstopok"')
|
||||
elif len(self.remoteChannel_) > 0:
|
||||
err = lldb.SBError()
|
||||
self.process = self.target.ConnectRemote(
|
||||
self.debugger.GetListener(),
|
||||
self.remoteChannel_, None, error)
|
||||
if not error.Success():
|
||||
self.report('state="inferiorrunfailed"')
|
||||
return
|
||||
self.report('state="enginerunandinferiorstopok"')
|
||||
else:
|
||||
launchInfo = lldb.SBLaunchInfo(self.processArgs_.split(' '))
|
||||
@@ -688,7 +667,7 @@ class Dumper(DumperBase):
|
||||
environmentList = [key + "=" + value for key,value in os.environ.items()]
|
||||
launchInfo.SetEnvironmentEntries(environmentList, False)
|
||||
self.process = self.target.Launch(launchInfo, error)
|
||||
if not err.Success():
|
||||
if not error.Success():
|
||||
self.report('state="inferiorrunfailed"')
|
||||
return
|
||||
self.report('pid="%s"' % self.process.GetProcessID())
|
||||
@@ -1252,7 +1231,7 @@ class Dumper(DumperBase):
|
||||
self.report(result)
|
||||
|
||||
def report(self, stuff):
|
||||
sys.stdout.write(stuff + "\n")
|
||||
sys.stdout.write(stuff + "@\n")
|
||||
|
||||
def interruptInferior(self, _ = None):
|
||||
if self.process is None:
|
||||
@@ -1327,17 +1306,11 @@ class Dumper(DumperBase):
|
||||
% binascii.hexlify(msg))
|
||||
elif type == lldb.SBProcess.eBroadcastBitSTDERR:
|
||||
msg = self.process.GetSTDERR(1024)
|
||||
self.report('output={channel="stdout",data="%s"}'
|
||||
self.report('output={channel="stderr",data="%s"}'
|
||||
% binascii.hexlify(msg))
|
||||
elif type == lldb.SBProcess.eBroadcastBitProfileData:
|
||||
pass
|
||||
|
||||
def processEvents(self):
|
||||
event = lldb.SBEvent()
|
||||
while self.debugger.GetListener().PeekAtNextEvent(event):
|
||||
self.debugger.GetListener().GetNextEvent(event)
|
||||
self.handleEvent(event)
|
||||
|
||||
def describeBreakpoint(self, bp, modelId):
|
||||
isWatch = isinstance(bp, lldb.SBWatchpoint)
|
||||
if isWatch:
|
||||
@@ -1557,9 +1530,6 @@ class Dumper(DumperBase):
|
||||
error = str(result.GetError())
|
||||
self.report('success="%d",output="%s",error="%s"' % (success, output, error))
|
||||
|
||||
def setOptions(self, args):
|
||||
self.options = args
|
||||
|
||||
def setWatchers(self, args):
|
||||
#self.currentWatchers = args['watchers']
|
||||
#warn("WATCHERS %s" % self.currentWatchers)
|
||||
@@ -1659,11 +1629,6 @@ class Dumper(DumperBase):
|
||||
cont = args['continuation']
|
||||
self.report('continuation="%s"' % cont)
|
||||
|
||||
def consumeEvents(self):
|
||||
event = lldb.SBEvent()
|
||||
if self.debugger.GetListener().PeekAtNextEvent(event):
|
||||
self.debugger.GetListener().GetNextEvent(event)
|
||||
self.handleEvent(event)
|
||||
|
||||
def convertHash(args):
|
||||
if sys.version_info[0] == 3:
|
||||
@@ -1712,6 +1677,7 @@ def testit():
|
||||
|
||||
db.debugger.SetAsync(False)
|
||||
db.expandedINames = set(sys.argv[3].split(','))
|
||||
db.passExceptions = True
|
||||
|
||||
db.setupInferior({'cmd':'setupInferior','executable':sys.argv[2],'token':1})
|
||||
db.handleBreakpoints({'cmd':'handleBreakpoints','bkpts':[{'operation':'add',
|
||||
@@ -1729,9 +1695,9 @@ def testit():
|
||||
db.reportVariables()
|
||||
#db.report("DUMPER=%s" % qqDumpers)
|
||||
|
||||
|
||||
if len(sys.argv) > 2:
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) > 2:
|
||||
testit()
|
||||
else:
|
||||
else:
|
||||
doit()
|
||||
|
||||
|
||||
@@ -587,8 +587,13 @@ def qHashIteratorHelper(d, value):
|
||||
# -> QHashNode<int, float> with 'proper' spacing,
|
||||
# as space changes confuse LLDB.
|
||||
innerTypeName = hashTypeName.replace("QHash", "QHashNode", 1)
|
||||
node = value["i"].cast(d.lookupType(innerTypeName).pointer())
|
||||
d.putSubItem("key", node["key"])
|
||||
node = value["i"].cast(d.lookupType(innerTypeName).pointer()).dereference()
|
||||
key = node["key"]
|
||||
if not key:
|
||||
# LLDB can't access directly since it's in anonymous union
|
||||
# for Qt4 optimized int keytype
|
||||
key = node[1]["key"]
|
||||
d.putSubItem("key", key)
|
||||
d.putSubItem("value", node["value"])
|
||||
|
||||
def qdump__QHash__const_iterator(d, value):
|
||||
@@ -1575,7 +1580,12 @@ def qdump__QSet(d, value):
|
||||
for i in d.childRange():
|
||||
it = node.dereference().cast(innerType)
|
||||
with SubItem(d, i):
|
||||
d.putItem(it["key"])
|
||||
key = it["key"]
|
||||
if not key:
|
||||
# LLDB can't access directly since it's in anonymous union
|
||||
# for Qt4 optimized int keytype
|
||||
key = it[1]["key"]
|
||||
d.putItem(key)
|
||||
node = hashDataNextNode(node, numBuckets)
|
||||
|
||||
|
||||
@@ -1723,13 +1733,27 @@ def qdump__QTextDocument(d, value):
|
||||
|
||||
def qdump__QUrl(d, value):
|
||||
if d.qtVersion() < 0x050000:
|
||||
if not d.dereferenceValue(value):
|
||||
privAddress = d.dereferenceValue(value)
|
||||
if not privAddress:
|
||||
# d == 0 if QUrl was constructed with default constructor
|
||||
d.putValue("<invalid>")
|
||||
return
|
||||
data = value["d"].dereference()
|
||||
d.putByteArrayValue(data["encodedOriginal"])
|
||||
d.putPlainChildren(data)
|
||||
encodedOriginalAddress = privAddress + 8 * d.ptrSize()
|
||||
d.putValue(d.encodeByteArrayHelper(d.dereference(encodedOriginalAddress)), Hex2EncodedLatin1)
|
||||
d.putNumChild(8)
|
||||
if d.isExpanded():
|
||||
stringType = d.lookupType(d.qtNamespace() + "QString")
|
||||
baType = d.lookupType(d.qtNamespace() + "QByteArray")
|
||||
with Children(d):
|
||||
# Qt 4 only decodes the original string if some detail is requested
|
||||
d.putCallItem("scheme", value, "scheme")
|
||||
d.putCallItem("userName", value, "userName")
|
||||
d.putCallItem("password", value, "password")
|
||||
d.putCallItem("host", value, "host")
|
||||
d.putCallItem("path", value, "path")
|
||||
d.putCallItem("query", value, "encodedQuery")
|
||||
d.putCallItem("fragment", value, "fragment")
|
||||
d.putCallItem("port", value, "port")
|
||||
else:
|
||||
# QUrlPrivate:
|
||||
# - QAtomicInt ref;
|
||||
@@ -1908,9 +1932,7 @@ def qdumpHelper__QVariant(d, value):
|
||||
isSpecial = d.qtVersion() >= 0x050000 \
|
||||
and (innert == "QVariantMap" or innert == "QVariantHash")
|
||||
if innerType.sizeof > sizePD or isSpecial:
|
||||
sizePS = 2 * d.ptrSize() # sizeof(QVariant::PrivateShared)
|
||||
val = (data.cast(d.charPtrType()) + sizePS) \
|
||||
.cast(innerType.pointer()).dereference()
|
||||
val = data["ptr"].cast(innerType.pointer().pointer()).dereference().dereference()
|
||||
else:
|
||||
val = data.cast(innerType)
|
||||
|
||||
|
||||
@@ -1,185 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "abstractliveedittool.h"
|
||||
#include "qdeclarativeviewinspector.h"
|
||||
#include "../qdeclarativeviewinspector_p.h"
|
||||
|
||||
#include <QDeclarativeEngine>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QGraphicsItem>
|
||||
#include <QDeclarativeItem>
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
AbstractLiveEditTool::AbstractLiveEditTool(QDeclarativeViewInspector *editorView)
|
||||
: QObject(editorView), m_inspector(editorView)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
AbstractLiveEditTool::~AbstractLiveEditTool()
|
||||
{
|
||||
}
|
||||
|
||||
QDeclarativeViewInspector *AbstractLiveEditTool::inspector() const
|
||||
{
|
||||
return m_inspector;
|
||||
}
|
||||
|
||||
QDeclarativeView *AbstractLiveEditTool::view() const
|
||||
{
|
||||
return m_inspector->declarativeView();
|
||||
}
|
||||
|
||||
QGraphicsScene* AbstractLiveEditTool::scene() const
|
||||
{
|
||||
return view()->scene();
|
||||
}
|
||||
|
||||
void AbstractLiveEditTool::updateSelectedItems()
|
||||
{
|
||||
selectedItemsChanged(items());
|
||||
}
|
||||
|
||||
QList<QGraphicsItem*> AbstractLiveEditTool::items() const
|
||||
{
|
||||
return inspector()->selectedItems();
|
||||
}
|
||||
|
||||
bool AbstractLiveEditTool::topItemIsMovable(const QList<QGraphicsItem*> & itemList)
|
||||
{
|
||||
QGraphicsItem *firstSelectableItem = topMovableGraphicsItem(itemList);
|
||||
if (firstSelectableItem == 0)
|
||||
return false;
|
||||
if (toQDeclarativeItem(firstSelectableItem) != 0)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
bool AbstractLiveEditTool::topSelectedItemIsMovable(const QList<QGraphicsItem*> &itemList)
|
||||
{
|
||||
QList<QGraphicsItem*> selectedItems = inspector()->selectedItems();
|
||||
|
||||
foreach (QGraphicsItem *item, itemList) {
|
||||
QDeclarativeItem *declarativeItem = toQDeclarativeItem(item);
|
||||
if (declarativeItem
|
||||
&& selectedItems.contains(declarativeItem)
|
||||
/*&& (declarativeItem->qmlItemNode().hasShowContent() || selectNonContentItems)*/)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
bool AbstractLiveEditTool::topItemIsResizeHandle(const QList<QGraphicsItem*> &/*itemList*/)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
QDeclarativeItem *AbstractLiveEditTool::toQDeclarativeItem(QGraphicsItem *item)
|
||||
{
|
||||
return qobject_cast<QDeclarativeItem*>(item->toGraphicsObject());
|
||||
}
|
||||
|
||||
QGraphicsItem *AbstractLiveEditTool::topMovableGraphicsItem(const QList<QGraphicsItem*> &itemList)
|
||||
{
|
||||
foreach (QGraphicsItem *item, itemList) {
|
||||
if (item->flags().testFlag(QGraphicsItem::ItemIsMovable))
|
||||
return item;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
QDeclarativeItem *AbstractLiveEditTool::topMovableDeclarativeItem(const QList<QGraphicsItem*>
|
||||
&itemList)
|
||||
{
|
||||
foreach (QGraphicsItem *item, itemList) {
|
||||
QDeclarativeItem *declarativeItem = toQDeclarativeItem(item);
|
||||
if (declarativeItem /*&& (declarativeItem->qmlItemNode().hasShowContent())*/)
|
||||
return declarativeItem;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
QList<QGraphicsObject*> AbstractLiveEditTool::toGraphicsObjectList(const QList<QGraphicsItem*>
|
||||
&itemList)
|
||||
{
|
||||
QList<QGraphicsObject*> gfxObjects;
|
||||
foreach (QGraphicsItem *item, itemList) {
|
||||
QGraphicsObject *obj = item->toGraphicsObject();
|
||||
if (obj)
|
||||
gfxObjects << obj;
|
||||
}
|
||||
|
||||
return gfxObjects;
|
||||
}
|
||||
|
||||
QString AbstractLiveEditTool::titleForItem(QGraphicsItem *item)
|
||||
{
|
||||
QString className("QGraphicsItem");
|
||||
QString objectStringId;
|
||||
|
||||
QString constructedName;
|
||||
|
||||
QGraphicsObject *gfxObject = item->toGraphicsObject();
|
||||
if (gfxObject) {
|
||||
className = gfxObject->metaObject()->className();
|
||||
|
||||
className.remove(QRegExp("_QMLTYPE_\\d+"));
|
||||
className.remove(QRegExp("_QML_\\d+"));
|
||||
if (className.startsWith(QLatin1String("QDeclarative")))
|
||||
className = className.remove(QLatin1String("QDeclarative"));
|
||||
|
||||
QDeclarativeItem *declarativeItem = qobject_cast<QDeclarativeItem*>(gfxObject);
|
||||
if (declarativeItem) {
|
||||
objectStringId = QDeclarativeViewInspector::idStringForObject(declarativeItem);
|
||||
}
|
||||
|
||||
if (!objectStringId.isEmpty()) {
|
||||
constructedName = objectStringId + " (" + className + QLatin1Char(')');
|
||||
} else {
|
||||
if (!gfxObject->objectName().isEmpty()) {
|
||||
constructedName = gfxObject->objectName() + " (" + className + QLatin1Char(')');
|
||||
} else {
|
||||
constructedName = className;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return constructedName;
|
||||
}
|
||||
|
||||
|
||||
} // namespace QmlJSDebugger
|
||||
@@ -1,104 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef ABSTRACTLIVEEDITTOOL_H
|
||||
#define ABSTRACTLIVEEDITTOOL_H
|
||||
|
||||
#include <QList>
|
||||
#include <QObject>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QMouseEvent;
|
||||
class QGraphicsItem;
|
||||
class QDeclarativeItem;
|
||||
class QKeyEvent;
|
||||
class QGraphicsScene;
|
||||
class QGraphicsObject;
|
||||
class QWheelEvent;
|
||||
class QDeclarativeView;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
class QDeclarativeViewInspector;
|
||||
|
||||
class FormEditorView;
|
||||
|
||||
class AbstractLiveEditTool : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
AbstractLiveEditTool(QDeclarativeViewInspector *inspector);
|
||||
|
||||
virtual ~AbstractLiveEditTool();
|
||||
|
||||
virtual void mousePressEvent(QMouseEvent *event) = 0;
|
||||
virtual void mouseMoveEvent(QMouseEvent *event) = 0;
|
||||
virtual void mouseReleaseEvent(QMouseEvent *event) = 0;
|
||||
virtual void mouseDoubleClickEvent(QMouseEvent *event) = 0;
|
||||
|
||||
virtual void hoverMoveEvent(QMouseEvent *event) = 0;
|
||||
virtual void wheelEvent(QWheelEvent *event) = 0;
|
||||
|
||||
virtual void keyPressEvent(QKeyEvent *event) = 0;
|
||||
virtual void keyReleaseEvent(QKeyEvent *keyEvent) = 0;
|
||||
virtual void itemsAboutToRemoved(const QList<QGraphicsItem*> &itemList) = 0;
|
||||
|
||||
virtual void clear() = 0;
|
||||
|
||||
void updateSelectedItems();
|
||||
QList<QGraphicsItem*> items() const;
|
||||
|
||||
void enterContext(QGraphicsItem *itemToEnter);
|
||||
|
||||
bool topItemIsMovable(const QList<QGraphicsItem*> &itemList);
|
||||
bool topItemIsResizeHandle(const QList<QGraphicsItem*> &itemList);
|
||||
bool topSelectedItemIsMovable(const QList<QGraphicsItem*> &itemList);
|
||||
|
||||
static QString titleForItem(QGraphicsItem *item);
|
||||
static QList<QGraphicsObject*> toGraphicsObjectList(const QList<QGraphicsItem*> &itemList);
|
||||
static QGraphicsItem* topMovableGraphicsItem(const QList<QGraphicsItem*> &itemList);
|
||||
static QDeclarativeItem* topMovableDeclarativeItem(const QList<QGraphicsItem*> &itemList);
|
||||
static QDeclarativeItem *toQDeclarativeItem(QGraphicsItem *item);
|
||||
|
||||
protected:
|
||||
virtual void selectedItemsChanged(const QList<QGraphicsItem*> &objectList) = 0;
|
||||
|
||||
QDeclarativeViewInspector *inspector() const;
|
||||
QDeclarativeView *view() const;
|
||||
QGraphicsScene *scene() const;
|
||||
|
||||
private:
|
||||
QDeclarativeViewInspector *m_inspector;
|
||||
QList<QGraphicsItem*> m_itemList;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // ABSTRACTLIVEEDITTOOL_H
|
||||
@@ -1,228 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "boundingrecthighlighter.h"
|
||||
#include "qdeclarativeviewinspector.h"
|
||||
#include "qmlinspectorconstants.h"
|
||||
|
||||
#include <QGraphicsPolygonItem>
|
||||
|
||||
#include <QTimer>
|
||||
#include <QObject>
|
||||
#include <QDebug>
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
BoundingBox::BoundingBox(QGraphicsObject *itemToHighlight, QGraphicsItem *parentItem,
|
||||
QObject *parent)
|
||||
: QObject(parent),
|
||||
highlightedObject(itemToHighlight),
|
||||
highlightPolygon(0),
|
||||
highlightPolygonEdge(0)
|
||||
{
|
||||
highlightPolygon = new BoundingBoxPolygonItem(parentItem);
|
||||
highlightPolygonEdge = new BoundingBoxPolygonItem(parentItem);
|
||||
|
||||
highlightPolygon->setPen(QPen(QColor(0, 22, 159)));
|
||||
highlightPolygonEdge->setPen(QPen(QColor(158, 199, 255)));
|
||||
|
||||
highlightPolygon->setFlag(QGraphicsItem::ItemIsSelectable, false);
|
||||
highlightPolygonEdge->setFlag(QGraphicsItem::ItemIsSelectable, false);
|
||||
}
|
||||
|
||||
BoundingBox::~BoundingBox()
|
||||
{
|
||||
highlightedObject.clear();
|
||||
}
|
||||
|
||||
BoundingBoxPolygonItem::BoundingBoxPolygonItem(QGraphicsItem *item) : QGraphicsPolygonItem(item)
|
||||
{
|
||||
QPen pen;
|
||||
pen.setColor(QColor(108, 141, 221));
|
||||
pen.setWidth(1);
|
||||
setPen(pen);
|
||||
}
|
||||
|
||||
int BoundingBoxPolygonItem::type() const
|
||||
{
|
||||
return Constants::EditorItemType;
|
||||
}
|
||||
|
||||
BoundingRectHighlighter::BoundingRectHighlighter(QDeclarativeViewInspector *view) :
|
||||
LiveLayerItem(view->declarativeView()->scene()),
|
||||
m_view(view)
|
||||
{
|
||||
}
|
||||
|
||||
BoundingRectHighlighter::~BoundingRectHighlighter()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void BoundingRectHighlighter::clear()
|
||||
{
|
||||
foreach (BoundingBox *box, m_boxes)
|
||||
freeBoundingBox(box);
|
||||
}
|
||||
|
||||
BoundingBox *BoundingRectHighlighter::boxFor(QGraphicsObject *item) const
|
||||
{
|
||||
foreach (BoundingBox *box, m_boxes) {
|
||||
if (box->highlightedObject.data() == item)
|
||||
return box;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void BoundingRectHighlighter::highlight(QList<QGraphicsObject*> items)
|
||||
{
|
||||
if (items.isEmpty())
|
||||
return;
|
||||
|
||||
QList<BoundingBox *> newBoxes;
|
||||
foreach (QGraphicsObject *itemToHighlight, items) {
|
||||
BoundingBox *box = boxFor(itemToHighlight);
|
||||
if (!box)
|
||||
box = createBoundingBox(itemToHighlight);
|
||||
|
||||
newBoxes << box;
|
||||
}
|
||||
qSort(newBoxes);
|
||||
|
||||
if (newBoxes != m_boxes) {
|
||||
clear();
|
||||
m_boxes << newBoxes;
|
||||
}
|
||||
|
||||
highlightAll();
|
||||
}
|
||||
|
||||
void BoundingRectHighlighter::highlight(QGraphicsObject* itemToHighlight)
|
||||
{
|
||||
if (!itemToHighlight)
|
||||
return;
|
||||
|
||||
BoundingBox *box = boxFor(itemToHighlight);
|
||||
if (!box) {
|
||||
box = createBoundingBox(itemToHighlight);
|
||||
m_boxes << box;
|
||||
qSort(m_boxes);
|
||||
}
|
||||
|
||||
highlightAll();
|
||||
}
|
||||
|
||||
BoundingBox *BoundingRectHighlighter::createBoundingBox(QGraphicsObject *itemToHighlight)
|
||||
{
|
||||
if (!m_freeBoxes.isEmpty()) {
|
||||
BoundingBox *box = m_freeBoxes.last();
|
||||
if (box->highlightedObject.isNull()) {
|
||||
box->highlightedObject = itemToHighlight;
|
||||
box->highlightPolygon->show();
|
||||
box->highlightPolygonEdge->show();
|
||||
m_freeBoxes.removeLast();
|
||||
return box;
|
||||
}
|
||||
}
|
||||
|
||||
BoundingBox *box = new BoundingBox(itemToHighlight, this, this);
|
||||
|
||||
connect(itemToHighlight, SIGNAL(xChanged()), this, SLOT(refresh()));
|
||||
connect(itemToHighlight, SIGNAL(yChanged()), this, SLOT(refresh()));
|
||||
connect(itemToHighlight, SIGNAL(widthChanged()), this, SLOT(refresh()));
|
||||
connect(itemToHighlight, SIGNAL(heightChanged()), this, SLOT(refresh()));
|
||||
connect(itemToHighlight, SIGNAL(rotationChanged()), this, SLOT(refresh()));
|
||||
connect(itemToHighlight, SIGNAL(destroyed(QObject*)), this, SLOT(itemDestroyed(QObject*)));
|
||||
|
||||
return box;
|
||||
}
|
||||
|
||||
void BoundingRectHighlighter::removeBoundingBox(BoundingBox *box)
|
||||
{
|
||||
delete box;
|
||||
box = 0;
|
||||
}
|
||||
|
||||
void BoundingRectHighlighter::freeBoundingBox(BoundingBox *box)
|
||||
{
|
||||
if (!box->highlightedObject.isNull()) {
|
||||
disconnect(box->highlightedObject.data(), SIGNAL(xChanged()), this, SLOT(refresh()));
|
||||
disconnect(box->highlightedObject.data(), SIGNAL(yChanged()), this, SLOT(refresh()));
|
||||
disconnect(box->highlightedObject.data(), SIGNAL(widthChanged()), this, SLOT(refresh()));
|
||||
disconnect(box->highlightedObject.data(), SIGNAL(heightChanged()), this, SLOT(refresh()));
|
||||
disconnect(box->highlightedObject.data(), SIGNAL(rotationChanged()), this, SLOT(refresh()));
|
||||
}
|
||||
|
||||
box->highlightedObject.clear();
|
||||
box->highlightPolygon->hide();
|
||||
box->highlightPolygonEdge->hide();
|
||||
m_boxes.removeOne(box);
|
||||
m_freeBoxes << box;
|
||||
}
|
||||
|
||||
void BoundingRectHighlighter::itemDestroyed(QObject *obj)
|
||||
{
|
||||
foreach (BoundingBox *box, m_boxes) {
|
||||
if (box->highlightedObject.data() == obj) {
|
||||
freeBoundingBox(box);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BoundingRectHighlighter::highlightAll()
|
||||
{
|
||||
foreach (BoundingBox *box, m_boxes) {
|
||||
Q_ASSERT(box);
|
||||
if (box->highlightedObject.isNull()) {
|
||||
// clear all highlights
|
||||
clear();
|
||||
return;
|
||||
}
|
||||
QGraphicsObject *item = box->highlightedObject.data();
|
||||
|
||||
QRectF boundingRectInSceneSpace(item->mapToScene(item->boundingRect()).boundingRect());
|
||||
QRectF boundingRectInLayerItemSpace = mapRectFromScene(boundingRectInSceneSpace);
|
||||
QRectF bboxRect = m_view->adjustToScreenBoundaries(boundingRectInLayerItemSpace);
|
||||
QRectF edgeRect = bboxRect;
|
||||
edgeRect.adjust(-1, -1, 1, 1);
|
||||
|
||||
box->highlightPolygon->setPolygon(QPolygonF(bboxRect));
|
||||
box->highlightPolygonEdge->setPolygon(QPolygonF(edgeRect));
|
||||
}
|
||||
}
|
||||
|
||||
void BoundingRectHighlighter::refresh()
|
||||
{
|
||||
if (!m_boxes.isEmpty())
|
||||
highlightAll();
|
||||
}
|
||||
|
||||
|
||||
} // namespace QmlJSDebugger
|
||||
@@ -1,103 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef BOUNDINGRECTHIGHLIGHTER_H
|
||||
#define BOUNDINGRECTHIGHLIGHTER_H
|
||||
|
||||
#include "livelayeritem.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QWeakPointer>
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QGraphicsItem)
|
||||
QT_FORWARD_DECLARE_CLASS(QPainter)
|
||||
QT_FORWARD_DECLARE_CLASS(QWidget)
|
||||
QT_FORWARD_DECLARE_CLASS(QStyleOptionGraphicsItem)
|
||||
QT_FORWARD_DECLARE_CLASS(QTimer)
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
class QDeclarativeViewInspector;
|
||||
class BoundingBox;
|
||||
|
||||
class BoundingRectHighlighter : public LiveLayerItem
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit BoundingRectHighlighter(QDeclarativeViewInspector *view);
|
||||
~BoundingRectHighlighter();
|
||||
void clear();
|
||||
void highlight(QList<QGraphicsObject*> items);
|
||||
void highlight(QGraphicsObject* item);
|
||||
|
||||
private slots:
|
||||
void refresh();
|
||||
void itemDestroyed(QObject *);
|
||||
|
||||
private:
|
||||
BoundingBox *boxFor(QGraphicsObject *item) const;
|
||||
void highlightAll();
|
||||
BoundingBox *createBoundingBox(QGraphicsObject *itemToHighlight);
|
||||
void removeBoundingBox(BoundingBox *box);
|
||||
void freeBoundingBox(BoundingBox *box);
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(BoundingRectHighlighter)
|
||||
|
||||
QDeclarativeViewInspector *m_view;
|
||||
QList<BoundingBox* > m_boxes;
|
||||
QList<BoundingBox* > m_freeBoxes;
|
||||
};
|
||||
|
||||
class BoundingBox : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit BoundingBox(QGraphicsObject *itemToHighlight, QGraphicsItem *parentItem,
|
||||
QObject *parent = 0);
|
||||
~BoundingBox();
|
||||
QWeakPointer<QGraphicsObject> highlightedObject;
|
||||
QGraphicsPolygonItem *highlightPolygon;
|
||||
QGraphicsPolygonItem *highlightPolygonEdge;
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(BoundingBox)
|
||||
|
||||
};
|
||||
|
||||
class BoundingBoxPolygonItem : public QGraphicsPolygonItem
|
||||
{
|
||||
public:
|
||||
explicit BoundingBoxPolygonItem(QGraphicsItem *item);
|
||||
int type() const;
|
||||
};
|
||||
|
||||
} // namespace QmlJSDebugger
|
||||
|
||||
#endif // BOUNDINGRECTHIGHLIGHTER_H
|
||||
@@ -1,118 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "colorpickertool.h"
|
||||
#include "qdeclarativeviewinspector.h"
|
||||
|
||||
#include <QMouseEvent>
|
||||
#include <QKeyEvent>
|
||||
#include <QRectF>
|
||||
#include <QRgb>
|
||||
#include <QImage>
|
||||
#include <QApplication>
|
||||
#include <QPalette>
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
ColorPickerTool::ColorPickerTool(QDeclarativeViewInspector *view) :
|
||||
AbstractLiveEditTool(view)
|
||||
{
|
||||
m_selectedColor.setRgb(0,0,0);
|
||||
}
|
||||
|
||||
ColorPickerTool::~ColorPickerTool()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ColorPickerTool::mousePressEvent(QMouseEvent * /*event*/)
|
||||
{
|
||||
}
|
||||
|
||||
void ColorPickerTool::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
pickColor(event->pos());
|
||||
}
|
||||
|
||||
void ColorPickerTool::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
pickColor(event->pos());
|
||||
}
|
||||
|
||||
void ColorPickerTool::mouseDoubleClickEvent(QMouseEvent * /*event*/)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void ColorPickerTool::hoverMoveEvent(QMouseEvent * /*event*/)
|
||||
{
|
||||
}
|
||||
|
||||
void ColorPickerTool::keyPressEvent(QKeyEvent * /*event*/)
|
||||
{
|
||||
}
|
||||
|
||||
void ColorPickerTool::keyReleaseEvent(QKeyEvent * /*keyEvent*/)
|
||||
{
|
||||
}
|
||||
void ColorPickerTool::wheelEvent(QWheelEvent * /*event*/)
|
||||
{
|
||||
}
|
||||
|
||||
void ColorPickerTool::itemsAboutToRemoved(const QList<QGraphicsItem*> &/*itemList*/)
|
||||
{
|
||||
}
|
||||
|
||||
void ColorPickerTool::clear()
|
||||
{
|
||||
view()->setCursor(Qt::CrossCursor);
|
||||
}
|
||||
|
||||
void ColorPickerTool::selectedItemsChanged(const QList<QGraphicsItem*> &/*itemList*/)
|
||||
{
|
||||
}
|
||||
|
||||
void ColorPickerTool::pickColor(const QPoint &pos)
|
||||
{
|
||||
QRgb fillColor = view()->backgroundBrush().color().rgb();
|
||||
if (view()->backgroundBrush().style() == Qt::NoBrush)
|
||||
fillColor = view()->palette().color(QPalette::Base).rgb();
|
||||
|
||||
QRectF target(0,0, 1, 1);
|
||||
QRect source(pos.x(), pos.y(), 1, 1);
|
||||
QImage img(1, 1, QImage::Format_ARGB32);
|
||||
img.fill(fillColor);
|
||||
QPainter painter(&img);
|
||||
view()->render(&painter, target, source);
|
||||
m_selectedColor = QColor::fromRgb(img.pixel(0, 0));
|
||||
|
||||
emit selectedColorChanged(m_selectedColor);
|
||||
}
|
||||
|
||||
} // namespace QmlJSDebugger
|
||||
@@ -1,81 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef COLORPICKERTOOL_H
|
||||
#define COLORPICKERTOOL_H
|
||||
|
||||
#include "abstractliveedittool.h"
|
||||
|
||||
#include <QColor>
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QPoint)
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
class ColorPickerTool : public AbstractLiveEditTool
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit ColorPickerTool(QDeclarativeViewInspector *view);
|
||||
|
||||
virtual ~ColorPickerTool();
|
||||
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
void mouseMoveEvent(QMouseEvent *event);
|
||||
void mouseReleaseEvent(QMouseEvent *event);
|
||||
void mouseDoubleClickEvent(QMouseEvent *event);
|
||||
|
||||
void hoverMoveEvent(QMouseEvent *event);
|
||||
|
||||
void keyPressEvent(QKeyEvent *event);
|
||||
void keyReleaseEvent(QKeyEvent *keyEvent);
|
||||
|
||||
void wheelEvent(QWheelEvent *event);
|
||||
|
||||
void itemsAboutToRemoved(const QList<QGraphicsItem*> &itemList);
|
||||
|
||||
void clear();
|
||||
|
||||
signals:
|
||||
void selectedColorChanged(const QColor &color);
|
||||
|
||||
protected:
|
||||
|
||||
void selectedItemsChanged(const QList<QGraphicsItem*> &itemList);
|
||||
|
||||
private:
|
||||
void pickColor(const QPoint &pos);
|
||||
|
||||
private:
|
||||
QColor m_selectedColor;
|
||||
};
|
||||
|
||||
} // namespace QmlJSDebugger
|
||||
|
||||
#endif // COLORPICKERTOOL_H
|
||||
@@ -1,79 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "livelayeritem.h"
|
||||
#include "qmlinspectorconstants.h"
|
||||
|
||||
#include <QGraphicsScene>
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
LiveLayerItem::LiveLayerItem(QGraphicsScene* scene)
|
||||
: QGraphicsObject()
|
||||
{
|
||||
scene->addItem(this);
|
||||
setZValue(1);
|
||||
setFlag(QGraphicsItem::ItemIsMovable, false);
|
||||
}
|
||||
|
||||
LiveLayerItem::~LiveLayerItem()
|
||||
{
|
||||
}
|
||||
|
||||
void LiveLayerItem::paint(QPainter * /*painter*/, const QStyleOptionGraphicsItem * /*option*/,
|
||||
QWidget * /*widget*/)
|
||||
{
|
||||
}
|
||||
|
||||
int LiveLayerItem::type() const
|
||||
{
|
||||
return Constants::EditorItemType;
|
||||
}
|
||||
|
||||
QRectF LiveLayerItem::boundingRect() const
|
||||
{
|
||||
return childrenBoundingRect();
|
||||
}
|
||||
|
||||
QList<QGraphicsItem*> LiveLayerItem::findAllChildItems() const
|
||||
{
|
||||
return findAllChildItems(this);
|
||||
}
|
||||
|
||||
QList<QGraphicsItem*> LiveLayerItem::findAllChildItems(const QGraphicsItem *item) const
|
||||
{
|
||||
QList<QGraphicsItem*> itemList(item->childItems());
|
||||
|
||||
foreach (QGraphicsItem *childItem, item->childItems())
|
||||
itemList += findAllChildItems(childItem);
|
||||
|
||||
return itemList;
|
||||
}
|
||||
|
||||
} // namespace QmlJSDebugger
|
||||
@@ -1,55 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef LIVELAYERITEM_H
|
||||
#define LIVELAYERITEM_H
|
||||
|
||||
#include <QGraphicsObject>
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
class LiveLayerItem : public QGraphicsObject
|
||||
{
|
||||
public:
|
||||
LiveLayerItem(QGraphicsScene *scene);
|
||||
~LiveLayerItem();
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget = 0);
|
||||
QRectF boundingRect() const;
|
||||
int type() const;
|
||||
|
||||
QList<QGraphicsItem*> findAllChildItems() const;
|
||||
|
||||
protected:
|
||||
QList<QGraphicsItem*> findAllChildItems(const QGraphicsItem *item) const;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // LIVELAYERITEM_H
|
||||
@@ -1,152 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "liverubberbandselectionmanipulator.h"
|
||||
#include "../qdeclarativeviewinspector_p.h"
|
||||
|
||||
#include <QGraphicsItem>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
LiveRubberBandSelectionManipulator::LiveRubberBandSelectionManipulator(QGraphicsObject *layerItem,
|
||||
QDeclarativeViewInspector *editorView)
|
||||
: m_selectionRectangleElement(layerItem),
|
||||
m_editorView(editorView),
|
||||
m_beginFormEditorItem(0),
|
||||
m_isActive(false)
|
||||
{
|
||||
m_selectionRectangleElement.hide();
|
||||
}
|
||||
|
||||
void LiveRubberBandSelectionManipulator::clear()
|
||||
{
|
||||
m_selectionRectangleElement.clear();
|
||||
m_isActive = false;
|
||||
m_beginPoint = QPointF();
|
||||
m_itemList.clear();
|
||||
m_oldSelectionList.clear();
|
||||
}
|
||||
|
||||
QGraphicsItem *LiveRubberBandSelectionManipulator::topFormEditorItem(const QList<QGraphicsItem*>
|
||||
&itemList)
|
||||
{
|
||||
if (itemList.isEmpty())
|
||||
return 0;
|
||||
|
||||
return itemList.first();
|
||||
}
|
||||
|
||||
void LiveRubberBandSelectionManipulator::begin(const QPointF &beginPoint)
|
||||
{
|
||||
m_beginPoint = beginPoint;
|
||||
m_selectionRectangleElement.setRect(m_beginPoint, m_beginPoint);
|
||||
m_selectionRectangleElement.show();
|
||||
m_isActive = true;
|
||||
QDeclarativeViewInspectorPrivate *inspectorPrivate
|
||||
= QDeclarativeViewInspectorPrivate::get(m_editorView);
|
||||
m_beginFormEditorItem = topFormEditorItem(inspectorPrivate->selectableItems(beginPoint));
|
||||
m_oldSelectionList = m_editorView->selectedItems();
|
||||
}
|
||||
|
||||
void LiveRubberBandSelectionManipulator::update(const QPointF &updatePoint)
|
||||
{
|
||||
m_selectionRectangleElement.setRect(m_beginPoint, updatePoint);
|
||||
}
|
||||
|
||||
void LiveRubberBandSelectionManipulator::end()
|
||||
{
|
||||
m_oldSelectionList.clear();
|
||||
m_selectionRectangleElement.hide();
|
||||
m_isActive = false;
|
||||
}
|
||||
|
||||
void LiveRubberBandSelectionManipulator::select(SelectionType selectionType)
|
||||
{
|
||||
QDeclarativeViewInspectorPrivate *inspectorPrivate
|
||||
= QDeclarativeViewInspectorPrivate::get(m_editorView);
|
||||
QList<QGraphicsItem*> itemList
|
||||
= inspectorPrivate->selectableItems(m_selectionRectangleElement.rect(),
|
||||
Qt::IntersectsItemShape);
|
||||
QList<QGraphicsItem*> newSelectionList;
|
||||
|
||||
foreach (QGraphicsItem* item, itemList) {
|
||||
if (item
|
||||
&& item->parentItem()
|
||||
&& !newSelectionList.contains(item)
|
||||
//&& m_beginFormEditorItem->childItems().contains(item) // TODO activate this test
|
||||
)
|
||||
{
|
||||
newSelectionList.append(item);
|
||||
}
|
||||
}
|
||||
|
||||
if (newSelectionList.isEmpty() && m_beginFormEditorItem)
|
||||
newSelectionList.append(m_beginFormEditorItem);
|
||||
|
||||
QList<QGraphicsItem*> resultList;
|
||||
|
||||
switch(selectionType) {
|
||||
case AddToSelection: {
|
||||
resultList.append(m_oldSelectionList);
|
||||
resultList.append(newSelectionList);
|
||||
}
|
||||
break;
|
||||
case ReplaceSelection: {
|
||||
resultList.append(newSelectionList);
|
||||
}
|
||||
break;
|
||||
case RemoveFromSelection: {
|
||||
QSet<QGraphicsItem*> oldSelectionSet(m_oldSelectionList.toSet());
|
||||
QSet<QGraphicsItem*> newSelectionSet(newSelectionList.toSet());
|
||||
resultList.append(oldSelectionSet.subtract(newSelectionSet).toList());
|
||||
}
|
||||
}
|
||||
|
||||
m_editorView->setSelectedItems(resultList);
|
||||
}
|
||||
|
||||
|
||||
void LiveRubberBandSelectionManipulator::setItems(const QList<QGraphicsItem*> &itemList)
|
||||
{
|
||||
m_itemList = itemList;
|
||||
}
|
||||
|
||||
QPointF LiveRubberBandSelectionManipulator::beginPoint() const
|
||||
{
|
||||
return m_beginPoint;
|
||||
}
|
||||
|
||||
bool LiveRubberBandSelectionManipulator::isActive() const
|
||||
{
|
||||
return m_isActive;
|
||||
}
|
||||
|
||||
} // namespace QmlJSDebugger
|
||||
@@ -1,85 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef RUBBERBANDSELECTIONMANIPULATOR_H
|
||||
#define RUBBERBANDSELECTIONMANIPULATOR_H
|
||||
|
||||
|
||||
#include "liveselectionrectangle.h"
|
||||
|
||||
#include <QPointF>
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QGraphicsItem)
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
class QDeclarativeViewInspector;
|
||||
|
||||
class LiveRubberBandSelectionManipulator
|
||||
{
|
||||
public:
|
||||
enum SelectionType {
|
||||
ReplaceSelection,
|
||||
AddToSelection,
|
||||
RemoveFromSelection
|
||||
};
|
||||
|
||||
LiveRubberBandSelectionManipulator(QGraphicsObject *layerItem,
|
||||
QDeclarativeViewInspector *editorView);
|
||||
|
||||
void setItems(const QList<QGraphicsItem*> &itemList);
|
||||
|
||||
void begin(const QPointF& beginPoint);
|
||||
void update(const QPointF& updatePoint);
|
||||
void end();
|
||||
|
||||
void clear();
|
||||
|
||||
void select(SelectionType selectionType);
|
||||
|
||||
QPointF beginPoint() const;
|
||||
|
||||
bool isActive() const;
|
||||
|
||||
protected:
|
||||
QGraphicsItem *topFormEditorItem(const QList<QGraphicsItem*> &itemList);
|
||||
|
||||
private:
|
||||
QList<QGraphicsItem*> m_itemList;
|
||||
QList<QGraphicsItem*> m_oldSelectionList;
|
||||
LiveSelectionRectangle m_selectionRectangleElement;
|
||||
QPointF m_beginPoint;
|
||||
QDeclarativeViewInspector *m_editorView;
|
||||
QGraphicsItem *m_beginFormEditorItem;
|
||||
bool m_isActive;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // RUBBERBANDSELECTIONMANIPULATOR_H
|
||||
@@ -1,105 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "liveselectionindicator.h"
|
||||
#include "../qdeclarativeviewinspector_p.h"
|
||||
#include "qmlinspectorconstants.h"
|
||||
|
||||
#include <QGraphicsRectItem>
|
||||
#include <QGraphicsObject>
|
||||
#include <QGraphicsScene>
|
||||
#include <QPen>
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
LiveSelectionIndicator::LiveSelectionIndicator(QDeclarativeViewInspector *viewInspector,
|
||||
QGraphicsObject *layerItem)
|
||||
: m_layerItem(layerItem)
|
||||
, m_view(viewInspector)
|
||||
{
|
||||
}
|
||||
|
||||
LiveSelectionIndicator::~LiveSelectionIndicator()
|
||||
{
|
||||
clear();
|
||||
}
|
||||
|
||||
void LiveSelectionIndicator::show()
|
||||
{
|
||||
foreach (QGraphicsRectItem *item, m_indicatorShapeHash)
|
||||
item->show();
|
||||
}
|
||||
|
||||
void LiveSelectionIndicator::hide()
|
||||
{
|
||||
foreach (QGraphicsRectItem *item, m_indicatorShapeHash)
|
||||
item->hide();
|
||||
}
|
||||
|
||||
void LiveSelectionIndicator::clear()
|
||||
{
|
||||
if (!m_layerItem.isNull()) {
|
||||
QGraphicsScene *scene = m_layerItem.data()->scene();
|
||||
foreach (QGraphicsRectItem *item, m_indicatorShapeHash) {
|
||||
scene->removeItem(item);
|
||||
delete item;
|
||||
}
|
||||
}
|
||||
|
||||
m_indicatorShapeHash.clear();
|
||||
|
||||
}
|
||||
|
||||
void LiveSelectionIndicator::setItems(const QList<QWeakPointer<QGraphicsObject> > &itemList)
|
||||
{
|
||||
clear();
|
||||
|
||||
foreach (const QWeakPointer<QGraphicsObject> &object, itemList) {
|
||||
if (object.isNull())
|
||||
continue;
|
||||
|
||||
QGraphicsItem *item = object.data();
|
||||
|
||||
if (!m_indicatorShapeHash.contains(item)) {
|
||||
QGraphicsRectItem *selectionIndicator = new QGraphicsRectItem(m_layerItem.data());
|
||||
m_indicatorShapeHash.insert(item, selectionIndicator);
|
||||
|
||||
const QRectF boundingRect = m_view->adjustToScreenBoundaries(item->mapRectToScene(item->boundingRect()));
|
||||
const QRectF boundingRectInLayerItemSpace = m_layerItem.data()->mapRectFromScene(boundingRect);
|
||||
|
||||
selectionIndicator->setData(Constants::EditorItemDataKey, true);
|
||||
selectionIndicator->setFlag(QGraphicsItem::ItemIsSelectable, false);
|
||||
selectionIndicator->setRect(boundingRectInLayerItemSpace);
|
||||
selectionIndicator->setPen(QColor(108, 141, 221));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} //namespace QmlJSDebugger
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef LIVESELECTIONINDICATOR_H
|
||||
#define LIVESELECTIONINDICATOR_H
|
||||
|
||||
#include <QWeakPointer>
|
||||
#include <QHash>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QGraphicsObject;
|
||||
class QGraphicsRectItem;
|
||||
class QGraphicsItem;
|
||||
class QPolygonF;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
class QDeclarativeViewInspector;
|
||||
|
||||
class LiveSelectionIndicator
|
||||
{
|
||||
public:
|
||||
LiveSelectionIndicator(QDeclarativeViewInspector *viewInspector, QGraphicsObject *layerItem);
|
||||
~LiveSelectionIndicator();
|
||||
|
||||
void show();
|
||||
void hide();
|
||||
|
||||
void clear();
|
||||
|
||||
void setItems(const QList<QWeakPointer<QGraphicsObject> > &itemList);
|
||||
|
||||
private:
|
||||
QHash<QGraphicsItem*, QGraphicsRectItem *> m_indicatorShapeHash;
|
||||
QWeakPointer<QGraphicsObject> m_layerItem;
|
||||
QDeclarativeViewInspector *m_view;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // LIVESELECTIONINDICATOR_H
|
||||
@@ -1,100 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "liveselectionrectangle.h"
|
||||
#include "qmlinspectorconstants.h"
|
||||
|
||||
#include <QPen>
|
||||
#include <QGraphicsRectItem>
|
||||
#include <QGraphicsObject>
|
||||
#include <QGraphicsScene>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include <cmath>
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
class SelectionRectShape : public QGraphicsRectItem
|
||||
{
|
||||
public:
|
||||
SelectionRectShape(QGraphicsItem *parent = 0) : QGraphicsRectItem(parent) {}
|
||||
int type() const { return Constants::EditorItemType; }
|
||||
};
|
||||
|
||||
LiveSelectionRectangle::LiveSelectionRectangle(QGraphicsObject *layerItem)
|
||||
: m_controlShape(new SelectionRectShape(layerItem)),
|
||||
m_layerItem(layerItem)
|
||||
{
|
||||
m_controlShape->setPen(QPen(Qt::black));
|
||||
m_controlShape->setBrush(QColor(128, 128, 128, 50));
|
||||
}
|
||||
|
||||
LiveSelectionRectangle::~LiveSelectionRectangle()
|
||||
{
|
||||
if (m_layerItem)
|
||||
m_layerItem.data()->scene()->removeItem(m_controlShape);
|
||||
}
|
||||
|
||||
void LiveSelectionRectangle::clear()
|
||||
{
|
||||
hide();
|
||||
}
|
||||
void LiveSelectionRectangle::show()
|
||||
{
|
||||
m_controlShape->show();
|
||||
}
|
||||
|
||||
void LiveSelectionRectangle::hide()
|
||||
{
|
||||
m_controlShape->hide();
|
||||
}
|
||||
|
||||
QRectF LiveSelectionRectangle::rect() const
|
||||
{
|
||||
return m_controlShape->mapFromScene(m_controlShape->rect()).boundingRect();
|
||||
}
|
||||
|
||||
void LiveSelectionRectangle::setRect(const QPointF &firstPoint,
|
||||
const QPointF &secondPoint)
|
||||
{
|
||||
double firstX = std::floor(firstPoint.x()) + 0.5;
|
||||
double firstY = std::floor(firstPoint.y()) + 0.5;
|
||||
double secondX = std::floor(secondPoint.x()) + 0.5;
|
||||
double secondY = std::floor(secondPoint.y()) + 0.5;
|
||||
QPointF topLeftPoint(firstX < secondX ? firstX : secondX,
|
||||
firstY < secondY ? firstY : secondY);
|
||||
QPointF bottomRightPoint(firstX > secondX ? firstX : secondX,
|
||||
firstY > secondY ? firstY : secondY);
|
||||
|
||||
QRectF rect(topLeftPoint, bottomRightPoint);
|
||||
m_controlShape->setRect(rect);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef LIVESELECTIONRECTANGLE_H
|
||||
#define LIVESELECTIONRECTANGLE_H
|
||||
|
||||
#include <QWeakPointer>
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QGraphicsObject)
|
||||
QT_FORWARD_DECLARE_CLASS(QGraphicsRectItem)
|
||||
QT_FORWARD_DECLARE_CLASS(QPointF)
|
||||
QT_FORWARD_DECLARE_CLASS(QRectF)
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
class LiveSelectionRectangle
|
||||
{
|
||||
public:
|
||||
LiveSelectionRectangle(QGraphicsObject *layerItem);
|
||||
~LiveSelectionRectangle();
|
||||
|
||||
void show();
|
||||
void hide();
|
||||
|
||||
void clear();
|
||||
|
||||
void setRect(const QPointF &firstPoint,
|
||||
const QPointF &secondPoint);
|
||||
|
||||
QRectF rect() const;
|
||||
|
||||
private:
|
||||
QGraphicsRectItem *m_controlShape;
|
||||
QWeakPointer<QGraphicsObject> m_layerItem;
|
||||
};
|
||||
|
||||
} // namespace QmlJSDebugger
|
||||
|
||||
#endif // LIVESELECTIONRECTANGLE_H
|
||||
@@ -1,424 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "liveselectiontool.h"
|
||||
#include "livelayeritem.h"
|
||||
|
||||
#include "../qdeclarativeviewinspector_p.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QWheelEvent>
|
||||
#include <QMouseEvent>
|
||||
#include <QClipboard>
|
||||
#include <QMenu>
|
||||
#include <QAction>
|
||||
#include <QGraphicsObject>
|
||||
|
||||
#include <QDeclarativeItem>
|
||||
#include <QDeclarativeEngine>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
LiveSelectionTool::LiveSelectionTool(QDeclarativeViewInspector *editorView) :
|
||||
AbstractLiveEditTool(editorView),
|
||||
m_rubberbandSelectionMode(false),
|
||||
m_rubberbandSelectionManipulator(
|
||||
QDeclarativeViewInspectorPrivate::get(editorView)->manipulatorLayer, editorView),
|
||||
m_singleSelectionManipulator(editorView),
|
||||
m_selectionIndicator(editorView,
|
||||
QDeclarativeViewInspectorPrivate::get(editorView)->manipulatorLayer),
|
||||
//m_resizeIndicator(editorView->manipulatorLayer()),
|
||||
m_selectOnlyContentItems(true)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
LiveSelectionTool::~LiveSelectionTool()
|
||||
{
|
||||
}
|
||||
|
||||
void LiveSelectionTool::setRubberbandSelectionMode(bool value)
|
||||
{
|
||||
m_rubberbandSelectionMode = value;
|
||||
}
|
||||
|
||||
LiveSingleSelectionManipulator::SelectionType LiveSelectionTool::getSelectionType(Qt::KeyboardModifiers
|
||||
modifiers)
|
||||
{
|
||||
LiveSingleSelectionManipulator::SelectionType selectionType
|
||||
= LiveSingleSelectionManipulator::ReplaceSelection;
|
||||
if (modifiers.testFlag(Qt::ControlModifier)) {
|
||||
selectionType = LiveSingleSelectionManipulator::RemoveFromSelection;
|
||||
} else if (modifiers.testFlag(Qt::ShiftModifier)) {
|
||||
selectionType = LiveSingleSelectionManipulator::AddToSelection;
|
||||
}
|
||||
return selectionType;
|
||||
}
|
||||
|
||||
bool LiveSelectionTool::alreadySelected(const QList<QGraphicsItem*> &itemList) const
|
||||
{
|
||||
QDeclarativeViewInspectorPrivate *inspectorPrivate
|
||||
= QDeclarativeViewInspectorPrivate::get(inspector());
|
||||
const QList<QGraphicsItem*> selectedItems = inspectorPrivate->selectedItems();
|
||||
|
||||
if (selectedItems.isEmpty())
|
||||
return false;
|
||||
|
||||
foreach (QGraphicsItem *item, itemList)
|
||||
if (selectedItems.contains(item))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void LiveSelectionTool::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
QDeclarativeViewInspectorPrivate *inspectorPrivate
|
||||
= QDeclarativeViewInspectorPrivate::get(inspector());
|
||||
QList<QGraphicsItem*> itemList = inspectorPrivate->selectableItems(event->pos());
|
||||
LiveSingleSelectionManipulator::SelectionType selectionType = getSelectionType(event->modifiers());
|
||||
|
||||
if (event->buttons() & Qt::LeftButton) {
|
||||
m_mousePressTimer.start();
|
||||
|
||||
if (m_rubberbandSelectionMode) {
|
||||
m_rubberbandSelectionManipulator.begin(event->pos());
|
||||
} else {
|
||||
m_singleSelectionManipulator.begin(event->pos());
|
||||
m_singleSelectionManipulator.select(selectionType, m_selectOnlyContentItems);
|
||||
}
|
||||
} else if (event->buttons() & Qt::RightButton) {
|
||||
createContextMenu(itemList, event->globalPos());
|
||||
}
|
||||
}
|
||||
|
||||
void LiveSelectionTool::createContextMenu(QList<QGraphicsItem*> itemList, QPoint globalPos)
|
||||
{
|
||||
QMenu contextMenu;
|
||||
connect(&contextMenu, SIGNAL(hovered(QAction*)),
|
||||
this, SLOT(contextMenuElementHovered(QAction*)));
|
||||
|
||||
m_contextMenuItemList = itemList;
|
||||
|
||||
contextMenu.addAction("Items");
|
||||
contextMenu.addSeparator();
|
||||
int shortcutKey = Qt::Key_1;
|
||||
bool addKeySequence = true;
|
||||
int i = 0;
|
||||
|
||||
foreach (QGraphicsItem * const item, itemList) {
|
||||
QString itemTitle = titleForItem(item);
|
||||
QAction *elementAction = contextMenu.addAction(itemTitle, this,
|
||||
SLOT(contextMenuElementSelected()));
|
||||
|
||||
if (inspector()->selectedItems().contains(item)) {
|
||||
QFont boldFont = elementAction->font();
|
||||
boldFont.setBold(true);
|
||||
elementAction->setFont(boldFont);
|
||||
}
|
||||
|
||||
elementAction->setData(i);
|
||||
if (addKeySequence)
|
||||
elementAction->setShortcut(QKeySequence(shortcutKey));
|
||||
|
||||
shortcutKey++;
|
||||
if (shortcutKey > Qt::Key_9)
|
||||
addKeySequence = false;
|
||||
|
||||
++i;
|
||||
}
|
||||
// add root item separately
|
||||
// QString itemTitle = QString(tr("%1")).arg(titleForItem(view()->currentRootItem()));
|
||||
// contextMenu.addAction(itemTitle, this, SLOT(contextMenuElementSelected()));
|
||||
// m_contextMenuItemList.append(view()->currentRootItem());
|
||||
|
||||
contextMenu.exec(globalPos);
|
||||
m_contextMenuItemList.clear();
|
||||
}
|
||||
|
||||
void LiveSelectionTool::contextMenuElementSelected()
|
||||
{
|
||||
QAction *senderAction = static_cast<QAction*>(sender());
|
||||
int itemListIndex = senderAction->data().toInt();
|
||||
if (itemListIndex >= 0 && itemListIndex < m_contextMenuItemList.length()) {
|
||||
|
||||
QPointF updatePt(0, 0);
|
||||
QGraphicsItem *item = m_contextMenuItemList.at(itemListIndex);
|
||||
m_singleSelectionManipulator.begin(updatePt);
|
||||
m_singleSelectionManipulator.select(LiveSingleSelectionManipulator::InvertSelection,
|
||||
QList<QGraphicsItem*>() << item,
|
||||
false);
|
||||
m_singleSelectionManipulator.end(updatePt);
|
||||
}
|
||||
}
|
||||
|
||||
void LiveSelectionTool::contextMenuElementHovered(QAction *action)
|
||||
{
|
||||
int itemListIndex = action->data().toInt();
|
||||
if (itemListIndex >= 0 && itemListIndex < m_contextMenuItemList.length()) {
|
||||
QGraphicsObject *item = m_contextMenuItemList.at(itemListIndex)->toGraphicsObject();
|
||||
QDeclarativeViewInspectorPrivate::get(inspector())->highlight(item);
|
||||
}
|
||||
}
|
||||
|
||||
void LiveSelectionTool::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
if (m_singleSelectionManipulator.isActive()) {
|
||||
QPointF mouseMovementVector = m_singleSelectionManipulator.beginPoint() - event->pos();
|
||||
|
||||
if ((mouseMovementVector.toPoint().manhattanLength() > Constants::DragStartDistance)
|
||||
&& (m_mousePressTimer.elapsed() > Constants::DragStartTime))
|
||||
{
|
||||
m_singleSelectionManipulator.end(event->pos());
|
||||
//view()->changeToMoveTool(m_singleSelectionManipulator.beginPoint());
|
||||
return;
|
||||
}
|
||||
} else if (m_rubberbandSelectionManipulator.isActive()) {
|
||||
QPointF mouseMovementVector = m_rubberbandSelectionManipulator.beginPoint() - event->pos();
|
||||
|
||||
if ((mouseMovementVector.toPoint().manhattanLength() > Constants::DragStartDistance)
|
||||
&& (m_mousePressTimer.elapsed() > Constants::DragStartTime)) {
|
||||
m_rubberbandSelectionManipulator.update(event->pos());
|
||||
|
||||
if (event->modifiers().testFlag(Qt::ControlModifier))
|
||||
m_rubberbandSelectionManipulator.select(
|
||||
LiveRubberBandSelectionManipulator::RemoveFromSelection);
|
||||
else if (event->modifiers().testFlag(Qt::ShiftModifier))
|
||||
m_rubberbandSelectionManipulator.select(
|
||||
LiveRubberBandSelectionManipulator::AddToSelection);
|
||||
else
|
||||
m_rubberbandSelectionManipulator.select(
|
||||
LiveRubberBandSelectionManipulator::ReplaceSelection);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LiveSelectionTool::hoverMoveEvent(QMouseEvent * event)
|
||||
{
|
||||
// ### commented out until move tool is re-enabled
|
||||
// QList<QGraphicsItem*> itemList = view()->items(event->pos());
|
||||
// if (!itemList.isEmpty() && !m_rubberbandSelectionMode) {
|
||||
//
|
||||
// foreach (QGraphicsItem *item, itemList) {
|
||||
// if (item->type() == Constants::ResizeHandleItemType) {
|
||||
// ResizeHandleItem* resizeHandle = ResizeHandleItem::fromGraphicsItem(item);
|
||||
// if (resizeHandle)
|
||||
// view()->changeTool(Constants::ResizeToolMode);
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// if (topSelectedItemIsMovable(itemList))
|
||||
// view()->changeTool(Constants::MoveToolMode);
|
||||
// }
|
||||
QDeclarativeViewInspectorPrivate *inspectorPrivate
|
||||
= QDeclarativeViewInspectorPrivate::get(inspector());
|
||||
|
||||
QList<QGraphicsItem*> selectableItemList = inspectorPrivate->selectableItems(event->pos());
|
||||
if (!selectableItemList.isEmpty()) {
|
||||
QGraphicsObject *item = selectableItemList.first()->toGraphicsObject();
|
||||
if (item)
|
||||
QDeclarativeViewInspectorPrivate::get(inspector())->highlight(item);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
QDeclarativeViewInspectorPrivate::get(inspector())->clearHighlight();
|
||||
}
|
||||
|
||||
void LiveSelectionTool::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
if (m_singleSelectionManipulator.isActive()) {
|
||||
m_singleSelectionManipulator.end(event->pos());
|
||||
} else if (m_rubberbandSelectionManipulator.isActive()) {
|
||||
QPointF mouseMovementVector = m_rubberbandSelectionManipulator.beginPoint() - event->pos();
|
||||
if (mouseMovementVector.toPoint().manhattanLength() < Constants::DragStartDistance) {
|
||||
m_singleSelectionManipulator.begin(event->pos());
|
||||
|
||||
if (event->modifiers().testFlag(Qt::ControlModifier))
|
||||
m_singleSelectionManipulator.select(LiveSingleSelectionManipulator::RemoveFromSelection,
|
||||
m_selectOnlyContentItems);
|
||||
else if (event->modifiers().testFlag(Qt::ShiftModifier))
|
||||
m_singleSelectionManipulator.select(LiveSingleSelectionManipulator::AddToSelection,
|
||||
m_selectOnlyContentItems);
|
||||
else
|
||||
m_singleSelectionManipulator.select(LiveSingleSelectionManipulator::InvertSelection,
|
||||
m_selectOnlyContentItems);
|
||||
|
||||
m_singleSelectionManipulator.end(event->pos());
|
||||
} else {
|
||||
m_rubberbandSelectionManipulator.update(event->pos());
|
||||
|
||||
if (event->modifiers().testFlag(Qt::ControlModifier))
|
||||
m_rubberbandSelectionManipulator.select(
|
||||
LiveRubberBandSelectionManipulator::RemoveFromSelection);
|
||||
else if (event->modifiers().testFlag(Qt::ShiftModifier))
|
||||
m_rubberbandSelectionManipulator.select(
|
||||
LiveRubberBandSelectionManipulator::AddToSelection);
|
||||
else
|
||||
m_rubberbandSelectionManipulator.select(
|
||||
LiveRubberBandSelectionManipulator::ReplaceSelection);
|
||||
|
||||
m_rubberbandSelectionManipulator.end();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LiveSelectionTool::mouseDoubleClickEvent(QMouseEvent * /*event*/)
|
||||
{
|
||||
}
|
||||
|
||||
void LiveSelectionTool::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
switch(event->key()) {
|
||||
case Qt::Key_Left:
|
||||
case Qt::Key_Right:
|
||||
case Qt::Key_Up:
|
||||
case Qt::Key_Down:
|
||||
// disabled for now, cannot move stuff yet.
|
||||
//view()->changeTool(Constants::MoveToolMode);
|
||||
//view()->currentTool()->keyPressEvent(event);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void LiveSelectionTool::keyReleaseEvent(QKeyEvent * /*keyEvent*/)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void LiveSelectionTool::wheelEvent(QWheelEvent *event)
|
||||
{
|
||||
if (event->orientation() == Qt::Horizontal || m_rubberbandSelectionMode)
|
||||
return;
|
||||
|
||||
QDeclarativeViewInspectorPrivate *inspectorPrivate
|
||||
= QDeclarativeViewInspectorPrivate::get(inspector());
|
||||
QList<QGraphicsItem*> itemList = inspectorPrivate->selectableItems(event->pos());
|
||||
|
||||
if (itemList.isEmpty())
|
||||
return;
|
||||
|
||||
int selectedIdx = 0;
|
||||
if (!inspector()->selectedItems().isEmpty()) {
|
||||
selectedIdx = itemList.indexOf(inspector()->selectedItems().first());
|
||||
if (selectedIdx >= 0) {
|
||||
if (event->delta() > 0) {
|
||||
selectedIdx++;
|
||||
if (selectedIdx == itemList.length())
|
||||
selectedIdx = 0;
|
||||
} else if (event->delta() < 0) {
|
||||
selectedIdx--;
|
||||
if (selectedIdx == -1)
|
||||
selectedIdx = itemList.length() - 1;
|
||||
}
|
||||
} else {
|
||||
selectedIdx = 0;
|
||||
}
|
||||
}
|
||||
|
||||
QPointF updatePt(0, 0);
|
||||
m_singleSelectionManipulator.begin(updatePt);
|
||||
m_singleSelectionManipulator.select(LiveSingleSelectionManipulator::ReplaceSelection,
|
||||
QList<QGraphicsItem*>() << itemList.at(selectedIdx),
|
||||
false);
|
||||
m_singleSelectionManipulator.end(updatePt);
|
||||
|
||||
}
|
||||
|
||||
void LiveSelectionTool::setSelectOnlyContentItems(bool selectOnlyContentItems)
|
||||
{
|
||||
m_selectOnlyContentItems = selectOnlyContentItems;
|
||||
}
|
||||
|
||||
void LiveSelectionTool::itemsAboutToRemoved(const QList<QGraphicsItem*> &/*itemList*/)
|
||||
{
|
||||
}
|
||||
|
||||
void LiveSelectionTool::clear()
|
||||
{
|
||||
view()->setCursor(Qt::ArrowCursor);
|
||||
m_rubberbandSelectionManipulator.clear(),
|
||||
m_singleSelectionManipulator.clear();
|
||||
m_selectionIndicator.clear();
|
||||
//m_resizeIndicator.clear();
|
||||
}
|
||||
|
||||
void LiveSelectionTool::selectedItemsChanged(const QList<QGraphicsItem*> &itemList)
|
||||
{
|
||||
foreach (const QWeakPointer<QGraphicsObject> &obj, m_selectedItemList) {
|
||||
if (!obj.isNull()) {
|
||||
disconnect(obj.data(), SIGNAL(xChanged()), this, SLOT(repaintBoundingRects()));
|
||||
disconnect(obj.data(), SIGNAL(yChanged()), this, SLOT(repaintBoundingRects()));
|
||||
disconnect(obj.data(), SIGNAL(widthChanged()), this, SLOT(repaintBoundingRects()));
|
||||
disconnect(obj.data(), SIGNAL(heightChanged()), this, SLOT(repaintBoundingRects()));
|
||||
disconnect(obj.data(), SIGNAL(rotationChanged()), this, SLOT(repaintBoundingRects()));
|
||||
}
|
||||
}
|
||||
|
||||
QList<QGraphicsObject*> objects = toGraphicsObjectList(itemList);
|
||||
m_selectedItemList.clear();
|
||||
|
||||
foreach (QGraphicsObject *obj, objects) {
|
||||
m_selectedItemList.append(obj);
|
||||
connect(obj, SIGNAL(xChanged()), this, SLOT(repaintBoundingRects()));
|
||||
connect(obj, SIGNAL(yChanged()), this, SLOT(repaintBoundingRects()));
|
||||
connect(obj, SIGNAL(widthChanged()), this, SLOT(repaintBoundingRects()));
|
||||
connect(obj, SIGNAL(heightChanged()), this, SLOT(repaintBoundingRects()));
|
||||
connect(obj, SIGNAL(rotationChanged()), this, SLOT(repaintBoundingRects()));
|
||||
}
|
||||
|
||||
m_selectionIndicator.setItems(m_selectedItemList);
|
||||
//m_resizeIndicator.setItems(toGraphicsObjectList(itemList));
|
||||
}
|
||||
|
||||
void LiveSelectionTool::repaintBoundingRects()
|
||||
{
|
||||
m_selectionIndicator.setItems(m_selectedItemList);
|
||||
}
|
||||
|
||||
void LiveSelectionTool::selectUnderPoint(QMouseEvent *event)
|
||||
{
|
||||
m_singleSelectionManipulator.begin(event->pos());
|
||||
|
||||
if (event->modifiers().testFlag(Qt::ControlModifier))
|
||||
m_singleSelectionManipulator.select(LiveSingleSelectionManipulator::RemoveFromSelection,
|
||||
m_selectOnlyContentItems);
|
||||
else if (event->modifiers().testFlag(Qt::ShiftModifier))
|
||||
m_singleSelectionManipulator.select(LiveSingleSelectionManipulator::AddToSelection,
|
||||
m_selectOnlyContentItems);
|
||||
else
|
||||
m_singleSelectionManipulator.select(LiveSingleSelectionManipulator::InvertSelection,
|
||||
m_selectOnlyContentItems);
|
||||
|
||||
m_singleSelectionManipulator.end(event->pos());
|
||||
}
|
||||
|
||||
} // namespace QmlJSDebugger
|
||||
@@ -1,109 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef LIVESELECTIONTOOL_H
|
||||
#define LIVESELECTIONTOOL_H
|
||||
|
||||
|
||||
#include "abstractliveedittool.h"
|
||||
#include "liverubberbandselectionmanipulator.h"
|
||||
#include "livesingleselectionmanipulator.h"
|
||||
#include "liveselectionindicator.h"
|
||||
|
||||
#include <QList>
|
||||
#include <QTime>
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QGraphicsItem)
|
||||
QT_FORWARD_DECLARE_CLASS(QMouseEvent)
|
||||
QT_FORWARD_DECLARE_CLASS(QKeyEvent)
|
||||
QT_FORWARD_DECLARE_CLASS(QAction)
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
class LiveSelectionTool : public AbstractLiveEditTool
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
LiveSelectionTool(QDeclarativeViewInspector* editorView);
|
||||
~LiveSelectionTool();
|
||||
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
void mouseMoveEvent(QMouseEvent *event);
|
||||
void mouseReleaseEvent(QMouseEvent *event);
|
||||
void mouseDoubleClickEvent(QMouseEvent *event);
|
||||
void hoverMoveEvent(QMouseEvent *event);
|
||||
void keyPressEvent(QKeyEvent *event);
|
||||
void keyReleaseEvent(QKeyEvent *keyEvent);
|
||||
void wheelEvent(QWheelEvent *event);
|
||||
|
||||
void itemsAboutToRemoved(const QList<QGraphicsItem*> &itemList);
|
||||
// QVariant itemChange(const QList<QGraphicsItem*> &itemList,
|
||||
// QGraphicsItem::GraphicsItemChange change,
|
||||
// const QVariant &value );
|
||||
|
||||
// void update();
|
||||
|
||||
void clear();
|
||||
|
||||
void selectedItemsChanged(const QList<QGraphicsItem*> &itemList);
|
||||
|
||||
void selectUnderPoint(QMouseEvent *event);
|
||||
|
||||
void setSelectOnlyContentItems(bool selectOnlyContentItems);
|
||||
|
||||
void setRubberbandSelectionMode(bool value);
|
||||
|
||||
private slots:
|
||||
void contextMenuElementSelected();
|
||||
void contextMenuElementHovered(QAction *action);
|
||||
void repaintBoundingRects();
|
||||
|
||||
private:
|
||||
void createContextMenu(QList<QGraphicsItem*> itemList, QPoint globalPos);
|
||||
LiveSingleSelectionManipulator::SelectionType getSelectionType(Qt::KeyboardModifiers modifiers);
|
||||
bool alreadySelected(const QList<QGraphicsItem*> &itemList) const;
|
||||
|
||||
private:
|
||||
bool m_rubberbandSelectionMode;
|
||||
LiveRubberBandSelectionManipulator m_rubberbandSelectionManipulator;
|
||||
LiveSingleSelectionManipulator m_singleSelectionManipulator;
|
||||
LiveSelectionIndicator m_selectionIndicator;
|
||||
//ResizeIndicator m_resizeIndicator;
|
||||
QTime m_mousePressTimer;
|
||||
bool m_selectOnlyContentItems;
|
||||
|
||||
QList<QWeakPointer<QGraphicsObject> > m_selectedItemList;
|
||||
|
||||
QList<QGraphicsItem*> m_contextMenuItemList;
|
||||
};
|
||||
|
||||
} // namespace QmlJSDebugger
|
||||
|
||||
#endif // LIVESELECTIONTOOL_H
|
||||
@@ -1,138 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "livesingleselectionmanipulator.h"
|
||||
#include "qdeclarativeviewinspector.h"
|
||||
#include "../qdeclarativeviewinspector_p.h"
|
||||
#include <QDebug>
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
LiveSingleSelectionManipulator::LiveSingleSelectionManipulator(QDeclarativeViewInspector *editorView)
|
||||
: m_editorView(editorView),
|
||||
m_isActive(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void LiveSingleSelectionManipulator::begin(const QPointF &beginPoint)
|
||||
{
|
||||
m_beginPoint = beginPoint;
|
||||
m_isActive = true;
|
||||
m_oldSelectionList = QDeclarativeViewInspectorPrivate::get(m_editorView)->selectedItems();
|
||||
}
|
||||
|
||||
void LiveSingleSelectionManipulator::update(const QPointF &/*updatePoint*/)
|
||||
{
|
||||
m_oldSelectionList.clear();
|
||||
}
|
||||
|
||||
void LiveSingleSelectionManipulator::clear()
|
||||
{
|
||||
m_beginPoint = QPointF();
|
||||
m_oldSelectionList.clear();
|
||||
}
|
||||
|
||||
|
||||
void LiveSingleSelectionManipulator::end(const QPointF &/*updatePoint*/)
|
||||
{
|
||||
m_oldSelectionList.clear();
|
||||
m_isActive = false;
|
||||
}
|
||||
|
||||
void LiveSingleSelectionManipulator::select(SelectionType selectionType,
|
||||
const QList<QGraphicsItem*> &items,
|
||||
bool /*selectOnlyContentItems*/)
|
||||
{
|
||||
QGraphicsItem *selectedItem = 0;
|
||||
|
||||
foreach (QGraphicsItem* item, items)
|
||||
{
|
||||
//FormEditorItem *formEditorItem = FormEditorItem::fromQGraphicsItem(item);
|
||||
if (item
|
||||
/*&& !formEditorItem->qmlItemNode().isRootNode()
|
||||
&& (formEditorItem->qmlItemNode().hasShowContent() || !selectOnlyContentItems)*/)
|
||||
{
|
||||
selectedItem = item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
QList<QGraphicsItem*> resultList;
|
||||
|
||||
switch(selectionType) {
|
||||
case AddToSelection: {
|
||||
resultList.append(m_oldSelectionList);
|
||||
if (selectedItem && !m_oldSelectionList.contains(selectedItem))
|
||||
resultList.append(selectedItem);
|
||||
}
|
||||
break;
|
||||
case ReplaceSelection: {
|
||||
if (selectedItem)
|
||||
resultList.append(selectedItem);
|
||||
}
|
||||
break;
|
||||
case RemoveFromSelection: {
|
||||
resultList.append(m_oldSelectionList);
|
||||
if (selectedItem)
|
||||
resultList.removeAll(selectedItem);
|
||||
}
|
||||
break;
|
||||
case InvertSelection: {
|
||||
if (selectedItem
|
||||
&& !m_oldSelectionList.contains(selectedItem))
|
||||
{
|
||||
resultList.append(selectedItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_editorView->setSelectedItems(resultList);
|
||||
}
|
||||
|
||||
void LiveSingleSelectionManipulator::select(SelectionType selectionType, bool selectOnlyContentItems)
|
||||
{
|
||||
QDeclarativeViewInspectorPrivate *inspectorPrivate =
|
||||
QDeclarativeViewInspectorPrivate::get(m_editorView);
|
||||
QList<QGraphicsItem*> itemList = inspectorPrivate->selectableItems(m_beginPoint);
|
||||
select(selectionType, itemList, selectOnlyContentItems);
|
||||
}
|
||||
|
||||
|
||||
bool LiveSingleSelectionManipulator::isActive() const
|
||||
{
|
||||
return m_isActive;
|
||||
}
|
||||
|
||||
QPointF LiveSingleSelectionManipulator::beginPoint() const
|
||||
{
|
||||
return m_beginPoint;
|
||||
}
|
||||
|
||||
} // namespace QmlJSDebugger
|
||||
@@ -1,77 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef LIVESINGLESELECTIONMANIPULATOR_H
|
||||
#define LIVESINGLESELECTIONMANIPULATOR_H
|
||||
|
||||
#include <QPointF>
|
||||
#include <QList>
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QGraphicsItem);
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
class QDeclarativeViewInspector;
|
||||
|
||||
class LiveSingleSelectionManipulator
|
||||
{
|
||||
public:
|
||||
LiveSingleSelectionManipulator(QDeclarativeViewInspector *editorView);
|
||||
|
||||
enum SelectionType {
|
||||
ReplaceSelection,
|
||||
AddToSelection,
|
||||
RemoveFromSelection,
|
||||
InvertSelection
|
||||
};
|
||||
|
||||
void begin(const QPointF& beginPoint);
|
||||
void update(const QPointF& updatePoint);
|
||||
void end(const QPointF& updatePoint);
|
||||
|
||||
void select(SelectionType selectionType, const QList<QGraphicsItem*> &items,
|
||||
bool selectOnlyContentItems);
|
||||
void select(SelectionType selectionType, bool selectOnlyContentItems);
|
||||
|
||||
void clear();
|
||||
|
||||
QPointF beginPoint() const;
|
||||
|
||||
bool isActive() const;
|
||||
|
||||
private:
|
||||
QList<QGraphicsItem*> m_oldSelectionList;
|
||||
QPointF m_beginPoint;
|
||||
QDeclarativeViewInspector *m_editorView;
|
||||
bool m_isActive;
|
||||
};
|
||||
|
||||
} // namespace QmlJSDebugger
|
||||
|
||||
#endif // LIVESINGLESELECTIONMANIPULATOR_H
|
||||
@@ -1,116 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "subcomponentmasklayeritem.h"
|
||||
#include "qmlinspectorconstants.h"
|
||||
#include "qdeclarativeviewinspector.h"
|
||||
#include <QPolygonF>
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
SubcomponentMaskLayerItem::SubcomponentMaskLayerItem(QDeclarativeViewInspector *inspector,
|
||||
QGraphicsItem *parentItem) :
|
||||
QGraphicsPolygonItem(parentItem),
|
||||
m_inspector(inspector),
|
||||
m_currentItem(0),
|
||||
m_borderRect(new QGraphicsRectItem(this))
|
||||
{
|
||||
m_borderRect->setRect(0,0,0,0);
|
||||
m_borderRect->setPen(QPen(QColor(60, 60, 60), 1));
|
||||
m_borderRect->setData(Constants::EditorItemDataKey, QVariant(true));
|
||||
|
||||
setBrush(QBrush(QColor(160,160,160)));
|
||||
setPen(Qt::NoPen);
|
||||
}
|
||||
|
||||
int SubcomponentMaskLayerItem::type() const
|
||||
{
|
||||
return Constants::EditorItemType;
|
||||
}
|
||||
|
||||
static QRectF resizeRect(const QRectF &newRect, const QRectF &oldRect)
|
||||
{
|
||||
QRectF result = newRect;
|
||||
if (oldRect.left() < newRect.left())
|
||||
result.setLeft(oldRect.left());
|
||||
|
||||
if (oldRect.top() < newRect.top())
|
||||
result.setTop(oldRect.top());
|
||||
|
||||
if (oldRect.right() > newRect.right())
|
||||
result.setRight(oldRect.right());
|
||||
|
||||
if (oldRect.bottom() > newRect.bottom())
|
||||
result.setBottom(oldRect.bottom());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static QPolygonF regionToPolygon(const QRegion ®ion)
|
||||
{
|
||||
QPainterPath path;
|
||||
foreach (const QRect &rect, region.rects())
|
||||
path.addRect(rect);
|
||||
return path.toFillPolygon();
|
||||
}
|
||||
|
||||
void SubcomponentMaskLayerItem::setCurrentItem(QGraphicsItem *item)
|
||||
{
|
||||
QGraphicsItem *prevItem = m_currentItem;
|
||||
m_currentItem = item;
|
||||
|
||||
if (!m_currentItem)
|
||||
return;
|
||||
|
||||
QRect viewRect = m_inspector->declarativeView()->rect();
|
||||
viewRect = m_inspector->declarativeView()->mapToScene(viewRect).boundingRect().toRect();
|
||||
|
||||
QRectF itemRect = item->boundingRect() | item->childrenBoundingRect();
|
||||
itemRect = item->mapRectToScene(itemRect);
|
||||
|
||||
// if updating the same item as before, resize the rectangle only bigger, not smaller.
|
||||
if (prevItem == item && prevItem != 0) {
|
||||
m_itemPolyRect = resizeRect(itemRect, m_itemPolyRect);
|
||||
} else {
|
||||
m_itemPolyRect = itemRect;
|
||||
}
|
||||
QRectF borderRect = m_itemPolyRect;
|
||||
borderRect.adjust(-1, -1, 1, 1);
|
||||
m_borderRect->setRect(borderRect);
|
||||
|
||||
const QRegion externalRegion = QRegion(viewRect).subtracted(m_itemPolyRect.toRect());
|
||||
setPolygon(regionToPolygon(externalRegion));
|
||||
}
|
||||
|
||||
QGraphicsItem *SubcomponentMaskLayerItem::currentItem() const
|
||||
{
|
||||
return m_currentItem;
|
||||
}
|
||||
|
||||
} // namespace QmlJSDebugger
|
||||
@@ -1,59 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef SUBCOMPONENTMASKLAYERITEM_H
|
||||
#define SUBCOMPONENTMASKLAYERITEM_H
|
||||
|
||||
#include <QGraphicsPolygonItem>
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
class QDeclarativeViewInspector;
|
||||
|
||||
class SubcomponentMaskLayerItem : public QGraphicsPolygonItem
|
||||
{
|
||||
public:
|
||||
explicit SubcomponentMaskLayerItem(QDeclarativeViewInspector *inspector,
|
||||
QGraphicsItem *parentItem = 0);
|
||||
int type() const;
|
||||
void setCurrentItem(QGraphicsItem *item);
|
||||
void setBoundingBox(const QRectF &boundingBox);
|
||||
QGraphicsItem *currentItem() const;
|
||||
QRectF itemRect() const;
|
||||
|
||||
private:
|
||||
QDeclarativeViewInspector *m_inspector;
|
||||
QGraphicsItem *m_currentItem;
|
||||
QGraphicsRectItem *m_borderRect;
|
||||
QRectF m_itemPolyRect;
|
||||
};
|
||||
|
||||
} // namespace QmlJSDebugger
|
||||
|
||||
#endif // SUBCOMPONENTMASKLAYERITEM_H
|
||||
@@ -1,323 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "zoomtool.h"
|
||||
#include "../qdeclarativeviewinspector_p.h"
|
||||
|
||||
#include <QMouseEvent>
|
||||
#include <QWheelEvent>
|
||||
#include <QKeyEvent>
|
||||
#include <QMenu>
|
||||
#include <QAction>
|
||||
|
||||
#include <QRectF>
|
||||
#include <QDebug>
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
ZoomTool::ZoomTool(QDeclarativeViewInspector *view) :
|
||||
AbstractLiveEditTool(view),
|
||||
m_rubberbandManipulator(),
|
||||
m_smoothZoomMultiplier(0.05f),
|
||||
m_currentScale(1.0f)
|
||||
{
|
||||
m_zoomTo100Action = new QAction(tr("Zoom to &100%"), this);
|
||||
m_zoomInAction = new QAction(tr("Zoom In"), this);
|
||||
m_zoomOutAction = new QAction(tr("Zoom Out"), this);
|
||||
m_zoomInAction->setShortcut(QKeySequence(Qt::Key_Plus));
|
||||
m_zoomOutAction->setShortcut(QKeySequence(Qt::Key_Minus));
|
||||
|
||||
|
||||
LiveLayerItem *layerItem = QDeclarativeViewInspectorPrivate::get(view)->manipulatorLayer;
|
||||
QGraphicsObject *layerObject = reinterpret_cast<QGraphicsObject *>(layerItem);
|
||||
m_rubberbandManipulator = new LiveRubberBandSelectionManipulator(layerObject, view);
|
||||
|
||||
|
||||
connect(m_zoomTo100Action, SIGNAL(triggered()), SLOT(zoomTo100()));
|
||||
connect(m_zoomInAction, SIGNAL(triggered()), SLOT(zoomIn()));
|
||||
connect(m_zoomOutAction, SIGNAL(triggered()), SLOT(zoomOut()));
|
||||
}
|
||||
|
||||
ZoomTool::~ZoomTool()
|
||||
{
|
||||
delete m_rubberbandManipulator;
|
||||
}
|
||||
|
||||
void ZoomTool::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
m_mousePos = event->pos();
|
||||
|
||||
QPointF scenePos = view()->mapToScene(event->pos());
|
||||
|
||||
if (event->buttons() & Qt::RightButton) {
|
||||
QMenu contextMenu;
|
||||
contextMenu.addAction(m_zoomTo100Action);
|
||||
contextMenu.addSeparator();
|
||||
contextMenu.addAction(m_zoomInAction);
|
||||
contextMenu.addAction(m_zoomOutAction);
|
||||
contextMenu.exec(event->globalPos());
|
||||
} else if (event->buttons() & Qt::LeftButton) {
|
||||
m_dragBeginPos = scenePos;
|
||||
m_dragStarted = false;
|
||||
}
|
||||
}
|
||||
|
||||
void ZoomTool::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
m_mousePos = event->pos();
|
||||
|
||||
QPointF scenePos = view()->mapToScene(event->pos());
|
||||
|
||||
if (event->buttons() & Qt::LeftButton
|
||||
&& (QPointF(scenePos - m_dragBeginPos).manhattanLength()
|
||||
> Constants::DragStartDistance / 3)
|
||||
&& !m_dragStarted)
|
||||
{
|
||||
m_dragStarted = true;
|
||||
m_rubberbandManipulator->begin(m_dragBeginPos);
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_dragStarted)
|
||||
m_rubberbandManipulator->update(scenePos);
|
||||
|
||||
}
|
||||
|
||||
void ZoomTool::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
m_mousePos = event->pos();
|
||||
QPointF scenePos = view()->mapToScene(event->pos());
|
||||
|
||||
if (m_dragStarted) {
|
||||
m_rubberbandManipulator->end();
|
||||
|
||||
int x1 = qMin(scenePos.x(), m_rubberbandManipulator->beginPoint().x());
|
||||
int x2 = qMax(scenePos.x(), m_rubberbandManipulator->beginPoint().x());
|
||||
int y1 = qMin(scenePos.y(), m_rubberbandManipulator->beginPoint().y());
|
||||
int y2 = qMax(scenePos.y(), m_rubberbandManipulator->beginPoint().y());
|
||||
|
||||
QPointF scenePosTopLeft = QPoint(x1, y1);
|
||||
QPointF scenePosBottomRight = QPoint(x2, y2);
|
||||
|
||||
QRectF sceneArea(scenePosTopLeft, scenePosBottomRight);
|
||||
|
||||
m_currentScale = qMin(view()->rect().width() / sceneArea.width(),
|
||||
view()->rect().height() / sceneArea.height());
|
||||
|
||||
|
||||
QTransform transform;
|
||||
transform.scale(m_currentScale, m_currentScale);
|
||||
|
||||
view()->setTransform(transform);
|
||||
view()->setSceneRect(sceneArea);
|
||||
} else {
|
||||
Qt::KeyboardModifier modifierKey = Qt::ControlModifier;
|
||||
#ifdef Q_OS_MAC
|
||||
modifierKey = Qt::AltModifier;
|
||||
#endif
|
||||
if (event->modifiers() & modifierKey) {
|
||||
zoomOut();
|
||||
} else {
|
||||
zoomIn();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ZoomTool::zoomIn()
|
||||
{
|
||||
m_currentScale = nextZoomScale(ZoomIn);
|
||||
scaleView(view()->mapToScene(m_mousePos));
|
||||
}
|
||||
|
||||
void ZoomTool::zoomOut()
|
||||
{
|
||||
m_currentScale = nextZoomScale(ZoomOut);
|
||||
scaleView(view()->mapToScene(m_mousePos));
|
||||
}
|
||||
|
||||
void ZoomTool::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
{
|
||||
m_mousePos = event->pos();
|
||||
}
|
||||
|
||||
|
||||
void ZoomTool::hoverMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
m_mousePos = event->pos();
|
||||
}
|
||||
|
||||
|
||||
void ZoomTool::keyPressEvent(QKeyEvent * /*event*/)
|
||||
{
|
||||
}
|
||||
|
||||
void ZoomTool::wheelEvent(QWheelEvent *event)
|
||||
{
|
||||
if (event->orientation() != Qt::Vertical)
|
||||
return;
|
||||
|
||||
Qt::KeyboardModifier smoothZoomModifier = Qt::ControlModifier;
|
||||
if (event->modifiers() & smoothZoomModifier) {
|
||||
int numDegrees = event->delta() / 8;
|
||||
m_currentScale += m_smoothZoomMultiplier * (numDegrees / 15.0f);
|
||||
|
||||
scaleView(view()->mapToScene(m_mousePos));
|
||||
|
||||
} else if (!event->modifiers()) {
|
||||
if (event->delta() > 0) {
|
||||
m_currentScale = nextZoomScale(ZoomIn);
|
||||
} else if (event->delta() < 0) {
|
||||
m_currentScale = nextZoomScale(ZoomOut);
|
||||
}
|
||||
scaleView(view()->mapToScene(m_mousePos));
|
||||
}
|
||||
}
|
||||
|
||||
void ZoomTool::keyReleaseEvent(QKeyEvent *event)
|
||||
{
|
||||
switch(event->key()) {
|
||||
case Qt::Key_Plus:
|
||||
zoomIn();
|
||||
break;
|
||||
case Qt::Key_Minus:
|
||||
zoomOut();
|
||||
break;
|
||||
case Qt::Key_1:
|
||||
case Qt::Key_2:
|
||||
case Qt::Key_3:
|
||||
case Qt::Key_4:
|
||||
case Qt::Key_5:
|
||||
case Qt::Key_6:
|
||||
case Qt::Key_7:
|
||||
case Qt::Key_8:
|
||||
case Qt::Key_9:
|
||||
{
|
||||
m_currentScale = ((event->key() - Qt::Key_0) * 1.0f);
|
||||
scaleView(view()->mapToScene(m_mousePos)); // view()->mapToScene(view()->rect().center())
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ZoomTool::itemsAboutToRemoved(const QList<QGraphicsItem*> &/*itemList*/)
|
||||
{
|
||||
}
|
||||
|
||||
void ZoomTool::clear()
|
||||
{
|
||||
view()->setCursor(Qt::ArrowCursor);
|
||||
}
|
||||
|
||||
void ZoomTool::selectedItemsChanged(const QList<QGraphicsItem*> &/*itemList*/)
|
||||
{
|
||||
}
|
||||
|
||||
void ZoomTool::scaleView(const QPointF ¢erPos)
|
||||
{
|
||||
|
||||
QTransform transform;
|
||||
transform.scale(m_currentScale, m_currentScale);
|
||||
view()->setTransform(transform);
|
||||
|
||||
QPointF adjustedCenterPos = centerPos;
|
||||
QSize rectSize(view()->rect().width() / m_currentScale,
|
||||
view()->rect().height() / m_currentScale);
|
||||
|
||||
QRectF sceneRect;
|
||||
if (qAbs(m_currentScale - 1.0f) < Constants::ZoomSnapDelta) {
|
||||
adjustedCenterPos.rx() = rectSize.width() / 2;
|
||||
adjustedCenterPos.ry() = rectSize.height() / 2;
|
||||
}
|
||||
|
||||
if (m_currentScale < 1.0f) {
|
||||
adjustedCenterPos.rx() = rectSize.width() / 2;
|
||||
adjustedCenterPos.ry() = rectSize.height() / 2;
|
||||
sceneRect.setRect(view()->rect().width() / 2 -rectSize.width() / 2,
|
||||
view()->rect().height() / 2 -rectSize.height() / 2,
|
||||
rectSize.width(),
|
||||
rectSize.height());
|
||||
} else {
|
||||
sceneRect.setRect(adjustedCenterPos.x() - rectSize.width() / 2,
|
||||
adjustedCenterPos.y() - rectSize.height() / 2,
|
||||
rectSize.width(),
|
||||
rectSize.height());
|
||||
}
|
||||
|
||||
view()->setSceneRect(sceneRect);
|
||||
}
|
||||
|
||||
void ZoomTool::zoomTo100()
|
||||
{
|
||||
m_currentScale = 1.0f;
|
||||
scaleView(view()->mapToScene(view()->rect().center()));
|
||||
}
|
||||
|
||||
qreal ZoomTool::nextZoomScale(ZoomDirection direction) const
|
||||
{
|
||||
static QList<qreal> zoomScales =
|
||||
QList<qreal>()
|
||||
<< 0.125f
|
||||
<< 1.0f / 6.0f
|
||||
<< 0.25f
|
||||
<< 1.0f / 3.0f
|
||||
<< 0.5f
|
||||
<< 2.0f / 3.0f
|
||||
<< 1.0f
|
||||
<< 2.0f
|
||||
<< 3.0f
|
||||
<< 4.0f
|
||||
<< 5.0f
|
||||
<< 6.0f
|
||||
<< 7.0f
|
||||
<< 8.0f
|
||||
<< 12.0f
|
||||
<< 16.0f
|
||||
<< 32.0f
|
||||
<< 48.0f;
|
||||
|
||||
if (direction == ZoomIn) {
|
||||
for (int i = 0; i < zoomScales.length(); ++i) {
|
||||
if (zoomScales[i] > m_currentScale || i == zoomScales.length() - 1)
|
||||
return zoomScales[i];
|
||||
}
|
||||
} else {
|
||||
for (int i = zoomScales.length() - 1; i >= 0; --i) {
|
||||
if (zoomScales[i] < m_currentScale || i == 0)
|
||||
return zoomScales[i];
|
||||
}
|
||||
}
|
||||
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
} // namespace QmlJSDebugger
|
||||
@@ -1,94 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef ZOOMTOOL_H
|
||||
#define ZOOMTOOL_H
|
||||
|
||||
#include "abstractliveedittool.h"
|
||||
#include "liverubberbandselectionmanipulator.h"
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QAction)
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
class ZoomTool : public AbstractLiveEditTool
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum ZoomDirection {
|
||||
ZoomIn,
|
||||
ZoomOut
|
||||
};
|
||||
|
||||
explicit ZoomTool(QDeclarativeViewInspector *view);
|
||||
|
||||
virtual ~ZoomTool();
|
||||
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
void mouseMoveEvent(QMouseEvent *event);
|
||||
void mouseReleaseEvent(QMouseEvent *event);
|
||||
void mouseDoubleClickEvent(QMouseEvent *event);
|
||||
|
||||
void hoverMoveEvent(QMouseEvent *event);
|
||||
void wheelEvent(QWheelEvent *event);
|
||||
|
||||
void keyPressEvent(QKeyEvent *event);
|
||||
void keyReleaseEvent(QKeyEvent *keyEvent);
|
||||
void itemsAboutToRemoved(const QList<QGraphicsItem*> &itemList);
|
||||
|
||||
void clear();
|
||||
protected:
|
||||
void selectedItemsChanged(const QList<QGraphicsItem*> &itemList);
|
||||
|
||||
private slots:
|
||||
void zoomTo100();
|
||||
void zoomIn();
|
||||
void zoomOut();
|
||||
|
||||
private:
|
||||
qreal nextZoomScale(ZoomDirection direction) const;
|
||||
void scaleView(const QPointF ¢erPos);
|
||||
|
||||
private:
|
||||
bool m_dragStarted;
|
||||
QPoint m_mousePos; // in view coords
|
||||
QPointF m_dragBeginPos;
|
||||
QAction *m_zoomTo100Action;
|
||||
QAction *m_zoomInAction;
|
||||
QAction *m_zoomOutAction;
|
||||
LiveRubberBandSelectionManipulator *m_rubberbandManipulator;
|
||||
|
||||
qreal m_smoothZoomMultiplier;
|
||||
qreal m_currentScale;
|
||||
|
||||
};
|
||||
|
||||
} // namespace QmlJSDebugger
|
||||
|
||||
#endif // ZOOMTOOL_H
|
||||
@@ -1,107 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef JSDEBUGGERAGENT_H
|
||||
#define JSDEBUGGERAGENT_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include <qscriptengineagent.h>
|
||||
|
||||
#include "qt_private/qdeclarativedebugservice_p.h"
|
||||
|
||||
#include "qmljsdebugger_global.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QScriptValue;
|
||||
class QDeclarativeEngine;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
class JSDebuggerAgentPrivate;
|
||||
|
||||
class QMLJSDEBUGGER_EXPORT JSDebuggerAgent
|
||||
: public QDeclarativeDebugService
|
||||
, public QScriptEngineAgent
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
JSDebuggerAgent(QScriptEngine *engine);
|
||||
JSDebuggerAgent(QDeclarativeEngine *engine);
|
||||
~JSDebuggerAgent();
|
||||
|
||||
// reimplemented
|
||||
void scriptLoad(qint64 id, const QString &program,
|
||||
const QString &fileName, int baseLineNumber);
|
||||
void scriptUnload(qint64 id);
|
||||
|
||||
void contextPush();
|
||||
void contextPop();
|
||||
|
||||
void functionEntry(qint64 scriptId);
|
||||
void functionExit(qint64 scriptId,
|
||||
const QScriptValue &returnValue);
|
||||
|
||||
void positionChange(qint64 scriptId,
|
||||
int lineNumber, int columnNumber);
|
||||
|
||||
void exceptionThrow(qint64 scriptId,
|
||||
const QScriptValue &exception,
|
||||
bool hasHandler);
|
||||
void exceptionCatch(qint64 scriptId,
|
||||
const QScriptValue &exception);
|
||||
|
||||
bool supportsExtension(Extension extension) const;
|
||||
QVariant extension(Extension extension,
|
||||
const QVariant &argument = QVariant());
|
||||
|
||||
void messageReceived(const QByteArray &);
|
||||
void statusChanged(Status status);
|
||||
void baseMessageReceived(const QByteArray &message);
|
||||
|
||||
public slots:
|
||||
|
||||
private:
|
||||
JSDebuggerAgentPrivate *d;
|
||||
};
|
||||
|
||||
} // namespace QmlJSDebugger
|
||||
|
||||
#endif // JSDEBUGGERAGENT_H
|
||||
@@ -1,103 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QDECLARATIVEDINSPECTORSERVICE_H
|
||||
#define QDECLARATIVEDINSPECTORSERVICE_H
|
||||
|
||||
#include "qt_private/qdeclarativedebugservice_p.h"
|
||||
#include "qmlinspectorconstants.h"
|
||||
#include "qmljsdebugger_global.h"
|
||||
|
||||
#include <QHash>
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QColor)
|
||||
QT_FORWARD_DECLARE_CLASS(QDeclarativeEngine)
|
||||
QT_FORWARD_DECLARE_CLASS(QDeclarativeContext)
|
||||
QT_FORWARD_DECLARE_CLASS(QDeclarativeWatcher)
|
||||
QT_FORWARD_DECLARE_CLASS(QDataStream)
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
class QMLJSDEBUGGER_EXPORT QDeclarativeInspectorService : public QDeclarativeDebugService
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QDeclarativeInspectorService();
|
||||
static QDeclarativeInspectorService *instance();
|
||||
|
||||
void setDesignModeBehavior(bool inDesignMode);
|
||||
void setCurrentObjects(QList<QObject*> items);
|
||||
void setAnimationSpeed(qreal slowDownFactor);
|
||||
void setAnimationPaused(bool paused);
|
||||
void setCurrentTool(QmlJSDebugger::Constants::DesignTool toolId);
|
||||
void reloaded();
|
||||
void setShowAppOnTop(bool showAppOnTop);
|
||||
|
||||
QString idStringForObject(QObject *obj) const;
|
||||
|
||||
void sendMessage(const QByteArray &message);
|
||||
|
||||
public Q_SLOTS:
|
||||
void selectedColorChanged(const QColor &color);
|
||||
|
||||
Q_SIGNALS:
|
||||
void debuggingClientChanged(bool hasDebuggingClient);
|
||||
|
||||
void currentObjectsChanged(const QList<QObject*> &objects);
|
||||
void designModeBehaviorChanged(bool inDesignMode);
|
||||
void showAppOnTopChanged(bool showAppOnTop);
|
||||
void reloadRequested();
|
||||
void selectToolRequested();
|
||||
void selectMarqueeToolRequested();
|
||||
void zoomToolRequested();
|
||||
void colorPickerToolRequested();
|
||||
|
||||
void objectCreationRequested(const QString &qml, QObject *parent,
|
||||
const QStringList &imports, const QString &filename = QString(), int order = -1);
|
||||
void objectReparentRequested(QObject *object, QObject *newParent);
|
||||
void objectDeletionRequested(QObject *object);
|
||||
|
||||
// 1 = normal speed,
|
||||
// 1 < x < 16 = slowdown by some factor
|
||||
void animationSpeedChangeRequested(qreal speedFactor);
|
||||
void executionPauseChangeRequested(bool paused);
|
||||
|
||||
void clearComponentCacheRequested();
|
||||
|
||||
protected:
|
||||
virtual void statusChanged(Status status);
|
||||
virtual void messageReceived(const QByteArray &);
|
||||
|
||||
private:
|
||||
QHash<int, QString> m_stringIdForObjectId;
|
||||
};
|
||||
|
||||
} // namespace QmlJSDebugger
|
||||
|
||||
#endif // QDECLARATIVEDINSPECTORSERVICE_H
|
||||
@@ -1,116 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QDECLARATIVEVIEWINSPECTOR_H
|
||||
#define QDECLARATIVEVIEWINSPECTOR_H
|
||||
|
||||
#include "qmljsdebugger_global.h"
|
||||
#include "qmlinspectorconstants.h"
|
||||
|
||||
#include <QScopedPointer>
|
||||
#include <QDeclarativeView>
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QDeclarativeItem)
|
||||
QT_FORWARD_DECLARE_CLASS(QMouseEvent)
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
class CrumblePath;
|
||||
class QDeclarativeViewInspectorPrivate;
|
||||
|
||||
class QMLJSDEBUGGER_EXPORT QDeclarativeViewInspector : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
explicit QDeclarativeViewInspector(QDeclarativeView *view, QObject *parent = 0);
|
||||
~QDeclarativeViewInspector();
|
||||
|
||||
void setSelectedItems(QList<QGraphicsItem *> items);
|
||||
QList<QGraphicsItem *> selectedItems();
|
||||
|
||||
QDeclarativeView *declarativeView();
|
||||
|
||||
static QString idStringForObject(QObject *obj);
|
||||
QRectF adjustToScreenBoundaries(const QRectF &boundingRectInSceneSpace);
|
||||
|
||||
bool showAppOnTop() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void setDesignModeBehavior(bool value);
|
||||
bool designModeBehavior();
|
||||
|
||||
void setShowAppOnTop(bool appOnTop);
|
||||
|
||||
void setAnimationSpeed(qreal factor);
|
||||
void setAnimationPaused(bool paused);
|
||||
|
||||
Q_SIGNALS:
|
||||
void designModeBehaviorChanged(bool inDesignMode);
|
||||
void showAppOnTopChanged(bool showAppOnTop);
|
||||
void reloadRequested();
|
||||
void marqueeSelectToolActivated();
|
||||
void selectToolActivated();
|
||||
void zoomToolActivated();
|
||||
void colorPickerActivated();
|
||||
void selectedColorChanged(const QColor &color);
|
||||
|
||||
void animationSpeedChanged(qreal factor);
|
||||
void animationPausedChanged(bool paused);
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject *obj, QEvent *event);
|
||||
|
||||
bool leaveEvent(QEvent *);
|
||||
bool mousePressEvent(QMouseEvent *event);
|
||||
bool mouseMoveEvent(QMouseEvent *event);
|
||||
bool mouseReleaseEvent(QMouseEvent *event);
|
||||
bool keyPressEvent(QKeyEvent *event);
|
||||
bool keyReleaseEvent(QKeyEvent *keyEvent);
|
||||
bool mouseDoubleClickEvent(QMouseEvent *event);
|
||||
bool wheelEvent(QWheelEvent *event);
|
||||
|
||||
void setSelectedItemsForTools(QList<QGraphicsItem *> items);
|
||||
|
||||
private slots:
|
||||
void animationSpeedChangeRequested(qreal factor);
|
||||
void animationPausedChangeRequested(bool paused);
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(QDeclarativeViewInspector)
|
||||
|
||||
inline QDeclarativeViewInspectorPrivate *d_func() { return data.data(); }
|
||||
QScopedPointer<QDeclarativeViewInspectorPrivate> data;
|
||||
friend class QDeclarativeViewInspectorPrivate;
|
||||
friend class AbstractLiveEditTool;
|
||||
};
|
||||
|
||||
} // namespace QmlJSDebugger
|
||||
|
||||
#endif // QDECLARATIVEVIEWINSPECTOR_H
|
||||
@@ -1,50 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QDECLARATIVEVIEWOBSERVER_H
|
||||
#define QDECLARATIVEVIEWOBSERVER_H
|
||||
|
||||
#include "qdeclarativeviewinspector.h"
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
// Provided for compatibility with QmlApplicationViewer
|
||||
class QMLJSDEBUGGER_EXPORT QDeclarativeViewObserver : public QDeclarativeViewInspector
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit QDeclarativeViewObserver(QDeclarativeView *view, QObject *parent = 0)
|
||||
: QDeclarativeViewInspector(view, parent)
|
||||
{}
|
||||
};
|
||||
|
||||
} // namespace QmlJSDebugger
|
||||
|
||||
#endif // QDECLARATIVEVIEWOBSERVER_H
|
||||
@@ -1,68 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QMLINSPECTORCONSTANTS_H
|
||||
#define QMLINSPECTORCONSTANTS_H
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
namespace Constants {
|
||||
|
||||
enum DesignTool {
|
||||
NoTool = 0,
|
||||
SelectionToolMode = 1,
|
||||
MarqueeSelectionToolMode = 2,
|
||||
MoveToolMode = 3,
|
||||
ResizeToolMode = 4,
|
||||
ColorPickerMode = 5,
|
||||
ZoomMode = 6
|
||||
};
|
||||
|
||||
enum ToolFlags {
|
||||
NoToolFlags = 0,
|
||||
UseCursorPos = 1
|
||||
};
|
||||
|
||||
static const int DragStartTime = 50;
|
||||
|
||||
static const int DragStartDistance = 20;
|
||||
|
||||
static const double ZoomSnapDelta = 0.04;
|
||||
|
||||
static const int EditorItemDataKey = 1000;
|
||||
|
||||
enum GraphicsItemTypes {
|
||||
EditorItemType = 0xEAAA,
|
||||
ResizeHandleItemType = 0xEAEA
|
||||
};
|
||||
|
||||
|
||||
} // namespace Constants
|
||||
} // namespace QmlJSDebugger
|
||||
|
||||
#endif // QMLINSPECTORCONSTANTS_H
|
||||
@@ -1,46 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QMLJSDEBUGGER_GLOBAL_H
|
||||
#define QMLJSDEBUGGER_GLOBAL_H
|
||||
|
||||
#include <qglobal.h>
|
||||
|
||||
# if defined(BUILD_QMLJSDEBUGGER_LIB)
|
||||
# define QMLJSDEBUGGER_EXPORT Q_DECL_EXPORT
|
||||
# define QMLJSDEBUGGER_EXTERN Q_DECL_IMPORT
|
||||
# elif defined(BUILD_QMLJSDEBUGGER_STATIC_LIB)
|
||||
# define QMLJSDEBUGGER_EXPORT
|
||||
# define QMLJSDEBUGGER_EXTERN Q_DECL_IMPORT
|
||||
# else
|
||||
# define QMLJSDEBUGGER_EXPORT
|
||||
# define QMLJSDEBUGGER_EXTERN Q_DECL_IMPORT
|
||||
#endif
|
||||
|
||||
#endif // QMLJSDEBUGGER_GLOBAL_H
|
||||
@@ -1,56 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QDECLARATIVEDEBUGHELPER_P_H
|
||||
#define QDECLARATIVEDEBUGHELPER_P_H
|
||||
|
||||
#include "../qmljsdebugger_global.h"
|
||||
#include <qglobal.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QScriptEngine;
|
||||
class QDeclarativeEngine;
|
||||
|
||||
// Helper functions to access private API through a stable interface
|
||||
// This is used in the qmljsdebugger library of QtCreator.
|
||||
class QMLJSDEBUGGER_EXTERN QDeclarativeDebugHelper
|
||||
{
|
||||
public:
|
||||
static QScriptEngine *getScriptEngine(QDeclarativeEngine *engine);
|
||||
static void setAnimationSlowDownFactor(qreal factor);
|
||||
|
||||
// Enables remote debugging functionality
|
||||
// Only use this for debugging in a safe environment!
|
||||
static void enableDebugging();
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QDECLARATIVEDEBUGHELPER_P_H
|
||||
@@ -1,77 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QDECLARATIVEDEBUGSERVICE_H
|
||||
#define QDECLARATIVEDEBUGSERVICE_H
|
||||
|
||||
#include "../qmljsdebugger_global.h"
|
||||
#include <qobject.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Declarative)
|
||||
|
||||
class QDeclarativeDebugServicePrivate;
|
||||
class QMLJSDEBUGGER_EXTERN QDeclarativeDebugService : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DECLARE_PRIVATE(QDeclarativeDebugService)
|
||||
Q_DISABLE_COPY(QDeclarativeDebugService)
|
||||
|
||||
public:
|
||||
explicit QDeclarativeDebugService(const QString &, QObject *parent = 0);
|
||||
~QDeclarativeDebugService();
|
||||
|
||||
QString name() const;
|
||||
|
||||
enum Status { NotConnected, Unavailable, Enabled };
|
||||
Status status() const;
|
||||
|
||||
void sendMessage(const QByteArray &);
|
||||
|
||||
static int idForObject(QObject *);
|
||||
static QObject *objectForId(int);
|
||||
|
||||
static QString objectToString(QObject *obj);
|
||||
|
||||
static bool isDebuggingEnabled();
|
||||
static bool hasDebuggingClient();
|
||||
|
||||
protected:
|
||||
virtual void statusChanged(Status);
|
||||
virtual void messageReceived(const QByteArray &);
|
||||
|
||||
private:
|
||||
friend class QDeclarativeDebugServer;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QDECLARATIVEDEBUGSERVICE_H
|
||||
|
||||
@@ -1,194 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QDECLARATIVESTATE_H
|
||||
#define QDECLARATIVESTATE_H
|
||||
|
||||
#include "../qmljsdebugger_global.h"
|
||||
|
||||
#include <qdeclarative.h>
|
||||
#include <qdeclarativeproperty.h>
|
||||
#include <qobject.h>
|
||||
#include <qsharedpointer.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QT_MODULE(Declarative)
|
||||
|
||||
class QDeclarativeActionEvent;
|
||||
class QDeclarativeAbstractBinding;
|
||||
class QDeclarativeBinding;
|
||||
class QDeclarativeExpression;
|
||||
class QMLJSDEBUGGER_EXTERN QDeclarativeAction
|
||||
{
|
||||
public:
|
||||
QDeclarativeAction();
|
||||
QDeclarativeAction(QObject *, const QString &, const QVariant &);
|
||||
QDeclarativeAction(QObject *, const QString &,
|
||||
QDeclarativeContext *, const QVariant &);
|
||||
|
||||
bool restore:1;
|
||||
bool actionDone:1;
|
||||
bool reverseEvent:1;
|
||||
bool deletableToBinding:1;
|
||||
|
||||
QDeclarativeProperty property;
|
||||
QVariant fromValue;
|
||||
QVariant toValue;
|
||||
|
||||
QDeclarativeAbstractBinding *fromBinding;
|
||||
QWeakPointer<QDeclarativeAbstractBinding> toBinding;
|
||||
QDeclarativeActionEvent *event;
|
||||
|
||||
//strictly for matching
|
||||
QObject *specifiedObject;
|
||||
QString specifiedProperty;
|
||||
|
||||
void deleteFromBinding();
|
||||
};
|
||||
|
||||
class QMLJSDEBUGGER_EXTERN QDeclarativeActionEvent
|
||||
{
|
||||
public:
|
||||
virtual ~QDeclarativeActionEvent();
|
||||
virtual QString typeName() const;
|
||||
|
||||
enum Reason { ActualChange, FastForward };
|
||||
|
||||
virtual void execute(Reason reason = ActualChange);
|
||||
virtual bool isReversable();
|
||||
virtual void reverse(Reason reason = ActualChange);
|
||||
virtual void saveOriginals() {}
|
||||
virtual bool needsCopy() { return false; }
|
||||
virtual void copyOriginals(QDeclarativeActionEvent *) {}
|
||||
virtual bool isRewindable() { return isReversable(); }
|
||||
virtual void rewind() {}
|
||||
virtual void saveCurrentValues() {}
|
||||
virtual void saveTargetValues() {}
|
||||
|
||||
virtual bool changesBindings();
|
||||
virtual void clearBindings();
|
||||
virtual bool override(QDeclarativeActionEvent*other);
|
||||
};
|
||||
|
||||
//### rename to QDeclarativeStateChange?
|
||||
class QDeclarativeStateGroup;
|
||||
class QDeclarativeState;
|
||||
class QDeclarativeStateOperationPrivate;
|
||||
class QMLJSDEBUGGER_EXTERN QDeclarativeStateOperation : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QDeclarativeStateOperation(QObject *parent = 0)
|
||||
: QObject(parent) {}
|
||||
typedef QList<QDeclarativeAction> ActionList;
|
||||
|
||||
virtual ActionList actions();
|
||||
|
||||
QDeclarativeState *state() const;
|
||||
void setState(QDeclarativeState *state);
|
||||
|
||||
protected:
|
||||
QDeclarativeStateOperation(QObjectPrivate &dd, QObject *parent = 0);
|
||||
|
||||
private:
|
||||
Q_DECLARE_PRIVATE(QDeclarativeStateOperation)
|
||||
Q_DISABLE_COPY(QDeclarativeStateOperation)
|
||||
};
|
||||
|
||||
typedef QDeclarativeStateOperation::ActionList QDeclarativeStateActions;
|
||||
|
||||
class QDeclarativeTransition;
|
||||
class QDeclarativeStatePrivate;
|
||||
class QMLJSDEBUGGER_EXTERN QDeclarativeState : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QString name READ name WRITE setName)
|
||||
Q_PROPERTY(QDeclarativeBinding *when READ when WRITE setWhen)
|
||||
Q_PROPERTY(QString extend READ extends WRITE setExtends)
|
||||
Q_PROPERTY(QDeclarativeListProperty<QDeclarativeStateOperation> changes READ changes)
|
||||
Q_CLASSINFO("DefaultProperty", "changes")
|
||||
Q_CLASSINFO("DeferredPropertyNames", "changes")
|
||||
|
||||
public:
|
||||
QDeclarativeState(QObject *parent=0);
|
||||
virtual ~QDeclarativeState();
|
||||
|
||||
QString name() const;
|
||||
void setName(const QString &);
|
||||
bool isNamed() const;
|
||||
|
||||
/*'when' is a QDeclarativeBinding to limit state changes oscillation
|
||||
due to the unpredictable order of evaluation of bound expressions*/
|
||||
bool isWhenKnown() const;
|
||||
QDeclarativeBinding *when() const;
|
||||
void setWhen(QDeclarativeBinding *);
|
||||
|
||||
QString extends() const;
|
||||
void setExtends(const QString &);
|
||||
|
||||
QDeclarativeListProperty<QDeclarativeStateOperation> changes();
|
||||
int operationCount() const;
|
||||
QDeclarativeStateOperation *operationAt(int) const;
|
||||
|
||||
QDeclarativeState &operator<<(QDeclarativeStateOperation *);
|
||||
|
||||
void apply(QDeclarativeStateGroup *, QDeclarativeTransition *, QDeclarativeState *revert);
|
||||
void cancel();
|
||||
|
||||
QDeclarativeStateGroup *stateGroup() const;
|
||||
void setStateGroup(QDeclarativeStateGroup *);
|
||||
|
||||
bool containsPropertyInRevertList(QObject *target, const QString &name) const;
|
||||
bool changeValueInRevertList(QObject *target, const QString &name, const QVariant &revertValue);
|
||||
bool changeBindingInRevertList(QObject *target, const QString &name, QDeclarativeAbstractBinding *binding);
|
||||
bool removeEntryFromRevertList(QObject *target, const QString &name);
|
||||
void addEntryToRevertList(const QDeclarativeAction &action);
|
||||
void removeAllEntriesFromRevertList(QObject *target);
|
||||
void addEntriesToRevertList(const QList<QDeclarativeAction> &actions);
|
||||
QVariant valueInRevertList(QObject *target, const QString &name) const;
|
||||
QDeclarativeAbstractBinding *bindingInRevertList(QObject *target, const QString &name) const;
|
||||
|
||||
bool isStateActive() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void completed();
|
||||
|
||||
private:
|
||||
Q_DECLARE_PRIVATE(QDeclarativeState)
|
||||
Q_DISABLE_COPY(QDeclarativeState)
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
//QML_DECLARE_TYPE(QDeclarativeStateOperation)
|
||||
//QML_DECLARE_TYPE(QDeclarativeState)
|
||||
|
||||
#endif // QDECLARATIVESTATE_H
|
||||
@@ -1,672 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "jsdebuggeragent.h"
|
||||
#include "qt_private/qdeclarativedebughelper_p.h"
|
||||
|
||||
#include <qdatetime.h>
|
||||
#include <qdebug.h>
|
||||
#include <qcoreapplication.h>
|
||||
#include <qset.h>
|
||||
#include <qurl.h>
|
||||
#include <qscriptcontextinfo.h>
|
||||
#include <qscriptengine.h>
|
||||
#include <qscriptvalueiterator.h>
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
enum JSDebuggerState
|
||||
{
|
||||
NoState,
|
||||
SteppingIntoState,
|
||||
SteppingOverState,
|
||||
SteppingOutState,
|
||||
StoppedState
|
||||
};
|
||||
|
||||
struct JSAgentWatchData
|
||||
{
|
||||
QByteArray exp;
|
||||
QByteArray name;
|
||||
QByteArray value;
|
||||
QByteArray type;
|
||||
bool hasChildren;
|
||||
quint64 objectId;
|
||||
};
|
||||
|
||||
QDataStream &operator<<(QDataStream &s, const JSAgentWatchData &data)
|
||||
{
|
||||
return s << data.exp << data.name << data.value
|
||||
<< data.type << data.hasChildren << data.objectId;
|
||||
}
|
||||
|
||||
struct JSAgentStackData
|
||||
{
|
||||
QByteArray functionName;
|
||||
QByteArray fileUrl;
|
||||
qint32 lineNumber;
|
||||
};
|
||||
|
||||
QDataStream &operator<<(QDataStream &s, const JSAgentStackData &data)
|
||||
{
|
||||
return s << data.functionName << data.fileUrl << data.lineNumber;
|
||||
}
|
||||
|
||||
struct JSAgentBreakpointData
|
||||
{
|
||||
QByteArray functionName;
|
||||
QByteArray fileUrl;
|
||||
qint32 lineNumber;
|
||||
};
|
||||
|
||||
typedef QSet<JSAgentBreakpointData> JSAgentBreakpoints;
|
||||
|
||||
QDataStream &operator<<(QDataStream &s, const JSAgentBreakpointData &data)
|
||||
{
|
||||
return s << data.functionName << data.fileUrl << data.lineNumber;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &s, JSAgentBreakpointData &data)
|
||||
{
|
||||
return s >> data.functionName >> data.fileUrl >> data.lineNumber;
|
||||
}
|
||||
|
||||
bool operator==(const JSAgentBreakpointData &b1, const JSAgentBreakpointData &b2)
|
||||
{
|
||||
return b1.lineNumber == b2.lineNumber && b1.fileUrl == b2.fileUrl;
|
||||
}
|
||||
|
||||
uint qHash(const JSAgentBreakpointData &b)
|
||||
{
|
||||
return b.lineNumber ^ qHash(b.fileUrl);
|
||||
}
|
||||
|
||||
class JSDebuggerAgentPrivate
|
||||
{
|
||||
public:
|
||||
JSDebuggerAgentPrivate(JSDebuggerAgent *q)
|
||||
: q(q), state(NoState)
|
||||
{}
|
||||
|
||||
void continueExec();
|
||||
void recordKnownObjects(const QList<JSAgentWatchData> &);
|
||||
QList<JSAgentWatchData> getLocals(QScriptContext *);
|
||||
void positionChange(qint64 scriptId, int lineNumber, int columnNumber);
|
||||
QScriptEngine *engine() { return q->engine(); }
|
||||
void stopped();
|
||||
void messageReceived(const QByteArray &message);
|
||||
void sendMessage(const QByteArray &message) { q->sendMessage(message); }
|
||||
|
||||
public:
|
||||
JSDebuggerAgent *q;
|
||||
JSDebuggerState state;
|
||||
int stepDepth;
|
||||
int stepCount;
|
||||
|
||||
QEventLoop loop;
|
||||
QHash<qint64, QString> filenames;
|
||||
JSAgentBreakpoints breakpoints;
|
||||
// breakpoints by filename (without path)
|
||||
QHash<QString, JSAgentBreakpointData> fileNameToBreakpoints;
|
||||
QStringList watchExpressions;
|
||||
QSet<qint64> knownObjectIds;
|
||||
};
|
||||
|
||||
class SetupExecEnv
|
||||
{
|
||||
public:
|
||||
SetupExecEnv(JSDebuggerAgentPrivate *a)
|
||||
: agent(a),
|
||||
previousState(a->state),
|
||||
hadException(a->engine()->hasUncaughtException())
|
||||
{
|
||||
agent->state = StoppedState;
|
||||
}
|
||||
|
||||
~SetupExecEnv()
|
||||
{
|
||||
if (!hadException && agent->engine()->hasUncaughtException())
|
||||
agent->engine()->clearExceptions();
|
||||
agent->state = previousState;
|
||||
}
|
||||
|
||||
private:
|
||||
JSDebuggerAgentPrivate *agent;
|
||||
JSDebuggerState previousState;
|
||||
bool hadException;
|
||||
};
|
||||
|
||||
static JSAgentWatchData fromScriptValue(const QString &expression,
|
||||
const QScriptValue &value)
|
||||
{
|
||||
static const QString arrayStr = QCoreApplication::translate
|
||||
("Debugger::JSAgentWatchData", "[Array of length %1]");
|
||||
static const QString undefinedStr = QCoreApplication::translate
|
||||
("Debugger::JSAgentWatchData", "<undefined>");
|
||||
|
||||
JSAgentWatchData data;
|
||||
data.exp = expression.toUtf8();
|
||||
data.name = data.exp;
|
||||
data.hasChildren = false;
|
||||
data.value = value.toString().toUtf8();
|
||||
data.objectId = value.objectId();
|
||||
if (value.isArray()) {
|
||||
data.type = "Array";
|
||||
data.value = arrayStr.arg(value.property("length").toString()).toUtf8();
|
||||
data.hasChildren = true;
|
||||
} else if (value.isBool()) {
|
||||
data.type = "Bool";
|
||||
// data.value = value.toBool() ? "true" : "false";
|
||||
} else if (value.isDate()) {
|
||||
data.type = "Date";
|
||||
data.value = value.toDateTime().toString().toUtf8();
|
||||
} else if (value.isError()) {
|
||||
data.type = "Error";
|
||||
} else if (value.isFunction()) {
|
||||
data.type = "Function";
|
||||
} else if (value.isUndefined()) {
|
||||
data.type = undefinedStr.toUtf8();
|
||||
} else if (value.isNumber()) {
|
||||
data.type = "Number";
|
||||
} else if (value.isRegExp()) {
|
||||
data.type = "RegExp";
|
||||
} else if (value.isString()) {
|
||||
data.type = "String";
|
||||
} else if (value.isVariant()) {
|
||||
data.type = "Variant";
|
||||
} else if (value.isQObject()) {
|
||||
const QObject *obj = value.toQObject();
|
||||
data.type = "Object";
|
||||
data.value += '[';
|
||||
data.value += obj->metaObject()->className();
|
||||
data.value += ']';
|
||||
data.hasChildren = true;
|
||||
} else if (value.isObject()) {
|
||||
data.type = "Object";
|
||||
data.hasChildren = true;
|
||||
data.value = "[Object]";
|
||||
} else if (value.isNull()) {
|
||||
data.type = "<null>";
|
||||
} else {
|
||||
data.type = "<unknown>";
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
static QList<JSAgentWatchData> expandObject(const QScriptValue &object)
|
||||
{
|
||||
QList<JSAgentWatchData> result;
|
||||
QScriptValueIterator it(object);
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
if (it.flags() & QScriptValue::SkipInEnumeration)
|
||||
continue;
|
||||
if (/*object.isQObject() &&*/ it.value().isFunction()) {
|
||||
// Cosmetics: skip all functions and slot, there are too many of them,
|
||||
// and it is not useful information in the debugger.
|
||||
continue;
|
||||
}
|
||||
JSAgentWatchData data = fromScriptValue(it.name(), it.value());
|
||||
result.append(data);
|
||||
}
|
||||
if (result.isEmpty()) {
|
||||
JSAgentWatchData data;
|
||||
data.name = "<no initialized data>";
|
||||
data.hasChildren = false;
|
||||
data.value = " ";
|
||||
data.objectId = 0;
|
||||
result.append(data);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void JSDebuggerAgentPrivate::recordKnownObjects(const QList<JSAgentWatchData>& list)
|
||||
{
|
||||
foreach (const JSAgentWatchData &data, list)
|
||||
knownObjectIds << data.objectId;
|
||||
}
|
||||
|
||||
QList<JSAgentWatchData> JSDebuggerAgentPrivate::getLocals(QScriptContext *ctx)
|
||||
{
|
||||
QList<JSAgentWatchData> locals;
|
||||
if (ctx) {
|
||||
QScriptValue activationObject = ctx->activationObject();
|
||||
QScriptValue thisObject = ctx->thisObject();
|
||||
locals = expandObject(activationObject);
|
||||
if (thisObject.isObject()
|
||||
&& thisObject.objectId() != engine()->globalObject().objectId()
|
||||
&& QScriptValueIterator(thisObject).hasNext())
|
||||
locals.prepend(fromScriptValue("this", thisObject));
|
||||
recordKnownObjects(locals);
|
||||
knownObjectIds << activationObject.objectId();
|
||||
}
|
||||
return locals;
|
||||
}
|
||||
|
||||
/*!
|
||||
Constructs a new agent for the given \a engine. The agent will
|
||||
report debugging-related events (e.g. step completion) to the given
|
||||
\a backend.
|
||||
*/
|
||||
JSDebuggerAgent::JSDebuggerAgent(QScriptEngine *engine)
|
||||
: QDeclarativeDebugService("JSDebugger")
|
||||
, QScriptEngineAgent(engine)
|
||||
, d(new JSDebuggerAgentPrivate(this))
|
||||
{
|
||||
if (status() == Enabled)
|
||||
engine->setAgent(this);
|
||||
}
|
||||
|
||||
JSDebuggerAgent::JSDebuggerAgent(QDeclarativeEngine *engine)
|
||||
: QDeclarativeDebugService("JSDebugger")
|
||||
, QScriptEngineAgent(QDeclarativeDebugHelper::getScriptEngine(engine))
|
||||
, d(new JSDebuggerAgentPrivate(this))
|
||||
{
|
||||
if (status() == Enabled)
|
||||
QDeclarativeDebugHelper::getScriptEngine(engine)->setAgent(this);
|
||||
}
|
||||
|
||||
/*!
|
||||
Destroys this QScriptDebuggerAgent.
|
||||
*/
|
||||
JSDebuggerAgent::~JSDebuggerAgent()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void JSDebuggerAgent::scriptLoad(qint64 id, const QString &program,
|
||||
const QString &fileName, int)
|
||||
{
|
||||
Q_UNUSED(program);
|
||||
d->filenames.insert(id, fileName);
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void JSDebuggerAgent::scriptUnload(qint64 id)
|
||||
{
|
||||
d->filenames.remove(id);
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void JSDebuggerAgent::contextPush()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void JSDebuggerAgent::contextPop()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void JSDebuggerAgent::functionEntry(qint64 scriptId)
|
||||
{
|
||||
Q_UNUSED(scriptId);
|
||||
d->stepDepth++;
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void JSDebuggerAgent::functionExit(qint64 scriptId, const QScriptValue &returnValue)
|
||||
{
|
||||
Q_UNUSED(scriptId);
|
||||
Q_UNUSED(returnValue);
|
||||
d->stepDepth--;
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void JSDebuggerAgent::positionChange(qint64 scriptId, int lineNumber, int columnNumber)
|
||||
{
|
||||
d->positionChange(scriptId, lineNumber, columnNumber);
|
||||
}
|
||||
|
||||
QString fileName(const QString &fileUrl)
|
||||
{
|
||||
int lastDelimiterPos = fileUrl.lastIndexOf(QLatin1Char('/'));
|
||||
return fileUrl.mid(lastDelimiterPos, fileUrl.size() - lastDelimiterPos);
|
||||
}
|
||||
|
||||
void JSDebuggerAgentPrivate::positionChange(qint64 scriptId, int lineNumber, int columnNumber)
|
||||
{
|
||||
Q_UNUSED(columnNumber);
|
||||
|
||||
if (state == StoppedState)
|
||||
return; //no re-entrency
|
||||
|
||||
// check breakpoints
|
||||
if (!breakpoints.isEmpty()) {
|
||||
QScriptContext *ctx = engine()->currentContext();
|
||||
QScriptContextInfo info(ctx);
|
||||
|
||||
if (info.functionType() == QScriptContextInfo::ScriptFunction) {
|
||||
QHash<qint64, QString>::const_iterator it = filenames.constFind(scriptId);
|
||||
if (it == filenames.constEnd()) {
|
||||
// It is possible that the scripts are loaded before the agent is attached
|
||||
QString filename = info.fileName();
|
||||
|
||||
JSAgentStackData frame;
|
||||
frame.functionName = info.functionName().toUtf8();
|
||||
it = filenames.insert(scriptId, filename);
|
||||
}
|
||||
|
||||
const QString filePath = it->toUtf8();
|
||||
JSAgentBreakpoints bps = fileNameToBreakpoints.values(fileName(filePath)).toSet();
|
||||
|
||||
foreach (const JSAgentBreakpointData &bp, bps) {
|
||||
if (bp.lineNumber == lineNumber) {
|
||||
stopped();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch (state) {
|
||||
case NoState:
|
||||
case StoppedState:
|
||||
// Do nothing
|
||||
break;
|
||||
case SteppingOutState:
|
||||
if (stepDepth >= 0)
|
||||
break;
|
||||
//fallthough
|
||||
case SteppingOverState:
|
||||
if (stepDepth > 0)
|
||||
break;
|
||||
//fallthough
|
||||
case SteppingIntoState:
|
||||
stopped();
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void JSDebuggerAgent::exceptionThrow(qint64 scriptId,
|
||||
const QScriptValue &exception,
|
||||
bool hasHandler)
|
||||
{
|
||||
Q_UNUSED(scriptId);
|
||||
Q_UNUSED(exception);
|
||||
Q_UNUSED(hasHandler);
|
||||
// qDebug() << Q_FUNC_INFO << exception.toString() << hasHandler;
|
||||
#if 0 //sometimes, we get exceptions that we should just ignore.
|
||||
if (!hasHandler && state != StoppedState)
|
||||
stopped(true, exception);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
void JSDebuggerAgent::exceptionCatch(qint64 scriptId, const QScriptValue &exception)
|
||||
{
|
||||
Q_UNUSED(scriptId);
|
||||
Q_UNUSED(exception);
|
||||
}
|
||||
|
||||
bool JSDebuggerAgent::supportsExtension(Extension extension) const
|
||||
{
|
||||
return extension == QScriptEngineAgent::DebuggerInvocationRequest;
|
||||
}
|
||||
|
||||
QVariant JSDebuggerAgent::extension(Extension extension, const QVariant &argument)
|
||||
{
|
||||
if (extension == QScriptEngineAgent::DebuggerInvocationRequest) {
|
||||
d->stopped();
|
||||
return QVariant();
|
||||
}
|
||||
return QScriptEngineAgent::extension(extension, argument);
|
||||
}
|
||||
|
||||
void JSDebuggerAgent::messageReceived(const QByteArray &message)
|
||||
{
|
||||
d->messageReceived(message);
|
||||
}
|
||||
|
||||
void JSDebuggerAgentPrivate::messageReceived(const QByteArray &message)
|
||||
{
|
||||
QDataStream ds(message);
|
||||
QByteArray command;
|
||||
ds >> command;
|
||||
if (command == "BREAKPOINTS") {
|
||||
ds >> breakpoints;
|
||||
|
||||
fileNameToBreakpoints.clear();
|
||||
foreach (const JSAgentBreakpointData &bp, breakpoints) {
|
||||
fileNameToBreakpoints.insertMulti(fileName(bp.fileUrl), bp);
|
||||
}
|
||||
|
||||
//qDebug() << "BREAKPOINTS";
|
||||
//foreach (const JSAgentBreakpointData &bp, breakpoints)
|
||||
// qDebug() << "BREAKPOINT: " << bp.fileName << bp.lineNumber;
|
||||
} else if (command == "WATCH_EXPRESSIONS") {
|
||||
ds >> watchExpressions;
|
||||
} else if (command == "STEPOVER") {
|
||||
stepDepth = 0;
|
||||
state = SteppingOverState;
|
||||
continueExec();
|
||||
} else if (command == "STEPINTO" || command == "INTERRUPT") {
|
||||
stepDepth = 0;
|
||||
state = SteppingIntoState;
|
||||
continueExec();
|
||||
} else if (command == "STEPOUT") {
|
||||
stepDepth = 0;
|
||||
state = SteppingOutState;
|
||||
continueExec();
|
||||
} else if (command == "CONTINUE") {
|
||||
state = NoState;
|
||||
continueExec();
|
||||
} else if (command == "EXEC") {
|
||||
SetupExecEnv execEnv(this);
|
||||
|
||||
QByteArray id;
|
||||
QString expr;
|
||||
ds >> id >> expr;
|
||||
|
||||
JSAgentWatchData data = fromScriptValue(expr, engine()->evaluate(expr));
|
||||
knownObjectIds << data.objectId;
|
||||
|
||||
QByteArray reply;
|
||||
QDataStream rs(&reply, QIODevice::WriteOnly);
|
||||
rs << QByteArray("RESULT") << id << data;
|
||||
sendMessage(reply);
|
||||
} else if (command == "EXPAND") {
|
||||
SetupExecEnv execEnv(this);
|
||||
|
||||
QByteArray requestId;
|
||||
quint64 objectId;
|
||||
ds >> requestId >> objectId;
|
||||
QScriptValue v;
|
||||
if (knownObjectIds.contains(objectId))
|
||||
v = engine()->objectById(objectId);
|
||||
|
||||
QList<JSAgentWatchData> result = expandObject(v);
|
||||
recordKnownObjects(result);
|
||||
|
||||
QByteArray reply;
|
||||
QDataStream rs(&reply, QIODevice::WriteOnly);
|
||||
rs << QByteArray("EXPANDED") << requestId << result;
|
||||
sendMessage(reply);
|
||||
|
||||
} else if (command == "ACTIVATE_FRAME") {
|
||||
SetupExecEnv execEnv(this);
|
||||
|
||||
int frameId;
|
||||
ds >> frameId;
|
||||
|
||||
int deep = 0;
|
||||
QScriptContext *ctx = engine()->currentContext();
|
||||
while (ctx && deep < frameId) {
|
||||
ctx = ctx->parentContext();
|
||||
deep++;
|
||||
}
|
||||
|
||||
QList<JSAgentWatchData> watches;
|
||||
QList<JSAgentWatchData> locals = getLocals(ctx);
|
||||
|
||||
// re-evaluate watches given the frame's context
|
||||
QScriptContext *currentCtx = engine()->pushContext();
|
||||
currentCtx->setActivationObject(ctx->activationObject());
|
||||
currentCtx->setThisObject(ctx->thisObject());
|
||||
foreach (const QString &expr, watchExpressions)
|
||||
watches << fromScriptValue(expr, engine()->evaluate(expr));
|
||||
recordKnownObjects(watches);
|
||||
engine()->popContext();
|
||||
|
||||
QByteArray reply;
|
||||
QDataStream rs(&reply, QIODevice::WriteOnly);
|
||||
rs << QByteArray("LOCALS") << frameId << locals << watches;
|
||||
sendMessage(reply);
|
||||
} else if (command == "SET_PROPERTY") {
|
||||
SetupExecEnv execEnv(this);
|
||||
|
||||
QByteArray id;
|
||||
qint64 objectId;
|
||||
QString property;
|
||||
QString value;
|
||||
ds >> id >> objectId >> property >> value;
|
||||
|
||||
if (knownObjectIds.contains(objectId)) {
|
||||
QScriptValue object;
|
||||
object = engine()->objectById(objectId);
|
||||
|
||||
if (object.isObject()) {
|
||||
QScriptValue result = engine()->evaluate(value);
|
||||
object.setProperty(property, result);
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: feedback
|
||||
} else if (command == "PING") {
|
||||
int ping;
|
||||
ds >> ping;
|
||||
QByteArray reply;
|
||||
QDataStream rs(&reply, QIODevice::WriteOnly);
|
||||
rs << QByteArray("PONG") << ping;
|
||||
sendMessage(reply);
|
||||
} else {
|
||||
qDebug() << Q_FUNC_INFO << "Unknown command" << command;
|
||||
}
|
||||
|
||||
q->baseMessageReceived(message);
|
||||
}
|
||||
|
||||
void JSDebuggerAgentPrivate::stopped()
|
||||
{
|
||||
bool becauseOfException = false;
|
||||
const QScriptValue &exception = QScriptValue();
|
||||
|
||||
knownObjectIds.clear();
|
||||
state = StoppedState;
|
||||
QList<JSAgentStackData> backtrace;
|
||||
|
||||
for (QScriptContext* ctx = engine()->currentContext(); ctx; ctx = ctx->parentContext()) {
|
||||
QScriptContextInfo info(ctx);
|
||||
|
||||
JSAgentStackData frame;
|
||||
frame.functionName = info.functionName().toUtf8();
|
||||
if (frame.functionName.isEmpty()) {
|
||||
if (ctx->parentContext()) {
|
||||
switch (info.functionType()) {
|
||||
case QScriptContextInfo::ScriptFunction:
|
||||
frame.functionName = "<anonymous>";
|
||||
break;
|
||||
case QScriptContextInfo::NativeFunction:
|
||||
frame.functionName = "<native>";
|
||||
break;
|
||||
case QScriptContextInfo::QtFunction:
|
||||
case QScriptContextInfo::QtPropertyFunction:
|
||||
frame.functionName = "<native slot>";
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
frame.functionName = "<global>";
|
||||
}
|
||||
}
|
||||
frame.lineNumber = info.lineNumber();
|
||||
// if the line number is unknown, fallback to the function line number
|
||||
if (frame.lineNumber == -1)
|
||||
frame.lineNumber = info.functionStartLineNumber();
|
||||
|
||||
frame.fileUrl = info.fileName().toUtf8();
|
||||
backtrace.append(frame);
|
||||
}
|
||||
QList<JSAgentWatchData> watches;
|
||||
foreach (const QString &expr, watchExpressions)
|
||||
watches << fromScriptValue(expr, engine()->evaluate(expr));
|
||||
recordKnownObjects(watches);
|
||||
|
||||
QList<JSAgentWatchData> locals = getLocals(engine()->currentContext());
|
||||
|
||||
if (!becauseOfException) {
|
||||
// Clear any exceptions occurred during locals evaluation.
|
||||
engine()->clearExceptions();
|
||||
}
|
||||
|
||||
QByteArray reply;
|
||||
QDataStream rs(&reply, QIODevice::WriteOnly);
|
||||
rs << QByteArray("STOPPED") << backtrace << watches << locals
|
||||
<< becauseOfException << exception.toString();
|
||||
sendMessage(reply);
|
||||
|
||||
loop.exec(QEventLoop::ExcludeUserInputEvents);
|
||||
}
|
||||
|
||||
void JSDebuggerAgentPrivate::continueExec()
|
||||
{
|
||||
loop.quit();
|
||||
}
|
||||
|
||||
void JSDebuggerAgent::statusChanged(Status status)
|
||||
{
|
||||
engine()->setAgent((status == QDeclarativeDebugService::Enabled) ? this : 0);
|
||||
}
|
||||
|
||||
void JSDebuggerAgent::baseMessageReceived(const QByteArray &message)
|
||||
{
|
||||
QDeclarativeDebugService::messageReceived(message);
|
||||
}
|
||||
|
||||
} // namespace QmlJSDebugger
|
||||
@@ -1,125 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef INSPECTORPROTOCOL_H
|
||||
#define INSPECTORPROTOCOL_H
|
||||
|
||||
#include <QDebug>
|
||||
#include <QMetaType>
|
||||
#include <QMetaEnum>
|
||||
#include <QObject>
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
class InspectorProtocol : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_ENUMS(Message Tool)
|
||||
|
||||
public:
|
||||
enum Message {
|
||||
AnimationSpeedChanged = 0,
|
||||
AnimationPausedChanged = 19, // highest value
|
||||
ChangeTool = 1,
|
||||
ClearComponentCache = 2,
|
||||
ColorChanged = 3,
|
||||
CreateObject = 5,
|
||||
CurrentObjectsChanged = 6,
|
||||
DestroyObject = 7,
|
||||
MoveObject = 8,
|
||||
ObjectIdList = 9,
|
||||
Reload = 10,
|
||||
Reloaded = 11,
|
||||
SetAnimationSpeed = 12,
|
||||
SetAnimationPaused = 18,
|
||||
SetCurrentObjects = 14,
|
||||
SetDesignMode = 15,
|
||||
ShowAppOnTop = 16,
|
||||
ToolChanged = 17
|
||||
};
|
||||
|
||||
enum Tool {
|
||||
ColorPickerTool,
|
||||
SelectMarqueeTool,
|
||||
SelectTool,
|
||||
ZoomTool
|
||||
};
|
||||
|
||||
static inline QString toString(Message message)
|
||||
{
|
||||
return staticMetaObject.enumerator(0).valueToKey(message);
|
||||
}
|
||||
|
||||
static inline QString toString(Tool tool)
|
||||
{
|
||||
return staticMetaObject.enumerator(1).valueToKey(tool);
|
||||
}
|
||||
};
|
||||
|
||||
inline QDataStream & operator<< (QDataStream &stream, InspectorProtocol::Message message)
|
||||
{
|
||||
return stream << static_cast<quint32>(message);
|
||||
}
|
||||
|
||||
inline QDataStream & operator>> (QDataStream &stream, InspectorProtocol::Message &message)
|
||||
{
|
||||
quint32 i;
|
||||
stream >> i;
|
||||
message = static_cast<InspectorProtocol::Message>(i);
|
||||
return stream;
|
||||
}
|
||||
|
||||
inline QDebug operator<< (QDebug dbg, InspectorProtocol::Message message)
|
||||
{
|
||||
dbg << InspectorProtocol::toString(message);
|
||||
return dbg;
|
||||
}
|
||||
|
||||
inline QDataStream & operator<< (QDataStream &stream, InspectorProtocol::Tool tool)
|
||||
{
|
||||
return stream << static_cast<quint32>(tool);
|
||||
}
|
||||
|
||||
inline QDataStream & operator>> (QDataStream &stream, InspectorProtocol::Tool &tool)
|
||||
{
|
||||
quint32 i;
|
||||
stream >> i;
|
||||
tool = static_cast<InspectorProtocol::Tool>(i);
|
||||
return stream;
|
||||
}
|
||||
|
||||
inline QDebug operator<< (QDebug dbg, InspectorProtocol::Tool tool)
|
||||
{
|
||||
dbg << InspectorProtocol::toString(tool);
|
||||
return dbg;
|
||||
}
|
||||
|
||||
} // namespace QmlJSDebugger
|
||||
|
||||
#endif // INSPECTORPROTOCOL_H
|
||||
@@ -1,3 +0,0 @@
|
||||
INCLUDEPATH += $$PWD
|
||||
DEPENDPATH += $$PWD
|
||||
HEADERS += $$PWD/inspectorprotocol.h
|
||||
@@ -1,284 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qdeclarativeinspectorservice.h"
|
||||
|
||||
#include <inspectorprotocol.h>
|
||||
|
||||
#include <QStringList>
|
||||
#include <QColor>
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
Q_GLOBAL_STATIC(QDeclarativeInspectorService, serviceInstance)
|
||||
|
||||
QDeclarativeInspectorService::QDeclarativeInspectorService()
|
||||
: QDeclarativeDebugService(QLatin1String("QDeclarativeObserverMode"))
|
||||
{
|
||||
}
|
||||
|
||||
QDeclarativeInspectorService *QDeclarativeInspectorService::instance()
|
||||
{
|
||||
return serviceInstance();
|
||||
}
|
||||
|
||||
void QDeclarativeInspectorService::statusChanged(Status status)
|
||||
{
|
||||
emit debuggingClientChanged((status == Enabled));
|
||||
}
|
||||
|
||||
void QDeclarativeInspectorService::messageReceived(const QByteArray &message)
|
||||
{
|
||||
QDataStream ds(message);
|
||||
|
||||
InspectorProtocol::Message type;
|
||||
ds >> type;
|
||||
|
||||
switch (type) {
|
||||
case InspectorProtocol::SetCurrentObjects: {
|
||||
int itemCount = 0;
|
||||
ds >> itemCount;
|
||||
|
||||
QList<QObject*> selectedObjects;
|
||||
for (int i = 0; i < itemCount; ++i) {
|
||||
int debugId = -1;
|
||||
ds >> debugId;
|
||||
if (QObject *obj = objectForId(debugId))
|
||||
selectedObjects << obj;
|
||||
}
|
||||
|
||||
emit currentObjectsChanged(selectedObjects);
|
||||
break;
|
||||
}
|
||||
case InspectorProtocol::Reload: {
|
||||
emit reloadRequested();
|
||||
break;
|
||||
}
|
||||
case InspectorProtocol::SetAnimationSpeed: {
|
||||
qreal speed;
|
||||
ds >> speed;
|
||||
emit animationSpeedChangeRequested(speed);
|
||||
break;
|
||||
}
|
||||
case InspectorProtocol::SetAnimationPaused: {
|
||||
bool paused;
|
||||
ds >> paused;
|
||||
emit executionPauseChangeRequested(paused);
|
||||
break;
|
||||
}
|
||||
case InspectorProtocol::ChangeTool: {
|
||||
InspectorProtocol::Tool tool;
|
||||
ds >> tool;
|
||||
switch (tool) {
|
||||
case InspectorProtocol::ColorPickerTool:
|
||||
emit colorPickerToolRequested();
|
||||
break;
|
||||
case InspectorProtocol::SelectTool:
|
||||
emit selectToolRequested();
|
||||
break;
|
||||
case InspectorProtocol::SelectMarqueeTool:
|
||||
emit selectMarqueeToolRequested();
|
||||
break;
|
||||
case InspectorProtocol::ZoomTool:
|
||||
emit zoomToolRequested();
|
||||
break;
|
||||
default:
|
||||
qWarning() << "Warning: Unhandled tool:" << tool;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case InspectorProtocol::SetDesignMode: {
|
||||
bool inDesignMode;
|
||||
ds >> inDesignMode;
|
||||
emit designModeBehaviorChanged(inDesignMode);
|
||||
break;
|
||||
}
|
||||
case InspectorProtocol::ShowAppOnTop: {
|
||||
bool showOnTop;
|
||||
ds >> showOnTop;
|
||||
emit showAppOnTopChanged(showOnTop);
|
||||
break;
|
||||
}
|
||||
case InspectorProtocol::CreateObject: {
|
||||
QString qml;
|
||||
int parentId;
|
||||
QString filename;
|
||||
QStringList imports;
|
||||
ds >> qml >> parentId >> imports >> filename;
|
||||
int order = -1;
|
||||
if (!ds.atEnd()) {
|
||||
ds >> order;
|
||||
}
|
||||
emit objectCreationRequested(qml, objectForId(parentId), imports, filename, order);
|
||||
break;
|
||||
}
|
||||
case InspectorProtocol::DestroyObject: {
|
||||
int debugId;
|
||||
ds >> debugId;
|
||||
if (QObject* obj = objectForId(debugId)) {
|
||||
emit objectDeletionRequested(obj);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case InspectorProtocol::MoveObject: {
|
||||
int debugId, newParent;
|
||||
ds >> debugId >> newParent;
|
||||
emit objectReparentRequested(objectForId(debugId), objectForId(newParent));
|
||||
break;
|
||||
}
|
||||
case InspectorProtocol::ObjectIdList: {
|
||||
int itemCount;
|
||||
ds >> itemCount;
|
||||
m_stringIdForObjectId.clear();
|
||||
for (int i = 0; i < itemCount; ++i) {
|
||||
int itemDebugId;
|
||||
QString itemIdString;
|
||||
ds >> itemDebugId
|
||||
>> itemIdString;
|
||||
|
||||
m_stringIdForObjectId.insert(itemDebugId, itemIdString);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case InspectorProtocol::ClearComponentCache: {
|
||||
emit clearComponentCacheRequested();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
qWarning() << "Warning: Not handling message:" << type;
|
||||
}
|
||||
}
|
||||
|
||||
void QDeclarativeInspectorService::setDesignModeBehavior(bool inDesignMode)
|
||||
{
|
||||
QByteArray message;
|
||||
QDataStream ds(&message, QIODevice::WriteOnly);
|
||||
|
||||
ds << InspectorProtocol::SetDesignMode
|
||||
<< inDesignMode;
|
||||
|
||||
sendMessage(message);
|
||||
}
|
||||
|
||||
void QDeclarativeInspectorService::setCurrentObjects(QList<QObject*> objects)
|
||||
{
|
||||
QByteArray message;
|
||||
QDataStream ds(&message, QIODevice::WriteOnly);
|
||||
|
||||
ds << InspectorProtocol::CurrentObjectsChanged
|
||||
<< objects.length();
|
||||
|
||||
foreach (QObject *object, objects) {
|
||||
int id = idForObject(object);
|
||||
ds << id;
|
||||
}
|
||||
|
||||
sendMessage(message);
|
||||
}
|
||||
|
||||
void QDeclarativeInspectorService::setCurrentTool(QmlJSDebugger::Constants::DesignTool toolId)
|
||||
{
|
||||
QByteArray message;
|
||||
QDataStream ds(&message, QIODevice::WriteOnly);
|
||||
|
||||
ds << InspectorProtocol::ToolChanged
|
||||
<< toolId;
|
||||
|
||||
sendMessage(message);
|
||||
}
|
||||
|
||||
void QDeclarativeInspectorService::setAnimationSpeed(qreal slowDownFactor)
|
||||
{
|
||||
QByteArray message;
|
||||
QDataStream ds(&message, QIODevice::WriteOnly);
|
||||
|
||||
ds << InspectorProtocol::AnimationSpeedChanged
|
||||
<< slowDownFactor;
|
||||
|
||||
sendMessage(message);
|
||||
}
|
||||
|
||||
void QDeclarativeInspectorService::setAnimationPaused(bool paused)
|
||||
{
|
||||
QByteArray message;
|
||||
QDataStream ds(&message, QIODevice::WriteOnly);
|
||||
|
||||
ds << InspectorProtocol::AnimationPausedChanged
|
||||
<< paused;
|
||||
|
||||
sendMessage(message);
|
||||
}
|
||||
|
||||
void QDeclarativeInspectorService::reloaded()
|
||||
{
|
||||
QByteArray message;
|
||||
QDataStream ds(&message, QIODevice::WriteOnly);
|
||||
|
||||
ds << InspectorProtocol::Reloaded;
|
||||
|
||||
sendMessage(message);
|
||||
}
|
||||
|
||||
void QDeclarativeInspectorService::setShowAppOnTop(bool showAppOnTop)
|
||||
{
|
||||
QByteArray message;
|
||||
QDataStream ds(&message, QIODevice::WriteOnly);
|
||||
|
||||
ds << InspectorProtocol::ShowAppOnTop << showAppOnTop;
|
||||
|
||||
sendMessage(message);
|
||||
}
|
||||
|
||||
void QDeclarativeInspectorService::selectedColorChanged(const QColor &color)
|
||||
{
|
||||
QByteArray message;
|
||||
QDataStream ds(&message, QIODevice::WriteOnly);
|
||||
|
||||
ds << InspectorProtocol::ColorChanged
|
||||
<< color;
|
||||
|
||||
sendMessage(message);
|
||||
}
|
||||
|
||||
QString QDeclarativeInspectorService::idStringForObject(QObject *obj) const
|
||||
{
|
||||
int id = idForObject(obj);
|
||||
QString idString = m_stringIdForObjectId.value(id, QString());
|
||||
return idString;
|
||||
}
|
||||
|
||||
void QDeclarativeInspectorService::sendMessage(const QByteArray &message)
|
||||
{
|
||||
if (status() != Enabled)
|
||||
return;
|
||||
|
||||
QDeclarativeDebugService::sendMessage(message);
|
||||
}
|
||||
|
||||
} // namespace QmlJSDebugger
|
||||
@@ -1,835 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qdeclarativeviewinspector.h"
|
||||
#include "qdeclarativeviewinspector_p.h"
|
||||
#include "qdeclarativeinspectorservice.h"
|
||||
#include "editor/liveselectiontool.h"
|
||||
#include "editor/zoomtool.h"
|
||||
#include "editor/colorpickertool.h"
|
||||
#include "editor/livelayeritem.h"
|
||||
#include "editor/boundingrecthighlighter.h"
|
||||
|
||||
#include "qt_private/qdeclarativedebughelper_p.h"
|
||||
|
||||
#include <QDeclarativeItem>
|
||||
#include <QDeclarativeEngine>
|
||||
#include <QDeclarativeContext>
|
||||
#include <QDeclarativeExpression>
|
||||
#include <QWidget>
|
||||
#include <QVBoxLayout>
|
||||
#include <QMouseEvent>
|
||||
#include <QGraphicsObject>
|
||||
#include <QApplication>
|
||||
|
||||
#include "qt_private/qdeclarativestate_p.h"
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
QDeclarativeViewInspectorPrivate::QDeclarativeViewInspectorPrivate(QDeclarativeViewInspector *q) :
|
||||
q(q),
|
||||
designModeBehavior(false),
|
||||
showAppOnTop(false),
|
||||
animationPaused(false),
|
||||
slowDownFactor(1.0f)
|
||||
{
|
||||
}
|
||||
|
||||
QDeclarativeViewInspectorPrivate::~QDeclarativeViewInspectorPrivate()
|
||||
{
|
||||
}
|
||||
|
||||
QDeclarativeViewInspector::QDeclarativeViewInspector(QDeclarativeView *view, QObject *parent) :
|
||||
QObject(parent), data(new QDeclarativeViewInspectorPrivate(this))
|
||||
{
|
||||
data->view = view;
|
||||
data->manipulatorLayer = new LiveLayerItem(view->scene());
|
||||
data->selectionTool = new LiveSelectionTool(this);
|
||||
data->zoomTool = new ZoomTool(this);
|
||||
data->colorPickerTool = new ColorPickerTool(this);
|
||||
data->boundingRectHighlighter = new BoundingRectHighlighter(this);
|
||||
data->currentTool = data->selectionTool;
|
||||
|
||||
// to capture ChildRemoved event when viewport changes
|
||||
data->view->installEventFilter(this);
|
||||
|
||||
data->setViewport(data->view->viewport());
|
||||
|
||||
data->debugService = QDeclarativeInspectorService::instance();
|
||||
|
||||
connect(data->debugService, SIGNAL(designModeBehaviorChanged(bool)),
|
||||
SLOT(setDesignModeBehavior(bool)));
|
||||
connect(data->debugService, SIGNAL(showAppOnTopChanged(bool)),
|
||||
SLOT(setShowAppOnTop(bool)));
|
||||
connect(data->debugService, SIGNAL(reloadRequested()), data.data(), SLOT(_q_reloadView()));
|
||||
connect(data->debugService, SIGNAL(currentObjectsChanged(QList<QObject*>)),
|
||||
data.data(), SLOT(_q_onCurrentObjectsChanged(QList<QObject*>)));
|
||||
connect(data->debugService, SIGNAL(animationSpeedChangeRequested(qreal)),
|
||||
SLOT(animationSpeedChangeRequested(qreal)));
|
||||
connect(data->debugService, SIGNAL(executionPauseChangeRequested(bool)),
|
||||
SLOT(animationPausedChangeRequested(bool)));
|
||||
connect(data->debugService, SIGNAL(colorPickerToolRequested()),
|
||||
data.data(), SLOT(_q_changeToColorPickerTool()));
|
||||
connect(data->debugService, SIGNAL(selectMarqueeToolRequested()),
|
||||
data.data(), SLOT(_q_changeToMarqueeSelectTool()));
|
||||
connect(data->debugService, SIGNAL(selectToolRequested()), data.data(), SLOT(_q_changeToSingleSelectTool()));
|
||||
connect(data->debugService, SIGNAL(zoomToolRequested()), data.data(), SLOT(_q_changeToZoomTool()));
|
||||
connect(data->debugService,
|
||||
SIGNAL(objectCreationRequested(QString,QObject*,QStringList,QString,int)),
|
||||
data.data(), SLOT(_q_createQmlObject(QString,QObject*,QStringList,QString,int)));
|
||||
connect(data->debugService,
|
||||
SIGNAL(objectDeletionRequested(QObject*)), data.data(), SLOT(_q_deleteQmlObject(QObject*)));
|
||||
connect(data->debugService,
|
||||
SIGNAL(objectReparentRequested(QObject*,QObject*)),
|
||||
data.data(), SLOT(_q_reparentQmlObject(QObject*,QObject*)));
|
||||
connect(data->debugService, SIGNAL(clearComponentCacheRequested()),
|
||||
data.data(), SLOT(_q_clearComponentCache()));
|
||||
connect(data->view, SIGNAL(statusChanged(QDeclarativeView::Status)),
|
||||
data.data(), SLOT(_q_onStatusChanged(QDeclarativeView::Status)));
|
||||
|
||||
connect(data->colorPickerTool, SIGNAL(selectedColorChanged(QColor)),
|
||||
SIGNAL(selectedColorChanged(QColor)));
|
||||
connect(data->colorPickerTool, SIGNAL(selectedColorChanged(QColor)),
|
||||
data->debugService, SLOT(selectedColorChanged(QColor)));
|
||||
|
||||
data->_q_changeToSingleSelectTool();
|
||||
}
|
||||
|
||||
QDeclarativeViewInspector::~QDeclarativeViewInspector()
|
||||
{
|
||||
}
|
||||
|
||||
void QDeclarativeViewInspectorPrivate::_q_reloadView()
|
||||
{
|
||||
clearHighlight();
|
||||
emit q->reloadRequested();
|
||||
}
|
||||
|
||||
void QDeclarativeViewInspectorPrivate::setViewport(QWidget *widget)
|
||||
{
|
||||
if (viewport.data() == widget)
|
||||
return;
|
||||
|
||||
if (viewport)
|
||||
viewport.data()->removeEventFilter(q);
|
||||
|
||||
viewport = widget;
|
||||
if (viewport) {
|
||||
// make sure we get mouse move events
|
||||
viewport.data()->setMouseTracking(true);
|
||||
viewport.data()->installEventFilter(q);
|
||||
}
|
||||
}
|
||||
|
||||
void QDeclarativeViewInspectorPrivate::clearEditorItems()
|
||||
{
|
||||
clearHighlight();
|
||||
setSelectedItems(QList<QGraphicsItem*>());
|
||||
}
|
||||
|
||||
bool QDeclarativeViewInspector::eventFilter(QObject *obj, QEvent *event)
|
||||
{
|
||||
if (obj == data->view) {
|
||||
// Event from view
|
||||
if (event->type() == QEvent::ChildRemoved) {
|
||||
// Might mean that viewport has changed
|
||||
if (data->view->viewport() != data->viewport.data())
|
||||
data->setViewport(data->view->viewport());
|
||||
}
|
||||
return QObject::eventFilter(obj, event);
|
||||
}
|
||||
|
||||
// Event from viewport
|
||||
switch (event->type()) {
|
||||
case QEvent::Leave: {
|
||||
if (leaveEvent(event))
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
case QEvent::MouseButtonPress: {
|
||||
if (mousePressEvent(static_cast<QMouseEvent*>(event)))
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
case QEvent::MouseMove: {
|
||||
if (mouseMoveEvent(static_cast<QMouseEvent*>(event)))
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
case QEvent::MouseButtonRelease: {
|
||||
if (mouseReleaseEvent(static_cast<QMouseEvent*>(event)))
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
case QEvent::KeyPress: {
|
||||
if (keyPressEvent(static_cast<QKeyEvent*>(event)))
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
case QEvent::KeyRelease: {
|
||||
if (keyReleaseEvent(static_cast<QKeyEvent*>(event)))
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
case QEvent::MouseButtonDblClick: {
|
||||
if (mouseDoubleClickEvent(static_cast<QMouseEvent*>(event)))
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
case QEvent::Wheel: {
|
||||
if (wheelEvent(static_cast<QWheelEvent*>(event)))
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
} //switch
|
||||
|
||||
// standard event processing
|
||||
return QObject::eventFilter(obj, event);
|
||||
}
|
||||
|
||||
bool QDeclarativeViewInspector::leaveEvent(QEvent * /*event*/)
|
||||
{
|
||||
if (!data->designModeBehavior)
|
||||
return false;
|
||||
data->clearHighlight();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool QDeclarativeViewInspector::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
if (!data->designModeBehavior)
|
||||
return false;
|
||||
data->cursorPos = event->pos();
|
||||
data->currentTool->mousePressEvent(event);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool QDeclarativeViewInspector::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
if (!data->designModeBehavior) {
|
||||
data->clearEditorItems();
|
||||
return false;
|
||||
}
|
||||
data->cursorPos = event->pos();
|
||||
|
||||
QList<QGraphicsItem*> selItems = data->selectableItems(event->pos());
|
||||
if (!selItems.isEmpty()) {
|
||||
declarativeView()->setToolTip(AbstractLiveEditTool::titleForItem(selItems.first()));
|
||||
} else {
|
||||
declarativeView()->setToolTip(QString());
|
||||
}
|
||||
if (event->buttons()) {
|
||||
data->currentTool->mouseMoveEvent(event);
|
||||
} else {
|
||||
data->currentTool->hoverMoveEvent(event);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool QDeclarativeViewInspector::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
if (!data->designModeBehavior)
|
||||
return false;
|
||||
|
||||
data->cursorPos = event->pos();
|
||||
data->currentTool->mouseReleaseEvent(event);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool QDeclarativeViewInspector::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
if (!data->designModeBehavior)
|
||||
return false;
|
||||
|
||||
data->currentTool->keyPressEvent(event);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool QDeclarativeViewInspector::keyReleaseEvent(QKeyEvent *event)
|
||||
{
|
||||
if (!data->designModeBehavior)
|
||||
return false;
|
||||
|
||||
switch(event->key()) {
|
||||
case Qt::Key_V:
|
||||
data->_q_changeToSingleSelectTool();
|
||||
break;
|
||||
// disabled because multiselection does not do anything useful without design mode
|
||||
// case Qt::Key_M:
|
||||
// data->_q_changeToMarqueeSelectTool();
|
||||
// break;
|
||||
case Qt::Key_I:
|
||||
data->_q_changeToColorPickerTool();
|
||||
break;
|
||||
case Qt::Key_Z:
|
||||
data->_q_changeToZoomTool();
|
||||
break;
|
||||
case Qt::Key_Space:
|
||||
setAnimationPaused(!data->animationPaused);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
data->currentTool->keyReleaseEvent(event);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool insertObjectInListProperty(QDeclarativeListReference &fromList, int position, QObject *object)
|
||||
{
|
||||
QList<QObject *> tmpList;
|
||||
int i;
|
||||
|
||||
if (!(fromList.canCount() && fromList.canAt() && fromList.canAppend() && fromList.canClear()))
|
||||
return false;
|
||||
|
||||
if (position == fromList.count()) {
|
||||
fromList.append(object);
|
||||
return true;
|
||||
}
|
||||
|
||||
for (i=0; i<fromList.count(); ++i)
|
||||
tmpList << fromList.at(i);
|
||||
|
||||
fromList.clear();
|
||||
for (i=0; i<position; ++i)
|
||||
fromList.append(tmpList.at(i));
|
||||
|
||||
fromList.append(object);
|
||||
for (; i<tmpList.count(); ++i)
|
||||
fromList.append(tmpList.at(i));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool removeObjectFromListProperty(QDeclarativeListReference &fromList, QObject *object)
|
||||
{
|
||||
QList<QObject *> tmpList;
|
||||
int i;
|
||||
|
||||
if (!(fromList.canCount() && fromList.canAt() && fromList.canAppend() && fromList.canClear()))
|
||||
return false;
|
||||
|
||||
for (i=0; i<fromList.count(); ++i)
|
||||
if (object != fromList.at(i))
|
||||
tmpList << fromList.at(i);
|
||||
|
||||
fromList.clear();
|
||||
|
||||
foreach (QObject *item, tmpList)
|
||||
fromList.append(item);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void QDeclarativeViewInspectorPrivate::_q_createQmlObject(const QString &qml, QObject *parent,
|
||||
const QStringList &importList,
|
||||
const QString &filename, int order)
|
||||
{
|
||||
if (!parent)
|
||||
return;
|
||||
|
||||
QString imports;
|
||||
foreach (const QString &s, importList) {
|
||||
imports += s;
|
||||
imports += QLatin1Char('\n');
|
||||
}
|
||||
|
||||
QDeclarativeContext *parentContext = view->engine()->contextForObject(parent);
|
||||
QDeclarativeComponent component(view->engine(), q);
|
||||
QByteArray constructedQml = QString(imports + qml).toLatin1();
|
||||
|
||||
component.setData(constructedQml, filename);
|
||||
QObject *newObject = component.create(parentContext);
|
||||
if (newObject) {
|
||||
newObject->setParent(parent);
|
||||
do {
|
||||
// add child item
|
||||
QDeclarativeItem *parentItem = qobject_cast<QDeclarativeItem*>(parent);
|
||||
QDeclarativeItem *newItem = qobject_cast<QDeclarativeItem*>(newObject);
|
||||
if (parentItem && newItem) {
|
||||
newItem->setParentItem(parentItem);
|
||||
break;
|
||||
}
|
||||
|
||||
// add property change
|
||||
QDeclarativeState *parentState = qobject_cast<QDeclarativeState*>(parent);
|
||||
QDeclarativeStateOperation *newPropertyChanges = qobject_cast<QDeclarativeStateOperation *>(newObject);
|
||||
if (parentState && newPropertyChanges) {
|
||||
(*parentState) << newPropertyChanges;
|
||||
break;
|
||||
}
|
||||
|
||||
// add states
|
||||
QDeclarativeState *newState = qobject_cast<QDeclarativeState*>(newObject);
|
||||
if (parentItem && newState) {
|
||||
QDeclarativeListReference statesList(parentItem, "states");
|
||||
statesList.append(newObject);
|
||||
break;
|
||||
}
|
||||
|
||||
// add animation to transition
|
||||
if (parent->inherits("QDeclarativeTransition") &&
|
||||
newObject->inherits("QDeclarativeAbstractAnimation")) {
|
||||
QDeclarativeListReference animationsList(parent, "animations");
|
||||
animationsList.append(newObject);
|
||||
break;
|
||||
}
|
||||
|
||||
// add animation to animation
|
||||
if (parent->inherits("QDeclarativeAnimationGroup") &&
|
||||
newObject->inherits("QDeclarativeAbstractAnimation")) {
|
||||
QDeclarativeListReference animationsList(parent, "animations");
|
||||
if (order==-1) {
|
||||
animationsList.append(newObject);
|
||||
} else {
|
||||
if (!insertObjectInListProperty(animationsList, order, newObject)) {
|
||||
animationsList.append(newObject);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// add transition
|
||||
if (parentItem && newObject->inherits("QDeclarativeTransition")) {
|
||||
QDeclarativeListReference transitionsList(parentItem,"transitions");
|
||||
if (transitionsList.count() == 1 && transitionsList.at(0) == 0) {
|
||||
transitionsList.clear();
|
||||
}
|
||||
transitionsList.append(newObject);
|
||||
break;
|
||||
}
|
||||
|
||||
} while (false);
|
||||
}
|
||||
}
|
||||
|
||||
void QDeclarativeViewInspectorPrivate::_q_reparentQmlObject(QObject *object, QObject *newParent)
|
||||
{
|
||||
if (!newParent)
|
||||
return;
|
||||
|
||||
object->setParent(newParent);
|
||||
QDeclarativeItem *newParentItem = qobject_cast<QDeclarativeItem*>(newParent);
|
||||
QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(object);
|
||||
if (newParentItem && item)
|
||||
item->setParentItem(newParentItem);
|
||||
}
|
||||
|
||||
void QDeclarativeViewInspectorPrivate::_q_deleteQmlObject(QObject *object)
|
||||
{
|
||||
// special cases for transitions/animations
|
||||
if (object->inherits("QDeclarativeAbstractAnimation")) {
|
||||
if (object->parent()) {
|
||||
QDeclarativeListReference animationsList(object->parent(), "animations");
|
||||
if (removeObjectFromListProperty(animationsList, object))
|
||||
object->deleteLater();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (object->inherits("QDeclarativeTransition")) {
|
||||
QDeclarativeListReference transitionsList(object->parent(), "transitions");
|
||||
if (removeObjectFromListProperty(transitionsList, object))
|
||||
object->deleteLater();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void QDeclarativeViewInspectorPrivate::_q_clearComponentCache()
|
||||
{
|
||||
view->engine()->clearComponentCache();
|
||||
}
|
||||
|
||||
void QDeclarativeViewInspectorPrivate::_q_removeFromSelection(QObject *obj)
|
||||
{
|
||||
QList<QGraphicsItem*> items = selectedItems();
|
||||
if (QGraphicsItem *item = qobject_cast<QGraphicsObject*>(obj))
|
||||
items.removeOne(item);
|
||||
setSelectedItems(items);
|
||||
}
|
||||
|
||||
bool QDeclarativeViewInspector::mouseDoubleClickEvent(QMouseEvent * /*event*/)
|
||||
{
|
||||
if (!data->designModeBehavior)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool QDeclarativeViewInspector::wheelEvent(QWheelEvent *event)
|
||||
{
|
||||
if (!data->designModeBehavior)
|
||||
return false;
|
||||
data->currentTool->wheelEvent(event);
|
||||
return true;
|
||||
}
|
||||
|
||||
void QDeclarativeViewInspector::setDesignModeBehavior(bool value)
|
||||
{
|
||||
emit designModeBehaviorChanged(value);
|
||||
|
||||
data->debugService->setDesignModeBehavior(value);
|
||||
|
||||
data->designModeBehavior = value;
|
||||
|
||||
if (!data->designModeBehavior)
|
||||
data->clearEditorItems();
|
||||
}
|
||||
|
||||
bool QDeclarativeViewInspector::designModeBehavior()
|
||||
{
|
||||
return data->designModeBehavior;
|
||||
}
|
||||
|
||||
bool QDeclarativeViewInspector::showAppOnTop() const
|
||||
{
|
||||
return data->showAppOnTop;
|
||||
}
|
||||
|
||||
void QDeclarativeViewInspector::setShowAppOnTop(bool appOnTop)
|
||||
{
|
||||
if (data->view) {
|
||||
QWidget *window = data->view->window();
|
||||
Qt::WindowFlags flags = window->windowFlags();
|
||||
if (appOnTop)
|
||||
flags |= Qt::WindowStaysOnTopHint;
|
||||
else
|
||||
flags &= ~Qt::WindowStaysOnTopHint;
|
||||
|
||||
window->setWindowFlags(flags);
|
||||
window->show();
|
||||
}
|
||||
|
||||
data->showAppOnTop = appOnTop;
|
||||
data->debugService->setShowAppOnTop(appOnTop);
|
||||
|
||||
emit showAppOnTopChanged(appOnTop);
|
||||
}
|
||||
|
||||
void QDeclarativeViewInspectorPrivate::changeTool(Constants::DesignTool tool,
|
||||
Constants::ToolFlags /*flags*/)
|
||||
{
|
||||
switch(tool) {
|
||||
case Constants::SelectionToolMode:
|
||||
_q_changeToSingleSelectTool();
|
||||
break;
|
||||
case Constants::NoTool:
|
||||
default:
|
||||
currentTool = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void QDeclarativeViewInspectorPrivate::setSelectedItemsForTools(QList<QGraphicsItem *> items)
|
||||
{
|
||||
foreach (const QWeakPointer<QGraphicsObject> &obj, currentSelection) {
|
||||
if (QGraphicsItem *item = obj.data()) {
|
||||
if (!items.contains(item)) {
|
||||
QObject::disconnect(obj.data(), SIGNAL(destroyed(QObject*)),
|
||||
this, SLOT(_q_removeFromSelection(QObject*)));
|
||||
currentSelection.removeOne(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (QGraphicsItem *item, items) {
|
||||
if (QGraphicsObject *obj = item->toGraphicsObject()) {
|
||||
if (!currentSelection.contains(obj)) {
|
||||
QObject::connect(obj, SIGNAL(destroyed(QObject*)),
|
||||
this, SLOT(_q_removeFromSelection(QObject*)));
|
||||
currentSelection.append(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
currentTool->updateSelectedItems();
|
||||
}
|
||||
|
||||
void QDeclarativeViewInspectorPrivate::setSelectedItems(QList<QGraphicsItem *> items)
|
||||
{
|
||||
QList<QWeakPointer<QGraphicsObject> > oldList = currentSelection;
|
||||
setSelectedItemsForTools(items);
|
||||
if (oldList != currentSelection) {
|
||||
QList<QObject*> objectList;
|
||||
foreach (const QWeakPointer<QGraphicsObject> &graphicsObject, currentSelection) {
|
||||
if (graphicsObject)
|
||||
objectList << graphicsObject.data();
|
||||
}
|
||||
|
||||
debugService->setCurrentObjects(objectList);
|
||||
}
|
||||
}
|
||||
|
||||
QList<QGraphicsItem *> QDeclarativeViewInspectorPrivate::selectedItems()
|
||||
{
|
||||
QList<QGraphicsItem *> selection;
|
||||
foreach (const QWeakPointer<QGraphicsObject> &selectedObject, currentSelection) {
|
||||
if (selectedObject.data())
|
||||
selection << selectedObject.data();
|
||||
}
|
||||
|
||||
return selection;
|
||||
}
|
||||
|
||||
void QDeclarativeViewInspector::setSelectedItems(QList<QGraphicsItem *> items)
|
||||
{
|
||||
data->setSelectedItems(items);
|
||||
}
|
||||
|
||||
QList<QGraphicsItem *> QDeclarativeViewInspector::selectedItems()
|
||||
{
|
||||
return data->selectedItems();
|
||||
}
|
||||
|
||||
QDeclarativeView *QDeclarativeViewInspector::declarativeView()
|
||||
{
|
||||
return data->view;
|
||||
}
|
||||
|
||||
void QDeclarativeViewInspectorPrivate::clearHighlight()
|
||||
{
|
||||
boundingRectHighlighter->clear();
|
||||
}
|
||||
|
||||
void QDeclarativeViewInspectorPrivate::highlight(const QList<QGraphicsObject *> &items)
|
||||
{
|
||||
if (items.isEmpty())
|
||||
return;
|
||||
|
||||
QList<QGraphicsObject*> objectList;
|
||||
foreach (QGraphicsItem *item, items) {
|
||||
QGraphicsItem *child = item;
|
||||
|
||||
if (child) {
|
||||
QGraphicsObject *childObject = child->toGraphicsObject();
|
||||
if (childObject)
|
||||
objectList << childObject;
|
||||
}
|
||||
}
|
||||
|
||||
boundingRectHighlighter->highlight(objectList);
|
||||
}
|
||||
|
||||
QList<QGraphicsItem*> QDeclarativeViewInspectorPrivate::selectableItems(
|
||||
const QPointF &scenePos) const
|
||||
{
|
||||
QList<QGraphicsItem*> itemlist = view->scene()->items(scenePos);
|
||||
return filterForSelection(itemlist);
|
||||
}
|
||||
|
||||
QList<QGraphicsItem*> QDeclarativeViewInspectorPrivate::selectableItems(const QPoint &pos) const
|
||||
{
|
||||
QList<QGraphicsItem*> itemlist = view->items(pos);
|
||||
return filterForSelection(itemlist);
|
||||
}
|
||||
|
||||
QList<QGraphicsItem*> QDeclarativeViewInspectorPrivate::selectableItems(
|
||||
const QRectF &sceneRect, Qt::ItemSelectionMode selectionMode) const
|
||||
{
|
||||
QList<QGraphicsItem*> itemlist = view->scene()->items(sceneRect, selectionMode);
|
||||
return filterForSelection(itemlist);
|
||||
}
|
||||
|
||||
void QDeclarativeViewInspectorPrivate::_q_changeToSingleSelectTool()
|
||||
{
|
||||
currentToolMode = Constants::SelectionToolMode;
|
||||
selectionTool->setRubberbandSelectionMode(false);
|
||||
|
||||
changeToSelectTool();
|
||||
|
||||
emit q->selectToolActivated();
|
||||
debugService->setCurrentTool(Constants::SelectionToolMode);
|
||||
}
|
||||
|
||||
void QDeclarativeViewInspectorPrivate::changeToSelectTool()
|
||||
{
|
||||
if (currentTool == selectionTool)
|
||||
return;
|
||||
|
||||
currentTool->clear();
|
||||
currentTool = selectionTool;
|
||||
currentTool->clear();
|
||||
currentTool->updateSelectedItems();
|
||||
}
|
||||
|
||||
void QDeclarativeViewInspectorPrivate::_q_changeToMarqueeSelectTool()
|
||||
{
|
||||
changeToSelectTool();
|
||||
currentToolMode = Constants::MarqueeSelectionToolMode;
|
||||
selectionTool->setRubberbandSelectionMode(true);
|
||||
|
||||
emit q->marqueeSelectToolActivated();
|
||||
debugService->setCurrentTool(Constants::MarqueeSelectionToolMode);
|
||||
}
|
||||
|
||||
void QDeclarativeViewInspectorPrivate::_q_changeToZoomTool()
|
||||
{
|
||||
currentToolMode = Constants::ZoomMode;
|
||||
currentTool->clear();
|
||||
currentTool = zoomTool;
|
||||
currentTool->clear();
|
||||
|
||||
emit q->zoomToolActivated();
|
||||
debugService->setCurrentTool(Constants::ZoomMode);
|
||||
}
|
||||
|
||||
void QDeclarativeViewInspectorPrivate::_q_changeToColorPickerTool()
|
||||
{
|
||||
if (currentTool == colorPickerTool)
|
||||
return;
|
||||
|
||||
currentToolMode = Constants::ColorPickerMode;
|
||||
currentTool->clear();
|
||||
currentTool = colorPickerTool;
|
||||
currentTool->clear();
|
||||
|
||||
emit q->colorPickerActivated();
|
||||
debugService->setCurrentTool(Constants::ColorPickerMode);
|
||||
}
|
||||
|
||||
void QDeclarativeViewInspector::setAnimationSpeed(qreal slowDownFactor)
|
||||
{
|
||||
Q_ASSERT(slowDownFactor > 0);
|
||||
if (data->slowDownFactor == slowDownFactor)
|
||||
return;
|
||||
|
||||
animationSpeedChangeRequested(slowDownFactor);
|
||||
data->debugService->setAnimationSpeed(slowDownFactor);
|
||||
}
|
||||
|
||||
void QDeclarativeViewInspector::setAnimationPaused(bool paused)
|
||||
{
|
||||
if (data->animationPaused == paused)
|
||||
return;
|
||||
|
||||
animationPausedChangeRequested(paused);
|
||||
data->debugService->setAnimationPaused(paused);
|
||||
}
|
||||
|
||||
void QDeclarativeViewInspector::animationSpeedChangeRequested(qreal factor)
|
||||
{
|
||||
if (data->slowDownFactor != factor) {
|
||||
data->slowDownFactor = factor;
|
||||
emit animationSpeedChanged(factor);
|
||||
}
|
||||
|
||||
const float effectiveFactor = data->animationPaused ? 0 : factor;
|
||||
QDeclarativeDebugHelper::setAnimationSlowDownFactor(effectiveFactor);
|
||||
}
|
||||
|
||||
void QDeclarativeViewInspector::animationPausedChangeRequested(bool paused)
|
||||
{
|
||||
if (data->animationPaused != paused) {
|
||||
data->animationPaused = paused;
|
||||
emit animationPausedChanged(paused);
|
||||
}
|
||||
|
||||
const float effectiveFactor = paused ? 0 : data->slowDownFactor;
|
||||
QDeclarativeDebugHelper::setAnimationSlowDownFactor(effectiveFactor);
|
||||
}
|
||||
|
||||
|
||||
void QDeclarativeViewInspectorPrivate::_q_applyChangesFromClient()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
QList<QGraphicsItem*> QDeclarativeViewInspectorPrivate::filterForSelection(
|
||||
QList<QGraphicsItem*> &itemlist) const
|
||||
{
|
||||
foreach (QGraphicsItem *item, itemlist) {
|
||||
if (isEditorItem(item))
|
||||
itemlist.removeOne(item);
|
||||
}
|
||||
|
||||
return itemlist;
|
||||
}
|
||||
|
||||
bool QDeclarativeViewInspectorPrivate::isEditorItem(QGraphicsItem *item) const
|
||||
{
|
||||
return (item->type() == Constants::EditorItemType
|
||||
|| item->type() == Constants::ResizeHandleItemType
|
||||
|| item->data(Constants::EditorItemDataKey).toBool());
|
||||
}
|
||||
|
||||
void QDeclarativeViewInspectorPrivate::_q_onStatusChanged(QDeclarativeView::Status status)
|
||||
{
|
||||
if (status == QDeclarativeView::Ready)
|
||||
debugService->reloaded();
|
||||
}
|
||||
|
||||
void QDeclarativeViewInspectorPrivate::_q_onCurrentObjectsChanged(QList<QObject*> objects)
|
||||
{
|
||||
QList<QGraphicsItem*> items;
|
||||
QList<QGraphicsObject*> gfxObjects;
|
||||
foreach (QObject *obj, objects) {
|
||||
if (QDeclarativeItem *declarativeItem = qobject_cast<QDeclarativeItem*>(obj)) {
|
||||
items << declarativeItem;
|
||||
gfxObjects << declarativeItem;
|
||||
}
|
||||
}
|
||||
if (designModeBehavior) {
|
||||
setSelectedItemsForTools(items);
|
||||
clearHighlight();
|
||||
highlight(gfxObjects);
|
||||
}
|
||||
}
|
||||
|
||||
QString QDeclarativeViewInspector::idStringForObject(QObject *obj)
|
||||
{
|
||||
return QDeclarativeInspectorService::instance()->idStringForObject(obj);
|
||||
}
|
||||
|
||||
// adjusts bounding boxes on edges of screen to be visible
|
||||
QRectF QDeclarativeViewInspector::adjustToScreenBoundaries(const QRectF &boundingRectInSceneSpace)
|
||||
{
|
||||
int marginFromEdge = 1;
|
||||
QRectF boundingRect(boundingRectInSceneSpace);
|
||||
if (qAbs(boundingRect.left()) - 1 < 2)
|
||||
boundingRect.setLeft(marginFromEdge);
|
||||
|
||||
QRect rect = data->view->rect();
|
||||
|
||||
if (boundingRect.right() >= rect.right())
|
||||
boundingRect.setRight(rect.right() - marginFromEdge);
|
||||
|
||||
if (qAbs(boundingRect.top()) - 1 < 2)
|
||||
boundingRect.setTop(marginFromEdge);
|
||||
|
||||
if (boundingRect.bottom() >= rect.bottom())
|
||||
boundingRect.setBottom(rect.bottom() - marginFromEdge);
|
||||
|
||||
return boundingRect;
|
||||
}
|
||||
|
||||
} // namespace QmlJSDebugger
|
||||
@@ -1,129 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QDECLARATIVEVIEWINSPECTOR_P_H
|
||||
#define QDECLARATIVEVIEWINSPECTOR_P_H
|
||||
|
||||
#include <QWeakPointer>
|
||||
#include <QPointF>
|
||||
|
||||
#include "qdeclarativeviewinspector.h"
|
||||
#include "qdeclarativeinspectorservice.h"
|
||||
|
||||
namespace QmlJSDebugger {
|
||||
|
||||
class JSDebuggerAgent;
|
||||
class QDeclarativeViewInspector;
|
||||
class LiveSelectionTool;
|
||||
class ZoomTool;
|
||||
class ColorPickerTool;
|
||||
class LiveLayerItem;
|
||||
class BoundingRectHighlighter;
|
||||
class CrumblePath;
|
||||
class AbstractLiveEditTool;
|
||||
|
||||
class QDeclarativeViewInspectorPrivate : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QDeclarativeViewInspectorPrivate(QDeclarativeViewInspector *);
|
||||
~QDeclarativeViewInspectorPrivate();
|
||||
|
||||
QDeclarativeView *view;
|
||||
QDeclarativeViewInspector *q;
|
||||
QDeclarativeInspectorService *debugService;
|
||||
QWeakPointer<QWidget> viewport;
|
||||
|
||||
QPointF cursorPos;
|
||||
QList<QWeakPointer<QGraphicsObject> > currentSelection;
|
||||
|
||||
Constants::DesignTool currentToolMode;
|
||||
AbstractLiveEditTool *currentTool;
|
||||
|
||||
LiveSelectionTool *selectionTool;
|
||||
ZoomTool *zoomTool;
|
||||
ColorPickerTool *colorPickerTool;
|
||||
LiveLayerItem *manipulatorLayer;
|
||||
|
||||
BoundingRectHighlighter *boundingRectHighlighter;
|
||||
|
||||
bool designModeBehavior;
|
||||
bool showAppOnTop;
|
||||
|
||||
bool animationPaused;
|
||||
qreal slowDownFactor;
|
||||
|
||||
void setViewport(QWidget *widget);
|
||||
|
||||
void clearEditorItems();
|
||||
void changeToSelectTool();
|
||||
QList<QGraphicsItem*> filterForSelection(QList<QGraphicsItem*> &itemlist) const;
|
||||
|
||||
QList<QGraphicsItem*> selectableItems(const QPoint &pos) const;
|
||||
QList<QGraphicsItem*> selectableItems(const QPointF &scenePos) const;
|
||||
QList<QGraphicsItem*> selectableItems(const QRectF &sceneRect, Qt::ItemSelectionMode selectionMode) const;
|
||||
|
||||
void setSelectedItemsForTools(QList<QGraphicsItem *> items);
|
||||
void setSelectedItems(QList<QGraphicsItem *> items);
|
||||
QList<QGraphicsItem *> selectedItems();
|
||||
|
||||
void changeTool(Constants::DesignTool tool,
|
||||
Constants::ToolFlags flags = Constants::NoToolFlags);
|
||||
|
||||
void clearHighlight();
|
||||
void highlight(const QList<QGraphicsObject *> &item);
|
||||
inline void highlight(QGraphicsObject *item)
|
||||
{ highlight(QList<QGraphicsObject*>() << item); }
|
||||
|
||||
bool isEditorItem(QGraphicsItem *item) const;
|
||||
|
||||
public slots:
|
||||
void _q_reloadView();
|
||||
void _q_onStatusChanged(QDeclarativeView::Status status);
|
||||
void _q_onCurrentObjectsChanged(QList<QObject*> objects);
|
||||
void _q_applyChangesFromClient();
|
||||
void _q_createQmlObject(const QString &qml, QObject *parent,
|
||||
const QStringList &imports, const QString &filename = QString(), int order = 0);
|
||||
void _q_reparentQmlObject(QObject *, QObject *);
|
||||
void _q_deleteQmlObject(QObject *);
|
||||
|
||||
void _q_changeToSingleSelectTool();
|
||||
void _q_changeToMarqueeSelectTool();
|
||||
void _q_changeToZoomTool();
|
||||
void _q_changeToColorPickerTool();
|
||||
void _q_clearComponentCache();
|
||||
void _q_removeFromSelection(QObject *);
|
||||
|
||||
public:
|
||||
static QDeclarativeViewInspectorPrivate *get(QDeclarativeViewInspector *v) { return v->d_func(); }
|
||||
};
|
||||
|
||||
} // namespace QmlJSDebugger
|
||||
|
||||
#endif // QDECLARATIVEVIEWINSPECTOR_P_H
|
||||
@@ -1,14 +0,0 @@
|
||||
# This file is part of Qt Creator
|
||||
# It enables debugging of Qt Quick applications
|
||||
|
||||
QT += declarative script
|
||||
INCLUDEPATH += $$PWD/include
|
||||
|
||||
windows:CONFIG(debug, debug|release) {
|
||||
LIBNAME = QmlJSDebuggerd
|
||||
} else {
|
||||
LIBNAME = QmlJSDebugger
|
||||
}
|
||||
LIBS += -L$$PWD -l$$LIBNAME
|
||||
|
||||
DEFINES += QMLJSDEBUGGER
|
||||
@@ -1,45 +0,0 @@
|
||||
INCLUDEPATH += $$PWD/include
|
||||
|
||||
include($$PWD/protocol/protocol.pri)
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/include/jsdebuggeragent.h \
|
||||
$$PWD/include/qmljsdebugger_global.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/jsdebuggeragent.cpp
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/include/qdeclarativeviewinspector.h \
|
||||
$$PWD/include/qdeclarativeviewobserver.h \
|
||||
$$PWD/include/qdeclarativeinspectorservice.h \
|
||||
$$PWD/include/qmlinspectorconstants.h \
|
||||
$$PWD/editor/abstractliveedittool.h \
|
||||
$$PWD/editor/liveselectiontool.h \
|
||||
$$PWD/editor/livelayeritem.h \
|
||||
$$PWD/editor/livesingleselectionmanipulator.h \
|
||||
$$PWD/editor/liverubberbandselectionmanipulator.h \
|
||||
$$PWD/editor/liveselectionrectangle.h \
|
||||
$$PWD/editor/liveselectionindicator.h \
|
||||
$$PWD/editor/boundingrecthighlighter.h \
|
||||
$$PWD/editor/subcomponentmasklayeritem.h \
|
||||
$$PWD/editor/zoomtool.h \
|
||||
$$PWD/editor/colorpickertool.h \
|
||||
$$PWD/qdeclarativeviewinspector_p.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/qdeclarativeviewinspector.cpp \
|
||||
$$PWD/qdeclarativeinspectorservice.cpp \
|
||||
$$PWD/editor/abstractliveedittool.cpp \
|
||||
$$PWD/editor/liveselectiontool.cpp \
|
||||
$$PWD/editor/livelayeritem.cpp \
|
||||
$$PWD/editor/livesingleselectionmanipulator.cpp \
|
||||
$$PWD/editor/liverubberbandselectionmanipulator.cpp \
|
||||
$$PWD/editor/liveselectionrectangle.cpp \
|
||||
$$PWD/editor/liveselectionindicator.cpp \
|
||||
$$PWD/editor/boundingrecthighlighter.cpp \
|
||||
$$PWD/editor/subcomponentmasklayeritem.cpp \
|
||||
$$PWD/editor/zoomtool.cpp \
|
||||
$$PWD/editor/colorpickertool.cpp
|
||||
|
||||
DEFINES += QMLJSDEBUGGER
|
||||
@@ -1,18 +0,0 @@
|
||||
# This file is part of Qt Creator
|
||||
# It enables debugging of Qt Quick applications
|
||||
|
||||
TEMPLATE = lib
|
||||
CONFIG += staticlib create_prl
|
||||
QT += declarative script
|
||||
|
||||
DEFINES += BUILD_QMLJSDEBUGGER_STATIC_LIB
|
||||
|
||||
unix:QMAKE_CXXFLAGS_DEBUG += -O3
|
||||
|
||||
DESTDIR = $$PWD
|
||||
TARGET=QmlJSDebugger
|
||||
CONFIG(debug, debug|release) {
|
||||
windows:TARGET=QmlJSDebuggerd
|
||||
}
|
||||
|
||||
include(qmljsdebugger-src.pri)
|
||||
@@ -1,78 +0,0 @@
|
||||
<?xml version=\"1.0\" encoding=\"UTF-8\"?>
|
||||
<!DOCTYPE plist SYSTEM \"file://localhost/System/Library/DTDs/PropertyList.dtd\">
|
||||
<plist version=\"0.1\">
|
||||
<dict>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>This file is part of Qt Creator
|
||||
|
||||
Copyright (c) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
|
||||
Contact: http://www.qt-project.org/
|
||||
|
||||
GNU Lesser General Public License Usage
|
||||
|
||||
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, Digia gives you certain additional
|
||||
rights. These rights are described in the Digia Qt LGPL Exception
|
||||
version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
|
||||
Other Usage
|
||||
|
||||
Alternatively, this file may be used in accordance with the terms and
|
||||
conditions contained in a signed written agreement between you and Digia.
|
||||
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>@ICON@</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.nokia.qt.qml</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleGetInfoString</key>
|
||||
<string>Created by Qt/QMake</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>@TYPEINFO@</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>@EXECUTABLE@</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>$$QTCREATOR_VERSION</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>$$QTCREATOR_VERSION</string>
|
||||
<key>UTExportedTypeDeclarations</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>UTTypeIdentifier</key>
|
||||
<string>com.nokia.qt.qml</string>
|
||||
<key>UTTypeDescription</key>
|
||||
<string>Qt Markup Language</string>
|
||||
<key>UTTypeConformsTo</key>
|
||||
<array>
|
||||
<string>public.plain-text</string>
|
||||
</array>
|
||||
<key>UTTypeTagSpecification</key>
|
||||
<dict>
|
||||
<key>public.filename-extension</key>
|
||||
<array>
|
||||
<string>qml</string>
|
||||
</array>
|
||||
</dict>
|
||||
</dict>
|
||||
</array>
|
||||
<key>CFBundleDocumentTypes</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>LSItemContentTypes</key>
|
||||
<array>
|
||||
<string>com.nokia.qt.qml</string>
|
||||
</array>
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>Viewer</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,22 +0,0 @@
|
||||
Digia Qt LGPL Exception version 1.1
|
||||
|
||||
As an additional permission to the GNU Lesser General Public License version
|
||||
2.1, the object code form of a "work that uses the Library" may incorporate
|
||||
material from a header file that is part of the Library. You may distribute
|
||||
such object code under terms of your choice, provided that:
|
||||
(i) the header files of the Library have not been modified; and
|
||||
(ii) the incorporated material is limited to numerical parameters, data
|
||||
structure layouts, accessors, macros, inline functions and
|
||||
templates; and
|
||||
(iii) you comply with the terms of Section 6 of the GNU Lesser General
|
||||
Public License version 2.1.
|
||||
|
||||
Moreover, you may apply this exception to a modified version of the Library,
|
||||
provided that such modification does not involve copying material from the
|
||||
Library into the modified Library's header files unless such material is
|
||||
limited to (i) numerical parameters; (ii) data structure layouts;
|
||||
(iii) accessors; and (iv) small macros, templates and inline functions of
|
||||
five lines or less in length.
|
||||
|
||||
Furthermore, you are not required to apply this additional permission to a
|
||||
modified version of the Library.
|
||||
@@ -1,504 +0,0 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 2.1, February 1999
|
||||
|
||||
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the Lesser GPL. It also counts
|
||||
as the successor of the GNU Library Public License, version 2, hence
|
||||
the version number 2.1.]
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
Licenses are intended to guarantee your freedom to share and change
|
||||
free software--to make sure the software is free for all its users.
|
||||
|
||||
This license, the Lesser General Public License, applies to some
|
||||
specially designated software packages--typically libraries--of the
|
||||
Free Software Foundation and other authors who decide to use it. You
|
||||
can use it too, but we suggest you first think carefully about whether
|
||||
this license or the ordinary General Public License is the better
|
||||
strategy to use in any particular case, based on the explanations below.
|
||||
|
||||
When we speak of free software, we are referring to freedom of use,
|
||||
not price. Our General Public Licenses are designed to make sure that
|
||||
you have the freedom to distribute copies of free software (and charge
|
||||
for this service if you wish); that you receive source code or can get
|
||||
it if you want it; that you can change the software and use pieces of
|
||||
it in new free programs; and that you are informed that you can do
|
||||
these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
distributors to deny you these rights or to ask you to surrender these
|
||||
rights. These restrictions translate to certain responsibilities for
|
||||
you if you distribute copies of the library or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source
|
||||
code. If you link other code with the library, you must provide
|
||||
complete object files to the recipients, so that they can relink them
|
||||
with the library after making changes to the library and recompiling
|
||||
it. And you must show them these terms so they know their rights.
|
||||
|
||||
We protect your rights with a two-step method: (1) we copyright the
|
||||
library, and (2) we offer you this license, which gives you legal
|
||||
permission to copy, distribute and/or modify the library.
|
||||
|
||||
To protect each distributor, we want to make it very clear that
|
||||
there is no warranty for the free library. Also, if the library is
|
||||
modified by someone else and passed on, the recipients should know
|
||||
that what they have is not the original version, so that the original
|
||||
author's reputation will not be affected by problems that might be
|
||||
introduced by others.
|
||||
|
||||
Finally, software patents pose a constant threat to the existence of
|
||||
any free program. We wish to make sure that a company cannot
|
||||
effectively restrict the users of a free program by obtaining a
|
||||
restrictive license from a patent holder. Therefore, we insist that
|
||||
any patent license obtained for a version of the library must be
|
||||
consistent with the full freedom of use specified in this license.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the
|
||||
ordinary GNU General Public License. This license, the GNU Lesser
|
||||
General Public License, applies to certain designated libraries, and
|
||||
is quite different from the ordinary General Public License. We use
|
||||
this license for certain libraries in order to permit linking those
|
||||
libraries into non-free programs.
|
||||
|
||||
When a program is linked with a library, whether statically or using
|
||||
a shared library, the combination of the two is legally speaking a
|
||||
combined work, a derivative of the original library. The ordinary
|
||||
General Public License therefore permits such linking only if the
|
||||
entire combination fits its criteria of freedom. The Lesser General
|
||||
Public License permits more lax criteria for linking other code with
|
||||
the library.
|
||||
|
||||
We call this license the "Lesser" General Public License because it
|
||||
does Less to protect the user's freedom than the ordinary General
|
||||
Public License. It also provides other free software developers Less
|
||||
of an advantage over competing non-free programs. These disadvantages
|
||||
are the reason we use the ordinary General Public License for many
|
||||
libraries. However, the Lesser license provides advantages in certain
|
||||
special circumstances.
|
||||
|
||||
For example, on rare occasions, there may be a special need to
|
||||
encourage the widest possible use of a certain library, so that it becomes
|
||||
a de-facto standard. To achieve this, non-free programs must be
|
||||
allowed to use the library. A more frequent case is that a free
|
||||
library does the same job as widely used non-free libraries. In this
|
||||
case, there is little to gain by limiting the free library to free
|
||||
software only, so we use the Lesser General Public License.
|
||||
|
||||
In other cases, permission to use a particular library in non-free
|
||||
programs enables a greater number of people to use a large body of
|
||||
free software. For example, permission to use the GNU C Library in
|
||||
non-free programs enables many more people to use the whole GNU
|
||||
operating system, as well as its variant, the GNU/Linux operating
|
||||
system.
|
||||
|
||||
Although the Lesser General Public License is Less protective of the
|
||||
users' freedom, it does ensure that the user of a program that is
|
||||
linked with the Library has the freedom and the wherewithal to run
|
||||
that program using a modified version of the Library.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow. Pay close attention to the difference between a
|
||||
"work based on the library" and a "work that uses the library". The
|
||||
former contains code derived from the library, whereas the latter must
|
||||
be combined with the library in order to run.
|
||||
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library or other
|
||||
program which contains a notice placed by the copyright holder or
|
||||
other authorized party saying it may be distributed under the terms of
|
||||
this Lesser General Public License (also called "this License").
|
||||
Each licensee is addressed as "you".
|
||||
|
||||
A "library" means a collection of software functions and/or data
|
||||
prepared so as to be conveniently linked with application programs
|
||||
(which use some of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work
|
||||
which has been distributed under these terms. A "work based on the
|
||||
Library" means either the Library or any derivative work under
|
||||
copyright law: that is to say, a work containing the Library or a
|
||||
portion of it, either verbatim or with modifications and/or translated
|
||||
straightforwardly into another language. (Hereinafter, translation is
|
||||
included without limitation in the term "modification".)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for
|
||||
making modifications to it. For a library, complete source code means
|
||||
all the source code for all modules it contains, plus any associated
|
||||
interface definition files, plus the scripts used to control compilation
|
||||
and installation of the library.
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running a program using the Library is not restricted, and output from
|
||||
such a program is covered only if its contents constitute a work based
|
||||
on the Library (independent of the use of the Library in a tool for
|
||||
writing it). Whether that is true depends on what the Library does
|
||||
and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's
|
||||
complete source code as you receive it, in any medium, provided that
|
||||
you conspicuously and appropriately publish on each copy an
|
||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||
all the notices that refer to this License and to the absence of any
|
||||
warranty; and distribute a copy of this License along with the
|
||||
Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy,
|
||||
and you may at your option offer warranty protection in exchange for a
|
||||
fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion
|
||||
of it, thus forming a work based on the Library, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no
|
||||
charge to all third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a
|
||||
table of data to be supplied by an application program that uses
|
||||
the facility, other than as an argument passed when the facility
|
||||
is invoked, then you must make a good faith effort to ensure that,
|
||||
in the event an application does not supply such function or
|
||||
table, the facility still operates, and performs whatever part of
|
||||
its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has
|
||||
a purpose that is entirely well-defined independent of the
|
||||
application. Therefore, Subsection 2d requires that any
|
||||
application-supplied function or table used by this function must
|
||||
be optional: if the application does not supply it, the square
|
||||
root function must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Library,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Library, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||
License instead of this License to a given copy of the Library. To do
|
||||
this, you must alter all the notices that refer to this License, so
|
||||
that they refer to the ordinary GNU General Public License, version 2,
|
||||
instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in
|
||||
these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for
|
||||
that copy, so the ordinary GNU General Public License applies to all
|
||||
subsequent copies and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of
|
||||
the Library into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or
|
||||
derivative of it, under Section 2) in object code or executable form
|
||||
under the terms of Sections 1 and 2 above provided that you accompany
|
||||
it with the complete corresponding machine-readable source code, which
|
||||
must be distributed under the terms of Sections 1 and 2 above on a
|
||||
medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy
|
||||
from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place satisfies the requirement to
|
||||
distribute the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a "work that uses the Library". Such a
|
||||
work, in isolation, is not a derivative work of the Library, and
|
||||
therefore falls outside the scope of this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library
|
||||
creates an executable that is a derivative of the Library (because it
|
||||
contains portions of the Library), rather than a "work that uses the
|
||||
library". The executable is therefore covered by this License.
|
||||
Section 6 states terms for distribution of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a
|
||||
derivative work of the Library even though the source code is not.
|
||||
Whether this is true is especially significant if the work can be
|
||||
linked without the Library, or if the work is itself a library. The
|
||||
threshold for this to be true is not precisely defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data
|
||||
structure layouts and accessors, and small macros and small inline
|
||||
functions (ten lines or less in length), then the use of the object
|
||||
file is unrestricted, regardless of whether it is legally a derivative
|
||||
work. (Executables containing this object code plus portions of the
|
||||
Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may
|
||||
distribute the object code for the work under the terms of Section 6.
|
||||
Any executables containing that work also fall under Section 6,
|
||||
whether or not they are linked directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also combine or
|
||||
link a "work that uses the Library" with the Library to produce a
|
||||
work containing portions of the Library, and distribute that work
|
||||
under terms of your choice, provided that the terms permit
|
||||
modification of the work for the customer's own use and reverse
|
||||
engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the
|
||||
Library is used in it and that the Library and its use are covered by
|
||||
this License. You must supply a copy of this License. If the work
|
||||
during execution displays copyright notices, you must include the
|
||||
copyright notice for the Library among them, as well as a reference
|
||||
directing the user to the copy of this License. Also, you must do one
|
||||
of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding
|
||||
machine-readable source code for the Library including whatever
|
||||
changes were used in the work (which must be distributed under
|
||||
Sections 1 and 2 above); and, if the work is an executable linked
|
||||
with the Library, with the complete machine-readable "work that
|
||||
uses the Library", as object code and/or source code, so that the
|
||||
user can modify the Library and then relink to produce a modified
|
||||
executable containing the modified Library. (It is understood
|
||||
that the user who changes the contents of definitions files in the
|
||||
Library will not necessarily be able to recompile the application
|
||||
to use the modified definitions.)
|
||||
|
||||
b) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (1) uses at run time a
|
||||
copy of the library already present on the user's computer system,
|
||||
rather than copying library functions into the executable, and (2)
|
||||
will operate properly with a modified version of the library, if
|
||||
the user installs one, as long as the modified version is
|
||||
interface-compatible with the version that the work was made with.
|
||||
|
||||
c) Accompany the work with a written offer, valid for at
|
||||
least three years, to give the same user the materials
|
||||
specified in Subsection 6a, above, for a charge no more
|
||||
than the cost of performing this distribution.
|
||||
|
||||
d) If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above
|
||||
specified materials from the same place.
|
||||
|
||||
e) Verify that the user has already received a copy of these
|
||||
materials or that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the
|
||||
Library" must include any data and utility programs needed for
|
||||
reproducing the executable from it. However, as a special exception,
|
||||
the materials to be distributed need not include anything that is
|
||||
normally distributed (in either source or binary form) with the major
|
||||
components (compiler, kernel, and so on) of the operating system on
|
||||
which the executable runs, unless that component itself accompanies
|
||||
the executable.
|
||||
|
||||
It may happen that this requirement contradicts the license
|
||||
restrictions of other proprietary libraries that do not normally
|
||||
accompany the operating system. Such a contradiction means you cannot
|
||||
use both them and the Library together in an executable that you
|
||||
distribute.
|
||||
|
||||
7. You may place library facilities that are a work based on the
|
||||
Library side-by-side in a single library together with other library
|
||||
facilities not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on
|
||||
the Library and of the other library facilities is otherwise
|
||||
permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities. This must be distributed under the terms of the
|
||||
Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact
|
||||
that part of it is a work based on the Library, and explaining
|
||||
where to find the accompanying uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any
|
||||
attempt otherwise to copy, modify, sublicense, link with, or
|
||||
distribute the Library is void, and will automatically terminate your
|
||||
rights under this License. However, parties who have received copies,
|
||||
or rights, from you under this License will not have their licenses
|
||||
terminated so long as such parties remain in full compliance.
|
||||
|
||||
9. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Library or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Library (or any work based on the
|
||||
Library), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the
|
||||
Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
subject to these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties with
|
||||
this License.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Library at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Library by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library under this License may add
|
||||
an explicit geographical distribution limitation excluding those countries,
|
||||
so that distribution is permitted only in or among countries not thus
|
||||
excluded. In such case, this License incorporates the limitation as if
|
||||
written in the body of this License.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new
|
||||
versions of the Lesser General Public License from time to time.
|
||||
Such new versions will be similar in spirit to the present version,
|
||||
but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library
|
||||
specifies a version number of this License which applies to it and
|
||||
"any later version", you have the option of following the terms and
|
||||
conditions either of that version or of any later version published by
|
||||
the Free Software Foundation. If the Library does not specify a
|
||||
license version number, you may choose any version ever published by
|
||||
the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free
|
||||
programs whose distribution conditions are incompatible with these,
|
||||
write to the author to ask for permission. For software which is
|
||||
copyrighted by the Free Software Foundation, write to the Free
|
||||
Software Foundation; we sometimes make exceptions for this. Our
|
||||
decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
||||
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||||
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||||
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||||
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest
|
||||
possible use to the public, we recommend making it free software that
|
||||
everyone can redistribute and change. You can do so by permitting
|
||||
redistribution under these terms (or, alternatively, under the terms of the
|
||||
ordinary General Public License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. It is
|
||||
safest to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least the
|
||||
"copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the library's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the library, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1990
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
||||
|
||||
|
||||
@@ -1,306 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
** Contact: http://www.qt-project.org/legal
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and Digia. For licensing terms and
|
||||
** conditions see http://qt.digia.com/licensing. For further information
|
||||
** use the contact form at http://qt.digia.com/contact-us.
|
||||
**
|
||||
** 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, Digia gives you certain additional
|
||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
import QtQuick 1.0
|
||||
import Qt.labs.folderlistmodel 1.0
|
||||
|
||||
Rectangle {
|
||||
id: root
|
||||
property bool showFocusHighlight: false
|
||||
property variant folders: folders1
|
||||
property variant view: view1
|
||||
width: 320
|
||||
height: 480
|
||||
color: palette.window
|
||||
|
||||
FolderListModel {
|
||||
id: folders1
|
||||
nameFilters: [ "*.qml" ]
|
||||
folder: qmlViewerFolder
|
||||
}
|
||||
FolderListModel {
|
||||
id: folders2
|
||||
nameFilters: [ "*.qml" ]
|
||||
folder: qmlViewerFolder
|
||||
}
|
||||
|
||||
SystemPalette { id: palette }
|
||||
|
||||
function down(path) {
|
||||
if (folders == folders1) {
|
||||
view = view2
|
||||
folders = folders2;
|
||||
view1.state = "exitLeft";
|
||||
} else {
|
||||
view = view1
|
||||
folders = folders1;
|
||||
view2.state = "exitLeft";
|
||||
}
|
||||
view.x = root.width;
|
||||
view.state = "current";
|
||||
view.focus = true;
|
||||
folders.folder = path;
|
||||
}
|
||||
function up() {
|
||||
var path = folders.parentFolder;
|
||||
if (folders == folders1) {
|
||||
view = view2
|
||||
folders = folders2;
|
||||
view1.state = "exitRight";
|
||||
} else {
|
||||
view = view1
|
||||
folders = folders1;
|
||||
view2.state = "exitRight";
|
||||
}
|
||||
view.x = -root.width;
|
||||
view.state = "current";
|
||||
view.focus = true;
|
||||
folders.folder = path;
|
||||
}
|
||||
function keyPressed(key) {
|
||||
switch (key) {
|
||||
case Qt.Key_Up:
|
||||
case Qt.Key_Down:
|
||||
case Qt.Key_Left:
|
||||
case Qt.Key_Right:
|
||||
root.showFocusHighlight = true;
|
||||
break;
|
||||
default:
|
||||
// do nothing
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: folderDelegate
|
||||
Rectangle {
|
||||
id: wrapper
|
||||
function launch() {
|
||||
if (folders.isFolder(index)) {
|
||||
down(filePath);
|
||||
} else {
|
||||
qmlViewer.launch(filePath);
|
||||
}
|
||||
}
|
||||
width: root.width
|
||||
height: 52
|
||||
color: "transparent"
|
||||
Rectangle {
|
||||
id: highlight; visible: false
|
||||
anchors.fill: parent
|
||||
color: palette.highlight
|
||||
gradient: Gradient {
|
||||
GradientStop { id: t1; position: 0.0; color: palette.highlight }
|
||||
GradientStop { id: t2; position: 1.0; color: Qt.lighter(palette.highlight) }
|
||||
}
|
||||
}
|
||||
Item {
|
||||
width: 48; height: 48
|
||||
Image { source: "images/folder.png"; anchors.centerIn: parent; visible: folders.isFolder(index)}
|
||||
}
|
||||
Text {
|
||||
id: nameText
|
||||
anchors.fill: parent; verticalAlignment: Text.AlignVCenter
|
||||
text: fileName
|
||||
anchors.leftMargin: 54
|
||||
font.pixelSize: 32
|
||||
color: (wrapper.ListView.isCurrentItem && root.showFocusHighlight) ? palette.highlightedText : palette.windowText
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
MouseArea {
|
||||
id: mouseRegion
|
||||
anchors.fill: parent
|
||||
onPressed: {
|
||||
root.showFocusHighlight = false;
|
||||
wrapper.ListView.view.currentIndex = index;
|
||||
}
|
||||
onClicked: { if (folders == wrapper.ListView.view.model) launch() }
|
||||
}
|
||||
states: [
|
||||
State {
|
||||
name: "pressed"
|
||||
when: mouseRegion.pressed
|
||||
PropertyChanges { target: highlight; visible: true }
|
||||
PropertyChanges { target: nameText; color: palette.highlightedText }
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
ListView {
|
||||
id: view1
|
||||
anchors.top: titleBar.bottom
|
||||
anchors.bottom: parent.bottom
|
||||
x: 0
|
||||
width: parent.width
|
||||
model: folders1
|
||||
delegate: folderDelegate
|
||||
highlight: Rectangle {
|
||||
color: palette.highlight
|
||||
visible: root.showFocusHighlight && view1.count != 0
|
||||
gradient: Gradient {
|
||||
GradientStop { id: t1; position: 0.0; color: palette.highlight }
|
||||
GradientStop { id: t2; position: 1.0; color: Qt.lighter(palette.highlight) }
|
||||
}
|
||||
width: view1.currentItem == null ? 0 : view1.currentItem.width
|
||||
}
|
||||
highlightMoveSpeed: 1000
|
||||
pressDelay: 100
|
||||
focus: true
|
||||
state: "current"
|
||||
states: [
|
||||
State {
|
||||
name: "current"
|
||||
PropertyChanges { target: view1; x: 0 }
|
||||
},
|
||||
State {
|
||||
name: "exitLeft"
|
||||
PropertyChanges { target: view1; x: -root.width }
|
||||
},
|
||||
State {
|
||||
name: "exitRight"
|
||||
PropertyChanges { target: view1; x: root.width }
|
||||
}
|
||||
]
|
||||
transitions: [
|
||||
Transition {
|
||||
to: "current"
|
||||
SequentialAnimation {
|
||||
NumberAnimation { properties: "x"; duration: 250 }
|
||||
}
|
||||
},
|
||||
Transition {
|
||||
NumberAnimation { properties: "x"; duration: 250 }
|
||||
NumberAnimation { properties: "x"; duration: 250 }
|
||||
}
|
||||
]
|
||||
Keys.onPressed: root.keyPressed(event.key)
|
||||
}
|
||||
|
||||
ListView {
|
||||
id: view2
|
||||
anchors.top: titleBar.bottom
|
||||
anchors.bottom: parent.bottom
|
||||
x: parent.width
|
||||
width: parent.width
|
||||
model: folders2
|
||||
delegate: folderDelegate
|
||||
highlight: Rectangle {
|
||||
color: palette.highlight
|
||||
visible: root.showFocusHighlight && view2.count != 0
|
||||
gradient: Gradient {
|
||||
GradientStop { id: t1; position: 0.0; color: palette.highlight }
|
||||
GradientStop { id: t2; position: 1.0; color: Qt.lighter(palette.highlight) }
|
||||
}
|
||||
width: view1.currentItem == null ? 0 : view1.currentItem.width
|
||||
}
|
||||
highlightMoveSpeed: 1000
|
||||
pressDelay: 100
|
||||
states: [
|
||||
State {
|
||||
name: "current"
|
||||
PropertyChanges { target: view2; x: 0 }
|
||||
},
|
||||
State {
|
||||
name: "exitLeft"
|
||||
PropertyChanges { target: view2; x: -root.width }
|
||||
},
|
||||
State {
|
||||
name: "exitRight"
|
||||
PropertyChanges { target: view2; x: root.width }
|
||||
}
|
||||
]
|
||||
transitions: [
|
||||
Transition {
|
||||
to: "current"
|
||||
SequentialAnimation {
|
||||
NumberAnimation { properties: "x"; duration: 250 }
|
||||
}
|
||||
},
|
||||
Transition {
|
||||
NumberAnimation { properties: "x"; duration: 250 }
|
||||
}
|
||||
]
|
||||
Keys.onPressed: root.keyPressed(event.key)
|
||||
}
|
||||
|
||||
Keys.onPressed: {
|
||||
root.keyPressed(event.key);
|
||||
if (event.key == Qt.Key_Return || event.key == Qt.Key_Select || event.key == Qt.Key_Right) {
|
||||
view.currentItem.launch();
|
||||
event.accepted = true;
|
||||
} else if (event.key == Qt.Key_Left) {
|
||||
up();
|
||||
}
|
||||
}
|
||||
|
||||
BorderImage {
|
||||
source: "images/titlebar.sci";
|
||||
width: parent.width;
|
||||
height: 52
|
||||
y: -7
|
||||
id: titleBar
|
||||
|
||||
Rectangle {
|
||||
id: upButton
|
||||
width: 48
|
||||
height: titleBar.height - 7
|
||||
color: "transparent"
|
||||
|
||||
Image { anchors.centerIn: parent; source: "images/up.png" }
|
||||
MouseArea { id: upRegion; anchors.centerIn: parent
|
||||
width: 56
|
||||
height: 56
|
||||
onClicked: if (folders.parentFolder != "") up()
|
||||
}
|
||||
states: [
|
||||
State {
|
||||
name: "pressed"
|
||||
when: upRegion.pressed
|
||||
PropertyChanges { target: upButton; color: palette.highlight }
|
||||
}
|
||||
]
|
||||
}
|
||||
Rectangle {
|
||||
color: "gray"
|
||||
x: 48
|
||||
width: 1
|
||||
height: 44
|
||||
}
|
||||
|
||||
Text {
|
||||
anchors.left: upButton.right; anchors.right: parent.right; height: parent.height
|
||||
anchors.leftMargin: 4; anchors.rightMargin: 4
|
||||
text: folders.folder
|
||||
color: "white"
|
||||
elide: Text.ElideLeft; horizontalAlignment: Text.AlignRight; verticalAlignment: Text.AlignVCenter
|
||||
font.pixelSize: 32
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
<RCC>
|
||||
<qresource prefix="/browser">
|
||||
<file>Browser.qml</file>
|
||||
<file>images/up.png</file>
|
||||
<file>images/folder.png</file>
|
||||
<file>images/titlebar.sci</file>
|
||||
<file>images/titlebar.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||