本文整理汇总了Python中cola.settings.Settings.load方法的典型用法代码示例。如果您正苦于以下问题:Python Settings.load方法的具体用法?Python Settings.load怎么用?Python Settings.load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cola.settings.Settings
的用法示例。
在下文中一共展示了Settings.load方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: BookmarksWidget
# 需要导入模块: from cola.settings import Settings [as 别名]
# 或者: from cola.settings.Settings import load [as 别名]
class BookmarksWidget(QtGui.QWidget):
def __init__(self, style=BOOKMARKS, parent=None):
QtGui.QWidget.__init__(self, parent)
self.style = style
self.settings = Settings()
self.tree = BookmarksTreeWidget(style, self.settings, parent=self)
self.add_button = qtutils.create_action_button(
tooltip=N_('Add'), icon=qtutils.add_icon())
self.delete_button = qtutils.create_action_button(
tooltip=N_('Delete'), icon=qtutils.remove_icon())
self.delete_button.setEnabled(False)
self.open_button = qtutils.create_action_button(
tooltip=N_('Open'), icon=qtutils.open_icon())
self.open_button.setEnabled(False)
self.setFocusProxy(self.tree)
if style == BOOKMARKS:
self.setToolTip(N_('Bookmarked repositories'))
elif style == RECENT_REPOS:
self.setToolTip(N_('Recent repositories'))
self.add_button.hide()
self.button_layout = qtutils.hbox(defs.no_margin, defs.spacing,
self.open_button, self.add_button,
self.delete_button)
self.main_layout = qtutils.vbox(defs.no_margin, defs.spacing, self.tree)
self.setLayout(self.main_layout)
self.corner_widget = QtGui.QWidget(self)
self.corner_widget.setLayout(self.button_layout)
titlebar = parent.titleBarWidget()
titlebar.add_corner_widget(self.corner_widget)
qtutils.connect_button(self.add_button, self.tree.add_bookmark)
qtutils.connect_button(self.delete_button, self.tree.delete_bookmark)
qtutils.connect_button(self.open_button, self.tree.open_repo)
self.connect(self.tree, SIGNAL('itemSelectionChanged()'),
self.tree_item_selection_changed)
QtCore.QTimer.singleShot(0, self.reload_bookmarks)
def reload_bookmarks(self):
# Called once after the GUI is initialized
self.settings.load()
self.tree.refresh()
def tree_item_selection_changed(self):
enabled = bool(self.tree.selected_item())
self.delete_button.setEnabled(enabled)
self.open_button.setEnabled(enabled)
示例2: BookmarksWidget
# 需要导入模块: from cola.settings import Settings [as 别名]
# 或者: from cola.settings.Settings import load [as 别名]
class BookmarksWidget(QtGui.QWidget):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.settings = Settings()
self.tree = BookmarksTreeWidget(self.settings, parent=self)
self.add_button = qtutils.create_action_button(
tooltip=N_('Add'), icon=qtutils.add_icon())
self.delete_button = qtutils.create_action_button(
tooltip=N_('Delete'), icon=qtutils.remove_icon())
self.delete_button.setEnabled(False)
self.open_button = qtutils.create_action_button(
tooltip=N_('Open'), icon=qtutils.open_icon())
self.open_button.setEnabled(False)
qtutils.connect_button(self.add_button, self.tree.add_bookmark)
qtutils.connect_button(self.delete_button, self.tree.delete_bookmark)
qtutils.connect_button(self.open_button, self.tree.open_repo)
self.connect(self.tree, SIGNAL('itemSelectionChanged()'),
self.tree_item_selection_changed)
self.button_layout = QtGui.QHBoxLayout()
self.button_layout.setMargin(defs.no_margin)
self.button_layout.setSpacing(defs.spacing)
self.button_layout.addWidget(self.open_button)
self.button_layout.addWidget(self.add_button)
self.button_layout.addWidget(self.delete_button)
self.main_layout = QtGui.QVBoxLayout()
self.main_layout.setMargin(defs.no_margin)
self.main_layout.setSpacing(defs.spacing)
self.main_layout.addWidget(self.tree)
self.setLayout(self.main_layout)
self.corner_widget = QtGui.QWidget(self)
self.corner_widget.setLayout(self.button_layout)
titlebar = parent.titleBarWidget()
titlebar.add_corner_widget(self.corner_widget)
self.setFocusProxy(self.tree)
QtCore.QTimer.singleShot(0, self.reload_bookmarks)
def reload_bookmarks(self):
# Called once after the GUI is initialized
self.settings.load()
self.tree.refresh()
def tree_item_selection_changed(self):
enabled = bool(self.tree.selected_item())
self.delete_button.setEnabled(enabled)
self.open_button.setEnabled(enabled)
示例3: build_recent_menu
# 需要导入模块: from cola.settings import Settings [as 别名]
# 或者: from cola.settings.Settings import load [as 别名]
def build_recent_menu(self):
settings = Settings()
settings.load()
recent = settings.recent
cmd = cmds.OpenRepo
menu = self.open_recent_menu
menu.clear()
for r in recent:
name = os.path.basename(r)
directory = os.path.dirname(r)
text = '%s %s %s' % (name, unichr(0x2192), directory)
menu.addAction(text, cmds.run(cmd, r))
示例4: refresh
# 需要导入模块: from cola.settings import Settings [as 别名]
# 或者: from cola.settings.Settings import load [as 别名]
def refresh(self):
self.clear()
settings = Settings()
settings.load()
items = []
icon = qtutils.dir_icon()
recents = set(settings.recent)
for path in settings.recent:
item = BookmarksTreeWidgetItem(path, icon)
items.append(item)
for path in settings.bookmarks:
if path in recents: # avoid duplicates
continue
item = BookmarksTreeWidgetItem(path, icon)
items.append(item)
self.addTopLevelItems(items)
示例5: closeEvent
# 需要导入模块: from cola.settings import Settings [as 别名]
# 或者: from cola.settings.Settings import load [as 别名]
def closeEvent(self, event):
settings = Settings()
settings.load()
settings.add_recent(core.getcwd())
self.save_state(settings=settings)
self.QtClass.closeEvent(self, event)
示例6: restore_state
# 需要导入模块: from cola.settings import Settings [as 别名]
# 或者: from cola.settings.Settings import load [as 别名]
def restore_state(self, settings=None):
if settings is None:
settings = Settings()
settings.load()
state = settings.get_gui_state(self)
return bool(state) and self.apply_state(state)
示例7: save_state
# 需要导入模块: from cola.settings import Settings [as 别名]
# 或者: from cola.settings.Settings import load [as 别名]
def save_state(self, settings=None):
if settings is None:
settings = Settings()
settings.load()
if gitcfg.current().get('cola.savewindowsettings', True):
settings.save_gui_state(self)
示例8: BookmarksDialog
# 需要导入模块: from cola.settings import Settings [as 别名]
# 或者: from cola.settings.Settings import load [as 别名]
class BookmarksDialog(standard.Dialog):
def __init__(self, parent):
standard.Dialog.__init__(self, parent=parent)
self.settings = Settings()
self.settings.load()
self.resize(494, 238)
self.setWindowTitle(N_('Bookmarks'))
if parent is not None:
self.setWindowModality(Qt.WindowModal)
self.layt = QtGui.QVBoxLayout(self)
self.layt.setMargin(defs.margin)
self.layt.setSpacing(defs.spacing)
self.bookmarks = QtGui.QListWidget(self)
self.bookmarks.setAlternatingRowColors(True)
self.bookmarks.setSelectionMode(QtGui.QAbstractItemView
.ExtendedSelection)
self.layt.addWidget(self.bookmarks)
self.button_layout = QtGui.QHBoxLayout()
self.open_button = qtutils.create_button(text=N_('Open'),
icon=qtutils.open_icon())
self.open_button.setEnabled(False)
self.button_layout.addWidget(self.open_button)
self.add_button = qtutils.create_button(text=N_('Add'),
icon=qtutils.add_icon())
self.button_layout.addWidget(self.add_button)
self.delete_button = QtGui.QPushButton(self)
self.delete_button.setText(N_('Delete'))
self.delete_button.setIcon(qtutils.discard_icon())
self.delete_button.setEnabled(False)
self.button_layout.addWidget(self.delete_button)
self.button_layout.addStretch()
self.save_button = QtGui.QPushButton(self)
self.save_button.setText(N_('Save'))
self.save_button.setIcon(qtutils.save_icon())
self.save_button.setEnabled(False)
self.button_layout.addWidget(self.save_button)
self.close_button = QtGui.QPushButton(self)
self.close_button.setText(N_('Close'))
self.button_layout.addWidget(self.close_button)
self.layt.addLayout(self.button_layout)
self.connect(self.bookmarks, SIGNAL('itemSelectionChanged()'),
self.item_selection_changed)
qtutils.connect_button(self.open_button, self.open_repo)
qtutils.connect_button(self.add_button, self.add)
qtutils.connect_button(self.delete_button, self.delete)
qtutils.connect_button(self.save_button, self.save)
qtutils.connect_button(self.close_button, self.accept)
self.update_bookmarks()
def update_bookmarks(self):
self.bookmarks.clear()
self.bookmarks.addItems(self.settings.bookmarks)
def selection(self):
return qtutils.selection_list(self.bookmarks, self.settings.bookmarks)
def item_selection_changed(self):
has_selection = bool(self.selection())
self.open_button.setEnabled(has_selection)
self.delete_button.setEnabled(has_selection)
def save(self):
"""Saves the bookmarks settings and exits"""
self.settings.save()
self.save_button.setEnabled(False)
def add(self):
path, ok = qtutils.prompt(N_('Path to git repository'),
title=N_('Enter Git Repository'),
text=core.getcwd())
if not ok:
return
self.settings.bookmarks.append(path)
self.update_bookmarks()
self.save()
def open_repo(self):
"""Opens a new git-cola session on a bookmark"""
for repo in self.selection():
core.fork([sys.executable, sys.argv[0], '--repo', repo])
def delete(self):
"""Removes a bookmark from the bookmarks list"""
selection = self.selection()
if not selection:
return
for repo in selection:
self.settings.remove_bookmark(repo)
#.........这里部分代码省略.........
示例9: __init__
# 需要导入模块: from cola.settings import Settings [as 别名]
# 或者: from cola.settings.Settings import load [as 别名]
def __init__(self, parent=None):
QtGui.QDialog.__init__(self, parent)
self.setWindowTitle(N_("git-cola"))
self.repodir = None
self.task_runner = TaskRunner(self)
self.progress = ProgressDialog("", "", self)
self.new_button = QtGui.QPushButton(N_("New..."))
self.new_button.setIcon(qtutils.new_icon())
self.open_button = QtGui.QPushButton(N_("Open..."))
self.open_button.setIcon(qtutils.open_icon())
self.clone_button = QtGui.QPushButton(N_("Clone..."))
self.clone_button.setIcon(qtutils.git_icon())
self.close_button = QtGui.QPushButton(N_("Close"))
settings = Settings()
settings.load()
self.bookmarks_label = QtGui.QLabel(N_("Select Repository..."))
self.bookmarks_label.setAlignment(Qt.AlignCenter)
self.bookmarks_model = QtGui.QStandardItemModel()
item = QtGui.QStandardItem(N_("Select manually..."))
item.setEditable(False)
self.bookmarks_model.appendRow(item)
added = set()
all_repos = settings.bookmarks + settings.recent
for repo in all_repos:
if repo in added:
continue
added.add(repo)
item = QtGui.QStandardItem(repo)
item.setEditable(False)
self.bookmarks_model.appendRow(item)
selection_mode = QtGui.QAbstractItemView.SingleSelection
self.bookmarks = QtGui.QListView()
self.bookmarks.setSelectionMode(selection_mode)
self.bookmarks.setAlternatingRowColors(True)
self.bookmarks.setModel(self.bookmarks_model)
if not all_repos:
self.bookmarks_label.setMinimumHeight(1)
self.bookmarks.setMinimumHeight(1)
self.bookmarks_label.hide()
self.bookmarks.hide()
self.button_layout = qtutils.hbox(
defs.no_margin,
defs.spacing,
self.open_button,
self.clone_button,
self.new_button,
qtutils.STRETCH,
self.close_button,
)
self.main_layout = qtutils.vbox(
defs.margin, defs.spacing, self.bookmarks_label, self.bookmarks, self.button_layout
)
self.setLayout(self.main_layout)
qtutils.connect_button(self.open_button, self.open_repo)
qtutils.connect_button(self.clone_button, self.clone_repo)
qtutils.connect_button(self.new_button, self.new_repo)
qtutils.connect_button(self.close_button, self.reject)
self.connect(self.bookmarks, SIGNAL("activated(const QModelIndex &)"), self.open_bookmark)
示例10: new_settings
# 需要导入模块: from cola.settings import Settings [as 别名]
# 或者: from cola.settings.Settings import load [as 别名]
def new_settings(self, **kwargs):
settings = Settings(**kwargs)
settings.load()
return settings
示例11: save_settings
# 需要导入模块: from cola.settings import Settings [as 别名]
# 或者: from cola.settings.Settings import load [as 别名]
def save_settings(self):
settings = Settings()
settings.load()
settings.add_recent(core.getcwd())
return self.save_state(settings=settings)
示例12: __init__
# 需要导入模块: from cola.settings import Settings [as 别名]
# 或者: from cola.settings.Settings import load [as 别名]
def __init__(self, parent=None, settings=None):
standard.Dialog.__init__(self, parent, save_settings=True)
self.setWindowTitle(N_('git-cola'))
self.repodir = None
self.runtask = qtutils.RunTask(parent=self)
self.progress = standard.ProgressDialog('', '', self)
self.new_button = qtutils.create_button(text=N_('New...'),
icon=icons.new())
self.open_button = qtutils.create_button(text=N_('Open...'),
icon=icons.repo())
self.clone_button = qtutils.create_button(text=N_('Clone...'),
icon=icons.cola())
self.close_button = qtutils.close_button()
if settings is None:
settings = Settings()
settings.load()
self.settings = settings
self.bookmarks_label = QtGui.QLabel(N_('Select Repository...'))
self.bookmarks_label.setAlignment(Qt.AlignCenter)
self.bookmarks_model = QtGui.QStandardItemModel()
item = QtGui.QStandardItem(N_('Select manually...'))
item.setEditable(False)
self.bookmarks_model.appendRow(item)
added = set()
all_repos = settings.bookmarks + settings.recent
for repo in all_repos:
if repo in added:
continue
added.add(repo)
item = QtGui.QStandardItem(repo)
item.setEditable(False)
self.bookmarks_model.appendRow(item)
selection_mode = QtGui.QAbstractItemView.SingleSelection
self.bookmarks = QtGui.QListView()
self.bookmarks.setSelectionMode(selection_mode)
self.bookmarks.setAlternatingRowColors(True)
self.bookmarks.setModel(self.bookmarks_model)
if not all_repos:
self.bookmarks_label.setMinimumHeight(1)
self.bookmarks.setMinimumHeight(1)
self.bookmarks_label.hide()
self.bookmarks.hide()
self.button_layout = qtutils.hbox(defs.no_margin, defs.spacing,
self.open_button, self.clone_button,
self.new_button, qtutils.STRETCH,
self.close_button)
self.main_layout = qtutils.vbox(defs.margin, defs.spacing,
self.bookmarks_label, self.bookmarks,
self.button_layout)
self.setLayout(self.main_layout)
qtutils.connect_button(self.open_button, self.open_repo)
qtutils.connect_button(self.clone_button, self.clone_repo)
qtutils.connect_button(self.new_button, self.new_repo)
qtutils.connect_button(self.close_button, self.reject)
self.connect(self.bookmarks,
SIGNAL('activated(QModelIndex)'), self.open_bookmark)
if not self.restore_state(settings=settings):
screen = QtGui.QApplication.instance().desktop()
self.setGeometry(screen.width() // 4, screen.height() // 4,
screen.width() // 2, screen.height() // 2)
示例13: __init__
# 需要导入模块: from cola.settings import Settings [as 别名]
# 或者: from cola.settings.Settings import load [as 别名]
def __init__(self, parent=None):
QtGui.QDialog.__init__(self, parent)
self.setWindowTitle(N_('git-cola'))
self._gitdir = None
self._layt = QtGui.QHBoxLayout()
self._layt.setMargin(defs.margin)
self._layt.setSpacing(defs.spacing)
self._new_btn = QtGui.QPushButton(N_('New...'))
self._new_btn.setIcon(qtutils.new_icon())
self._open_btn = QtGui.QPushButton(N_('Open...'))
self._open_btn.setIcon(qtutils.open_icon())
self._clone_btn = QtGui.QPushButton(N_('Clone...'))
self._clone_btn.setIcon(qtutils.git_icon())
self._close_btn = QtGui.QPushButton(N_('Close'))
self._layt.addWidget(self._open_btn)
self._layt.addWidget(self._clone_btn)
self._layt.addWidget(self._new_btn)
self._layt.addStretch()
self._layt.addWidget(self._close_btn)
settings = Settings()
settings.load()
self._vlayt = QtGui.QVBoxLayout()
self._vlayt.setMargin(defs.margin)
self._vlayt.setSpacing(defs.margin)
self._bookmark_label = QtGui.QLabel(N_('Select Repository...'))
self._bookmark_label.setAlignment(Qt.AlignCenter)
self._bookmark_model = QtGui.QStandardItemModel()
item = QtGui.QStandardItem(N_('Select manually...'))
item.setEditable(False)
self._bookmark_model.appendRow(item)
added = set()
all_repos = settings.bookmarks + settings.recent
for repo in all_repos:
if repo in added:
continue
added.add(repo)
item = QtGui.QStandardItem(repo)
item.setEditable(False)
self._bookmark_model.appendRow(item)
selection_mode = QtGui.QAbstractItemView.SingleSelection
self._bookmark_list = QtGui.QListView()
self._bookmark_list.setSelectionMode(selection_mode)
self._bookmark_list.setAlternatingRowColors(True)
self._bookmark_list.setModel(self._bookmark_model)
if not all_repos:
self._bookmark_label.setMinimumHeight(1)
self._bookmark_list.setMinimumHeight(1)
self._bookmark_label.hide()
self._bookmark_list.hide()
self._vlayt.addWidget(self._bookmark_label)
self._vlayt.addWidget(self._bookmark_list)
self._vlayt.addLayout(self._layt)
self.setLayout(self._vlayt)
qtutils.connect_button(self._open_btn, self._open)
qtutils.connect_button(self._clone_btn, self._clone)
qtutils.connect_button(self._new_btn, self._new)
qtutils.connect_button(self._close_btn, self.reject)
self.connect(self._bookmark_list,
SIGNAL('activated(const QModelIndex &)'),
self._open_bookmark)