Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vmj-qt
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
vmj-qt
Commits
31fac3e1
Commit
31fac3e1
authored
Jun 03, 2022
by
Tijmen de Mes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added menu option to show last messages/chat
parent
1dfbed51
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
61 additions
and
1 deletion
+61
-1
chatwindow.py
blink/chatwindow.py
+14
-0
history.py
blink/history.py
+19
-1
mainwindow.py
blink/mainwindow.py
+5
-0
messages.py
blink/messages.py
+11
-0
blink.ui
resources/blink.ui
+12
-0
No files found.
blink/chatwindow.py
View file @
31fac3e1
...
@@ -1597,6 +1597,7 @@ class ChatWindow(base_class, ui_class, ColorHelperMixin):
...
@@ -1597,6 +1597,7 @@ class ChatWindow(base_class, ui_class, ColorHelperMixin):
notification_center
.
add_observer
(
self
,
name
=
'BlinkMessageDidFail'
)
notification_center
.
add_observer
(
self
,
name
=
'BlinkMessageDidFail'
)
notification_center
.
add_observer
(
self
,
name
=
'BlinkMessageHistoryLoadDidSucceed'
)
notification_center
.
add_observer
(
self
,
name
=
'BlinkMessageHistoryLoadDidSucceed'
)
notification_center
.
add_observer
(
self
,
name
=
'BlinkMessageHistoryLoadDidFail'
)
notification_center
.
add_observer
(
self
,
name
=
'BlinkMessageHistoryLoadDidFail'
)
notification_center
.
add_observer
(
self
,
name
=
'BlinkMessageHistoryLastContactsDidSucceed'
)
# self.splitter.splitterMoved.connect(self._SH_SplitterMoved) # check this and decide on what size to have in the window (see Notes) -Dan
# self.splitter.splitterMoved.connect(self._SH_SplitterMoved) # check this and decide on what size to have in the window (see Notes) -Dan
...
@@ -2045,6 +2046,13 @@ class ChatWindow(base_class, ui_class, ColorHelperMixin):
...
@@ -2045,6 +2046,13 @@ class ChatWindow(base_class, ui_class, ColorHelperMixin):
self
.
raise_
()
self
.
raise_
()
self
.
activateWindow
()
self
.
activateWindow
()
def
show_with_messages
(
self
):
super
(
ChatWindow
,
self
)
.
show
()
self
.
raise_
()
self
.
activateWindow
()
history
=
HistoryManager
()
history
.
get_last_contacts
()
def
closeEvent
(
self
,
event
):
def
closeEvent
(
self
,
event
):
QSettings
()
.
setValue
(
"chat_window/geometry"
,
self
.
saveGeometry
())
QSettings
()
.
setValue
(
"chat_window/geometry"
,
self
.
saveGeometry
())
super
(
ChatWindow
,
self
)
.
closeEvent
(
event
)
super
(
ChatWindow
,
self
)
.
closeEvent
(
event
)
...
@@ -2453,6 +2461,12 @@ class ChatWindow(base_class, ui_class, ColorHelperMixin):
...
@@ -2453,6 +2461,12 @@ class ChatWindow(base_class, ui_class, ColorHelperMixin):
session
.
chat_widget
.
history_loaded
=
True
session
.
chat_widget
.
history_loaded
=
True
session
.
chat_widget
.
show_loading_screen
(
False
)
session
.
chat_widget
.
show_loading_screen
(
False
)
def
_NH_BlinkMessageHistoryLastContactsDidSucceed
(
self
,
notification
):
contacts
=
notification
.
data
.
contacts
message_manager
=
MessageManager
()
for
contact
in
contacts
[::
-
1
]:
message_manager
.
create_message_session
(
contact
)
def
_NH_ChatStreamGotMessage
(
self
,
notification
):
def
_NH_ChatStreamGotMessage
(
self
,
notification
):
blink_session
=
notification
.
sender
.
blink_session
blink_session
=
notification
.
sender
.
blink_session
session
=
blink_session
.
items
.
chat
session
=
blink_session
.
items
.
chat
...
...
blink/history.py
View file @
31fac3e1
...
@@ -73,6 +73,9 @@ class HistoryManager(object, metaclass=Singleton):
...
@@ -73,6 +73,9 @@ class HistoryManager(object, metaclass=Singleton):
def
load
(
self
,
uri
,
session
):
def
load
(
self
,
uri
,
session
):
return
self
.
message_history
.
load
(
uri
,
session
)
return
self
.
message_history
.
load
(
uri
,
session
)
def
get_last_contacts
(
self
,
number
=
5
):
return
self
.
message_history
.
get_last_contacts
(
number
)
@
run_in_gui_thread
@
run_in_gui_thread
def
handle_notification
(
self
,
notification
):
def
handle_notification
(
self
,
notification
):
handler
=
getattr
(
self
,
'_NH_
%
s'
%
notification
.
name
,
Null
)
handler
=
getattr
(
self
,
'_NH_
%
s'
%
notification
.
name
,
Null
)
...
@@ -362,7 +365,22 @@ class MessageHistory(object, metaclass=Singleton):
...
@@ -362,7 +365,22 @@ class MessageHistory(object, metaclass=Singleton):
notification_center
.
post_notification
(
'BlinkMessageHistoryLoadDidFail'
,
sender
=
session
,
data
=
NotificationData
(
uri
=
uri
))
notification_center
.
post_notification
(
'BlinkMessageHistoryLoadDidFail'
,
sender
=
session
,
data
=
NotificationData
(
uri
=
uri
))
return
return
# print(f"-- Messages loaded: {len(list(result))}")
# print(f"-- Messages loaded: {len(list(result))}")
notification_center
.
post_notification
(
'BlinkMessageHistoryLoadDidSucceed'
,
sender
=
session
,
data
=
NotificationData
(
messages
=
list
(
result
),
uri
=
uri
))
notification_center
.
post_notification
(
'BlinkMessageHistoryLoadDidSucceed'
,
sender
=
session
,
data
=
NotificationData
(
messages
=
list
(
result
),
uri
=
uri
))
@
run_in_thread
(
'db'
)
def
get_last_contacts
(
self
,
number
=
5
):
# print(f'-- Getting last {number} contacts wtih messages')
query
=
f
'select distinct(remote_uri) from messages order by id desc limit {Message.sqlrepr(number)}'
notification_center
=
NotificationCenter
()
try
:
result
=
self
.
db
.
queryAll
(
query
)
except
Exception
as
e
:
return
# print(f"-- Contacts fetched: {len(list(result))}")
result
=
[
' '
.
join
(
item
)
for
item
in
result
]
notification_center
.
post_notification
(
'BlinkMessageHistoryLastContactsDidSucceed'
,
data
=
NotificationData
(
contacts
=
list
(
result
)))
@
run_in_thread
(
'db'
)
@
run_in_thread
(
'db'
)
def
remove
(
self
,
account
):
def
remove
(
self
,
account
):
...
...
blink/mainwindow.py
View file @
31fac3e1
...
@@ -204,6 +204,7 @@ class MainWindow(base_class, ui_class):
...
@@ -204,6 +204,7 @@ class MainWindow(base_class, ui_class):
self
.
history_on_server_action
.
triggered
.
connect
(
self
.
_AH_HistoryOnServer
)
self
.
history_on_server_action
.
triggered
.
connect
(
self
.
_AH_HistoryOnServer
)
self
.
google_contacts_action
.
triggered
.
connect
(
self
.
_AH_GoogleContactsActionTriggered
)
self
.
google_contacts_action
.
triggered
.
connect
(
self
.
_AH_GoogleContactsActionTriggered
)
self
.
show_last_messages_action
.
triggered
.
connect
(
self
.
_AH_ShowLastMessagesActionTriggered
)
# This will load messages from 5 last contacts used in messages/chat
# Window menu actions
# Window menu actions
self
.
chat_window_action
.
triggered
.
connect
(
self
.
_AH_ChatWindowActionTriggered
)
self
.
chat_window_action
.
triggered
.
connect
(
self
.
_AH_ChatWindowActionTriggered
)
self
.
transfers_window_action
.
triggered
.
connect
(
self
.
_AH_TransfersWindowActionTriggered
)
self
.
transfers_window_action
.
triggered
.
connect
(
self
.
_AH_TransfersWindowActionTriggered
)
...
@@ -430,6 +431,10 @@ class MainWindow(base_class, ui_class):
...
@@ -430,6 +431,10 @@ class MainWindow(base_class, ui_class):
blink
=
QApplication
.
instance
()
blink
=
QApplication
.
instance
()
blink
.
chat_window
.
show
()
blink
.
chat_window
.
show
()
def
_AH_ShowLastMessagesActionTriggered
(
self
,
checked
):
blink
=
QApplication
.
instance
()
blink
.
chat_window
.
show_with_messages
()
def
_AH_TransfersWindowActionTriggered
(
self
,
checked
):
def
_AH_TransfersWindowActionTriggered
(
self
,
checked
):
self
.
filetransfer_window
.
show
()
self
.
filetransfer_window
.
show
()
...
...
blink/messages.py
View file @
31fac3e1
...
@@ -300,3 +300,14 @@ class MessageManager(object, metaclass=Singleton):
...
@@ -300,3 +300,14 @@ class MessageManager(object, metaclass=Singleton):
outgoing_message
=
OutgoingMessage
(
account
,
contact
,
content
,
content_type
,
recipients
,
courtesy_recipients
,
subject
,
timestamp
,
required
,
additional_headers
,
id
)
outgoing_message
=
OutgoingMessage
(
account
,
contact
,
content
,
content_type
,
recipients
,
courtesy_recipients
,
subject
,
timestamp
,
required
,
additional_headers
,
id
)
outgoing_message
.
send
(
blink_session
)
outgoing_message
.
send
(
blink_session
)
def
create_message_session
(
self
,
uri
):
from
blink.contacts
import
URIUtils
contact
,
contact_uri
=
URIUtils
.
find_contact
(
uri
)
session_manager
=
SessionManager
()
account
=
AccountManager
()
.
default_account
try
:
next
(
session
for
session
in
self
.
sessions
if
session
.
reusable
and
session
.
contact
.
settings
is
contact
.
settings
)
except
StopIteration
:
session_manager
.
create_session
(
contact
,
contact_uri
,
[
StreamDescription
(
'messages'
)],
account
=
account
,
connect
=
False
)
resources/blink.ui
View file @
31fac3e1
...
@@ -1131,6 +1131,7 @@ padding: 2px;</string>
...
@@ -1131,6 +1131,7 @@ padding: 2px;</string>
<string>
&
Chat
</string>
<string>
&
Chat
</string>
</property>
</property>
<addaction
name=
"join_conference_action"
/>
<addaction
name=
"join_conference_action"
/>
<addaction
name=
"show_last_messages_action"
/>
<addaction
name=
"auto_accept_chat_action"
/>
<addaction
name=
"auto_accept_chat_action"
/>
<addaction
name=
"received_messages_sound_action"
/>
<addaction
name=
"received_messages_sound_action"
/>
</widget>
</widget>
...
@@ -1444,6 +1445,17 @@ padding: 2px;</string>
...
@@ -1444,6 +1445,17 @@ padding: 2px;</string>
<string>
&
Auto-answer
</string>
<string>
&
Auto-answer
</string>
</property>
</property>
</action>
</action>
<action
name=
"show_last_messages_action"
>
<property
name=
"text"
>
<string>
&
Show last messages/chats
</string>
</property>
<property
name=
"shortcut"
>
<string>
Ctrl+O
</string>
</property>
<property
name=
"shortcutContext"
>
<enum>
Qt::ApplicationShortcut
</enum>
</property>
</action>
</widget>
</widget>
<customwidgets>
<customwidgets>
<customwidget>
<customwidget>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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