create profile screen, main screen opens now
This commit is contained in:
parent
85467e1885
commit
91d3f885c0
15 changed files with 286 additions and 118 deletions
43
toxygen/ui/create_profile_screen.py
Normal file
43
toxygen/ui/create_profile_screen.py
Normal file
|
@ -0,0 +1,43 @@
|
|||
from ui.widgets import *
|
||||
from PyQt5 import uic
|
||||
import util.util as util
|
||||
import util.ui as util_ui
|
||||
|
||||
|
||||
class CreateProfileScreenResult:
|
||||
|
||||
def __init__(self, save_into_default_folder, password):
|
||||
self._save_into_default_folder = save_into_default_folder
|
||||
self._password = password
|
||||
|
||||
def get_save_into_default_folder(self):
|
||||
return self._save_into_default_folder
|
||||
|
||||
save_into_default_folder = property(get_save_into_default_folder)
|
||||
|
||||
def get_password(self):
|
||||
return self._password
|
||||
|
||||
password = property(get_password)
|
||||
|
||||
|
||||
class CreateProfileScreen(CenteredWidget, DialogWithResult):
|
||||
|
||||
def __init__(self):
|
||||
CenteredWidget.__init__(self)
|
||||
DialogWithResult.__init__(self)
|
||||
uic.loadUi(util.get_views_path('create_profile_screen'))
|
||||
self.center()
|
||||
self.createProfile.clicked.connect(self.create_profile)
|
||||
|
||||
def retranslateUi(self):
|
||||
self.defaultFolder.setPlaceholderText(util_ui.tr('Save in default folder'))
|
||||
self.programFolder.setPlaceholderText(util_ui.tr('Save in program folder'))
|
||||
self.createProfile.setText(util_ui.tr('Create profile'))
|
||||
self.passwordLabel.setText(util_ui.tr('Password:'))
|
||||
|
||||
def create_profile(self):
|
||||
if self.password.text() != self.confirmPassword.text():
|
||||
return # TODO : error
|
||||
result = CreateProfileScreenResult(self.defaultFolder.isChecked(), self.password.text())
|
||||
self.close_with_result(result)
|
|
@ -5,7 +5,7 @@ import os.path
|
|||
class NickEdit(LineEdit):
|
||||
|
||||
def __init__(self, parent):
|
||||
super(NickEdit, self).__init__(parent)
|
||||
super().__init__(parent)
|
||||
self.parent = parent
|
||||
|
||||
def keyPressEvent(self, event):
|
||||
|
@ -108,7 +108,7 @@ class LoginScreen(CenteredWidget, DialogWithResult):
|
|||
def load_existing_profile(self):
|
||||
index = self.comboBox.currentIndex()
|
||||
load_as_default = self.default.isChecked()
|
||||
path = os.path.join(self._profiles[index][0], self._profiles[index][1] + '.tox')
|
||||
path = os.path.join(self._profiles[index][0], self._profiles[index][1] + '.tox')
|
||||
result = LoginScreenResult(path, load_as_default)
|
||||
self.close_with_result(result)
|
||||
|
||||
|
@ -118,9 +118,3 @@ class LoginScreen(CenteredWidget, DialogWithResult):
|
|||
self.comboBox.addItems(list(map(lambda p: p[1], profiles)))
|
||||
self.load_profile.setEnabled(len(profiles) > 0)
|
||||
|
||||
def update_on_close(self, func):
|
||||
self.onclose = func
|
||||
|
||||
def closeEvent(self, event):
|
||||
self.onclose(self.type, self.number, self.load_as_default, self.name)
|
||||
event.accept()
|
||||
|
|
|
@ -5,19 +5,20 @@ from ui.widgets import MultilineEdit, ComboBox
|
|||
import plugin_support
|
||||
from ui.main_screen_widgets import *
|
||||
from user_data import toxes, settings
|
||||
import util.util as util
|
||||
|
||||
|
||||
class MainWindow(QtWidgets.QMainWindow, Singleton):
|
||||
class MainWindow(QtWidgets.QMainWindow):
|
||||
|
||||
def __init__(self, tox, reset, tray):
|
||||
def __init__(self, settings, tox, reset, tray):
|
||||
super().__init__()
|
||||
Singleton.__init__(self)
|
||||
self._settings = settings
|
||||
self.reset = reset
|
||||
self.tray = tray
|
||||
self.setAcceptDrops(True)
|
||||
self.initUI(tox)
|
||||
self._saved = False
|
||||
if settings.Settings.get_instance()['show_welcome_screen']:
|
||||
if settings['show_welcome_screen']:
|
||||
self.ws = WelcomeScreen()
|
||||
|
||||
def setup_menu(self, window):
|
||||
|
@ -137,7 +138,7 @@ class MainWindow(QtWidgets.QMainWindow, Singleton):
|
|||
self.online_contacts.addItem(QtWidgets.QApplication.translate("MainWindow", "Name"))
|
||||
self.online_contacts.addItem(QtWidgets.QApplication.translate("MainWindow", "Online and by name"))
|
||||
self.online_contacts.addItem(QtWidgets.QApplication.translate("MainWindow", "Online first and by name"))
|
||||
ind = Settings.get_instance()['sorting']
|
||||
ind = self._settings['sorting']
|
||||
d = {0: 0, 1: 1, 2: 2, 3: 4, 1 | 4: 4, 2 | 4: 5}
|
||||
self.online_contacts.setCurrentIndex(d[ind])
|
||||
self.importPlugin.setText(QtWidgets.QApplication.translate("MainWindow", "Import plugin"))
|
||||
|
@ -150,7 +151,7 @@ class MainWindow(QtWidgets.QMainWindow, Singleton):
|
|||
self.messageEdit.setObjectName("messageEdit")
|
||||
font = QtGui.QFont()
|
||||
font.setPointSize(11)
|
||||
font.setFamily(settings.Settings.get_instance()['font'])
|
||||
font.setFamily(self._settings['font'])
|
||||
self.messageEdit.setFont(font)
|
||||
|
||||
self.sendMessageButton = QtWidgets.QPushButton(Form)
|
||||
|
@ -207,7 +208,7 @@ class MainWindow(QtWidgets.QMainWindow, Singleton):
|
|||
self.name = Form.name = DataLabel(Form)
|
||||
Form.name.setGeometry(QtCore.QRect(75, 15, 150, 25))
|
||||
font = QtGui.QFont()
|
||||
font.setFamily(settings.Settings.get_instance()['font'])
|
||||
font.setFamily(self._settings['font'])
|
||||
font.setPointSize(14)
|
||||
font.setBold(True)
|
||||
Form.name.setFont(font)
|
||||
|
@ -235,7 +236,7 @@ class MainWindow(QtWidgets.QMainWindow, Singleton):
|
|||
self.account_name.setGeometry(QtCore.QRect(100, 0, 400, 25))
|
||||
self.account_name.setTextInteractionFlags(QtCore.Qt.LinksAccessibleByMouse)
|
||||
font = QtGui.QFont()
|
||||
font.setFamily(settings.Settings.get_instance()['font'])
|
||||
font.setFamily(self._settings['font'])
|
||||
font.setPointSize(14)
|
||||
font.setBold(True)
|
||||
self.account_name.setFont(font)
|
||||
|
@ -297,10 +298,9 @@ class MainWindow(QtWidgets.QMainWindow, Singleton):
|
|||
|
||||
def initUI(self, tox):
|
||||
self.setMinimumSize(920, 500)
|
||||
s = Settings.get_instance()
|
||||
s = self._settings
|
||||
self.setGeometry(s['x'], s['y'], s['width'], s['height'])
|
||||
self.setWindowTitle('Toxygen')
|
||||
os.chdir(curr_directory() + '/images/')
|
||||
menu = QtWidgets.QWidget()
|
||||
main = QtWidgets.QWidget()
|
||||
grid = QtWidgets.QGridLayout()
|
||||
|
@ -317,7 +317,7 @@ class MainWindow(QtWidgets.QMainWindow, Singleton):
|
|||
self.setup_right_bottom(message_buttons)
|
||||
self.setup_left_center(main_list)
|
||||
self.setup_menu(menu)
|
||||
if not Settings.get_instance()['mirror_mode']:
|
||||
if not self._settings['mirror_mode']:
|
||||
grid.addWidget(search, 2, 0)
|
||||
grid.addWidget(name, 1, 0)
|
||||
grid.addWidget(messages, 2, 1, 2, 1)
|
||||
|
@ -391,7 +391,7 @@ class MainWindow(QtWidgets.QMainWindow, Singleton):
|
|||
self.account_name.setGeometry(QtCore.QRect(100, 15, self.width() - 560, 25))
|
||||
self.account_status.setGeometry(QtCore.QRect(100, 35, self.width() - 560, 25))
|
||||
self.messageEdit.setFocus()
|
||||
self.profile.update()
|
||||
#self.profile.update()
|
||||
|
||||
def keyPressEvent(self, event):
|
||||
if event.key() == QtCore.Qt.Key_Escape and QtWidgets.QSystemTrayIcon.isSystemTrayAvailable():
|
||||
|
@ -561,14 +561,13 @@ class MainWindow(QtWidgets.QMainWindow, Singleton):
|
|||
self.update_call_state('call')
|
||||
|
||||
def update_call_state(self, state):
|
||||
os.chdir(curr_directory() + '/images/')
|
||||
|
||||
pixmap = QtGui.QPixmap(curr_directory() + '/images/{}.png'.format(state))
|
||||
pixmap = QtGui.QPixmap(os.path.join(util.get_images_directory(), '{}.png'.format(state)))
|
||||
icon = QtGui.QIcon(pixmap)
|
||||
self.callButton.setIcon(icon)
|
||||
self.callButton.setIconSize(QtCore.QSize(50, 50))
|
||||
|
||||
pixmap = QtGui.QPixmap(curr_directory() + '/images/{}_video.png'.format(state))
|
||||
pixmap = QtGui.QPixmap(os.path.join(util.get_images_directory(), '{}_video.png'.format(state)))
|
||||
icon = QtGui.QIcon(pixmap)
|
||||
self.videocallButton.setIcon(icon)
|
||||
self.videocallButton.setIconSize(QtCore.QSize(35, 35))
|
||||
|
@ -732,7 +731,7 @@ class MainWindow(QtWidgets.QMainWindow, Singleton):
|
|||
|
||||
def show(self):
|
||||
super().show()
|
||||
self.profile.update()
|
||||
#self.profile.update()
|
||||
|
||||
def filtering(self):
|
||||
ind = self.online_contacts.currentIndex()
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from PyQt5 import QtCore, QtGui, QtWidgets
|
||||
from user_data.settings import *
|
||||
from contacts.profile import Profile
|
||||
from util import curr_directory, copy
|
||||
from util.util import curr_directory, copy
|
||||
from ui.widgets import CenteredWidget, DataLabel, LineEdit, RubberBandWindow
|
||||
import pyaudio
|
||||
from user_data import toxes
|
||||
|
|
106
toxygen/ui/views/create_profile_screen.ui
Normal file
106
toxygen/ui/views/create_profile_screen.ui
Normal file
|
@ -0,0 +1,106 @@
|
|||
<?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>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<widget class="QPushButton" name="createProfile">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>240</y>
|
||||
<width>341</width>
|
||||
<height>51</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>PushButton</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="confirmPassword">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>190</y>
|
||||
<width>341</width>
|
||||
<height>41</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="password">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>140</y>
|
||||
<width>341</width>
|
||||
<height>41</height>
|
||||
</rect>
|
||||
</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="QRadioButton" name="defaultFolder">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>10</y>
|
||||
<width>112</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>RadioButton</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QRadioButton" name="programFolder">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>50</y>
|
||||
<width>112</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>RadioButton</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
Loading…
Add table
Add a link
Reference in a new issue