コード例 #1
0
    def __init__(self, parent=None):
        super(FilesHandler, self).__init__(None,
                                           Qt.FramelessWindowHint | Qt.Popup)
        self._main_container = parent
        self.setAttribute(Qt.WA_TranslucentBackground)
        self.setStyleSheet("background:transparent;")
        # Create the QML user interface.
        self.view = QDeclarativeView()
        self.view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
        self.view.setSource(ui_tools.get_qml_resource("FilesHandler.qml"))
        self._root = self.view.rootObject()
        vbox = QVBoxLayout(self)
        vbox.setContentsMargins(0, 0, 0, 0)
        vbox.setSpacing(0)
        vbox.addWidget(self.view)

        self._model = {}
        self._temp_files = {}
        self._max_index = 0

        self.connect(self._root, SIGNAL("open(QString, QString, QString)"),
                     self._open)
        self.connect(self._root, SIGNAL("close(QString, QString)"),
                     self._close)
        self.connect(self._root, SIGNAL("hide()"), self.hide)
        self.connect(self._root, SIGNAL("fuzzySearch(QString)"),
                     self._fuzzy_search)
コード例 #2
0
    def __init__(self, parent=None):
        super(StartPage, self).__init__(parent)
        self._id = "Start Page"
        vbox = QVBoxLayout(self)
        self.view = QDeclarativeView()
        self.view.setMinimumWidth(430)
        #self.view.setMinimumWidth(400)
        #self.view.setMinimumHeight(500)
        self.view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
        path_qml = QDir.fromNativeSeparators(
            os.path.join(resources.QML_FILES, "StartPage_Alexa.qml"))
            #os.path.join(resources.QML_FILES, "StartPage.qml"))
        path_qml = urlunparse(urlparse(path_qml)._replace(scheme='file'))
        self.view.setSource(QUrl(path_qml))
        self.root = self.view.rootObject()
        vbox.addWidget(self.view)

        self.load_items()

        self.connect(self.root, SIGNAL("openProject(QString)"),
            self._open_project)
        self.connect(self.root, SIGNAL("removeProject(QString)"),
            self._on_click_on_delete)
        self.connect(self.root, SIGNAL("markAsFavorite(QString, bool)"),
            self._on_click_on_favorite)
        self.connect(self.root, SIGNAL("openPreferences()"),
            lambda: self.emit(SIGNAL("openPreferences()")))
コード例 #3
0
    def __init__(self, parent=None):
        super(StartPage, self).__init__(parent)
        vbox = QVBoxLayout(self)
        vbox.setContentsMargins(0, 0, 0, 0)
        vbox.setSpacing(0)
        self.view = QDeclarativeView()
        self.view.setMinimumWidth(400)
        self.view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
        self.view.setSource(ui_tools.get_qml_resource("StartPage.qml"))
        self.root = self.view.rootObject()
        vbox.addWidget(self.view)

        self.load_items()

        self.connect(self.root, SIGNAL("openProject(QString)"),
            self._open_project)
        self.connect(self.root, SIGNAL("removeProject(QString)"),
            self._on_click_on_delete)
        self.connect(self.root, SIGNAL("markAsFavorite(QString, bool)"),
            self._on_click_on_favorite)
        self.connect(self.root, SIGNAL("openPreferences()"),
            lambda: self.emit(SIGNAL("openPreferences()")))
        self.connect(self.root, SIGNAL("newFile()"),
            lambda: self.emit(SIGNAL("newFile()")))

        self.root.set_year(str(datetime.datetime.now().year))
コード例 #4
0
ファイル: FingerPing.py プロジェクト: inblueswithu/Ping
def main():
    # Main function to be executed while running the program

    # Generate QML View
    app = QApplication(sys.argv)
    view = QDeclarativeView()
    view.setSource(QUrl('Fingers.qml'))
    view.setResizeMode(QDeclarativeView.SizeRootObjectToView)

    # Get Root Object for communication
    global rootObject
    rootObject = view.rootObject()
        
    # Connect to start Leap signal
    rootObject.qmlStarted.connect(startLeap)
    
    # Connect to stop Leap signal
    rootObject.qmlStop.connect(stopLeap)
    
    # Display the component
    import subprocess
    output = subprocess.Popen('xrandr | grep "\*" | cut -d" " -f4',shell=True, stdout=subprocess.PIPE).communicate()[0]
    output = output[:-1]
    screenX = output[:output.index('x')]
    screenY = output[output.index('x')+1:]
    
    view.setGeometry(100, 100, int(screenX), int(screenY))
    view.show()
    app.exec_()
コード例 #5
0
ファイル: launchqmlnb.py プロジェクト: Armagedoom/leo-editor
def create_dv():
    # Create the QML user interface.
    view = QDeclarativeView()
    view.setSource(QUrl('qml/leonbmain.qml'))
    view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
    # Display the user interface and allow the user to interact with it.
    view.setGeometry(100, 100, 400, 240)
    view.show()
    
    rootObject = view.rootObject()
    return view
コード例 #6
0
ファイル: notifier.py プロジェクト: diegosarmentero/jarvis
 def __init__(self):
     super(Notification, self).__init__()
     self.setAttribute(Qt.WA_TranslucentBackground)
     self.setStyleSheet("background:transparent;")
     self.setWindowFlags(Qt.FramelessWindowHint)
     self.setMinimumHeight(120)
     # Create the QML user interface.
     view = QDeclarativeView()
     view.setSource(QUrl('Bubble.qml'))
     view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
     vbox = QVBoxLayout(self)
     vbox.addWidget(view)
コード例 #7
0
ファイル: files_handler.py プロジェクト: AnyBucket/ninja-ide
    def __init__(self, parent=None):
        super(FilesHandler, self).__init__(
            None, Qt.FramelessWindowHint | Qt.Popup)
        self._main_container = parent
        self.setAttribute(Qt.WA_TranslucentBackground)
        self.setStyleSheet("background:transparent;")
        # Create the QML user interface.
        self.view = QDeclarativeView()
        self.view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
        self.view.setSource(ui_tools.get_qml_resource("FilesHandler.qml"))
        self._root = self.view.rootObject()
        vbox = QVBoxLayout(self)
        vbox.setContentsMargins(0, 0, 0, 0)
        vbox.setSpacing(0)
        vbox.addWidget(self.view)

        self._model = {}
        self._temp_files = {}
        self._max_index = 0

        self.connect(self._root, SIGNAL("open(QString, QString, QString)"),
                     self._open)
        self.connect(self._root, SIGNAL("close(QString, QString)"), self._close)
        self.connect(self._root, SIGNAL("hide()"), self.hide)
        self.connect(self._root, SIGNAL("fuzzySearch(QString)"),
                     self._fuzzy_search)
コード例 #8
0
    def __init__(self, c):

        self.c = c
        self.gnxcache = {}

        self.mw = ModelWrapper(["h", "b", "gnx", "level", "style"])

        #self.add_all_nodes()
        #self.add_subtree(p)
        c._view = view = QDeclarativeView()
        ctx = view.rootContext()

        @g.command("nb-all")
        def nb_all_f(event):
            self.add_all_nodes()

        @g.command("nb-subtree")
        def nb_subtree_f(event):
            p = self.c.p
            self.add_subtree(p)

        ctx.setContextProperty("nodesModel", self.mw.model)

        path = g.os_path_join(g.computeLeoDir(), 'plugins', 'qmlnb', 'qml',
                              'leonbmain.qml')
        view.setSource(QUrl(path))
        view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
        # Display the user interface and allow the user to interact with it.
        view.setGeometry(100, 100, 800, 600)
        view.show()

        c.dummy = view
コード例 #9
0
    def __init__(self, parent=None):
        super(PluginsStore, self).__init__(parent, Qt.Dialog)
        self.setWindowTitle(translations.TR_MANAGE_PLUGINS)
        vbox = QVBoxLayout(self)
        vbox.setContentsMargins(0, 0, 0, 0)
        vbox.setSpacing(0)
        self.view = QDeclarativeView()
        self.view.setMinimumWidth(800)
        self.view.setMinimumHeight(600)
        self.view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
        self.view.setSource(ui_tools.get_qml_resource("PluginsStore.qml"))
        self.root = self.view.rootObject()
        vbox.addWidget(self.view)
        self._plugins = {}
        self._plugins_inflate = []
        self._plugins_by_tag = collections.defaultdict(list)
        self._plugins_by_author = collections.defaultdict(list)
        self._base_color = QColor("white")
        self._counter = 0
        self._counter_callback = None
        self._inflating_plugins = []
        self._categoryTags = True
        self._search = []
        self.status = None

        self.connect(self.root, SIGNAL("loadPluginsGrid()"),
                     self._load_by_name)
        self.connect(self.root, SIGNAL("showPluginDetails(int)"),
                     self.show_plugin_details)
        self.connect(self.root, SIGNAL("loadTagsGrid()"),
                     self._load_tags_grid)
        self.connect(self.root, SIGNAL("loadAuthorGrid()"),
                     self._load_author_grid)
        self.connect(self.root, SIGNAL("search(QString)"),
                     self._load_search_results)
        self.connect(self.root, SIGNAL("loadPluginsForCategory(QString)"),
                     self._load_plugins_for_category)
        self.connect(self, SIGNAL("processCompleted(PyQt_PyObject)"),
                     self._process_complete)

        self.nenv = nenvironment.NenvEggSearcher()
        self.connect(self.nenv,
                     SIGNAL("searchCompleted(PyQt_PyObject)"),
                     self.callback)
        self.status = self.nenv.do_search()
コード例 #10
0
ファイル: start_page.py プロジェクト: ekimdev/edis
 def __init__(self):
     QWidget.__init__(self)
     box = QVBoxLayout(self)
     box.setContentsMargins(0, 0, 0, 0)
     view = QDeclarativeView()
     view.setMinimumSize(400, 400)
     view.setSource(QUrl("src/ui/StartPage.qml"))
     view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
     box.addWidget(view)
コード例 #11
0
    def __init__(self, parent=None):
        super(LocatorWidget, self).__init__(parent,
                                            Qt.Dialog | Qt.FramelessWindowHint)
        self._parent = parent
        self.setModal(True)
        self.setAttribute(Qt.WA_TranslucentBackground)
        self.setStyleSheet("background:transparent;")
        self.setFixedHeight(400)
        self.setFixedWidth(500)
        # Create the QML user interface.
        view = QDeclarativeView()
        view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
        view.setSource(ui_tools.get_qml_resource("Locator.qml"))
        self._root = view.rootObject()
        vbox = QVBoxLayout(self)
        vbox.setContentsMargins(0, 0, 0, 0)
        vbox.setSpacing(0)
        vbox.addWidget(view)

        self.locate_symbols = locator.LocateSymbolsThread()
        self.connect(self.locate_symbols, SIGNAL("finished()"), self._cleanup)
        self.connect(self.locate_symbols, SIGNAL("terminated()"),
                     self._cleanup)

        # Locator things
        self.filterPrefix = re.compile(r'(@|<|>|-|!|\.|/|:)')
        self.page_items_step = 10
        self._colors = {
            "@": "white",
            "<": "#18ff6a",
            ">": "red",
            "-": "#18e1ff",
            ".": "#f118ff",
            "/": "#fff118",
            ":": "#18ffd6",
            "!": "#ffa018"
        }
        self._filters_list = [("@", "Filename"), ("<", "Class"),
                              (">", "Function"), ("-", "Attribute"),
                              (".", "Current"), ("/", "Opened"), (":", "Line"),
                              ("!", "NoPython")]
        self._replace_symbol_type = {"<": "&lt;", ">": "&gt;"}
        self.reset_values()

        self._filter_actions = {
            '.': self._filter_this_file,
            '/': self._filter_tabs,
            ':': self._filter_lines
        }

        self.connect(self._root, SIGNAL("textChanged(QString)"),
                     self.set_prefix)
        self.connect(self._root, SIGNAL("open(QString, int)"), self._open_item)
        self.connect(self._root, SIGNAL("fetchMore()"), self._fetch_more)
