Ejemplo n.º 1
0
	def __init__(self, parent=None):
		super().__init__(parent)
		self.parent_widget = parent
		self.setViewMode(self.IconMode)
		self.setResizeMode(self.Adjust)
		self.setWrapping(True)
		# all items have the same size (perfomance)
		self.setUniformItemSizes(True)
		# improve scrolling
		self.setAutoScroll(True)
		self.setVerticalScrollMode(self.ScrollPerPixel)
		self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
		self.setLayoutMode(self.Batched)
		self.setMouseTracking(True)
		self.setAcceptDrops(True)
		self.setDragEnabled(True)
		self.viewport().setAcceptDrops(True)
		self.setDropIndicatorShown(True)
		self.setDragDropMode(self.DragDrop)

		self.sort_model = SortFilterModel(self)
		self.sort_model.setDynamicSortFilter(True)
		self.sort_model.setFilterCaseSensitivity(Qt.CaseInsensitive)
		self.sort_model.setSortLocaleAware(True)
		self.sort_model.setSortCaseSensitivity(Qt.CaseInsensitive)
		self.manga_delegate = GridDelegate(parent)
		self.setItemDelegate(self.manga_delegate)
		self.setSpacing(app_constants.GRID_SPACING)
		self.setFlow(QListView.LeftToRight)
		self.setIconSize(QSize(self.manga_delegate.W, self.manga_delegate.H))
		self.setSelectionBehavior(self.SelectItems)
		self.setSelectionMode(self.ExtendedSelection)
		self.gallery_model = GalleryModel(parent)
		self.gallery_model.db_emitter.DONE.connect(self.sort_model.setup_search)
		self.sort_model.change_model(self.gallery_model)
		self.sort_model.sort(0)
		self.sort_model.ROWCOUNT_CHANGE.connect(self.gallery_model.ROWCOUNT_CHANGE.emit)
		self.setModel(self.sort_model)
		self.SERIES_DIALOG.connect(self.spawn_dialog)
		self.doubleClicked.connect(lambda idx: idx.data(Qt.UserRole+1).chapters[0].open())
		self.setViewportMargins(0,0,0,0)

		self.gallery_window = misc.GalleryMetaWindow(parent if parent else self)
		self.gallery_window.arrow_size = (10,10,)
		self.clicked.connect(lambda idx: self.gallery_window.show_gallery(idx, self))

		self.current_sort = app_constants.CURRENT_SORT
		self.sort(self.current_sort)
		if app_constants.DEBUG:
			def debug_print(a):
				g = a.data(Qt.UserRole+1)
				try:
					print(g)
				except:
					print("{}".format(g).encode(errors='ignore'))
				#log_d(gallerydb.HashDB.gen_gallery_hash(g, 0, 'mid')['mid'])

			self.clicked.connect(debug_print)

		self.k_scroller = QScroller.scroller(self)
Ejemplo n.º 2
0
	def __init__(self, parent=None):
		super().__init__(parent)
		# options
		self.parent_widget = parent
		self.setAcceptDrops(True)
		self.setDragEnabled(True)
		self.viewport().setAcceptDrops(True)
		self.setDropIndicatorShown(True)
		self.setDragDropMode(self.DragDrop)
		self.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
		self.setSelectionBehavior(self.SelectRows)
		self.setSelectionMode(self.ExtendedSelection)
		self.setShowGrid(True)
		self.setSortingEnabled(True)
		h_header = self.horizontalHeader()
		h_header.setSortIndicatorShown(True)
		v_header = self.verticalHeader()
		v_header.sectionResizeMode(QHeaderView.Fixed)
		v_header.setDefaultSectionSize(24)
		v_header.hide()
		palette = self.palette()
		palette.setColor(palette.Highlight, QColor(88, 88, 88, 70))
		palette.setColor(palette.HighlightedText, QColor('black'))
		self.setPalette(palette)
		self.setIconSize(QSize(0,0))
		self.doubleClicked.connect(lambda idx: idx.data(Qt.UserRole+1).chapters[0].open())
		self.grabGesture(Qt.SwipeGesture)
		self.k_scroller = QScroller.scroller(self)
Ejemplo n.º 3
0
    def keyUI(self, syms, keystack):
        layout = QGridLayout()
        scroll = QScrollArea()
        scroll.setWidgetResizable(True)
        widget = QWidget()
        vbox = QVBoxLayout()
        widget.setLayout(layout)
        btn_list = []
        positions = [(i, j) for i in range(int(len(syms) / 4) + 1)
                     for j in range(4)]
        for position, name in zip(positions, syms):
            kbtn = QPushButton(name)
            kbtn.setMinimumSize(QtCore.QSize(50, 50))
            kbtn.setStyleSheet(self.btnstyle)
            layout.addWidget(kbtn, *position)
            kbtn.clicked.connect(partial(self.all_keys_list, name, kbtn,
                                         'key'))
        scroll.setWidget(widget)

        qs = QScroller.scroller(scroll.viewport())
        props = qs.scrollerProperties()
        props.setScrollMetric(QScrollerProperties.DecelerationFactor, 0.35)
        props.setScrollMetric(QScrollerProperties.DragStartDistance, .001)
        qs.setScrollerProperties(props)
        qs.grabGesture(scroll.viewport(), QScroller.TouchGesture)

        vbox.addWidget(scroll)
        keystack.setLayout(vbox)
