def init_stylesheet(self): current_stylesheet = Settings.get_instance().get_settings( ).design.color_theme.current if current_stylesheet == 0: self.setStyleSheet(open(Resources.files.qss_dark, "r").read()) elif current_stylesheet == 1: self.setStyleSheet(open(Resources.files.qss_light, "r").read())
def do_operation(self, operation): """ Executes a given operation and adds it to the history. @type operation: Operation @param operation: An operation that is executed. """ # Add operation to history if (len(self.operations) > self.__last_operation + 1): # Other operation is overriden self.operations[self.__last_operation + 1] = operation # Remove undone operations self.operations = self.operations[0:(self.__last_operation + 2)] else: # Operation is added at the end self.operations.append(operation) self.__last_operation += 1 # Execute operation operation.do() # delete first operation if limit was reached limit = Settings.get_instance().get_settings( ).general.history_limit.current if len(self.operations) > limit: self.operations = self.operations[len(self.operations) - limit:] self.__last_operation = limit - 1
def update_language(self): lang = Settings.get_instance().get_settings().general.language.current if lang == 0: Language.set_language('en') elif lang == 1: Language.set_language('de') self.__settings_view.saved.emit()
def contextMenuEvent(self, event): """shows a menu on rightclick""" event.accept() menu = QMenu() current_stylesheet = Settings.get_instance().get_settings( ).design.color_theme.current if current_stylesheet == 0: menu.setStyleSheet(open(Resources.files.qss_dark, "r").read()) elif current_stylesheet == 1: menu.setStyleSheet(open(Resources.files.qss_light, "r").read()) cut_timeneedle = QAction(str(Language.current.timeable.cut_timeneedle)) menu.addAction(cut_timeneedle) cut_timeneedle.triggered.connect(self.cut_timeneedle) cut_here = QAction(str(Language.current.timeable.cut_here)) menu.addAction(cut_here) cut_here.triggered.connect(lambda: self.cut_here(event.pos().x())) delete = QAction(str(Language.current.timeable.delete)) menu.addAction(delete) delete.triggered.connect(lambda: self.delete(hist=True)) settings = QAction(str(Language.current.timeable.settings)) menu.addAction(settings) settings.triggered.connect(self.settings) if self.group_id is not None: remove_from_group = QAction( str(Language.current.timeable.group_remove)) menu.addAction(remove_from_group) remove_from_group.triggered.connect(self.remove_from_group) menu.exec_(event.screenPos() + QPoint(0, 5))
def __start_open(self): """ Open a project """ self.__video_editor_view.previewview.stop() filetypes = Settings.get_instance().get_dict_settings()[ "Invisible"]["project_formats"] path, _ = QFileDialog.getOpenFileName(self.__video_editor_view, 'Open Project', '', filetypes) # do nothing if cancel was clicked if path == "": return with open(path, 'r') as f: project_data = json.load(f) # set up timeline self.__timeline_controller.clear_timeline() if "timeline" in project_data: self.__timeline_controller.create_project_timeline(project_data["timeline"]) else: self.__timeline_controller.create_default_tracks() # set up filemanager self.__filemanager_controller.clear() if "filemanager" in project_data: filemanager_data = project_data["filemanager"] self.__filemanager_controller.create_project_filemanager(filemanager_data) # set project path project = Project.get_instance() project.path = path project.changed = False self.set_title_saved()
def on_context_menu(self, point): """ shows a menu on rightclick """ button_menu = QMenu() current_stylesheet = Settings.get_instance().get_settings().design.color_theme.current if current_stylesheet == 0: button_menu.setStyleSheet(open(Resources.files.qss_dark, "r").read()) elif current_stylesheet == 1: button_menu.setStyleSheet(open(Resources.files.qss_light, "r").read()) delete = QAction(str(Language.current.track.delete)) button_menu.addAction(delete) delete.triggered.connect(self.delete) add = QAction(str(Language.current.track.add)) button_menu.addAction(add) add.triggered.connect(self.add) if self.is_video: overlay = QAction(str(Language.current.track.overlay)) overlay.setCheckable(True) if self.is_overlay: overlay.setChecked(True) button_menu.addAction(overlay) overlay.changed.connect(self.overlay_toggle) button_menu.exec_(self.button.mapToGlobal(point) + QPoint(10, 0))
def pickFileNames(self): """ This method saves the selected files in a list and add this to the filemanager window This method ensures that only supported files are displayed and can be used. """ self.full_path = Project.get_instance().path self.directory_strings = self.full_path.split('/') self.project_name = self.directory_strings[-2] self.directory_strings.pop(-1) self.directory_strings.pop(-1) self.project_path = os.path.join( '/', *self.directory_strings ) #* takes every element of the list as single argument supported_filetypes = Settings.get_instance().get_dict_settings( )["Invisible"]["filemanager_import_formats"] fileNames, _ = QFileDialog.getOpenFileNames( self.__filemanager_view, 'QFileDialog.getOpenFileNames()', '', (supported_filetypes)) if not fileNames: return for file in fileNames: QApplication.processEvents() self.addFileNames(file) project = Project.get_instance() if not project.changed: project.changed = True self.__filemanager_view.changed.emit()
def pick_video(self): """Opens a file picker to select a video file.""" supported_filetypes = Settings.get_instance().get_dict_settings( )["Invisible"]["autocutvideo_import_formats"] self.filename_video, _ = QFileDialog.getOpenFileName( self.__autocut_view, 'QFileDialog.getOpenFileNames()', '', (supported_filetypes)) if self.filename_video: self.textlabel.setText(str(Language.current.autocut.ready)) self.__autocut_view.change_icon( self.__autocut_view.video_image_label) self.ok_button.setEnabled(True)
def pick_pdf(self): """Opens a file picker to select a pdf.""" supported_filetypes = Settings.get_instance().get_dict_settings( )["Invisible"]["autocutpdf_import_formats"] self.filename_pdf, _ = QFileDialog.getOpenFileName( self.__autocut_view, 'QFileDialog.getOpenFileNames()', '', (supported_filetypes)) if self.filename_pdf: self.textlabel.setText(str(Language.current.autocut.addvideotext)) self.__autocut_view.change_icon( self.__autocut_view.pdf_image_label) else: pass
def __init__(self, view): self.__settings_view = view """imports settings instance and applies it""" self.settingsInstance = Settings.get_instance() self.settings = self.settingsInstance.get_dict_settings() self.__settings_view.saveButton.setText( str(Language.current.settings.save)) self.__settings_view.saveButton.clicked.connect( lambda: self.saveSettings()) self.__settings_view.cancelButton.setText( str(Language.current.settings.cancel)) self.__settings_view.cancelButton.clicked.connect( lambda: self.__settings_view.close())
def run(self): """Starts the application using 'MainController' with the 'StartView'.""" # init resources Resources(self) # init language lang = Settings.get_instance().get_settings().general.language.current if lang == 0: Language('en') elif lang == 1: Language('de') else: Language() # start view and controller start_view = StartView() __main_controller = MainController(start_view) __main_controller.start() return self.app.exec_()
def add_from_filemanager(self, drag_event): """ Adds a timeable when item from filemanager is dragged into the track """ # get the path from the dropped item item_data = drag_event.mimeData().data('ubicut/file') stream = QDataStream(item_data, QIODevice.ReadOnly) path = QDataStream.readString(stream).decode() width = QDataStream.readInt(stream) x_pos = drag_event.pos().x() # check if theres already another timeable at the drop position rect = QRectF(x_pos, 0, width, self.height) colliding = self.scene().items(rect) # add the timeable when there are no colliding items if not colliding: name = os.path.basename(path) clip_id = generate_id() if Settings.get_instance().get_dict_settings()["general"]["autoaudio"]["current"]: model = TimeableModel(path, generate_id(), is_video=True) model.move(x_pos) model.set_end(width) self.__controller.create_timeable(self.num, name, width, x_pos, model, clip_id, is_drag=True) model_audio = TimeableModel(path, generate_id(), is_video=False) model_audio.move(x_pos) model_audio.set_end(width) clip_id_audio = generate_id() self.__controller.create_timeable(None, name, width, x_pos, model_audio, clip_id_audio, is_drag=True, auto_audio=self.num) self.__controller.create_group([clip_id, clip_id_audio]) else: model_withoutgroup = TimeableModel(path, generate_id()) model_withoutgroup.move(x_pos) model_withoutgroup.set_end(width) self.__controller.create_timeable(self.num, name, width, x_pos, model_withoutgroup, clip_id, is_drag=True) self.item_dropped = True
def __init__(self, window): """ Creates the shortcuts. Queries all entries of the Shortcuts section in the config file. For every entry a new shortcut is going to be created. @type window: QMainWindow @param window: The Window, the shortcut gets assigned to. """ shortcuts = Settings.get_instance().get_dict_settings()["shortcuts"] self.loaded_shortcuts = [] for operation in shortcuts: if operation == "starter": self.starter = shortcuts[operation]["current"] else: key = shortcuts[operation]["current"] key_sequence = self.starter + "+" + key shortcut = Shortcut(window, key_sequence, operation) self.loaded_shortcuts.append(shortcut)
def __init__(self, view): self.__start_view = view manual_cut_button = self.__start_view.findChild( QWidget, "manual_cut_button") manual_cut_button.clicked.connect( lambda: self.__new_project("SimpleCut")) auto_cut_button = self.__start_view.findChild(QWidget, "auto_cut_button") auto_cut_button.clicked.connect(lambda: self.__new_project("AutoCut")) load_project_button = self.__start_view.findChild( QWidget, "load_project_button") load_project_button.setText( str(Language.current.startview.load_project)) load_project_button.clicked.connect(self.__load_project) new_project_button = self.__start_view.findChild( QWidget, "new_project_button") back_button = self.__start_view.findChild(QWidget, "back_button") new_project_button.clicked.connect(self.__start_view.switch_frame) back_button.clicked.connect(self.__start_view.switch_frame) pick_folder_button = self.__start_view.findChild( QWidget, "pick_folder_button") pick_folder_button.clicked.connect(self.__pick_folder) settings = Settings.get_instance().get_settings() self.folder_line_edit = self.__start_view.findChild( QWidget, "folder_line_edit") self.folder_line_edit.setText(settings.Invisible.projects_path) self.name_line_edit = self.__start_view.findChild( QWidget, "name_line_edit") listview = self.__start_view.findChild(QWidget, "projects_list_view") listview.doubleClicked.connect(self.__load_project)
def __show_message_box(self, title, icon, text, info): """ Creates and shows a QMessageBox. :param title: String - Title of the message box :param icon: Icon of the message box, e.g. QMessageBox.Critical :param text: String - Text of the message box :param info: String - More text for the message box to provide further information """ message_box = QMessageBox() current_stylesheet = Settings.get_instance().get_settings( ).design.color_theme.current if current_stylesheet == 0: message_box.setStyleSheet( open(Resources.files.qss_dark, "r").read()) elif current_stylesheet == 1: message_box.setStyleSheet( open(Resources.files.qss_light, "r").read()) message_box.setWindowTitle(title) message_box.setIcon(icon) message_box.setText(text) message_box.setInformativeText(info) message_box.exec_()
def get_px_per_second(): s = Settings.get_instance().get_settings() return int(s.Invisible.pixels_per_second)