コード例 #12
0
ファイル: start_page.py プロジェクト: yoshitomimaehara/edis
    def __init__(self):
        QWidget.__init__(self)
        box = QVBoxLayout(self)
        box.setContentsMargins(0, 0, 0, 0)
        view = QDeclarativeView()
        view.setMinimumSize(400, 400)
        qml = os.path.join(paths.PATH, "ui", "StartPage.qml")
        path = QDir.fromNativeSeparators(qml)
        view.setSource(QUrl.fromLocalFile(path))
        view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
        self._root = view.rootObject()
        box.addWidget(view)

        self._current_text = ""
        # Timer
        self.timer = QTimer(self)
        self.timer.setInterval(3000)
        self._show_welcome_text()
        self.timer.timeout.connect(self._show_text)
        self.timer.start()
コード例 #13
0
    def __init__(self, parent=None):
        super(AddFileFolderWidget,
              self).__init__(parent, Qt.Dialog | Qt.FramelessWindowHint)
        self._main_container = parent
        self.setModal(True)
        self.setAttribute(Qt.WA_TranslucentBackground)
        self.setStyleSheet("background:transparent;")
        self.setFixedHeight(70)
        self.setFixedWidth(650)
        # Create the QML user interface.
        self.view = QDeclarativeView()
        self.view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
        self.view.setSource(ui_tools.get_qml_resource("AddFileFolder.qml"))
        self._root = self.view.rootObject()
        vbox = QVBoxLayout(self)
        vbox.setContentsMargins(0, 0, 0, 0)
        vbox.setSpacing(0)
        vbox.addWidget(self.view)

        self._base_path = ""

        self._create_file_operation = True

        self.connect(self._root, SIGNAL("create(QString)"), self._create)
コード例 #14
0
ファイル: plugins_store.py プロジェクト: AnyBucket/ninja-ide
    def __init__(self, parent=None):
        super(PluginsStore, self).__init__(parent, Qt.Dialog)
        self.setWindowTitle(translations.TR_MANAGE_PLUGINS)
        vbox = QVBoxLayout(self)
        vbox.setContentsMargins(0, 0, 0, 0)
        vbox.setSpacing(0)
        self.view = QDeclarativeView()
        self.view.setMinimumWidth(800)
        self.view.setMinimumHeight(600)
        self.view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
        self.view.setSource(ui_tools.get_qml_resource("PluginsStore.qml"))
        self.root = self.view.rootObject()
        vbox.addWidget(self.view)
        self._plugins = {}
        self._plugins_inflate = []
        self._plugins_by_tag = collections.defaultdict(list)
        self._plugins_by_author = collections.defaultdict(list)
        self._base_color = QColor("white")
        self._counter = 0
        self._counter_callback = None
        self._inflating_plugins = []
        self._categoryTags = True
        self._search = []
        self.status = None

        self.connect(self.root, SIGNAL("loadPluginsGrid()"),
                     self._load_by_name)
        self.connect(self.root, SIGNAL("close()"),
                     self.close)
        self.connect(self.root, SIGNAL("showPluginDetails(int)"),
                     self.show_plugin_details)
        self.connect(self.root, SIGNAL("loadTagsGrid()"),
                     self._load_tags_grid)
        self.connect(self.root, SIGNAL("loadAuthorGrid()"),
                     self._load_author_grid)
        self.connect(self.root, SIGNAL("search(QString)"),
                     self._load_search_results)
        self.connect(self.root, SIGNAL("loadPluginsForCategory(QString)"),
                     self._load_plugins_for_category)
        self.connect(self, SIGNAL("processCompleted(PyQt_PyObject)"),
                     self._process_complete)

        self.nenv = nenvironment.NenvEggSearcher()
        self.connect(self.nenv,
                     SIGNAL("searchCompleted(PyQt_PyObject)"),
                     self.callback)
        self.status = self.nenv.do_search()
コード例 #15
0
ファイル: start_page.py プロジェクト: papablopo07/pireal
 def __init__(self):
     super(StartPage, self).__init__()
     vbox = QVBoxLayout(self)
     vbox.setContentsMargins(0, 0, 0, 0)
     view = QDeclarativeView()
     qml = os.path.join(os.path.dirname(__file__), "StartPage.qml")
     path = QDir.fromNativeSeparators(qml)
     view.setSource(QUrl.fromLocalFile(path))
     view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
     self._root = view.rootObject()
     vbox.addWidget(view)
コード例 #16
0
 def __init__(self, parent=None):
     super(SplitOrientation,
           self).__init__(parent, Qt.Dialog | Qt.FramelessWindowHint)
     self.setModal(True)
     self.setAttribute(Qt.WA_TranslucentBackground)
     self.setStyleSheet("background:transparent;")
     self.setFixedHeight(180)
     self.setFixedWidth(315)
     # Create the QML user interface.
     view = QDeclarativeView()
     view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
     view.setSource(ui_tools.get_qml_resource("SplitOrientation.qml"))
     self._root = view.rootObject()
     vbox = QVBoxLayout(self)
     vbox.addWidget(view)
コード例 #17
0
    def __init__(self, parent=None):
        super(MainSelector, self).__init__(parent)
        # Create the QML user interface.
        view = QDeclarativeView()
        view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
        view.setSource(ui_tools.get_qml_resource("MainSelector.qml"))
        self._root = view.rootObject()
        vbox = QVBoxLayout(self)
        vbox.setContentsMargins(0, 0, 0, 0)
        vbox.setSpacing(0)
        vbox.addWidget(view)

        self.connect(self._root, SIGNAL("open(int)"),
                     lambda i: self.emit(SIGNAL("changeCurrent(int)"), i))
        self.connect(self._root, SIGNAL("ready()"),
                     lambda: self.emit(SIGNAL("ready()")))
コード例 #18
0
ファイル: plugins_store.py プロジェクト: JuloWaks/ninja-ide
    def __init__(self, parent=None):
        super(PluginsStore, self).__init__(parent, Qt.Dialog)
        vbox = QVBoxLayout(self)
        vbox.setContentsMargins(0, 0, 0, 0)
        vbox.setSpacing(0)
        self.view = QDeclarativeView()
        self.view.setMinimumWidth(800)
        self.view.setMinimumHeight(600)
        self.view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
        self.view.setSource(ui_tools.get_qml_resource("PluginsStore.qml"))
        self.root = self.view.rootObject()
        vbox.addWidget(self.view)

        self.nenv = nenvironment.NenvEggSearcher()
        self.connect(self.nenv, SIGNAL("searchCompleted(PyQt_PyObject)"),
            self.callback)

        self.status = self.nenv.do_search()
コード例 #19
0
ファイル: start_page.py プロジェクト: Garjy/edis
    def __init__(self):
        QWidget.__init__(self)
        box = QVBoxLayout(self)
        box.setContentsMargins(0, 0, 0, 0)
        view = QDeclarativeView()
        view.setMinimumSize(400, 400)
        qml = os.path.join(paths.PATH, "ui", "StartPage.qml")
        path = QDir.fromNativeSeparators(qml)
        view.setSource(QUrl.fromLocalFile(path))
        view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
        self._root = view.rootObject()
        box.addWidget(view)

        self._current_text = ""
        # Timer
        self.timer = QTimer(self)
        self.timer.setInterval(3000)
        self._show_welcome_text()
        self.timer.timeout.connect(self._show_text)
        self.timer.start()
コード例 #20
0
ファイル: server.py プロジェクト: fmfi-svt/infoboard
    def __init__(self, schedule_dir):
        self.schedule_dir = schedule_dir
        self.videos = {}
        self.playlist = []

        self.app = QApplication(sys.argv)

        self.view = QDeclarativeView()
        self.view.setSource(QUrl('scene.qml'))
        self.view.setResizeMode(QDeclarativeView.SizeRootObjectToView)

        self.viewRoot = self.view.rootObject()
        self.viewRoot.quit.connect(self.app.quit)
        self.viewRoot.finished.connect(self.show_next)

        self.view.setGeometry(100, 100, 400, 240)
        self.view.showFullScreen()

        self.watcher = QFileSystemWatcher()
コード例 #21
0
ファイル: split_orientation.py プロジェクト: Hmaal/ninja-ide
 def __init__(self, parent=None):
     super(SplitOrientation, self).__init__(parent,
         Qt.Dialog | Qt.FramelessWindowHint)
     self.setModal(True)
     self.setAttribute(Qt.WA_TranslucentBackground)
     self.setStyleSheet("background:transparent;")
     self.setFixedHeight(150)
     self.setFixedWidth(310)
     # Create the QML user interface.
     view = QDeclarativeView()
     view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
     view.setSource(ui_tools.get_qml_resource("SplitOrientation.qml"))
     self._root = view.rootObject()
     vbox = QVBoxLayout(self)
     vbox.addWidget(view)
コード例 #22
0
    def __init__(self, parent=None):
        super(Notification, self).__init__(None, Qt.ToolTip)
        self._parent = parent
        self._duration = 3000
        self.setAttribute(Qt.WA_TranslucentBackground)
        self.setAttribute(Qt.WA_TransparentForMouseEvents)
        self.setAttribute(Qt.WA_ShowWithoutActivating)
        self.setStyleSheet("background:transparent;")
        self.setWindowFlags(Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint)
        self.setFixedHeight(60)
        # Create the QML user interface.
        view = QDeclarativeView()
        view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
        view.setSource(ui_tools.get_qml_resource("Notification.qml"))
        self._root = view.rootObject()
        vbox = QVBoxLayout(self)
        vbox.addWidget(view)

        self.connect(self._root, SIGNAL("close()"), self.close)
コード例 #23
0
ファイル: main_selector.py プロジェクト: JuloWaks/ninja-ide
    def __init__(self, parent=None):
        super(MainSelector, self).__init__(parent)
        # Create the QML user interface.
        view = QDeclarativeView()
        view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
        view.setSource(ui_tools.get_qml_resource("MainSelector.qml"))
        self._root = view.rootObject()
        vbox = QVBoxLayout(self)
        vbox.setContentsMargins(0, 0, 0, 0)
        vbox.setSpacing(0)
        vbox.addWidget(view)

        self.connect(self._root, SIGNAL("open(int)"),
            lambda i: self.emit(SIGNAL("changeCurrent(int)"), i))
        self.connect(self._root, SIGNAL("ready()"),
            lambda: self.emit(SIGNAL("ready()")))
コード例 #24
0
    def __init__(self, parent=None):
        super(SplitOrientation,
              self).__init__(parent, Qt.Dialog | Qt.FramelessWindowHint)
        self._operations = {'row': False, 'col': True}
        self.setModal(True)
        self.setAttribute(Qt.WA_TranslucentBackground)
        self.setStyleSheet("background:transparent;")
        self.setFixedHeight(150)
        self.setFixedWidth(290)
        # Create the QML user interface.
        view = QDeclarativeView()
        view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
        view.setSource(ui_tools.get_qml_resource("SplitOrientation.qml"))
        self._root = view.rootObject()
        vbox = QVBoxLayout(self)
        vbox.setContentsMargins(0, 0, 0, 0)
        vbox.setSpacing(0)
        vbox.addWidget(view)

        self.connect(self._root, SIGNAL("selected(QString)"),
                     self._split_operation)
コード例 #25
0
    def __init__(self, parent=None):
        super(AddFileFolderWidget, self).__init__(
            parent, Qt.Dialog | Qt.FramelessWindowHint)
        self._main_container = parent
        self.setModal(True)
        self.setAttribute(Qt.WA_TranslucentBackground)
        self.setStyleSheet("background:transparent;")
        self.setFixedHeight(70)
        self.setFixedWidth(650)
        # Create the QML user interface.
        self.view = QDeclarativeView()
        self.view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
        self.view.setSource(ui_tools.get_qml_resource("AddFileFolder.qml"))
        self._root = self.view.rootObject()
        vbox = QVBoxLayout(self)
        vbox.setContentsMargins(0, 0, 0, 0)
        vbox.setSpacing(0)
        vbox.addWidget(self.view)

        self._base_path = ""

        self._create_file_operation = True

        self.connect(self._root, SIGNAL("create(QString)"), self._create)
コード例 #26
0
ファイル: notification.py プロジェクト: Zekom/ninja-ide
    def __init__(self, parent=None):
        super(Notification, self).__init__(None, Qt.ToolTip)
        self._parent = parent
        self._duration = 3000
        self.setAttribute(Qt.WA_TranslucentBackground)
        self.setAttribute(Qt.WA_TransparentForMouseEvents)
        self.setAttribute(Qt.WA_ShowWithoutActivating)
        self.setStyleSheet("background:transparent;")
        self.setWindowFlags(Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint)
        self.setFixedHeight(30)
        # Create the QML user interface.
        view = QDeclarativeView()
        view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
        view.setSource(ui_tools.get_qml_resource("Notification.qml"))
        self._root = view.rootObject()
        vbox = QVBoxLayout(self)
        vbox.addWidget(view)

        self.connect(self._root, SIGNAL("close()"), self.close)
コード例 #27
0
    def __init__(self, parent=None):
        super(SplitOrientation, self).__init__(parent, Qt.Dialog | Qt.FramelessWindowHint)
        self._operations = {"row": False, "col": True}
        self.setModal(True)
        self.setAttribute(Qt.WA_TranslucentBackground)
        self.setStyleSheet("background:transparent;")
        self.setFixedHeight(130)
        self.setFixedWidth(290)
        # Create the QML user interface.
        view = QDeclarativeView()
        view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
        view.setSource(ui_tools.get_qml_resource("SplitOrientation.qml"))
        self._root = view.rootObject()
        vbox = QVBoxLayout(self)
        vbox.setContentsMargins(0, 0, 0, 0)
        vbox.setSpacing(0)
        vbox.addWidget(view)

        self.connect(self._root, SIGNAL("selected(QString)"), self._split_operation)
コード例 #28
0
ファイル: selector.py プロジェクト: ekimdev/edis
    def __init__(self, parent=None):
        super(Selector, self).__init__(parent,
                                       Qt.Dialog | Qt.FramelessWindowHint)
        # Configuración
        self.setModal(True)

        box = QVBoxLayout(self)
        box.setContentsMargins(0, 0, 1, 1)
        box.setSpacing(0)
        # Interfáz QML
        view = QDeclarativeView()
        qml = os.path.join(paths.PATH, "ui", "selector", "selector.qml")
        path = QDir.fromNativeSeparators(qml)
        view.setSource(QUrl.fromLocalFile(path))

        view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
        box.addWidget(view)

        self.root = view.rootObject()
        self.__cargar()

        self.connect(self.root, SIGNAL("abrirArchivo(int)"),
                     self.__abrir_archivo)
コード例 #29
0
def create_dv():
    # Create the QML user interface.
    view = QDeclarativeView()
    view.setSource(QUrl('qml/leonbmain.qml'))
    view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
    # Display the user interface and allow the user to interact with it.
    view.setGeometry(100, 100, 400, 240)
    view.show()

    rootObject = view.rootObject()
    return view
コード例 #30
0
ファイル: jabber.py プロジェクト: shashankv02/xmppautomater
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtDeclarative import QDeclarativeView
import sys

app = QApplication(sys.argv)
view = QDeclarativeView()
view.setSource(QUrl('login.qml'))
view.show()
app.exec_()
コード例 #31
0

# Import popen to execute shell commands,
# path for working with standard paths
# ConfigParser for config handling
# and time for time and date handling
from os import popen, path, remove
#import ConfigParser, time
home = path.expanduser("~")

app = QApplication(sys.argv)
app.setGraphicsSystem("raster")
app.setWindowIcon(QIcon('qml/img/encode.png'))

# Create the QML user interface.
view = QDeclarativeView()
# Use PlasmaComponents
engine = view.engine()
engine.addImportPath("/usr/lib/kde4/imports")
# Set main qml here
view.setSource(QUrl("3ncode.qml"))
view.setResizeMode(QDeclarativeView.SizeRootObjectToView)

# Get the root object of the user interface.
rootObject = view.rootObject()

# Check for parameters
if len(sys.argv) > 1:
    openF(str(sys.argv[1]).decode('utf-8'))

# Connect QML signals with Python functions
コード例 #32
0
ファイル: symulator.py プロジェクト: mazakodron/symulator
  def run(self):
    app = QApplication(sys.argv)
    imageProvider = ImageProvider()

    # Create the QML user interface.
    view = QDeclarativeView()
    
    view.setResizeMode(QDeclarativeView.SizeRootObjectToView)

    engine = view.engine()
    
    engine.addImageProvider("mazakodron", imageProvider)
    
    view.setSource(QUrl('symulator/mazakodron.qml'))
    rootObject = view.rootObject()
    if not rootObject:
      view.setSource(QUrl('mazakodron.qml'))
      rootObject = view.rootObject()
    
    rootObject.requestDraw.connect(imageProvider.draw)
    
    self.rootObject = rootObject

    view.setGeometry(0, 0, 800, 600)
    view.show()

    timer = QTimer()
    timer.start(1000/60) # 60FPS
    timer.timeout.connect(self.process)

    sys.exit(app.exec_());
コード例 #33
0
ファイル: start_page.py プロジェクト: belug23/ninja-ide
class StartPage(QWidget, itab_item.ITabItem):
    def __init__(self, parent=None):
        super(StartPage, self).__init__(parent)
        self._id = "Start Page"
        vbox = QVBoxLayout(self)
        self.view = QDeclarativeView()
        self.view.setMinimumWidth(400)
        self.view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
        path_qml = os.path.join(resources.QML_FILES, "StartPage.qml")
        self.view.setSource(QUrl(path_qml))
        self.root = self.view.rootObject()
        vbox.addWidget(self.view)

        self.load_items()

        self.connect(self.root, SIGNAL("openProject(QString)"),
                     self._open_project)
        self.connect(self.root, SIGNAL("removeProject(QString)"),
                     self._on_click_on_delete)
        self.connect(self.root, SIGNAL("markAsFavorite(QString, bool)"),
                     self._on_click_on_favorite)
        self.connect(self.root, SIGNAL("openPreferences()"),
                     lambda: self.emit(SIGNAL("openPreferences()")))

    def _open_project(self, path):
        self.emit(SIGNAL("openProject(QString)"), path)

    def _on_click_on_delete(self, path):
        settings = QSettings()
        recent_projects = settings.value("recentProjects")
        if path in recent_projects:
            del recent_projects[path]
            settings.setValue("recentProjects", recent_projects)

    def _on_click_on_favorite(self, path, value):
        settings = QSettings()
        recent_projects = settings.value("recentProjects")
        properties = recent_projects[path]
        properties["isFavorite"] = value
        recent_projects[path] = properties
        settings.setValue("recentProjects", recent_projects)

    def load_items(self):
        settings = QSettings()
        listByFavorites = []
        listNoneFavorites = []
        recent_projects_dict = dict(settings.value('recentProjects', {}))
        #Filter for favorites
        for recent_project_path, content in list(recent_projects_dict.items()):
            if bool(dict(content)["isFavorite"]):
                listByFavorites.append(
                    (recent_project_path, content["lastopen"]))
            else:
                listNoneFavorites.append(
                    (recent_project_path, content["lastopen"]))
        if len(listByFavorites) > 1:
            # sort by date favorites
            listByFavorites = sorted(listByFavorites,
                                     key=lambda date: listByFavorites[1])

        if len(listNoneFavorites) > 1:
            #sort by date last used
            listNoneFavorites = sorted(listNoneFavorites,
                                       key=lambda date: listNoneFavorites[1])

        for recent_project_path in listByFavorites:
            path = recent_project_path[0]
            name = recent_projects_dict[path]['name']
            self.root.add_project(name, path, True)

        for recent_project_path in listNoneFavorites:
            path = recent_project_path[0]
            name = recent_projects_dict[path]['name']
            self.root.add_project(name, path, False)
コード例 #34
0
ファイル: ubezee.py プロジェクト: kurokid/Ubezee
def main():
	os.chdir(sys.path[0])
	app = QApplication(sys.argv)
	canvas = QDeclarativeView()
	canvas.setFixedSize(360, 500)
	canvas.setWindowTitle('Ubezee - Lock Your System')
	icon = QIcon()
	icon.addPixmap(QPixmap('qml/images/UbezeeIcon.png'), QIcon.Normal, QIcon.Off)
	canvas.setWindowIcon(QIcon(icon)) 
	qr = canvas.frameGeometry()
	cp = QDesktopWidget().availableGeometry().center()
	qr.moveCenter(cp)
	canvas.move(qr.topLeft())
	engine = canvas.engine()

	element = MyElement()
	
	engine.rootContext().setContextObject(element)
	canvas.setSource(QUrl.fromLocalFile('qml/Ubezee.qml'))
	engine.quit.connect(app.quit)
	canvas.setResizeMode(QDeclarativeView.SizeRootObjectToView)
	canvas.show()
	sys.exit(app.exec_())
コード例 #35
0
ファイル: sleeptimer.py プロジェクト: Acer54/Webradio_v2
class SleepTimer(QWidget):
    '''
    A resizable Widget with two Spinboxes Labeled with "h" and "min", also a Time-bomb containing a countdownclock.
    If a spinbox is changed, start is triggered. After 2 Seconds, countdown is startet.
    When countdown ends, signal "sleepTimerelapsed()" is emitted.
    '''
    sleepTimerelapsed = pyqtSignal()
    sleepTimertenseconds = pyqtSignal()

    def __init__(self, parent=None):
        super(SleepTimer, self).__init__(parent)
        self.forceSpinBoxWidget = global_vars.configuration.get("GENERAL").get("sleeptimerdigitalspinbox")
        self.setStyleSheet("SleepTimer {"
                            "background-color: rgb(76, 76, 76);"
                            "color: rgb(240, 240, 240);"
                            "}"
                           "QLabel {"
                           "color: white;"
                           "}"
                           "QSpinBox {"
                           "padding-right: 10px; /* make room for the arrows */"
                           "border-width: 3;"
                           "}"
                           "QSpinBox::up-button {"
                           "width: 26px;"
                            "}"
                           "QSpinBox::down-button {"
                           "width: 26px;"
                            "}"
                            )
        self.value = 0 # the value is calculated in self.active (calculated seconds in total)
        self.isActive = False

        if self.forceSpinBoxWidget:
            self.sb_hours = LeadingZeroSpinBox()
            self.sb_hours.setRange(0,23)
            self.sb_hours.setAlignment(Qt.AlignCenter)
            self.sb_hours.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        else:
            self.sb_hours = QDeclarativeView()
            self.sb_hours.setSource(QUrl(os.path.join(cwd,'sb_hours.qml')))
            self.sb_hours.setResizeMode(QDeclarativeView.SizeViewToRootObject)
            self.sb_hours.setStyleSheet("background:transparent;")
            self.sb_hours.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)

            self.sb_hours_obj = self.sb_hours.rootObject().findChild(QObject, "spinner")
            self.sb_hours_value = QDeclarativeProperty(self.sb_hours.rootObject().findChild(QDeclarativeItem, name="spinner"),"currentIndex")

        if self.forceSpinBoxWidget:
            self.sb_minutes = LeadingZeroSpinBox()
            self.sb_minutes.setRange(0,59)
            self.sb_minutes.setAlignment(Qt.AlignCenter)
            self.sb_minutes.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        else:
            self.sb_minutes = QDeclarativeView()
            self.sb_minutes.setSource(QUrl(os.path.join(cwd,'sb_minutes.qml')))
            self.sb_minutes.setResizeMode(QDeclarativeView.SizeViewToRootObject)
            self.sb_minutes.setStyleSheet("background:transparent;")
            self.sb_minutes.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)

            self.sb_minutes_obj = self.sb_minutes.rootObject().findChild(QObject, "spinner")
            self.sb_minutes_value = QDeclarativeProperty(self.sb_minutes.rootObject().findChild(QDeclarativeItem, name="spinner"),"currentIndex")



        tmpFont = QFont()
        tmpFont.setPointSize(18)
        self.lbl_hours = QLabel(QString("h"))
        self.lbl_hours.setFont(tmpFont)
        self.lbl_minutes = QLabel(QString("min"))
        self.lbl_minutes.setFont(tmpFont)

        # Load QML Widget Bomb
        self.bomb = QDeclarativeView()
        self.bomb.setSource(QUrl(os.path.join(cwd,'timebomb.qml')))
        self.bomb.setResizeMode(QDeclarativeView.SizeViewToRootObject)
        #self.bomb.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.bomb.setStyleSheet("background:transparent;")
        self.bomb_text = QDeclarativeProperty(self.bomb.rootObject().findChild(QDeclarativeItem, name="counter_text"),"text")

        #setup layouts
        tmpLayout = QHBoxLayout()
        tmpLayout.addSpacerItem(QSpacerItem(40, 40, QSizePolicy.Expanding))
        tmpLayout.addWidget(self.sb_hours)
        tmpLayout.addWidget(self.lbl_hours)
        tmpLayout.addWidget(self.sb_minutes)
        tmpLayout.addWidget(self.lbl_minutes)
        tmpLayout.addSpacerItem(QSpacerItem(40, 40, QSizePolicy.Expanding))

        tmp2Layout = QVBoxLayout()
        tmp2Layout.addLayout(tmpLayout)
        tmp2Layout.addWidget(self.bomb)
        tmp2Layout.addSpacerItem(QSpacerItem(40, 40, QSizePolicy.Expanding))

        self.setLayout(tmp2Layout)
        self.blockValueSignal = False  # if this is true, valueChanged signal is not evaluated
        if self.forceSpinBoxWidget:
            self.sb_hours.valueChanged.connect(self.onValueChanged)
            self.sb_minutes.valueChanged.connect(self.onValueChanged)
        else:
            self.sb_hours_obj.currentIndexChanged.connect(self.onValueChanged)
            self.sb_minutes_obj.currentIndexChanged.connect(self.onValueChanged)


        # setup Timer which is started as soon as a value is changed in any of the spinboxes
        self.timer = QTimer()
        self.timer.setSingleShot(True)
        self.timer.setInterval(2000)  # 2 seconds until timer starts automatically
        self.connect(self.timer, SIGNAL("timeout()"), self.activate)

        #setup Timer which is a second-timer. It is startet with the self.timer (see self.active)
        self.countDown = QTimer()
        self.countDown.setInterval(1000) #sec
        self.connect(self.countDown, SIGNAL("timeout()"), self.check)

    def onValueChanged(self):

        if self.forceSpinBoxWidget:
            value_sb_hours = self.sb_hours.value()
            value_sb_minutes = self.sb_minutes.value()
        else:
            value_sb_hours = self.sb_hours_value.read().toInt()[0]
            value_sb_minutes = self.sb_minutes_value.read().toInt()[0]

        if self.blockValueSignal:
            return

        if value_sb_hours == 0 and value_sb_minutes == 0:
            print("Stop Timer")
            self.bomb_text.write("Abbruch")
            self.timer.stop()
            self.countDown.stop()
            self.isActive = False
            return

        if self.countDown.isActive():
            self.countDown.stop()

        if self.timer.isActive():
            self.timer.stop()
            self.timer.start()
        else:
            self.timer.start()

    def activate(self):
        #print("Activated")
        self.isActive = True
        self.countDown.start()
        if self.forceSpinBoxWidget:
            self.value = self.sb_hours.value() * 60 * 60 + self.sb_minutes.value() * 60
        else:
            self.value = self.sb_hours_value.read().toInt()[0] * 60 * 60 + self.sb_minutes_value.read().toInt()[0] * 60

    def check(self):
        #print("check")
        self.value -= 1
        if self.value == 0:
            #print("Der Timer ist abgelaufen")
            self.bomb_text.write(" Boom!")
            self.sleepTimerelapsed.emit()
            self.countDown.stop()
            self.isActive = False
        elif self.value == 10:
            self.sleepTimertenseconds.emit()
        else:
            m, s = divmod(self.value, 60)
            h, m = divmod(m, 60)
            text = "%02d:%02d:%02d" % (h, m, s)
            #self.lbl_countdown.setText(text)
            self.bomb_text.write(text)
            self.blockValueSignal = True
            if self.forceSpinBoxWidget:
                self.sb_hours.setValue(h)
                self.sb_minutes.setValue(m)
            else:
                self.sb_minutes_value.write(m)
                self.sb_hours_value.write(h)# = h
            self.blockValueSignal = False

    def stop(self, silent=True):
        if not silent:
            self.bomb_text.write("Abbruch")
        else:
            self.bomb_text.write("00:00:00")
        self.timer.stop()
        self.countDown.stop()
        self.blockValueSignal = True
        if self.forceSpinBoxWidget:
            self.sb_hours.setValue(0)
            self.sb_minutes.setValue(0)
        else:
            self.sb_minutes_value.write(0)
            self.sb_hours_value.write(0)
        self.blockValueSignal = False
        self.isActive = False
コード例 #36
0
ファイル: nest.py プロジェクト: baritonehands/opennest
from PyQt4.QtCore import QDateTime, QObject, QUrl, pyqtSignal
from PyQt4.QtGui import QApplication, QGraphicsColorizeEffect, QColor
from PyQt4.QtDeclarative import QDeclarativeView
from triangle import *
from weather import *


def upArrowClicked():
    print 'Testing!'


app = QApplication(sys.argv)

# Create the QML user interface.
view = QDeclarativeView()
view.rootContext().setContextProperty("dp", 1)
view.setSource(QUrl('qml/nest.qml'))
view.setResizeMode(QDeclarativeView.SizeViewToRootObject)

rootObject = view.rootObject()

upArrow = rootObject.findChild(QObject, 'upArrow')
up = Triangle(upArrow)

downArrow = rootObject.findChild(QObject, 'downArrow')
down = Triangle(downArrow)

weatherView = rootObject.findChild(QObject, 'weatherView')
weather = Weather(weatherView)
weather.start()
コード例 #37
0
from os import popen, path, remove
#import ConfigParser, time
home = path.expanduser("~")

app = QApplication(sys.argv)
app.setGraphicsSystem("raster")
app.setWindowIcon(QIcon('qml/img/encode.png'))

defaultBgColor=app.palette().color(QPalette.Window).name()
Plasma.Theme.defaultTheme().setUseGlobalSettings(False)
Plasma.Theme.defaultTheme().setThemeName("AirNeptune")
#Plasma::Theme::defaultTheme()->setUseGlobalSettings(false); //don't change every plasma theme!
#Plasma::Theme::defaultTheme()->setThemeName("appdashboard");

# Create the QML user interface.
view = QDeclarativeView()
# Use PlasmaComponents
engine = view.engine()
engine.addImportPath("/usr/lib/kde4/imports")
# Set main qml here
view.setSource(QUrl("3ncode.qml"))
view.setResizeMode(QDeclarativeView.SizeRootObjectToView)

# Get the root object of the user interface.
rootObject = view.rootObject()

# Set default background
rootObject.setBgColor(defaultBgColor)

# Check for parameters
if len(sys.argv) > 1:
コード例 #38
0
ファイル: pyqt-qml.py プロジェクト: mutse/pyqt4-code
#!/usr/bin/python
# -*- coding: utf-8 -*-

import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtDeclarative import QDeclarativeView

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

    view = QDeclarativeView()
    view.setSource(QUrl('hello.qml'))
    view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
    view.show()

    sys.exit(app.exec_())

コード例 #39
0
from PyQt4.QtCore import QUrl
from PyQt4.QtGui import QPushButton, QApplication
from PyQt4.QtDeclarative import QDeclarativeView

# This example uses a QML file to show a scrolling list containing
# all the items listed into dataList.

dataList = ["Item 1", "Item 2", "Item 3", "Item 4"]

app = QApplication([])
view = QDeclarativeView()

ctxt = view.rootContext()
ctxt.setContextProperty("myModel", dataList)

url = QUrl(
    'view.qml'
)  # <-- Problem seems to be here, the file gets copied correctly to Resources folder
view.setSource(url)
view.show()
app.exec_()
コード例 #40
0
class FilesHandler(QFrame):
    def __init__(self, parent=None):
        super(FilesHandler, self).__init__(None,
                                           Qt.FramelessWindowHint | Qt.Popup)
        self._main_container = parent
        self.setAttribute(Qt.WA_TranslucentBackground)
        self.setStyleSheet("background:transparent;")
        # Create the QML user interface.
        self.view = QDeclarativeView()
        self.view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
        self.view.setSource(ui_tools.get_qml_resource("FilesHandler.qml"))
        self._root = self.view.rootObject()
        vbox = QVBoxLayout(self)
        vbox.setContentsMargins(0, 0, 0, 0)
        vbox.setSpacing(0)
        vbox.addWidget(self.view)

        self._model = {}
        self._temp_files = {}
        self._max_index = 0

        self.connect(self._root, SIGNAL("open(QString, QString, QString)"),
                     self._open)
        self.connect(self._root, SIGNAL("close(QString, QString)"),
                     self._close)
        self.connect(self._root, SIGNAL("hide()"), self.hide)
        self.connect(self._root, SIGNAL("fuzzySearch(QString)"),
                     self._fuzzy_search)

    def _open(self, path, temp, project):
        if project:
            path = os.path.join(os.path.split(project)[0], path)
            self._main_container.open_file(path)
        elif temp:
            nfile = self._temp_files[temp]
            ninjaide = IDE.get_service("ide")
            neditable = ninjaide.get_or_create_editable(nfile=nfile)
            self._main_container.current_widget.set_current(neditable)
        else:
            self._main_container.open_file(path)
            index = self._model[path]
            self._max_index = max(self._max_index, index) + 1
            self._model[path] = self._max_index
        self.hide()

    def _close(self, path, temp):
        if temp:
            nfile = self._temp_files.get(temp, None)
        else:
            ninjaide = IDE.get_service("ide")
            nfile = ninjaide.get_or_create_nfile(path)
        if nfile is not None:
            nfile.close()

    def _fuzzy_search(self, search):
        search = '.+'.join(re.escape(search).split('\\ '))
        pattern = re.compile(search, re.IGNORECASE)

        model = []
        for project_path in locator.files_paths:
            files_in_project = locator.files_paths[project_path]
            base_project = os.path.basename(project_path)
            for file_path in files_in_project:
                file_path = os.path.join(
                    base_project, os.path.relpath(file_path, project_path))
                if pattern.search(file_path):
                    model.append(
                        [os.path.basename(file_path), file_path, project_path])
        self._root.set_fuzzy_model(model)

    def _add_model(self):
        ninjaide = IDE.get_service("ide")
        files = ninjaide.opened_files
        # Update model
        old = set(self._model.keys())
        new = set([nfile.file_path for nfile in files])
        result = old - new
        for item in result:
            del self._model[item]
        current_editor = self._main_container.get_current_editor()
        current_path = None
        if current_editor:
            current_path = current_editor.file_path
        model = []
        for nfile in files:
            if (nfile.file_path not in self._model
                    and nfile.file_path is not None):
                self._model[nfile.file_path] = 0
            neditable = ninjaide.get_or_create_editable(nfile=nfile)
            checkers = neditable.sorted_checkers
            checks = []
            for items in checkers:
                checker, color, _ = items
                if checker.dirty:
                    checks.append({
                        "checker_text": checker.dirty_text,
                        "checker_color": color
                    })
            modified = neditable.document.isModified()
            temp_file = str(uuid.uuid4()) if nfile.file_path is None else ""
            filepath = nfile.file_path if nfile.file_path is not None else ""
            model.append(
                [nfile.file_name, filepath, checks, modified, temp_file])
            if temp_file:
                self._temp_files[temp_file] = nfile
        if current_path:
            index = self._model[current_path]
            self._max_index = max(self._max_index, index) + 1
            self._model[current_path] = self._max_index
        model = sorted(model,
                       key=lambda x: self._model.get(x[1], False),
                       reverse=True)
        self._root.set_model(model)

    def showEvent(self, event):
        self._add_model()
        widget = self._main_container.get_current_editor()
        if widget is None:
            widget = self._main_container
        if self._main_container.splitter.count() < 2:
            width = max(widget.width() / 2, 500)
            height = max(widget.height() / 2, 400)
        else:
            width = widget.width()
            height = widget.height()
        self.view.setFixedWidth(width)
        self.view.setFixedHeight(height)

        super(FilesHandler, self).showEvent(event)
        self._root.show_animation()
        point = widget.mapToGlobal(self.view.pos())
        self.move(point.x(), point.y())
        self.view.setFocus()
        self._root.activateInput()

    def hideEvent(self, event):
        super(FilesHandler, self).hideEvent(event)
        self._temp_files = {}
        self._root.clear_model()

    def next_item(self):
        if not self.isVisible():
            self.show()
        self._root.next_item()

    def previous_item(self):
        if not self.isVisible():
            self.show()
        self._root.previous_item()

    def keyPressEvent(self, event):
        if event.key() == Qt.Key_Escape:
            self.hide()
        elif (event.modifiers() == Qt.ControlModifier and event.key()
              == Qt.Key_PageDown) or event.key() == Qt.Key_Down:
            self._root.next_item()
        elif (event.modifiers() == Qt.ControlModifier
              and event.key() == Qt.Key_PageUp) or event.key() == Qt.Key_Up:
            self._root.previous_item()
        elif event.key() in (Qt.Key_Return, Qt.Key_Enter):
            self._root.open_item()
        super(FilesHandler, self).keyPressEvent(event)
