Exemple #1
0
def main():
    global dbus
    parser = ArgumentParser()
    parser.add_argument("-v", "--verbose", help="increase output verbosity",
                        action="store_true")
    args = parser.parse_args()
    QtQml.qmlRegisterType(QmlPage, "djpdf", 1, 0, "DjpdfPage")
    app = QApplication([])
    engine = QQmlApplicationEngine()
    thumbnail_image_provider = ThumbnailImageProvider()
    engine.addImageProvider("thumbnails", thumbnail_image_provider)
    ctx = engine.rootContext()
    pages_model = QmlPagesModel(verbose=args.verbose)
    if os.environ.get("DJPDF_PLATFORM_INTEGRATION", "") == "flatpak":
        import dbus
        import dbus.mainloop.glib
        dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
        bus = dbus.SessionBus()
        platform_integration = QmlFlatpakPlatformIntegration(bus)
    else:
        platform_integration = QmlPlatformIntegration()
    ctx.setContextProperty("pagesModel", pages_model)
    ctx.setContextProperty("platformIntegration", platform_integration)
    engine.load(QUrl.fromLocalFile(
        os.path.join(QML_DIR, "main.qml")))
    if os.environ.get("DJPDF_PLATFORM_INTEGRATION", "") == "flatpak":
        platform_integration.win_id = engine.rootObjects()[0].winId()
    exit(app.exec_())
Exemple #2
0
def main():
    global dbus
    parser = ArgumentParser()
    parser.add_argument("-v",
                        "--verbose",
                        help="increase output verbosity",
                        action="store_true")
    args = parser.parse_args()
    QtQml.qmlRegisterType(QmlPage, "djpdf", 1, 0, "DjpdfPage")
    app = QApplication([])
    app.setWindowIcon(QIcon.fromTheme("com.github.unrud.djpdf"))
    engine = QQmlApplicationEngine()
    thumbnail_image_provider = ThumbnailImageProvider()
    engine.addImageProvider("thumbnails", thumbnail_image_provider)
    ctx = engine.rootContext()
    pages_model = QmlPagesModel(verbose=args.verbose)
    if os.environ.get("DJPDF_PLATFORM") == "flatpak":
        import dbus
        import dbus.mainloop.glib
        dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
        bus = dbus.SessionBus()
        platform_integration = QmlFlatpakPlatformIntegration(bus)
    else:
        platform_integration = QmlPlatformIntegration()
    ctx.setContextProperty("pagesModel", pages_model)
    ctx.setContextProperty("platformIntegration", platform_integration)
    engine.load(QUrl.fromLocalFile(os.path.join(QML_DIR, "main.qml")))
    platform_integration.window = engine.rootObjects()[0]
    exit(app.exec_())
Exemple #3
0
def main():
    app = QtGui.QGuiApplication(sys.argv)

    QtQml.qmlRegisterType(CalendarProvider, "MyCalendar", 1, 0,
                          "CalendarProvider")

    engine = QtQml.QQmlApplicationEngine()
    filename = os.path.join(CURRENT_DIR, "main.qml")
    engine.load(QtCore.QUrl.fromLocalFile(filename))

    if not engine.rootObjects():
        sys.exit(-1)

    sys.exit(app.exec_())
Exemple #4
0
def registerQmlCustomTypes():
    """Register the custom QML types for the app."""

    QtQml.qmlRegisterType(PostCardListModel, "PostCard", 1, 0,
                          "PostCardListModel")
    QtQml.qmlRegisterType(RecipientListModel, "PostCard", 1, 0,
                          "RecipientListModel")
    QtQml.qmlRegisterType(Utils, "PostCard", 1, 0, "Utils")
    QtQml.qmlRegisterType(CredentialManager, "PostCard", 1, 0,
                          "CredentialManager")
Exemple #5
0
def register_qml_types():
    QtQml.qmlRegisterType(GraphTableModel, 'GraphUtils', 1, 0,
                          'GraphTableModel')
    QtQml.qmlRegisterType(SpectrumGraphData, 'GraphUtils', 1, 0,
                          'SpectrumGraphData')
    QtQml.qmlRegisterType(LiveSpectrumGraphData, 'GraphUtils', 1, 0,
                          'LiveSpectrumGraphData')
Exemple #6
0
def main():
    sys.argv += ['--style', 'material']

    CURRENT_DIR = os.path.dirname(sys.argv[0])

    QtGui.QGuiApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling)
    QtCore.QCoreApplication.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps)

    QtQml.qmlRegisterType(Backend, 'MyLibrary', 1, 0, 'Backend')

    app = QtGui.QGuiApplication(sys.argv)
    app.setWindowIcon(QtGui.QIcon(resource_path('icon.ico')))

    engine = QtQml.QQmlApplicationEngine()

    utils = Utils()
    engine.rootContext().setContextProperty('Utils', utils)

    engine.load(os.path.join(CURRENT_DIR, resource_path('qml/main.qml')))

    if not engine.rootObjects():
        sys.exit(-1)
    sys.exit(app.exec_())
