# Path: tikz_editor/tools/qt/actions.py
# class ActionFactory(object):
# 	"""
# 	Helper functions to create Qt actions
# 	"""
# 
# 	@staticmethod
# 	def createAction(parent, text, tip=None, shortcut=None, slot=None, checkable=False, icon=None):
# 		a = QAction(text, parent)
# 		if icon is not None:
# 			a.setIcon(QIcon(":/%s.png" % icon))
# 		if shortcut is not None:
# 			a.setShortcut(shortcut)
# 		if tip is not None:
# 			a.setToolTip(tip)
# 			a.setStatusTip(tip)
# 		if slot is not None:
# 			a.triggered.connect(slot)
# 		if checkable:
# 			a.setCheckable(True)
# 		return a
# 
# 	@staticmethod
# 	def addActionsToMenu(actions, menu):
# 		for action in actions:
# 			if action is None:
# 				menu.addSeparator()
# 			else:
# 				menu.addAction(action)
# 
# Path: tikz_editor/tools/qt/toolbar.py
# class ToolBarFactory(object):
# 	"""
# 	Helper functions to create Qt toolbars
# 	"""
# 
# 	@staticmethod
# 	def createToolBar(parent, name):
# 		toolbar = QToolBar(name, parent)
# 		toolbar.setMovable(False)
# 		toolbar.setFloatable(False)
# 		parent.addToolBar(Qt.TopToolBarArea, toolbar)
# 		return toolbar
# 
# 	@staticmethod
# 	def addItemsToToolBar(items, toolbar):
# 		for item in items:
# 			if item is None:
# 				ToolBarFactory.addSpacerToToolBar(toolbar)
# 			elif isinstance(item, QAction):
# 				toolbar.addAction(item)
# 			elif isinstance(item, tuple):
# 				ToolBarFactory.addMenuToToolBar(item[0], item[1], toolbar)
# 			elif isinstance(item, QWidget):
# 				toolbar.addWidget(item)
# 
# 	@staticmethod
# 	def addSpacerToToolBar(toolbar):
# 		spacer = QWidget()
# 		spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
# 		toolbar.addWidget(spacer)
# 
# 	@staticmethod
# 	def addMenuToToolBar(title, menu, toolbar):
# 		button = QToolButton()
# 		button.setToolButtonStyle(Qt.ToolButtonTextOnly)
# 		button.setDefaultAction(QAction(title, button))
# 		button.setMenu(menu)
# 		button.setPopupMode(QToolButton.InstantPopup)
# 		toolbar.addWidget(button)


from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from tikz_editor.tools.qt import ActionFactory, ToolBarFactory
import tikz_editor.globals.actions as actions
	@current_editor_view.setter
	def current_editor_view(self, view):
		self.stacked_widget.setCurrentWidget(view)
		view.setFocus()

	def initView(self):
		self.source_editor_view.cursorPositionChanged.connect(self._sourceCursorPositionChanged)
		self.source_editor_view.selectionChanged.connect(self._sourceSelectionChanged)
		self.source_editor_view.modificationAttempted.connect(self._sourceModificationAttemptedWhileReadOnly)
		self._initToolBar()
		self._initStackedWidgets()

	def _initToolBar(self):
		toolbar = ToolBarFactory.createToolBar(self, "Content")
		self._initToolBarActions(toolbar)

	def _initToolBarActions(self, toolbar):
		actions_group = QActionGroup(self)
		show_source_action = ActionFactory.createAction(toolbar, "Source", "Show LaTeX source editor",
														slot=self.showSourceView, checkable=True)
		show_preamble_action = ActionFactory.createAction(toolbar, "Preamble", "Show LaTeX preamble editor",
														  slot=self.showPreambleView, checkable=True)

		self.actions[actions.SHOW_SOURCE] = show_source_action
		self.actions[actions.SHOW_PREAMBLE] = show_preamble_action

		show_source_action.setChecked(True)
		actions_group.addAction(show_source_action)
		actions_group.addAction(show_preamble_action)


