def icon(self, act):
     settings = QSettings()
     iconSet = settings.value("toolbar/iconset", QtReduceDefaults.ICONSET)
     iconSize = settings.value("toolbar/iconsize",
                               QtReduceDefaults.ICONSIZE)
     if iconSet:
         iEntry = self.db[iconSet]
         text = act.iconText()
         entry = None
         if text in iEntry.keys():
             entry = iEntry[text]
         path = ''
         if entry:
             path = sys.path[0] + "/icons/" + iconSet + "/"
             if iEntry["sized"]:
                 path += str(iconSize) + "/"
             path += entry
             traceLogger.debug("iconPath=%s" % path)
         return QIcon(path)
     else:
         if mEntry == "open":
             return self.style().standardIcon(QStyle.SP_DialogOpenButton)
         elif mEntry == "save":
             return self.style().standardIcon(QStyle.SP_DialogSaveButton)
         elif mEntry == "abort":
             return self.style().standardIcon(QStyle.SP_BrowserStop)
         else:
             return QIcon('')
Example #2
0
 def __init__(self,reduce='../../bin/redcsl'):
     traceLogger.debug("######### reduce is %s", reduce)
     super(Reduce,self).__init__()
     self.__process = procNew(sys.path[0] + "/" + reduce)
     self.__processId = self.__process['processId']
     self.__process = self.__process['handle']
     self.__mutex = QMutex()
Example #3
0
 def compute(self,row,count=1):
     traceLogger.debug("row=%d, count=%d" % (row, count))
     for i in range(row,row+count):
         computation = self.data(self.index(i,0),QtReduceModel.RawDataRole)
         signalLogger.debug("Emmitting %s" % computation.command)
         #self.startComputation.emit(computation)
         self.reduce.compute(computation)
Example #4
0
 def compute1(self,c):
     self.wait()
     traceLogger.debug("after wait, %s"% c)
     self.computation = c
     self.computation.status = QtReduceComputation.Evaluating
     self.startedComputations.append(self.computation)
     self.start()
Example #5
0
 def icon(self, act):
     settings = QSettings()
     iconSet = settings.value("toolbar/iconset",QtReduceDefaults.ICONSET)
     iconSize = settings.value("toolbar/iconsize",
                                  QtReduceDefaults.ICONSIZE)
     if iconSet:
         iEntry = self.db[iconSet]
         text = act.iconText()
         entry = None
         if text in iEntry.keys():
             entry = iEntry[text]
         path = ''
         if entry:
             path = sys.path[0] + "/icons/" + iconSet + "/"
             if iEntry["sized"]:
                 path += str(iconSize) + "/"
             path += entry
             traceLogger.debug("iconPath=%s" % path)
         return QIcon(path)
     else:
         if mEntry == "open":
             return self.style().standardIcon(QStyle.SP_DialogOpenButton)
         elif mEntry == "save":
             return self.style().standardIcon(QStyle.SP_DialogSaveButton)
         elif mEntry == "abort":
             return self.style().standardIcon(QStyle.SP_BrowserStop)
         else:
             return QIcon('')
Example #6
0
 def setTitle(self,fullPath):
     traceLogger.debug("fullPath=%s" % fullPath)
     if fullPath is '':
         self.setWindowTitle("[*]" + self.tr("Untitled"))
     else:
         info = QFileInfo(fullPath)
         self.setWindowFilePath(info.absolutePath())
         self.setWindowTitle("[*]" + info.fileName())
Example #7
0
 def __setWidthByFont(self,n,adaptHeight=False):
     oldWidth = self.width()
     width = n * self.controller.view.fontMetrics().width('m')
     traceLogger.debug("width=%s, n=%s, family=%s, size=%s" %
                       (width,n,self.controller.view.font().family(),
                        self.controller.view.font().pointSize()))
     self.setFixedWidth(width)
     if adaptHeight:
         factor = float(self.width())/float(oldWidth)
         self.resize(1,int(self.height()*factor))
 def renderResult(self,result):
     traceLogger.debug("result=%s" % result)
     if result.strip("\\0123456789 ") == '':
         return result.replace('\\ ','\\\n')
     command = "qr_render(" + result.rstrip("$") + ");"
     answer = self.model.reduce.reduce.compute(command)
     rendered = answer['pretext']
     if rendered:
         rendered = rendered.strip("\n")
     traceLogger.debug("rendered=%s" % rendered)
     return rendered
