def init_button_menu(self): layout = QtWidgets.QHBoxLayout() open_input_file = QtWidgets.QPushButton("🎞 Source") open_input_file.setFixedSize(100, 50) open_input_file.setDefault(True) open_input_file.clicked.connect(lambda: self.open_file()) open_input_file.setStyleSheet('background: blue') convert = QtWidgets.QPushButton("Convert 🎥") convert.setFixedSize(100, 50) convert.setStyleSheet('background: green') convert.clicked.connect(lambda: self.create_video()) self.widgets.convert_button = convert layout.addWidget(open_input_file) layout.addStretch() layout.addLayout(self.init_output_type(), alignment=Qt.AlignRight) layout.addStretch() layout.addWidget(convert) return layout
def init_preview_buttons(self): layout = QtWidgets.QVBoxLayout() refresh = QtWidgets.QPushButton("R") refresh.setFixedWidth(20) preview = QtWidgets.QPushButton("P") preview.setFixedWidth(20) one = QtWidgets.QPushButton("1") one.setFixedWidth(20) two = QtWidgets.QPushButton("2") two.setFixedWidth(20) refresh.clicked.connect(lambda: self.page_update()) layout.addWidget(refresh) layout.addWidget(preview) layout.addWidget(one) layout.addWidget(two) layout.addStretch() return layout
def init_input_file(self): layout = QtWidgets.QHBoxLayout() self.widgets.input_file = QtWidgets.QLineEdit("") self.widgets.input_file.setReadOnly(True) open_input_file = QtWidgets.QPushButton("...") open_input_file.setFixedWidth(50) open_input_file.setMaximumHeight(22) open_input_file.setDefault(True) layout.addWidget(QtWidgets.QLabel("Source File:")) layout.addWidget(self.widgets.input_file) layout.addWidget(open_input_file) layout.setSpacing(10) open_input_file.clicked.connect(lambda: self.open_file()) return layout
def build_hoz_int_field(self, name, button_size=22, left_stretch=True, right_stretch=True, layout=None, return_buttons=False, time_field=False): widget = QtWidgets.QLineEdit( self.number_to_time(0) if time_field else "0") widget.setFixedHeight(button_size) if not layout: layout = QtWidgets.QHBoxLayout() layout.setSpacing(0) if left_stretch: layout.addStretch() layout.addWidget(QtWidgets.QLabel(name)) minus_button = QtWidgets.QPushButton("-") minus_button.setAutoRepeat(True) minus_button.setFixedSize(button_size, button_size) minus_button.clicked.connect( lambda: self.modify_int(widget, 'minus', time_field)) plus_button = QtWidgets.QPushButton("+") plus_button.setAutoRepeat(True) plus_button.setFixedSize(button_size, button_size) plus_button.clicked.connect( lambda: self.modify_int(widget, 'add', time_field)) if not time_field: widget.setFixedWidth(40) layout.addWidget(minus_button) layout.addWidget(widget) layout.addWidget(plus_button) if right_stretch: layout.addStretch() if return_buttons: return widget, layout, minus_button, plus_button return widget, layout
def init_scale(self): scale_area = QtWidgets.QGroupBox() scale_area.setStyleSheet( "QGroupBox{padding-top:15px; margin-top:-18px}") scale_layout = QtWidgets.QVBoxLayout() self.widgets.scale.width, new_scale_layout = self.build_hoz_int_field( "Width ", right_stretch=False) self.widgets.scale.height, new_scale_layout, lb, rb = self.build_hoz_int_field( " Height ", left_stretch=False, layout=new_scale_layout, return_buttons=True) self.widgets.scale.height.setDisabled(True) lb.setDisabled(True) rb.setDisabled(True) QtWidgets.QPushButton() # TODO scale 0 error self.widgets.scale.width.textChanged.connect( lambda: self.scale_update()) self.widgets.scale.height.textChanged.connect( lambda: self.scale_update()) bottom_row = QtWidgets.QHBoxLayout() self.widgets.scale.keep_aspect = QtWidgets.QCheckBox( "Keep aspect ratio") self.widgets.scale.keep_aspect.setMaximumHeight(40) self.widgets.scale.keep_aspect.setChecked(True) self.widgets.scale.keep_aspect.toggled.connect( lambda: self.toggle_disable((self.widgets.scale.height, lb, rb))) self.widgets.scale.keep_aspect.toggled.connect( lambda: self.scale_update()) label = QtWidgets.QLabel('Scale', alignment=(Qt.AlignBottom | Qt.AlignRight)) label.setStyleSheet("QLabel{color:#777}") label.setMaximumHeight(40) bottom_row.addWidget(self.widgets.scale.keep_aspect, alignment=Qt.AlignCenter) scale_layout.addLayout(new_scale_layout) bottom_row.addWidget(label) scale_layout.addLayout(bottom_row) scale_area.setLayout(scale_layout) return scale_area
def __init__(self, parent, audio, index, codec, available_audio_encoders, outdex=None, enabled=True, original=False, first=False, last=False, codecs=(), channels=2): super(Audio, self).__init__(parent) self.parent = parent self.audio = audio self.setFixedHeight(60) self.original = original self.outdex = index if self.original else outdex self.first = first self.last = last self.index = index self.codec = codec self.codecs = codecs self.channels = channels self.loading = True self.available_audio_encoders = available_audio_encoders self.widgets = Box( track_number=QtWidgets.QLabel( f'{index}:{self.outdex}' if enabled else '❌'), audio_info=QtWidgets.QLineEdit(audio), up_button=QtWidgets.QPushButton("^"), down_button=QtWidgets.QPushButton("v"), enable_check=QtWidgets.QCheckBox("Enabled"), dup_button=QtWidgets.QPushButton("➕"), delete_button=QtWidgets.QPushButton("⛔"), convert_to=None, convert_bitrate=None, ) self.widgets.enable_check.setChecked(enabled) #self.widgets.enable_check.toggled.connect(lambda: self.parent.reorder()) self.widgets.dup_button.clicked.connect(lambda: self.dup_me()) self.widgets.dup_button.setFixedWidth(20) self.widgets.delete_button.clicked.connect(lambda: self.del_me()) self.widgets.delete_button.setFixedWidth(20) self.widgets.track_number.setFixedWidth(20) grid = QtWidgets.QGridLayout() grid.addLayout(self.init_move_buttons(), 0, 0) grid.addWidget(self.widgets.track_number, 0, 1) grid.addWidget(self.widgets.audio_info, 0, 2) grid.addLayout(self.init_conversion(), 0, 3) if not original: grid.addWidget(self.widgets.delete_button, 0, 4) else: grid.addWidget(self.widgets.dup_button, 0, 5) grid.addWidget(self.widgets.enable_check, 0, 4) self.setLayout(grid) self.loading = False