Browse Source

Add Canvas menu; set-up some keyboard shortcuts

tags/1.9.4
falkTX 12 years ago
parent
commit
9667e5a176
12 changed files with 228 additions and 1 deletions
  1. BIN
      resources/16x16/document-print.png
  2. BIN
      resources/16x16/media-playback-pause.png
  3. BIN
      resources/16x16/media-seek-backward.png
  4. BIN
      resources/16x16/media-seek-forward.png
  5. BIN
      resources/16x16/view-sort-ascending.png
  6. BIN
      resources/16x16/zoom-fit-best.png
  7. BIN
      resources/16x16/zoom-in.png
  8. BIN
      resources/16x16/zoom-original.png
  9. BIN
      resources/16x16/zoom-out.png
  10. +9
    -0
      resources/resources.qrc
  11. +147
    -1
      resources/ui/carla.ui
  12. +72
    -0
      source/carla.py

BIN
resources/16x16/document-print.png View File

Before After
Width: 16  |  Height: 16  |  Size: 566B

BIN
resources/16x16/media-playback-pause.png View File

Before After
Width: 16  |  Height: 16  |  Size: 484B

BIN
resources/16x16/media-seek-backward.png View File

Before After
Width: 16  |  Height: 16  |  Size: 505B

BIN
resources/16x16/media-seek-forward.png View File

Before After
Width: 16  |  Height: 16  |  Size: 506B

BIN
resources/16x16/view-sort-ascending.png View File

Before After
Width: 16  |  Height: 16  |  Size: 609B

BIN
resources/16x16/zoom-fit-best.png View File

Before After
Width: 16  |  Height: 16  |  Size: 454B

BIN
resources/16x16/zoom-in.png View File

Before After
Width: 16  |  Height: 16  |  Size: 791B

BIN
resources/16x16/zoom-original.png View File

Before After
Width: 16  |  Height: 16  |  Size: 781B

BIN
resources/16x16/zoom-out.png View File

Before After
Width: 16  |  Height: 16  |  Size: 786B

+ 9
- 0
resources/resources.qrc View File

@@ -11,17 +11,26 @@
<file>16x16/dialog-ok-apply.png</file> <file>16x16/dialog-ok-apply.png</file>
<file>16x16/document-new.png</file> <file>16x16/document-new.png</file>
<file>16x16/document-open.png</file> <file>16x16/document-open.png</file>
<file>16x16/document-print.png</file>
<file>16x16/document-save.png</file> <file>16x16/document-save.png</file>
<file>16x16/document-save-as.png</file> <file>16x16/document-save-as.png</file>
<file>16x16/edit-delete.png</file> <file>16x16/edit-delete.png</file>
<file>16x16/edit-rename.png</file> <file>16x16/edit-rename.png</file>
<file>16x16/list-add.png</file> <file>16x16/list-add.png</file>
<file>16x16/list-remove.png</file> <file>16x16/list-remove.png</file>
<file>16x16/media-playback-pause.png</file>
<file>16x16/media-playback-start.png</file> <file>16x16/media-playback-start.png</file>
<file>16x16/media-playback-stop.png</file> <file>16x16/media-playback-stop.png</file>
<file>16x16/media-seek-backward.png</file>
<file>16x16/media-seek-forward.png</file>
<file>16x16/network-connect.png</file> <file>16x16/network-connect.png</file>
<file>16x16/view-refresh.png</file> <file>16x16/view-refresh.png</file>
<file>16x16/view-sort-ascending.png</file>
<file>16x16/window-close.png</file> <file>16x16/window-close.png</file>
<file>16x16/zoom-fit-best.png</file>
<file>16x16/zoom-in.png</file>
<file>16x16/zoom-original.png</file>
<file>16x16/zoom-out.png</file>


<file>48x48/carla.png</file> <file>48x48/carla.png</file>
<file>48x48/carla-control.png</file> <file>48x48/carla-control.png</file>


+ 147
- 1
resources/ui/carla.ui View File