Example #9
0
 def abortComputation(self):
     traceLogger.debug("entering")
     if self.queue:
         self.reduce.signal("SIGSTOP")
         ans = self.__abortComputationBox()
         self.reduce.signal("SIGCONT")
         if ans == 'cancel':
             return
         if ans == 'all':
             self.queue = []
     self.computation.status = QtReduceComputation.Aborted
     self.reduce.signal("SIGINT")
Example #10
0
 def setupFont(self,size=None,step=1):
     traceLogger.debug("size=%s, step=%s" % (size,step))
     if not size:
         size = self.font().pointSize()
     font = self.font()
     font.setFamily(QSettings().value("worksheet/fontfamily",
                                      QtReduceDefaults.FONTFAMILY))
     font.setFixedPitch(True)
     font.setKerning(0)
     font.setWeight(QFont.Normal)
     font.setItalic(False)
     font.setPointSize(self.__nextGoodFontSize(font,size,step))
     self.setFont(font)
Example #11
0
 def saveAs(self):
     title = self.tr("Save Reduce Worksheet")
     path = os.path.dirname(os.path.abspath(self.controller.fileName().__str__()))
     filter = self.tr("Reduce Worksheets (*.rws)")
     fileName = QFileDialog.getSaveFileName(self,title,path,filter)
     fileName = str(fileName[0])
     traceLogger.debug("fileName=%s" % fileName)
     if fileName == '':
         return
     if not fileName.endswith(".rws"):
         fileName += ".rws"
     self.controller.saveAs(fileName)
     self.activateWindow()
Example #12
0
 def setupFont(self, size=None, step=1):
     traceLogger.debug("size=%s, step=%s" % (size, step))
     if not size:
         size = self.font().pointSize()
     font = self.font()
     font.setFamily(QSettings().value("worksheet/fontfamily",
                                      QtReduceDefaults.FONTFAMILY))
     font.setFixedPitch(True)
     font.setKerning(0)
     font.setWeight(QFont.Normal)
     font.setItalic(False)
     font.setPointSize(self.__nextGoodFontSize(font, size, step))
     self.setFont(font)
Example #13
0
 def __textToToolButtonStyle(self,show):
     traceLogger.debug("show=%s,('%s', '%s', '%s')" %
                       (show,
                        self.tr("Symbol and Text"),
                        self.tr("Only Symbol"),
                        self.tr("Only Text")))
     if show == self.tr("Symbol and Text"):
         return Qt.ToolButtonTextUnderIcon
     if show == self.tr("Only Symbol"):
         return Qt.ToolButtonIconOnly
     if show == self.tr("Only Text"):
         return Qt.ToolButtonTextOnly
     traceLogger.warning("unknown tool button style '%s'" % show)
     return Qt.ToolButtonTextUnderIcon
    def __init__(self,parent=None):
        super(QtReducePreferencesToolBar,self).__init__(parent)

        settings = QSettings()

        toolBarGroup = QGroupBox(self.tr("Toolbar"))

        self.iconSetCombo = QtReduceComboBox()
        iDbKeys = QtReduceIconSets().db.keys()
        iDbKeys.sort()
        self.iconSetCombo.addItems(iDbKeys)

        settings.setValue("toolbar/iconset","Oxygen") # Hack

        traceLogger.debug("toolbar/iconset=%s" % settings.value("toolbar/iconset"))

        self.iconSetCombo.setCurrentIndex(
            self.iconSetCombo.findText(
                settings.value("toolbar/iconset",QtReduceDefaults.ICONSET)))

        self.iconSizeCombo = QtReduceIconSizeComboBox()
        self.iconSizeCombo.addItems(["16","22","32"])
        self.iconSizeCombo.setCurrentIndex(
            self.iconSizeCombo.findText(
                str(settings.value("toolbar/iconsize",
                                   QtReduceDefaults.ICONSIZE))))

        self.showCombo = QtReduceComboBox()
        self.showCombo.addItems([self.tr("Symbol and Text"),
                                 self.tr("Only Symbol"),
                                 self.tr("Only Text")])
        self.showCombo.setCurrentIndex(self.showCombo.findText(
            settings.value("toolbar/buttonstyle",
                           self.tr(QtReduceDefaults.BUTTONSTYLE))))

        toolBarLayout = QFormLayout()
