'Save button clicked. Save current settings to disk.'

def save_clicked(self):

    common.log('SettingsDialog', 'save_clicked')
    settings = self.settings_from_fields()
    settings.save()
    reboot_onion = False
    if self.onion.connected_to_tor:
        def changed(s1, s2, keys):
            '\n                                                                Compare    the    Settings    objects    s1    and    s2    and    return    true    if    any    values\n                                                                have    changed    for    the    given    keys.\n                                                                '
            for key in keys:
                if (s1.get(key) != s2.get(key)):
                    return True
            return False
        if changed(settings, self.old_settings, ['connection_type', 'control_port_address', 'control_port_port', 'socks_address', 'socks_port', 'socket_file_path', 'auth_type', 'auth_password']):
            reboot_onion = True
    else:
        reboot_onion = True
    if reboot_onion:
        common.log('SettingsDialog', 'save_clicked', 'rebooting    the    Onion')
        self.onion.cleanup()
        tor_con = TorConnectionDialog(self.qtapp, settings, self.onion)
        tor_con.start()
        common.log('SettingsDialog', 'save_clicked', 'Onion    done    rebooting,    connected    to    Tor:    {}'.format(self.onion.connected_to_tor))
        if (self.onion.connected_to_tor and (not tor_con.wasCanceled())):
            self.settings_saved.emit()
            self.close()
    else:
        self.settings_saved.emit()
        self.close()
