gc settings screen added

This commit is contained in:
ingvar1995 2018-08-22 12:08:00 +03:00
parent 85ea9ab6e8
commit 0ee8a0ec21
10 changed files with 139 additions and 11 deletions

View File

@ -1 +1 @@
{"nodes":[{"ipv4":"80.211.19.83","ipv6":"-","port":33445,"public_key":"C78997BEA65096B09EAD41F850116D798A0D4A14D2D8652FCD2495ADDE006523","status_udp":true,"status_tcp":true}]} {"nodes":[{"ipv4":"80.211.19.83","ipv6":"-","port":33445,"public_key":"A05AFD9C7B785ADBB93DCD55FC8992177A2BA50413AAD7AD8D3442EE5E7ADA21","status_udp":true,"status_tcp":true}]}

View File

@ -184,6 +184,9 @@ class GroupMenuGenerator(BaseContactMenuGenerator):
.with_optional_action(util_ui.tr('Manage group'), .with_optional_action(util_ui.tr('Manage group'),
lambda: groups_service.show_group_management_screen(self._contact), lambda: groups_service.show_group_management_screen(self._contact),
self._contact.is_self_founder()) self._contact.is_self_founder())
.with_optional_action(util_ui.tr('Group settings'),
lambda: groups_service.show_group_settings_screen(self._contact),
not self._contact.is_self_founder())
.with_optional_action(util_ui.tr('Set topic'), .with_optional_action(util_ui.tr('Set topic'),
lambda: groups_service.set_group_topic(self._contact), lambda: groups_service.set_group_topic(self._contact),
self._contact.is_self_moderator_or_founder()) self._contact.is_self_moderator_or_founder())

View File

@ -118,6 +118,11 @@ class GroupsService(tox_save.ToxSave):
self._screen = widgets_factory.create_group_management_screen(group) self._screen = widgets_factory.create_group_management_screen(group)
self._screen.show() self._screen.show()
def show_group_settings_screen(self, group):
widgets_factory = self._get_widgets_factory()
self._screen = widgets_factory.create_group_settings_screen(group)
self._screen.show()
def set_group_password(self, group, password): def set_group_password(self, group, password):
if group.password == password: if group.password == password:
return return

View File

@ -25,9 +25,9 @@ class GroupManagementScreen(CenteredWidget):
def _retranslate_ui(self): def _retranslate_ui(self):
self.setWindowTitle(util_ui.tr('Group "{}"').format(self._group.name)) self.setWindowTitle(util_ui.tr('Group "{}"').format(self._group.name))
self.passwordLabel.setText(util_ui.tr('Password')) self.passwordLabel.setText(util_ui.tr('Password:'))
self.peerLimitLabel.setText(util_ui.tr('Peer limit:')) self.peerLimitLabel.setText(util_ui.tr('Peer limit:'))
self.privacyStateLabel.setText(util_ui.tr('Privacy state')) self.privacyStateLabel.setText(util_ui.tr('Privacy state:'))
self.savePushButton.setText(util_ui.tr('Save')) self.savePushButton.setText(util_ui.tr('Save'))
self.privacyStateComboBox.clear() self.privacyStateComboBox.clear()
@ -44,3 +44,34 @@ class GroupManagementScreen(CenteredWidget):
self._groups_service.set_group_peers_limit(self._group, peers_limit) self._groups_service.set_group_peers_limit(self._group, peers_limit)
self.close() self.close()
class GroupSettingsScreen(CenteredWidget):
def __init__(self, group):
super().__init__()
self._group = group
uic.loadUi(util.get_views_path('gc_settings_screen'), self)
self._update_ui()
def _update_ui(self):
self._retranslate_ui()
self.copyPasswordPushButton.clicked.connect(self._copy_password)
self.copyPasswordPushButton.setEnabled(bool(self._group.password))
def _retranslate_ui(self):
self.setWindowTitle(util_ui.tr('Group "{}"').format(self._group.name))
if self._group.password:
password_label_text = '{} {}'.format(util_ui.tr('Password:'), self._group.password)
else:
password_label_text = util_ui.tr('Password is not set')
self.passwordLabel.setText(password_label_text)
self.peerLimitLabel.setText('{} {}'.format(util_ui.tr('Peer limit:'), self._group.peers_limit))
privacy_state = util_ui.tr('Private') if self._group.is_private else util_ui.tr('Public')
self.privacyStateLabel.setText('{} {}'.format(util_ui.tr('Privacy state:'), privacy_state))
self.copyPasswordPushButton.setText(util_ui.tr('Copy password'))
def _copy_password(self):
util_ui.copy_to_clipboard(self._group.password)