#        toolBarLayout.addRow(self.tr("Symbol Set"),self.iconSetCombo)
        toolBarLayout.addRow(self.tr("Symbol Size"),self.iconSizeCombo)
        toolBarLayout.addRow(self.tr("Show"),self.showCombo)

        toolBarGroup.setLayout(toolBarLayout)

        mainLayout = QVBoxLayout()
        mainLayout.addWidget(toolBarGroup)

        self.setLayout(mainLayout)
Example #15
0
    def __init__(self,parent=None):
        super(QtReduceToolBar,self).__init__(parent)

        buttonStyle = QSettings().value("toolbar/buttonstyle",
                                        self.tr(QtReduceDefaults.BUTTONSTYLE))
        self.setToolButtonStyleByText(buttonStyle)

        iconSize = QSettings().value("toolbar/iconsize",
                                     QtReduceDefaults.ICONSIZE)
        traceLogger.debug("2######### QtReduceDefaults.ICONSIZE is %s", QtReduceDefaults.ICONSIZE)
        traceLogger.debug("2######### iconSize is %s", iconSize)
        self.setIconSize(QSize(int(iconSize),int(iconSize)))

        self.setContextMenuPolicy(Qt.CustomContextMenu)
        self.customContextMenuRequested.connect(self.contextMenu)

        self.setVisible(True)
Example #16
0
 def open(self):
     ok = self.__suggestSave()
     if not ok:
         return
     title = self.tr("Open Reduce Worksheet")
     fn = self.controller.fileName().__str__()
     if fn == '':
         fn = '$HOME'
     path = os.path.dirname(os.path.abspath(fn))
     traceLogger.debug("path=%s" % path)
     filter = self.tr("Reduce Worksheets (*.rws);;All Files (*.*)")
     fileName = QFileDialog.getOpenFileName(self,title,path,filter)
     fileName = str(fileName[0])
     traceLogger.debug("fileName=%s" % fileName)
     if fileName is '':
         return
     if not fileName.endswith(".rws"):
         fileName += ".rws"
     return self.controller.open(fileName)
Example #17
0
 def __init__(self,parent=None):
     QStatusBar.__init__(self,parent)
     self.symbolic = None
     font = self.font()
     traceLogger.debug(font.pointSize())
     if os.uname()[0] == "Darwin":
         font.setPointSize(font.pointSize() - 2)
     self.setFont(font)
     self.reduceMode = QLabel()
     self.reduceMode.setFixedWidth(
         QFontMetrics(font).width(self.tr("Mode: Algebraic")))
     self.reduceMode.setFont(font)
     self.reduceTime = QLabel()
     self.reduceTime.setFont(font)
     self.reduceStatus = QLabel()
     self.reduceStatus.setFont(font)
     self.addPermanentWidget(self.reduceMode)
     self.addPermanentWidget(self.reduceTime)
     self.addWidget(self.reduceStatus)
     self.reduceStatus.setText(self.tr("Initializing ..."))
Example #18
0
 def pruneSelection(self):
     cursor = self.textCursor()
     if not cursor.hasSelection():
         return
     if cursor.hasComplexSelection():
         cursor.clearSelection()
         self.setTextCursor(cursor)
         return
     s = cursor.selectionStart()
     e = cursor.selectionEnd()
     sp = self.__positionPair(s)
     ep = self.__positionPair(e)
     traceLogger.debug("start=%d in %s, end=%d in %s" % (s,sp,e,ep))
     if sp == ep:
         return
     c = cursor.position()
     cp = self.__positionPair(c)
     traceLogger.debug("cursor=%d in %s" % (c,cp))
     cursor.clearSelection()
     self.setTextCursor(cursor)
     return
Example #19
0
 def pruneSelection(self):
     cursor = self.textCursor()
     if not cursor.hasSelection():
         return
     if cursor.hasComplexSelection():
         cursor.clearSelection()
         self.setTextCursor(cursor)
         return
     s = cursor.selectionStart()
     e = cursor.selectionEnd()
     sp = self.__positionPair(s)
     ep = self.__positionPair(e)
     traceLogger.debug("start=%d in %s, end=%d in %s" % (s, sp, e, ep))
     if sp == ep:
         return
     c = cursor.position()
     cp = self.__positionPair(c)
     traceLogger.debug("cursor=%d in %s" % (c, cp))
     cursor.clearSelection()
     self.setTextCursor(cursor)
     return
