53fe0d34 pyros2097

13 years ago
v0.52 #Added - font support done - threshold done - emulator or device done
Files changed (7) hide show
  1. Widget/dialogs.py +24 -1
  2. Widget/editor.py +6 -4
  3. Widget/editor.pyc +0 -0
  4. config.py +10 -5
  5. config.yaml +2 -1
  6. globals.py +5 -4
  7. window.py +38 -14
Widget/dialogs.py CHANGED
@@ -1,6 +1,6 @@
1
1
  from PyQt4 import QtGui
2
2
  from PyQt4 import QtCore
3
- from globals import adblist,config
3
+ from globals import adblist,config,device
4
4
  """
5
5
  class UIProject(QDialog):
6
6
  def __init__(self, parentWindow):
@@ -28,14 +28,22 @@ class DialogAndroid(QtGui.QDialog):
28
28
  self.horizontalLayoutWidget.setObjectName(("horizontalLayoutWidget"))
29
29
  self.horizontalLayout = QtGui.QHBoxLayout(self.horizontalLayoutWidget)
30
30
  self.horizontalLayout.setMargin(0)
31
+
32
+
33
+
34
+
31
35
  self.horizontalLayout.setObjectName(("horizontalLayout"))
32
36
  self.tabWidget = QtGui.QTabWidget(self.horizontalLayoutWidget)
33
37
  self.tabWidget.setObjectName(("tabWidget"))
34
38
  self.tab_4 = QtGui.QWidget()
35
39
  self.tab_4.setObjectName(("tab_4"))
40
+
41
+
36
42
  self.formLayoutWidget = QtGui.QWidget(self.tab_4)
37
43
  self.formLayoutWidget.setGeometry(QtCore.QRect(10, 10, 361, 311))
38
44
  self.formLayoutWidget.setObjectName(("formLayoutWidget"))
45
+
46
+
39
47
  self.formLayout = QtGui.QFormLayout(self.formLayoutWidget)
40
48
  self.formLayout.setMargin(0)
41
49
  self.formLayout.setObjectName(("formLayout"))
@@ -68,7 +76,17 @@ class DialogAndroid(QtGui.QDialog):
68
76
  self.lineEdit_5.setObjectName(("lineEdit_5"))
69
77
  self.formLayout.setWidget(8, QtGui.QFormLayout.SpanningRole, self.lineEdit_5)
70
78
  self.tabWidget.addTab(self.tab_4, (""))
79
+
80
+ #radio buttons
81
+ self.radio1=QtGui.QRadioButton("Device", self.formLayoutWidget)
82
+ self.radio2=QtGui.QRadioButton("Emulator", self.formLayoutWidget)
83
+ self.radio1.clicked.connect(lambda:self.setDevice(1))
84
+ self.radio2.clicked.connect(lambda:self.setDevice(0))
85
+ self.formLayout.setWidget(9, QtGui.QFormLayout.SpanningRole,self.radio1)
86
+ self.formLayout.setWidget(10, QtGui.QFormLayout.SpanningRole,self.radio2)
87
+ self.radio1.setChecked(1)
71
88
  self.horizontalLayout.addWidget(self.tabWidget)
89
+
72
90
  self.buttonBox = QtGui.QDialogButtonBox(self)
73
91
  self.buttonBox.setGeometry(QtCore.QRect(40, 370, 341, 32))
74
92
  self.buttonBox.setOrientation(QtCore.Qt.Horizontal)
@@ -87,6 +105,7 @@ class DialogAndroid(QtGui.QDialog):
87
105
  self.lineEdit_4.setText(adblist[2])
88
106
  self.lineEdit_5.setText(adblist[3])
89
107
 
108
+
90
109
  def ok(self,btn):
91
110
  val = []
92
111
  if(btn.text() == "OK"):
@@ -96,6 +115,10 @@ class DialogAndroid(QtGui.QDialog):
96
115
  val.append(str(self.lineEdit_5.text()))
97
116
  config.setAdb(val)
98
117
  self.close()
118
+
119
+ def setDevice(self,val):
120
+ config.setDevice(val)
121
+
99
122
  class DialogAnt(QtGui.QDialog):
100
123
  def __init__(self, parent=None):
101
124
  QtGui.QDialog.__init__(self, parent)
Widget/editor.py CHANGED
@@ -1,4 +1,4 @@
1
- from globals import fontSize,fontName,ospathjoin,os_pixmap,apiDir,thresHold,config
1
+ from globals import fontSize,fontName,ospathjoin,os_pixmap,apiDir,threshold,config
2
2
  from PyQt4.QtCore import SIGNAL,QString
3
3
  from PyQt4.QtGui import QFontMetrics, QFont, QPixmap, QColor ,QPalette
4
4
  from PyQt4.Qsci import QsciScintilla, QsciLexerPython ,QsciAPIs ,QsciLexerCPP
@@ -26,7 +26,7 @@ class Editor(QsciScintilla):
26
26
  # Brace matching: enable for a brace immediately before or after
27
27
  # the current position
28
28
  self.setBraceMatching(QsciScintilla.SloppyBraceMatch)
29
- self.setAutoCompletionThreshold(thresHold)
29
+ self.setAutoCompletionThreshold(threshold)
30
30
  self.setAutoCompletionSource(QsciScintilla.AcsAPIs)
31
31
  #self.setFolding(QsciScintilla.BoxedTreeFoldStyle)
32
32
  #self.setAutoCompletionSource(QsciScintilla.AcsAll)
@@ -39,7 +39,7 @@ class Editor(QsciScintilla):
39
39
  self.setMarkerBackgroundColor(self.colorStyle.marker,self.ARROW_MARKER_NUM)
40
40
  self.font = QFont()
41
41
  self.font.setFamily(fontName)
42
- self.font.setFixedPitch(True)
42
+ #self.font.setFixedPitch(True)
43
43
  self.font.setPointSize(self.fontSize)
44
44
  self.setFont(self.font)
45
45
  self.fontmetrics = QFontMetrics(self.font)
@@ -96,10 +96,12 @@ class Editor(QsciScintilla):
96
96
  self.setMarginsFont(self.font)
97
97
 
98
98
  def setFontName(self,name):
99
- config.setFontName(name)
100
99
  self.font.setFamily(name)
101
100
  self.lexer.setFont(self.font)
102
101
 
102
+ def setThreshold(self,val):
103
+ self.setAutoCompletionThreshold(val)
104
+
103
105
 
104
106
 
105
107
  """
Widget/editor.pyc CHANGED
Binary file
config.py CHANGED
@@ -32,6 +32,16 @@ class Config:
32
32
  def iconSize(self):
33
33
  return int(self.readSetting('iconsize'))
34
34
 
35
+ def device(self):
36
+ return int(self.readSetting('device'))
37
+ def setDevice(self,value):
38
+ self.writeSetting("device",value)
39
+
40
+ def thresh(self):
41
+ return self.readSetting('thresh')
42
+ def setThresh(self,val):
43
+ self.writeSetting('thresh',val)
44
+
35
45
  def projects(self):
36
46
  return self.read('Project')
37
47
 
@@ -56,11 +66,6 @@ class Config:
56
66
  self.data['ADB'][3] = val[3]
57
67
  self.write()
58
68
 
59
- def thresh(self):
60
- return self.readSetting('thresh')
61
- def setThresh(self,val):
62
- self.writeSetting('thresh',val)
63
-
64
69
  def colorStyle(self):
65
70
  return int(self.readSetting('colorstyle'))
66
71
  def styleIndex(self):
config.yaml CHANGED
@@ -16,8 +16,9 @@ Project:
16
16
  Recent:
17
17
  - C:\CODE\main.nut
18
18
  Setting:
19
+ device: 1
19
20
  fontname: Courier New
20
- fontsize: 9
21
+ fontsize: 11
21
22
  iconsize: 16
22
23
  styleindex: 8
23
24
  thresh: 1
globals.py CHANGED
@@ -1,11 +1,10 @@
1
1
  #!/usr/bin/env python
2
2
  __author__ = "pyros2097"
3
3
  __license__ = "GPLv3"
4
- __version__ = "0.48"
5
4
  __copyright__ = 'Copyright (c) 2012, pyros2097'
6
5
  __credits__ = ['pyros2097', 'eclipse']
7
6
  __email__ = 'pyros2097@gmail.com'
8
- __version__ = "0.51"
7
+ __version__ = "0.52"
9
8
 
10
9
  #TODO:
11
10
  #Must learn to destroy editor completely because memory keeps increasing
@@ -36,24 +35,26 @@ osrename = os.rename
36
35
  ossep = os.sep
37
36
  OS_NAME = system()
38
37
 
38
+
39
39
  workDir = os.getcwd()
40
40
  apiDir = ospathjoin(workDir,"api")
41
41
  iconDir = ospathjoin("Icons")
42
42
  binDir = ospathjoin(workDir,"bin")
43
43
  sqcDir = ospathjoin(binDir,"sqc.exe")
44
44
 
45
-
46
45
  recycle = send2trash
47
46
  PY_VERSION = python_version()
48
47
 
48
+ #Config data
49
49
  config = Config()
50
50
  workSpace = config.workSpace()
51
51
  fontSize = config.fontSize()
52
52
  fontName = config.fontName()
53
53
  iconSize = config.iconSize()
54
54
  styleIndex = config.styleIndex()
55
- thresHold = config.thresh()
55
+ threshold = config.thresh()
56
56
  adblist = config.adb()
57
+ device = config.device()
57
58
 
58
59
  def os_icon(name):
59
60
  return QIcon(":/{0}.png".format(ospathjoin(iconDir,name)))
window.py CHANGED
@@ -1,14 +1,16 @@
1
1
  from PyQt4.QtGui import (QAction,QIcon,QMessageBox,QWidgetAction,QMenu,QWidget,
2
2
  QHBoxLayout,QVBoxLayout,QTabWidget,QToolBar,QTextEdit,
3
3
  QLineEdit,QPushButton,QToolButton,QSplitter,QStatusBar,
4
- QMainWindow,QPalette,QColor,QSlider,QFontDialog,QLabel)
4
+ QMainWindow,QPalette,QColor,QSlider,QFontDialog,QLabel,
5
+ QFont)
5
6
  from PyQt4.QtCore import QSize,Qt, QT_VERSION_STR,PYQT_VERSION_STR,QStringList
6
7
  from Widget import Tab,Tree,DialogAndroid
7
8
  from Widget.style import Styles
8
9
 
9
10
  from globals import (ospathsep,ospathjoin,ospathbasename,workDir,
10
11
  OS_NAME,PY_VERSION,__version__,config,workSpace,
11
- iconSize,iconDir,styleIndex,adblist,Icons,os_icon)
12
+ iconSize,iconDir,styleIndex,adblist,Icons,os_icon,threshold,
13
+ fontName,fontSize)
12
14
 
13
15
  class Window(QMainWindow):
14
16
  def __init__(self,parent = None):
@@ -226,6 +228,7 @@ class Window(QMainWindow):
226
228
  self.setCentralWidget(self.centralwidget)
227
229
  self.setStatusBar(self.statusbar)
228
230
  self.textEdit.setReadOnly(True)
231
+ self.fontName = fontName
229
232
  #QtGui.QApplication.setStyle(QtGui.QStyleFactory.create('Cleanlooks'))
230
233
 
231
234
  def findBarShow(self):
@@ -273,21 +276,25 @@ class Window(QMainWindow):
273
276
  #self.action_Todo.triggered.connect(self.stop)
274
277
  #Only variation CHeck Later
275
278
  men = QMenu()
276
- chkBox = QSlider()
279
+ self.threshSlider = QSlider()
277
- chkBox.setTickPosition(QSlider.TicksLeft)
280
+ self.threshSlider.setTickPosition(QSlider.TicksLeft)
281
+ self.threshSlider.setOrientation(Qt.Horizontal)
282
+ self.threshSlider.setValue(threshold)
283
+ self.threshSlider.setMinimum(0)
284
+ self.threshSlider.setMaximum(5)
285
+ self.threshSlider.valueChanged.connect(self.setThreshold)
286
+ #self.threshSlider.setInvertedAppearance(True)
278
- chkBoxAction = QWidgetAction(men)
287
+ self.threshSliderAction = QWidgetAction(men)
279
- chkBoxAction.setDefaultWidget(chkBox)
288
+ self.threshSliderAction.setDefaultWidget(self.threshSlider)
289
+
280
290
  men.addAction(QAction("Ident",self))
281
291
  men.addAction(QAction("Edit",self))
282
292
  men.addAction(QAction("Paste",self))
283
293
  men.addAction(QAction("Tabs",self))
284
294
  men.addSeparator()
285
295
  men.addAction(QAction("Threshold",self))
286
- men.addAction(chkBoxAction)
296
+ men.addAction(self.threshSliderAction)
287
- chkBox.setValue(1)
297
+
288
- chkBox.setMinimum(0)
289
- chkBox.setMaximum(5)
290
- chkBox.setInvertedAppearance(True)
291
298
  self.action_Options = QAction(Icons.thread_view, 'Options', self)
292
299
  self.action_Options.setMenu(men)
293
300
  self.action_Options.triggered.connect(self.options)
@@ -448,9 +455,26 @@ class Window(QMainWindow):
448
455
  self.tabWidget.widget(i).zoomout()
449
456
 
450
457
  def setFont(self):
458
+ font = QFont()
459
+ font.setFamily(self.fontName)
451
- font = QFontDialog.getFont()
460
+ fdialog = QFontDialog(self)
461
+ fdialog.show()
462
+ fdialog.setCurrentFont(font)
463
+ fdialog.accepted.connect(lambda:self.setFontName(fdialog.currentFont()))
464
+
465
+
466
+ def setFontName(self,font):
467
+ #print "accepted"
468
+ #print font.family()
469
+ self.fontName = str(font.family())
470
+ config.setFontName(self.fontName)
452
- #for i in range(len(self.files)):
471
+ for i in range(len(self.files)):
453
- #self.tabWidget.widget(i).setFontName()
472
+ self.tabWidget.widget(i).setFontName(self.fontName)
473
+
474
+ def setThreshold(self,val):
475
+ config.setThresh(val)
476
+ for i in range(len(self.files)):
477
+ self.tabWidget.widget(i).setThreshold(val)
454
478
 
455
479
  def initColorStyle(self):
456
480
  self.colorStyle = Styles[self.styleIndex]