2013-05-15 13:17:33 +02:00
|
|
|
#############################################################################
|
|
|
|
##
|
2015-01-14 18:07:15 +01:00
|
|
|
## Copyright (C) 2015 The Qt Company Ltd.
|
|
|
|
## Contact: http://www.qt.io/licensing
|
2013-05-15 13:17:33 +02:00
|
|
|
##
|
|
|
|
## 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
|
2015-01-14 18:07:15 +01:00
|
|
|
## a written agreement between you and The Qt Company. For licensing terms and
|
|
|
|
## conditions see http://www.qt.io/terms-conditions. For further information
|
2014-10-01 13:21:18 +02:00
|
|
|
## use the contact form at http://www.qt.io/contact-us.
|
2013-05-15 13:17:33 +02:00
|
|
|
##
|
|
|
|
## GNU Lesser General Public License Usage
|
|
|
|
## Alternatively, this file may be used under the terms of the GNU Lesser
|
2014-10-01 13:21:18 +02:00
|
|
|
## General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
## Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
## LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
## following information to ensure the GNU Lesser General Public License
|
|
|
|
## requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
2015-02-13 16:51:38 +01:00
|
|
|
## http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2013-05-15 13:17:33 +02:00
|
|
|
##
|
2015-01-14 18:07:15 +01:00
|
|
|
## In addition, as a special exception, The Qt Company gives you certain additional
|
|
|
|
## rights. These rights are described in The Qt Company LGPL Exception
|
2013-05-15 13:17:33 +02:00
|
|
|
## version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
##
|
|
|
|
#############################################################################
|
|
|
|
|
2013-04-08 14:05:17 +02:00
|
|
|
import operator
|
|
|
|
|
2011-11-29 16:00:18 +01:00
|
|
|
# for easier re-usage (because Python hasn't an enum type)
|
2013-04-05 16:58:06 +02:00
|
|
|
class Targets:
|
2015-05-29 17:26:13 +02:00
|
|
|
ALL_TARGETS = map(lambda x: 2 ** x , range(7))
|
2015-03-19 17:22:12 +01:00
|
|
|
|
|
|
|
(DESKTOP_474_GCC,
|
|
|
|
DESKTOP_480_DEFAULT,
|
|
|
|
SIMULATOR,
|
|
|
|
EMBEDDED_LINUX,
|
|
|
|
DESKTOP_521_DEFAULT,
|
|
|
|
DESKTOP_531_DEFAULT,
|
|
|
|
DESKTOP_541_GCC) = ALL_TARGETS
|
2011-11-29 16:00:18 +01:00
|
|
|
|
2013-01-18 16:31:48 +01:00
|
|
|
@staticmethod
|
|
|
|
def desktopTargetClasses():
|
2015-05-29 17:26:13 +02:00
|
|
|
desktopTargets = (sum(Targets.ALL_TARGETS) & ~Targets.SIMULATOR & ~Targets.EMBEDDED_LINUX)
|
2015-03-19 17:22:12 +01:00
|
|
|
if platform.system() == 'Darwin':
|
|
|
|
desktopTargets &= ~Targets.DESKTOP_541_GCC
|
2013-01-18 16:31:48 +01:00
|
|
|
return desktopTargets
|
|
|
|
|
2015-12-07 12:00:09 +01:00
|
|
|
@staticmethod
|
|
|
|
def qt4Classes():
|
2015-12-07 16:19:46 +01:00
|
|
|
return (Targets.DESKTOP_474_GCC | Targets.DESKTOP_480_DEFAULT
|
|
|
|
| Targets.SIMULATOR | Targets.EMBEDDED_LINUX)
|
2015-12-07 12:00:09 +01:00
|
|
|
|
2011-11-29 16:00:18 +01:00
|
|
|
@staticmethod
|
|
|
|
def getStringForTarget(target):
|
2013-04-05 16:58:06 +02:00
|
|
|
if target == Targets.DESKTOP_474_GCC:
|
2012-09-25 13:43:17 +02:00
|
|
|
return "Desktop 474 GCC"
|
2015-03-18 15:31:36 +01:00
|
|
|
elif target == Targets.DESKTOP_480_DEFAULT:
|
|
|
|
if platform.system() in ('Windows', 'Microsoft'):
|
|
|
|
return "Desktop 480 MSVC2010"
|
|
|
|
else:
|
|
|
|
return "Desktop 480 GCC"
|
2013-04-05 16:58:06 +02:00
|
|
|
elif target == Targets.SIMULATOR:
|
2011-11-29 16:00:18 +01:00
|
|
|
return "Qt Simulator"
|
2013-04-05 16:58:06 +02:00
|
|
|
elif target == Targets.EMBEDDED_LINUX:
|
2012-02-27 20:36:13 +01:00
|
|
|
return "Embedded Linux"
|
2014-02-20 11:15:27 +01:00
|
|
|
elif target == Targets.DESKTOP_521_DEFAULT:
|
|
|
|
return "Desktop 521 default"
|
2014-07-28 16:01:11 +02:00
|
|
|
elif target == Targets.DESKTOP_531_DEFAULT:
|
|
|
|
return "Desktop 531 default"
|
2015-02-20 13:54:44 +01:00
|
|
|
elif target == Targets.DESKTOP_541_GCC:
|
|
|
|
return "Desktop 541 GCC"
|
2011-11-29 16:00:18 +01:00
|
|
|
else:
|
|
|
|
return None
|
|
|
|
|
2012-02-17 17:10:53 +01:00
|
|
|
@staticmethod
|
|
|
|
def getTargetsAsStrings(targets):
|
|
|
|
if not isinstance(targets, (tuple,list)):
|
|
|
|
test.fatal("Wrong usage... This function handles only tuples or lists.")
|
|
|
|
return None
|
2013-04-05 16:58:06 +02:00
|
|
|
result = map(Targets.getStringForTarget, targets)
|
2012-02-17 17:10:53 +01:00
|
|
|
if None in result:
|
|
|
|
test.fatal("You've passed at least one unknown target!")
|
|
|
|
return result
|
|
|
|
|
2013-04-08 14:05:17 +02:00
|
|
|
@staticmethod
|
|
|
|
def intToArray(targets):
|
2015-03-19 17:22:12 +01:00
|
|
|
return filter(lambda x: x & targets, Targets.ALL_TARGETS)
|
2013-04-08 14:05:17 +02:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def arrayToInt(targetArr):
|
|
|
|
return reduce(operator.or_, targetArr, 0)
|
|
|
|
|
2014-07-28 16:01:11 +02:00
|
|
|
@staticmethod
|
|
|
|
def getDefaultKit():
|
|
|
|
return Targets.DESKTOP_521_DEFAULT
|
|
|
|
|
2011-11-29 16:00:18 +01:00
|
|
|
# this class holds some constants for easier usage inside the Projects view
|
|
|
|
class ProjectSettings:
|
|
|
|
BUILD = 1
|
|
|
|
RUN = 2
|
|
|
|
|
|
|
|
# this class defines some constants for the views of the creator's MainWindow
|
|
|
|
class ViewConstants:
|
2014-10-30 15:57:44 +01:00
|
|
|
WELCOME, EDIT, DESIGN, DEBUG, PROJECTS, ANALYZE, HELP = range(7)
|
2013-09-25 16:45:17 +02:00
|
|
|
FIRST_AVAILABLE = 0
|
2011-11-29 16:00:18 +01:00
|
|
|
# always adjust the following to the highest value of the available ViewConstants when adding new
|
|
|
|
LAST_AVAILABLE = HELP
|
|
|
|
|
|
|
|
# this function returns a regex of the tooltip of the FancyTabBar elements
|
|
|
|
# this is needed because the keyboard shortcut is OS specific
|
|
|
|
# if the provided argument does not match any of the ViewConstants it returns None
|
|
|
|
@staticmethod
|
|
|
|
def getToolTipForViewTab(viewTab):
|
2014-10-30 15:57:44 +01:00
|
|
|
if viewTab == ViewConstants.WELCOME:
|
2013-09-18 11:54:08 +02:00
|
|
|
toolTip = ur'Switch to <b>Welcome</b> mode <span style="color: gray; font-size: small">(Ctrl\+|\u2303)%d</span>'
|
2011-11-29 16:00:18 +01:00
|
|
|
elif viewTab == ViewConstants.EDIT:
|
2013-09-18 11:54:08 +02:00
|
|
|
toolTip = ur'Switch to <b>Edit</b> mode <span style="color: gray; font-size: small">(Ctrl\+|\u2303)%d</span>'
|
2011-11-29 16:00:18 +01:00
|
|
|
elif viewTab == ViewConstants.DESIGN:
|
2013-09-18 11:54:08 +02:00
|
|
|
toolTip = ur'Switch to <b>Design</b> mode <span style="color: gray; font-size: small">(Ctrl\+|\u2303)%d</span>'
|
2011-11-29 16:00:18 +01:00
|
|
|
elif viewTab == ViewConstants.DEBUG:
|
2013-09-18 11:54:08 +02:00
|
|
|
toolTip = ur'Switch to <b>Debug</b> mode <span style="color: gray; font-size: small">(Ctrl\+|\u2303)%d</span>'
|
2011-11-29 16:00:18 +01:00
|
|
|
elif viewTab == ViewConstants.PROJECTS:
|
2013-09-18 11:54:08 +02:00
|
|
|
toolTip = ur'Switch to <b>Projects</b> mode <span style="color: gray; font-size: small">(Ctrl\+|\u2303)%d</span>'
|
2011-11-29 16:00:18 +01:00
|
|
|
elif viewTab == ViewConstants.ANALYZE:
|
2013-09-18 11:54:08 +02:00
|
|
|
toolTip = ur'Switch to <b>Analyze</b> mode <span style="color: gray; font-size: small">(Ctrl\+|\u2303)%d</span>'
|
2011-11-29 16:00:18 +01:00
|
|
|
elif viewTab == ViewConstants.HELP:
|
2013-09-18 11:54:08 +02:00
|
|
|
toolTip = ur'Switch to <b>Help</b> mode <span style="color: gray; font-size: small">(Ctrl\+|\u2303)%d</span>'
|
2011-11-29 16:00:18 +01:00
|
|
|
else:
|
|
|
|
return None
|
2013-09-18 11:54:08 +02:00
|
|
|
return toolTip % (viewTab + 1)
|
2011-11-29 16:00:18 +01:00
|
|
|
|
|
|
|
class SubprocessType:
|
|
|
|
QT_WIDGET=0
|
|
|
|
QT_QUICK_APPLICATION=1
|
|
|
|
QT_QUICK_UI=2
|
|
|
|
USER_DEFINED=3
|
|
|
|
|
|
|
|
@staticmethod
|
2014-02-14 13:04:07 +01:00
|
|
|
def getWindowType(subprocessType, qtQuickVersion="1.1"):
|
2011-11-29 16:00:18 +01:00
|
|
|
if subprocessType == SubprocessType.QT_WIDGET:
|
|
|
|
return "QMainWindow"
|
|
|
|
if subprocessType == SubprocessType.QT_QUICK_APPLICATION:
|
2014-05-15 13:43:57 +02:00
|
|
|
qqv = "2"
|
|
|
|
if qtQuickVersion[0] == "1":
|
|
|
|
qqv = "1"
|
|
|
|
return "QtQuick%sApplicationViewer" % qqv
|
2011-11-29 16:00:18 +01:00
|
|
|
if subprocessType == SubprocessType.QT_QUICK_UI:
|
2014-02-14 13:04:07 +01:00
|
|
|
if qtQuickVersion == "1.1":
|
2014-01-22 09:39:04 +01:00
|
|
|
return "QDeclarativeViewer"
|
|
|
|
else:
|
|
|
|
return "QQuickView"
|
2011-11-29 16:00:18 +01:00
|
|
|
if subprocessType == SubprocessType.USER_DEFINED:
|
|
|
|
return "user-defined"
|
|
|
|
test.fatal("Could not determine the WindowType for SubprocessType %s" % subprocessType)
|
|
|
|
return None
|
|
|
|
|
2012-07-24 11:42:14 +02:00
|
|
|
class QtInformation:
|
|
|
|
QT_VERSION = 0
|
|
|
|
QT_BINPATH = 1
|
|
|
|
QT_LIBPATH = 2
|
2014-04-24 16:50:29 +02:00
|
|
|
|
|
|
|
class LibType:
|
|
|
|
SHARED = 0
|
|
|
|
STATIC = 1
|
|
|
|
QT_PLUGIN = 2
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def getStringForLib(libType):
|
|
|
|
if libType == LibType.SHARED:
|
|
|
|
return "Shared Library"
|
|
|
|
if libType == LibType.STATIC:
|
|
|
|
return "Statically Linked Library"
|
|
|
|
if libType == LibType.QT_PLUGIN:
|
|
|
|
return "Qt Plugin"
|
|
|
|
return None
|
2015-06-23 14:39:27 +02:00
|
|
|
|
|
|
|
class Qt5Path:
|
|
|
|
DOCS = 0
|
|
|
|
EXAMPLES = 1
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def getPaths(pathSpec):
|
|
|
|
if pathSpec == Qt5Path.DOCS:
|
|
|
|
path52 = "/doc"
|
|
|
|
path53 = "/Docs/Qt-5.3"
|
|
|
|
path54 = "/Docs/Qt-5.4"
|
|
|
|
elif pathSpec == Qt5Path.EXAMPLES:
|
|
|
|
path52 = "/examples"
|
|
|
|
path53 = "/Examples/Qt-5.3"
|
|
|
|
path54 = "/Examples/Qt-5.4"
|
|
|
|
else:
|
|
|
|
test.fatal("Unknown pathSpec given: %s" % str(pathSpec))
|
|
|
|
return []
|
|
|
|
if platform.system() in ('Microsoft', 'Windows'):
|
|
|
|
return ["C:/Qt/Qt5.2.1/5.2.1/msvc2010" + path52,
|
|
|
|
"C:/Qt/Qt5.3.1" + path53, "C:/Qt/Qt5.4.1" + path54]
|
|
|
|
elif platform.system() == 'Linux':
|
|
|
|
if __is64BitOS__():
|
|
|
|
return map(os.path.expanduser, ["~/Qt5.2.1/5.2.1/gcc_64" + path52,
|
|
|
|
"~/Qt5.3.1" + path53, "~/Qt5.4.1" + path54])
|
|
|
|
return map(os.path.expanduser, ["~/Qt5.2.1/5.2.1/gcc" + path52,
|
|
|
|
"~/Qt5.3.1" + path53, "~/Qt5.4.1" + path54])
|
|
|
|
else:
|
|
|
|
return map(os.path.expanduser, ["~/Qt5.2.1/5.2.1/clang_64" + path52,
|
|
|
|
"~/Qt5.3.1" + path53])
|