can't right-click empty space + color eyedropper
This commit is contained in:
parent
59c2c090ab
commit
be5d47f863
|
@ -24,7 +24,9 @@ class Component:
|
||||||
exec('self.%s = value' % var)
|
exec('self.%s = value' % var)
|
||||||
|
|
||||||
def pickColor(self):
|
def pickColor(self):
|
||||||
color = QtGui.QColorDialog.getColor()
|
dialog = QtGui.QColorDialog()
|
||||||
|
dialog.setOption(QtGui.QColorDialog.ShowAlphaChannel, True)
|
||||||
|
color = dialog.getColor()
|
||||||
if color.isValid():
|
if color.isValid():
|
||||||
RGBstring = '%s,%s,%s' % (
|
RGBstring = '%s,%s,%s' % (
|
||||||
str(color.red()), str(color.green()), str(color.blue()))
|
str(color.red()), str(color.green()), str(color.blue()))
|
||||||
|
|
|
@ -31,7 +31,7 @@ class Component(__base__.Component):
|
||||||
page.comboBox_textAlign.addItem("Right")
|
page.comboBox_textAlign.addItem("Right")
|
||||||
|
|
||||||
page.lineEdit_textColor.setText('%s,%s,%s' % self.textColor)
|
page.lineEdit_textColor.setText('%s,%s,%s' % self.textColor)
|
||||||
page.pushButton_textColor.clicked.connect(lambda: self.pickColor())
|
page.pushButton_textColor.clicked.connect(self.pickColor)
|
||||||
btnStyle = "QPushButton { background-color : %s; outline: none; }" \
|
btnStyle = "QPushButton { background-color : %s; outline: none; }" \
|
||||||
% QColor(*self.textColor).name()
|
% QColor(*self.textColor).name()
|
||||||
page.pushButton_textColor.setStyleSheet(btnStyle)
|
page.pushButton_textColor.setStyleSheet(btnStyle)
|
||||||
|
|
4
core.py
4
core.py
|
@ -95,9 +95,9 @@ class Core():
|
||||||
origName, saveValueStore,
|
origName, saveValueStore,
|
||||||
exportPath
|
exportPath
|
||||||
)
|
)
|
||||||
|
return True
|
||||||
except:
|
except:
|
||||||
# TODO: add proper warning message
|
return False
|
||||||
print('couldn\'t export %s' % exportPath)
|
|
||||||
|
|
||||||
def createPresetFile(
|
def createPresetFile(
|
||||||
self, compName, vers, presetName, saveValueStore, filepath=''):
|
self, compName, vers, presetName, saveValueStore, filepath=''):
|
||||||
|
|
|
@ -606,20 +606,25 @@ class MainWindow(QtCore.QObject):
|
||||||
|
|
||||||
def componentContextMenu(self, QPos):
|
def componentContextMenu(self, QPos):
|
||||||
'''Appears when right-clicking a component in the list'''
|
'''Appears when right-clicking a component in the list'''
|
||||||
if not self.window.listWidget_componentList.selectedItems():
|
componentList = self.window.listWidget_componentList
|
||||||
|
if not componentList.selectedItems():
|
||||||
|
return
|
||||||
|
|
||||||
|
# don't show menu if clicking empty space
|
||||||
|
parentPosition = componentList.mapToGlobal(QtCore.QPoint(0, 0))
|
||||||
|
index = componentList.currentRow()
|
||||||
|
modelIndex = componentList.model().index(index)
|
||||||
|
if not componentList.visualRect(modelIndex).contains(QPos):
|
||||||
return
|
return
|
||||||
|
|
||||||
self.presetManager.findPresets()
|
self.presetManager.findPresets()
|
||||||
self.menu = QtGui.QMenu()
|
self.menu = QtGui.QMenu()
|
||||||
menuItem = self.menu.addAction("Save Preset")
|
menuItem = self.menu.addAction("Save Preset")
|
||||||
self.connect(
|
menuItem.triggered.connect(
|
||||||
menuItem,
|
|
||||||
QtCore.SIGNAL("triggered()"),
|
|
||||||
self.presetManager.openSavePresetDialog
|
self.presetManager.openSavePresetDialog
|
||||||
)
|
)
|
||||||
|
|
||||||
# submenu for opening presets
|
# submenu for opening presets
|
||||||
index = self.window.listWidget_componentList.currentRow()
|
|
||||||
try:
|
try:
|
||||||
presets = self.presetManager.presets[str(self.core.selectedComponents[index])]
|
presets = self.presetManager.presets[str(self.core.selectedComponents[index])]
|
||||||
self.submenu = QtGui.QMenu("Open Preset")
|
self.submenu = QtGui.QMenu("Open Preset")
|
||||||
|
@ -627,14 +632,12 @@ class MainWindow(QtCore.QObject):
|
||||||
|
|
||||||
for version, presetName in presets:
|
for version, presetName in presets:
|
||||||
menuItem = self.submenu.addAction(presetName)
|
menuItem = self.submenu.addAction(presetName)
|
||||||
self.connect(
|
menuItem.triggered.connect(
|
||||||
menuItem,
|
lambda _, presetName=presetName:
|
||||||
QtCore.SIGNAL("triggered()"),
|
|
||||||
lambda presetName=presetName:
|
|
||||||
self.presetManager.openPreset(presetName)
|
self.presetManager.openPreset(presetName)
|
||||||
)
|
)
|
||||||
except KeyError as e:
|
except KeyError:
|
||||||
print(e)
|
pass
|
||||||
parentPosition = self.window.listWidget_componentList.mapToGlobal(QtCore.QPoint(0, 0))
|
|
||||||
self.menu.move(parentPosition + QPos)
|
self.menu.move(parentPosition + QPos)
|
||||||
self.menu.show()
|
self.menu.show()
|
||||||
|
|
|
@ -259,4 +259,8 @@ class PresetManager(QtGui.QDialog):
|
||||||
if filename:
|
if filename:
|
||||||
index = self.window.listWidget_presets.currentRow()
|
index = self.window.listWidget_presets.currentRow()
|
||||||
comp, vers, name = self.presetRows[index]
|
comp, vers, name = self.presetRows[index]
|
||||||
self.core.exportPreset(filename, comp, vers, name)
|
if not self.core.exportPreset(filename, comp, vers, name):
|
||||||
|
self.parent.showMessage(
|
||||||
|
msg='Couldn\'t export %s.' % filename,
|
||||||
|
parent=self.window
|
||||||
|
)
|
||||||
|
|
Reference in New Issue