Ejemplo n.º 4
0
    def _setup_scroll_bars(self):
        """Set the properties of all scroll bars

        Scroll bars are selected based on a unique prefix and a common suffix.
        Example: dairy + ListWidget, where the 'ListWidget' suffix is the same for all other list widgets.

        """
        for widget_prefix in settings.ALL_SCROLLABLE_LIST_WIDGETS_PREFIXES:

            list_widget = self.stacked_widget.findChild(QtWidgets.QWidget, widget_prefix + "Page")\
                .findChild(QtWidgets.QListWidget, widget_prefix + "ListWidget")

            sp = QScrollerProperties()
            sp.setScrollMetric(QScrollerProperties.DragVelocitySmoothingFactor,
                               0.6)
            sp.setScrollMetric(QScrollerProperties.MinimumVelocity, 0.0)
            sp.setScrollMetric(QScrollerProperties.MaximumVelocity, 0.2)
            sp.setScrollMetric(
                QScrollerProperties.AcceleratingFlickMaximumTime, 0.1)
            sp.setScrollMetric(
                QScrollerProperties.AcceleratingFlickSpeedupFactor, 1.2)
            sp.setScrollMetric(QScrollerProperties.SnapPositionRatio, 0.2)
            sp.setScrollMetric(QScrollerProperties.MaximumClickThroughVelocity,
                               1)
            sp.setScrollMetric(QScrollerProperties.DragStartDistance, 0.001)
            sp.setScrollMetric(QScrollerProperties.HorizontalOvershootPolicy,
                               1)
            sp.setScrollMetric(QScrollerProperties.VerticalOvershootPolicy, 1)

            scroller = QScroller.scroller(list_widget.viewport())
            scroller.setScrollerProperties(sp)
            scroller.grabGesture(list_widget.viewport(),
                                 QScroller.LeftMouseButtonGesture)
Ejemplo n.º 5
0
	def __init__(self, window):
		super().__init__()
		self.setupUi(self)
		
		# API init.
		self.control = api.control()

		# Panel init.
		self.setFixedSize(window.app.primaryScreen().virtualSize())
		self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
		self.setAttribute(QtCore.Qt.WA_TranslucentBackground, True)
		
		#Substitute constants into header bit.
		self.control.get(['cameraModel', 'cameraMemoryGB', 'sensorColorPattern', 'cameraSerial', 'cameraApiVersion', 'cameraFpgaVersion']).then(
			lambda values:
				self.uiText.setText(
					self.uiText.text()
					.replace('{MODEL}', f"{values['cameraModel']}, {values['cameraMemoryGB']}, {'mono' if values['sensorColorPattern'] == 'mono' else 'color'}")
					.replace('{SERIAL_NUMBER}', values['cameraSerial'])
					.replace('{UI_VERSION}', appVersion)
					.replace('{API_VERSION}', values['cameraApiVersion'])
					.replace('{FPGA_VERSION}', values['cameraFpgaVersion'])
				)
		)
		settings.observe('theme', 'dark', lambda name: (
			self.uiScrollArea.setStyleSheet(f"""
				color: {theme(name).text};
				background: {theme(name).base};
				border: 1px solid {theme(name).border};
			"""),
			self.uiText.setStyleSheet(f"""
				border: none;
				padding: 5px;
			""")
		))
		
		# Set scroll bar to scroll all text content. 
		self.uiScroll.setMaximum( 
			self.uiText.height() - self.uiScrollArea.height() )
		
		#Add drag-to-scroll to text content.
		self.uiScrollArea.setFocusPolicy(QtCore.Qt.NoFocus)
		QScroller.grabGesture(self.uiScrollArea.viewport(), QScroller.LeftMouseButtonGesture) #DDR 2019-01-15: Defaults to TouchGesture - which should work, according to WA_AcceptTouchEvents, but doesn't.
		scroller = QScroller.scroller(self.uiScrollArea.viewport())
		properties = scroller.scrollerProperties()
		properties.setScrollMetric(properties.AxisLockThreshold, 0.0)
		properties.setScrollMetric(properties.MousePressEventDelay, 0.0)
		properties.setScrollMetric(properties.DragStartDistance, 0.0) #default: 0.005 - tweaked for "feel", the platform defaults are overly dramatic.
		properties.setScrollMetric(properties.OvershootDragDistanceFactor, 0.3) #default: 1
		properties.setScrollMetric(properties.OvershootScrollDistanceFactor, 0.3) #default: 1
		properties.setScrollMetric(properties.OvershootScrollTime, 0.5) #default: 0.7
		scroller.setScrollerProperties(properties)
		
		# Button binding.
		self.uiScroll.valueChanged.connect(self.scrollPane)
		self.uiScrollArea.verticalScrollBar().valueChanged.connect(self.scrollKnob)
		
		self.uiDone.clicked.connect(window.back)
Ejemplo n.º 6
0
	def __init__(self, parent=None):
		super().__init__(parent)
		self.parent_widget = parent
		self.setViewMode(self.IconMode)
		self.H = app_constants.GRIDBOX_H_SIZE
		self.W = app_constants.GRIDBOX_W_SIZE
		self.setGridSize(QSize(self.W, self.H))
		self.setResizeMode(self.Adjust)
		self.setIconSize(QSize(app_constants.THUMB_W_SIZE,
						 app_constants.THUMB_H_SIZE))
		# all items have the same size (perfomance)
		self.setUniformItemSizes(True)
		# improve scrolling
		self.setVerticalScrollMode(self.ScrollPerPixel)
		self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
		self.setLayoutMode(self.SinglePass)
		self.setBatchSize(1)#app_constants.PREFETCH_ITEM_AMOUNT)
		self.setMouseTracking(True)
		self.sort_model = SortFilterModel()
		self.sort_model.setDynamicSortFilter(True)
		self.sort_model.setFilterCaseSensitivity(Qt.CaseInsensitive)
		self.sort_model.setSortLocaleAware(True)
		self.sort_model.setSortCaseSensitivity(Qt.CaseInsensitive)
		self.manga_delegate = CustomDelegate(parent)
		self.setItemDelegate(self.manga_delegate)
		self.setSelectionBehavior(self.SelectItems)
		self.setSelectionMode(self.ExtendedSelection)
		self.gallery_model = GalleryModel(parent)
		self.gallery_model.db_emitter.DONE.connect(self.sort_model.setup_search)
		self.sort_model.change_model(self.gallery_model)
		self.sort_model.sort(0)
		self.sort_model.ROWCOUNT_CHANGE.connect(self.gallery_model.ROWCOUNT_CHANGE.emit)
		self.setModel(self.sort_model)
		self.SERIES_DIALOG.connect(self.spawn_dialog)
		self.doubleClicked.connect(lambda idx: idx.data(Qt.UserRole+1).chapters[0].open())
		self.setViewportMargins(0,0,0,0)

		self.gallery_window = misc.GalleryMetaWindow(parent if parent else self)
		self.gallery_window.arrow_size = (10,10,)
		self.clicked.connect(lambda idx: self.gallery_window.show_gallery(idx, self))

		self.current_sort = app_constants.CURRENT_SORT
		self.sort(self.current_sort)
		if app_constants.DEBUG:
			def debug_print(a):
				try:
					print(a.data(Qt.UserRole+1))
				except:
					print("{}".format(a.data(Qt.UserRole+1)).encode(errors='ignore'))

			self.clicked.connect(debug_print)

		#self.viewport().grabGesture(Qt.SwipeGesture)
		self.k_scroller = QScroller.scroller(self)
Ejemplo n.º 7
0
    def __init__(self, 社員: 社員, 予約画面: 食事予約):
        super(Window, self).__init__()
        self.setAttribute(Qt.WA_DeleteOnClose)
        self.load_ui()
        self.予約画面 = 予約画面
        self.社員 = 社員
        self.ui.btnGoBack.clicked.connect(lambda: self.quit(withParent=False))
        self.ui.btnOpenReserve.clicked.connect(
            lambda: self.quit(withParent=True))
        self.ui.tableWidget.itemClicked.connect(self.reserve)
        self.plot_data()

        # タッチスクロール設定
        QScroller.grabGesture(self.ui.tableWidget,
                              QScroller.LeftMouseButtonGesture)
        scroller = QScroller.scroller(self.ui.tableWidget)
        props = scroller.scrollerProperties()
        props.setScrollMetric(QScrollerProperties.MaximumVelocity, 0.5)
        scroller.setScrollerProperties(props)
    def __init__(self):
        super().__init__()
        self.hbox = QHBoxLayout()

        # Create the list
        self.mylist = QListWidget()
        self.mylist.setStyleSheet(
            "QListWidget::item { border-bottom: 1px solid gray; }")
        self.mylist.setFocusPolicy(Qt.NoFocus)
        self.mylist.setSelectionMode(QAbstractItemView.NoSelection)
        self.mylist.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.mylist.setVerticalScrollMode(QAbstractItemView.ScrollPerPixel)

        for i in range(19, 0, -1):
            item = QListWidgetItem(self.mylist)
            self.mylist.addItem(item)
            self.mylist.setItemWidget(item, QLabel(str(i)))

        self.sp = QScrollerProperties()
        self.sp.setScrollMetric(
            QScrollerProperties.DragVelocitySmoothingFactor, 0.6)
        self.sp.setScrollMetric(QScrollerProperties.MinimumVelocity, 0.0)
        self.sp.setScrollMetric(QScrollerProperties.MaximumVelocity, 0.2)
        self.sp.setScrollMetric(
            QScrollerProperties.AcceleratingFlickMaximumTime, 0.1)
        self.sp.setScrollMetric(
            QScrollerProperties.AcceleratingFlickSpeedupFactor, 1.2)
        self.sp.setScrollMetric(QScrollerProperties.SnapPositionRatio, 0.2)
        self.sp.setScrollMetric(
            QScrollerProperties.MaximumClickThroughVelocity, 1)
        self.sp.setScrollMetric(QScrollerProperties.DragStartDistance, 0.001)
        self.sp.setScrollMetric(QScrollerProperties.MousePressEventDelay, 0.5)

        self.scroller = QScroller.scroller(self.mylist.viewport())
        self.scroller.setScrollerProperties(self.sp)
        self.scroller.grabGesture(self.mylist.viewport(),
                                  QScroller.LeftMouseButtonGesture)

        self.mylist.show()
        self.hbox.addWidget(self.mylist)
        self.setLayout(self.hbox)
Ejemplo n.º 9
0
	def __init__(self, parent=None):
		super().__init__(parent)
		# options
		self.parent_widget = parent
		self.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
		self.setSelectionBehavior(self.SelectRows)
		self.setSelectionMode(self.ExtendedSelection)
		self.setShowGrid(True)
		self.setSortingEnabled(True)
		v_header = self.verticalHeader()
		v_header.sectionResizeMode(QHeaderView.Fixed)
		v_header.setDefaultSectionSize(24)
		v_header.hide()
		palette = self.palette()
		palette.setColor(palette.Highlight, QColor(88, 88, 88, 70))
		palette.setColor(palette.HighlightedText, QColor('black'))
		self.setPalette(palette)
		self.setIconSize(QSize(0,0))
		self.doubleClicked.connect(lambda idx: idx.data(Qt.UserRole+1).chapters[0].open())
		self.grabGesture(Qt.SwipeGesture)
		self.k_scroller = QScroller.scroller(self)
		self.k_scroller.grabGesture(self, QScroller.TouchGesture)
Ejemplo n.º 10
0
	def __init__(self, parent=None):
		super().__init__(parent)
		self._customStyleSheet = ''
		self._useInlineSelectMode = False
		self.setStyle(QStyleFactory.create('Fusion')) #Fix bug where scrollbar background is stippled.
		
		settings.observe('theme', 'dark', lambda name: (
			setattr(self, 'theme', theme(name)),
			self.refreshStyle(),
		))
		
		#Set up scroll on jogwheel.
		self.setMouseTracking(False) #Something do do with the scroller?
		self.setUniformItemSizes(True) #This enables the view to do some optimizations for performance purposes.
		self.setHorizontalScrollMode(self.ScrollPerPixel) #Make grab gesture work, otherwise moves dropdown 1 entry per pixel dragged.
		self.setVerticalScrollMode(self.ScrollPerPixel)
		self.setAttribute(Qt.WA_AcceptTouchEvents, True) #Enable touch gestures according to http://doc.qt.io/qt-5/qtouchevent.html#enabling-touch-events, which appears to be lieing.
		self.setDragDropMode(self.NoDragDrop)
		self.setMovement(self.Static)
		
		#Only works in Qt ≥ v5.10.
		#self.jogWheelClick.connect(lambda: self.injectKeystrokes(Qt.Key_Enter))
		
		self.jogWheelClick.connect(self.onJogWheelClick)
		self.jogWheelLowResolutionRotation.connect(self.onJogWheelRotate)
		
		#Add drag-to-scroll to dropdown menus.
		QScroller.grabGesture(self.viewport(), QScroller.LeftMouseButtonGesture) #DDR 2019-01-15: Defaults to TouchGesture - which should work, according to WA_AcceptTouchEvents, but doesn't.
		scroller = QScroller.scroller(self.viewport())
		properties = scroller.scrollerProperties()
		properties.setScrollMetric(properties.AxisLockThreshold, 0.0)
		properties.setScrollMetric(properties.DragStartDistance, 0.010) #default: 0.005 - Set to 0.010, since if the scroll starts horizontally it goes into a weird selection mode. Initially tweaked for "feel" to 0.003, before knowledge of this issue.
		properties.setScrollMetric(properties.OvershootDragDistanceFactor, 0.3) #default: 1
		properties.setScrollMetric(properties.OvershootScrollDistanceFactor, 0.3) #default: 1
		properties.setScrollMetric(properties.OvershootScrollTime, 0.5) #default: 0.7
		scroller.setScrollerProperties(properties)
