# Path: vise/constants.py
# DOWNLOADS_URL = 'vise:downloads'
# WELCOME_URL = 'vise:welcome'
# STATUS_BAR_HEIGHT = 24
# FOLLOW_LINK_KEY_MAP = {getattr(Qt.Key, 'Key_' + x.upper()): x for x in string.ascii_lowercase + string.digits}
# VISE_SCHEME = 'vise'
# def _get_cache_dir():
# def _get_config_dir():
# def get_windows_username():
# def local_socket_address():
# 
# Path: vise/resources.py
# @lru_cache(maxsize=512)
# def get_icon(name):
#     if not name.startswith('images/'):
#         name = 'images/' + name
#     return QIcon(get_data_as_path(name))
# 
# Path: vise/settings.py
# def to_json(obj):
# def from_json(obj):
#     def __init__(self, name):
#     def conn(self):
#     def get(self, name, default=None):
#     def set(self, name, val):
#     def __getitem__(self, name):
#     def __setitem__(self, name, val):
#     def __delitem__(self, name):
#     def buffer_commits(self):
#     def buffer_commits(self, val):
#     def __enter__(self):
#     def __exit__(self, *args):
# def safe_makedirs(path):
# def create_script(
#     name, src, world=QWebEngineScript.ScriptWorldId.ApplicationWorld, injection_point=QWebEngineScript.InjectionPoint.DocumentCreation, on_subframes=True
# ):
# def client_script():
# def insert_scripts(profile, *scripts):
# def get_spell_langs():
# def create_profile(parent=None, private=False):
# def profile():
# def do_delete_profile(profile):
# def delete_profile():
# def quickmarks():
# class DynamicPrefs:
# TITLE_TOKEN = None
#     TITLE_TOKEN = hexlify(os.urandom(32)).decode('ascii')
# 
# Path: vise/utils.py
# def safe_disconnect(signal):
#     try:
#         signal.disconnect()
#     except TypeError:
#         pass  # signal was not connected


from gettext import gettext as _
from PyQt6.QtCore import QSize, Qt, pyqtSignal
from PyQt6.QtGui import QAction, QIcon, QKeySequence
from PyQt6.QtWidgets import (QApplication, QCheckBox, QDialog,
                             QDialogButtonBox, QGridLayout, QLabel,
                             QPlainTextEdit, QStyle)
from .constants import appname, str_version
from .resources import get_icon
from .settings import gprefs
from .utils import safe_disconnect
        # Set skip_dialog_msg to a message displayed to the user
        skip_dialog_name=None, skip_dialog_msg=_('Show this confirmation again'),
        skip_dialog_skipped_value=True, skip_dialog_skip_precheck=True,
        # Override icon (QIcon to be used as the icon for this dialog or string for I())
        override_icon=None,
        # Change the text/icons of the yes and no buttons.
        # The icons must be QIcon objects or strings for I()
        yes_text=None, no_text=None, yes_icon=None, no_icon=None,
):

    auto_skip = set(gprefs.get('questions_to_auto_skip', []))
    if (skip_dialog_name is not None and skip_dialog_name in auto_skip):
        return bool(skip_dialog_skipped_value)

    d = MessageBox(MessageBox.QUESTION, title, msg, det_msg, parent=parent,
                   show_copy_button=show_copy_button, default_yes=default_yes,
                   q_icon=override_icon, yes_text=yes_text, no_text=no_text,
                   yes_icon=yes_icon, no_icon=no_icon)

    if skip_dialog_name is not None and skip_dialog_msg:
        tc = d.toggle_checkbox
        tc.setVisible(True)
        tc.setText(skip_dialog_msg)
        tc.setChecked(bool(skip_dialog_skip_precheck))
        d.resize_needed.emit()

    ret = d.exec() == QDialog.DialogCode.Accepted

    if skip_dialog_name is not None and not d.toggle_checkbox.isChecked():
        auto_skip.add(skip_dialog_name)

