Commit c27ec4c5 authored by Dan Pascu's avatar Dan Pascu

Reorganized preferences

parent 0570b69f
......@@ -1146,7 +1146,7 @@ class VideoWidget(VideoSurface, ui_class):
def _SH_ScreenshotsFolderActionTriggered(self, pos):
settings = BlinkSettings()
QDesktopServices.openUrl(QUrl.fromLocalFile(settings.video.screenshots_directory.normalized))
QDesktopServices.openUrl(QUrl.fromLocalFile(settings.screenshots_directory.normalized))
def _SH_DetachAnimationFinished(self):
if self.detach_animation.direction() == QPropertyAnimation.Backward:
......@@ -2155,7 +2155,7 @@ class VideoScreenshot(object):
@classmethod
def filename_generator(cls):
settings = BlinkSettings()
name = os.path.join(settings.video.screenshots_directory.normalized, 'VideoCall-{:%Y%m%d-%H.%M.%S}'.format(datetime.now()))
name = os.path.join(settings.screenshots_directory.normalized, 'VideoCall-{:%Y%m%d-%H.%M.%S}'.format(datetime.now()))
yield '%s.png' % name
for x in count(1):
yield "%s-%d.png" % (name, x)
......
......@@ -10,7 +10,7 @@ import sys
from sipsimple.configuration import Setting, SettingsGroup, SettingsObject, SettingsObjectExtension
from sipsimple.configuration.datatypes import AudioCodecList, NonNegativeInteger, PositiveInteger, Path, SampleRate, VideoCodecList
from sipsimple.configuration.settings import AudioSettings, ChatSettings, EchoCancellerSettings, FileTransferSettings, LogsSettings, RTPSettings, TLSSettings
from sipsimple.configuration.settings import AudioSettings, ChatSettings, EchoCancellerSettings, LogsSettings, RTPSettings, TLSSettings
from blink import __version__
from blink.configuration.datatypes import ApplicationDataPath, AuthorizationToken, GraphTimeScale, HTTPURL, IconDescriptor, SoundFile, PresenceState, PresenceStateList
......@@ -41,10 +41,6 @@ class ChatSettingsExtension(ChatSettings):
history_directory = Setting(type=ApplicationDataPath, default=ApplicationDataPath('history'))
class FileTransferSettingsExtension(FileTransferSettings):
directory = Setting(type=Path, default=Path('~/Downloads'))
class GoogleContactsSettings(SettingsGroup):
authorization_token = Setting(type=AuthorizationToken, default=None, nillable=True)
username = Setting(type=unicode, default=None, nillable=True)
......@@ -82,7 +78,6 @@ class SIPSimpleSettingsExtension(SettingsObjectExtension):
answering_machine = AnsweringMachineSettings
audio = AudioSettingsExtension
chat = ChatSettingsExtension
file_transfer = FileTransferSettingsExtension
google_contacts = GoogleContactsSettings
logs = LogsSettingsExtension
rtp = RTPSettingsExtension
......@@ -110,16 +105,11 @@ class ChatWindowSettings(SettingsGroup):
class BlinkScreenSharingSettings(SettingsGroup):
screenshots_directory = Setting(type=Path, default=Path('~/Downloads'))
scale = Setting(type=bool, default=True)
open_fullscreen = Setting(type=bool, default=False)
open_viewonly = Setting(type=bool, default=False)
class BlinkVideoSettings(SettingsGroup):
screenshots_directory = Setting(type=Path, default=Path('~/Downloads'))
class BlinkPresenceSettings(SettingsGroup):
current_state = Setting(type=PresenceState, default=PresenceState('Available'))
state_history = Setting(type=PresenceStateList, default=PresenceStateList())
......@@ -133,5 +123,7 @@ class BlinkSettings(SettingsObject):
chat_window = ChatWindowSettings
presence = BlinkPresenceSettings
screen_sharing = BlinkScreenSharingSettings
video = BlinkVideoSettings
screenshots_directory = Setting(type=Path, default=Path('~/Downloads'))
transfers_directory = Setting(type=Path, default=Path('~/Downloads'))
......@@ -14,8 +14,7 @@ from application.python import Null
from application.system import makedirs
from zope.interface import implements
from sipsimple.configuration.settings import SIPSimpleSettings
from blink.configuration.settings import BlinkSettings
from blink.resources import Resources
from blink.sessions import FileTransferDelegate, FileTransferModel
from blink.widgets.util import ContextMenuActions
......@@ -43,7 +42,7 @@ class FileTransferWindow(base_class, ui_class):
self.actions.cancel_transfer = QAction("Cancel", self, triggered=self._AH_CancelTransfer)
self.actions.retry_transfer = QAction("Retry", self, triggered=self._AH_RetryTransfer)
self.actions.remove_entry = QAction("Remove From List", self, triggered=self._AH_RemoveEntry)
self.actions.open_downloads_folder = QAction("Open Downloads Folder", self, triggered=self._AH_OpenDownloadsFolder)
self.actions.open_downloads_folder = QAction("Open Transfers Folder", self, triggered=self._AH_OpenTransfersFolder)
self.actions.clear_list = QAction("Clear List", self, triggered=self._AH_ClearList)
self.model.itemAdded.connect(self.update_status)
......@@ -55,9 +54,8 @@ class FileTransferWindow(base_class, ui_class):
notification_center.add_observer(self, name='FileTransferDidEnd')
def show(self, activate=True):
settings = SIPSimpleSettings()
directory = settings.file_transfer.directory.normalized
makedirs(directory)
settings = BlinkSettings()
makedirs(settings.transfers_directory.normalized)
self.setAttribute(Qt.WA_ShowWithoutActivating, not activate)
super(FileTransferWindow, self).show()
self.raise_()
......@@ -130,10 +128,9 @@ class FileTransferWindow(base_class, ui_class):
item = self.listview.selectedIndexes()[0].data(Qt.UserRole)
self.model.removeItem(item)
def _AH_OpenDownloadsFolder(self):
settings = SIPSimpleSettings()
directory = settings.file_transfer.directory.normalized
QDesktopServices.openUrl(QUrl.fromLocalFile(directory))
def _AH_OpenTransfersFolder(self):
settings = BlinkSettings()
QDesktopServices.openUrl(QUrl.fromLocalFile(settings.transfers_directory.normalized))
def _AH_ClearList(self):
self.model.clear_ended()
......
......@@ -416,14 +416,14 @@ class MainWindow(base_class, ui_class):
QDesktopServices.openUrl(QUrl.fromLocalFile(directory))
def _AH_ReceivedFilesWindowActionTriggered(self, checked):
settings = SIPSimpleSettings()
directory = settings.file_transfer.directory.normalized
settings = BlinkSettings()
directory = settings.transfers_directory.normalized
makedirs(directory)
QDesktopServices.openUrl(QUrl.fromLocalFile(directory))
def _AH_ScreenshotsWindowActionTriggered(self, checked):
settings = BlinkSettings()
directory = settings.screen_sharing.screenshots_directory.normalized
directory = settings.screenshots_directory.normalized
makedirs(directory)
QDesktopServices.openUrl(QUrl.fromLocalFile(directory))
......
......@@ -303,14 +303,10 @@ class PreferencesWindow(base_class, ui_class):
self.traffic_units_button.clicked.connect(self._SH_TrafficUnitsButtonClicked)
# Screen sharing
self.screenshots_directory_browse_button.clicked.connect(self._SH_ScreenshotsDirectoryBrowseButtonClicked)
self.screen_sharing_scale_button.clicked.connect(self._SH_ScreenSharingScaleButtonClicked)
self.screen_sharing_fullscreen_button.clicked.connect(self._SH_ScreenSharingFullscreenButtonClicked)
self.screen_sharing_viewonly_button.clicked.connect(self._SH_ScreenSharingViewonlyButtonClicked)
# File transfer
self.download_directory_browse_button.clicked.connect(self._SH_DownloadDirectoryBrowseButtonClicked)
# File logging
self.trace_sip_button.clicked.connect(self._SH_TraceSIPButtonClicked)
self.trace_msrp_button.clicked.connect(self._SH_TraceMSRPButtonClicked)
......@@ -328,7 +324,11 @@ class PreferencesWindow(base_class, ui_class):
self.media_ports_start.valueChanged[int].connect(self._SH_MediaPortsStartValueChanged)
self.media_ports.valueChanged[int].connect(self._SH_MediaPortsValueChanged)
# TLS
# Files and directories
self.screenshots_directory_browse_button.clicked.connect(self._SH_ScreenshotsDirectoryBrowseButtonClicked)
self.transfers_directory_browse_button.clicked.connect(self._SH_TransfersDirectoryBrowseButtonClicked)
# TLS settings
self.tls_ca_file_editor.locationCleared.connect(self._SH_TLSCAFileEditorLocationCleared)
self.tls_ca_file_browse_button.clicked.connect(self._SH_TLSCAFileBrowseButtonClicked)
......@@ -713,14 +713,10 @@ class PreferencesWindow(base_class, ui_class):
self.traffic_units_button.setChecked(blink_settings.chat_window.session_info.bytes_per_second)
# Screen sharing settings
self.screenshots_directory_editor.setText(blink_settings.screen_sharing.screenshots_directory or u'')
self.screen_sharing_scale_button.setChecked(blink_settings.screen_sharing.scale)
self.screen_sharing_fullscreen_button.setChecked(blink_settings.screen_sharing.open_fullscreen)
self.screen_sharing_viewonly_button.setChecked(blink_settings.screen_sharing.open_viewonly)
# File transfer settings
self.download_directory_editor.setText(settings.file_transfer.directory or u'')
# File logging settings
self.trace_sip_button.setChecked(settings.logs.trace_sip)
self.trace_msrp_button.setChecked(settings.logs.trace_msrp)
......@@ -750,6 +746,8 @@ class PreferencesWindow(base_class, ui_class):
with blocked_qt_signals(self.media_ports):
self.media_ports.setValue(settings.rtp.port_range.end - settings.rtp.port_range.start)
self.screenshots_directory_editor.setText(blink_settings.screenshots_directory or u'')
self.transfers_directory_editor.setText(blink_settings.transfers_directory or u'')
self.tls_ca_file_editor.setText(settings.tls.ca_list or u'')
def load_account_settings(self, account):
......@@ -1499,13 +1497,12 @@ class PreferencesWindow(base_class, ui_class):
def _SH_ScreenshotsDirectoryBrowseButtonClicked(self, checked):
# TODO: open the file selection dialog in non-modal mode. Same for the one for TLS CA list and the IconSelector from contacts. -Dan
settings = BlinkSettings()
directory = settings.screen_sharing.screenshots_directory.normalized
directory = QFileDialog.getExistingDirectory(self, u'Select Screenshots Directory', directory) or None
directory = QFileDialog.getExistingDirectory(self, u'Select Screenshots Directory', settings.screenshots_directory.normalized) or None
if directory is not None:
directory = os.path.normpath(directory)
if directory != settings.screen_sharing.screenshots_directory:
if directory != settings.screenshots_directory:
self.screenshots_directory_editor.setText(directory)
settings.screen_sharing.screenshots_directory = directory
settings.screenshots_directory = directory
settings.save()
def _SH_ScreenSharingScaleButtonClicked(self, checked):
......@@ -1524,16 +1521,15 @@ class PreferencesWindow(base_class, ui_class):
settings.save()
# File transfer signal handlers
def _SH_DownloadDirectoryBrowseButtonClicked(self, checked):
def _SH_TransfersDirectoryBrowseButtonClicked(self, checked):
# TODO: open the file selection dialog in non-modal mode. Same for the one for TLS CA list and the IconSelector from contacts. -Dan
settings = SIPSimpleSettings()
directory = settings.file_transfer.directory.normalized
directory = QFileDialog.getExistingDirectory(self, u'Select Download Directory', directory) or None
settings = BlinkSettings()
directory = QFileDialog.getExistingDirectory(self, u'Select Transfers Directory', settings.transfers_directory.normalized) or None
if directory is not None:
directory = os.path.normpath(directory)
if directory != settings.file_transfer.directory:
self.download_directory_editor.setText(directory)
settings.file_transfer.directory = directory
if directory != settings.transfers_directory:
self.transfers_directory_editor.setText(directory)
settings.transfers_directory = directory
settings.save()
# File logging signal handlers
......
......@@ -653,7 +653,7 @@ class ScreensharingWindow(base_class, ui_class):
def _SH_ScreenshotsFolderActionTriggered(self, pos):
settings = BlinkSettings()
QDesktopServices.openUrl(QUrl.fromLocalFile(settings.screen_sharing.screenshots_directory.normalized))
QDesktopServices.openUrl(QUrl.fromLocalFile(settings.screenshots_directory.normalized))
def _SH_VNCClientTextCut(self, text):
self.clipboard.blockSignals(True)
......@@ -675,7 +675,7 @@ class Screenshot(object):
@classmethod
def filename_generator(cls):
settings = BlinkSettings()
name = os.path.join(settings.screen_sharing.screenshots_directory.normalized, 'ScreenSharing-{:%Y%m%d-%H.%M.%S}'.format(datetime.now()))
name = os.path.join(settings.screenshots_directory.normalized, 'ScreenSharing-{:%Y%m%d-%H.%M.%S}'.format(datetime.now()))
yield '%s.png' % name
for x in count(1):
yield "%s-%d.png" % (name, x)
......
......@@ -3458,8 +3458,8 @@ class FileTransfer(object):
self._file_selector = stream.file_selector
self._local_hash = hashlib.sha1()
settings = SIPSimpleSettings()
directory = settings.file_transfer.directory.normalized
settings = BlinkSettings()
directory = settings.transfers_directory.normalized
makedirs(directory)
filename = os.path.basename(self._file_selector.name)
for name in UniqueFilenameGenerator.generate(os.path.join(directory, filename)):
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment