Title block template editor: the window title now displays a [Modified] tag.

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/branches/0.3@1458 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
xavier
2012-01-12 07:24:21 +00:00
parent fa11ec59ad
commit 44dbe5a20f
2 changed files with 34 additions and 6 deletions

View File

@@ -392,6 +392,35 @@ void QETTitleBlockTemplateEditor::initLogoManager() {
);
}
/**
@return a string describing what is being edited, along with [Changed] or
[Read only] tags. Useful to compose the window title.
*/
QString QETTitleBlockTemplateEditor::currentlyEditedTitle() const {
QString titleblock_title;
if (opened_from_file_) {
titleblock_title = filepath_;
} else {
titleblock_title = location_.name();
}
// if a (file)name has been added, also add a "[Changed]" tag if needed
if (!titleblock_title.isEmpty()) {
QString tag;
if (!undo_stack_ -> isClean()) {
tag = tr("[Modifi\351]", "window title tag");
}
titleblock_title = QString(
tr(
"%1 %2",
"part of the window title - %1 is the filepath or template name, %2 is the [Changed] or [Read only] tag"
)
).arg(titleblock_title).arg(tag);
}
return(titleblock_title);
}
/**
Update various things when user changes the selected cells.
@param selected_cells List of selected cells.
@@ -434,6 +463,7 @@ void QETTitleBlockTemplateEditor::pushUndoCommand(QUndoCommand *command) {
Set the title of this editor.
*/
void QETTitleBlockTemplateEditor::updateEditorTitle() {
// base title
QString min_title(
tr(
"QElectroTech - \311diteur de mod\350le de cartouche",
@@ -441,13 +471,10 @@ void QETTitleBlockTemplateEditor::updateEditorTitle() {
)
);
QString titleblock_title;
if (opened_from_file_) {
titleblock_title = filepath_;
} else {
titleblock_title = location_.name();
}
// get the currently edited template (file)name
QString titleblock_title = currentlyEditedTitle();
// generate the final window title
QString title;
if (titleblock_title.isEmpty()) {
title = min_title;

View File

@@ -85,6 +85,7 @@ class QETTitleBlockTemplateEditor : public QMainWindow {
void initMenus();
void initWidgets();
void initLogoManager();
QString currentlyEditedTitle() const;
public slots:
void selectedCellsChanged(QList<TitleBlockCell *>);