# Path: vise/constants.py
# DOWNLOADS_URL = 'vise:downloads'
# WELCOME_URL = 'vise:welcome'
# STATUS_BAR_HEIGHT = 24
# FOLLOW_LINK_KEY_MAP = {getattr(Qt.Key, 'Key_' + x.upper()): x for x in string.ascii_lowercase + string.digits}
# VISE_SCHEME = 'vise'
# def _get_cache_dir():
# def _get_config_dir():
# def get_windows_username():
# def local_socket_address():
# 
# Path: vise/resources.py
# @lru_cache(maxsize=512)
# def get_icon(name):
#     if not name.startswith('images/'):
#         name = 'images/' + name
#     return QIcon(get_data_as_path(name))
# 
# Path: vise/settings.py
# def to_json(obj):
# def from_json(obj):
#     def __init__(self, name):
#     def conn(self):
#     def get(self, name, default=None):
#     def set(self, name, val):
#     def __getitem__(self, name):
#     def __setitem__(self, name, val):
#     def __delitem__(self, name):
#     def buffer_commits(self):
#     def buffer_commits(self, val):
#     def __enter__(self):
#     def __exit__(self, *args):
# def safe_makedirs(path):
# def create_script(
#     name, src, world=QWebEngineScript.ScriptWorldId.ApplicationWorld, injection_point=QWebEngineScript.InjectionPoint.DocumentCreation, on_subframes=True
# ):
# def client_script():
# def insert_scripts(profile, *scripts):
# def get_spell_langs():
# def create_profile(parent=None, private=False):
# def profile():
# def do_delete_profile(profile):
# def delete_profile():
# def quickmarks():
# class DynamicPrefs:
# TITLE_TOKEN = None
#     TITLE_TOKEN = hexlify(os.urandom(32)).decode('ascii')
# 
# Path: vise/utils.py
# def safe_disconnect(signal):
#     try:
#         signal.disconnect()
#     except TypeError:
#         pass  # signal was not connected


# Path: vise/message_box.py
from gettext import gettext as _
from PyQt6.QtCore import QSize, Qt, pyqtSignal
from PyQt6.QtGui import QAction, QIcon, QKeySequence
from PyQt6.QtWidgets import (QApplication, QCheckBox, QDialog,
                             QDialogButtonBox, QGridLayout, QLabel,
                             QPlainTextEdit, QStyle)
from .constants import appname, str_version
from .resources import get_icon
from .settings import gprefs
from .utils import safe_disconnect

        # Set skip_dialog_msg to a message displayed to the user
        skip_dialog_name=None, skip_dialog_msg=_('Show this confirmation again'),
        skip_dialog_skipped_value=True, skip_dialog_skip_precheck=True,
        # Override icon (QIcon to be used as the icon for this dialog or string for I())
        override_icon=None,
        # Change the text/icons of the yes and no buttons.
        # The icons must be QIcon objects or strings for I()
        yes_text=None, no_text=None, yes_icon=None, no_icon=None,
):

    auto_skip = set(gprefs.get('questions_to_auto_skip', []))
    if (skip_dialog_name is not None and skip_dialog_name in auto_skip):
        return bool(skip_dialog_skipped_value)

    d = MessageBox(MessageBox.QUESTION, title, msg, det_msg, parent=parent,
                   show_copy_button=show_copy_button, default_yes=default_yes,
                   q_icon=override_icon, yes_text=yes_text, no_text=no_text,
                   yes_icon=yes_icon, no_icon=no_icon)

    if skip_dialog_name is not None and skip_dialog_msg:
        tc = d.toggle_checkbox
        tc.setVisible(True)
        tc.setText(skip_dialog_msg)
        tc.setChecked(bool(skip_dialog_skip_precheck))
        d.resize_needed.emit()

    ret = d.exec() == QDialog.DialogCode.Accepted

    if skip_dialog_name is not None and not d.toggle_checkbox.isChecked():
        auto_skip.add(skip_dialog_name)

        gprefs.set('questions_to_auto_skip', list(auto_skip))