forked from qt-creator/qt-creator
LayoutBuilder: Add a few Label related functions
... and use them in the CoPilot settings Change-Id: Id861cf34274d2afe798d4735072d02c2c8f724e3 Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
@@ -763,6 +763,31 @@ void Label::setText(const QString &text)
|
|||||||
access(this)->setText(text);
|
access(this)->setText(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Label::setTextFormat(Qt::TextFormat format)
|
||||||
|
{
|
||||||
|
access(this)->setTextFormat(format);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Label::setWordWrap(bool on)
|
||||||
|
{
|
||||||
|
access(this)->setWordWrap(on);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Label::setTextInteractionFlags(Qt::TextInteractionFlags flags)
|
||||||
|
{
|
||||||
|
access(this)->setTextInteractionFlags(flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Label::setOpenExternalLinks(bool on)
|
||||||
|
{
|
||||||
|
access(this)->setOpenExternalLinks(on);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Label::onLinkHovered(const std::function<void (const QString &)> &func, QObject *guard)
|
||||||
|
{
|
||||||
|
QObject::connect(access(this), &QLabel::linkHovered, guard, func);
|
||||||
|
}
|
||||||
|
|
||||||
// Group
|
// Group
|
||||||
|
|
||||||
Group::Group(std::initializer_list<I> ps)
|
Group::Group(std::initializer_list<I> ps)
|
||||||
|
@@ -279,6 +279,11 @@ public:
|
|||||||
Label(const QString &text);
|
Label(const QString &text);
|
||||||
|
|
||||||
void setText(const QString &);
|
void setText(const QString &);
|
||||||
|
void setTextFormat(Qt::TextFormat);
|
||||||
|
void setWordWrap(bool);
|
||||||
|
void setTextInteractionFlags(Qt::TextInteractionFlags);
|
||||||
|
void setOpenExternalLinks(bool);
|
||||||
|
void onLinkHovered(const std::function<void(const QString &)> &, QObject *guard);
|
||||||
};
|
};
|
||||||
|
|
||||||
class QTCREATOR_UTILS_EXPORT Group : public Widget
|
class QTCREATOR_UTILS_EXPORT Group : public Widget
|
||||||
@@ -446,6 +451,26 @@ class TitleId {};
|
|||||||
auto title(auto p) { return IdAndArg{TitleId{}, p}; }
|
auto title(auto p) { return IdAndArg{TitleId{}, p}; }
|
||||||
void doit(auto x, TitleId, auto p) { x->setTitle(p); }
|
void doit(auto x, TitleId, auto p) { x->setTitle(p); }
|
||||||
|
|
||||||
|
class TextFormatId {};
|
||||||
|
auto textFormat(auto p) { return IdAndArg{TextFormatId{}, p}; }
|
||||||
|
void doit(auto x, TextFormatId, auto p) { x->setTextFormat(p); }
|
||||||
|
|
||||||
|
class WordWrapId {};
|
||||||
|
auto wordWrap(auto p) { return IdAndArg{WordWrapId{}, p}; }
|
||||||
|
void doit(auto x, WordWrapId, auto p) { x->setWordWrap(p); }
|
||||||
|
|
||||||
|
class TextInteractionFlagId {};
|
||||||
|
auto textInteractionFlags(auto p) { return IdAndArg{TextInteractionFlagId{}, p}; }
|
||||||
|
void doit(auto x, TextInteractionFlagId, auto p) { x->setTextInteractionFlags(p); }
|
||||||
|
|
||||||
|
class OpenExternalLinksId {};
|
||||||
|
auto openExternalLinks(auto p) { return IdAndArg{OpenExternalLinksId{}, p}; }
|
||||||
|
void doit(auto x, OpenExternalLinksId, auto p) { x->setOpenExternalLinks(p); }
|
||||||
|
|
||||||
|
class OnLinkHoveredId {};
|
||||||
|
auto onLinkHovered(auto p, QObject *guard) { return IdAndArg{OnLinkHoveredId{}, std::pair{p, guard}}; }
|
||||||
|
void doit(auto x, OnLinkHoveredId, auto p) { x->onLinkHovered(p.first, p.second); }
|
||||||
|
|
||||||
class GroupCheckerId {};
|
class GroupCheckerId {};
|
||||||
auto groupChecker(auto p) { return IdAndArg{GroupCheckerId{}, p}; }
|
auto groupChecker(auto p) { return IdAndArg{GroupCheckerId{}, p}; }
|
||||||
void doit(auto x, GroupCheckerId, auto p) { x->setGroupChecker(p); }
|
void doit(auto x, GroupCheckerId, auto p) { x->setGroupChecker(p); }
|
||||||
|
@@ -168,33 +168,29 @@ CopilotSettings::CopilotSettings()
|
|||||||
setLayouter([this] {
|
setLayouter([this] {
|
||||||
using namespace Layouting;
|
using namespace Layouting;
|
||||||
|
|
||||||
auto warningLabel = new QLabel;
|
// clang-format off
|
||||||
warningLabel->setWordWrap(true);
|
|
||||||
warningLabel->setTextInteractionFlags(
|
Label warningLabel {
|
||||||
Qt::LinksAccessibleByMouse | Qt::LinksAccessibleByKeyboard | Qt::TextSelectableByMouse);
|
wordWrap(true),
|
||||||
warningLabel->setText(
|
textInteractionFlags(
|
||||||
Tr::tr("Enabling %1 is subject to your agreement and abidance with your applicable "
|
Qt::LinksAccessibleByMouse | Qt::LinksAccessibleByKeyboard | Qt::TextSelectableByMouse),
|
||||||
|
text(Tr::tr("Enabling %1 is subject to your agreement and abidance with your applicable "
|
||||||
"%1 terms. It is your responsibility to know and accept the requirements and "
|
"%1 terms. It is your responsibility to know and accept the requirements and "
|
||||||
"parameters of using tools like %1. This may include, but is not limited to, "
|
"parameters of using tools like %1. This may include, but is not limited to, "
|
||||||
"ensuring you have the rights to allow %1 access to your code, as well as "
|
"ensuring you have the rights to allow %1 access to your code, as well as "
|
||||||
"understanding any implications of your use of %1 and suggestions produced "
|
"understanding any implications of your use of %1 and suggestions produced "
|
||||||
"(like copyright, accuracy, etc.).")
|
"(like copyright, accuracy, etc.).")
|
||||||
.arg("Copilot"));
|
.arg("Copilot")),
|
||||||
|
};
|
||||||
|
|
||||||
auto authWidget = new AuthWidget();
|
Label helpLabel {
|
||||||
|
textFormat(Qt::MarkdownText),
|
||||||
auto helpLabel = new QLabel();
|
wordWrap(true),
|
||||||
helpLabel->setTextFormat(Qt::MarkdownText);
|
textInteractionFlags(
|
||||||
helpLabel->setWordWrap(true);
|
Qt::LinksAccessibleByMouse | Qt::LinksAccessibleByKeyboard | Qt::TextSelectableByMouse),
|
||||||
helpLabel->setTextInteractionFlags(
|
openExternalLinks(true),
|
||||||
Qt::LinksAccessibleByMouse | Qt::LinksAccessibleByKeyboard | Qt::TextSelectableByMouse);
|
onLinkHovered([](const QString &link) { QToolTip::showText(QCursor::pos(), link); }, this),
|
||||||
helpLabel->setOpenExternalLinks(true);
|
text(Tr::tr(
|
||||||
connect(helpLabel, &QLabel::linkHovered, [](const QString &link) {
|
|
||||||
QToolTip::showText(QCursor::pos(), link);
|
|
||||||
});
|
|
||||||
|
|
||||||
// clang-format off
|
|
||||||
helpLabel->setText(Tr::tr(
|
|
||||||
"The Copilot plugin requires node.js and the Copilot neovim plugin. "
|
"The Copilot plugin requires node.js and the Copilot neovim plugin. "
|
||||||
"If you install the neovim plugin as described in %1, "
|
"If you install the neovim plugin as described in %1, "
|
||||||
"the plugin will find the agent.js file automatically.\n\n"
|
"the plugin will find the agent.js file automatically.\n\n"
|
||||||
@@ -202,7 +198,8 @@ CopilotSettings::CopilotSettings()
|
|||||||
"file from the Copilot neovim plugin.",
|
"file from the Copilot neovim plugin.",
|
||||||
"Markdown text for the copilot instruction label")
|
"Markdown text for the copilot instruction label")
|
||||||
.arg("[README.md](https://github.com/github/copilot.vim)")
|
.arg("[README.md](https://github.com/github/copilot.vim)")
|
||||||
.arg("[agent.js](https://github.com/github/copilot.vim/tree/release/dist)"));
|
.arg("[agent.js](https://github.com/github/copilot.vim/tree/release/dist)"))
|
||||||
|
};
|
||||||
|
|
||||||
return Column {
|
return Column {
|
||||||
Group {
|
Group {
|
||||||
@@ -213,7 +210,7 @@ CopilotSettings::CopilotSettings()
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
Form {
|
Form {
|
||||||
authWidget, br,
|
new AuthWidget, br,
|
||||||
enableCopilot, br,
|
enableCopilot, br,
|
||||||
nodeJsPath, br,
|
nodeJsPath, br,
|
||||||
distPath, br,
|
distPath, br,
|
||||||
|
Reference in New Issue
Block a user