pj`$dZddlZddlmZddlmZddlmZddlmZddl m Z m Z m Z m Z mZmZmZmZeej'j(dd z d z d z Zed z Zd ZdedefdZdeddfdZGdde ZdZedk(reyy)uEditor istantaneo per il diario di lavoro — pannello PyQt6, stile Frank/MyICR Suite. Un file .md per giorno (frontmatter + testo libero). All'apertura carica tutto il contenuto gia' presente, editabile ovunque, con una riga vuota gia' timbrata in fondo pronta per scrivere. Il salvataggio (periodico + alla chiusura) scrive semplicemente tutto il contenuto della casella nel file: nessun controllo di concorrenza, non ce n'e' motivo (un solo editore alla volta, keep simple). N)datetime)Path)QTimer) QTextCursor) QApplication QHBoxLayoutQLabel QMainWindowQPlainTextEdit QPushButton QVBoxLayoutQWidgetarchivioMaurodiarioz _i_diario.mdi0udate_strreturncd|dS)Nz --- date: z tipo: diario --- )rs A/mnt/ssd/data/Dropbox/adrian/tools/diario-editor/diario_editor.py frontmatterr s  "7 88ctjsytjd}d|d}||vryd|vrytj|j dd|dzdy)zAggiunge il nuovo giorno all'elenco in _i_diario.md, senza mai toccare la descrizione scritta a mano sopra. Se l'hub non esiste ancora, non lo crea (e' un file curato a mano, non generato dall'app).Nutf-8encodingz- [[z]]z ## Giorni ) DIARIO_HUBexists read_text write_textrstrip)rcontententrys rregister_in_hubr&$ss    ""G"4G8*B E '!'...2eWB?'Rrc6eZdZfdZdZdZdZdZxZS) DiarioEditorc6t|tjj d|_t |j dz |_t jdd|jjsE|jjt|j dt|j |jjd}tjj d}|jdd |d z|_d|_|j#t%||_|j&j(j+|j,|j&j/t0y) Nz%Y-%m-%dz.mdT)parentsexist_okrr%H:%Mr **** — )super__init__rnowstrftimetodayARCHIVIO_DIARIO file_pathmkdirr r"rr&r!r# initial_text last_saved _build_uirtimertimeoutconnectsavestartSAVE_INTERVAL_MS)selfexistingr1 __class__s rr0zDiarioEditor.__init__4s# \\^,,Z8 (djj\+==dT:~~$$& NN % %k$**&= % P DJJ '>>++W+=lln%%g.$OOD1fSE4II D\  ""499- )*rcH|jd|j|jddt}t |}t |jd}|j d|j|t|_ |jj|j|jj}|jtjj |jj#||j|jt%}t'd|_|j(j*j-|j.|j1|j|j(|j3|t d|_|j4j d|j|j4|j7||jj9y) Nu Diario — i0iu3 · #lavoro / #casa dove serve · editabile ovunquez color: #666;z+ Nuova voce (ora)zcolor: #999; font-size: 11px;)setWindowTitler3resizerr r setStyleSheet addWidgetr text_edit setPlainTextr7 textCursor movePositionr MoveOperationEnd setTextCursorrr new_entry_buttonclickedr<insert_new_entry addStretch addLayoutstatussetCentralWidgetsetFocus)r@ containerlayoutinfocursor button_rows rr9zDiarioEditor._build_uiJs k$**67 CI Y' $WXY >*') ##D$5$56**,K5599: $$V,( ] +,@ A %%--d.C.CDT223$Rj  !!"AB% i( !rctjjd}|jj j d}|jj |d|dz|jj}|jtjj|jj||jjy)zAppende in fondo una nuova riga timbrata con l'ora attuale, senza dover chiudere e riaprire l'app (l'unico modo, prima, di ottenere un orario aggiornato per un secondo pensiero nella stessa sessione).r,rr-r.N)rr1r2rI toPlainTextr#rJrKrLrrMrNrOrW)r@r1currentr[s rrRzDiarioEditor.insert_new_entryjslln%%g...,,.55d; ##Gse7.C$CD**,K5599: $$V, !rc|jj}||jk(ry|jj |d||_|j j dtjjdy)NrrzSalvato z%H:%M:%S) rIr^r8r5r"rUsetTextrr1r2)r@r$s rr=zDiarioEditor.savevsl..,,. doo %  !!'G!<! hx||~'>'>z'J&KLMrcD|j|jyN)r=accept)r@events r closeEventzDiarioEditor.closeEvent~s  r) __name__ __module__ __qualname__r0r9rRr=rf __classcell__)rBs@rr(r(3s+,"@ "Nrr(cttj}t}|j tj |j yrc)rsysargvr(showexitexec)appwindows rmainrss2 sxx C ^F KKMHHSXXZr__main__)__doc__rlrpathlibr PyQt6.QtCorer PyQt6.QtGuirPyQt6.QtWidgetsrrr r r r r r__file__resolver*r4rr?strrr&r(rsrgrrrr}s #   x.((*2215 BWLxW ~ - 9#9#9 Sc Sd SM;M` zFr