Exemple #7
0
    @QtCore.Slot(QtCore.QDate, result="QVariantList")
    def eventsForDate(self, date):
        events = []
        for event in self._cache_events:
            start = event["start"]
            if start.date() == date:
                events.append(event)
        return events

    @QtCore.Slot(list)
    def _handle_events(self, events):
        self._cache_events = events
        self.loaded.emit()
        logging.debug("Loaded")


if __name__ == "__main__":
    app = QtGui.QGuiApplication(sys.argv)

    QtQml.qmlRegisterType(CalendarProvider, "MyCalendar", 1, 0,
                          "CalendarProvider")
    cal2 = CalendarProvider()
    engine = QtQml.QQmlApplicationEngine()
    engine.rootContext().setContextProperty("cal2", cal2)
    filename = os.path.join(CURRENT_DIR, "CalendarDraft.qml")
    engine.load(QtCore.QUrl.fromLocalFile(filename))

    if not engine.rootObjects():
        sys.exit(-1)

    sys.exit(app.exec_())
def register_qml_types():
    QtQml.qmlRegisterType(DeviceInfo, 'DeviceConfig', 1, 0, 'DeviceInfo')
    QtQml.qmlRegisterType(DeviceInfoList, 'DeviceConfig', 1, 0,
                          'DeviceInfoList')
Exemple #9
0
from TodosViewModel import TodosViewModel
from SettingsViewModel import SettingsViewModel
from TodosListModel import TodosListModel

# App constants
MODULE_NAME = 'QtTodos'
MAJOR_VERSION = 0
MINOR_VERSION = 1

# Enable Ctrl-C to kill
signal.signal(signal.SIGINT, signal.SIG_DFL)

if __name__ == '__main__':
    # Create QML components from a Python classes
    # major_version and minor_version represent major and minor version numbers for when we import it in QML
    QtQml.qmlRegisterType(TodosViewModel, MODULE_NAME, MAJOR_VERSION,
                          MINOR_VERSION, 'TodosViewModel')
    QtQml.qmlRegisterType(SettingsViewModel, MODULE_NAME, MAJOR_VERSION,
                          MINOR_VERSION, 'SettingsViewModel')
    QtQml.qmlRegisterType(TodosListModel, MODULE_NAME, MAJOR_VERSION,
                          MINOR_VERSION, 'TodosListModel')

    # Use render loop that supports persistent 6major_versionfps
    os.environ['QSG_RENDER_LOOP'] = 'windows'

    # Create system app
    app = QtGui.QGuiApplication(sys.argv)

    # Initialize QML rendering engine
    engine = QtQml.QQmlApplicationEngine(parent=app)
    engine.load('main.qml')
Exemple #10
0
def register_qml_types():
    QtQml.qmlRegisterType(EngineModel, 'DeviceModels', 1, 0, 'EngineModel')
Exemple #11
0
# from PySide2.QtCore import QUrl, qDebug, QObject, Signal, Property, Slot
# from PySide2.QtGui import QGuiApplication, QOpenGLFramebufferObjectFormat, QOpenGLFramebufferObject
# from PySide2.QtQml import qmlRegisterType, QQmlApplicationEngine
# from PySide2.QtQuick import QQuickItem, QQuickView, QQuickFramebufferObject
# from PySide2.QtWidgets import QApplication

from PySide2 import QtCore, QtGui, QtQuick, QtQml
import squircle
import os, sys

if __name__ == '__main__':
    app = QtGui.QGuiApplication(sys.argv)

    QtQml.qmlRegisterType(squircle.Squircle, "OpenGLUnderQML", 1, 0,
                          "Squircle")

    view = QtQuick.QQuickView()
    view.setResizeMode(QtQuick.QQuickView.SizeRootObjectToView)
    view.setSource(QtCore.QUrl("resources//main2.qml"))
    view.show()

    sys.exit(app.exec_())
Exemple #12
0
            pos = invt * invt * invt * self._p1 + 3 * invt * invt * t * self._p2 + 3 * invt * t * t * self._p3 + t * t * t * self._p4
            x = pos.x() * itemSize.width()
            y = pos.y() * itemSize.height()
            verts[x].set(x, y)
        node.markDirty(QtQuick.QSGNode.DirtyGeometry)
        return node

    # Property
    p1 = QtCore.Property(QtCore.QPointF, p1, setP1, notify=p1Changed)
    p2 = QtCore.Property(QtCore.QPointF, p2, setP1, notify=p2Changed)
    p3 = QtCore.Property(QtCore.QPointF, p3, setP1, notify=p3Changed)
    p4 = QtCore.Property(QtCore.QPointF, p4, setP1, notify=p4Changed)
    segmentCount = QtCore.Property(int, segmentCount, setSegmentCount, notify=segmentCountChanged)