Ejemplo n.º 11
0
    def __init__(self):
        #super(Music_Player, self).__init__()
        super().__init__()
        #set up the user interface from Designer
        self.setupUi(self)

        # this gets the inforation needed for the table
        lib = []
        directory = os.path.join(Music_Player.home_dir, "Music")

        walk = os.walk(directory)
        for root, dirs, files in walk:
            for file in files:
                path = os.path.join(root, file)
                if file.endswith(
                        '.mp3'):  # then we should add file to library\
                    song = os.path.splitext(file)[0]
                    song = song.replace('_', ' ')

                    # using eyed3 to get song info
                    audiofile = eyed3.load(path)
                    artist = audiofile.tag.artist
                    album = audiofile.tag.album
                    length_secs = audiofile.info.time_secs  # seconds
                    length_formatted = seconds_to_minutes(length_secs)

                    # list of lists with information
                    lib.append([
                        song, artist, album, length_formatted, path,
                        str(length_secs)
                    ])  # length shows seconds

        # usedfor the functions
        self.library = lib

        self.songTableWidget_tab3.setRowCount(len(lib))
        self.songTableWidget_2.setRowCount(len(lib))
        self.songTableWidget.setRowCount(len(lib))
        self.songTableWidget.setColumnHidden(4, True)  #hide path column
        self.songTableWidget.setColumnHidden(
            5, True)  #hide length column that shows seconds
        self.songTableWidget_2.setColumnHidden(4, True)  #hide path column
        self.songTableWidget_2.setColumnHidden(
            5, True)  #hide length column that shows seconds
        self.songTableWidget_tab3.setColumnHidden(4, True)  #hide path column
        self.songTableWidget_tab3.setColumnHidden(
            5, True)  #hide length column that shows seconds
        self.songTableWidget.setEditTriggers(
            QAbstractItemView.NoEditTriggers)  # no way to edit items
        self.songTableWidget_tab3.setEditTriggers(
            QAbstractItemView.NoEditTriggers)

        # setting the column widths
        self.songTableWidget.setColumnWidth(0, 220)
        self.songTableWidget.setColumnWidth(1, 160)
        self.songTableWidget.setColumnWidth(2, 165)
        self.songTableWidget.setColumnWidth(3, 60)

        # setting up touch scrolling for the songTableWidget
        scroller = QScroller.scroller(self.songTableWidget)
        QScroller.grabGesture(self.songTableWidget,
                              QScroller.LeftMouseButtonGesture)

        # setting up touch scrolling for the playlistTableWidget_2
        scroller_playlist_2 = QScroller.scroller(self.playlistTableWidget_2)
        QScroller.grabGesture(self.playlistTableWidget_2,
                              QScroller.LeftMouseButtonGesture)

        # setting up touch scrolling for the songTableWidget_2
        scroller_2 = QScroller.scroller(self.songTableWidget_2)
        QScroller.grabGesture(self.songTableWidget_2,
                              QScroller.LeftMouseButtonGesture)

        # setting up touch scrolling for the songTableWidget_tab3
        scroller_3 = QScroller.scroller(self.songTableWidget_tab3)
        QScroller.grabGesture(self.songTableWidget_tab3,
                              QScroller.LeftMouseButtonGesture)

        # populating the table
        for i in range(len(lib)):  #number of rows
            for k in range(6):  # there are 6 columns
                item = QTableWidgetItem(lib[i][k])
                item2 = QTableWidgetItem(lib[i][k])
                item3 = QTableWidgetItem(lib[i][k])
                self.songTableWidget.setItem(i, k, item)
                self.songTableWidget_tab3.setItem(i, k, item2)  # for tab3
                self.songTableWidget_2.setItem(i, k, item3)

        self.songTableWidget.sortItems(0, Qt.AscendingOrder)
        self.songTableWidget_tab3.sortItems(0, Qt.AscendingOrder)  # tab 3

        # add the check mark boxes so they don't only appear when the song is played for the first time
        for i in range(self.songTableWidget.rowCount()):
            self.songTableWidget.item(i, 0).setCheckState(Qt.Unchecked)
            self.songTableWidget_2.item(i, 0).setCheckState(Qt.Unchecked)

        # setting up media Player
        self.player = QMediaPlayer(None)

        if not os.path.exists("log.txt"):
            with open("log.txt", 'w') as f:
                pass
        # the time doesn't work but the row does
        # this will load the last song played into the media player, though time will start from 0
        with open("log.txt", 'r') as f:
            info = f.read()

        if info:
            row = int(info.split(',')[0])
            self.time = int(
                info.split(',')[1]
            )  # used in mediaStatusChanged to allow for the startup time
            song_path = self.songTableWidget.item(row, 4).text()
            self.player.setMedia(QMediaContent(QUrl.fromLocalFile(song_path)))
            #self.player.play()

            # used by mediaStatusChanged to load in the correct place the player left off from
            #self.startup = 1

        else:
            row = 0
            default_song_path = self.songTableWidget.item(0, 4).text()
            self.player.setMedia(
                QMediaContent(QUrl.fromLocalFile(default_song_path)))

        # make adjustments
        self.volumeSlider.setMaximum(100)
        self.volumeSlider.setSliderPosition(100)
        self.volumeLabel.setText(str(100))

        self.songSlider.setMinimum(0)
        self.songSlider.setMaximum(
            int(self.songTableWidget.item(row, 5).text()))

        self.endLabel.setText(self.songTableWidget.item(row, 3).text())
        self.songPlayingLabel.setText(self.songTableWidget.item(row, 0).text())

        # tab 3 signals and slots
        self.saveButton_tab3.clicked.connect(self.save_click)
        self.searchEdit_tab3.textChanged.connect(self.search_edit)

        #conncect buttons
        self.volumeSlider.valueChanged.connect(self.volume_change)
        self.playButton.clicked.connect(self.play_click)
        self.songTableWidget.cellDoubleClicked.connect(self.double_click)
        self.player.stateChanged.connect(
            self.state_changed)  # playing, paused, no media
        self.player.positionChanged.connect(self.position_changed)
        self.player.mediaStatusChanged.connect(
            self.media_status)  # #loading media, end of media, etc.
        self.player.currentMediaChanged.connect(
            self.song_changed)  # when the song changes
        self.songSlider.sliderMoved.connect(self.slider_moved)
        self.songSlider.sliderReleased.connect(self.slider_released)
        self.nextButton.clicked.connect(self.next)
        self.prevButton.clicked.connect(self.prev)

        ##################################################################
        ###########################################################
        #################### tab 2 #############################\

        self.finaldeleteButton_2.setVisible(False)

        self.player_2 = QMediaPlayer(None)
        self.player_2.setVolume(100)

        # make adjustments
        self.volumeSlider_2.setMaximum(100)
        self.volumeSlider_2.setSliderPosition(100)
        self.volumeLabel_2.setText(str(100))

        self.endLabel_2.setText(self.songTableWidget_2.item(0, 3).text())
        self.songPlayingLabel_2.setText(
            self.songTableWidget_2.item(0, 0).text())

        self.playlistTableWidget_2.setEditTriggers(
            QAbstractItemView.NoEditTriggers)
        self.songTableWidget_2.setEditTriggers(
            QAbstractItemView.NoEditTriggers)

        #conncect buttons
        self.volumeSlider_2.valueChanged.connect(self.volume_change_2)
        self.playButton_2.clicked.connect(self.play_click_2)
        self.songTableWidget_2.cellDoubleClicked.connect(self.double_click_2)
        self.player_2.stateChanged.connect(
            self.state_changed_2)  # playing, paused, no media
        self.player_2.positionChanged.connect(self.position_changed_2)
        self.player_2.mediaStatusChanged.connect(
            self.media_status_2)  # #loading media, end of media, etc.
        self.player_2.currentMediaChanged.connect(
            self.song_changed_2)  # when the song changes
        self.songSlider_2.sliderMoved.connect(self.slider_moved_2)
        self.songSlider_2.sliderReleased.connect(self.slider_released_2)
        self.nextButton_2.clicked.connect(self.next_2)
        self.prevButton_2.clicked.connect(self.prev_2)

        # if there are playlists present on the system we want to list them
        files = os.listdir(Music_Player.home_dir +
                           "/Desktop/music_player/playlists")
        if files:
            self.playlistTableWidget_2.setRowCount(len(files))
            playlist_names = [os.path.splitext(file)[0] for file in files]

            x = 0
            for file in files:
                with open(
                        Music_Player.home_dir +
                        '/Desktop/music_player/playlists/{}'.format(file),
                        'r') as f:
                    lines = f.readlines()
                    amount_of_songs = lines[-2]
                    date_added = lines[-1]
                playlist_name = os.path.splitext(file)[0]
                item_1 = QTableWidgetItem(playlist_name)
                item_2 = QTableWidgetItem(amount_of_songs)
                item_3 = QTableWidgetItem(date_added)
                self.playlistTableWidget_2.setItem(x, 0, item_1)
                self.playlistTableWidget_2.setItem(x, 1, item_2)
                self.playlistTableWidget_2.setItem(x, 2, item_3)
                x = x + 1

        self.playlistTableWidget_2.cellDoubleClicked.connect(
            self.choose_playlist)
        self.playlist_button_2.clicked.connect(self.back_to_playlists)
        self.deleteButton_2.clicked.connect(self.delete_button_2)
        self.finaldeleteButton_2.clicked.connect(self.finaldelete_clicked_2)
