11import os
22import sys
3- import psutil
4- from PySide6 .QtWidgets import QMainWindow , QWidget , QVBoxLayout , QTabWidget , QFileDialog , QMessageBox , QLabel , QStatusBar , QGraphicsOpacityEffect
3+ from PySide6 .QtWidgets import QMainWindow , QWidget , QVBoxLayout , QTabWidget , QFileDialog , QMessageBox , QGraphicsOpacityEffect
54from PySide6 .QtGui import QAction , QIcon , QKeySequence , QTextCursor
65from PySide6 .QtCore import Qt , QPropertyAnimation
76
@@ -625,22 +624,8 @@ def set_active_build_target(self, target):
625624 self .lbl_status .setText (f"Active Build Target: { target } " )
626625
627626 def create_status_bar (self ):
628- status = QStatusBar ()
629- status .setStyleSheet ("background-color: #2b2d30; color: #bcbec4; border-top: 1px solid #393b40;" )
630- self .setStatusBar (status )
631-
632- cores = os .cpu_count () or "Unavailable"
633- ram_gb = round (psutil .virtual_memory ().total / (1024 ** 3 ), 1 )
634-
635- self .lbl_status = QLabel (f"Ready [{ self .active_build_config } ]" )
636- self .lbl_cursor_pos = QLabel ("Ln 1, Col 1 | C" )
637- self .lbl_cursor_pos .setStyleSheet ("color: #a1a3ab; margin-right: 15px;" )
638- self .lbl_sys_info = QLabel (f" CPU: { cores } Cores | RAM: { ram_gb } GB (Live OS) " )
639- self .lbl_sys_info .setStyleSheet ("color: #58a6ff; font-weight: bold;" )
640-
641- status .addWidget (self .lbl_status , 1 )
642- status .addPermanentWidget (self .lbl_cursor_pos )
643- status .addPermanentWidget (self .lbl_sys_info )
627+ from medha .status import StatusController
628+ self .status_controller = StatusController (self )
644629
645630 def confirm_close (self , widget ):
646631 if not isinstance (widget , AdvancedCodeEditorWidget ) or not widget .is_modified :
@@ -670,6 +655,7 @@ def close_tab(self, index):
670655 self .show_welcome ()
671656
672657 def on_tab_changed (self , index ):
658+ self .update_cursor_status ()
673659 editor = self .get_current_editor ()
674660 if editor and hasattr (editor , 'get_symbol_outline' ):
675661 symbols = editor .get_symbol_outline ()
@@ -687,13 +673,8 @@ def update_tab_title(self, editor):
687673 break
688674
689675 def update_cursor_status (self ):
690- editor = self .get_current_editor ()
691- if editor :
692- cursor = editor .textCursor ()
693- line = cursor .blockNumber () + 1
694- col = cursor .columnNumber () + 1
695- lang = getattr (editor , 'lang' , 'cpp' ).upper ()
696- self .lbl_cursor_pos .setText (f"Ln { line } , Col { col } | { lang } " )
676+ if hasattr (self , 'status_controller' ):
677+ self .status_controller .document_changed ()
697678
698679 def apply_dark_theme (self ):
699680 self .apply_theme (self .workbench .prefs .value ('theme' , 'dark' ))
@@ -768,6 +749,7 @@ def open_file_path(self, path):
768749
769750 filename = os .path .basename (path )
770751 editor = AdvancedCodeEditorWidget (file_path = path , parent = self )
752+ editor .encoding_label = 'UTF-8 (replacement)' if '\ufffd ' in content else 'UTF-8'
771753 editor .setPlainText (content )
772754 editor .document ().setModified (False )
773755 editor .is_modified = False
@@ -807,6 +789,8 @@ def action_open_folder(self):
807789 self .workspace_path = folder
808790 self .explorer .set_workspace (folder )
809791 self .terminal .set_working_directory (folder )
792+ self .workspace_ctrl = HybridWorkspaceController (folder )
793+ self .status_controller .refresh ()
810794 self .lbl_status .setText (f"Opened workspace: { folder } " )
811795
812796 def action_save_file (self ):
@@ -1030,6 +1014,7 @@ def on_runner_finished(self, exit_code, diagnostics):
10301014 self .turbo_panel .on_finished (exit_code )
10311015 self ._turbo_active = False
10321016 self .problems .set_diagnostics (diagnostics )
1017+ self .status_controller .set_diagnostics (diagnostics )
10331018 if diagnostics :
10341019 self .bottom_tabs .setCurrentWidget (self .problems )
10351020 self .lbl_status .setText (f"Build Finished with { len (diagnostics )} diagnostic error(s)." )
0 commit comments