# Path: tikz_editor/tools/qt/actions.py
# class ActionFactory(object):
# 	"""
# 	Helper functions to create Qt actions
# 	"""
# 
# 	@staticmethod
# 	def createAction(parent, text, tip=None, shortcut=None, slot=None, checkable=False, icon=None):
# 		a = QAction(text, parent)
# 		if icon is not None:
# 			a.setIcon(QIcon(":/%s.png" % icon))
# 		if shortcut is not None:
# 			a.setShortcut(shortcut)
# 		if tip is not None:
# 			a.setToolTip(tip)
# 			a.setStatusTip(tip)
# 		if slot is not None:
# 			a.triggered.connect(slot)
# 		if checkable:
# 			a.setCheckable(True)
# 		return a
# 
# 	@staticmethod
# 	def addActionsToMenu(actions, menu):
# 		for action in actions:
# 			if action is None:
# 				menu.addSeparator()
# 			else:
# 				menu.addAction(action)
# 
# Path: tikz_editor/tools/qt/toolbar.py
# class ToolBarFactory(object):
# 	"""
# 	Helper functions to create Qt toolbars
# 	"""
# 
# 	@staticmethod
# 	def createToolBar(parent, name):
# 		toolbar = QToolBar(name, parent)
# 		toolbar.setMovable(False)
# 		toolbar.setFloatable(False)
# 		parent.addToolBar(Qt.TopToolBarArea, toolbar)
# 		return toolbar
# 
# 	@staticmethod
# 	def addItemsToToolBar(items, toolbar):
# 		for item in items:
# 			if item is None:
# 				ToolBarFactory.addSpacerToToolBar(toolbar)
# 			elif isinstance(item, QAction):
# 				toolbar.addAction(item)
# 			elif isinstance(item, tuple):
# 				ToolBarFactory.addMenuToToolBar(item[0], item[1], toolbar)
# 			elif isinstance(item, QWidget):
# 				toolbar.addWidget(item)
# 
# 	@staticmethod
# 	def addSpacerToToolBar(toolbar):
# 		spacer = QWidget()
# 		spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
# 		toolbar.addWidget(spacer)
# 
# 	@staticmethod
# 	def addMenuToToolBar(title, menu, toolbar):
# 		button = QToolButton()
# 		button.setToolButtonStyle(Qt.ToolButtonTextOnly)
# 		button.setDefaultAction(QAction(title, button))
# 		button.setMenu(menu)
# 		button.setPopupMode(QToolButton.InstantPopup)
# 		toolbar.addWidget(button)


# Path: tikz_editor/views/document/content.py
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from tikz_editor.tools.qt import ActionFactory, ToolBarFactory
import tikz_editor.globals.actions as actions

	@current_editor_view.setter
	def current_editor_view(self, view):
		self.stacked_widget.setCurrentWidget(view)
		view.setFocus()

	def initView(self):
		self.source_editor_view.cursorPositionChanged.connect(self._sourceCursorPositionChanged)
		self.source_editor_view.selectionChanged.connect(self._sourceSelectionChanged)
		self.source_editor_view.modificationAttempted.connect(self._sourceModificationAttemptedWhileReadOnly)
		self._initToolBar()
		self._initStackedWidgets()

	def _initToolBar(self):
		toolbar = ToolBarFactory.createToolBar(self, "Content")
		self._initToolBarActions(toolbar)

	def _initToolBarActions(self, toolbar):
		actions_group = QActionGroup(self)
		show_source_action = ActionFactory.createAction(toolbar, "Source", "Show LaTeX source editor",
														slot=self.showSourceView, checkable=True)
		show_preamble_action = ActionFactory.createAction(toolbar, "Preamble", "Show LaTeX preamble editor",
														  slot=self.showPreambleView, checkable=True)

		self.actions[actions.SHOW_SOURCE] = show_source_action
		self.actions[actions.SHOW_PREAMBLE] = show_preamble_action

		show_source_action.setChecked(True)
		actions_group.addAction(show_source_action)
		actions_group.addAction(show_preamble_action)


		ToolBarFactory.addItemsToToolBar((