1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- from PyQt5 import QtWidgets, uic
- from lyberry_qt import helpers
- class CommentWidget(QtWidgets.QDialog):
- def __init__(self, comment):
- super(CommentWidget, self).__init__()
- uic.loadUi(helpers.relative_path('designer/comment.ui'), self)
- self.comment = comment
- self.pub = comment.pub
- self._lbry = comment._LBRY_api
- self.message.setText(comment.msg)
- self.channel_button.setText(comment.channel.name)
- self.show_replies_button.setText(str(comment.replies_amt) + " Replies")
- if comment.replies_amt > 0:
- self.show_replies_button.clicked.connect(self.show_replies)
- else:
- self.show_replies_button.setEnabled(False)
- self.write_comment_button.clicked.connect(self.write_comment)
- def write_comment(self):
- self.write_comment_section.addWidget(WriteCommentWidget(self, self.comment))
-
- def show_replies(self):
- for comment in self.comment.replies:
- item = CommentWidget(comment)
- self.replies_section.addWidget(item)
- self.show_replies_button.setEnabled(False)
- class WriteCommentWidget(QtWidgets.QDialog):
- def __init__(self, parent, comment=None):
- super(WriteCommentWidget, self).__init__()
- uic.loadUi(helpers.relative_path('designer/write_comment.ui'), self)
- self.create_comment_button.clicked.connect(self.create_comment)
- self.parent = parent
- self.comment = comment
- self.add_my_channels_as_comment_options()
-
- def add_my_channels_as_comment_options(self):
- my_channels = self.parent._lbry.my_channels
- for channel in my_channels:
- self.channel_select.addItem(channel.name)
- def create_comment(self):
- channel_name = self.channel_select.currentText()
- channel = self.parent._lbry.channel_from_uri(channel_name)
- message = self.comment_box.toPlainText()
- self.parent._lbry.make_comment(channel, message, self.parent.pub, self.comment)
- self.comment_box.clear()
- self.close()
|