if __name__ == "__main__":
    app = QtWidgets.QApplication(sys.argv[1:])

    QtQml.qmlRegisterType(CurveItem, "CustomGeometry", 1, 0, 'BezierCurve')

    view = QtQuick.QQuickView()
    surface = view.format()
    surface.setSamples(16)
    view.setFormat(surface)

    view.engine().addImportPath(os.path.dirname(__file__))
    view.setSource('resource\\main2.qml')
    view.show()

    sys.exit(app.exec_())
Exemple #13
0
    # Use render loop that supports persistent 60fps
    os.environ['QSG_RENDER_LOOP'] = 'windows'

    # Create QML components from Python classes
    # major_version and minor_version represent major and minor version numbers for when we import it in QML
    from ApplicationViewModel import ApplicationViewModel
    from OnboardingViewModel import OnboardingViewModel
    from HistoryViewModel import HistoryViewModel
    from HistoryListModel import HistoryListModel
    from ProfileViewModel import ProfileViewModel
    from FriendsViewModel import FriendsViewModel
    from FriendsListModel import FriendsListModel
    from DetailsViewModel import DetailsViewModel
    from shared.components.NetworkImage import NetworkImage

    QtQml.qmlRegisterType(ApplicationViewModel, MODULE_NAME, MAJOR_VERSION,
                          MINOR_VERSION, 'ApplicationViewModel')
    QtQml.qmlRegisterType(OnboardingViewModel, MODULE_NAME, MAJOR_VERSION,
                          MINOR_VERSION, 'OnboardingViewModel')
    QtQml.qmlRegisterType(HistoryViewModel, MODULE_NAME, MAJOR_VERSION,
                          MINOR_VERSION, 'HistoryViewModel')
    QtQml.qmlRegisterType(HistoryListModel, MODULE_NAME, MAJOR_VERSION,
                          MINOR_VERSION, 'HistoryListModel')
    QtQml.qmlRegisterType(ProfileViewModel, MODULE_NAME, MAJOR_VERSION,
                          MINOR_VERSION, 'ProfileViewModel')
    QtQml.qmlRegisterType(FriendsViewModel, MODULE_NAME, MAJOR_VERSION,
                          MINOR_VERSION, 'FriendsViewModel')
    QtQml.qmlRegisterType(FriendsListModel, MODULE_NAME, MAJOR_VERSION,
                          MINOR_VERSION, 'FriendsListModel')
    QtQml.qmlRegisterType(DetailsViewModel, MODULE_NAME, MAJOR_VERSION,
                          MINOR_VERSION, 'DetailsViewModel')
    QtQml.qmlRegisterType(NetworkImage, MODULE_NAME, MAJOR_VERSION,
def register_qml_types():
    QtQml.qmlRegisterType(ScanConfigData, 'ScanTools', 1, 0, 'ScanConfigData')
    QtQml.qmlRegisterType(ScannerInterface, 'ScanTools', 1, 0,
                          'ScannerInterface')
Exemple #15
0
def register_qml_types():
    QtQml.qmlRegisterType(CameraPreview, 'DeviceModels', 1, 0, 'CameraPreview')
        test_rect.setTopLeft(rect.topLeft() +
                             QtCore.QPointF(rect.width() / 6,
                                            rect.height() / 6).toPoint())
        test_rect.setBottomRight(rect.bottomRight() -
                                 QtCore.QPointF(rect.width() / 6,
                                                rect.height() / 6).toPoint())
        pen = QtGui.QPen(QtGui.QBrush(QtCore.Qt.red), 2)
        painter.setPen(pen)
        painter.drawRoundRect(test_rect, 10)
        painter.drawRoundRect(rect, 10)
        painter.restore()


if __name__ == "__main__":
    app = QtGui.QGuiApplication(sys.argv[1:])
    QtQml.qmlRegisterType(QuickItem, "Demo", 1, 0, "PaintItem")
    # 类型不能小写开头,要和qml中的类似,大写开头
    # -------------------------------------------主体是window
    # engine = QtQml.QQmlApplicationEngine()
    # engine.addImportPath(os.path.dirname(__file__))
    # engine.load('resource\\main.qml')
    # --------------------------------------------------------
    view = QtQuick.QQuickView()
    # view 不支持window 作为root
    view.setResizeMode(QtQuick.QQuickView.SizeRootObjectToView)
    view.engine().addImportPath(os.path.dirname(__file__))
    view.setSource('resource\\main.qml')
    view.show()
    # ----------------------------------------------------------

    sys.exit(app.exec_())
Exemple #17
0
def register_qml_types():
    for cls in MODEL_CLASSES:
        QtQml.qmlRegisterType(cls, 'MidiModels', 1, 0, cls.__name__)
Exemple #18
0
def register_qml_types():
    QtQml.qmlRegisterType(PaletteManager, 'Palette', 1, 0, 'PaletteManager')