move the log file viewer to its own plugin
We plan to have multiple different types of tabs.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import os
|
||||
from typing import Callable
|
||||
|
||||
from pathlib import Path
|
||||
from PyQt6.QtGui import QAction, QIcon
|
||||
from PyQt6.QtWidgets import QMenu, QFileDialog
|
||||
|
||||
@@ -41,8 +41,8 @@ class OpenFilePlugin(PluginBase):
|
||||
]
|
||||
|
||||
def _open_file_dialog(self) -> None:
|
||||
current_file = PluginRegistry.executeSingle("current_file")
|
||||
directory = os.path.dirname(current_file) if current_file else ''
|
||||
current_file = PluginRegistry.execute_single("current_file")
|
||||
directory = os.path.dirname(current_file) if current_file else os.path.join(Path.home())
|
||||
|
||||
dialog = QFileDialog()
|
||||
(selected_file, _filter) = dialog.getOpenFileName(
|
||||
@@ -53,12 +53,14 @@ class OpenFilePlugin(PluginBase):
|
||||
self._open_file(selected_file)
|
||||
|
||||
def _open_file(self, selected_file: str):
|
||||
PluginRegistry.executeSingle("create_tab", selected_file)
|
||||
self._remember_recent_file(selected_file)
|
||||
tab = PluginRegistry.execute_single("create_tab", selected_file)
|
||||
if tab:
|
||||
PluginRegistry.execute_single("add_tab", tab)
|
||||
PluginRegistry.execute("after_open_file", selected_file)
|
||||
|
||||
def _get_recent_files(self) -> [str]:
|
||||
recent_files = self.settings.session.get('general', 'recent_files', fallback='')
|
||||
print(recent_files)
|
||||
# print(recent_files)
|
||||
files = recent_files.split(os.pathsep)
|
||||
if "" in files:
|
||||
files.remove("")
|
||||
|
||||
Reference in New Issue
Block a user