diff options
| author | Marcus Tillmanns <[email protected]> | 2024-09-27 12:20:58 +0200 |
|---|---|---|
| committer | Marcus Tillmanns <[email protected]> | 2024-10-08 11:01:45 +0000 |
| commit | 2109e64a7c6f4bb52d692f58cb52527d8a91decb (patch) | |
| tree | 9cd0d964f829a27ec3e8e1b425b2245c3936defc /src/plugins/lua/luaplugin.cpp | |
| parent | cfb64f3518a362f248839d656160f566ff436ca3 (diff) | |
Lua: Replace lua repl script
Change-Id: Iea236081b9cfecd29d7c5c2290570010c9a83276
Reviewed-by: Eike Ziller <[email protected]>
Diffstat (limited to 'src/plugins/lua/luaplugin.cpp')
| -rw-r--r-- | src/plugins/lua/luaplugin.cpp | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/plugins/lua/luaplugin.cpp b/src/plugins/lua/luaplugin.cpp index cb173b943d4..a1821094500 100644 --- a/src/plugins/lua/luaplugin.cpp +++ b/src/plugins/lua/luaplugin.cpp @@ -24,6 +24,7 @@ #include <QLabel> #include <QLineEdit> #include <QListView> +#include <QPainter> #include <QStringListModel> #include <QStyledItemDelegate> @@ -78,7 +79,7 @@ public: { auto label = new QLabel(parent); const QString text = index.data().toString(); - label->setText(text); + label->setText(text.startsWith("__ERROR__") ? text.mid(9) : text); label->setFont(option.font); label->setTextInteractionFlags( Qt::TextInteractionFlag::TextSelectableByMouse @@ -87,6 +88,29 @@ public: label->setSelection(0, text.size()); return label; } + + void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) + const override + { + QStyleOptionViewItem opt = option; + initStyleOption(&opt, index); + + bool isError = opt.text.startsWith("__ERROR__"); + + if (isError) + opt.text = opt.text.mid(9); + + if (opt.state & QStyle::State_Selected) { + painter->fillRect(opt.rect, opt.palette.highlight()); + painter->setPen(opt.palette.highlightedText().color()); + } else if (isError) { + painter->setPen(creatorColor(Theme::Token_Notification_Danger)); + } else { + painter->setPen(opt.palette.text().color()); + } + + painter->drawText(opt.rect, opt.displayAlignment, opt.text); + } }; class LuaReplView : public QListView @@ -135,6 +159,7 @@ public: m_model.setStringList(m_model.stringList() << msgs); scrollToBottom(); }; + lua["LuaCopyright"] = LUA_COPYRIGHT; sol::table async = lua.script("return require('async')", "_ilua_").get<sol::table>(); sol::function wrap = async["wrap"]; |
