private messages support
parent
e15620c3ad
commit
5521b768bc
@ -0,0 +1,13 @@
|
||||
|
||||
|
||||
class Provider:
|
||||
|
||||
def __init__(self, get_item_action):
|
||||
self._get_item_action = get_item_action
|
||||
self._item = None
|
||||
|
||||
def get_item(self):
|
||||
if self._item is None:
|
||||
self._item = self._get_item_action()
|
||||
|
||||
return self._item
|
@ -0,0 +1,23 @@
|
||||
from common.tox_save import ToxSave
|
||||
from contacts.group_peer_contact import GroupPeerContact
|
||||
|
||||
|
||||
class GroupPeerFactory(ToxSave):
|
||||
|
||||
def __init__(self, tox, profile_manager, db, items_factory):
|
||||
super().__init__(tox)
|
||||
self._profile_manager = profile_manager
|
||||
self._db = db
|
||||
self._items_factory = items_factory
|
||||
|
||||
def create_group_peer(self, group, peer):
|
||||
item = self._create_group_peer_item()
|
||||
message_getter = self._db.messages_getter(peer.public_key)
|
||||
group_peer_contact = GroupPeerContact(self._profile_manager, message_getter, peer.id, peer.name,
|
||||
item, peer.public_key, group.tox_id)
|
||||
group_peer_contact.status = peer.status
|
||||
|
||||
return group_peer_contact
|
||||
|
||||
def _create_group_peer_item(self):
|
||||
return self._items_factory.create_contact_item()
|
@ -0,0 +1,36 @@
|
||||
from ui.widgets import CenteredWidget
|
||||
from PyQt5 import QtCore, QtWidgets, uic
|
||||
import utils.util as util
|
||||
import utils.ui as util_ui
|
||||
from ui.contact_items import *
|
||||
|
||||
|
||||
class PeerScreen(CenteredWidget):
|
||||
|
||||
def __init__(self, contacts_manager, groups_service, group, peer_id):
|
||||
super().__init__()
|
||||
self._contacts_manager = contacts_manager
|
||||
self._groups_service = groups_service
|
||||
self._group = group
|
||||
self._peer = group.get_peer_by_id(peer_id)
|
||||
|
||||
uic.loadUi(util.get_views_path('peer_screen'), self)
|
||||
self._update_ui()
|
||||
|
||||
def _update_ui(self):
|
||||
self.statusCircle = StatusCircle(self)
|
||||
self.statusCircle.setGeometry(50, 20, 20, 20)
|
||||
self.statusCircle.update(self._peer.status)
|
||||
self.peerNameLabel.setText(self._peer.name)
|
||||
self.ignorePeerCheckBox.setChecked(self._peer.is_muted)
|
||||
self.sendPrivateMessagePushButton.clicked.connect(self._send_private_message)
|
||||
self._retranslate_ui()
|
||||
|
||||
def _retranslate_ui(self):
|
||||
self.setWindowTitle(util_ui.tr('Peer details'))
|
||||
self.ignorePeerCheckBox.setText(util_ui.tr('Ignore peer'))
|
||||
self.sendPrivateMessagePushButton.setText(util_ui.tr('Send private message'))
|
||||
|
||||
def _send_private_message(self):
|
||||
self._contacts_manager.add_group_peer(self._group, self._peer)
|
||||
self.close()
|
@ -0,0 +1,83 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Form</class>
|
||||
<widget class="QWidget" name="Form">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>600</width>
|
||||
<height>400</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>600</width>
|
||||
<height>400</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>600</width>
|
||||
<height>400</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<widget class="QLabel" name="peerNameLabel">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>110</x>
|
||||
<y>10</y>
|
||||
<width>431</width>
|
||||
<height>41</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="sendPrivateMessagePushButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>50</x>
|
||||
<y>120</y>
|
||||
<width>500</width>
|
||||
<height>50</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="ignorePeerCheckBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>50</x>
|
||||
<y>70</y>
|
||||
<width>500</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>CheckBox</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="banGroupBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>50</x>
|
||||
<y>200</y>
|
||||
<width>521</width>
|
||||
<height>161</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>GroupBox</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
Loading…
Reference in New Issue