コード例 #41
0
class TabsHandler(QFrame):

    def __init__(self, parent=None):
        super(TabsHandler, self).__init__(None,
            Qt.FramelessWindowHint | Qt.Popup)
        self._main_container = parent
        self.setAttribute(Qt.WA_TranslucentBackground)
        self.setStyleSheet("background:transparent;")
        # Create the QML user interface.
        self.view = QDeclarativeView()
        self.view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
        self.view.setSource(ui_tools.get_qml_resource("TabsHandler.qml"))
        self._root = self.view.rootObject()
        vbox = QVBoxLayout(self)
        vbox.setContentsMargins(0, 0, 0, 0)
        vbox.setSpacing(0)
        vbox.addWidget(self.view)

        self._model = {}
        self._max_index = 0

        self.connect(self._root, SIGNAL("open(QString)"), self._open)
        self.connect(self._root, SIGNAL("close(QString)"), self._close)

    def _open(self, path):
        self._main_container.open_file(path)
        index = self._model[path]
        self._max_index = max(self._max_index, index) + 1
        self._model[path] = self._max_index
        self.hide()

    def _close(self, path):
        ninjaide = IDE.get_service("ide")
        nfile = ninjaide.get_or_create_nfile(path)
        nfile.close()

    def _add_model(self):
        ninjaide = IDE.get_service("ide")
        files = ninjaide.filesystem.get_files()
        files_data = list(files.values())
        # Update model
        old = set(self._model.keys())
        new = set([nfile.file_path for nfile in files_data])
        result = old - new
        for item in result:
            del self._model[item]
        current_editor = self._main_container.get_current_editor()
        current_path = None
        if current_editor:
            current_path = current_editor.file_path
        model = []
        for nfile in files_data:
            if nfile.file_path not in self._model:
                self._model[nfile.file_path] = 0
            neditable = ninjaide.get_or_create_editable(nfile.file_path)
            checkers = neditable.sorted_checkers
            checks = []
            for items in checkers:
                checker, color, _ = items
                if checker.dirty:
                    checks.append(
                        {"checker_text": checker.dirty_text,
                         "checker_color": color})
            modified = neditable.document.isModified()
            model.append([nfile.file_name, nfile.file_path, checks, modified])
        if current_path:
            index = self._model[current_path]
            self._max_index = max(self._max_index, index) + 1
            self._model[current_path] = self._max_index
        model = sorted(model, key=lambda x: self._model[x[1]], reverse=True)
        self._root.set_model(model)

    def showEvent(self, event):
        self._add_model()
        width = max(self._main_container.width() / 3, 300)
        height = max(self._main_container.height() / 2, 400)
        self.view.setFixedWidth(width)
        self.view.setFixedHeight(height)
        super(TabsHandler, self).showEvent(event)
        self._root.show_animation()
        point = self._main_container.mapToGlobal(self.view.pos())
        y_diff = self._main_container.combo_header_size
        self.move(point.x(), point.y() + y_diff)
        self.view.setFocus()

    def hideEvent(self, event):
        super(TabsHandler, self).hideEvent(event)
        self._root.clear_model()

    def next_item(self):
        if not self.isVisible():
            self.show()
        self._root.next_item()

    def previous_item(self):
        if not self.isVisible():
            self.show()
        self._root.previous_item()

    def keyPressEvent(self, event):
        if event.key() == Qt.Key_Escape:
            self.hide()
        elif (event.modifiers() == Qt.ControlModifier and
                event.key() == Qt.Key_PageDown) or event.key() == Qt.Key_Down:
            self._root.next_item()
        elif (event.modifiers() == Qt.ControlModifier and
                event.key() == Qt.Key_PageUp) or event.key() == Qt.Key_Up:
            self._root.previous_item()
        elif event.key() in (Qt.Key_Return, Qt.Key_Enter):
            self._root.open_item()
        super(TabsHandler, self).keyPressEvent(event)
コード例 #42
0
class StartPage(QWidget):

    def __init__(self, parent=None):
        super(StartPage, self).__init__(parent)
        vbox = QVBoxLayout(self)
        vbox.setContentsMargins(0, 0, 0, 0)
        vbox.setSpacing(0)
        self.view = QDeclarativeView()
        self.view.setMinimumWidth(400)
        self.view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
        self.view.setSource(ui_tools.get_qml_resource("StartPage.qml"))
        self.root = self.view.rootObject()
        vbox.addWidget(self.view)

        self.load_items()

        self.connect(self.root, SIGNAL("openProject(QString)"),
            self._open_project)
        self.connect(self.root, SIGNAL("removeProject(QString)"),
            self._on_click_on_delete)
        self.connect(self.root, SIGNAL("markAsFavorite(QString, bool)"),
            self._on_click_on_favorite)
        self.connect(self.root, SIGNAL("openPreferences()"),
            lambda: self.emit(SIGNAL("openPreferences()")))
        self.connect(self.root, SIGNAL("newFile()"),
            lambda: self.emit(SIGNAL("newFile()")))

        self.root.set_year(str(datetime.datetime.now().year))

    def _open_project(self, path):
        projects_explorer = IDE.get_service('projects_explorer')
        if projects_explorer:
            projects_explorer.open_project_folder(path)

    def _on_click_on_delete(self, path):
        settings = IDE.data_settings()
        recent_projects = settings.value("recentProjects")
        if path in recent_projects:
            del recent_projects[path]
            settings.setValue("recentProjects", recent_projects)

    def _on_click_on_favorite(self, path, value):
        settings = IDE.data_settings()
        recent_projects = settings.value("recentProjects")
        properties = recent_projects[path]
        properties["isFavorite"] = value
        recent_projects[path] = properties
        settings.setValue("recentProjects", recent_projects)

    def load_items(self):
        settings = IDE.data_settings()
        listByFavorites = []
        listNoneFavorites = []
        recent_projects_dict = dict(settings.value('recentProjects', {}))
        #Filter for favorites
        for recent_project_path, content in list(recent_projects_dict.items()):
            if bool(dict(content)["isFavorite"]):
                listByFavorites.append((recent_project_path,
                    content["lastopen"]))
            else:
                listNoneFavorites.append((recent_project_path,
                    content["lastopen"]))
        if len(listByFavorites) > 1:
            # sort by date favorites
            listByFavorites = sorted(listByFavorites,
                key=lambda date: listByFavorites[1])

        if len(listNoneFavorites) > 1:
            #sort by date last used
            listNoneFavorites = sorted(listNoneFavorites,
                key=lambda date: listNoneFavorites[1])

        for recent_project_path in listByFavorites:
            path = recent_project_path[0]
            name = recent_projects_dict[path]['name']
            self.root.add_project(name, path, True)

        for recent_project_path in listNoneFavorites:
            path = recent_project_path[0]
            name = recent_projects_dict[path]['name']
            self.root.add_project(name, path, False)
        self.root.forceActiveFocus()
コード例 #43
0
from softwarecenter.db.pkginfo import get_pkg_info

from pkglist import PkgListModel
from reviewslist import ReviewsListModel
from categoriesmodel import CategoriesModel

from softwarecenter.utils import mangle_paths_if_running_in_local_checkout

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

    # TODO do this async
    app.cache = get_pkg_info()
    app.cache.open()

    view = QDeclarativeView()
    view.setWindowTitle(view.tr("Ubuntu Software Center"))
    view.setWindowIcon(
        QIcon(
            os.path.join(
                os.path.dirname(__file__),
                "../../../data/icons/scalable/apps/softwarecenter.svg")))
    view.setResizeMode(QtDeclarative.QDeclarativeView.SizeRootObjectToView)

    # if running locally, fixup softwarecenter.paths
    mangle_paths_if_running_in_local_checkout()

    # ideally this should be part of the qml by using a qmlRegisterType()
    # but that does not seem to be supported in pyqt yet(?) so we need
    # to cowboy it in here
    pkglistmodel = PkgListModel()
コード例 #44
0
    def __init__(self, parent=None):
        super(SleepTimer, self).__init__(parent)
        self.forceSpinBoxWidget = global_vars.configuration.get("GENERAL").get(
            "sleeptimerdigitalspinbox")
        self.setStyleSheet(
            "SleepTimer {"
            "background-color: rgb(76, 76, 76);"
            "color: rgb(240, 240, 240);"
            "}"
            "QLabel {"
            "color: white;"
            "}"
            "QSpinBox {"
            "padding-right: 10px; /* make room for the arrows */"
            "border-width: 3;"
            "}"
            "QSpinBox::up-button {"
            "width: 26px;"
            "}"
            "QSpinBox::down-button {"
            "width: 26px;"
            "}")
        self.value = 0  # the value is calculated in self.active (calculated seconds in total)
        self.isActive = False

        if self.forceSpinBoxWidget:
            self.sb_hours = LeadingZeroSpinBox()
            self.sb_hours.setRange(0, 23)
            self.sb_hours.setAlignment(Qt.AlignCenter)
            self.sb_hours.setSizePolicy(QSizePolicy.Expanding,
                                        QSizePolicy.Expanding)
        else:
            self.sb_hours = QDeclarativeView()
            self.sb_hours.setSource(QUrl(os.path.join(cwd, 'sb_hours.qml')))
            self.sb_hours.setResizeMode(QDeclarativeView.SizeViewToRootObject)
            self.sb_hours.setStyleSheet("background:transparent;")
            self.sb_hours.setSizePolicy(QSizePolicy.Expanding,
                                        QSizePolicy.Expanding)

            self.sb_hours_obj = self.sb_hours.rootObject().findChild(
                QObject, "spinner")
            self.sb_hours_value = QDeclarativeProperty(
                self.sb_hours.rootObject().findChild(QDeclarativeItem,
                                                     name="spinner"),
                "currentIndex")

        if self.forceSpinBoxWidget:
            self.sb_minutes = LeadingZeroSpinBox()
            self.sb_minutes.setRange(0, 59)
            self.sb_minutes.setAlignment(Qt.AlignCenter)
            self.sb_minutes.setSizePolicy(QSizePolicy.Expanding,
                                          QSizePolicy.Expanding)
        else:
            self.sb_minutes = QDeclarativeView()
            self.sb_minutes.setSource(QUrl(os.path.join(cwd,
                                                        'sb_minutes.qml')))
            self.sb_minutes.setResizeMode(
                QDeclarativeView.SizeViewToRootObject)
            self.sb_minutes.setStyleSheet("background:transparent;")
            self.sb_minutes.setSizePolicy(QSizePolicy.Expanding,
                                          QSizePolicy.Expanding)

            self.sb_minutes_obj = self.sb_minutes.rootObject().findChild(
                QObject, "spinner")
            self.sb_minutes_value = QDeclarativeProperty(
                self.sb_minutes.rootObject().findChild(QDeclarativeItem,
                                                       name="spinner"),
                "currentIndex")

        tmpFont = QFont()
        tmpFont.setPointSize(18)
        self.lbl_hours = QLabel(QString("h"))
        self.lbl_hours.setFont(tmpFont)
        self.lbl_minutes = QLabel(QString("min"))
        self.lbl_minutes.setFont(tmpFont)

        # Load QML Widget Bomb
        self.bomb = QDeclarativeView()
        self.bomb.setSource(QUrl(os.path.join(cwd, 'timebomb.qml')))
        self.bomb.setResizeMode(QDeclarativeView.SizeViewToRootObject)
        #self.bomb.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.bomb.setStyleSheet("background:transparent;")
        self.bomb_text = QDeclarativeProperty(
            self.bomb.rootObject().findChild(QDeclarativeItem,
                                             name="counter_text"), "text")

        #setup layouts
        tmpLayout = QHBoxLayout()
        tmpLayout.addSpacerItem(QSpacerItem(40, 40, QSizePolicy.Expanding))
        tmpLayout.addWidget(self.sb_hours)
        tmpLayout.addWidget(self.lbl_hours)
        tmpLayout.addWidget(self.sb_minutes)
        tmpLayout.addWidget(self.lbl_minutes)
        tmpLayout.addSpacerItem(QSpacerItem(40, 40, QSizePolicy.Expanding))

        tmp2Layout = QVBoxLayout()
        tmp2Layout.addLayout(tmpLayout)
        tmp2Layout.addWidget(self.bomb)
        tmp2Layout.addSpacerItem(QSpacerItem(40, 40, QSizePolicy.Expanding))

        self.setLayout(tmp2Layout)
        self.blockValueSignal = False  # if this is true, valueChanged signal is not evaluated
        if self.forceSpinBoxWidget:
            self.sb_hours.valueChanged.connect(self.onValueChanged)
            self.sb_minutes.valueChanged.connect(self.onValueChanged)
        else:
            self.sb_hours_obj.currentIndexChanged.connect(self.onValueChanged)
            self.sb_minutes_obj.currentIndexChanged.connect(
                self.onValueChanged)

        # setup Timer which is started as soon as a value is changed in any of the spinboxes
        self.timer = QTimer()
        self.timer.setSingleShot(True)
        self.timer.setInterval(
            2000)  # 2 seconds until timer starts automatically
        self.connect(self.timer, SIGNAL("timeout()"), self.activate)

        #setup Timer which is a second-timer. It is startet with the self.timer (see self.active)
        self.countDown = QTimer()
        self.countDown.setInterval(1000)  #sec
        self.connect(self.countDown, SIGNAL("timeout()"), self.check)
コード例 #45
0
    try:
        # PyInstaller creates a temp folder and stores path in _MEIPASS
        # 打包后走这边
        print(sys._MEIPASS)
        base_path = sys._MEIPASS
    except Exception:
        # dev时走这边
        base_path = os.path.abspath(".")

    return os.path.join(base_path, relative_path)


if __name__ == '__main__':
    app = QApplication([])

    view = QDeclarativeView()
    # 这里相当于传进的成绝对路径了
    # path = 'file:///' + resource_path('view.qml')
    # view.setSource(QUrl(path))
    view.setSource(QUrl('qrc:view.qml'))
    # dev的时候resource_path 就setSource到当前目录下文件了
    # 打包完过后 就setSource到那个TMP目录下的文件去了
    # 相当于我之前打包的时候,在spec文件中写入了文件,运行时文件才会跑到TMP里去了的
    view.setAttribute(Qt.WA_TranslucentBackground)

    view.setStyleSheet("background-color:transparent")
    view.setWindowFlags(Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint)
    view.showFullScreen()

    app.exec_()
コード例 #46
0
# requested.
class Now(QObject):

    now = QtCore.pyqtSignal(str)

    def emit_now(self):
        formatted_date = QDateTime.currentDateTime().toString()
        self.now.emit(formatted_date)


app = QApplication(sys.argv)

now = Now()

# Create the QML user interface.
view = QDeclarativeView()
view.setSource(QUrl('message.qml'))
view.setResizeMode(QDeclarativeView.SizeRootObjectToView)

# Get the root object of the user interface.  It defines a
# 'messageRequired' signal and JavaScript 'updateMessage' function.  Both
# can be accessed transparently from Python.
rootObject = view.rootObject()

# Provide the current date and time when requested by the user interface.
rootObject.messageRequired.connect(now.emit_now)

# Update the user interface with the current date and time.
now.now.connect(rootObject.updateMessage)

# Provide an initial message as a prompt.
        elif role == "_iconname":
            # funny, but it appears like Qt does not have something
            # to lookup the icon path in QIcon
            icons = Gtk.IconTheme.get_default()
            info = icons.lookup_icon(cat.iconname, 48, 0)
            if info:
                return info.get_filename()
            return ""


if __name__ == "__main__":
    from PyQt4.QtGui import QApplication
    from PyQt4.QtDeclarative import QDeclarativeView
    import sys

    app = QApplication(sys.argv)
    app.cache = get_pkg_info()
    app.cache.open()
    view = QDeclarativeView()
    categoriesmodel = CategoriesModel()
    rc = view.rootContext()
    rc.setContextProperty('categoriesmodel', categoriesmodel)

    # load the main QML file into the view
    qmlpath = os.path.join(os.path.dirname(__file__), "CategoriesView.qml")
    view.setSource(qmlpath)

    # show it
    view.show()
    sys.exit(app.exec_())
コード例 #48
0
class PluginsStore(QDialog):

    def __init__(self, parent=None):
        super(PluginsStore, self).__init__(parent, Qt.Dialog)
        self.setWindowTitle(translations.TR_MANAGE_PLUGINS)
        vbox = QVBoxLayout(self)
        vbox.setContentsMargins(0, 0, 0, 0)
        vbox.setSpacing(0)
        self.view = QDeclarativeView()
        self.view.setMinimumWidth(800)
        self.view.setMinimumHeight(600)
        self.view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
        self.view.setSource(ui_tools.get_qml_resource("PluginsStore.qml"))
        self.root = self.view.rootObject()
        vbox.addWidget(self.view)
        self._plugins = {}
        self._plugins_inflate = []
        self._plugins_by_tag = collections.defaultdict(list)
        self._plugins_by_author = collections.defaultdict(list)
        self._base_color = QColor("white")
        self._counter = 0
        self._counter_callback = None
        self._inflating_plugins = []
        self._categoryTags = True
        self._search = []
        self.status = None

        self.connect(self.root, SIGNAL("loadPluginsGrid()"),
                     self._load_by_name)
        self.connect(self.root, SIGNAL("showPluginDetails(int)"),
                     self.show_plugin_details)
        self.connect(self.root, SIGNAL("loadTagsGrid()"),
                     self._load_tags_grid)
        self.connect(self.root, SIGNAL("loadAuthorGrid()"),
                     self._load_author_grid)
        self.connect(self.root, SIGNAL("search(QString)"),
                     self._load_search_results)
        self.connect(self.root, SIGNAL("loadPluginsForCategory(QString)"),
                     self._load_plugins_for_category)
        self.connect(self, SIGNAL("processCompleted(PyQt_PyObject)"),
                     self._process_complete)

        self.nenv = nenvironment.NenvEggSearcher()
        self.connect(self.nenv,
                     SIGNAL("searchCompleted(PyQt_PyObject)"),
                     self.callback)
        self.status = self.nenv.do_search()

    def _load_by_name(self):
        if self._plugins:
            self.root.showGridPlugins()
            for plugin in list(self._plugins.values()):
                self.root.addPlugin(plugin.identifier, plugin.name,
                                    plugin.summary, plugin.version)

    def _load_plugins_for_category(self, name):
        self.root.showGridPlugins()
        if self._categoryTags:
            for plugin in self._plugins_by_tag[name]:
                self.root.addPlugin(plugin.identifier, plugin.name,
                                    plugin.summary, plugin.version)
        else:
            for plugin in self._plugins_by_author[name]:
                self.root.addPlugin(plugin.identifier, plugin.name,
                                    plugin.summary, plugin.version)

    def callback(self, values):
        self.root.showGridPlugins()
        for i, plugin in enumerate(values):
            plugin.identifier = i + 1
            self.root.addPlugin(plugin.identifier, plugin.name,
                                plugin.summary, plugin.version)
            self._plugins[plugin.identifier] = plugin

    def show_plugin_details(self, identifier):
        plugin = self._plugins[identifier]
        self._counter = 1
        self._counter_callback = self._show_details

        if plugin.shallow:
            self.connect(plugin,
                         SIGNAL("pluginMetadataInflated(PyQt_PyObject)"),
                         self._update_content)
            self._plugins_inflate.append(plugin.inflate())
        else:
            self._update_content(plugin)

    def _load_tags_grid(self):
        self._categoryTags = True
        self._counter = len(self._plugins)
        self.root.updateCategoryCounter(self._counter)
        self._counter_callback = self._show_tags_grid
        self._inflating_plugins = list(self._plugins.values())
        self._loading_function()

    def _load_author_grid(self):
        self._categoryTags = False
        self._counter = len(self._plugins)
        self.root.updateCategoryCounter(self._counter)
        self._counter_callback = self._show_author_grid
        self._inflating_plugins = list(self._plugins.values())
        self._loading_function()

    def _load_search_results(self, search):
        self._search = search.lower().split()
        self._counter = len(self._plugins)
        self.root.updateCategoryCounter(self._counter)
        self._counter_callback = self._show_search_grid
        self._inflating_plugins = list(self._plugins.values())
        self._loading_function()

    def _loading_function(self):
        plugin = self._inflating_plugins.pop()
        if plugin.shallow:
            self.connect(plugin,
                         SIGNAL("pluginMetadataInflated(PyQt_PyObject)"),
                         self._update_content)
            self._plugins_inflate.append(plugin.inflate())
        else:
            self._process_complete(plugin)

    def _process_complete(self, plugin=None):
        self._counter -= 1
        self.root.updateCategoryCounter(self._counter)
        if self._counter == 0:
            self._counter_callback(plugin)
        else:
            self._loading_function()

    def _show_search_grid(self, plugin=None):
        self.root.showGridPlugins()
        for plugin in list(self._plugins.values()):
            keywords = plugin.keywords.lower().split() + [plugin.name.lower()]
            for word in self._search:
                if word in keywords:
                    self.root.addPlugin(plugin.identifier, plugin.name,
                                        plugin.summary, plugin.version)

    def _show_details(self, plugin):
        self.root.displayDetails(plugin.identifier)

    def _show_tags_grid(self, plugin=None):
        tags = sorted(self._plugins_by_tag.keys())
        for tag in tags:
            color = self._get_random_color(self._base_color)
            self.root.addCategory(color.name(), tag)
        self.root.loadingComplete()

    def _show_author_grid(self, plugin=None):
        authors = sorted(self._plugins_by_author.keys())
        for author in authors:
            color = self._get_random_color(self._base_color)
            self.root.addCategory(color.name(), author)
        self.root.loadingComplete()

    def _update_content(self, plugin):
        self.root.updatePlugin(
            plugin.identifier, plugin.author, plugin.author_email,
            plugin.description, plugin.download_url, plugin.home_page,
            plugin.license)
        keywords = plugin.keywords.split()
        for key in keywords:
            plugins = self._plugins_by_tag[key]
            if plugin not in plugins:
                plugins.append(plugin)
                self._plugins_by_tag[key] = plugins
        plugins = self._plugins_by_author[plugin.author]
        if plugin not in plugins:
            plugins.append(plugin)
            self._plugins_by_author[plugin.author] = plugins
        self.emit(SIGNAL("processCompleted(PyQt_PyObject)"), plugin)

    def _get_random_color(self, mix=None):
        red = random.randint(0, 256)
        green = random.randint(0, 256)
        blue = random.randint(0, 256)

        # mix the color
        if mix:
            red = (red + mix.red()) / 2
            green = (green + mix.green()) / 2
            blue = (blue + mix.blue()) / 2

        color = QColor(red, green, blue)
        return color
