Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Plasma
Plasma Add-ons
Commits
6c88a6fa
Verified
Commit
6c88a6fa
authored
May 05, 2022
by
Fushan Wen
Browse files
dict: Add `dictLoadingChanged` signal to indicate the downloading status
parent
528c551b
Changes
2
Hide whitespace changes
Inline
Side-by-side
dict/dictengine.cpp
View file @
6c88a6fa
...
...
@@ -174,6 +174,7 @@ void DictEngine::getDicts()
m_tcpSocket
->
disconnectFromHost
();
m_availableDictsCache
.
insert
(
m_serverName
,
availableDicts
);
Q_EMIT
dictsRecieved
(
availableDicts
);
Q_EMIT
dictLoadingChanged
(
false
);
}
void
DictEngine
::
requestDicts
()
...
...
@@ -188,11 +189,13 @@ void DictEngine::requestDicts()
m_tcpSocket
=
nullptr
;
}
Q_EMIT
dictLoadingChanged
(
true
);
m_tcpSocket
=
new
QTcpSocket
(
this
);
connect
(
m_tcpSocket
,
&
QTcpSocket
::
disconnected
,
this
,
&
DictEngine
::
socketClosed
);
connect
(
m_tcpSocket
,
&
QTcpSocket
::
readyRead
,
this
,
&
DictEngine
::
getDicts
);
m_tcpSocket
->
connectToHost
(
m_serverName
,
2628
);
}
void
DictEngine
::
requestDefinition
(
const
QString
&
query
)
{
if
(
m_tcpSocket
)
{
...
...
@@ -233,6 +236,8 @@ void DictEngine::requestDefinition(const QString &query)
void
DictEngine
::
socketClosed
()
{
Q_EMIT
dictLoadingChanged
(
false
);
if
(
m_tcpSocket
)
{
m_tcpSocket
->
deleteLater
();
}
...
...
dict/dictengine.h
View file @
6c88a6fa
...
...
@@ -27,8 +27,15 @@ public:
~
DictEngine
()
override
;
Q_SIGNALS:
/**
* @param loading @c true if the dict finder is downloading dict list from
* the Internet, @c false otherwise.
*/
void
dictLoadingChanged
(
bool
loading
);
void
dictsRecieved
(
const
QMap
<
QString
,
QString
>
&
dicts
);
void
definitionRecieved
(
const
QString
&
html
);
public
Q_SLOTS
:
void
requestDicts
();
void
requestDefinition
(
const
QString
&
query
);
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment