# HG changeset patch # User Torsten Lilge # Date 1555614879 -7200 # Node ID 1bdfd2b523c912ed91b1af512f67e3f3fdccf06e # Parent 44d1fe403c191fecf434bd6188526577f2a69996 use tab icon for indicating a modified editor file (bug #56158) * file-editor-tab.cc (update_window_title): emit file name changed signal with new boolean parameter indicating modification state * file-editor-tab.h: signal file_name_changed has new boolean parameter * file-editor.cc (handle_file_name_changed): new boolean parameter indicating modification state, set document-save icon to the tab if file is modified; (add_file_editor_tab): Updated signal connection sue to new parameter * file-editor.h: signal slot handle_file_name_changed with new parameter diff -r 44d1fe403c19 -r 1bdfd2b523c9 libgui/src/m-editor/file-editor-tab.cc --- a/libgui/src/m-editor/file-editor-tab.cc Wed Apr 17 20:35:52 2019 +0000 +++ b/libgui/src/m-editor/file-editor-tab.cc Thu Apr 18 21:14:39 2019 +0200 @@ -1641,10 +1641,7 @@ } } - if (modified) - emit file_name_changed (title.prepend ("* "), tooltip); - else - emit file_name_changed (title, tooltip); + emit file_name_changed (title, tooltip, modified); } void file_editor_tab::handle_copy_available (bool enableCopy) diff -r 44d1fe403c19 -r 1bdfd2b523c9 libgui/src/m-editor/file-editor-tab.h --- a/libgui/src/m-editor/file-editor-tab.h Wed Apr 17 20:35:52 2019 +0000 +++ b/libgui/src/m-editor/file-editor-tab.h Thu Apr 18 21:14:39 2019 +0200 @@ -154,7 +154,9 @@ signals: - void file_name_changed (const QString& fileName, const QString& toolTip); + void file_name_changed (const QString& fileName, + const QString& toolTip, + bool modified); void editor_state_changed (bool copy_available, bool is_octave_file); void set_focus_editor_signal (QWidget *); void tab_remove_request (void); diff -r 44d1fe403c19 -r 1bdfd2b523c9 libgui/src/m-editor/file-editor.cc --- a/libgui/src/m-editor/file-editor.cc Wed Apr 17 20:35:52 2019 +0000 +++ b/libgui/src/m-editor/file-editor.cc Thu Apr 18 21:14:39 2019 +0200 @@ -756,7 +756,8 @@ } void file_editor::handle_file_name_changed (const QString& fname, - const QString& tip) + const QString& tip, + bool modified) { QObject *fileEditorTab = sender (); if (fileEditorTab) @@ -767,6 +768,11 @@ { m_tab_widget->setTabText (i, fname); m_tab_widget->setTabToolTip (i, tip); + if (modified) + m_tab_widget->setTabIcon (i, + resource_manager::icon ("document-save")); + else + m_tab_widget->setTabIcon (i, QIcon ()); } } } @@ -2173,9 +2179,9 @@ main_win (), SLOT (execute_command_in_terminal (const QString&))); // Signals from the file editor_tab - connect (f, SIGNAL (file_name_changed (const QString&, const QString&)), + connect (f, SIGNAL (file_name_changed (const QString&, const QString&, bool)), this, SLOT (handle_file_name_changed (const QString&, - const QString&))); + const QString&, bool))); connect (f, SIGNAL (editor_state_changed (bool, bool)), this, SLOT (handle_editor_state_changed (bool, bool))); diff -r 44d1fe403c19 -r 1bdfd2b523c9 libgui/src/m-editor/file-editor.h --- a/libgui/src/m-editor/file-editor.h Wed Apr 17 20:35:52 2019 +0000 +++ b/libgui/src/m-editor/file-editor.h Thu Apr 18 21:14:39 2019 +0200 @@ -246,7 +246,8 @@ void request_completion (bool); void handle_file_name_changed (const QString& fileName, - const QString& toolTip); + const QString& toolTip, + bool modified); void handle_tab_close_request (int index); void handle_tab_remove_request (void); void handle_add_filename_to_list (const QString& fileName,