コード例 #49
0
ファイル: files_handler.py プロジェクト: AnyBucket/ninja-ide
class FilesHandler(QFrame):

    def __init__(self, parent=None):
        super(FilesHandler, self).__init__(
            None, Qt.FramelessWindowHint | Qt.Popup)
        self._main_container = parent
        self.setAttribute(Qt.WA_TranslucentBackground)
        self.setStyleSheet("background:transparent;")
        # Create the QML user interface.
        self.view = QDeclarativeView()
        self.view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
        self.view.setSource(ui_tools.get_qml_resource("FilesHandler.qml"))
        self._root = self.view.rootObject()
        vbox = QVBoxLayout(self)
        vbox.setContentsMargins(0, 0, 0, 0)
        vbox.setSpacing(0)
        vbox.addWidget(self.view)

        self._model = {}
        self._temp_files = {}
        self._max_index = 0

        self.connect(self._root, SIGNAL("open(QString, QString, QString)"),
                     self._open)
        self.connect(self._root, SIGNAL("close(QString, QString)"), self._close)
        self.connect(self._root, SIGNAL("hide()"), self.hide)
        self.connect(self._root, SIGNAL("fuzzySearch(QString)"),
                     self._fuzzy_search)

    def _open(self, path, temp, project):
        if project:
            path = os.path.join(os.path.split(project)[0], path)
            self._main_container.open_file(path)
        elif temp:
            nfile = self._temp_files[temp]
            ninjaide = IDE.get_service("ide")
            neditable = ninjaide.get_or_create_editable(nfile=nfile)
            self._main_container.current_widget.set_current(neditable)
        else:
            self._main_container.open_file(path)
            index = self._model[path]
            self._max_index = max(self._max_index, index) + 1
            self._model[path] = self._max_index
        self.hide()

    def _close(self, path, temp):
        if temp:
            nfile = self._temp_files.get(temp, None)
        else:
            ninjaide = IDE.get_service("ide")
            nfile = ninjaide.get_or_create_nfile(path)
        if nfile is not None:
            nfile.close()

    def _fuzzy_search(self, search):
        search = '.+'.join(re.escape(search).split('\\ '))
        pattern = re.compile(search, re.IGNORECASE)

        model = []
        for project_path in locator.files_paths:
            files_in_project = locator.files_paths[project_path]
            base_project = os.path.basename(project_path)
            for file_path in files_in_project:
                file_path = os.path.join(
                    base_project, os.path.relpath(file_path, project_path))
                if pattern.search(file_path):
                    model.append([os.path.basename(file_path), file_path,
                                  project_path])
        self._root.set_fuzzy_model(model)

    def _add_model(self):
        ninjaide = IDE.get_service("ide")
        files = ninjaide.opened_files
        # Update model
        old = set(self._model.keys())
        new = set([nfile.file_path for nfile in files])
        result = old - new
        for item in result:
            del self._model[item]
        current_editor = self._main_container.get_current_editor()
        current_path = None
        if current_editor:
            current_path = current_editor.file_path
        model = []
        for nfile in files:
            if (nfile.file_path not in self._model and
                    nfile.file_path is not None):
                self._model[nfile.file_path] = 0
            neditable = ninjaide.get_or_create_editable(nfile=nfile)
            checkers = neditable.sorted_checkers
            checks = []
            for items in checkers:
                checker, color, _ = items
                if checker.dirty:
                    checks.append(
                        {"checker_text": checker.dirty_text,
                         "checker_color": color})
            modified = neditable.document.isModified()
            temp_file = str(uuid.uuid4()) if nfile.file_path is None else ""
            filepath = nfile.file_path if nfile.file_path is not None else ""
            model.append([nfile.file_name, filepath, checks, modified,
                          temp_file])
            if temp_file:
                self._temp_files[temp_file] = nfile
        if current_path:
            index = self._model[current_path]
            self._max_index = max(self._max_index, index) + 1
            self._model[current_path] = self._max_index
        model = sorted(model, key=lambda x: self._model.get(x[1], False),
                       reverse=True)
        self._root.set_model(model)

    def showEvent(self, event):
        self._add_model()
        widget = self._main_container.get_current_editor()
        if widget is None:
            widget = self._main_container
        if self._main_container.splitter.count() < 2:
            width = max(widget.width() / 2, 500)
            height = max(widget.height() / 2, 400)
        else:
            width = widget.width()
            height = widget.height()
        self.view.setFixedWidth(width)
        self.view.setFixedHeight(height)

        super(FilesHandler, self).showEvent(event)
        self._root.show_animation()
        point = widget.mapToGlobal(self.view.pos())
        self.move(point.x(), point.y())
        self.view.setFocus()
        self._root.activateInput()

    def hideEvent(self, event):
        super(FilesHandler, self).hideEvent(event)
        self._temp_files = {}
        self._root.clear_model()

    def next_item(self):
        if not self.isVisible():
            self.show()
        self._root.next_item()

    def previous_item(self):
        if not self.isVisible():
            self.show()
        self._root.previous_item()

    def keyPressEvent(self, event):
        if event.key() == Qt.Key_Escape:
            self.hide()
        elif (event.modifiers() == Qt.ControlModifier and
                event.key() == Qt.Key_PageDown) or event.key() == Qt.Key_Down:
            self._root.next_item()
        elif (event.modifiers() == Qt.ControlModifier and
                event.key() == Qt.Key_PageUp) or event.key() == Qt.Key_Up:
            self._root.previous_item()
        elif event.key() in (Qt.Key_Return, Qt.Key_Enter):
            self._root.open_item()
        super(FilesHandler, self).keyPressEvent(event)
コード例 #50
0
class TabsHandler(QFrame):
    def __init__(self, parent=None):
        super(TabsHandler, self).__init__(None, Qt.FramelessWindowHint | Qt.Popup)
        self._main_container = parent
        self.setAttribute(Qt.WA_TranslucentBackground)
        self.setStyleSheet("background:transparent;")
        # Create the QML user interface.
        self.view = QDeclarativeView()
        self.view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
        self.view.setSource(ui_tools.get_qml_resource("TabsHandler.qml"))
        self._root = self.view.rootObject()
        vbox = QVBoxLayout(self)
        vbox.setContentsMargins(0, 0, 0, 0)
        vbox.setSpacing(0)
        vbox.addWidget(self.view)

        self._model = {}
        self._max_index = 0

        self.connect(self._root, SIGNAL("open(QString)"), self._open)
        self.connect(self._root, SIGNAL("close(QString)"), self._close)
        self.connect(self._root, SIGNAL("hide()"), self.hide)

    def _open(self, path):
        self._main_container.open_file(path)
        index = self._model[path]
        self._max_index = max(self._max_index, index) + 1
        self._model[path] = self._max_index
        self.hide()

    def _close(self, path):
        ninjaide = IDE.get_service("ide")
        nfile = ninjaide.get_or_create_nfile(path)
        nfile.close()

    def _add_model(self):
        ninjaide = IDE.get_service("ide")
        files = ninjaide.filesystem.get_files()
        files_data = list(files.values())
        # Update model
        old = set(self._model.keys())
        new = set([nfile.file_path for nfile in files_data])
        result = old - new
        for item in result:
            del self._model[item]
        current_editor = self._main_container.get_current_editor()
        current_path = None
        if current_editor:
            current_path = current_editor.file_path
        model = []
        for nfile in files_data:
            if nfile.file_path not in self._model:
                self._model[nfile.file_path] = 0
            neditable = ninjaide.get_or_create_editable(nfile.file_path)
            checkers = neditable.sorted_checkers
            checks = []
            for items in checkers:
                checker, color, _ = items
                if checker.dirty:
                    checks.append({"checker_text": checker.dirty_text, "checker_color": color})
            modified = neditable.document.isModified()
            model.append([nfile.file_name, nfile.file_path, checks, modified])
        if current_path:
            index = self._model[current_path]
            self._max_index = max(self._max_index, index) + 1
            self._model[current_path] = self._max_index
        model = sorted(model, key=lambda x: self._model[x[1]], reverse=True)
        self._root.set_model(model)

    def showEvent(self, event):
        self._add_model()
        width = max(self._main_container.width() / 3, 300)
        logger.debug("This is the width")
        logger.debug(width)
        height = max(self._main_container.height() / 2, 400)
        logger.debug("This is the height")
        logger.debug(height)
        self.view.setFixedWidth(width)

        self.view.setFixedHeight(height)
        super(TabsHandler, self).showEvent(event)
        self._root.show_animation()
        point = self._main_container.mapToGlobal(self.view.pos())
        y_diff = self._main_container.combo_header_size
        self.move(point.x(), point.y() + y_diff)
        self.view.setFocus()

    def hideEvent(self, event):
        super(TabsHandler, self).hideEvent(event)
        self._root.clear_model()

    def next_item(self):
        if not self.isVisible():
            self.show()
        self._root.next_item()

    def previous_item(self):
        if not self.isVisible():
            self.show()
        self._root.previous_item()

    def keyPressEvent(self, event):
        if event.key() == Qt.Key_Escape:
            self.hide()
        elif (event.modifiers() == Qt.ControlModifier and event.key() == Qt.Key_PageDown) or event.key() == Qt.Key_Down:
            self._root.next_item()
        elif (event.modifiers() == Qt.ControlModifier and event.key() == Qt.Key_PageUp) or event.key() == Qt.Key_Up:
            self._root.previous_item()
        elif event.key() in (Qt.Key_Return, Qt.Key_Enter):
            self._root.open_item()
        super(TabsHandler, self).keyPressEvent(event)
コード例 #51
0
class AddFileFolderWidget(QDialog):
    """LocatorWidget class with the Logic for the QML UI"""
    def __init__(self, parent=None):
        super(AddFileFolderWidget,
              self).__init__(parent, Qt.Dialog | Qt.FramelessWindowHint)
        self._main_container = parent
        self.setModal(True)
        self.setAttribute(Qt.WA_TranslucentBackground)
        self.setStyleSheet("background:transparent;")
        self.setFixedHeight(70)
        self.setFixedWidth(650)
        # Create the QML user interface.
        self.view = QDeclarativeView()
        self.view.setResizeMode(QDeclarativeView.SizeRootObjectToView)
        self.view.setSource(ui_tools.get_qml_resource("AddFileFolder.qml"))
        self._root = self.view.rootObject()
        vbox = QVBoxLayout(self)
        vbox.setContentsMargins(0, 0, 0, 0)
        vbox.setSpacing(0)
        vbox.addWidget(self.view)

        self._base_path = ""

        self._create_file_operation = True

        self.connect(self._root, SIGNAL("create(QString)"), self._create)

    def create_file(self, base_path, project_path):
        self._create_file_operation = True
        self._base_path = project_path
        base_path = os.path.relpath(base_path, project_path)
        self._root.setDialogType(self._create_file_operation)
        self._root.setBasePath(base_path + os.path.sep)
        self.show()

    def create_folder(self, base_path, project_path):
        self._create_file_operation = False
        self._base_path = project_path
        base_path = os.path.relpath(base_path, project_path)
        self._root.setDialogType(self._create_file_operation)
        self._root.setBasePath(base_path + os.path.sep)
        self.show()

    def showEvent(self, event):
        """Method takes an event to show the Notification"""
        super(AddFileFolderWidget, self).showEvent(event)
        ninjaide = IDE.get_service("ide")
        point = self._main_container.mapToGlobal(self.view.pos())
        x = point.x() + (ninjaide.width() / 2) - (self.width() / 2)
        self.move(x, point.y())
        self.view.setFocus()
        self._root.activateInput()

    def _create(self, path):
        """Open the item received."""
        if self._create_file_operation:
            path = os.path.join(self._base_path, path)
            folder = os.path.split(path)[0]
            if not os.path.exists(folder):
                file_manager.create_folder(folder)
            ninjaide = IDE.get_service('ide')
            current_nfile = ninjaide.get_or_create_nfile(path)
            current_nfile.create()
            main_container = IDE.get_service('main_container')
            if main_container:
                main_container.open_file(path)
        else:
            path = os.path.join(self._base_path, path)
            if not os.path.exists(path):
                file_manager.create_folder(path)
        self.hide()

    def hideEvent(self, event):
        super(AddFileFolderWidget, self).hideEvent(event)
        self._root.cleanText()