View File

@ -650,8 +650,7 @@ class MainWindow(QtWidgets.QMainWindow):
@staticmethod @staticmethod
def copy_text(text): def copy_text(text):
clipboard = QtWidgets.QApplication.clipboard() util_ui.copy_to_clipboard(text)
clipboard.setText(text)
def clear_history(self, num): def clear_history(self, num):
self._history_loader.clear_history(num) self._history_loader.clear_history(num)

View File

@ -92,8 +92,7 @@ class PeerScreen(CenteredWidget):
self.close() self.close()
def _copy_public_key(self): def _copy_public_key(self):
clipboard = QtWidgets.QApplication.clipboard() util_ui.copy_to_clipboard(self._peer.public_key)
clipboard.setText(self._peer.public_key)
def _ban_peer(self): def _ban_peer(self):
ban_type = self._get_ban_type() ban_type = self._get_ban_type()

View File

@ -1,5 +1,5 @@
from ui.widgets import CenteredWidget, LineEdit from ui.widgets import CenteredWidget, LineEdit
from PyQt5 import QtCore, QtWidgets, uic from PyQt5 import uic
import utils.util as util import utils.util as util
import utils.ui as util_ui import utils.ui as util_ui
from ui.contact_items import * from ui.contact_items import *
@ -63,5 +63,4 @@ class SelfPeerScreen(CenteredWidget):
self.close() self.close()
def _copy_public_key(self): def _copy_public_key(self):
clipboard = QtWidgets.QApplication.clipboard() util_ui.copy_to_clipboard(self._peer.public_key)
clipboard.setText(self._peer.public_key)

View File

@ -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>400</width>
<height>220</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>400</width>
<height>220</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>400</width>
<height>220</height>
</size>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<widget class="QLabel" name="passwordLabel">
<property name="geometry">
<rect>
<x>10</x>
<y>20</y>
<width>380</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
<widget class="QPushButton" name="copyPasswordPushButton">
<property name="geometry">
<rect>
<x>10</x>
<y>60</y>
<width>380</width>
<height>40</height>
</rect>
</property>
<property name="text">
<string>PushButton</string>
</property>
</widget>
<widget class="QLabel" name="peerLimitLabel">
<property name="geometry">
<rect>
<x>10</x>
<y>120</y>
<width>380</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
<widget class="QLabel" name="privacyStateLabel">
<property name="geometry">
<rect>
<x>10</x>
<y>160</y>
<width>380</width>
<height>20</height>
</rect>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -4,7 +4,7 @@ from ui.groups_widgets import *
from ui.peer_screen import * from ui.peer_screen import *
from ui.self_peer_screen import * from ui.self_peer_screen import *
from ui.group_invites_widgets import * from ui.group_invites_widgets import *
from ui.group_management_screen import * from ui.group_settings_widgets import *
from ui.group_bans_widgets import * from ui.group_bans_widgets import *
@ -88,5 +88,9 @@ class WidgetsFactory:
def create_group_management_screen(self, group): def create_group_management_screen(self, group):
return GroupManagementScreen(self._groups_service, group) return GroupManagementScreen(self._groups_service, group)
@staticmethod
def create_group_settings_screen(group):
return GroupSettingsScreen(group)
def create_groups_bans_screen(self, group): def create_groups_bans_screen(self, group):
return GroupBansScreen(self._groups_service, group) return GroupBansScreen(self._groups_service, group)

View File

@ -46,4 +46,9 @@ def close_all_windows():
QtWidgets.QApplication.closeAllWindows() QtWidgets.QApplication.closeAllWindows()
def copy_to_clipboard(text):
clipboard = QtWidgets.QApplication.clipboard()
clipboard.setText(text)
# TODO: all dialogs # TODO: all dialogs