plugins improvements
This commit is contained in:
parent
8672c5fb56
commit
e004838013
@ -54,6 +54,7 @@ class MainWindow(QtGui.QMainWindow):
|
|||||||
self.actionSettings.setObjectName("actionSettings")
|
self.actionSettings.setObjectName("actionSettings")
|
||||||
self.audioSettings = QtGui.QAction(MainWindow)
|
self.audioSettings = QtGui.QAction(MainWindow)
|
||||||
self.pluginData = QtGui.QAction(MainWindow)
|
self.pluginData = QtGui.QAction(MainWindow)
|
||||||
|
self.importPlugin = QtGui.QAction(MainWindow)
|
||||||
self.lockApp = QtGui.QAction(MainWindow)
|
self.lockApp = QtGui.QAction(MainWindow)
|
||||||
self.menuProfile.addAction(self.actionAdd_friend)
|
self.menuProfile.addAction(self.actionAdd_friend)
|
||||||
self.menuProfile.addAction(self.actionSettings)
|
self.menuProfile.addAction(self.actionSettings)
|
||||||
@ -64,6 +65,7 @@ class MainWindow(QtGui.QMainWindow):
|
|||||||
self.menuSettings.addAction(self.actionNetwork)
|
self.menuSettings.addAction(self.actionNetwork)
|
||||||
self.menuSettings.addAction(self.audioSettings)
|
self.menuSettings.addAction(self.audioSettings)
|
||||||
self.menuPlugins.addAction(self.pluginData)
|
self.menuPlugins.addAction(self.pluginData)
|
||||||
|
self.menuPlugins.addAction(self.importPlugin)
|
||||||
self.menuAbout.addAction(self.actionAbout_program)
|
self.menuAbout.addAction(self.actionAbout_program)
|
||||||
self.menubar.addAction(self.menuProfile.menuAction())
|
self.menubar.addAction(self.menuProfile.menuAction())
|
||||||
self.menubar.addAction(self.menuSettings.menuAction())
|
self.menubar.addAction(self.menuSettings.menuAction())
|
||||||
@ -80,6 +82,7 @@ class MainWindow(QtGui.QMainWindow):
|
|||||||
self.audioSettings.triggered.connect(self.audio_settings)
|
self.audioSettings.triggered.connect(self.audio_settings)
|
||||||
self.pluginData.triggered.connect(self.plugins_menu)
|
self.pluginData.triggered.connect(self.plugins_menu)
|
||||||
self.lockApp.triggered.connect(self.lock_app)
|
self.lockApp.triggered.connect(self.lock_app)
|
||||||
|
self.importPlugin.triggered.connect(self.import_plugin)
|
||||||
QtCore.QMetaObject.connectSlotsByName(MainWindow)
|
QtCore.QMetaObject.connectSlotsByName(MainWindow)
|
||||||
|
|
||||||
def languageChange(self, *args, **kwargs):
|
def languageChange(self, *args, **kwargs):
|
||||||
@ -113,6 +116,7 @@ class MainWindow(QtGui.QMainWindow):
|
|||||||
self.online_contacts.addItem(QtGui.QApplication.translate("MainWindow", "All", None, QtGui.QApplication.UnicodeUTF8))
|
self.online_contacts.addItem(QtGui.QApplication.translate("MainWindow", "All", None, QtGui.QApplication.UnicodeUTF8))
|
||||||
self.online_contacts.addItem(QtGui.QApplication.translate("MainWindow", "Online", None, QtGui.QApplication.UnicodeUTF8))
|
self.online_contacts.addItem(QtGui.QApplication.translate("MainWindow", "Online", None, QtGui.QApplication.UnicodeUTF8))
|
||||||
self.online_contacts.setCurrentIndex(int(Settings.get_instance()['show_online_friends']))
|
self.online_contacts.setCurrentIndex(int(Settings.get_instance()['show_online_friends']))
|
||||||
|
self.importPlugin.setText(QtGui.QApplication.translate("MainWindow", "Import plugin", None, QtGui.QApplication.UnicodeUTF8))
|
||||||
|
|
||||||
def setup_right_bottom(self, Form):
|
def setup_right_bottom(self, Form):
|
||||||
Form.resize(650, 60)
|
Form.resize(650, 60)
|
||||||
@ -393,6 +397,26 @@ class MainWindow(QtGui.QMainWindow):
|
|||||||
self.audio_s = AudioSettings()
|
self.audio_s = AudioSettings()
|
||||||
self.audio_s.show()
|
self.audio_s.show()
|
||||||
|
|
||||||
|
def import_plugin(self):
|
||||||
|
import util
|
||||||
|
directory = QtGui.QFileDialog.getExistingDirectory(self,
|
||||||
|
QtGui.QApplication.translate("MainWindow", 'Choose folder with plugin',
|
||||||
|
None,
|
||||||
|
QtGui.QApplication.UnicodeUTF8),
|
||||||
|
util.curr_directory(),
|
||||||
|
QtGui.QFileDialog.ShowDirsOnly | QtGui.QFileDialog.DontUseNativeDialog)
|
||||||
|
if directory:
|
||||||
|
src = directory + '/'
|
||||||
|
dest = curr_directory() + '/plugins/'
|
||||||
|
util.copy(src, dest)
|
||||||
|
msgBox = QtGui.QMessageBox()
|
||||||
|
msgBox.setWindowTitle(
|
||||||
|
QtGui.QApplication.translate("MainWindow", "Restart Toxygen", None, QtGui.QApplication.UnicodeUTF8))
|
||||||
|
msgBox.setText(
|
||||||
|
QtGui.QApplication.translate("MainWindow", 'Plugin will be loaded after restart', None,
|
||||||
|
QtGui.QApplication.UnicodeUTF8))
|
||||||
|
msgBox.exec_()
|
||||||
|
|
||||||
def lock_app(self):
|
def lock_app(self):
|
||||||
if toxencryptsave.ToxEncryptSave.get_instance().has_password():
|
if toxencryptsave.ToxEncryptSave.get_instance().has_password():
|
||||||
Settings.get_instance().locked = True
|
Settings.get_instance().locked = True
|
||||||
|
@ -385,25 +385,29 @@ class Profile(contact.Contact, Singleton):
|
|||||||
if not friend.visibility:
|
if not friend.visibility:
|
||||||
self.update_filtration()
|
self.update_filtration()
|
||||||
|
|
||||||
def send_message(self, text):
|
def send_message(self, text, friend_num=None):
|
||||||
"""
|
"""
|
||||||
Send message to active friend
|
Send message
|
||||||
:param text: message text
|
:param text: message text
|
||||||
|
:param friend_num: num of friend
|
||||||
"""
|
"""
|
||||||
|
if friend_num is None:
|
||||||
|
friend_num = self.get_active_number()
|
||||||
if text.startswith('/plugin '):
|
if text.startswith('/plugin '):
|
||||||
plugin_support.PluginLoader.get_instance().command(text[8:])
|
plugin_support.PluginLoader.get_instance().command(text[8:])
|
||||||
self._screen.messageEdit.clear()
|
self._screen.messageEdit.clear()
|
||||||
elif text and self._active_friend + 1:
|
elif text and friend_num + 1:
|
||||||
text = ''.join(c if c <= '\u10FFFF' else '\u25AF' for c in text)
|
text = ''.join(c if c <= '\u10FFFF' else '\u25AF' for c in text)
|
||||||
if text.startswith('/me '):
|
if text.startswith('/me '):
|
||||||
message_type = TOX_MESSAGE_TYPE['ACTION']
|
message_type = TOX_MESSAGE_TYPE['ACTION']
|
||||||
text = text[4:]
|
text = text[4:]
|
||||||
else:
|
else:
|
||||||
message_type = TOX_MESSAGE_TYPE['NORMAL']
|
message_type = TOX_MESSAGE_TYPE['NORMAL']
|
||||||
friend = self._friends[self._active_friend]
|
friend = self.get_friend_by_number(friend_num)
|
||||||
friend.inc_receipts()
|
friend.inc_receipts()
|
||||||
if friend.status is not None:
|
if friend.status is not None:
|
||||||
self.split_and_send(friend.number, message_type, text.encode('utf-8'))
|
self.split_and_send(friend.number, message_type, text.encode('utf-8'))
|
||||||
|
if friend.number == self.get_active_number():
|
||||||
t = time.time()
|
t = time.time()
|
||||||
self.create_message_item(text, t, MESSAGE_OWNER['NOT_SENT'], message_type)
|
self.create_message_item(text, t, MESSAGE_OWNER['NOT_SENT'], message_type)
|
||||||
self._screen.messageEdit.clear()
|
self._screen.messageEdit.clear()
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
|
import shutil
|
||||||
|
|
||||||
program_version = '0.2.2'
|
program_version = '0.2.2'
|
||||||
|
|
||||||
@ -18,6 +18,18 @@ def curr_time():
|
|||||||
return time.strftime('%H:%M')
|
return time.strftime('%H:%M')
|
||||||
|
|
||||||
|
|
||||||
|
def copy(src, dest):
|
||||||
|
if not os.path.exists(dest):
|
||||||
|
os.makedirs(dest)
|
||||||
|
src_files = os.listdir(src)
|
||||||
|
for file_name in src_files:
|
||||||
|
full_file_name = os.path.join(src, file_name)
|
||||||
|
if os.path.isfile(full_file_name):
|
||||||
|
shutil.copy(full_file_name, dest)
|
||||||
|
else:
|
||||||
|
copy(full_file_name, os.path.join(dest, file_name))
|
||||||
|
|
||||||
|
|
||||||
def convert_time(t):
|
def convert_time(t):
|
||||||
sec = int(t) - time.timezone
|
sec = int(t) - time.timezone
|
||||||
m, s = divmod(sec, 60)
|
m, s = divmod(sec, 60)
|
||||||
|
Loading…
Reference in New Issue
Block a user