本文整理汇总了Python中PyQt5.QtCore.QSettings方法的典型用法代码示例。如果您正苦于以下问题:Python QtCore.QSettings方法的具体用法?Python QtCore.QSettings怎么用?Python QtCore.QSettings使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtCore
的用法示例。
在下文中一共展示了QtCore.QSettings方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QSettings [as 别名]
def __init__(self, parent=None):
super().__init__()
self.settings = Qc.QSettings(CONFIG_PATH, Qc.QSettings.IniFormat)
self.setting_params = {
'angrysearch_lite': True,
'fts': True,
'typing_delay': False,
'darktheme': False,
'fm_path_doubleclick_selects': False,
'icon_theme': 'adwaita',
'file_manager': 'xdg-open',
'row_height': 0,
'number_of_results': 500,
'directories_excluded': [],
'conditional_mounts_for_autoupdate': [],
'notifications': True,
'regex_mode': False,
'close_on_execute': False
}
# FOR REGEX MODE, WHEN REGEX QUERY CAN BE RUN SO ONLY ONE ACCESS DB
self.regex_query_ready = True
self.read_settings()
self.init_gui()
示例2: set_language
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QSettings [as 别名]
def set_language(self):
"""Change language"""
settings = QtCore.QSettings()
language = settings.value("language")
if not language:
language = QtCore.QLocale.system().name().split("_")[0]
lang_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "languages")
lang_file = "qhangups_{}.qm".format(language)
qt_lang_path = QtCore.QLibraryInfo.location(QtCore.QLibraryInfo.TranslationsPath)
qt_lang_file = "qt_{}.qm".format(language)
if os.path.isfile(os.path.join(lang_path, lang_file)):
translator.load(lang_file, lang_path)
qt_translator.load(qt_lang_file, qt_lang_path)
else:
translator.load("")
qt_translator.load("")
示例3: set_active
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QSettings [as 别名]
def set_active(self):
"""Activate conversation tab"""
settings = QtCore.QSettings()
# Set the client as active
if settings.value("send_client_active", True, type=bool):
future = asyncio.async(self.client.set_active())
future.add_done_callback(lambda future: future.result())
# Mark the newest event as read
if settings.value("send_read_state", True, type=bool):
future = asyncio.async(self.conv.update_read_timestamp())
future.add_done_callback(lambda future: future.result())
self.num_unread_local = 0
self.set_title()
self.messageTextEdit.setFocus()
示例4: closeEvent
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QSettings [as 别名]
def closeEvent(self, event=None):
if self.okToContinue():
for tab in range(self.centralwidget.count()):
centralwidget = self.centralwidget.widget(tab)
scene = centralwidget.subWindowList()[0].widget().scene()
scene.clearSelection()
settings = QtCore.QSettings()
if self.filename:
filename = QtCore.QVariant(self.filename)
else:
filename = QtCore.QVariant()
settings.setValue("LastFile", filename)
if self.recentFiles:
recentFiles = QtCore.QVariant(self.recentFiles)
else:
recentFiles = QtCore.QVariant()
settings.setValue("RecentFiles", recentFiles)
settings.setValue("Geometry", QtCore.QVariant(self.saveGeometry()))
settings.setValue("MainWindow/State",
QtCore.QVariant(self.saveState()))
self.close()
else:
event.ignore()
示例5: accept
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QSettings [as 别名]
def accept(self):
"""
Create Eddy workspace (if necessary).
"""
path = self.workspaceField.value()
try:
mkdir(path)
except Exception as e:
msgbox = QtWidgets.QMessageBox(self)
msgbox.setDetailedText(format_exception(e))
msgbox.setIconPixmap(QtGui.QIcon(':/icons/48/ic_error_outline_black').pixmap(48))
msgbox.setStandardButtons(QtWidgets.QMessageBox.Close)
msgbox.setText('{0} could not create the specified workspace: {1}!'.format(APPNAME, path))
msgbox.setWindowIcon(QtGui.QIcon(':/icons/128/ic_eddy'))
msgbox.setWindowTitle('Workspace setup failed!')
msgbox.exec_()
super().reject()
else:
settings = QtCore.QSettings(ORGANIZATION, APPNAME)
settings.setValue('workspace/home', path)
settings.sync()
super().accept()
示例6: doCheckForUpdate
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QSettings [as 别名]
def doCheckForUpdate(self):
"""
Execute the update check routine.
"""
channel = Channel.Beta
# SHOW PROGRESS BAR
progressBar = self.widget('progress_bar')
progressBar.setToolTip('Checking for updates...')
progressBar.setVisible(True)
# RUN THE UPDATE CHECK WORKER IN A THREAD
try:
settings = QtCore.QSettings(ORGANIZATION, APPNAME)
channel = Channel.valueOf(settings.value('update/channel', channel, str))
except TypeError:
pass
finally:
worker = UpdateCheckWorker(channel, VERSION)
connect(worker.sgnNoUpdateAvailable, self.onNoUpdateAvailable)
connect(worker.sgnNoUpdateDataAvailable, self.onNoUpdateDataAvailable)
connect(worker.sgnUpdateAvailable, self.onUpdateAvailable)
self.startThread('updateCheck', worker)
示例7: setUp
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QSettings [as 别名]
def setUp(self):
"""
Initialize test case environment.
"""
# ACQUIRE LOCK AND FLUSH STREAMS
testcase_lock.acquire()
sys.stderr.flush()
sys.stdout.flush()
# MAKE SURE TO USE CORRECT SETTINGS
settings = QtCore.QSettings(ORGANIZATION, APPNAME)
settings.setValue('workspace/home', WORKSPACE)
settings.setValue('update/check_on_startup', False)
settings.sync()
# MAKE SURE THE WORKSPACE DIRECTORY EXISTS
mkdir(expandPath(WORKSPACE))
# MAKE SURE TO HAVE A CLEAN TEST ENVIRONMENT
rmdir('@tests/.tests/')
mkdir('@tests/.tests/')
# INITIALIZED VARIABLES
self.eddy = None
self.project = None
self.session = None
示例8: get_conn_from_settings
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QSettings [as 别名]
def get_conn_from_settings(self, dbname):
"""Retruns a connection info and data from a dbname saved in QgsSettings"""
qs = QSettings()
conn_dict = {}
qs.beginGroup(CONN + '/' + dbname)
pg_conn_info = None
if qs.value('service') :
conn_dict['service'] = qs.value('service')
pg_conn_info = "service={}".format(conn_dict['service'])
else:
conn_dict['database'] = qs.value('database', dbname)
conn_dict['username'] = qs.value('username', "postgres")
print("username={}".format(conn_dict['username']))
conn_dict['host'] = qs.value('host', "127.0.0.1")
conn_dict['port'] = qs.value('port', "5432")
conn_dict['password'] = qs.value('password', '')
pg_conn_info = "dbname='{}' user='{}' host='{}' port='{}' password='{}'".format(
conn_dict['database'], conn_dict['username'], conn_dict['host'],
conn_dict['port'], conn_dict['password'])
return (pg_conn_info, conn_dict)
示例9: selectDatabase
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QSettings [as 别名]
def selectDatabase(self):
dlg = QDialog()
dlg.setWindowTitle('Choose the database')
layout = QVBoxLayout(dlg)
button_box = QDialogButtonBox(dlg)
button_box.setStandardButtons(
QDialogButtonBox.Cancel | QDialogButtonBox.Ok)
button_box.accepted.connect(dlg.accept)
button_box.rejected.connect(dlg.reject)
connectionBox = QComboBox(dlg)
qs = QSettings()
qs.beginGroup(CONN)
connections = qs.childGroups()
connectionBox.addItems(connections)
qs.endGroup()
layout.addWidget(connectionBox)
layout.addWidget(button_box)
if not dlg.exec_():
return None
return connectionBox.currentText()
示例10: read_view_settings
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QSettings [as 别名]
def read_view_settings(self, key, settings=None, reset=False):
""" Reads the persistent program settings
:param reset: If True, the program resets to its default settings
:returns: True if the header state was restored, otherwise returns False
"""
logger.debug("Reading view settings for: {}".format(key))
header_restored = False
if not reset:
if settings is None:
settings = QtCore.QSettings()
horizontal_header = self._horizontal_header()
header_restored = horizontal_header.restoreState(settings.value(key))
# update actions
for col, action in enumerate(horizontal_header.actions()):
is_checked = not horizontal_header.isSectionHidden(col)
action.setChecked(is_checked)
return header_restored
示例11: updatephases
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QSettings [as 别名]
def updatephases(self):
self.aw.qmc.phases[0] = self.startdry.value()
self.aw.qmc.phases[1] = self.enddry.value()
self.aw.qmc.phases[2] = self.endmid.value()
self.aw.qmc.phases[3] = self.endfinish.value()
if self.pushbuttonflag.isChecked():
self.aw.qmc.phasesbuttonflag = True
else:
self.aw.qmc.phasesbuttonflag = False
self.aw.qmc.redraw(recomputeAllDeltas=False)
self.savePhasesSettings()
#save window position (only; not size!)
settings = QSettings()
settings.setValue("PhasesPosition",self.frameGeometry().topLeft())
self.accept()
示例12: cancel
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QSettings [as 别名]
def cancel(self):
self.aw.qmc.phases = list(self.phases)
self.aw.qmc.phasesbuttonflag = bool(self.org_phasesbuttonflag)
self.aw.qmc.phasesfromBackgroundflag = bool(self.org_fromBackgroundflag)
self.aw.qmc.watermarksflag = bool(self.org_watermarksflag)
self.aw.qmc.phasesLCDflag = bool(self.org_phasesLCDflag)
self.aw.qmc.autoDRYflag = bool(self.org_autoDRYflag)
self.aw.qmc.autoFCsFlag = bool(self.org_autoFCsFlag)
self.aw.qmc.phasesLCDmode_l = list(self.org_phasesLCDmode_l)
self.aw.qmc.phasesLCDmode_all = list(self.org_phasesLCDmode_all)
self.aw.qmc.redraw(recomputeAllDeltas=False)
self.savePhasesSettings()
#save window position (only; not size!)
settings = QSettings()
settings.setValue("PhasesPosition",self.frameGeometry().topLeft())
self.reject()
示例13: closeEvent
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QSettings [as 别名]
def closeEvent(self, _):
self.disconnecting = True
if self.ble is not None:
try:
self.ble.batteryChanged.disconnect()
self.ble.weightChanged.disconnect()
self.ble.deviceDisconnected.disconnect()
except:
pass
try:
self.ble.disconnectDevice()
except:
pass
settings = QSettings()
#save window geometry
settings.setValue("RoastGeometry",self.saveGeometry())
# triggered via the cancel button
示例14: __init__
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QSettings [as 别名]
def __init__(self, parent = None, aw = None, title = "", content = ""):
super(HelpDlg,self).__init__(parent, aw)
self.setWindowTitle(title)
self.setModal(False)
settings = QSettings()
if settings.contains("HelpGeometry"):
self.restoreGeometry(settings.value("HelpGeometry"))
phelp = QTextEdit()
phelp.setHtml(content)
phelp.setReadOnly(True)
# connect the ArtisanDialog standard OK/Cancel buttons
self.dialogbuttons.removeButton(self.dialogbuttons.button(QDialogButtonBox.Cancel))
self.dialogbuttons.accepted.connect(self.close)
buttonLayout = QHBoxLayout()
buttonLayout.addStretch()
buttonLayout.addWidget(self.dialogbuttons)
hLayout = QVBoxLayout()
hLayout.addWidget(phelp)
hLayout.addLayout(buttonLayout)
self.setLayout(hLayout)
self.dialogbuttons.button(QDialogButtonBox.Ok).setFocus()
示例15: test_init
# 需要导入模块: from PyQt5 import QtCore [as 别名]
# 或者: from PyQt5.QtCore import QSettings [as 别名]
def test_init(init_patch, config_tmpdir):
configfiles.init()
# Make sure qsettings land in a subdir
if utils.is_linux:
settings = QSettings()
settings.setValue("hello", "world")
settings.sync()
assert (config_tmpdir / 'qsettings').exists()
# Lots of other stuff is tested in test_configinit.py