Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nheko
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nheko Reborn
nheko
Commits
ec8820ac
Commit
ec8820ac
authored
2 years ago
by
Loren Burkholder
Browse files
Options
Downloads
Patches
Plain Diff
Fix some nitpicks
parent
c27407bf
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#4535
failed
2 years ago
Stage: build
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/timeline/InputBar.cpp
+57
-52
57 additions, 52 deletions
src/timeline/InputBar.cpp
src/timeline/InputBar.h
+1
-1
1 addition, 1 deletion
src/timeline/InputBar.h
with
58 additions
and
53 deletions
src/timeline/InputBar.cpp
+
57
−
52
View file @
ec8820ac
...
...
@@ -253,50 +253,51 @@ InputBar::updateTextContentProperties(const QString &t)
// check for invalid commands
auto
commandName
=
getCommandAndArgs
().
first
;
bool
hasInvalidCommand
{};
if
(
!
commandName
.
isNull
()
&&
'/'
+
commandName
!=
text
())
{
static
const
QStringList
validCommands
{
QStringLiteral
(
"me"
),
QStringLiteral
(
"react"
),
QStringLiteral
(
"join"
),
QStringLiteral
(
"knock"
),
QStringLiteral
(
"part"
),
QStringLiteral
(
"leave"
),
QStringLiteral
(
"invite"
),
QStringLiteral
(
"kick"
),
QStringLiteral
(
"ban"
),
QStringLiteral
(
"unban"
),
QStringLiteral
(
"redact"
),
QStringLiteral
(
"roomnick"
),
QStringLiteral
(
"shrug"
),
QStringLiteral
(
"fliptable"
),
QStringLiteral
(
"unfliptable"
),
QStringLiteral
(
"sovietflip"
),
QStringLiteral
(
"clear-timeline"
),
QStringLiteral
(
"reset-state"
),
QStringLiteral
(
"rotate-megolm-session"
),
QStringLiteral
(
"md"
),
QStringLiteral
(
"cmark"
),
QStringLiteral
(
"plain"
),
QStringLiteral
(
"rainbow"
),
QStringLiteral
(
"rainbowme"
),
QStringLiteral
(
"notice"
),
QStringLiteral
(
"rainbownotice"
),
QStringLiteral
(
"confetti"
),
QStringLiteral
(
"rainbowconfetti"
),
QStringLiteral
(
"goto"
),
QStringLiteral
(
"converttodm"
),
QStringLiteral
(
"converttoroom"
)};
hasInvalidCommand
=
!
validCommands
.
contains
(
commandName
);
}
else
hasInvalidCommand
=
false
;
static
const
QStringList
validCommands
{
QStringLiteral
(
"me"
),
QStringLiteral
(
"react"
),
QStringLiteral
(
"join"
),
QStringLiteral
(
"knock"
),
QStringLiteral
(
"part"
),
QStringLiteral
(
"leave"
),
QStringLiteral
(
"invite"
),
QStringLiteral
(
"kick"
),
QStringLiteral
(
"ban"
),
QStringLiteral
(
"unban"
),
QStringLiteral
(
"redact"
),
QStringLiteral
(
"roomnick"
),
QStringLiteral
(
"shrug"
),
QStringLiteral
(
"fliptable"
),
QStringLiteral
(
"unfliptable"
),
QStringLiteral
(
"sovietflip"
),
QStringLiteral
(
"clear-timeline"
),
QStringLiteral
(
"reset-state"
),
QStringLiteral
(
"rotate-megolm-session"
),
QStringLiteral
(
"md"
),
QStringLiteral
(
"cmark"
),
QStringLiteral
(
"plain"
),
QStringLiteral
(
"rainbow"
),
QStringLiteral
(
"rainbowme"
),
QStringLiteral
(
"notice"
),
QStringLiteral
(
"rainbownotice"
),
QStringLiteral
(
"confetti"
),
QStringLiteral
(
"rainbowconfetti"
),
QStringLiteral
(
"goto"
),
QStringLiteral
(
"converttodm"
),
QStringLiteral
(
"converttoroom"
)};
bool
hasInvalidCommand
=
!
commandName
.
isNull
()
&&
'/'
+
commandName
!=
text
()
&&
!
validCommands
.
contains
(
commandName
);
bool
signalsChanged
{
false
};
if
(
containsInvalidCommand_
!=
hasInvalidCommand
)
{
containsInvalidCommand_
=
hasInvalidCommand
;
emit
containsInvalidCommandChanged
()
;
signalsChanged
=
true
;
}
if
(
currentCommand_
!=
commandName
)
{
currentCommand_
=
commandName
;
signalsChanged
=
true
;
}
if
(
signalsChanged
)
{
emit
currentCommandChanged
();
emit
containsInvalidCommandChanged
();
}
}
...
...
@@ -390,10 +391,11 @@ InputBar::send()
auto
wasEdit
=
!
room
->
edit
().
isEmpty
();
if
(
auto
[
commandName
,
args
]
=
getCommandAndArgs
();
commandName
.
is
Null
())
if
(
auto
[
commandName
,
args
]
=
getCommandAndArgs
();
commandName
.
is
Empty
())
message
(
text
());
else
command
(
commandName
,
args
);
if
(
!
command
(
commandName
,
args
))
message
(
text
());
if
(
!
wasEdit
)
{
history_
.
push_front
(
QLatin1String
(
""
));
...
...
@@ -758,16 +760,17 @@ InputBar::video(const QString &filename,
QPair
<
QString
,
QString
>
InputBar
::
getCommandAndArgs
()
const
{
if
(
!
text
().
startsWith
(
'/'
))
return
{{},
text
()};
const
auto
currentText
=
text
();
if
(
!
currentText
.
startsWith
(
'/'
))
return
{{},
currentText
};
int
command_end
=
t
ext
()
.
indexOf
(
QRegularExpression
(
QStringLiteral
(
"
\\
s"
)));
int
command_end
=
currentT
ext
.
indexOf
(
QRegularExpression
(
QStringLiteral
(
"
\\
s"
)));
if
(
command_end
==
-
1
)
command_end
=
t
ext
()
.
size
();
auto
name
=
t
ext
()
.
mid
(
1
,
command_end
-
1
);
auto
args
=
t
ext
()
.
mid
(
command_end
+
1
);
command_end
=
currentT
ext
.
size
();
auto
name
=
currentT
ext
.
mid
(
1
,
command_end
-
1
);
auto
args
=
currentT
ext
.
mid
(
command_end
+
1
);
if
(
name
.
isEmpty
()
||
name
==
QLatin1String
(
"/"
))
{
return
{{},
t
ext
()
};
return
{{},
currentT
ext
};
}
else
{
return
{
name
,
args
};
}
...
...
@@ -798,7 +801,7 @@ InputBar::sticker(CombinedImagePackModel *model, int row)
room
->
sendMessageEvent
(
sticker
,
mtx
::
events
::
EventType
::
Sticker
);
}
void
bool
InputBar
::
command
(
const
QString
&
command
,
QString
args
)
{
if
(
command
==
QLatin1String
(
"me"
))
{
...
...
@@ -886,16 +889,16 @@ InputBar::command(const QString &command, QString args)
// 1 - Going directly to a given event ID
if
(
args
[
0
]
==
'$'
)
{
room
->
showEvent
(
args
);
return
;
return
true
;
}
// 2 - Going directly to a given message index
if
(
args
[
0
]
>=
'0'
&&
args
[
0
]
<=
'9'
)
{
room
->
showEvent
(
args
);
return
;
return
true
;
}
// 3 - Matrix URI handler, as if you clicked the URI
if
(
ChatPage
::
instance
()
->
handleMatrixUri
(
args
))
{
return
;
return
true
;
}
nhlog
::
net
()
->
error
(
"Could not resolve goto: {}"
,
args
.
toStdString
());
}
else
if
(
command
==
QLatin1String
(
"converttodm"
))
{
...
...
@@ -904,8 +907,10 @@ InputBar::command(const QString &command, QString args)
}
else
if
(
command
==
QLatin1String
(
"converttoroom"
))
{
utils
::
removeDirectFromRoom
(
this
->
room
->
roomId
());
}
else
{
message
(
"/"
+
command
+
" "
+
args
)
;
return
false
;
}
return
true
;
}
MediaUpload
::
MediaUpload
(
std
::
unique_ptr
<
QIODevice
>
source_
,
...
...
This diff is collapsed.
Click to expand it.
src/timeline/InputBar.h
+
1
−
1
View file @
ec8820ac
...
...
@@ -238,7 +238,7 @@ private:
void
emote
(
const
QString
&
body
,
bool
rainbowify
);
void
notice
(
const
QString
&
body
,
bool
rainbowify
);
void
confetti
(
const
QString
&
body
,
bool
rainbowify
);
void
command
(
const
QString
&
name
,
QString
args
);
bool
command
(
const
QString
&
name
,
QString
args
);
void
image
(
const
QString
&
filename
,
const
std
::
optional
<
mtx
::
crypto
::
EncryptedFile
>
&
file
,
const
QString
&
url
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment