本文整理汇总了Python中PyQt5.QtWidgets.QSplitter.saveState方法的典型用法代码示例。如果您正苦于以下问题:Python QSplitter.saveState方法的具体用法?Python QSplitter.saveState怎么用?Python QSplitter.saveState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QSplitter
的用法示例。
在下文中一共展示了QSplitter.saveState方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MainWindow
# 需要导入模块: from PyQt5.QtWidgets import QSplitter [as 别名]
# 或者: from PyQt5.QtWidgets.QSplitter import saveState [as 别名]
#.........这里部分代码省略.........
work.triggered.connect(self._find_save)
# Open Recent gets a submenu that is added to the File menu.
# The aboutToShow signal is connected to our _build_recent slot.
self.recent_menu = QMenu( _TR('Sub-menu name', '&Recent Files') )
work = self.file_menu.addMenu( self.recent_menu )
work.setToolTip( _TR('File:Recent tooltip', 'List of recently-used files to open') )
self.file_menu.aboutToShow.connect(self._build_recent)
# divider if not Mac
if not C.PLATFORM_IS_MAC:
self.file_menu.addSeparator()
# TODO Preferences with the menu role that on mac, moves to the app menu
# Quit with the menu role that moves it to the app menu
work = QAction( _TR('Quit command','&Quit'), self )
work.setMenuRole(QAction.QuitRole)
work.setShortcut(QKeySequence.Quit)
work.triggered.connect(self.close)
self.file_menu.addAction(work)
# Initialize the list of "recent" files for the File sub-menu.
# These files were not necessarily open at shutdown, just sometime
# in the not too distant past.
self.recent_files = self._read_flist('mainwindow/recent_files')
# -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Functions related to shutdown and management of settings.
#
# Factor out the job of reading/writing a list of files in the settings.
# Input is a settings array key string like 'mainwindow/recent_files'
# Output is a possibly empty list of canonical-file-path strings.
def _read_flist(self, array_key):
f_list = []
f_count = self.settings.beginReadArray(array_key)
for f in range(f_count): # which may be 0
self.settings.setArrayIndex(f)
f_list.append( self.settings.value('filepath') )
self.settings.endArray()
return f_list
# Input is an array key and a possibly empty list of path strings
def _write_flist(self, file_list, array_key):
if len(file_list):
self.settings.beginWriteArray( array_key, len(file_list) )
for f in range(len(file_list)) :
self.settings.setArrayIndex( f )
self.settings.setValue( 'filepath',file_list[f] )
self.settings.endArray()
# Reimplement QWidget.closeEvent in order to save any open files
# and update the settings.
def closeEvent(self, event):
# If there are any unsaved books, ask the user if they should be
# saved. If the answer is yes, try to do so.
unsaved = []
for (seq, book_object) in self.open_books.items() :
if book_object.get_save_needed() :
unsaved.append(seq)
if len(unsaved):
if len(unsaved) == 1 :
msg = _TR('Shutdown message', 'There is one unsaved file')
else :
msg = _TR('Shutdown message', 'There are %n unsaved files', n=len(unsaved))
ret = utilities.save_discard_cancel_msg(
msg, _TR('Shutdown message', 'Save, Discard changes, or Cancel Quit?') )
if ret is None :
# user wants to cancel shutdown
event.ignore()
return
if ret :
# User want to save. Focus each unsaved file and call _save.
# For all but "Untitled-n" documents this will be silent. For
# those, it will open a save-as dialog. We ignore the return
# from this because we cannot distinguish between a cancelled
# file-open dialog and a file write error.
for seq in unsaved :
self.focus_me(seq)
self._save()
# Clear the settings so that old values don't hang around
self.settings.clear()
# Tell the submodules to save their current global values.
colors.shutdown(self.settings)
fonts.shutdown(self.settings)
dictionaries.shutdown(self.settings)
paths.shutdown(self.settings)
# Save the list of currently-open files in the settings, but do not
# save any whose filename matches "Untitled-#" because that is an
# unsaved New file (which the user chose not to save, above).
open_paths = []
for (index, book_obj) in self.open_books.items() :
if not book_obj.get_book_name().startswith('Untitled-'):
open_paths.append( book_obj.get_book_full_path() )
self._write_flist( open_paths, 'mainwindow/open_files' )
# Save the list of "recent" files in the settings.
self._write_flist(self.recent_files, 'mainwindow/recent_files')
# Save this window's position and size and splitter state
self.settings.setValue("mainwindow/size",self.size())
self.settings.setValue("mainwindow/position",self.pos())
self.settings.setValue("mainwindow/splitter",self.splitter.saveState())
# and that's it, we are done finished, over & out.
event.accept()
示例2: QueryWidget
# 需要导入模块: from PyQt5.QtWidgets import QSplitter [as 别名]
# 或者: from PyQt5.QtWidgets.QSplitter import saveState [as 别名]
class QueryWidget(QWidget):
editorModified = pyqtSignal(bool)
# Editor positions
TOP_POSITION = 0
LEFT_POSITION = 1
def __init__(self):
super(QueryWidget, self).__init__()
box = QVBoxLayout(self)
box.setContentsMargins(0, 0, 0, 0)
self._editor_splitter = QSplitter(Qt.Horizontal)
self.result_splitter = QSplitter(Qt.Vertical)
self._stack_tables = QStackedWidget()
self.result_splitter.addWidget(self._stack_tables)
self.relations = {}
# Editor widget
self._editor_widget = EditorWidget(self)
self._editor_widget.editorModified[bool].connect(
lambda modified: self.editorModified.emit(modified))
self._editor_splitter.addWidget(self._editor_widget)
box.addWidget(self._editor_splitter)
def show_relation(self, item):
central_widget = Pireal.get_service("central")
table_widget = central_widget.get_active_db().table_widget
rela = self.relations[item.name]
dialog = QDialog(self)
dialog.resize(700, 500)
dialog.setWindowTitle(item.name)
box = QVBoxLayout(dialog)
box.setContentsMargins(5, 5, 5, 5)
table = table_widget.create_table(rela, editable=False)
box.addWidget(table)
hbox = QHBoxLayout()
btn = QPushButton(self.tr("Ok"))
btn.clicked.connect(dialog.close)
hbox.addStretch()
hbox.addWidget(btn)
box.addLayout(hbox)
dialog.show()
def save_sizes(self):
""" Save sizes of Splitters """
qsettings = QSettings(settings.SETTINGS_PATH, QSettings.IniFormat)
qsettings.setValue('result_splitter_query_sizes',
self.result_splitter.saveState())
qsettings.setValue('editor_splitter_query_sizes',
self._editor_splitter.saveState())
def get_editor(self):
return self._editor_widget.get_editor()
def showEvent(self, event):
super().showEvent(event)
# self.result_splitter.setSizes([1, self._result_list.width() * 0.1])
def clear_results(self):
central_widget = Pireal.get_service("central")
lateral_widget = Pireal.get_service("lateral_widget")
lateral_widget.result_list.clear_items()
table_widget = central_widget.get_active_db().table_widget
i = table_widget.stacked_result.count()
# i = self._stack_tables.count()
while i >= 0:
# widget = self._stack_tables.widget(i)
widget = table_widget.stacked_result.widget(i)
# self._stack_tables.removeWidget(widget)
table_widget.stacked_result.removeWidget(widget)
if widget is not None:
widget.deleteLater()
i -= 1
def add_table(self, rela, rname):
central_widget = Pireal.get_service("central")
lateral_widget = Pireal.get_service("lateral_widget")
db = central_widget.get_active_db()
_view = db.create_table(rela, rname, editable=False)
table_widget = central_widget.get_active_db().table_widget
index = table_widget.stacked_result.addWidget(_view)
table_widget.stacked_result.setCurrentIndex(index)
lateral_widget.result_list.add_item(
rname, rela.cardinality(), rela.degree())
# lateral_widget.result_list.select_last()
table_widget._tabs.setCurrentIndex(1)
def show_search_widget(self):
self._editor_widget.show_search_widget()
def hide_search_widget(self):
self._editor_widget.hide_search_widget()
示例3: SubTabWidget
# 需要导入模块: from PyQt5.QtWidgets import QSplitter [as 别名]
# 或者: from PyQt5.QtWidgets.QSplitter import saveState [as 别名]
#.........这里部分代码省略.........
tab.history.cleanChanged.connect(
lambda clean: self._cleanStateForFileChanged(filePath, clean))
self.pages.addWidget(tab)
return newIndex
def __drawSplitterHandle(self, index):
splitterHandle = self.splitter.handle(index)
splitterLayout = QVBoxLayout(splitterHandle)
splitterLayout.setSpacing(0)
splitterLayout.setContentsMargins(0, 0, 0, 0)
line = QFrame(splitterHandle)
line.setFrameShape(QFrame.HLine)
line.setFrameShadow(QFrame.Sunken)
splitterLayout.addWidget(line)
splitterHandle.setLayout(splitterLayout)
def _createTabName(self, name, cleanState):
if cleanState is True:
return name
else:
return "%s +" % name
def _cleanStateForFileChanged(self, filePath, cleanState):
page = self.tabByPath(filePath)
if page is not None:
for i in range(self.tabBar.count()):
if self.tabBar.tabText(i)[:len(page.name)] == page.name:
self.tabBar.setTabText(i, self._createTabName(page.name, cleanState))
return
def saveWidgetState(self, settings):
settings.setState(self.splitter, self.splitter.saveState())
settings.setHidden(self._toolbox, self._toolbox.isHidden())
def restoreWidgetState(self, settings):
self.showPanel(not settings.getHidden(self._toolbox))
splitterState = settings.getState(self.splitter)
if not splitterState.isEmpty():
self.splitter.restoreState(settings.getState(self.splitter))
@pyqtSlot(str, bool)
def openTab(self, filePath, background=False):
if self._subtitleData.fileExists(filePath):
tabIndex = self.__addTab(filePath)
if background is False:
self.showTab(tabIndex)
else:
log.error(_("SubtitleEditor not created for %s!" % filePath))
@pyqtSlot(str)
def removeFile(self, filePath):
tab = self.tabByPath(filePath)
command = RemoveFile(filePath)
if tab is not None:
index = self.pages.indexOf(tab)
if self.closeTab(index):
self._subtitleData.execute(command)
else:
self._subtitleData.execute(command)
@pyqtSlot(int)
def closeTab(self, index):
示例4: MainWindow
# 需要导入模块: from PyQt5.QtWidgets import QSplitter [as 别名]
# 或者: from PyQt5.QtWidgets.QSplitter import saveState [as 别名]
#.........这里部分代码省略.........
if Settings.contains('inspector'):
w0, w1 = Settings.value('inspector')
self.Inspector.setColumnWidth( 0, int(w0) )
self.Inspector.setColumnWidth( 1, int(w1) )
self.FieldInspector.setColumnWidth( 0, int(w0) )
self.FieldInspector.setColumnWidth( 1, int(w1) )
#self.Inspector.setColumnWidth( 2, int(w2) )
if Settings.contains('splitter'):
self.Splitter.restoreState( Settings.value('splitter') )
if Settings.contains('inssplitter'):
self.InspectorSplit.restoreState( Settings.value('inssplitter') )
#----------------------------------------------------
#
# Process command line arguments
#
if len(sys.argv) > 1:
fname = sys.argv[1]
if os.path.exists(fname):
self.CmpTable.load_file(fname)
else:
print('E: input file "' + fname + '"does not exist')
self.show()
#---------------------------------------------------------------------------
def closeEvent(self, event):
Settings = QSettings('kicad-tools', 'Schematic Component Manager')
Settings.setValue( 'geometry', self.saveGeometry() )
Settings.setValue( 'cmptable', [self.CmpTable.columnWidth(0), self.CmpTable.columnWidth(1)] )
Settings.setValue( 'selector', [self.Selector.columnWidth(0), self.Selector.columnWidth(1)] )
Settings.setValue( 'inspector', [self.Inspector.columnWidth(0), self.Inspector.columnWidth(1)] )
Settings.setValue( 'splitter', self.Splitter.saveState() )
Settings.setValue( 'inssplitter', self.InspectorSplit.saveState() )
QWidget.closeEvent(self, event)
#---------------------------------------------------------------------------
def open_file(self):
#filename = QFileDialog.getOpenFileName(self, 'Open schematic file', '/opt/cad/kicad', 'KiCad Schematic Files (*.sch)')
dialog = QFileDialog(self)
dialog.setFileMode(QFileDialog.ExistingFile)
dialog.setNameFilter('KiCad Schematic Files (*.sch)')
filenames = []
if dialog.exec_():
filenames = dialog.selectedFiles()
if len(filenames) == 0:
return
CmpMgr.set_curr_file_path( filenames[0] )
self.CmpTable.load_file( filenames[0] )
#---------------------------------------------------------------------------
def save_file(self):
self.FieldInspector.save_fields()
self.Inspector.save_cmps()
curr_file = CmpMgr.curr_file_path()
message = 'Save File "' + curr_file + '"'
print(message)
self.statusBar().showMessage(message)
CmpMgr.save_file(curr_file)
#---------------------------------------------------------------------------
def save_file_as(self):
self.Inspector.save_cmps()
self.FieldInspector.save_fields()
示例5: MainWindow
# 需要导入模块: from PyQt5.QtWidgets import QSplitter [as 别名]
# 或者: from PyQt5.QtWidgets.QSplitter import saveState [as 别名]
class MainWindow(QWidget):
def __init__(self, appConfig, projectorControl, parent=None):
self.PHOTO_DELTAS_FILE_NAME = "//MACALLAN/Photos/Photo Info/Deltas/PhotoDeltas.txt"
QWidget.__init__(self, parent)
self._projectorControl = projectorControl
# File used for delta changes to photos
self.photoDeltas = PhotoDeltas(self.PHOTO_DELTAS_FILE_NAME)
# Frameless window
self.setWindowFlags(Qt.FramelessWindowHint)
# Background to black
self.setAutoFillBackground(True)
palette = QPalette()
palette.setColor(QPalette.Background, Qt.black)
self.setPalette(palette)
# Clock
self.clock = AnimatedClock()
# Calendar
self.calendar = AnimatedCalendar(calUpdateSecs=600, calServerUrl=appConfig["calServerUrl"])
# Image
# self.photos = AnimatedPhotos("//macallan/photos/PhotosMain/", ["jpg"], maxCols=3, maxRows=4, borders=[0,0,0,0], xBetweenPics=5, yBetweenPics=5, animationSpeed=1.0, picChangeMs=5000)
self.photos = StaticPhotos("//macallan/photos/PhotosMain/", ["jpg"], self.photoDeltas, picChangeMs=5000)
#self.photos = CaptionedPhotos("//macallan/photos/PhotosMain/", ["jpg"], picChangeMs=5000)
# Toolbar
self.windowToolbar = WindowToolbar(self.close, self)
# Left pane of page
self.leftPane = QSplitter(Qt.Vertical)
self.leftPane.addWidget(self.clock)
self.leftPane.addWidget(self.calendar)
# Right pane of page
self.rightPane = QSplitter(Qt.Vertical)
self.rightPane.addWidget(self.windowToolbar)
self.rightPane.addWidget(self.photos)
# Splitter between left and right panes
self.horzSplitter = QSplitter(Qt.Horizontal)
self.horzSplitter.addWidget(self.leftPane)
self.horzSplitter.addWidget(self.rightPane)
self.layout = QHBoxLayout(self)
self.layout.addWidget(self.horzSplitter)
self.setLayout(self.layout)
# Remember the locations of the splitter bars to restore next time the program is run
settings = QSettings("PhotoCalendar")
settings.beginGroup("MainWindow")
position = settings.value("Position", QVariant(QPoint(0, 0)))
self.move(position)
size = settings.value("Size", QVariant(QSize(1920, 1200)))
self.resize(size)
if settings.value("HorzSplitter") is not None:
self.horzSplitter.restoreState(settings.value("HorzSplitter"))
#print("Restoring horz", settings.value("HorzSplitter"))
if settings.value("LeftPaneSplitter") is not None:
self.leftPane.restoreState(settings.value("LeftPaneSplitter"))
#print("Restoring left pane", settings.value("LeftPaneSplitter"))
if settings.value("RightPaneSplitter") is not None:
self.rightPane.restoreState(settings.value("RightPaneSplitter"))
#print("Restoring right pane", settings.value("RightPaneSplitter"))
settings.endGroup()
# Start rotating photos
self.photos.start()
# # Grid layout
# layout = QGridLayout()
# # layout.setContentsMargins(0,0,0,0)
# layout.setSpacing(0)
# layout.addWidget(self.clock, 0, 0)
# layout.addWidget(self.calendar, 1, 0)
# layout.addWidget(self.photos, 0, 1, 2, 1)
# layout.setColumnStretch(0, 1)
# layout.setColumnStretch(1, 2.5)
# self.setLayout(layout)
# Start photo animation
self.photos.start()
def closeEvent(self, event):
print("Main window close event")
# Save layout settings
settings = QSettings("PhotoCalendar")
settings.beginGroup("MainWindow")
curSize = self.size()
settings.setValue("Size", QVariant(curSize))
curPos = self.pos()
settings.setValue("Position", QVariant(curPos))
#settings.setValue("MainWindow/State", QVariant(self.saveState()))
horzSplitterState = self.horzSplitter.saveState()
#print("HorzSplitter save", horzSplitterState)
settings.setValue("HorzSplitter", QVariant(horzSplitterState))
leftPaneSplitterState = self.leftPane.saveState()
settings.setValue("LeftPaneSplitter", QVariant(leftPaneSplitterState))
#print("LeftPaneSplitter save", leftPaneSplitterState)
rightPaneSplitterState = self.rightPane.saveState()
settings.setValue("RightPaneSplitter", QVariant(rightPaneSplitterState))
#print("RightPaneSplitter save", leftPaneSplitterState)
settings.endGroup()
# Stop the sub-elements
self.calendar.stop()
#.........这里部分代码省略.........
示例6: QueryWidget
# 需要导入模块: from PyQt5.QtWidgets import QSplitter [as 别名]
# 或者: from PyQt5.QtWidgets.QSplitter import saveState [as 别名]
#.........这里部分代码省略.........
new_editor.setDocument(actual_doc)
new_editor.resize(900, 400)
# Set text cursor
tc = self._query_editor.textCursor()
new_editor.setTextCursor(tc)
# Set title
db = Pireal.get_service("central").get_active_db()
qc = db.query_container
new_editor.setWindowTitle(qc.tab_text(qc.current_index()))
new_editor.show()
def __on_undo_available(self, value):
""" Change state of undo action """
pireal = Pireal.get_service("pireal")
action = pireal.get_action("undo_action")
action.setEnabled(value)
def __on_redo_available(self, value):
""" Change state of redo action """
pireal = Pireal.get_service("pireal")
action = pireal.get_action("redo_action")
action.setEnabled(value)
def __on_copy_available(self, value):
""" Change states of cut and copy action """
cut_action = Pireal.get_action("cut_action")
cut_action.setEnabled(value)
copy_action = Pireal.get_action("copy_action")
copy_action.setEnabled(value)
def show_relation(self, item):
central_widget = Pireal.get_service("central")
table_widget = central_widget.get_active_db().table_widget
rela = self.relations[item.name]
dialog = QDialog(self)
dialog.resize(700, 500)
dialog.setWindowTitle(item.name)
box = QVBoxLayout(dialog)
box.setContentsMargins(5, 5, 5, 5)
table = table_widget.create_table(rela)
box.addWidget(table)
hbox = QHBoxLayout()
btn = QPushButton(self.tr("Ok"))
btn.clicked.connect(dialog.close)
hbox.addStretch()
hbox.addWidget(btn)
box.addLayout(hbox)
dialog.show()
def save_sizes(self):
""" Save sizes of Splitters """
qsettings = QSettings(settings.SETTINGS_PATH, QSettings.IniFormat)
qsettings.setValue('hsplitter_query_sizes',
self._hsplitter.saveState())
qsettings.setValue('vsplitter_query_sizes',
self._vsplitter.saveState())
def get_editor(self):
return self._query_editor
def __editor_modified(self, modified):
self.editorModified.emit(modified)
def showEvent(self, event):
super(QueryWidget, self).showEvent(event)
self._hsplitter.setSizes([1, self.width() / 3])
def clear_results(self):
self._result_list.clear_items()
i = self._stack_tables.count()
while i >= 0:
widget = self._stack_tables.widget(i)
self._stack_tables.removeWidget(widget)
if widget is not None:
widget.deleteLater()
i -= 1
def add_table(self, rela, rname):
wtable = custom_table.Table()
# Model
model = QStandardItemModel()
wtable.setModel(model)
model.setHorizontalHeaderLabels(rela.header)
for data in rela.content:
nrow = model.rowCount()
# wtable.insertRow(nrow)
for col, text in enumerate(data):
item = QStandardItem(text)
item.setFlags(item.flags() & ~Qt.ItemIsEditable)
model.setItem(nrow, col, item)
index = self._stack_tables.addWidget(wtable)
self._stack_tables.setCurrentIndex(index)
self._result_list.add_item(rname, rela.count())
示例7: MainForm
# 需要导入模块: from PyQt5.QtWidgets import QSplitter [as 别名]
# 或者: from PyQt5.QtWidgets.QSplitter import saveState [as 别名]
#.........这里部分代码省略.........
def hideOrClose(self):
if self.settings['quit']:
self.close()
else:
self.hide()
def closeEvent(self, event):
self.saveSettings()
def hideEvent(self, event):
self.releaseMouse()
self.saveSettings()
def mouseMoveEvent(self, event):
if self.hasMouse():
self.releaseMouse()
def leaveEvent(self, event):
# If we set holdOpen, it means that we've opened a dialog, so we shouldn't grab
if not self.hasMouse():
self.grabMouse()
def mousePressEvent(self, event):
if not self.hasMouse():
self.hideOrClose()
def hasMouse(self):
return self.geometry().contains(QCursor.pos())
def saveSettings(self):
self.settings['splitterState'] = self.listSplitter.saveState()
self.settings['width'] = self.width()
self.settings['height'] = self.height()
with open(self.settingsFile, 'wb') as f:
cPickle.dump(self.settings, f)
def place(self):
desktop = qApp.desktop()
screenSize = desktop.availableGeometry(QCursor.pos())
self.move(screenSize.x(), screenSize.y() + screenSize.height() - self.height())
def newClicked(self):
form = AddForm()
self.holdOpen = True
form.exec_()
self.checkMouse()
self.holdOpen = False
if form.accepted:
item = MenuItem()
item.name = form.name
item.command = form.command
item.working = form.working
item.folder = form.folder
item.icon = form.icon
item.findIcon()
clicked = self.getClicked()
if clicked:
parent = clicked.item.parent
elif self.leftList.mouseOver:
示例8: DatabaseContainer
# 需要导入模块: from PyQt5.QtWidgets import QSplitter [as 别名]
# 或者: from PyQt5.QtWidgets.QSplitter import saveState [as 别名]
#.........这里部分代码省略.........
def __on_data_table_changed(self, row, col, data):
current_relation = self.lateral_widget.current_text()
# Relation to be update
rela = self.table_widget.relations.get(current_relation)
# Clear old content
rela.clear()
current_table = self.table_widget.stacked.currentWidget()
model = current_table.model()
for i in range(model.rowCount()):
reg = []
for j in range(model.columnCount()):
if row == i and col == j:
reg.append(data)
else:
reg.append(model.item(i, j).text())
# Insert new content
rela.insert(reg)
# Update relation
self.table_widget.relations[current_relation] = rela
def new_query(self, filename):
editor_tab_at = self.query_container.is_open(filename)
if editor_tab_at != -1:
self.query_container.set_focus_editor_tab(editor_tab_at)
else:
query_widget = query_container.QueryWidget()
# Create object file
ffile = pfile.File(filename)
editor = query_widget.get_editor()
editor.pfile = ffile
if not filename:
ffile.filename = 'untitled_{n}.pqf'.format(n=self.__nquery)
else:
content = ffile.read()
editor.setPlainText(content)
self.query_container.add_tab(query_widget, ffile.display_name)
self.__nquery += 1
def save_query(self, editor):
if not editor:
editor = self.query_container.currentWidget().get_editor()
if editor.is_new:
return self.save_query_as(editor)
# Get content of editor
content = editor.toPlainText()
try:
editor.pfile.save(content=content)
except Exception as reason:
QMessageBox.critical(self, "Error",
self.tr("The file couldn't be saved!"
"\n\n{}".format(reason)))
return False
editor.saved()
return editor.pfile.filename
def save_query_as(self, editor=None):
filename = QFileDialog.getSaveFileName(self, self.tr("Save File"),
editor.name,
"Pireal query files(*.pqf)")
filename = filename[0]
if not filename:
return
# Get the content
content = editor.toPlainText()
# Write the file
editor.pfile.save(content=content, new_fname=filename)
editor.saved()
def execute_queries(self):
self.query_container.execute_queries()
def execute_selection(self):
editor = self.query_container.currentWidget().get_editor()
text_cursor = editor.textCursor()
if text_cursor.hasSelection():
query = text_cursor.selectedText()
self.query_container.execute_queries(query)
def showEvent(self, event):
QSplitter.showEvent(self, event)
qsettings = QSettings(settings.SETTINGS_PATH, QSettings.IniFormat)
hsizes = qsettings.value('hsplitter_sizes', None)
if hsizes is not None:
self._hsplitter.restoreState(hsizes)
else:
self._hsplitter.setSizes([1, self._hsplitter.width() / 3])
vsizes = qsettings.value('vsplitter_sizes', None)
if vsizes is not None:
self.restoreState(vsizes)
else:
self.setSizes([self.height() / 3, self.height() / 3])
def save_sizes(self):
""" Save sizes of Splitters """
qsettings = QSettings(settings.SETTINGS_PATH, QSettings.IniFormat)
qsettings.setValue('hsplitter_sizes',
self._hsplitter.saveState())
qsettings.setValue('vsplitter_sizes',
self.saveState())