Пример #1
0
 def create(self, parent):
     nam = QNetworkAccessManager(parent)
     diskCache = QNetworkDiskCache(nam)
     cachePath = QStandardPaths.displayName(QStandardPaths.CacheLocation)
     print "cache path:", cachePath
     diskCache.setCacheDirectory(cachePath)
     diskCache.setMaximumCacheSize(100 * 1024 * 1024)  # 设置100M缓存
     nam.setCache(diskCache)
     return nam
Пример #2
0
 def displayName(location):
     return _QStandardPaths.displayName(location)
Пример #3
0
    def __init__(self):
        super().__init__()

        self.ui = core_gui.Ui_MainWindow()
        self.ui.setupUi(self)

        self.notepad_icon = QIcon('.\\icon.png')
        self.setWindowIcon(self.notepad_icon)

        self.last_path = QStandardPaths.displayName(
            QStandardPaths.DesktopLocation)
        self.zoom_amnt = 0

        # Opened file data
        self.opened_filepath = 'Untitled'
        self.changes_made = False

        # Text changing bindings
        self.ui.textField.textChanged.connect(lambda: self.set_changes_made())
        self.ui.textField.textChanged.connect(
            lambda: self.disable_empty_text_dependent())
        self.ui.textField.selectionChanged.connect(
            lambda: self.disable_selection_dependent())

        self.disable_empty_text_dependent()
        self.disable_selection_dependent()

        # File menu tab bindings
        self.ui.actionNew.triggered.connect(lambda: self.file_new_pressed())
        self.ui.actionOpen.triggered.connect(lambda: self.file_open_pressed())
        self.ui.actionSave.triggered.connect(lambda: self.file_save_pressed())
        self.ui.actionSave_as.triggered.connect(
            lambda: self.file_save_as_pressed())
        self.ui.actionFinish.triggered.connect(
            lambda: self.file_finish_pressed())

        # Edit menu tab bindings
        self.ui.actionUndo.triggered.connect(lambda: self.ui.textField.undo())
        self.ui.actionRedo.triggered.connect(lambda: self.ui.textField.redo())
        self.ui.actionCut.triggered.connect(lambda: self.ui.textField.cut())
        self.ui.actionCopy.triggered.connect(lambda: self.ui.textField.copy())
        self.ui.actionPaste.triggered.connect(
            lambda: self.ui.textField.paste())
        self.ui.actionDelete.triggered.connect(
            lambda: self.ui.textField.textCursor().removeSelectedText())
        self.ui.actionFind.triggered.connect(lambda: self.edit_find())

        self.find_memory = FindMemory(self)
        self.ui.actionFind_next.triggered.connect(
            lambda: self.find_memory.find_next_pressed())
        self.ui.actionFind_previous.triggered.connect(
            lambda: self.find_memory.find_previous_pressed())

        self.ui.actionReplace.triggered.connect(lambda: self.edit_replace())
        self.ui.actionGo_to.triggered.connect(lambda: self.edit_go_to())

        self.ui.actionGo_to.setDisabled(True)
        self.ui.actionSearch_in_Google.triggered.connect(
            lambda: self.edit_search_with_google())
        self.ui.actionSelect_all.triggered.connect(
            lambda: self.ui.textField.selectAll())
        self.ui.actionTime_date.triggered.connect(
            lambda: self.edit_time_date())

        # Format menu tab bindings
        self.ui.actionWord_wrap.setChecked(True)
        self.ui.actionWord_wrap.triggered.connect(
            lambda: self.format_word_wrap())
        self.ui.actionFont.triggered.connect(lambda: self.format_font())

        # View menu tab bindings
        self.ui.actionZoom_in.triggered.connect(lambda: self.zoom_in())
        self.ui.actionZoom_out.triggered.connect(lambda: self.zoom_out())
        self.ui.actionRestore_default_zoom.triggered.connect(
            lambda: self.restore_zoom())
        self.ui.actionStatus_bar.setChecked(True)
        self.ui.actionStatus_bar.triggered.connect(
            lambda: self.hide_show_status_bar())

        # Help menu tab bindings
        self.ui.actionShow_help.triggered.connect(
            lambda: self.help_show_help_pressed())
        self.ui.actionSend_feedback.triggered.connect(
            lambda: self.help_send_feedback_pressed())
        self.ui.actionNotepad_info.triggered.connect(
            lambda: self.help_about_pressed())