icons and sticker window

This commit is contained in:
ingvar1995 2016-06-14 23:55:41 +03:00
parent 53a381222f
commit 63774ba5df
9 changed files with 65 additions and 7 deletions

BIN
src/images/audio_message.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

BIN
src/images/menu.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

BIN
src/images/smiley.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

BIN
src/images/sticker.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

BIN
src/images/video_message.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

View file

@ -432,6 +432,14 @@ class MainWindow(QtGui.QMainWindow):
self.smiley.height())) self.smiley.height()))
self.smiley.show() self.smiley.show()
def send_sticker(self):
self.sticker = StickerWindow(self)
self.sticker.setGeometry(QtCore.QRect(self.x() if Settings.get_instance()['mirror_mode'] else 270 + self.x(),
self.y() + self.height() - 200,
self.sticker.width(),
self.sticker.height()))
self.sticker.show()
def active_call(self): def active_call(self):
self.update_call_state('finish_call') self.update_call_state('finish_call')

View file

@ -249,6 +249,7 @@ class DropdownMenu(QtGui.QWidget):
self.screenshotButton.clicked.connect(parent.send_screenshot) self.screenshotButton.clicked.connect(parent.send_screenshot)
self.connect(self.screenshotButton, QtCore.SIGNAL("rightClicked()"), lambda: parent.send_screenshot(True)) self.connect(self.screenshotButton, QtCore.SIGNAL("rightClicked()"), lambda: parent.send_screenshot(True))
self.smileyButton.clicked.connect(parent.send_smiley) self.smileyButton.clicked.connect(parent.send_smiley)
self.stickerButton.clicked.connect(parent.send_sticker)
def leaveEvent(self, event): def leaveEvent(self, event):
self.close() self.close()
@ -257,3 +258,42 @@ class DropdownMenu(QtGui.QWidget):
if event.type() == QtCore.QEvent.WindowDeactivate: if event.type() == QtCore.QEvent.WindowDeactivate:
self.close() self.close()
return False return False
class StickerItem(QtGui.QWidget):
def __init__(self, fl):
super(StickerItem, self).__init__()
self._image_label = QtGui.QLabel(self)
self.path = fl
self.pixmap = QtGui.QPixmap()
self.pixmap.load(fl)
self.setFixedSize(150, self.pixmap.height())
self._image_label.setPixmap(self.pixmap)
class StickerWindow(QtGui.QWidget):
def __init__(self, parent):
super(StickerWindow, self).__init__()
self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
self.setMaximumSize(150, 200)
self.setMinimumSize(150, 200)
self.list = QtGui.QListWidget(self)
self.list.setGeometry(QtCore.QRect(0, 0, 150, 200))
self.arr = smileys.sticker_loader()
for sticker in self.arr:
item = StickerItem(sticker)
elem = QtGui.QListWidgetItem()
elem.setSizeHint(QtCore.QSize(150, item.height()))
self.list.addItem(elem)
self.list.setItemWidget(elem, item)
self.list.clicked.connect(self.click)
self.parent = parent
def click(self, index):
num = index.row()
self.parent.profile.send_sticker(self.arr[num])
self.close()

View file

@ -716,7 +716,7 @@ class Profile(contact.Contact, Singleton):
settings = Settings.get_instance() settings = Settings.get_instance()
friend = self.get_friend_by_number(friend_number) friend = self.get_friend_by_number(friend_number)
auto = settings['allow_auto_accept'] and friend.tox_id in settings['auto_accept_from_friends'] auto = settings['allow_auto_accept'] and friend.tox_id in settings['auto_accept_from_friends']
inline = (file_name == 'toxygen_inline.png' or file_name == 'utox-inline.png') and settings['allow_inline'] inline = (file_name in ('toxygen_inline.png', 'utox-inline.png', 'sticker.png')) and settings['allow_inline']
if inline and size < 1024 * 1024: if inline and size < 1024 * 1024:
self.accept_transfer(None, '', friend_number, file_number, size, True) self.accept_transfer(None, '', friend_number, file_number, size, True)
tm = TransferMessage(MESSAGE_OWNER['FRIEND'], tm = TransferMessage(MESSAGE_OWNER['FRIEND'],
@ -833,8 +833,18 @@ class Profile(contact.Contact, Singleton):
Send screenshot to current active friend Send screenshot to current active friend
:param data: raw data - png :param data: raw data - png
""" """
self.send_inline(data, 'toxygen_inline.png')
def send_sticker(self, path):
with open(path) as fl:
data = fl.read()
self.send_inline(data, 'sticker.png')
def send_inline(self, data, file_name):
friend = self._friends[self._active_friend] friend = self._friends[self._active_friend]
st = SendFromBuffer(self._tox, friend.number, data, 'toxygen_inline.png') if friend.status is None:
return
st = SendFromBuffer(self._tox, friend.number, data, file_name)
self._file_transfers[(friend.number, st.get_file_number())] = st self._file_transfers[(friend.number, st.get_file_number())] = st
tm = TransferMessage(MESSAGE_OWNER['ME'], tm = TransferMessage(MESSAGE_OWNER['ME'],
time.time(), time.time(),

View file

@ -74,12 +74,12 @@ def sticker_loader():
""" """
:return dict of stickers :return dict of stickers
""" """
result = {} result = []
d = util.curr_directory() + '/stickers/' d = util.curr_directory() + '/stickers/'
keys = [x[1] for x in os.walk(d)][0] keys = [x[1] for x in os.walk(d)][0]
for key in keys: for key in keys:
path = d + key path = d + key + '/'
files = map(lambda f: f.endswith('.png'), os.listdir(path)) files = filter(lambda f: f.endswith('.png'), os.listdir(path))
if files: files = map(lambda f: path + f, files)
result[key] = files result.extend(files)
return result return result