forked from qt-creator/qt-creator
TextEditor: Collect the comment position setting from highlighter
Change-Id: I802b9e263a3515fe340459329a8c8d8f309cfa0e Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -38,7 +38,7 @@ struct BehaviorSettingsWidgetPrivate
|
||||
QComboBox *smartBackspaceBehavior;
|
||||
QCheckBox *autoIndent;
|
||||
QCheckBox *preferSingleLineComments;
|
||||
QCheckBox *preferAfterWhitespaceComments;
|
||||
QComboBox *commentPosition;
|
||||
QGroupBox *groupBoxStorageSettings;
|
||||
QGroupBox *groupBoxTyping;
|
||||
QCheckBox *skipTrailingWhitespace;
|
||||
@@ -96,7 +96,48 @@ BehaviorSettingsWidget::BehaviorSettingsWidget(QWidget *parent)
|
||||
d->autoIndent = new QCheckBox(Tr::tr("Enable automatic &indentation"));
|
||||
|
||||
d->preferSingleLineComments = new QCheckBox(Tr::tr("Prefer single line comments"));
|
||||
d->preferAfterWhitespaceComments = new QCheckBox(Tr::tr("Prefer comments after whitespace"));
|
||||
d->commentPosition = new QComboBox;
|
||||
const QString automaticText = Tr::tr("Automatic");
|
||||
d->commentPosition->addItem(automaticText);
|
||||
const QString lineStartText = Tr::tr("At Line Start");
|
||||
d->commentPosition->addItem(lineStartText);
|
||||
const QString afterWhitespaceText = Tr::tr("After Whitespace");
|
||||
d->commentPosition->addItem(afterWhitespaceText);
|
||||
|
||||
const QString generalCommentPosition = Tr::tr(
|
||||
"Specifies where single line comments should be positioned.");
|
||||
const QString automaticCommentPosition
|
||||
= Tr::tr(
|
||||
"%1: The highlight definition for the file determines the position. If no highlight "
|
||||
"definition is available, the comment is placed after leading whitespaces.")
|
||||
.arg(automaticText);
|
||||
const QString lineStartCommentPosition
|
||||
= Tr::tr("%1: The comment is placed at the start of the line.").arg(lineStartText);
|
||||
const QString afterWhitespaceCommentPosition
|
||||
= Tr::tr("%1: The comment is placed after leading whitespaces.").arg(afterWhitespaceText);
|
||||
|
||||
const QString commentPositionToolTip = QString("<html><head/><body>\n"
|
||||
"%1\n"
|
||||
"\n"
|
||||
"<ul>\n"
|
||||
"<li>%2\n"
|
||||
"</li>\n"
|
||||
"\n"
|
||||
"<li>%3\n"
|
||||
"</li>\n"
|
||||
"\n"
|
||||
"<li>%4\n"
|
||||
"</li>\n"
|
||||
"</ul></body></html>\n"
|
||||
"")
|
||||
.arg(generalCommentPosition)
|
||||
.arg(automaticCommentPosition)
|
||||
.arg(lineStartCommentPosition)
|
||||
.arg(afterWhitespaceCommentPosition);
|
||||
d->commentPosition->setToolTip(commentPositionToolTip);
|
||||
|
||||
auto commentPositionLabel = new QLabel(Tr::tr("Preferred comment position"));
|
||||
commentPositionLabel->setToolTip(commentPositionToolTip);
|
||||
|
||||
d->skipTrailingWhitespace = new QCheckBox(Tr::tr("Skip clean whitespace for file types:"));
|
||||
d->skipTrailingWhitespace->setToolTip(Tr::tr("For the file patterns listed, do not trim trailing whitespace."));
|
||||
@@ -176,7 +217,8 @@ BehaviorSettingsWidget::BehaviorSettingsWidget(QWidget *parent)
|
||||
Tr::tr("Tab key performs auto-indent:"),
|
||||
indent(d->tabKeyBehavior),
|
||||
d->preferSingleLineComments,
|
||||
d->preferAfterWhitespaceComments
|
||||
commentPositionLabel,
|
||||
indent(d->commentPosition)
|
||||
}.attachTo(d->groupBoxTyping);
|
||||
|
||||
Column {
|
||||
@@ -296,7 +338,7 @@ void BehaviorSettingsWidget::setAssignedTypingSettings(const TypingSettings &typ
|
||||
d->tabKeyBehavior->setCurrentIndex(typingSettings.m_tabKeyBehavior);
|
||||
|
||||
d->preferSingleLineComments->setChecked(typingSettings.m_preferSingleLineComments);
|
||||
d->preferAfterWhitespaceComments->setChecked(typingSettings.m_preferAfterWhitespaceComments);
|
||||
d->commentPosition->setCurrentIndex(typingSettings.m_commentPosition);
|
||||
}
|
||||
|
||||
void BehaviorSettingsWidget::assignedTypingSettings(TypingSettings *typingSettings) const
|
||||
@@ -308,7 +350,8 @@ void BehaviorSettingsWidget::assignedTypingSettings(TypingSettings *typingSettin
|
||||
(TypingSettings::TabKeyBehavior)(d->tabKeyBehavior->currentIndex());
|
||||
|
||||
typingSettings->m_preferSingleLineComments = d->preferSingleLineComments->isChecked();
|
||||
typingSettings->m_preferAfterWhitespaceComments = d->preferAfterWhitespaceComments->isChecked();
|
||||
typingSettings->m_commentPosition = TypingSettings::CommentPosition(
|
||||
d->commentPosition->currentIndex());
|
||||
}
|
||||
|
||||
void BehaviorSettingsWidget::setAssignedStorageSettings(const StorageSettings &storageSettings)
|
||||
|
||||
Reference in New Issue
Block a user