plugins improvements
This commit is contained in:
parent
8672c5fb56
commit
e004838013
3 changed files with 49 additions and 9 deletions
|
@ -54,6 +54,7 @@ class MainWindow(QtGui.QMainWindow):
|
|||
self.actionSettings.setObjectName("actionSettings")
|
||||
self.audioSettings = QtGui.QAction(MainWindow)
|
||||
self.pluginData = QtGui.QAction(MainWindow)
|
||||
self.importPlugin = QtGui.QAction(MainWindow)
|
||||
self.lockApp = QtGui.QAction(MainWindow)
|
||||
self.menuProfile.addAction(self.actionAdd_friend)
|
||||
self.menuProfile.addAction(self.actionSettings)
|
||||
|
@ -64,6 +65,7 @@ class MainWindow(QtGui.QMainWindow):
|
|||
self.menuSettings.addAction(self.actionNetwork)
|
||||
self.menuSettings.addAction(self.audioSettings)
|
||||
self.menuPlugins.addAction(self.pluginData)
|
||||
self.menuPlugins.addAction(self.importPlugin)
|
||||
self.menuAbout.addAction(self.actionAbout_program)
|
||||
self.menubar.addAction(self.menuProfile.menuAction())
|
||||
self.menubar.addAction(self.menuSettings.menuAction())
|
||||
|
@ -80,6 +82,7 @@ class MainWindow(QtGui.QMainWindow):
|
|||
self.audioSettings.triggered.connect(self.audio_settings)
|
||||
self.pluginData.triggered.connect(self.plugins_menu)
|
||||
self.lockApp.triggered.connect(self.lock_app)
|
||||
self.importPlugin.triggered.connect(self.import_plugin)
|
||||
QtCore.QMetaObject.connectSlotsByName(MainWindow)
|
||||
|
||||
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", "Online", None, QtGui.QApplication.UnicodeUTF8))
|
||||
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):
|
||||
Form.resize(650, 60)
|
||||
|
@ -393,6 +397,26 @@ class MainWindow(QtGui.QMainWindow):
|
|||
self.audio_s = AudioSettings()
|
||||
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):
|
||||
if toxencryptsave.ToxEncryptSave.get_instance().has_password():
|
||||
Settings.get_instance().locked = True
|
||||
|
|
|
@ -385,25 +385,29 @@ class Profile(contact.Contact, Singleton):
|
|||
if not friend.visibility:
|
||||
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 friend_num: num of friend
|
||||
"""
|
||||
if friend_num is None:
|
||||
friend_num = self.get_active_number()
|
||||
if text.startswith('/plugin '):
|
||||
plugin_support.PluginLoader.get_instance().command(text[8:])
|
||||
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)
|
||||
if text.startswith('/me '):
|
||||
message_type = TOX_MESSAGE_TYPE['ACTION']
|
||||
text = text[4:]
|
||||
else:
|
||||
message_type = TOX_MESSAGE_TYPE['NORMAL']
|
||||
friend = self._friends[self._active_friend]
|
||||
friend = self.get_friend_by_number(friend_num)
|
||||
friend.inc_receipts()
|
||||
if friend.status is not None:
|
||||
self.split_and_send(friend.number, message_type, text.encode('utf-8'))
|
||||
if friend.number == self.get_active_number():
|
||||
t = time.time()
|
||||
self.create_message_item(text, t, MESSAGE_OWNER['NOT_SENT'], message_type)
|
||||
self._screen.messageEdit.clear()
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import os
|
||||
import time
|
||||
|
||||
import shutil
|
||||
|
||||
program_version = '0.2.2'
|
||||
|
||||
|
@ -18,6 +18,18 @@ def curr_time():
|
|||
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):
|
||||
sec = int(t) - time.timezone
|
||||
m, s = divmod(sec, 60)
|
||||
|
|
Loading…
Reference in a new issue