diff --git a/auratext/Core/Lexers.py b/auratext/Core/Lexers.py index 3979702..07753e3 100644 --- a/auratext/Core/Lexers.py +++ b/auratext/Core/Lexers.py @@ -51,331 +51,331 @@ def python(self): lexer.setColor(QColor("#59ff00"), lexer.TripleDoubleQuotedString) lexer.setColor(QColor("#3ba800"), lexer.SingleQuotedString) lexer.setColor(QColor("#3ba800"), lexer.DoubleQuotedString) - lexer.setFont(QFont(self._config["font"])) + lexer.setFont(QFont(self._themes["font"])) class PythonLexer(QsciLexerPython): def __init__(self, window: "Window"): super().__init__() self.setDefaultColor(QColor("white")) - self.setPaper(QColor(window._config["editor_theme"])) + self.setPaper(QColor(window._themes["editor_theme"])) self.setColor(QColor("#ffffff"), self.ClassName) - self.setFont(QFont(window._config["font"])) + self.setFont(QFont(window._themes["font"])) def csharp(self): lexer = QsciLexerCSharp() lexer.setDefaultColor(QColor("#FFFFFF")) self.current_editor.setLexer(lexer) - lexer.setPaper(QColor(self._config["editor_theme"])) + lexer.setPaper(QColor(self._themes["editor_theme"])) lexer.setColor(QColor("#808080"), lexer.Comment) lexer.setColor(QColor("#FFA500"), lexer.Keyword) - lexer.setFont(QFont(self._config["font"])) + lexer.setFont(QFont(self._themes["font"])) def avs(self): lexer = QsciLexerAVS() lexer.setDefaultColor(QColor("#FFFFFF")) self.current_editor.setLexer(lexer) - lexer.setPaper(QColor(self._config["editor_theme"])) + lexer.setPaper(QColor(self._themes["editor_theme"])) lexer.setColor(QColor("#FFA500"), lexer.Keyword) - lexer.setFont(QFont(self._config["font"])) + lexer.setFont(QFont(self._themes["font"])) def asm(self): lexer = QsciLexerAsm() lexer.setDefaultColor(QColor("#FFFFFF")) self.current_editor.setLexer(lexer) - lexer.setPaper(QColor(self._config["editor_theme"])) + lexer.setPaper(QColor(self._themes["editor_theme"])) lexer.setColor(QColor("#808080"), lexer.Comment) - lexer.setFont(QFont(self._config["font"])) + lexer.setFont(QFont(self._themes["font"])) def coffeescript(self): lexer = QsciLexerCoffeeScript() lexer.setDefaultColor(QColor("#FFFFFF")) self.current_editor.setLexer(lexer) - lexer.setPaper(QColor(self._config["editor_theme"])) + lexer.setPaper(QColor(self._themes["editor_theme"])) lexer.setColor(QColor("#808080"), lexer.Comment) lexer.setColor(QColor("#FFA500"), lexer.Keyword) - lexer.setFont(QFont(self._config["font"])) + lexer.setFont(QFont(self._themes["font"])) def ma(self): lexer = QsciLexerCSharp() lexer.setDefaultColor(QColor("#FFFFFF")) self.current_editor.setLexer(lexer) - lexer.setPaper(QColor(self._config["editor_theme"])) + lexer.setPaper(QColor(self._themes["editor_theme"])) lexer.setColor(QColor("#808080"), lexer.Comment) lexer.setColor(QColor("#FFA500"), lexer.Keyword) - lexer.setFont(QFont(self._config["font"])) + lexer.setFont(QFont(self._themes["font"])) def json(self): lexer = QsciLexerJSON() lexer.setDefaultColor(QColor("#FFFFFF")) self.current_editor.setLexer(lexer) - lexer.setPaper(QColor(self._config["editor_theme"])) + lexer.setPaper(QColor(self._themes["editor_theme"])) lexer.setColor(QColor("#FFA500"), lexer.Keyword) - lexer.setFont(QFont(self._config["font"])) + lexer.setFont(QFont(self._themes["font"])) def js(self): lexer = QsciLexerJavaScript() lexer.setDefaultColor(QColor("#FFFFFF")) self.current_editor.setLexer(lexer) - lexer.setPaper(QColor(self._config["editor_theme"])) + lexer.setPaper(QColor(self._themes["editor_theme"])) lexer.setColor(QColor("#808080"), lexer.Comment) lexer.setColor(QColor("#FFA500"), lexer.Keyword) lexer.setColor(QColor("#ffffff"), lexer.Default) - lexer.setFont(QFont(self._config["font"])) + lexer.setFont(QFont(self._themes["font"])) def fortran(self): lexer = QsciLexerFortran() lexer.setDefaultColor(QColor("#FFFFFF")) self.current_editor.setLexer(lexer) - lexer.setPaper(QColor(self._config["editor_theme"])) + lexer.setPaper(QColor(self._themes["editor_theme"])) lexer.setColor(QColor("#808080"), lexer.Comment) lexer.setColor(QColor("#FFA500"), lexer.Keyword) - lexer.setFont(QFont(self._config["font"])) + lexer.setFont(QFont(self._themes["font"])) def java(self): lexer = QsciLexerJava() lexer.setDefaultColor(QColor("#FFFFFF")) self.current_editor.setLexer(lexer) - lexer.setPaper(QColor(self._config["editor_theme"])) + lexer.setPaper(QColor(self._themes["editor_theme"])) lexer.setColor(QColor("#808080"), lexer.Comment) lexer.setColor(QColor("#FFA500"), lexer.Keyword) - lexer.setFont(QFont(self._config["font"])) + lexer.setFont(QFont(self._themes["font"])) def bash(self): lexer = QsciLexerBash() lexer.setDefaultColor(QColor("#FFFFFF")) self.current_editor.setLexer(lexer) - lexer.setPaper(QColor(self._config["editor_theme"])) + lexer.setPaper(QColor(self._themes["editor_theme"])) lexer.setColor(QColor("#808080"), lexer.Comment) lexer.setColor(QColor("#FFA500"), lexer.Keyword) - lexer.setFont(QFont(self._config["font"])) + lexer.setFont(QFont(self._themes["font"])) def yaml(self): lexer = QsciLexerYAML() lexer.setDefaultColor(QColor("#FFFFFF")) self.current_editor.setLexer(lexer) - lexer.setPaper(QColor(self._config["editor_theme"])) + lexer.setPaper(QColor(self._themes["editor_theme"])) lexer.setColor(QColor("#808080"), lexer.Comment) lexer.setColor(QColor("#FFA500"), lexer.Keyword) - lexer.setFont(QFont(self._config["font"])) + lexer.setFont(QFont(self._themes["font"])) def xml(self): lexer = QsciLexerXML() lexer.setDefaultColor(QColor("#FFFFFF")) self.current_editor.setLexer(lexer) - lexer.setPaper(QColor(self._config["editor_theme"])) - lexer.setFont(QFont(self._config["font"])) + lexer.setPaper(QColor(self._themes["editor_theme"])) + lexer.setFont(QFont(self._themes["font"])) def html(self): lexer = QsciLexerHTML() lexer.setDefaultColor(QColor("#FFFFFF")) self.current_editor.setLexer(lexer) - lexer.setPaper(QColor(self._config["editor_theme"])) + lexer.setPaper(QColor(self._themes["editor_theme"])) lexer.setColor(QColor("#808080"), lexer.Tag) - lexer.setFont(QFont(self._config["font"])) + lexer.setFont(QFont(self._themes["font"])) def cpp(self): lexer = QsciLexerCPP() lexer.setDefaultColor(QColor("#FFFFFF")) self.current_editor.setLexer(lexer) - lexer.setPaper(QColor(self._config["editor_theme"])) + lexer.setPaper(QColor(self._themes["editor_theme"])) lexer.setColor(QColor("#808080"), lexer.Comment) lexer.setColor(QColor("#FFA500"), lexer.Keyword) lexer.setColor(QColor("#ffffff"), lexer.Identifier) - lexer.setFont(QFont(self._config["font"])) + lexer.setFont(QFont(self._themes["font"])) def srec(self): lexer = QsciLexerSRec() lexer.setDefaultColor(QColor("#FFFFFF")) self.current_editor.setLexer(lexer) - lexer.setPaper(QColor(self._config["editor_theme"])) - lexer.setFont(QFont(self._config["font"])) + lexer.setPaper(QColor(self._themes["editor_theme"])) + lexer.setFont(QFont(self._themes["font"])) def ruby(self): lexer = QsciLexerRuby() lexer.setDefaultColor(QColor("#FFFFFF")) self.current_editor.setLexer(lexer) - lexer.setPaper(QColor(self._config["editor_theme"])) + lexer.setPaper(QColor(self._themes["editor_theme"])) lexer.setColor(QColor("#808080"), lexer.Comment) lexer.setColor(QColor("#FFA500"), lexer.Keyword) lexer.setColor(QColor("#ffffff"), lexer.ClassName) - lexer.setFont(QFont(self._config["font"])) + lexer.setFont(QFont(self._themes["font"])) def perl(self): lexer = QsciLexerPerl() lexer.setDefaultColor(QColor("#FFFFFF")) self.current_editor.setLexer(lexer) - lexer.setPaper(QColor(self._config["editor_theme"])) + lexer.setPaper(QColor(self._themes["editor_theme"])) lexer.setColor(QColor("#808080"), lexer.Comment) lexer.setColor(QColor("#FFA500"), lexer.Keyword) - lexer.setFont(QFont(self._config["font"])) + lexer.setFont(QFont(self._themes["font"])) def css(self): lexer = QsciLexerCSS() lexer.setDefaultColor(QColor("#FFFFFF")) self.current_editor.setLexer(lexer) - lexer.setPaper(QColor(self._config["editor_theme"])) + lexer.setPaper(QColor(self._themes["editor_theme"])) lexer.setColor(QColor("#808080"), lexer.Comment) - lexer.setFont(QFont(self._config["font"])) + lexer.setFont(QFont(self._themes["font"])) def lua(self): lexer = QsciLexerLua() lexer.setDefaultColor(QColor("#FFFFFF")) self.current_editor.setLexer(lexer) - lexer.setPaper(QColor(self._config["editor_theme"])) + lexer.setPaper(QColor(self._themes["editor_theme"])) lexer.setColor(QColor("#808080"), lexer.Comment) lexer.setColor(QColor("#FFA500"), lexer.Keyword) - lexer.setFont(QFont(self._config["font"])) + lexer.setFont(QFont(self._themes["font"])) def sql(self): lexer = QsciLexerSQL() lexer.setDefaultColor(QColor("#FFFFFF")) self.current_editor.setLexer(lexer) - lexer.setPaper(QColor(self._config["editor_theme"])) + lexer.setPaper(QColor(self._themes["editor_theme"])) lexer.setColor(QColor("#808080"), lexer.Comment) lexer.setColor(QColor("#FFA500"), lexer.Keyword) - lexer.setFont(QFont(self._config["font"])) + lexer.setFont(QFont(self._themes["font"])) def tex(self): lexer = QsciLexerTeX() lexer.setDefaultColor(QColor("#FFFFFF")) self.current_editor.setLexer(lexer) - lexer.setPaper(QColor(self._config["editor_theme"])) - lexer.setFont(QFont(self._config["font"])) + lexer.setPaper(QColor(self._themes["editor_theme"])) + lexer.setFont(QFont(self._themes["font"])) def bat(self): lexer = QsciLexerBatch() lexer.setDefaultColor(QColor("#FFFFFF")) self.current_editor.setLexer(lexer) - lexer.setPaper(QColor(self._config["editor_theme"])) + lexer.setPaper(QColor(self._themes["editor_theme"])) lexer.setColor(QColor("#808080"), lexer.Comment) lexer.setColor(QColor("#FFA500"), lexer.Keyword) - lexer.setFont(QFont(self._config["font"])) + lexer.setFont(QFont(self._themes["font"])) def cmake(self): lexer = QsciLexerCMake() lexer.setDefaultColor(QColor("#FFFFFF")) self.current_editor.setLexer(lexer) - lexer.setPaper(QColor(self._config["editor_theme"])) + lexer.setPaper(QColor(self._themes["editor_theme"])) lexer.setColor(QColor("#808080"), lexer.Comment) - lexer.setFont(QFont(self._config["font"])) + lexer.setFont(QFont(self._themes["font"])) def postscript(self): lexer = QsciLexerPostScript() lexer.setDefaultColor(QColor("#FFFFFF")) self.current_editor.setLexer(lexer) - lexer.setPaper(QColor(self._config["editor_theme"])) + lexer.setPaper(QColor(self._themes["editor_theme"])) lexer.setColor(QColor("#808080"), lexer.Comment) lexer.setColor(QColor("#FFA500"), lexer.Keyword) - lexer.setFont(QFont(self._config["font"])) + lexer.setFont(QFont(self._themes["font"])) def markdown(self): lexer = QsciLexerMarkdown() lexer.setDefaultColor(QColor("#FFFFFF")) self.current_editor.setLexer(lexer) - lexer.setPaper(QColor(self._config["editor_theme"])) + lexer.setPaper(QColor(self._themes["editor_theme"])) lexer.setColor(QColor("#808080"), lexer.Header1) lexer.setColor(QColor("#FFA500"), lexer.Header2) lexer.setColor(QColor("#ffffff"), lexer.Header3) - lexer.setFont(QFont(self._config["font"])) + lexer.setFont(QFont(self._themes["font"])) def makefile(self): lexer = QsciLexerMakefile() lexer.setDefaultColor(QColor("#FFFFFF")) self.current_editor.setLexer(lexer) - lexer.setPaper(QColor(self._config["editor_theme"])) + lexer.setPaper(QColor(self._themes["editor_theme"])) lexer.setColor(QColor("#808080"), lexer.Comment) - lexer.setFont(QFont(self._config["font"])) + lexer.setFont(QFont(self._themes["font"])) def pascal(self): lexer = QsciLexerPascal() self.current_editor.setLexer(lexer) - lexer.setPaper(QColor(self._config["editor_theme"])) + lexer.setPaper(QColor(self._themes["editor_theme"])) lexer.setColor(QColor("#808080"), lexer.Comment) lexer.setColor(QColor("#FFA500"), lexer.Keyword) - lexer.setFont(QFont(self._config["font"])) + lexer.setFont(QFont(self._themes["font"])) def tcl(self): lexer = QsciLexerTCL() lexer.setDefaultColor(QColor("#FFFFFF")) self.current_editor.setLexer(lexer) - lexer.setPaper(QColor(self._config["editor_theme"])) + lexer.setPaper(QColor(self._themes["editor_theme"])) lexer.setColor(QColor("#808080"), lexer.Comment) - lexer.setFont(QFont(self._config["font"])) + lexer.setFont(QFont(self._themes["font"])) def verilog(self): lexer = QsciLexerVerilog() lexer.setDefaultColor(QColor("#FFFFFF")) self.current_editor.setLexer(lexer) - lexer.setPaper(QColor(self._config["editor_theme"])) - lexer.setColor(QColor(self._config["editor_theme"]), lexer.Comment) + lexer.setPaper(QColor(self._themes["editor_theme"])) + lexer.setColor(QColor(self._themes["editor_theme"]), lexer.Comment) lexer.setColor(QColor("#FFA500"), lexer.Keyword) - lexer.setFont(QFont(self._config["font"])) + lexer.setFont(QFont(self._themes["font"])) def spice(self): lexer = QsciLexerSpice() lexer.setDefaultColor(QColor("#FFFFFF")) self.current_editor.setLexer(lexer) - lexer.setPaper(QColor(self._config["editor_theme"])) + lexer.setPaper(QColor(self._themes["editor_theme"])) lexer.setColor(QColor("#808080"), lexer.Comment) - lexer.setFont(QFont(self._config["font"])) + lexer.setFont(QFont(self._themes["font"])) def vhdl(self): lexer = QsciLexerVHDL() lexer.setDefaultColor(QColor("#FFFFFF")) self.current_editor.setLexer(lexer) - lexer.setPaper(QColor(self._config["editor_theme"])) + lexer.setPaper(QColor(self._themes["editor_theme"])) lexer.setColor(QColor("#808080"), lexer.Comment) lexer.setColor(QColor("#FFA500"), lexer.Keyword) - lexer.setFont(QFont(self._config["font"])) + lexer.setFont(QFont(self._themes["font"])) def octave(self): lexer = QsciLexerOctave() lexer.setDefaultColor(QColor("#FFFFFF")) self.current_editor.setLexer(lexer) - lexer.setPaper(QColor(self._config["editor_theme"])) + lexer.setPaper(QColor(self._themes["editor_theme"])) lexer.setColor(QColor("#808080"), lexer.Comment) lexer.setColor(QColor("#FFA500"), lexer.Keyword) - lexer.setFont(QFont(self._config["font"])) + lexer.setFont(QFont(self._themes["font"])) def fortran77(self): lexer = QsciLexerFortran77() lexer.setDefaultColor(QColor("#FFFFFF")) self.current_editor.setLexer(lexer) - lexer.setPaper(QColor(self._config["editor_theme"])) + lexer.setPaper(QColor(self._themes["editor_theme"])) lexer.setColor(QColor("#808080"), lexer.Comment) lexer.setColor(QColor("#FFA500"), lexer.Keyword) - lexer.setFont(QFont(self._config["font"])) + lexer.setFont(QFont(self._themes["font"])) diff --git a/auratext/Core/MenuConfig.py b/auratext/Core/MenuConfig.py index 927b35f..1658358 100644 --- a/auratext/Core/MenuConfig.py +++ b/auratext/Core/MenuConfig.py @@ -387,6 +387,7 @@ def read_only(): prefernces_menu.addMenu(language_menu) prefernces_menu.addAction("Additional Preferences", self.additional_prefs) + prefernces_menu.addAction("Import Theme", self.import_theme) menubar.addMenu(prefernces_menu) help_menu = QMenu("&?", self) diff --git a/auratext/Core/ThemeDownload.py b/auratext/Core/ThemeDownload.py new file mode 100644 index 0000000..6dc7c49 --- /dev/null +++ b/auratext/Core/ThemeDownload.py @@ -0,0 +1,122 @@ +import os +import shutil +import sys +import requests +from PyQt6.QtWidgets import ( + QApplication, + QWidget, + QVBoxLayout, + QListWidget, + QPushButton, + QMessageBox, + QLineEdit, + QGroupBox, + QHBoxLayout, + QFormLayout, + QScrollArea, +) + + +class ThemeDownloader(QWidget): + def __init__(self, window): + super().__init__() + self._window = window + self.search_input = QLineEdit(self) + self.list_widget = QListWidget() + self.init_ui() + + def init_ui(self): + layout = QVBoxLayout() + search_group_box = QGroupBox("Search Extensions") + search_layout = QHBoxLayout() + search_layout.addWidget(self.search_input) + self.search_input.textChanged.connect(self.filter_list) + search_group_box.setLayout(search_layout) + layout.addWidget(search_group_box) + + # Extensions List + extensions_group_box = QGroupBox("Available Extensions") + extensions_layout = QFormLayout() + extensions_group_box.setLayout(extensions_layout) + + extensions_scroll_area = QScrollArea() + extensions_scroll_area.setWidgetResizable(True) + extensions_scroll_area.setWidget(extensions_group_box) + layout.addWidget(extensions_scroll_area) + + # Add the file list to the QListWidget + self.get_theme_list() + extensions_layout.addWidget(self.list_widget) + + self.setLayout(layout) + self.setWindowTitle("Extensions Downloader") + + def filter_list(self, text): + for i in range(self.list_widget.count()): + item = self.list_widget.item(i) + item_text = item.text() + if text.lower() in item_text.lower(): + item.setHidden(False) + else: + item.setHidden(True) + + username = "rohankishore" + repo = "AuraText-Themes" + + def get_theme_list(self): + api_url = f"https://api.github.com/repos/{self.username}/{self.repo}/contents/Themes" + response = requests.get(api_url) + if response.status_code == 200: + content = response.json() + files_info = [file["name"].split(".")[0] for file in content if file["type"] == "file"] + self.list_widget.clear() + for file_info in files_info: + install_button = QPushButton("Install", self) + install_button.setToolTip(f"Download '{file_info}'") + install_button.clicked.connect(lambda _, name=file_info: self.download_theme(name)) + self.list_widget.addItem(file_info) + self.list_widget.setItemWidget( + self.list_widget.item(self.list_widget.count() - 1), install_button + ) + + def download_theme(self, file_name): + selected_file = file_name + ".json" + download_url = f"https://raw.githubusercontent.com/{self.username}/{self.repo}/main/Themes/{selected_file}" + response = requests.get(download_url) + + if response.status_code == 200: + local_file_path = os.path.join(self._window.local_app_data, "plugins", selected_file) + with open(local_file_path, "wb") as file: + file.write(response.content) + + # Assuming you want to copy the downloaded file to "theme.json" + theme_json_path = os.path.join(self._window.local_app_data, "data", "theme.json") + shutil.copy(local_file_path, theme_json_path) + + QMessageBox.information( + self, + "Theme Downloaded", + f"Theme '{selected_file}' has been applied successfully.", + ) + + # Update the Install button to "Installed" and disable it + for i in range(self.list_widget.count()): + item = self.list_widget.item(i) + if item.text() == file_name: + button = self.list_widget.itemWidget(item) + button.setText("Installed") + button.setDisabled(True) + break + else: + QMessageBox.critical( + self, + "Download Failed", + f"Failed to download theme '{selected_file}'.\nStatus Code: {response.status_code}\nContent: {response.content}", + ) + + +if __name__ == "__main__": + app = QApplication(sys.argv) + window = ThemeDownloader() + window.show() + sys.exit(app.exec()) diff --git a/auratext/Core/window.py b/auratext/Core/window.py index 3a954c3..2ff478b 100644 --- a/auratext/Core/window.py +++ b/auratext/Core/window.py @@ -33,6 +33,7 @@ from . import additional_prefs from . import Modules as ModuleFile from . import PluginDownload +from . import ThemeDownload from . import WelcomeScreen from . import config_page from . import terminal @@ -63,8 +64,8 @@ def __init__(self): # self._terminal_history = "" # COMMENTED OUT CODE FOR FRAMELESS WINDOW. IN DEVELOPMENT - #self.setWindowFlags(Qt.WindowType.FramelessWindowHint) - #self.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground) + # self.setWindowFlags(Qt.WindowType.FramelessWindowHint) + # self.setAttribute(Qt.WidgetAttribute.WA_TranslucentBackground) with open(f"{local_app_data}/data/theme.json", "r") as themes_file: self._themes = json.load(themes_file) @@ -127,7 +128,7 @@ def splashScreen(): self.addDockWidget(Qt.DockWidgetArea.LeftDockWidgetArea, self.sidebar_main) self.bottom_bar = QStatusBar() - #self.setStatusBar(self.bottom_bar) + # self.setStatusBar(self.bottom_bar) self.statusbar = Sidebar("", self) self.statusbar.setTitleBarWidget(QWidget()) @@ -204,13 +205,13 @@ def splashScreen(): self.load_plugins() self.showMaximized() - #def mousePressEvent(self, event): - # self.dragPos = event.globalPosition().toPoint() + # def mousePressEvent(self, event): + # self.dragPos = event.globalPosition().toPoint() - #def mouseMoveEvent(self, event): - #self.move(self.pos() + event.globalPosition().toPoint() - self.dragPos) - #self.dragPos = event.globalPosition().toPoint() - #event.accept() + # def mouseMoveEvent(self, event): + # self.move(self.pos() + event.globalPosition().toPoint() - self.dragPos) + # self.dragPos = event.globalPosition().toPoint() + # event.accept() def create_editor(self): self.text_editor = CodeEditor(self) @@ -315,11 +316,13 @@ def expandSidebar__Settings(self): def expandSidebar__Plugins(self): self.plugin_dock = QDockWidget("Extensions", self) + self.theme_dock = QDockWidget("Themes", self) background_color = ( self.plugin_button.palette().color(self.plugin_button.backgroundRole()).name() ) if background_color == "#3574f0": self.plugin_dock.destroy() + self.theme_dock.destroy() else: self.plugin_dock.visibilityChanged.connect( lambda visible: self.onPluginDockVisibilityChanged(visible) @@ -330,8 +333,16 @@ def expandSidebar__Plugins(self): self.plugin_layout.addStretch(1) self.plugin_layout.addWidget(self.plugin_widget) self.plugin_dock.setWidget(self.plugin_widget) - self.addDockWidget(Qt.DockWidgetArea.RightDockWidgetArea, self.plugin_dock) + self.theme_widget = ThemeDownload.ThemeDownloader(self) + self.theme_layout = QVBoxLayout() + self.theme_layout.addStretch(1) + self.theme_layout.addWidget(self.theme_widget) + self.theme_dock.setWidget(self.theme_widget) + + self.addDockWidget(Qt.DockWidgetArea.RightDockWidgetArea ,self.plugin_dock) + self.addDockWidget(Qt.DockWidgetArea.RightDockWidgetArea ,self.theme_dock) + self.tabifyDockWidget(self.theme_dock, self.plugin_dock) def new_project(self): new_folder_path = filedialog.askdirectory( @@ -490,11 +501,11 @@ def html(self): def toggle_read_only(self): self.current_editor.setReadOnly(True) - #self.read_only_button.setIcon(self.read_only_icon) + # self.read_only_button.setIcon(self.read_only_icon) def read_only_reset(self): self.current_editor.setReadOnly(False) - #@self.read_only_button.setIcon(self.write_button_icon) + # @self.read_only_button.setIcon(self.write_button_icon) def cpp(self): Lexers.cpp(self) @@ -652,6 +663,16 @@ def goto_line(self): if ok: self.setCursorPosition(line_number - 1, 0) + def import_theme(self): + theme_open = filedialog.askopenfilename(title="Open JSON File", defaultextension='.json', + filetypes=[('JSON file', '*.json')]) + theme_path = os.path.abspath(theme_open) + + import shutil + + shutil.copyfile(theme_path, f'{local_app_data}/data/theme.json') # copy src to dst + + def open_project(self): dialog = QFileDialog(self) dialog.setFileMode(QFileDialog.FileMode.Directory)