コード例 #52
0
ファイル: sleeptimer.py プロジェクト: Acer54/Webradio_v2
    def __init__(self, parent=None):
        super(SleepTimer, self).__init__(parent)
        self.forceSpinBoxWidget = global_vars.configuration.get("GENERAL").get("sleeptimerdigitalspinbox")
        self.setStyleSheet("SleepTimer {"
                            "background-color: rgb(76, 76, 76);"
                            "color: rgb(240, 240, 240);"
                            "}"
                           "QLabel {"
                           "color: white;"
                           "}"
                           "QSpinBox {"
                           "padding-right: 10px; /* make room for the arrows */"
                           "border-width: 3;"
                           "}"
                           "QSpinBox::up-button {"
                           "width: 26px;"
                            "}"
                           "QSpinBox::down-button {"
                           "width: 26px;"
                            "}"
                            )
        self.value = 0 # the value is calculated in self.active (calculated seconds in total)
        self.isActive = False

        if self.forceSpinBoxWidget:
            self.sb_hours = LeadingZeroSpinBox()
            self.sb_hours.setRange(0,23)
            self.sb_hours.setAlignment(Qt.AlignCenter)
            self.sb_hours.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        else:
            self.sb_hours = QDeclarativeView()
            self.sb_hours.setSource(QUrl(os.path.join(cwd,'sb_hours.qml')))
            self.sb_hours.setResizeMode(QDeclarativeView.SizeViewToRootObject)
            self.sb_hours.setStyleSheet("background:transparent;")
            self.sb_hours.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)

            self.sb_hours_obj = self.sb_hours.rootObject().findChild(QObject, "spinner")
            self.sb_hours_value = QDeclarativeProperty(self.sb_hours.rootObject().findChild(QDeclarativeItem, name="spinner"),"currentIndex")

        if self.forceSpinBoxWidget:
            self.sb_minutes = LeadingZeroSpinBox()
            self.sb_minutes.setRange(0,59)
            self.sb_minutes.setAlignment(Qt.AlignCenter)
            self.sb_minutes.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        else:
            self.sb_minutes = QDeclarativeView()
            self.sb_minutes.setSource(QUrl(os.path.join(cwd,'sb_minutes.qml')))
            self.sb_minutes.setResizeMode(QDeclarativeView.SizeViewToRootObject)
            self.sb_minutes.setStyleSheet("background:transparent;")
            self.sb_minutes.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)

            self.sb_minutes_obj = self.sb_minutes.rootObject().findChild(QObject, "spinner")
            self.sb_minutes_value = QDeclarativeProperty(self.sb_minutes.rootObject().findChild(QDeclarativeItem, name="spinner"),"currentIndex")



        tmpFont = QFont()
        tmpFont.setPointSize(18)
        self.lbl_hours = QLabel(QString("h"))
        self.lbl_hours.setFont(tmpFont)
        self.lbl_minutes = QLabel(QString("min"))
        self.lbl_minutes.setFont(tmpFont)

        # Load QML Widget Bomb
        self.bomb = QDeclarativeView()
        self.bomb.setSource(QUrl(os.path.join(cwd,'timebomb.qml')))
        self.bomb.setResizeMode(QDeclarativeView.SizeViewToRootObject)
        #self.bomb.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.bomb.setStyleSheet("background:transparent;")
        self.bomb_text = QDeclarativeProperty(self.bomb.rootObject().findChild(QDeclarativeItem, name="counter_text"),"text")

        #setup layouts
        tmpLayout = QHBoxLayout()
        tmpLayout.addSpacerItem(QSpacerItem(40, 40, QSizePolicy.Expanding))
        tmpLayout.addWidget(self.sb_hours)
        tmpLayout.addWidget(self.lbl_hours)
        tmpLayout.addWidget(self.sb_minutes)
        tmpLayout.addWidget(self.lbl_minutes)
        tmpLayout.addSpacerItem(QSpacerItem(40, 40, QSizePolicy.Expanding))

        tmp2Layout = QVBoxLayout()
        tmp2Layout.addLayout(tmpLayout)
        tmp2Layout.addWidget(self.bomb)
        tmp2Layout.addSpacerItem(QSpacerItem(40, 40, QSizePolicy.Expanding))

        self.setLayout(tmp2Layout)
        self.blockValueSignal = False  # if this is true, valueChanged signal is not evaluated
        if self.forceSpinBoxWidget:
            self.sb_hours.valueChanged.connect(self.onValueChanged)
            self.sb_minutes.valueChanged.connect(self.onValueChanged)
        else:
            self.sb_hours_obj.currentIndexChanged.connect(self.onValueChanged)
            self.sb_minutes_obj.currentIndexChanged.connect(self.onValueChanged)


        # setup Timer which is started as soon as a value is changed in any of the spinboxes
        self.timer = QTimer()
        self.timer.setSingleShot(True)
        self.timer.setInterval(2000)  # 2 seconds until timer starts automatically
        self.connect(self.timer, SIGNAL("timeout()"), self.activate)

        #setup Timer which is a second-timer. It is startet with the self.timer (see self.active)
        self.countDown = QTimer()
        self.countDown.setInterval(1000) #sec
        self.connect(self.countDown, SIGNAL("timeout()"), self.check)
コード例 #53
0
class SleepTimer(QWidget):
    '''
    A resizable Widget with two Spinboxes Labeled with "h" and "min", also a Time-bomb containing a countdownclock.
    If a spinbox is changed, start is triggered. After 2 Seconds, countdown is startet.
    When countdown ends, signal "sleepTimerelapsed()" is emitted.
    '''
    sleepTimerelapsed = pyqtSignal()
    sleepTimertenseconds = pyqtSignal()

    def __init__(self, parent=None):
        super(SleepTimer, self).__init__(parent)
        self.forceSpinBoxWidget = global_vars.configuration.get("GENERAL").get(
            "sleeptimerdigitalspinbox")
        self.setStyleSheet(
            "SleepTimer {"
            "background-color: rgb(76, 76, 76);"
            "color: rgb(240, 240, 240);"
            "}"
            "QLabel {"
            "color: white;"
            "}"
            "QSpinBox {"
            "padding-right: 10px; /* make room for the arrows */"
            "border-width: 3;"
            "}"
            "QSpinBox::up-button {"
            "width: 26px;"
            "}"
            "QSpinBox::down-button {"
            "width: 26px;"
            "}")
        self.value = 0  # the value is calculated in self.active (calculated seconds in total)
        self.isActive = False

        if self.forceSpinBoxWidget:
            self.sb_hours = LeadingZeroSpinBox()
            self.sb_hours.setRange(0, 23)
            self.sb_hours.setAlignment(Qt.AlignCenter)
            self.sb_hours.setSizePolicy(QSizePolicy.Expanding,
                                        QSizePolicy.Expanding)
        else:
            self.sb_hours = QDeclarativeView()
            self.sb_hours.setSource(QUrl(os.path.join(cwd, 'sb_hours.qml')))
            self.sb_hours.setResizeMode(QDeclarativeView.SizeViewToRootObject)
            self.sb_hours.setStyleSheet("background:transparent;")
            self.sb_hours.setSizePolicy(QSizePolicy.Expanding,
                                        QSizePolicy.Expanding)

            self.sb_hours_obj = self.sb_hours.rootObject().findChild(
                QObject, "spinner")
            self.sb_hours_value = QDeclarativeProperty(
                self.sb_hours.rootObject().findChild(QDeclarativeItem,
                                                     name="spinner"),
                "currentIndex")

        if self.forceSpinBoxWidget:
            self.sb_minutes = LeadingZeroSpinBox()
            self.sb_minutes.setRange(0, 59)
            self.sb_minutes.setAlignment(Qt.AlignCenter)
            self.sb_minutes.setSizePolicy(QSizePolicy.Expanding,
                                          QSizePolicy.Expanding)
        else:
            self.sb_minutes = QDeclarativeView()
            self.sb_minutes.setSource(QUrl(os.path.join(cwd,
                                                        'sb_minutes.qml')))
            self.sb_minutes.setResizeMode(
                QDeclarativeView.SizeViewToRootObject)
            self.sb_minutes.setStyleSheet("background:transparent;")
            self.sb_minutes.setSizePolicy(QSizePolicy.Expanding,
                                          QSizePolicy.Expanding)

            self.sb_minutes_obj = self.sb_minutes.rootObject().findChild(
                QObject, "spinner")
            self.sb_minutes_value = QDeclarativeProperty(
                self.sb_minutes.rootObject().findChild(QDeclarativeItem,
                                                       name="spinner"),
                "currentIndex")

        tmpFont = QFont()
        tmpFont.setPointSize(18)
        self.lbl_hours = QLabel(QString("h"))
        self.lbl_hours.setFont(tmpFont)
        self.lbl_minutes = QLabel(QString("min"))
        self.lbl_minutes.setFont(tmpFont)

        # Load QML Widget Bomb
        self.bomb = QDeclarativeView()
        self.bomb.setSource(QUrl(os.path.join(cwd, 'timebomb.qml')))
        self.bomb.setResizeMode(QDeclarativeView.SizeViewToRootObject)
        #self.bomb.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.bomb.setStyleSheet("background:transparent;")
        self.bomb_text = QDeclarativeProperty(
            self.bomb.rootObject().findChild(QDeclarativeItem,
                                             name="counter_text"), "text")

        #setup layouts
        tmpLayout = QHBoxLayout()
        tmpLayout.addSpacerItem(QSpacerItem(40, 40, QSizePolicy.Expanding))
        tmpLayout.addWidget(self.sb_hours)
        tmpLayout.addWidget(self.lbl_hours)
        tmpLayout.addWidget(self.sb_minutes)
        tmpLayout.addWidget(self.lbl_minutes)
        tmpLayout.addSpacerItem(QSpacerItem(40, 40, QSizePolicy.Expanding))

        tmp2Layout = QVBoxLayout()
        tmp2Layout.addLayout(tmpLayout)
        tmp2Layout.addWidget(self.bomb)
        tmp2Layout.addSpacerItem(QSpacerItem(40, 40, QSizePolicy.Expanding))

        self.setLayout(tmp2Layout)
        self.blockValueSignal = False  # if this is true, valueChanged signal is not evaluated
        if self.forceSpinBoxWidget:
            self.sb_hours.valueChanged.connect(self.onValueChanged)
            self.sb_minutes.valueChanged.connect(self.onValueChanged)
        else:
            self.sb_hours_obj.currentIndexChanged.connect(self.onValueChanged)
            self.sb_minutes_obj.currentIndexChanged.connect(
                self.onValueChanged)

        # setup Timer which is started as soon as a value is changed in any of the spinboxes
        self.timer = QTimer()
        self.timer.setSingleShot(True)
        self.timer.setInterval(
            2000)  # 2 seconds until timer starts automatically
        self.connect(self.timer, SIGNAL("timeout()"), self.activate)

        #setup Timer which is a second-timer. It is startet with the self.timer (see self.active)
        self.countDown = QTimer()
        self.countDown.setInterval(1000)  #sec
        self.connect(self.countDown, SIGNAL("timeout()"), self.check)

    def onValueChanged(self):

        if self.forceSpinBoxWidget:
            value_sb_hours = self.sb_hours.value()
            value_sb_minutes = self.sb_minutes.value()
        else:
            value_sb_hours = self.sb_hours_value.read().toInt()[0]
            value_sb_minutes = self.sb_minutes_value.read().toInt()[0]

        if self.blockValueSignal:
            return

        if value_sb_hours == 0 and value_sb_minutes == 0:
            logger.info("Stop Timer")
            self.bomb_text.write("Abbruch")
            self.timer.stop()
            self.countDown.stop()
            self.isActive = False
            return

        if self.countDown.isActive():
            self.countDown.stop()

        if self.timer.isActive():
            self.timer.stop()
            self.timer.start()
        else:
            self.timer.start()

    def activate(self):
        #print("Activated")
        self.isActive = True
        self.countDown.start()
        if self.forceSpinBoxWidget:
            self.value = self.sb_hours.value(
            ) * 60 * 60 + self.sb_minutes.value() * 60
        else:
            self.value = self.sb_hours_value.read().toInt(
            )[0] * 60 * 60 + self.sb_minutes_value.read().toInt()[0] * 60

    def check(self):
        #print("check")
        self.value -= 1
        if self.value == 0:
            #print("Der Timer ist abgelaufen")
            self.bomb_text.write(" Boom!")
            self.sleepTimerelapsed.emit()
            self.countDown.stop()
            self.isActive = False
        elif self.value == 10:
            self.sleepTimertenseconds.emit()
        else:
            m, s = divmod(self.value, 60)
            h, m = divmod(m, 60)
            text = "%02d:%02d:%02d" % (h, m, s)
            #self.lbl_countdown.setText(text)
            self.bomb_text.write(text)
            self.blockValueSignal = True
            if self.forceSpinBoxWidget:
                self.sb_hours.setValue(h)
                self.sb_minutes.setValue(m)
            else:
                self.sb_minutes_value.write(m)
                self.sb_hours_value.write(h)  # = h
            self.blockValueSignal = False

    def stop(self, silent=True):
        if not silent:
            self.bomb_text.write("Abbruch")
        else:
            self.bomb_text.write("00:00:00")
        self.timer.stop()
        self.countDown.stop()
        self.blockValueSignal = True
        if self.forceSpinBoxWidget:
            self.sb_hours.setValue(0)
            self.sb_minutes.setValue(0)
        else:
            self.sb_minutes_value.write(0)
            self.sb_hours_value.write(0)
        self.blockValueSignal = False
        self.isActive = False