Ejemplo n.º 12
0
    def initUI(self):
        applyButton = QPushButton(" Apply ")
        quitButton = QPushButton(" Quit ")
        cancelButton = QPushButton(" Cancel ")
        defaultsButton = QPushButton(" Restore Defaults ")
        settingsButton = QPushButton(" Settings ")
        newButton = QPushButton(" NewButton ")
        helpButton = QPushButton(" Help ")

        cancelButton.clicked.connect(self.cancel_layout)
        applyButton.clicked.connect(self.on_apply_clicked)
        defaultsButton.clicked.connect(self.restore_defaults)
        quitButton.clicked.connect(self.parent.quithandler)
        settingsButton.clicked.connect(self.parent.show_settings_window)
        newButton.clicked.connect(self.show_new_button_dialog)
        helpButton.clicked.connect(self.show_help_button_dialog)

        cancelButton.setIcon(QIcon.fromTheme("window-close"))
        defaultsButton.setIcon(QIcon.fromTheme("view-refresh"))
        quitButton.setIcon(QIcon.fromTheme("application-exit"))
        applyButton.setIcon(QIcon.fromTheme("document-save"))
        settingsButton.setIcon(QIcon.fromTheme("preferences-other"))
        helpButton.setIcon(QIcon.fromTheme("help-contents"))
        newButton.setIcon(QIcon.fromTheme("list-add"))

        cancelButton.setMinimumHeight(50)
        applyButton.setMinimumHeight(50)
        defaultsButton.setMinimumHeight(50)
        quitButton.setMinimumHeight(50)
        settingsButton.setMinimumHeight(50)
        newButton.setMinimumHeight(50)
        helpButton.setMinimumHeight(50)

        scroll = QScrollArea()
        scroll.setWidgetResizable(True)
        widget = QWidget()
        vlayout = QVBoxLayout()

        hbox = QHBoxLayout()
        hbox.addWidget(quitButton)
        hbox.addWidget(helpButton)
        hbox.addWidget(defaultsButton)
        hbox.addWidget(settingsButton)
        hbox.addWidget(newButton)
        hbox.addStretch(1)
        hbox.addWidget(cancelButton)
        hbox.addWidget(applyButton)

        titlebox = QHBoxLayout()
        titlewidget = QWidget()
        titlewidget.setObjectName('TitleRow')
        titlewidget.setStyleSheet('#TitleRow { \
			background-color:#cccccc;border: 1px solid #aaaaaa; \
			border-radius:5px; \
		}')
        titlewidget.setMinimumSize(QtCore.QSize(50, 50))
        titletext = read_settings('User_Settings', 'current_layout_file')
        titletext = "Now editing  <font color='blue'>" + '<b>' + titletext + '</b>' + '</font> Profile'
        titlelabel = QLabel(titletext)
        titlebox.addStretch(1)
        titlebox.addWidget(titlelabel)
        titlebox.addStretch(1)
        titlewidget.setLayout(titlebox)
        vlayout.addWidget(titlewidget)

        all_layout_lists = read_layout('Layout')
        for i in all_layout_lists:
            self.createandmove(i[0], i[1], vlayout)

        widget.setLayout(vlayout)
        scroll.setWidget(widget)

        qs = QScroller.scroller(scroll.viewport())
        props = qs.scrollerProperties()
        props.setScrollMetric(QScrollerProperties.DecelerationFactor, 0.35)
        props.setScrollMetric(QScrollerProperties.DragStartDistance, .001)
        qs.setScrollerProperties(props)
        qs.grabGesture(scroll.viewport(), QScroller.TouchGesture)

        vbox = QVBoxLayout()
        vbox.addWidget(scroll)
        vbox.addLayout(hbox)
        self.setLayout(vbox)

        w, h = self.screen_width * .9, self.screen_height * .8
        self.setGeometry((self.screen_width - w) / 2,
                         (self.screen_height - h) / 2, w, h)
        self.setWindowTitle('Change Gamepad Layout')
Ejemplo n.º 13
0
    def initUI(self):
        applyButton = QPushButton(" Apply ")
        quitButton = QPushButton(" Quit ")
        cancelButton = QPushButton(" Cancel ")
        defaultsButton = QPushButton(" Restore Defaults ")
        layoutButton = QPushButton(" Change Gamepad Layout ")

        cancelButton.clicked.connect(self.cancel_settings)
        applyButton.clicked.connect(self.on_apply_clicked)
        defaultsButton.clicked.connect(self.restore_defaults)
        quitButton.clicked.connect(self.parent.quithandler)
        layoutButton.clicked.connect(self.parent.show_layout_window)

        cancelButton.setIcon(QIcon.fromTheme("window-close"))
        defaultsButton.setIcon(QIcon.fromTheme("view-refresh"))
        quitButton.setIcon(QIcon.fromTheme("application-exit"))
        applyButton.setIcon(QIcon.fromTheme("document-save"))
        layoutButton.setIcon(QIcon.fromTheme("input-gaming"))

        cancelButton.setMinimumHeight(50)
        applyButton.setMinimumHeight(50)
        defaultsButton.setMinimumHeight(50)
        quitButton.setMinimumHeight(50)
        layoutButton.setMinimumHeight(50)

        scroll = QScrollArea()
        scroll.setWidgetResizable(True)
        widget = QWidget()
        vlayout = QVBoxLayout()

        hbox = QHBoxLayout()
        hbox.addWidget(quitButton)
        hbox.addWidget(defaultsButton)
        hbox.addWidget(layoutButton)
        hbox.addStretch(1)
        hbox.addWidget(cancelButton)
        hbox.addWidget(applyButton)

        vbox = QVBoxLayout()
        for i in read_settings('User_Settings'):
            for j in settings_variables():
                if i[0] == j[0]:
                    self.createandmove(i[0], i[1], j[-1], i[-1], vlayout)

        self.createandmove(
            'New Layout File', ' Click to Create New Layout File ',
            'A new layout file will be created based on default layout (the app will restart after creating the file.)',
            str, vlayout)

        widget.setLayout(vlayout)
        scroll.setWidget(widget)

        qs = QScroller.scroller(scroll.viewport())
        props = qs.scrollerProperties()
        # props.setScrollMetric(QScrollerProperties.VerticalOvershootPolicy, QScrollerProperties.OvershootAlwaysOff)
        props.setScrollMetric(QScrollerProperties.DecelerationFactor, 0.35)
        props.setScrollMetric(QScrollerProperties.DragStartDistance, .001)
        qs.setScrollerProperties(props)
        qs.grabGesture(scroll.viewport(), QScroller.TouchGesture)
        # print(qs.scrollerProperties().scrollMetric(QScrollerProperties.DecelerationFactor))
        # print(qs.scrollerProperties().scrollMetric(QScrollerProperties.DragStartDistance))

        vbox.addWidget(scroll)
        vbox.addLayout(hbox)
        self.setLayout(vbox)

        w, h = self.screen_width * .9, self.screen_height * .8
        self.setGeometry((self.screen_width - w) / 2,
                         (self.screen_height - h) / 2, w, h)
        self.setWindowTitle('Settings')
Ejemplo n.º 14
0
    def initUI(self):
        w = QLabel()
        text = 'Big wall of text below.'
        w.setText(text)
        hbox = QHBoxLayout()
        hbox.addStretch(1)

        self.buttons = QDialogButtonBox(
            QDialogButtonBox.Ok | QDialogButtonBox.Cancel,
            QtCore.Qt.Horizontal, self)

        self.buttons.accepted.connect(self.accept)
        self.buttons.rejected.connect(self.reject)

        self.buttons.setMinimumSize(QtCore.QSize(50, 50))
        for b in self.buttons.buttons():
            b.setMinimumHeight(50)

        hbox.addWidget(self.buttons)
        vbox = QVBoxLayout()
        h = QHBoxLayout()
        vbox.addWidget(w)

        l = [
            'Name', 'X Positon', 'Y Position', 'Width', 'Height', 'Color',
            'Behavior', 'Input'
        ]
        behavior_list = ['normal', 'sticky', 'autorepeat', 'combo']

        for i in range(8):
            if i == 0:
                new_vbox = QVBoxLayout()
                new_widget = QWidget()
                lbl = QLabel(l[i])
                b = QLineEdit()
                b.setText('Z1')
                b.setMinimumHeight(50)
                new_vbox.addWidget(lbl)
                new_vbox.addWidget(b)
                new_widget.setLayout(new_vbox)
                h.addWidget(new_widget)
            if i > 0 and i <= 4:
                new_vbox = QVBoxLayout()
                new_widget = QWidget()
                lbl = QLabel(l[i])
                b = QSpinBox()
                b.setMinimum(0)
                b.setMaximum(100)
                b.setSingleStep(1)
                b.setValue(50)
                b.setMinimumHeight(50)
                new_vbox.addWidget(lbl)
                new_vbox.addWidget(b)
                new_widget.setLayout(new_vbox)
                h.addWidget(new_widget)
            if i == 5:
                new_vbox = QVBoxLayout()
                new_widget = QWidget()
                lbl = QLabel(l[i])
                b = QPushButton()
                b.setStyleSheet('background-color:green')
                b.setMinimumHeight(50)
                new_vbox.addWidget(lbl)
                new_vbox.addWidget(b)
                new_widget.setLayout(new_vbox)
                h.addWidget(new_widget)
            if i == 6:
                new_vbox = QVBoxLayout()
                new_widget = QWidget()
                lbl = QLabel(l[i])
                b = QComboBox()
                b.setMinimumHeight(50)
                b.addItem(behavior_list[0])
                b.addItem(behavior_list[1])
                b.addItem(behavior_list[2])
                new_vbox.addWidget(lbl)
                new_vbox.addWidget(b)
                new_widget.setLayout(new_vbox)
                h.addWidget(new_widget)
            if i == 7:
                new_vbox = QVBoxLayout()
                new_widget = QWidget()
                lbl = QLabel(l[i])
                b = QPushButton()
                b.setText('key D click 2')
                b.setMinimumHeight(50)
                new_vbox.addWidget(lbl)
                new_vbox.addWidget(b)
                new_widget.setLayout(new_vbox)
                h.addWidget(new_widget)

        scroll = QScrollArea()
        scroll.setWidgetResizable(True)
        widget = QLabel()
        widget.setWordWrap(True)

        t = (
            "<font color='blue'>Some fields in default buttons are disabled. "
            "This has been done on purpose to define a standard set of buttons. "
            "However, there are no such restrictions on creating a new button. "
            "If you want to hide an existing button, set its width and height to zero.</font><br><br>"
            "<b>Name:</b> Identification label for your button. "
            "You cannot change names of existing buttons. "
            "However you can always create a new button with any name.<br><br>"
            "<b>X Position:</b> Defines horizontal position of a button in terms of percentages of 'Overlay Width'. "
            "E.g., a value of 6 will postion a button horizontally at 6% of total overlay width value. "
            "Please note that overlay width may not be your screen width. "
            "You can change overlay width in settings.<br><br>"
            "<b>Y Position:</b> Defines vertical position of a button in terms of percentages of 'Overlay Height'. "
            "E.g., a value of 30 will postion a button vertically at 30% of total overlay height value. "
            "Please note that overlay height may not be your screen height. "
            "You can change overlay height in settings.<br><br>"
            "<b>Width:</b> Defines width of the button. "
            "If 'Override Button Size' is enabled in settings, this value will have no effect on button.<br><br>"
            "<b>Height:</b> Defines height of the button. "
            "If 'Override Button Size' is enabled in settings, this value will have no effect on button.<br><br>"
            "<font color='blue'><u>Tip:</u> To hide a button, set its width and height to zero.</font><br><br>"
            "<b>Color:</b> Sets the color of the button.<br><br>"
            "<b>Behavior:</b> Defines behavior of the button.<br>"
            "<font color='blue'>Some of the options below will only work if your game/emulator supports it.</font><br>"
            "<u>Normal:</u> Standard tap or long press on a button. "
            "Duplicate keys like 'Up, Up, Down, Down' will not work in this mode.<br>"
            "<u>Sticky:</u> Simulates press and hold behavior on a single press (continues unless stopped). "
            "Duplicate keys like 'Up, Up, Down, Down' will not work in this mode.<br>"
            "<u>Autorepeat:</u> Also known as rapid-fire/turbo. After touching once, it goes on and on, unless stopped. "
            "Duplicate keys like 'Up, Up, Down, Down' will not work in this mode.<br>"
            "<u>Combo:</u> Auto-executes keys one by one in a time interval defined in the settings. "
            "Once a combo starts, it cannot be interrupted until its done. "
            "Duplicate keys like 'Up, Up, Down, Down' will work in this mode if the game/emulator supports it.<br><br>"
            "<font color='blue'><u>Tip:</u> Tap on 'Stop All Inputs' to halt all sticky and autorepeating keys/clicks.</font><br><br>"
            "<b>Input:</b> Choose one or multiple keys/clicks to be executed on a button press. "
            "You can even combine keys and clicks together. "
            "There are more than 150 options, so you can now execute all those 'Soul Calibur' combos in one hit.<br><br>"
            "<font color='blue'><u>Tip:</u> If you find that the app is crashing at startup,"
            " delete 'settings.conf' file in main app folder and 'DefaultLayout.conf'"
            " file in profiles folder and then relaunch the app.</font><br><br>"
        )
        widget.setText(t)
        widget.setContentsMargins(10, 10, 10, 10)
        widget.setAlignment(QtCore.Qt.AlignJustify)
        widget.setStyleSheet('background-color:white;')

        scroll.setWidget(widget)
        scroll.setObjectName('scroll1')
        scroll.setStyleSheet('#scroll1 {background-color:white;}')

        qs = QScroller.scroller(scroll.viewport())
        props = qs.scrollerProperties()
        props.setScrollMetric(QScrollerProperties.DecelerationFactor, 0.35)
        props.setScrollMetric(QScrollerProperties.DragStartDistance, .001)
        qs.setScrollerProperties(props)
        qs.grabGesture(scroll.viewport(), QScroller.TouchGesture)

        vbox.addSpacing(10)
        vbox.addLayout(h)
        vbox.addSpacing(20)
        vbox.addWidget(scroll)
        vbox.addLayout(hbox)
        self.setLayout(vbox)

        w, h = self.screen_width * .9, self.sizeHint().height()
        self.setGeometry((self.screen_width - w) / 2,
                         (self.screen_height - h) / 2, w, h)
        self.setWindowTitle('Help')