MCPcopy Create free account
hub / github.com/actor-framework/actor-framework / sendChatMessage

Method sendChatMessage

examples/qtsupport/chatwidget.cpp:73–101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

71}
72
73void ChatWidget::sendChatMessage() {
74 QString line = input()->text();
75 if (line.isEmpty()) {
76 // Ignore empty lines.
77 } else if (line.startsWith('/')) {
78 vector<string> words;
79 auto utf8 = QStringView{line}.mid(1).toUtf8();
80 auto sv = std::string_view{utf8.constData(),
81 static_cast<size_t>(utf8.size())};
82 split(words, sv, is_any_of(" "));
83 if (words.size() == 2 && words[0] == "setName") {
84 auto name = QString::fromUtf8(words[1]);
85 if (!name.isEmpty())
86 name_ = name;
87 } else {
88 print("*** list of commands:\n"
89 "/setName <new name>\n");
90 }
91 } else {
92 auto msg = name_;
93 msg += ": ";
94 msg += line;
95 print("<you>: " + input()->text());
96 if (publisher_) {
97 publisher_->push(msg);
98 }
99 }
100 input()->setText(QString());
101}
102
103void ChatWidget::changeName() {
104 auto name = QInputDialog::getText(this, "Change Name",

Callers

nothing calls this directly

Calls 5

is_any_ofFunction · 0.85
splitFunction · 0.50
printFunction · 0.50
sizeMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected