Package mcbase :: Package libs :: Package designeditor :: Module toolbar
[hide private]
[frames] | no frames]

Source Code for Module mcbase.libs.designeditor.toolbar

 1  # -*- coding: utf-8 -*- 
 2   
 3  ########################################################################## 
 4  # toolbar.py 
 5  # 
 6  # Tasarım Editörünün ana toolbar sınıfı 
 7  # 
 8  # (C) 2007 Likya Yazılım ve Bilişim Hizmetleri Ltd. Şti. 
 9  ########################################################################## 
10   
11  from PyQt4.QtCore import * 
12  from PyQt4.QtGui import * 
13   
14  from tools import * 
15   
16  import icons 
17   
18 -class ToolBar(QToolBar):
19
20 - def __init__(self, parent, editor, plugin):
21 ''' 22 Tasarım editörü için toolbarı oluşturur. 23 ''' 24 QToolBar.__init__(self, parent) 25 26 self._editor = editor 27 self._plugin = plugin 28 29 # Toolbar'da bulunan düğmelerin action'ları 30 self._actions = {} 31 32 # Düğmeler oluşturulmadan önce çalışır. 33 self.preInitToolBar() 34 35 # Toolbar'ı oluştur. 36 self.createToolbarButtons() 37 38 self.initToolBar() 39 40 # Silinecek toolbutton'lar 41 for actionCode in self._plugin.removableActions(): 42 if actionCode in self._actions: 43 action = self.getAction(actionCode) 44 action.setVisible(False)
45
46 - def preInitToolBar(self):
47 pass
48
49 - def initToolBar(self):
50 pass
51
52 - def getToolbarItems(self):
53 ''' 54 Toolbar'da nelerin olacağını belirler. 55 ''' 56 toolbarItems = [ 57 ] 58 59 return toolbarItems
60
61 - def actions(self):
62 ''' 63 Oluşturulan actionları bir liste olarak geri döndürür 64 ''' 65 return self._actions
66
67 - def getAction(self, name):
68 ''' 69 İstenilen toolbar elemanının action'ını döndürür. 70 ''' 71 return self._actions[name]
72
73 - def createToolbarButtons(self):
74 ''' 75 Toolbar'da bulunan düğmelerin action'ları oluşturur. 76 ''' 77 toolbarItems = self.getToolbarItems() 78 79 # Düğmeleri oluşturuyoruz. 80 for name, definition, shortcut, description in toolbarItems: 81 82 if name == '-': 83 self.addSeparator() 84 85 else: 86 icon = getattr(icons, '%sIcon' % name) 87 definition = tr(definition) 88 if shortcut: 89 definition += " (%s)" % shortcut 90 action = QAction(icon, definition, self.parent()) 91 action.setShortcut(QKeySequence(shortcut)) 92 action.setStatusTip(tr(description)) 93 self.addAction(action) 94 self._actions[name] = action
95