def __init__(self, parent, sid = None, systray = False): if systray: super(LogViewDialog, self).__init__() else: super(LogViewDialog, self).__init__(parent) self.config = parent.config self.snapshots = parent.snapshots self.mainWindow = parent self.sid = sid self.enableUpdate = False self.decode = None w = self.config.intValue('qt.logview.width', 800) h = self.config.intValue('qt.logview.height', 500) self.resize(w, h) import icon self.setWindowIcon(icon.VIEW_SNAPSHOT_LOG) if self.sid is None: self.setWindowTitle(_('Last Log View')) else: self.setWindowTitle(_('Snapshot Log View')) self.mainLayout = QVBoxLayout(self) layout = QHBoxLayout() self.mainLayout.addLayout(layout) #profiles self.lblProfile = QLabel(_('Profile:'), self) layout.addWidget(self.lblProfile) self.comboProfiles = qttools.ProfileCombo(self) layout.addWidget(self.comboProfiles, 1) self.comboProfiles.currentIndexChanged.connect(self.profileChanged) #snapshots self.lblSnapshots = QLabel(_('Snapshots') + ':', self) layout.addWidget(self.lblSnapshots) self.comboSnapshots = qttools.SnapshotCombo(self) layout.addWidget(self.comboSnapshots, 1) self.comboSnapshots.currentIndexChanged.connect(self.comboSnapshotsChanged) if self.sid is None: self.lblSnapshots.hide() self.comboSnapshots.hide() if self.sid or systray: self.lblProfile.hide() self.comboProfiles.hide() #filter layout.addWidget(QLabel(_('Filter:'))) self.comboFilter = QComboBox(self) layout.addWidget(self.comboFilter, 1) self.comboFilter.currentIndexChanged.connect(self.comboFilterChanged) self.comboFilter.addItem(_('All'), 0) self.comboFilter.addItem(' + '.join((_('Errors'), _('Changes'))), 4) self.comboFilter.setCurrentIndex(self.comboFilter.count() - 1) self.comboFilter.addItem(_('Errors'), 1) self.comboFilter.addItem(_('Changes'), 2) self.comboFilter.addItem(_('Informations'), 3) #text view self.txtLogView = QPlainTextEdit(self) self.txtLogView.setFont(QFont('Monospace')) self.txtLogView.setReadOnly(True) self.txtLogView.setLineWrapMode(QPlainTextEdit.NoWrap) self.mainLayout.addWidget(self.txtLogView) # self.mainLayout.addWidget(QLabel(_('[E] Error, [I] Information, [C] Change'))) #decode path self.cbDecode = QCheckBox(_('decode paths'), self) self.cbDecode.stateChanged.connect(self.cbDecodeChanged) self.mainLayout.addWidget(self.cbDecode) #buttons buttonBox = QDialogButtonBox(QDialogButtonBox.Close) self.mainLayout.addWidget(buttonBox) buttonBox.rejected.connect(self.close) self.updateSnapshots() self.updateDecode() self.updateProfiles() # watch for changes in log file self.watcher = QFileSystemWatcher(self) if self.sid is None: # only watch if we show the last log log = self.config.takeSnapshotLogFile(self.comboProfiles.currentProfileID()) self.watcher.addPath(log) self.watcher.fileChanged.connect(self.updateLog) self.txtLogView.setContextMenuPolicy(Qt.CustomContextMenu) self.txtLogView.customContextMenuRequested.connect(self.contextMenuClicked)
def __init__(self, parent, sid, path): super(SnapshotsDialog, self).__init__(parent) self.parent = parent self.config = parent.config self.snapshots = parent.snapshots self.snapshotsList = parent.snapshotsList self.qapp = parent.qapp import icon self.sid = sid self.path = path self.setWindowIcon(icon.SNAPSHOTS) self.setWindowTitle(_('Snapshots')) self.mainLayout = QVBoxLayout(self) #path self.editPath = QLineEdit(self.path, self) self.editPath.setReadOnly(True) self.mainLayout.addWidget(self.editPath) #list different snapshots only self.cbOnlyDifferentSnapshots = QCheckBox( _('List only different snapshots'), self) self.mainLayout.addWidget(self.cbOnlyDifferentSnapshots) self.cbOnlyDifferentSnapshots.stateChanged.connect( self.cbOnlyDifferentSnapshotsChanged) #list equal snapshots only layout = QHBoxLayout() self.mainLayout.addLayout(layout) self.cbOnlyEqualSnapshots = QCheckBox( _('List only equal snapshots to: '), self) self.cbOnlyEqualSnapshots.stateChanged.connect( self.cbOnlyEqualSnapshotsChanged) layout.addWidget(self.cbOnlyEqualSnapshots) self.comboEqualTo = qttools.SnapshotCombo(self) self.comboEqualTo.currentIndexChanged.connect(self.comboEqualToChanged) self.comboEqualTo.setEnabled(False) layout.addWidget(self.comboEqualTo) #deep check self.cbDeepCheck = QCheckBox(_('Deep check (more accurate, but slow)'), self) self.mainLayout.addWidget(self.cbDeepCheck) self.cbDeepCheck.stateChanged.connect(self.cbDeepCheckChanged) #toolbar self.toolbar = QToolBar(self) self.toolbar.setFloatable(False) self.mainLayout.addWidget(self.toolbar) #toolbar restore menuRestore = QMenu(self) action = menuRestore.addAction(icon.RESTORE, _('Restore')) action.triggered.connect(self.restoreThis) action = menuRestore.addAction(icon.RESTORE_TO, _('Restore to ...')) action.triggered.connect(self.restoreThisTo) self.btnRestore = self.toolbar.addAction(icon.RESTORE, _('Restore')) self.btnRestore.setMenu(menuRestore) self.btnRestore.triggered.connect(self.restoreThis) #btn delete self.btnDelete = self.toolbar.addAction(icon.DELETE_FILE, _('Delete')) self.btnDelete.triggered.connect(self.btnDeleteClicked) #btn select_all self.btnSelectAll = self.toolbar.addAction(icon.SELECT_ALL, _('Select All')) self.btnSelectAll.triggered.connect(self.btnSelectAllClicked) #snapshots list self.timeLine = qttools.TimeLine(self) self.mainLayout.addWidget(self.timeLine) self.timeLine.itemSelectionChanged.connect(self.timeLineChanged) self.timeLine.itemActivated.connect(self.timeLineExecute) #diff layout = QHBoxLayout() self.mainLayout.addLayout(layout) self.btnDiff = QPushButton(_('Diff'), self) layout.addWidget(self.btnDiff) self.btnDiff.clicked.connect(self.btnDiffClicked) self.comboDiff = qttools.SnapshotCombo(self) layout.addWidget(self.comboDiff, 2) #buttons buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) self.btnGoto = buttonBox.button(QDialogButtonBox.Ok) self.btnCancel = buttonBox.button(QDialogButtonBox.Cancel) self.btnGoto.setText(_('Go To')) btnDiffOptions = buttonBox.addButton(_('Diff Options'), QDialogButtonBox.HelpRole) btnDiffOptions.setIcon(icon.DIFF_OPTIONS) self.mainLayout.addWidget(buttonBox) buttonBox.accepted.connect(self.accept) buttonBox.rejected.connect(self.reject) btnDiffOptions.clicked.connect(self.btnDiffOptionsClicked) # self.cbDeepCheck.setEnabled(False) full_path = self.sid.pathBackup(self.path) if os.path.islink(full_path): self.cbDeepCheck.hide() elif os.path.isdir(full_path): self.cbOnlyDifferentSnapshots.hide() self.cbOnlyEqualSnapshots.hide() self.comboEqualTo.hide() self.cbDeepCheck.hide() #update list and combobox self.UpdateSnapshotsAndComboEqualTo()