The title block template editor now displays a tooltip with the edited template's minimum and maximum widths.

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/branches/0.3@1540 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
xavier
2012-02-28 18:54:34 +00:00
parent ef2958eab1
commit fac0fea239
4 changed files with 114 additions and 0 deletions

View File

@@ -465,6 +465,8 @@ void TitleBlockTemplateView::applyColumnsWidths(bool animate) {
).arg(total_applied_width - preview_width_);
total_width_helper_cell_ -> split_size = total_applied_width - preview_width_;
}
updateDisplayedMinMaxWidth();
}
/**
@@ -735,6 +737,35 @@ void TitleBlockTemplateView::columnsDimensionsChanged() {
applyColumnsWidths();
}
/**
Update the tooltip that displays the minimum and/or maximum width of the
template.
*/
void TitleBlockTemplateView::updateDisplayedMinMaxWidth() {
if (!tbtemplate_) return;
int min_width = tbtemplate_ -> minimumWidth();
int max_width = tbtemplate_ -> maximumWidth();
QString min_max_width_sentence;
if (max_width != -1) {
min_max_width_sentence = QString(
tr(
"Minimum width: %1px\nMaximum width: %2px\n",
"tooltip showing the minimum and/or maximum width of the edited template"
)
).arg(min_width).arg(max_width);
} else {
min_max_width_sentence = QString(
tr(
"Minimum width: %1px\n",
"tooltip showing the minimum width of the edited template"
)
).arg(min_width);
}
total_width_helper_cell_ -> setToolTip(makePrettyToolTip(min_max_width_sentence));
}
/**
@param read_only whether this view should be read only.
@@ -848,6 +879,20 @@ TitleBlockTemplateCellsSet TitleBlockTemplateView::makeCellsSetFromGraphicsItems
return(set);
}
/*
@param a text string
@return an HTML string that can be passed to setToolTip()
*/
QString TitleBlockTemplateView::makePrettyToolTip(const QString &string) {
QString css_style = QString("white-space: pre;");
QString final_tooltip_content = QString(
"<div style=\"%1\">%2</div>"
).arg(css_style).arg(string);
return(final_tooltip_content);
}
/**
Stores \a last_context_menu_cell as being the last helper cell the context
menu was triggered on.