Example #20
0
    def __init__(self, parent=None):
        super(QtReduceMainWindow, self).__init__(parent)
        iconSize = QSettings().value("toolbar/iconsize", QtReduceDefaults.ICONSIZE)
        traceLogger.debug("0######### QtReduceDefaults.ICONSIZE is %s", QtReduceDefaults.ICONSIZE)
        traceLogger.debug("0######### iconSize is %s", iconSize)
        hugo = QSettings().value("toolbar/hugo", QtReduceDefaults.ICONSIZE)
        traceLogger.debug("0######### hugo is %s", hugo)

        if os.uname()[0] != "Darwin":  # For the Mac the icon is set for the app in qreduce.py.
            self.setWindowIcon(QIcon(sys.path[0] + "/" + "Bumblebee.png"))
        self.setUnifiedTitleAndToolBarOnMac(True)
        self.controller = QtReduceController(self)
        self.setCentralWidget(self.controller.view)
        self.__createPreferences()
        self.__initTitleBar()
        self.__createStatusBar()
        self.recentFileMenu = QtRecentFileMenu(self)
        self.controller.fileNameChanged.connect(self.recentFileMenu.addFile)
        self.__createActions()
        self.__createMenus()
        self.__createToolBar()
        self.__resizeByFont(QtReduceDefaults.WIDTH, QtReduceDefaults.HEIGHT)
        self.raise_()
        self.show()
        self.rawModelView = QtReduceTableView(self)
        self.rawModelView.setModel(self.controller.model)
 def setCell(self,row,computation):
     self.view.setCell(row,
                       computation.c1,
                       computation.command,
                       computation.c2,
                       computation.result,
                       computation.c3)
     s = computation.status
     if s == QtReduceComputation.NotEvaluated:
         self.view.setNotEvaluated(row)
     elif s == QtReduceComputation.Evaluated:
         if computation.result:
             result = computation.result
             if not computation.symbolic:
                 result = self.renderResult(result)
             self.view.setResult(row,result)
         else:
             self.view.setNoResult(row)
     elif s == QtReduceComputation.Error:
         self.view.setError(row,computation.errorText)
     elif s == QtReduceComputation.Aborted:
         self.view.setAborted(row)
     else:
         traceLogger.debug("Bad status: %d" % s)
 def rowsRemovedM(self,parent,start,end):
     traceLogger.debug("start=%d, end=%d" % (start, end))
     self.view.removeRows(start,end)
 def rowsInsertedM(self,parent,start,end):
     traceLogger.debug("start=%d, end=%d" % (start, end))
     self.view.insertRows(start,end)
Example #24
0
 def currentSizeChangedHandlerFs(self, newSize, fullScreen):
     newSize = int(newSize)
     traceLogger.debug("newSize=%s (%s)" % (newSize, type(newSize)))
     QSettings().setValue("worksheet/fontsizefs", newSize)
     if fullScreen:
         self.setupFont(newSize)
Example #25
0
 def run(self):
     traceLogger.debug("entering")
     c = self.computation.command
     traceLogger.debug("computing %s" % c)
     a = self.reduce.compute(c)
     traceLogger.debug("answer is %s" % a)
     self.computation.processAnswer(a,self.accTime,self.accGcTime)
     self.accTime = self.computation.accTime
     self.accGcTime = self.computation.accGcTime
     traceLogger.debug("processed computation is %s" % self.computation)
     self.finishedComputations.append(self.computation)
     traceLogger.debug("appended to finishedComputations")
     if self.computation.status == QtReduceComputation.Error:
         a = self.reduce.compute(" 0.0.")
         traceLogger.debug("error recovery %s" % a)
     traceLogger.debug("leaving")
Example #26
0
 def currentSizeChangedHandlerFs(self,newSize,fullScreen):
     newSize = int(newSize)
     traceLogger.debug("newSize=%s (%s)" % (newSize,type(newSize)))
     QSettings().setValue("worksheet/fontsizefs",newSize)
     if fullScreen:
         self.setupFont(newSize)
Example #27
0
 def addComputation(self,computation):
     traceLogger.debug("%s" % computation)
     self.insertRow(self.rowCount(QModelIndex()),QModelIndex())
     self.model[-1] = computation