Skip to content

Commit

Permalink
User add friend and block fix
Browse files Browse the repository at this point in the history
  • Loading branch information
henry232323 committed Jul 23, 2020
1 parent 8e159c5 commit ecb6de1
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 27 deletions.
37 changes: 20 additions & 17 deletions dialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,23 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.

from PyQt5.QtGui import QIcon, QTextCursor, QStandardItem, QColor, QBrush, QTextDocument, QImage
from PyQt5.QtCore import Qt, pyqtSlot, QUrl
from PyQt5.QtWidgets import QDialog, QWidget, QListWidgetItem, QComboBox, QHeaderView, QTableWidgetItem, QAction, QMenu
from PyQt5 import uic

from traceback import format_exc
from contextlib import redirect_stdout
from asyncio import ensure_future
from async_timeout import timeout
from sys import exit as sysexit
from contextlib import redirect_stdout
from inspect import isawaitable
from io import StringIO, BytesIO
from sys import exit as sysexit
from traceback import format_exc

import discord
import simpleaudio as sa
from PyQt5 import uic
from PyQt5.QtCore import Qt, pyqtSlot, QUrl
from PyQt5.QtGui import QIcon, QTextCursor, QStandardItem, QColor, QBrush, QTextDocument, QImage
from PyQt5.QtWidgets import QDialog, QWidget, QListWidgetItem, QComboBox, QHeaderView, QTableWidgetItem, QAction, QMenu
from async_timeout import timeout

from formatting import *

import simpleaudio as sa


class PrivateMessageWidget(QWidget):
def __init__(self, app, parent, user, name):
Expand Down Expand Up @@ -296,7 +295,8 @@ def __init__(self, app, parent):
self.themesComboBox.setInsertPolicy(QComboBox.InsertAlphabetically)
index = self.themesComboBox.findText(self.app.theme_name)
self.themesComboBox.setCurrentIndex(index)
self.refreshThemeButton.clicked.connect(lambda: self.app.change_theme(self.themesComboBox.currentText(), f=True))
self.refreshThemeButton.clicked.connect(
lambda: self.app.change_theme(self.themesComboBox.currentText(), f=True))

convo_opt = self.options["conversations"]
chum_opt = self.options["chum_list"]
Expand Down Expand Up @@ -385,9 +385,9 @@ def __init__(self, app, parent):
self.parent = parent
self.setWindowTitle('Memos')
self.setWindowIcon(QIcon(app.theme["path"] + "/trayicon.png"))
#width = self.frameGeometry().width()
#height = self.frameGeometry().height()
#self.setFixedSize(width, height)
# width = self.frameGeometry().width()
# height = self.frameGeometry().height()
# self.setFixedSize(width, height)
self.memosTableWidget.setColumnCount(2)
self.memosTableWidget.setHorizontalHeaderLabels(["Memo", "Users"])
self.memosTableWidget.doubleClicked.connect(self.openMemo)
Expand Down Expand Up @@ -691,7 +691,9 @@ def add_memo(self, memo):
return tab

def add_user_items(self):
for member in sorted(self.memo.members, key=lambda x: (max([r.position for r in x.roles if r.hoist], default=0), x.display_name), reverse=True):
for member in sorted(self.memo.members,
key=lambda x: (max([r.position for r in x.roles if r.hoist], default=0), x.display_name),
reverse=True):
nam = QListWidgetItem(member.display_name)
clra = member.color
clr = QBrush()
Expand Down Expand Up @@ -720,7 +722,8 @@ def __init__(self, app, parent, f=False, i=True):
self.acceptButton.setDefault(True)
self.closeButton.clicked.connect(self.rejected)
if f:
self.errorLabel.setText("""Invalid token! Failed to login. Make sure if you are using a bot to check the bot account check""")
self.errorLabel.setText(
"""Invalid token! Failed to login. Make sure if you are using a bot to check the bot account check""")
else:
self.errorLabel.setText("""Discord no longer allows usernames/passwords!
Check the README for how to find yours!""")
Expand Down
24 changes: 14 additions & 10 deletions gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.

from PyQt5.QtGui import QIcon, QDesktopServices, QStandardItemModel
from PyQt5.QtCore import Qt, pyqtSlot, QModelIndex, QVariant, QUrl
from PyQt5.QtWidgets import QMainWindow, QSystemTrayIcon, QTreeView
from PyQt5 import uic

from random import randint, choice

from PyQt5.QtCore import QModelIndex, QVariant
from PyQt5.QtGui import QDesktopServices, QStandardItemModel
from PyQt5.QtWidgets import QMainWindow, QSystemTrayIcon, QTreeView

from dialogs import *


Expand Down Expand Up @@ -166,7 +165,8 @@ def initialize(self):
button.setIcon(QIcon(os.path.join(self.theme["path"], "{}.png".format(mood_name))))
button.clicked.connect(self.make_setMood(button))

self.colorButton.setStyleSheet('background-color: rgb({},{},{});'.format(randint(0,255), randint(0,255), randint(0,255)))
self.colorButton.setStyleSheet(
'background-color: rgb({},{},{});'.format(randint(0, 255), randint(0, 255), randint(0, 255)))

self.show()

Expand Down Expand Up @@ -203,15 +203,17 @@ def add_selected(self):
selected = self.chumsTree.selectedIndexes()
if selected:
idx = selected[0]
user = self.friendsModel.data(idx)
ensure_future(user.send_friend_request())
user = self.friendsUsers[self.friendsModel.data(idx)]
if isinstance(user, (discord.User, discord.Member)):
ensure_future(user.send_friend_request())

def block_selected(self):
selected = self.chumsTree.selectedIndexes()
if selected:
idx = selected[0]
user = self.friendsModel.data(idx)
ensure_future(user.block())
user = self.friendsUsers[self.friendsModel.data(idx)]
if isinstance(user, (discord.User, discord.Member)):
ensure_future(user.block())

def start_privmsg(self, channel):
"""
Expand Down Expand Up @@ -275,6 +277,7 @@ def toggleIdle(self):

def make_setMood(self, button):
'''Makes set mood button for each button, each button deselects all others and sets user mood'''

def setMood():
if not button.isChecked():
button.setChecked(True)
Expand All @@ -286,6 +289,7 @@ def setMood():
self.app.change_mood(mood_name)
else:
moodButton.setChecked(False)

return setMood

def closeEvent(self, event):
Expand Down
3 changes: 3 additions & 0 deletions themes/pesterchum2.5/ui/MemoWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="sizeConstraint">
<enum>QLayout::SetMaximumSize</enum>
</property>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
Expand Down

0 comments on commit ecb6de1

Please sign in to comment.