@@ -95,6 +95,10 @@
<property name="text"> <property name="text">
<string/> <string/>
</property> </property>
<property name="icon">
<iconset resource="../resources.qrc">
<normaloff>:/16x16/media-seek-backward.png</normaloff>:/16x16/media-seek-backward.png</iconset>
</property>
</widget> </widget>
</item> </item>
<item> <item>
@@ -108,6 +112,10 @@
<property name="text"> <property name="text">
<string/> <string/>
</property> </property>
<property name="icon">
<iconset resource="../resources.qrc">
<normaloff>:/16x16/media-seek-forward.png</normaloff>:/16x16/media-seek-forward.png</iconset>
</property>
</widget> </widget>
</item> </item>
<item> <item>
@@ -211,7 +219,7 @@
</layout> </layout>
</widget> </widget>
</widget> </widget>
<widget class="QWidget" name="">
<widget class="QWidget" name="layoutWidget">
<layout class="QVBoxLayout" name="verticalLayout_4"> <layout class="QVBoxLayout" name="verticalLayout_4">
<item> <item>
<widget class="QTabWidget" name="tabUtils"> <widget class="QTabWidget" name="tabUtils">
@@ -332,9 +340,31 @@
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="act_settings_configure"/> <addaction name="act_settings_configure"/>
</widget> </widget>
<widget class="QMenu" name="menu_Canvas">
<property name="title">
<string>&amp;Canvas</string>
</property>
<widget class="QMenu" name="menu_Canvas_Zoom">
<property name="title">
<string>Zoom</string>
</property>
<addaction name="act_canvas_zoom_fit"/>
<addaction name="separator"/>
<addaction name="act_canvas_zoom_in"/>
<addaction name="act_canvas_zoom_out"/>
<addaction name="act_canvas_zoom_100"/>
</widget>
<addaction name="act_canvas_arrange"/>
<addaction name="act_canvas_refresh"/>
<addaction name="menu_Canvas_Zoom"/>
<addaction name="separator"/>
<addaction name="act_canvas_print"/>
<addaction name="act_canvas_save_image"/>
</widget>
<addaction name="menu_File"/> <addaction name="menu_File"/>
<addaction name="menu_Engine"/> <addaction name="menu_Engine"/>
<addaction name="menu_Plugin"/> <addaction name="menu_Plugin"/>
<addaction name="menu_Canvas"/>
<addaction name="menu_Settings"/> <addaction name="menu_Settings"/>
<addaction name="menu_Help"/> <addaction name="menu_Help"/>
</widget> </widget>
@@ -377,6 +407,9 @@
<property name="text"> <property name="text">
<string>&amp;Save</string> <string>&amp;Save</string>
</property> </property>
<property name="shortcut">
<string>Ctrl+S</string>
</property>
</action> </action>
<action name="act_file_save_as"> <action name="act_file_save_as">
<property name="icon"> <property name="icon">
@@ -386,6 +419,9 @@
<property name="text"> <property name="text">
<string>Save &amp;As...</string> <string>Save &amp;As...</string>
</property> </property>
<property name="shortcut">
<string>Ctrl+Shift+S</string>
</property>
</action> </action>
<action name="act_file_new"> <action name="act_file_new">
<property name="icon"> <property name="icon">
@@ -395,6 +431,9 @@
<property name="text"> <property name="text">
<string>&amp;New</string> <string>&amp;New</string>
</property> </property>
<property name="shortcut">
<string>Ctrl+N</string>
</property>
</action> </action>
<action name="act_file_open"> <action name="act_file_open">
<property name="icon"> <property name="icon">
@@ -404,6 +443,9 @@
<property name="text"> <property name="text">
<string>&amp;Open...</string> <string>&amp;Open...</string>
</property> </property>
<property name="shortcut">
<string>Ctrl+O</string>
</property>
</action> </action>
<action name="act_file_quit"> <action name="act_file_quit">
<property name="icon"> <property name="icon">
@@ -413,6 +455,9 @@
<property name="text"> <property name="text">
<string>&amp;Quit</string> <string>&amp;Quit</string>
</property> </property>
<property name="shortcut">
<string>Ctrl+Q</string>
</property>
</action> </action>
<action name="act_plugin_remove_all"> <action name="act_plugin_remove_all">
<property name="icon"> <property name="icon">
@@ -422,6 +467,9 @@
<property name="text"> <property name="text">
<string>&amp;Remove All</string> <string>&amp;Remove All</string>
</property> </property>
<property name="shortcut">
<string>Ctrl+Shift+R</string>
</property>
</action> </action>
<action name="act_help_about"> <action name="act_help_about">
<property name="text"> <property name="text">
@@ -441,6 +489,9 @@
<property name="text"> <property name="text">
<string>&amp;Add New...</string> <string>&amp;Add New...</string>
</property> </property>
<property name="shortcut">
<string>Ctrl+A</string>
</property>
</action> </action>
<action name="act_settings_show_toolbar"> <action name="act_settings_show_toolbar">
<property name="checkable"> <property name="checkable">
@@ -467,6 +518,9 @@
<property name="text"> <property name="text">
<string>&amp;Start</string> <string>&amp;Start</string>
</property> </property>
<property name="shortcut">
<string>F5</string>
</property>
</action> </action>
<action name="act_engine_stop"> <action name="act_engine_stop">
<property name="icon"> <property name="icon">
@@ -476,6 +530,9 @@
<property name="text"> <property name="text">
<string>St&amp;op</string> <string>St&amp;op</string>
</property> </property>
<property name="shortcut">
<string>F6</string>
</property>
</action> </action>
<action name="act_engine_configure"> <action name="act_engine_configure">
<property name="enabled"> <property name="enabled">
@@ -488,6 +545,9 @@
<property name="text"> <property name="text">
<string>Configure Driver</string> <string>Configure Driver</string>
</property> </property>
<property name="shortcut">
<string>F7</string>
</property>
</action> </action>
<action name="act_settings_show_transport"> <action name="act_settings_show_transport">
<property name="checkable"> <property name="checkable">
@@ -503,6 +563,92 @@
<string>Show Transport bar</string> <string>Show Transport bar</string>
</property> </property>
</action> </action>
<action name="act_canvas_arrange">
<property name="icon">
<iconset resource="../resources.qrc">
<normaloff>:/16x16/view-sort-ascending.png</normaloff>:/16x16/view-sort-ascending.png</iconset>
</property>
<property name="text">
<string>&amp;Arrange</string>
</property>
<property name="shortcut">
<string>Ctrl+G</string>
</property>
</action>
<action name="act_canvas_refresh">
<property name="icon">
<iconset resource="../resources.qrc">
<normaloff>:/16x16/view-refresh.png</normaloff>:/16x16/view-refresh.png</iconset>
</property>
<property name="text">
<string>&amp;Refresh</string>
</property>
<property name="shortcut">
<string>Ctrl+R</string>
</property>
</action>
<action name="act_canvas_print">
<property name="icon">
<iconset resource="../resources.qrc">
<normaloff>:/16x16/document-print.png</normaloff>:/16x16/document-print.png</iconset>
</property>
<property name="text">
<string>&amp;Print...</string>
</property>
</action>
<action name="act_canvas_save_image">
<property name="text">
<string>Save &amp;Image...</string>
</property>
</action>
<action name="act_canvas_zoom_fit">
<property name="icon">
<iconset resource="../resources.qrc">
<normaloff>:/16x16/zoom-fit-best.png</normaloff>:/16x16/zoom-fit-best.png</iconset>
</property>
<property name="text">
<string>Auto-Fit</string>
</property>
<property name="shortcut">
<string>Home</string>
</property>
</action>
<action name="act_canvas_zoom_in">
<property name="icon">
<iconset resource="../resources.qrc">
<normaloff>:/16x16/zoom-in.png</normaloff>:/16x16/zoom-in.png</iconset>
</property>
<property name="text">
<string>Zoom In</string>
</property>
<property name="shortcut">
<string>Ctrl++</string>
</property>
</action>
<action name="act_canvas_zoom_out">
<property name="icon">
<iconset resource="../resources.qrc">
<normaloff>:/16x16/zoom-out.png</normaloff>:/16x16/zoom-out.png</iconset>
</property>
<property name="text">
<string>Zoom Out</string>
</property>
<property name="shortcut">
<string>Ctrl+-</string>
</property>
</action>
<action name="act_canvas_zoom_100">
<property name="icon">
<iconset resource="../resources.qrc">
<normaloff>:/16x16/zoom-original.png</normaloff>:/16x16/zoom-original.png</iconset>
</property>
<property name="text">
<string>Zoom 100%</string>
</property>
<property name="shortcut">
<string>Ctrl+1</string>
</property>
</action>
</widget> </widget>
<customwidgets> <customwidgets>
<customwidget> <customwidget>


+ 72
- 0
source/carla.py View File

@@ -22,6 +22,7 @@
from time import sleep from time import sleep
from PyQt4.QtCore import Qt, QModelIndex, QPointF, QSize from PyQt4.QtCore import Qt, QModelIndex, QPointF, QSize
from PyQt4.QtGui import QApplication, QDialogButtonBox, QFileSystemModel, QMainWindow, QResizeEvent from PyQt4.QtGui import QApplication, QDialogButtonBox, QFileSystemModel, QMainWindow, QResizeEvent
from PyQt4.QtGui import QImage, QPrinter, QPrintDialog


# ------------------------------------------------------------------------------------------------------------ # ------------------------------------------------------------------------------------------------------------
# Imports (Custom Stuff) # Imports (Custom Stuff)
@@ -641,6 +642,16 @@ class CarlaMainW(QMainWindow):
self.connect(self.ui.act_plugin_add, SIGNAL("triggered()"), SLOT("slot_pluginAdd()")) self.connect(self.ui.act_plugin_add, SIGNAL("triggered()"), SLOT("slot_pluginAdd()"))
self.connect(self.ui.act_plugin_remove_all, SIGNAL("triggered()"), SLOT("slot_pluginRemoveAll()")) self.connect(self.ui.act_plugin_remove_all, SIGNAL("triggered()"), SLOT("slot_pluginRemoveAll()"))


self.ui.act_canvas_arrange.setEnabled(False) # TODO, later
self.connect(self.ui.act_canvas_arrange, SIGNAL("triggered()"), SLOT("slot_canvasArrange()"))
self.connect(self.ui.act_canvas_refresh, SIGNAL("triggered()"), SLOT("slot_canvasRefresh()"))
self.connect(self.ui.act_canvas_zoom_fit, SIGNAL("triggered()"), SLOT("slot_canvasZoomFit()"))
self.connect(self.ui.act_canvas_zoom_in, SIGNAL("triggered()"), SLOT("slot_canvasZoomIn()"))
self.connect(self.ui.act_canvas_zoom_out, SIGNAL("triggered()"), SLOT("slot_canvasZoomOut()"))
self.connect(self.ui.act_canvas_zoom_100, SIGNAL("triggered()"), SLOT("slot_canvasZoomReset()"))
self.connect(self.ui.act_canvas_print, SIGNAL("triggered()"), SLOT("slot_canvasPrint()"))
self.connect(self.ui.act_canvas_save_image, SIGNAL("triggered()"), SLOT("slot_canvasSaveImage()"))

self.connect(self.ui.act_settings_configure, SIGNAL("triggered()"), SLOT("slot_configureCarla()")) self.connect(self.ui.act_settings_configure, SIGNAL("triggered()"), SLOT("slot_configureCarla()"))
self.connect(self.ui.act_help_about, SIGNAL("triggered()"), SLOT("slot_aboutCarla()")) self.connect(self.ui.act_help_about, SIGNAL("triggered()"), SLOT("slot_aboutCarla()"))
self.connect(self.ui.act_help_about_qt, SIGNAL("triggered()"), app, SLOT("aboutQt()")) self.connect(self.ui.act_help_about_qt, SIGNAL("triggered()"), app, SLOT("aboutQt()"))
@@ -701,6 +712,67 @@ class CarlaMainW(QMainWindow):
#else: #else:
QTimer.singleShot(0, self, SLOT("slot_engineStart()")) QTimer.singleShot(0, self, SLOT("slot_engineStart()"))


@pyqtSlot()
def slot_canvasArrange(self):
patchcanvas.arrange()

@pyqtSlot()
def slot_canvasRefresh(self):
patchcanvas.clear()
Carla.host.patchbay_refresh()

@pyqtSlot()
def slot_canvasZoomFit(self):
self.scene.zoom_fit()

@pyqtSlot()
def slot_canvasZoomIn(self):
self.scene.zoom_in()

@pyqtSlot()
def slot_canvasZoomOut(self):
self.scene.zoom_out()

@pyqtSlot()
def slot_canvasZoomReset(self):
self.scene.zoom_reset()

@pyqtSlot()
def slot_canvasPrint(self):
self.scene.clearSelection()
self.fExportPrinter = QPrinter()
dialog = QPrintDialog(self.fExportPrinter, self)

if dialog.exec_():
painter = QPainter(self.fExportPrinter)
painter.setRenderHint(QPainter.Antialiasing)
painter.setRenderHint(QPainter.TextAntialiasing)
self.scene.render(painter)

@pyqtSlot()
def slot_canvasSaveImage(self):
newPath = QFileDialog.getSaveFileName(self, self.tr("Save Image"), filter=self.tr("PNG Image (*.png);;JPEG Image (*.jpg)"))

if newPath:
self.scene.clearSelection()

# FIXME - must be a better way...
if newPath.endswith((".jpg", ".jpG", ".jPG", ".JPG", ".JPg", ".Jpg")):
imgFormat = "JPG"
elif newPath.endswith((".png", ".pnG", ".pNG", ".PNG", ".PNg", ".Png")):
imgFormat = "PNG"
else:
# File-dialog may not auto-add the extension
imgFormat = "PNG"
newPath += ".png"

self.fExportImage = QImage(self.scene.sceneRect().width(), self.scene.sceneRect().height(), QImage.Format_RGB32)
painter = QPainter(self.fExportImage)
painter.setRenderHint(QPainter.Antialiasing) # TODO - set true, cleanup this
painter.setRenderHint(QPainter.TextAntialiasing)
self.scene.render(painter)
self.fExportImage.save(newPath, imgFormat, 100)

@pyqtSlot(QModelIndex) @pyqtSlot(QModelIndex)
def slot_fileTreeDoubleClicked(self, modelIndex): def slot_fileTreeDoubleClicked(self, modelIndex):
filename = self.fDirModel.filePath(modelIndex) filename = self.fDirModel.filePath(modelIndex)


Loading…
Cancel
Save