groups - service, chat, callbacks
This commit is contained in:
parent
acf75a6818
commit
dfe7601dc1
15 changed files with 400 additions and 44 deletions
|
@ -26,9 +26,9 @@ class CreateProfileScreen(CenteredWidget, DialogWithResult):
|
|||
def __init__(self):
|
||||
CenteredWidget.__init__(self)
|
||||
DialogWithResult.__init__(self)
|
||||
uic.loadUi(util.get_views_path('create_profile_screen'))
|
||||
uic.loadUi(util.get_views_path('create_profile_screen'), self)
|
||||
self.center()
|
||||
self.createProfile.clicked.connect(self.create_profile)
|
||||
self.createProfile.clicked.connect(self._create_profile)
|
||||
|
||||
def retranslateUi(self):
|
||||
self.defaultFolder.setPlaceholderText(util_ui.tr('Save in default folder'))
|
||||
|
@ -36,7 +36,7 @@ class CreateProfileScreen(CenteredWidget, DialogWithResult):
|
|||
self.createProfile.setText(util_ui.tr('Create profile'))
|
||||
self.passwordLabel.setText(util_ui.tr('Password:'))
|
||||
|
||||
def create_profile(self):
|
||||
def _create_profile(self):
|
||||
if self.password.text() != self.confirmPassword.text():
|
||||
return # TODO : error
|
||||
result = CreateProfileScreenResult(self.defaultFolder.isChecked(), self.password.text())
|
||||
|
|
72
toxygen/ui/groups_widgets.py
Normal file
72
toxygen/ui/groups_widgets.py
Normal file
|
@ -0,0 +1,72 @@
|
|||
from PyQt5 import uic
|
||||
import utils.util as util
|
||||
from ui.widgets import *
|
||||
from wrapper.toxcore_enums_and_consts import *
|
||||
|
||||
|
||||
class CreateGroupScreen(CenteredWidget):
|
||||
|
||||
def __init__(self, groups_service):
|
||||
super().__init__()
|
||||
self._groups_service = groups_service
|
||||
uic.loadUi(util.get_views_path('create_group_screen'), self)
|
||||
self.center()
|
||||
self.retranslateUi()
|
||||
self.addGroupButton.clicked.connect(self._create_group)
|
||||
self.groupNameLineEdit.textChanged.connect(self._group_name_changed)
|
||||
|
||||
def retranslateUi(self):
|
||||
self.setWindowTitle(util_ui.tr('Create new group chat'))
|
||||
self.groupNameLabel.setText(util_ui.tr('Group name:'))
|
||||
self.groupTypeLabel.setText(util_ui.tr('Group type:'))
|
||||
self.groupNameLineEdit.setPlaceholderText(util_ui.tr('Group\'s persistent name'))
|
||||
self.addGroupButton.setText(util_ui.tr('Create group'))
|
||||
self.groupTypeComboBox.addItem(util_ui.tr('Public'))
|
||||
self.groupTypeComboBox.addItem(util_ui.tr('Private'))
|
||||
|
||||
def _create_group(self):
|
||||
name = self.groupNameLineEdit.text()
|
||||
privacy_state = self.groupTypeComboBox.currentIndex()
|
||||
self._groups_service.create_new_gc(name, privacy_state)
|
||||
self.close()
|
||||
|
||||
def _group_name_changed(self):
|
||||
name = self.groupNameLineEdit.text()
|
||||
self.addGroupButton.setEnabled(bool(name.strip()))
|
||||
|
||||
|
||||
class JoinGroupScreen(CenteredWidget):
|
||||
|
||||
def __init__(self, groups_service):
|
||||
super().__init__()
|
||||
self._groups_service = groups_service
|
||||
uic.loadUi(util.get_views_path('join_group_screen'), self)
|
||||
self.center()
|
||||
self.retranslateUi()
|
||||
self.chatIdLineEdit.textChanged.connect(self._chat_id_changed)
|
||||
self.joinGroupButton.clicked.connect(self._join_group)
|
||||
|
||||
def retranslateUi(self):
|
||||
self.setWindowTitle(util_ui.tr('Join public group chat'))
|
||||
self.chatIdLabel.setText(util_ui.tr('Group ID:'))
|
||||
self.passwordLabel.setText(util_ui.tr('Password:'))
|
||||
self.chatIdLineEdit.setPlaceholderText(util_ui.tr('Group\'s chat ID'))
|
||||
self.joinGroupButton.setText(util_ui.tr('Join group'))
|
||||
self.passwordLineEdit.setPlaceholderText(util_ui.tr('Optional password'))
|
||||
|
||||
def _chat_id_changed(self):
|
||||
chat_id = self._get_chat_id()
|
||||
self.joinGroupButton.setEnabled(len(chat_id) == TOX_GROUP_CHAT_ID_SIZE * 2)
|
||||
|
||||
def _join_group(self):
|
||||
chat_id = self._get_chat_id()
|
||||
password = self.passwordLineEdit.text()
|
||||
self._groups_service.join_gc_by_id(chat_id, password)
|
||||
self.close()
|
||||
|
||||
def _get_chat_id(self):
|
||||
chat_id = self.chatIdLineEdit.text().strip()
|
||||
if chat_id.startswith('tox:'):
|
||||
chat_id = chat_id[4:]
|
||||
|
||||
return chat_id
|
|
@ -110,6 +110,7 @@ class MainWindow(QtWidgets.QMainWindow):
|
|||
self.actionNetwork.triggered.connect(self.network_settings)
|
||||
self.actionAdd_friend.triggered.connect(self.add_contact_triggered)
|
||||
self.createGC.triggered.connect(self.create_gc)
|
||||
self.joinGC.triggered.connect(self.join_gc)
|
||||
self.actionSettings.triggered.connect(self.profile_settings)
|
||||
self.actionPrivacy_settings.triggered.connect(self.privacy_settings)
|
||||
self.actionInterface_settings.triggered.connect(self.interface_settings)
|
||||
|
@ -459,7 +460,12 @@ class MainWindow(QtWidgets.QMainWindow):
|
|||
self._modal_window.show()
|
||||
|
||||
def create_gc(self):
|
||||
self.profile.create_group_chat()
|
||||
self._modal_window = self._widget_factory.create_group_screen_window()
|
||||
self._modal_window.show()
|
||||
|
||||
def join_gc(self):
|
||||
self._modal_window = self._widget_factory.create_join_group_screen_window()
|
||||
self._modal_window.show()
|
||||
|
||||
def profile_settings(self, _):
|
||||
self._modal_window = self._widget_factory.create_profile_settings_window()
|
||||
|
|
81
toxygen/ui/views/create_group_screen.ui
Normal file
81
toxygen/ui/views/create_group_screen.ui
Normal file
|
@ -0,0 +1,81 @@
|
|||
<?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>639</width>
|
||||
<height>199</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<widget class="QPushButton" name="addGroupButton">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>180</x>
|
||||
<y>150</y>
|
||||
<width>271</width>
|
||||
<height>41</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="groupNameLineEdit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>140</x>
|
||||
<y>40</y>
|
||||
<width>471</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="groupTypeComboBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>140</x>
|
||||
<y>100</y>
|
||||
<width>471</width>
|
||||
<height>41</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="groupNameLabel">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>40</y>
|
||||
<width>121</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="groupTypeLabel">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>100</y>
|
||||
<width>121</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
81
toxygen/ui/views/join_group_screen.ui
Normal file
81
toxygen/ui/views/join_group_screen.ui
Normal file
|
@ -0,0 +1,81 @@
|
|||
<?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>739</width>
|
||||
<height>212</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<widget class="QLabel" name="chatIdLabel">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>40</y>
|
||||
<width>67</width>
|
||||
<height>17</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="passwordLabel">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>100</y>
|
||||
<width>67</width>
|
||||
<height>17</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="joinGroupButton">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>258</x>
|
||||
<y>150</y>
|
||||
<width>241</width>
|
||||
<height>51</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="chatIdLineEdit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>190</x>
|
||||
<y>20</y>
|
||||
<width>431</width>
|
||||
<height>41</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="passwordLineEdit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>190</x>
|
||||
<y>90</y>
|
||||
<width>431</width>
|
||||
<height>41</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -1,11 +1,12 @@
|
|||
from ui.main_screen_widgets import *
|
||||
from ui.menu import *
|
||||
from ui.groups_widgets import *
|
||||
|
||||
|
||||
class WidgetsFactory:
|
||||
|
||||
def __init__(self, settings, profile, profile_manager, contacts_manager, file_transfer_handler, smiley_loader,
|
||||
plugin_loader, toxes, version):
|
||||
plugin_loader, toxes, version, groups_service):
|
||||
self._settings = settings
|
||||
self._profile = profile
|
||||
self._profile_manager = profile_manager
|
||||
|
@ -15,6 +16,7 @@ class WidgetsFactory:
|
|||
self._plugin_loader = plugin_loader
|
||||
self._toxes = toxes
|
||||
self._version = version
|
||||
self._groups_service = groups_service
|
||||
|
||||
def create_screenshot_window(self, *args):
|
||||
return ScreenShotWindow(self._file_transfer_handler, self._contacts_manager, *args)
|
||||
|
@ -63,3 +65,9 @@ class WidgetsFactory:
|
|||
|
||||
def create_sticker_window(self):
|
||||
return StickerWindow(self._file_transfer_handler, self._contacts_manager)
|
||||
|
||||
def create_group_screen_window(self):
|
||||
return CreateGroupScreen(self._groups_service)
|
||||
|
||||
def create_join_group_screen_window(self):
|
||||
return JoinGroupScreen(self._groups_service)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue