def __init__(self, win, site): UndoableEditor.__init__(self) self.win = win self.site = site self.title = QLineEdit() self.titleLabel.setText(QCoreApplication.translate("SiteSettingsEditor", "Site Settings")) self.filename = site.source_path + "/" + site.filename self.description = QLineEdit() self.copyright = QLineEdit() self.keywords = QLineEdit() self.author = QLineEdit() self.output = QLineEdit() self.logo = QLineEdit() seekButton = QPushButton("...") self.image = ImageSelector() self.image.setImage(QImage(":/images/image_placeholder.png")) self.copyright.setPlaceholderText("© 2019 your name") self.publisher = QComboBox() for key in Plugins.publishPluginNames(): pi = Plugins.getPublishPlugin(key) if pi: self.publisher.addItem(pi.display_name, key) vbox = QVBoxLayout() vbox.addStretch() self.layout.addWidget(QLabel(QCoreApplication.translate("SiteSettingsEditor", "Title")), 1, 0) self.layout.addWidget(self.title, 2, 0) self.layout.addWidget(QLabel(QCoreApplication.translate("SiteSettingsEditor", "Description")), 3, 0) self.layout.addWidget(self.description, 4, 0, 1, 3) self.layout.addWidget(QLabel(QCoreApplication.translate("SiteSettingsEditor", "Copyright")), 5, 0) self.layout.addWidget(self.copyright, 6, 0, 1, 3) self.layout.addWidget(QLabel(QCoreApplication.translate("SiteSettingsEditor", "Keywords")), 7, 0) self.layout.addWidget(self.keywords, 8, 0, 1, 3) self.layout.addWidget(QLabel(QCoreApplication.translate("SiteSettingsEditor", "Author")), 9, 0) self.layout.addWidget(self.author, 10, 0) self.layout.addWidget(QLabel(QCoreApplication.translate("SiteSettingsEditor", "Output directory (relative to to source dir)")), 11, 0) self.layout.addWidget(self.output, 12, 0) self.layout.addWidget(QLabel(QCoreApplication.translate("SiteSettingsEditor", "Logo")), 13, 0) self.layout.addWidget(self.logo, 14, 0) self.layout.addWidget(seekButton, 14, 1) self.layout.addWidget(self.image, 15, 0, 1, 2) self.layout.setRowStretch(15, 1) self.layout.addWidget(QLabel(QCoreApplication.translate("SiteSettingsEditor", "Plugin to be used for publishing")), 16, 0) self.layout.addWidget(self.publisher, 17, 0) self.layout.addLayout(vbox, 18, 0) self.load() self.title.editingFinished.connect(self.titleChanged) self.description.editingFinished.connect(self.descriptionChanged) self.copyright.editingFinished.connect(self.copyrightChanged) self.keywords.editingFinished.connect(self.keywordsChanged) self.author.editingFinished.connect(self.authorChanged) self.output.editingFinished.connect(self.outputChanged) self.logo.editingFinished.connect(self.logoChanged) self.publisher.currentIndexChanged.connect(self.publisherChanged) seekButton.clicked.connect(self.seek)
def __init__(self, win): QWidget.__init__(self) self.win = win self.id = 0 title = QLabel("Client Data") fnt = title.font() fnt.setPointSize(20) fnt.setBold(True) title.setFont(fnt) self.layout = QGridLayout() self.layout.setColumnStretch(0, 1) self.number = QLineEdit() self.name = QLineEdit() self.email = QLineEdit() self.profession = QLineEdit() self.address = QLineEdit() self.mobile = QLineEdit() self.notes = QTextEdit() self.birthday = QDateEdit() self.birthday.setCalendarPopup(True) self.birthday.setDisplayFormat("dd.MM.yyyy") self.image = ImageSelector() self.image.setMinimumWidth(250) self.layout.addWidget(title, 0, 0, 1, 2) self.layout.addWidget(QLabel("Id"), 1, 0) self.layout.addWidget(self.number, 2, 0) self.layout.addWidget(QLabel("Name"), 3, 0) self.layout.addWidget(self.name, 4, 0) self.layout.addWidget(QLabel("Address"), 5, 0) self.layout.addWidget(self.address, 6, 0) self.layout.addWidget(QLabel("Email"), 7, 0) self.layout.addWidget(self.email, 8, 0) self.layout.addWidget(QLabel("Mobile"), 9, 0) self.layout.addWidget(self.mobile, 10, 0) self.layout.addWidget(QLabel("Profession"), 11, 0) self.layout.addWidget(self.profession, 12, 0) self.layout.addWidget(QLabel("Notes"), 17, 0) self.layout.addWidget(self.notes, 18, 0, 1, 2) self.layout.addWidget(self.image, 2, 1, 7, 1) self.layout.addWidget(QLabel("Birhday"), 9, 1) self.layout.addWidget(self.birthday, 10, 1) self.setLayout(self.layout) self.reload() self.number.textEdited.connect(self.clientChanged) self.name.textEdited.connect(self.clientChanged) self.address.textEdited.connect(self.clientChanged) self.email.textEdited.connect(self.clientChanged) self.mobile.textEdited.connect(self.clientChanged) self.profession.textEdited.connect(self.clientChanged) self.notes.textChanged.connect(self.clientChanged) self.birthday.dateChanged.connect(self.clientChanged) self.image.clicked.connect(self.seek)
def __init__(self): super().__init__() self.changed = False self.setAutoFillBackground(True) grid = QGridLayout() seek = QPushButton("...") seek.setMaximumWidth(50) self.adminlabel = QLineEdit() self.adminlabel.setMaximumWidth(200) titleLabel = QLabel("Slide") fnt = titleLabel.font() fnt.setPointSize(16) fnt.setBold(True) titleLabel.setFont(fnt) self.source = QLineEdit() self.image = ImageSelector() self.image.setImage(QImage(":/images/image_placeholder.png")) close = FlatButton(":/images/close_normal.png", ":/images/close_hover.png") close.setToolTip("Close Editor") font = QFont() font.setFamily("Courier") font.setFixedPitch(True) font.setPointSize(13) self.innerHtml = QTextEdit() self.innerHtml.setMaximumHeight(120) self.innerHtml.setFont(font) self.innerHtml.setAcceptRichText(False) self.innerHtml.setLineWrapMode(QTextEdit.NoWrap) metrics = QFontMetrics(font) self.innerHtml.setTabStopWidth(4 * metrics.width(' ')) XmlHighlighter(self.innerHtml.document()) grid.addWidget(titleLabel, 0, 0) grid.addWidget(close, 0, 2, 1, 1, Qt.AlignRight) grid.addWidget(QLabel("Path"), 1, 0) grid.addWidget(self.source, 2, 0, 1, 2) grid.addWidget(seek, 2, 2) grid.addWidget(self.image, 3, 0, 1, 2) grid.setRowStretch(3, 1) grid.addWidget(QLabel("Inner HTML"), 4, 0) grid.addWidget(self.innerHtml, 5, 0, 1, 3) grid.addWidget(QLabel("Admin Label"), 6, 0) grid.addWidget(self.adminlabel, 7, 0) self.setLayout(grid) close.clicked.connect(self.closeEditor) self.image.clicked.connect(self.seek) seek.clicked.connect(self.seek) self.source.textChanged.connect(self.contentChanged) self.adminlabel.textChanged.connect(self.contentChanged) self.innerHtml.textChanged.connect(self.contentChanged)
def addTableCellButtons(self, item, twi): tcb = MenuEditorTableCellButtons() tcb.setMenuItem(item) self.tree.setItemWidget(twi, 3, tcb) self.tree.setColumnWidth(3, tcb.sizeHint().width()) if item.isSubitem(): tcb.deleteItem.connect(self.deleteSubItem) tcb.itemLeft.connect(self.itemLeft) else: tcb.deleteItem.connect(self.deleteItem) tcb.itemUp.connect(self.itemUp) tcb.itemDown.connect(self.itemDown) tcb.itemRight.connect(self.itemRight) tcb.editItem.connect(self.editItem) imgs = ImageSelector() imgs.setToolTip("Click to select image, right click to reset image") imgs.setItem(item) imgs.setMaximumSize(24, 24) isw = QWidget() vbox = QVBoxLayout() vbox.addWidget(imgs) isw.setLayout(vbox) if not item.icon: imgs.setImage(QImage(":/images/image_placeholder.png")) else: imgs.setImage(QImage(self.site.source_path + "/" + item.icon)) self.tree.setItemWidget(twi, 2, isw) imgs.clicked.connect(self.iconClicked)
def __init__(self): ElementEditorInterface.__init__(self) self.site = None self.animation = "" self.class_name = "ImageEditor" self.display_name = QCoreApplication.translate("ImageEditor", "Image") self.tag_name = "Image" self.version = "1.0" self.icon = QImage(":/imageeditor.png") self.changed = False self.setAutoFillBackground(True) grid = QGridLayout() self.source = QLineEdit() self.alt = QLineEdit() self.alt.setMaximumWidth(200) self.title = QLineEdit() self.title.setMaximumWidth(200) self.link = QLineEdit() self.link.setMaximumWidth(200) self.adminlabel = QLineEdit() self.adminlabel.setMaximumWidth(200) seek = QPushButton("...") seek.setMaximumWidth(50) titleLabel = QLabel( QCoreApplication.translate("ImageEditor", "Image Module")) fnt = titleLabel.font() fnt.setPointSize(16) fnt.setBold(True) titleLabel.setFont(fnt) self.image = ImageSelector() self.image.setImage(QImage(":/images/image_placeholder.png")) close = FlatButton(":/images/close_normal.png", ":/images/close_hover.png") close.setToolTip(QCoreApplication.translate("general", "Close Editor")) self.animation_type = QListWidget() self.animation_type.addItem("None") self.animation_type.addItem("Attention Seekers") self.animation_type.addItem("Bouncing Entrances") self.animation_type.addItem("Bouncing Exits") self.animation_type.addItem("Fading Entrances") self.animation_type.addItem("Fading Exits") self.animation_type.addItem("Flippers") self.animation_type.addItem("Rotating Entrances") self.animation_type.addItem("Rotating Exits") self.animation_type.addItem("Sliding Entrances") self.animation_type.addItem("Sliding Exits") self.animation_type.addItem("Zoom Entrances") self.animation_type.addItem("Zoom Exits") self.animation_subtype = QListWidget() grid.addWidget(titleLabel, 0, 0) grid.addWidget(close, 0, 3, 1, 1, Qt.AlignRight) grid.addWidget( QLabel(QCoreApplication.translate("ImageEditor", "Path")), 1, 0) grid.addWidget(self.source, 2, 0, 1, 3) grid.addWidget(seek, 2, 3) grid.addWidget(self.image, 3, 0, 1, 4) grid.setRowStretch(3, 1) grid.addWidget( QLabel(QCoreApplication.translate("ImageEditor", "Alt")), 6, 0) grid.addWidget(self.alt, 7, 0) grid.addWidget( QLabel(QCoreApplication.translate("ImageEditor", "Title")), 8, 0) grid.addWidget(self.title, 9, 0) grid.addWidget( QLabel(QCoreApplication.translate("ImageEditor", "Hyperlink")), 10, 0) grid.addWidget(self.link, 11, 0) grid.addWidget( QLabel(QCoreApplication.translate("ImageEditor", "Animation")), 6, 1) grid.addWidget(self.animation_type, 7, 1, 8, 1) grid.addWidget(self.animation_subtype, 7, 2, 8, 1) grid.addWidget( QLabel(QCoreApplication.translate("ImageEditor", "Admin Label")), 13, 0) grid.addWidget(self.adminlabel, 14, 0) self.setLayout(grid) close.clicked.connect(self.closeEditor) self.source.textChanged.connect(self.contentChanged) self.alt.textChanged.connect(self.contentChanged) self.title.textChanged.connect(self.contentChanged) self.link.textChanged.connect(self.contentChanged) self.adminlabel.textChanged.connect(self.contentChanged) seek.clicked.connect(self.seek) self.image.clicked.connect(self.seek) self.animation_type.currentTextChanged.connect( self.animationTypeChanged) self.animation_subtype.currentTextChanged.connect(self.contentChanged)
class ImageEditor(ElementEditorInterface): def __init__(self): ElementEditorInterface.__init__(self) self.site = None self.animation = "" self.class_name = "ImageEditor" self.display_name = QCoreApplication.translate("ImageEditor", "Image") self.tag_name = "Image" self.version = "1.0" self.icon = QImage(":/imageeditor.png") self.changed = False self.setAutoFillBackground(True) grid = QGridLayout() self.source = QLineEdit() self.alt = QLineEdit() self.alt.setMaximumWidth(200) self.title = QLineEdit() self.title.setMaximumWidth(200) self.link = QLineEdit() self.link.setMaximumWidth(200) self.adminlabel = QLineEdit() self.adminlabel.setMaximumWidth(200) seek = QPushButton("...") seek.setMaximumWidth(50) titleLabel = QLabel( QCoreApplication.translate("ImageEditor", "Image Module")) fnt = titleLabel.font() fnt.setPointSize(16) fnt.setBold(True) titleLabel.setFont(fnt) self.image = ImageSelector() self.image.setImage(QImage(":/images/image_placeholder.png")) close = FlatButton(":/images/close_normal.png", ":/images/close_hover.png") close.setToolTip(QCoreApplication.translate("general", "Close Editor")) self.animation_type = QListWidget() self.animation_type.addItem("None") self.animation_type.addItem("Attention Seekers") self.animation_type.addItem("Bouncing Entrances") self.animation_type.addItem("Bouncing Exits") self.animation_type.addItem("Fading Entrances") self.animation_type.addItem("Fading Exits") self.animation_type.addItem("Flippers") self.animation_type.addItem("Rotating Entrances") self.animation_type.addItem("Rotating Exits") self.animation_type.addItem("Sliding Entrances") self.animation_type.addItem("Sliding Exits") self.animation_type.addItem("Zoom Entrances") self.animation_type.addItem("Zoom Exits") self.animation_subtype = QListWidget() grid.addWidget(titleLabel, 0, 0) grid.addWidget(close, 0, 3, 1, 1, Qt.AlignRight) grid.addWidget( QLabel(QCoreApplication.translate("ImageEditor", "Path")), 1, 0) grid.addWidget(self.source, 2, 0, 1, 3) grid.addWidget(seek, 2, 3) grid.addWidget(self.image, 3, 0, 1, 4) grid.setRowStretch(3, 1) grid.addWidget( QLabel(QCoreApplication.translate("ImageEditor", "Alt")), 6, 0) grid.addWidget(self.alt, 7, 0) grid.addWidget( QLabel(QCoreApplication.translate("ImageEditor", "Title")), 8, 0) grid.addWidget(self.title, 9, 0) grid.addWidget( QLabel(QCoreApplication.translate("ImageEditor", "Hyperlink")), 10, 0) grid.addWidget(self.link, 11, 0) grid.addWidget( QLabel(QCoreApplication.translate("ImageEditor", "Animation")), 6, 1) grid.addWidget(self.animation_type, 7, 1, 8, 1) grid.addWidget(self.animation_subtype, 7, 2, 8, 1) grid.addWidget( QLabel(QCoreApplication.translate("ImageEditor", "Admin Label")), 13, 0) grid.addWidget(self.adminlabel, 14, 0) self.setLayout(grid) close.clicked.connect(self.closeEditor) self.source.textChanged.connect(self.contentChanged) self.alt.textChanged.connect(self.contentChanged) self.title.textChanged.connect(self.contentChanged) self.link.textChanged.connect(self.contentChanged) self.adminlabel.textChanged.connect(self.contentChanged) seek.clicked.connect(self.seek) self.image.clicked.connect(self.seek) self.animation_type.currentTextChanged.connect( self.animationTypeChanged) self.animation_subtype.currentTextChanged.connect(self.contentChanged) def animationTypeChanged(self, type): self.contentChanged() self.animation_subtype.clear() if type == "Attention Seekers": self.addSubItem("Bounce", "bounce") self.addSubItem("Flash", "flash") self.addSubItem("Pulse", "pulse") self.addSubItem("Shake", "shake") self.addSubItem("Swing", "swing") self.addSubItem("Tada", "tada") self.addSubItem("Wobble", "wobble") elif type == "Bouncing Entrances": self.addSubItem("Bounce In", "bounceIn") self.addSubItem("Bounce In Down", "bounceInDown") self.addSubItem("Bounce In Left", "bounceInLeft") self.addSubItem("Bounce In Right", "bounceInRight") self.addSubItem("Bounce In Up", "bounceInUp") elif type == "Bouncing Exits": self.addSubItem("Bounce Out", "bounceOut") self.addSubItem("Bounce Out Down", "bounceOutDown") self.addSubItem("Bounce Out Left", "bounceOutLeft") self.addSubItem("Bounce Out Right", "bounceOutRight") self.addSubItem("Bounce Out Up", "bounceOutUp") elif type == "Fading Entrances": self.addSubItem("Fade In", "fadeIn") self.addSubItem("Fade In Down", "fadeInDown") self.addSubItem("Fade In Down Big", "fadeInDownBig") self.addSubItem("Fade In Left", "fadeInLeft") self.addSubItem("Fade In Left Big", "fadeInLeftBig") self.addSubItem("Fade In Right", "fadeInRight") self.addSubItem("Fade In Right Big", "fadeInRightBig") self.addSubItem("Fade In Up", "fadeInUp") self.addSubItem("Fade In Up Big", "fadeInUpBig") elif type == "Fading Exits": self.addSubItem("Fade Out", "fadeOut") self.addSubItem("Fade Out Down", "fadeOutDown") self.addSubItem("Fade Out Down Big", "fadeOutDownBig") self.addSubItem("Fade Out Left", "fadeOutLeft") self.addSubItem("Fade Out Left Big", "fadeOutLeftBig") self.addSubItem("Fade Out Right", "fadeOutRight") self.addSubItem("Fade Out Right Big", "fadeOutRightBig") self.addSubItem("Fade Out Up", "fadeOutUp") self.addSubItem("Fade Out Up Big", "fadeOutUpBig") elif type == "Flippers": self.addSubItem("Flip", "flip") self.addSubItem("Flip In X", "flipInX") self.addSubItem("Flip In Y", "flipInY") self.addSubItem("Flip Out X", "flipOutX") self.addSubItem("Flip Out Y", "flipOutY") elif type == "Rotating Entrances": self.addSubItem("Rotate In", "rotateIn") self.addSubItem("Rotate In Down Left", "rotateInDownLeft") self.addSubItem("Rotate In Down Right", "rotateInDownRight") self.addSubItem("Rotate In Up Left", "rotateInUpLeft") self.addSubItem("Rotate In Up Right", "rotateInUpRight") elif type == "Rotating Exits": self.addSubItem("Rotate Out", "rotateOut") self.addSubItem("Rotate Out Down Left", "rotateOutDownLeft") self.addSubItem("Rotate Out Down Right", "rotateOutDownRight") self.addSubItem("Rotate Out Up Left", "rotateOutUpLeft") self.addSubItem("Rotate Out Up Right", "rotateOutUpRight") elif type == "Sliding Entrances": self.addSubItem("Slide In Up", "slideInUp") self.addSubItem("Slide In Down", "slideInDown") self.addSubItem("Slide In Left", "slideInLeft") self.addSubItem("Slide In Right", "slideInRight") elif type == "Sliding Exits": self.addSubItem("Slide Out Up", "slideOutUp") self.addSubItem("Slide Out Down", "slideOutDown") self.addSubItem("Slide Out Left", "slideOutLeft") self.addSubItem("Slide Out Right", "slideOutRight") elif type == "Zoom Entrances": self.addSubItem("Zoom In", "zoomIn") self.addSubItem("Zoom In Down", "zoomInDown") self.addSubItem("Zoom In Left", "zoomInLeft") self.addSubItem("Zoom In Right", "zoomInRight") self.addSubItem("Zoom In Up", "zoomInUp") elif type == "Zoom Exits": self.addSubItem("Zoom Out", "zoomOut") self.addSubItem("Zoom Out Down", "zoomOutDown") self.addSubItem("Zoom Out Left", "zoomOutLeft") self.addSubItem("Zoom Out Right", "zoomOutRight") self.addSubItem("Zoom Out Up", "zoomOutUp") def addSubItem(self, title, data): item = QListWidgetItem(title) item.setData(Qt.UserRole, data) self.animation_subtype.addItem(item) def closeEditor(self): if self.changed: self.content.src = self.source.text() self.content.alt = self.alt.text() self.content.title = self.title.text() self.content.link = self.link.text() self.content.adminlabel = self.adminlabel.text() if self.animation_type.currentItem(): self.content.animation_type = self.animation_type.currentItem( ).data(Qt.DisplayRole) if self.animation_subtype.currentItem(): self.content.animation = self.animation_subtype.currentItem( ).data(Qt.UserRole) else: self.content.animation = "" #foreach(QString attName, m_attributes.keys()) #{ # stream.writeAttribute(attName, m_attributes.value(attName)) #} self.close.emit() def getDefaultContent(self): return Image() def setContent(self, content): self.content = content self.source.setText(content.src) self.alt.setText(content.alt) self.title.setText(content.title) self.link.setText(content.link) self.adminlabel.setText(content.adminlabel) if content.src: self.image.setImage( QImage( os.path.join(self.site.source_path, "assets", "images", content.src))) if self.animation_type: index = self.findData(self.animation_type, content.animation_type, Qt.DisplayRole) self.animation_type.setCurrentRow(index) if self.animation_subtype: index = self.findData(self.animation_subtype, content.animation, Qt.UserRole) self.animation_subtype.setCurrentRow(index) else: self.animation_type.setCurrentRow(0) self.changed = False def findData(self, list, value, role): if not value: return -1 for index in range(list.count()): item = list.item(index) if item.data(role) == value: return index return -1 def getContent(self): return self.content def seek(self): fileName = "" dialog = QFileDialog() dialog.setFileMode(QFileDialog.AnyFile) dialog.setNameFilter( QCoreApplication.translate("ImageEditor", "Images") + " (*.png *.gif *.jpg)All (*)") dialog.setWindowTitle( QCoreApplication.translate("ImageEditor", "Load Image")) dialog.setOption(QFileDialog.DontUseNativeDialog, True) dialog.setAcceptMode(QFileDialog.AcceptOpen) if dialog.exec(): fileName = dialog.selectedFiles()[0] del dialog if not fileName: return # copy file to assets dir name = os.path.basename(fileName).replace(" ", "_") path = os.path.join(self.site.source_path, "assets", "images", name) self.source.setText(os.path.basename(path)) try: shutil.copy(fileName, path) except shutil.SameFileError: pass # also copy file to deploy dir for previews dpath = os.path.join(self.site.source_path, self.site.output, "assets", "images", name) try: shutil.copy(fileName, dpath) except shutil.SameFileError: pass self.image.setImage(QImage(path)) self.contentChanged() def registerContenType(self): qmlRegisterType(Image, 'ImageEditor', 1, 0, 'Image') def getImportString(self): return "import ImageEditor 1.0\n" def pluginStyles(self): return "<link href=\"assets/plugins/animate/animate.css\" rel=\"stylesheet\" type=\"text/css\"/>\n" def installAssets(self, assets_path): assets = QDir(assets_path) assets.mkdir("plugins") assets.cd("plugins") assets.mkdir("animate") dst = os.path.join(assets_path, "plugins", "animate", "animate.css") QFile.copy(":/animate.css", dst) os.chmod( dst, stat.S_IWRITE | stat.S_IREAD | stat.S_IWGRP | stat.S_IRGRP | stat.S_IROTH)
class SiteSettingsEditor(UndoableEditor): def __init__(self, win, site): UndoableEditor.__init__(self) self.win = win self.site = site self.title = QLineEdit() self.titleLabel.setText(QCoreApplication.translate("SiteSettingsEditor", "Site Settings")) self.filename = site.source_path + "/" + site.filename self.description = QLineEdit() self.copyright = QLineEdit() self.keywords = QLineEdit() self.author = QLineEdit() self.output = QLineEdit() self.logo = QLineEdit() seekButton = QPushButton("...") self.image = ImageSelector() self.image.setImage(QImage(":/images/image_placeholder.png")) self.copyright.setPlaceholderText("© 2019 your name") self.publisher = QComboBox() for key in Plugins.publishPluginNames(): pi = Plugins.getPublishPlugin(key) if pi: self.publisher.addItem(pi.display_name, key) vbox = QVBoxLayout() vbox.addStretch() self.layout.addWidget(QLabel(QCoreApplication.translate("SiteSettingsEditor", "Title")), 1, 0) self.layout.addWidget(self.title, 2, 0) self.layout.addWidget(QLabel(QCoreApplication.translate("SiteSettingsEditor", "Description")), 3, 0) self.layout.addWidget(self.description, 4, 0, 1, 3) self.layout.addWidget(QLabel(QCoreApplication.translate("SiteSettingsEditor", "Copyright")), 5, 0) self.layout.addWidget(self.copyright, 6, 0, 1, 3) self.layout.addWidget(QLabel(QCoreApplication.translate("SiteSettingsEditor", "Keywords")), 7, 0) self.layout.addWidget(self.keywords, 8, 0, 1, 3) self.layout.addWidget(QLabel(QCoreApplication.translate("SiteSettingsEditor", "Author")), 9, 0) self.layout.addWidget(self.author, 10, 0) self.layout.addWidget(QLabel(QCoreApplication.translate("SiteSettingsEditor", "Output directory (relative to to source dir)")), 11, 0) self.layout.addWidget(self.output, 12, 0) self.layout.addWidget(QLabel(QCoreApplication.translate("SiteSettingsEditor", "Logo")), 13, 0) self.layout.addWidget(self.logo, 14, 0) self.layout.addWidget(seekButton, 14, 1) self.layout.addWidget(self.image, 15, 0, 1, 2) self.layout.setRowStretch(15, 1) self.layout.addWidget(QLabel(QCoreApplication.translate("SiteSettingsEditor", "Plugin to be used for publishing")), 16, 0) self.layout.addWidget(self.publisher, 17, 0) self.layout.addLayout(vbox, 18, 0) self.load() self.title.editingFinished.connect(self.titleChanged) self.description.editingFinished.connect(self.descriptionChanged) self.copyright.editingFinished.connect(self.copyrightChanged) self.keywords.editingFinished.connect(self.keywordsChanged) self.author.editingFinished.connect(self.authorChanged) self.output.editingFinished.connect(self.outputChanged) self.logo.editingFinished.connect(self.logoChanged) self.publisher.currentIndexChanged.connect(self.publisherChanged) seekButton.clicked.connect(self.seek) def seek(self): fileName = "" dialog = QFileDialog() dialog.setFileMode(QFileDialog.AnyFile) dialog.setNameFilter("Images (*.png *.gif *.jpg);;All (*)") dialog.setWindowTitle(QCoreApplication.translate("SiteSettingsEditor", "Load Image")) dialog.setOption(QFileDialog.DontUseNativeDialog, True) dialog.setAcceptMode(QFileDialog.AcceptOpen) if dialog.exec(): fileName = dialog.selectedFiles()[0] del dialog if not fileName: return # copy file to assets dir name = os.path.basename(fileName).replace(" ", "_") path = os.path.join(self.site.source_path, "assets", "images", name) self.logo.setText(os.path.basename(path)) shutil.copy(fileName, path) # also copy file to deploy dir for previews dpath = os.path.join(self.site.source_path, self.site.output, "assets", "images", name) shutil.copy(fileName, dpath) self.image.setImage(QImage(path)) self.contentChanged("logo changed") def load(self): oldTitle = self.site.title self.title.setText(self.site.title) self.description.setText(self.site.description) self.copyright.setText(self.site.copyright) self.keywords.setText(self.site.keywords) self.author.setText(self.site.author) self.output.setText(self.site.output) self.logo.setText(self.site.logo) if self.site.logo: self.image.setImage(QImage(os.path.join(self.site.source_path, "assets", "images", self.site.logo))) index = self.publisher.findData(self.site.publisher) self.publisher.setCurrentIndex(index) #if oldTitle != self.site.title: # os.rename(Generator.sitesPath() + "/" + oldTitle, Generator.sitesPath() + "/" + self.site.title) # print("renaming1: " + Generator.sitesPath() + "/" + oldTitle) # self.win.statusBar().showMessage("Site settings have been loaded. Site should be rebuilded. Output path has been renamed to " + self.site.title()) def save(self): if self.site.title != self.title.text(): oldTitle = self.site.title self.site.title = self.title.text() self.site.save() #os.rename(Generator.sitesPath() + "/" + oldTitle, Generator.sitesPath() + "/" + self.site.title) self.win.statusBar().showMessage(QCoreApplication.translate("SiteSettingsEditor", "Site settings have been saved. Site should be rebuilded on the dashboard.") + " " + QCoreApplication.translate("SiteSettingsEditor", "Output path has been renamed to") + " " + self.title.text()) else: self.site.author = self.author.text() self.site.output = self.output.text() self.site.copyright = self.copyright.text() self.site.description = self.description.text() self.site.keywords = self.keywords.text() self.site.publisher = self.publisher.currentData() if not self.site.publisher: self.site.publisher = "" Plugins.setActualPublishPlugin(self.site.publisher) self.site.logo = self.logo.text() self.site.save() self.win.statusBar().showMessage(QCoreApplication.translate("SiteSettingsEditor", "Site settings have been saved. Site should be rebuilded on the dashboard.")) def publisherChanged(self, publisher): if self.site.publisher != publisher: self.contentChanged("publisher changed") def titleChanged(self): if self.site.title != self.title.text(): self.contentChanged("title changed") def authorChanged(self): if self.site.author != self.author.text(): self.contentChanged("author changed") def outputChanged(self): if self.site.output != self.output.text(): self.contentChanged("output changed") def logoChanged(self): if self.site.logo != self.logo.text(): self.contentChanged("logo changed") def descriptionChanged(self): if self.site.description != self.description.text(): self.contentChanged("description changed") def copyrightChanged(self): if self.site.copyright != self.copyright.text(): self.contentChanged("copyright changed") def keywordsChanged(self): if self.site.keywords != self.keywords.text(): self.contentChanged("keywords changed")
class SlideEditor(AnimateableEditor): def __init__(self): super().__init__() self.changed = False self.setAutoFillBackground(True) grid = QGridLayout() seek = QPushButton("...") seek.setMaximumWidth(50) self.adminlabel = QLineEdit() self.adminlabel.setMaximumWidth(200) titleLabel = QLabel("Slide") fnt = titleLabel.font() fnt.setPointSize(16) fnt.setBold(True) titleLabel.setFont(fnt) self.source = QLineEdit() self.image = ImageSelector() self.image.setImage(QImage(":/images/image_placeholder.png")) close = FlatButton(":/images/close_normal.png", ":/images/close_hover.png") close.setToolTip("Close Editor") font = QFont() font.setFamily("Courier") font.setFixedPitch(True) font.setPointSize(13) self.innerHtml = QTextEdit() self.innerHtml.setMaximumHeight(120) self.innerHtml.setFont(font) self.innerHtml.setAcceptRichText(False) self.innerHtml.setLineWrapMode(QTextEdit.NoWrap) metrics = QFontMetrics(font) self.innerHtml.setTabStopWidth(4 * metrics.width(' ')) XmlHighlighter(self.innerHtml.document()) grid.addWidget(titleLabel, 0, 0) grid.addWidget(close, 0, 2, 1, 1, Qt.AlignRight) grid.addWidget(QLabel("Path"), 1, 0) grid.addWidget(self.source, 2, 0, 1, 2) grid.addWidget(seek, 2, 2) grid.addWidget(self.image, 3, 0, 1, 2) grid.setRowStretch(3, 1) grid.addWidget(QLabel("Inner HTML"), 4, 0) grid.addWidget(self.innerHtml, 5, 0, 1, 3) grid.addWidget(QLabel("Admin Label"), 6, 0) grid.addWidget(self.adminlabel, 7, 0) self.setLayout(grid) close.clicked.connect(self.closeEditor) self.image.clicked.connect(self.seek) seek.clicked.connect(self.seek) self.source.textChanged.connect(self.contentChanged) self.adminlabel.textChanged.connect(self.contentChanged) self.innerHtml.textChanged.connect(self.contentChanged) def setSite(self, site): self.site = site def setSlide(self, slide): self.slide = slide self.source.setText(slide.src) if slide.src: self.image.setImage(QImage(slide.src)) else: self.image.setImage(QImage(":/images/image_placeholder.png")) self.innerHtml.setPlainText(html.unescape(slide._text)) self.adminlabel.setText(slide._adminlabel) self.changed = False def closeEditor(self): if self.changed: self.slide.src = self.source.text() self.slide._text = html.escape(self.innerHtml.toPlainText()) self.slide._adminlabel = self.adminlabel.text() self.closes.emit() def seek(self): fileName = "" dialog = QFileDialog() dialog.setFileMode(QFileDialog.AnyFile) dialog.setNameFilter("Images (*.png *.gif *.jpg)All (*)") dialog.setWindowTitle("Load Image") dialog.setOption(QFileDialog.DontUseNativeDialog, True) dialog.setAcceptMode(QFileDialog.AcceptOpen) if dialog.exec(): fileName = dialog.selectedFiles()[0] if not fileName: return # copy file to assets dir info = QFileInfo(fileName) name = info.fileName().replace(" ", "_") path = os.path.join(self.site.source_path, "assets", "images", name) self.source.setText(path) try: shutil.copy2(fileName, path) except shutil.SameFileError: pass # just ignore # also copy file to deploy dir for previews dpath = os.path.join(self.site.source_path, self.site.output, "docs", "assets", "images", name) shutil.copy2(fileName, dpath) self.image.setImage(QImage(path)) self.contentChanged()
class SlideEditor(AnimateableEditor): def __init__(self): super().__init__() self.changed = False self.setAutoFillBackground(True) grid = QGridLayout() seek = QPushButton("...") seek.setMaximumWidth(50) self.adminlabel = QLineEdit() self.adminlabel.setMaximumWidth(200) titleLabel = QLabel(QCoreApplication.translate("CarouselEditor", "Slide")) fnt = titleLabel.font() fnt.setPointSize(16) fnt.setBold(True) titleLabel.setFont(fnt) self.source = QLineEdit() self.image = ImageSelector() self.image.setImage(QImage(":/images/image_placeholder.png")) close = FlatButton(":/images/close_normal.png", ":/images/close_hover.png") close.setToolTip(QCoreApplication.translate("general", "Close Editor")) font = QFont() font.setFamily("Courier") font.setFixedPitch(True) font.setPointSize(13) self.innerHtml = QTextEdit() self.innerHtml.setMaximumHeight(120) self.innerHtml.setFont(font) self.innerHtml.setAcceptRichText(False) self.innerHtml.setLineWrapMode(QTextEdit.NoWrap) metrics = QFontMetrics(font) self.innerHtml.setTabStopWidth(4 * metrics.width(' ')) XmlHighlighter(self.innerHtml.document()) grid.addWidget(titleLabel, 0, 0) grid.addWidget(close, 0, 2, 1, 1, Qt.AlignRight) grid.addWidget(QLabel(QCoreApplication.translate("CarouselEditor", "Path")), 1, 0) grid.addWidget(self.source, 2, 0, 1, 2) grid.addWidget(seek, 2, 2) grid.addWidget(self.image, 3, 0, 1, 2) grid.setRowStretch(3, 1) grid.addWidget(QLabel(QCoreApplication.translate("CarouselEditor", "Inner HTML")), 4, 0) grid.addWidget(self.innerHtml, 5, 0, 1, 3) grid.addWidget(QLabel(QCoreApplication.translate("general", "Admin Label")), 6, 0) grid.addWidget(self.adminlabel, 7, 0) self.setLayout(grid) close.clicked.connect(self.closeEditor) #connect(self.image, SIGNAL(clicked()), this, SLOT(seek())) #connect(seek, SIGNAL(clicked(bool)), this, SLOT(seek())) #connect(self.source, SIGNAL(textChanged(QString)), this, SLOT(contentChanged())) #connect(self.adminlabel, SIGNAL(textChanged(QString)), this, SLOT(contentChanged())) #connect(self.innerHtml, SIGNAL(textChanged()), this, SLOT(contentChanged())) def setSlide(self, slide): self.slide = slide self.source.setText(slide.src) if slide.src: self.image.setImage(QImage(slide.src)) else: self.image.setImage(QImage(":/images/image_placeholder.png")) self.innerHtml.setPlainText(slide._text) self.adminlabel.setText(slide._adminlabel) self.changed = False def closeEditor(self): if self.changed: self.slide.setSource(self.source.text()) self.slide.setInnerHtml(self.innerHtml.toPlainText()) self.slide.setAdminLabel(self.adminlabel.text()) self.closes.emit()
def __init__(self, win): QWidget.__init__(self) self.win = win self.id = 0 title = QLabel("Client Data") fnt = title.font() fnt.setPointSize(20) fnt.setBold(True) title.setFont(fnt) self.layout = QGridLayout() self.layout.setColumnStretch(0, 1) self.number = QLineEdit() self.name = QLineEdit() self.email = QLineEdit() self.profession = QLineEdit() self.address = QLineEdit() self.mobile = QLineEdit() self.reason = QLineEdit() self.how = QLineEdit() self.fiscal = QLineEdit() self.notes = QTextEdit() self.birthday = QDateEdit() self.birthday.setCalendarPopup(True) self.birthday.setDisplayFormat("dd.MM.yyyy") self.firstcontact = QDateEdit(QDate.currentDate()) self.firstcontact.setDisplayFormat("dd.MM.yyyy") self.firstcontact.setCalendarPopup(True) self.image = ImageSelector() self.image.setImage(QImage(":/images/image_placeholder.png")) self.image.setMinimumWidth(250) self.layout.addWidget(title, 0, 0, 1, 2) self.layout.addWidget(QLabel("Number"), 1, 0) self.layout.addWidget(self.number, 2, 0) self.layout.addWidget(QLabel("Name"), 3, 0) self.layout.addWidget(self.name, 4, 0) self.layout.addWidget(QLabel("Address"), 5, 0) self.layout.addWidget(self.address, 6, 0) self.layout.addWidget(QLabel("Email"), 7, 0) self.layout.addWidget(self.email, 8, 0) self.layout.addWidget(QLabel("Mobile"), 9, 0) self.layout.addWidget(self.mobile, 10, 0) self.layout.addWidget(QLabel("Profession"), 11, 0) self.layout.addWidget(self.profession, 12, 0) self.layout.addWidget(QLabel("Reason"), 13, 0) self.layout.addWidget(self.reason, 14, 0) self.layout.addWidget(QLabel("How did you get here?"), 15, 0) self.layout.addWidget(self.how, 16, 0) self.layout.addWidget(QLabel("Notes"), 17, 0) self.layout.addWidget(self.notes, 18, 0, 1, 2) self.layout.addWidget(self.image, 2, 1, 7, 1) self.layout.addWidget(QLabel("Birhday"), 9, 1) self.layout.addWidget(self.birthday, 10, 1) self.layout.addWidget(QLabel("First Contact"), 11, 1) self.layout.addWidget(self.firstcontact, 12, 1) self.layout.addWidget(QLabel("Fiscal"), 13, 1) self.layout.addWidget(self.fiscal, 14, 1, 1, 1) self.setLayout(self.layout) self.reload() self.number.textEdited.connect(self.clientChanged) self.name.textEdited.connect(self.clientChanged) self.address.textEdited.connect(self.clientChanged) self.email.textEdited.connect(self.clientChanged) self.mobile.textEdited.connect(self.clientChanged) self.profession.textEdited.connect(self.clientChanged) self.reason.textEdited.connect(self.clientChanged) self.how.textEdited.connect(self.clientChanged) self.notes.textChanged.connect(self.clientChanged) self.fiscal.textEdited.connect(self.clientChanged) self.birthday.dateChanged.connect(self.clientChanged) self.firstcontact.dateChanged.connect(self.clientChanged)
class ClientEditor(QWidget): def __init__(self, win): QWidget.__init__(self) self.win = win self.id = 0 title = QLabel("Client Data") fnt = title.font() fnt.setPointSize(20) fnt.setBold(True) title.setFont(fnt) self.layout = QGridLayout() self.layout.setColumnStretch(0, 1) self.number = QLineEdit() self.name = QLineEdit() self.email = QLineEdit() self.profession = QLineEdit() self.address = QLineEdit() self.mobile = QLineEdit() self.reason = QLineEdit() self.how = QLineEdit() self.fiscal = QLineEdit() self.notes = QTextEdit() self.birthday = QDateEdit() self.birthday.setCalendarPopup(True) self.birthday.setDisplayFormat("dd.MM.yyyy") self.firstcontact = QDateEdit(QDate.currentDate()) self.firstcontact.setDisplayFormat("dd.MM.yyyy") self.firstcontact.setCalendarPopup(True) self.image = ImageSelector() self.image.setImage(QImage(":/images/image_placeholder.png")) self.image.setMinimumWidth(250) self.layout.addWidget(title, 0, 0, 1, 2) self.layout.addWidget(QLabel("Number"), 1, 0) self.layout.addWidget(self.number, 2, 0) self.layout.addWidget(QLabel("Name"), 3, 0) self.layout.addWidget(self.name, 4, 0) self.layout.addWidget(QLabel("Address"), 5, 0) self.layout.addWidget(self.address, 6, 0) self.layout.addWidget(QLabel("Email"), 7, 0) self.layout.addWidget(self.email, 8, 0) self.layout.addWidget(QLabel("Mobile"), 9, 0) self.layout.addWidget(self.mobile, 10, 0) self.layout.addWidget(QLabel("Profession"), 11, 0) self.layout.addWidget(self.profession, 12, 0) self.layout.addWidget(QLabel("Reason"), 13, 0) self.layout.addWidget(self.reason, 14, 0) self.layout.addWidget(QLabel("How did you get here?"), 15, 0) self.layout.addWidget(self.how, 16, 0) self.layout.addWidget(QLabel("Notes"), 17, 0) self.layout.addWidget(self.notes, 18, 0, 1, 2) self.layout.addWidget(self.image, 2, 1, 7, 1) self.layout.addWidget(QLabel("Birhday"), 9, 1) self.layout.addWidget(self.birthday, 10, 1) self.layout.addWidget(QLabel("First Contact"), 11, 1) self.layout.addWidget(self.firstcontact, 12, 1) self.layout.addWidget(QLabel("Fiscal"), 13, 1) self.layout.addWidget(self.fiscal, 14, 1, 1, 1) self.setLayout(self.layout) self.reload() self.number.textEdited.connect(self.clientChanged) self.name.textEdited.connect(self.clientChanged) self.address.textEdited.connect(self.clientChanged) self.email.textEdited.connect(self.clientChanged) self.mobile.textEdited.connect(self.clientChanged) self.profession.textEdited.connect(self.clientChanged) self.reason.textEdited.connect(self.clientChanged) self.how.textEdited.connect(self.clientChanged) self.notes.textChanged.connect(self.clientChanged) self.fiscal.textEdited.connect(self.clientChanged) self.birthday.dateChanged.connect(self.clientChanged) self.firstcontact.dateChanged.connect(self.clientChanged) def reload(self): self.loading = True if self.win.client: self.number.setText(self.win.client["number"]) self.name.setText(self.win.client["name"]) self.address.setText(self.win.client["address"]) self.email.setText(self.win.client["email"]) self.mobile.setText(self.win.client["mobile"]) self.profession.setText(self.win.client["profession"]) self.reason.setText(self.win.client["reason"]) self.how.setText(self.win.client["how"]) self.notes.setText(self.win.client["notes"]) self.birthday.setDate( QDate(self.win.client["birthday_year"], self.win.client["birthday_month"], self.win.client["birthday_day"])) self.firstcontact.setDate( QDate(self.win.client["first_contact_year"], self.win.client["first_contact_month"], self.win.client["first_contact_day"])) self.fiscal.setText(self.win.client["fiscal"]) else: self.number.setText("") self.name.setText("") self.address.setText("") self.email.setText("") self.mobile.setText("") self.profession.setText("") self.reason.setText("") self.how.setText("") self.notes.setText("") self.fiscal.setText("") self.birthday.setDate(QDate(1900, 1, 1)) self.firstcontact.setDate(QDate(1900, 1, 1)) self.loading = False def clientChanged(self): if self.loading: return self.win.client["number"] = self.number.text() self.win.client["name"] = self.name.text() self.win.client["address"] = self.address.text() self.win.client["email"] = self.email.text() self.win.client["mobile"] = self.mobile.text() self.win.client["profession"] = self.profession.text() self.win.client["reason"] = self.reason.text() self.win.client["how"] = self.how.text() self.win.client["notes"] = self.notes.toPlainText() self.win.client["fiscal"] = self.fiscal.text() self.win.client["birthday_year"] = self.birthday.date().year() self.win.client["birthday_month"] = self.birthday.date().month() self.win.client["birthday_day"] = self.birthday.date().day() self.win.client["first_contact_year"] = self.firstcontact.date().year() self.win.client["first_contact_month"] = self.firstcontact.date( ).month() self.win.client["first_contact_day"] = self.firstcontact.date().day() self.win.clients.update(self.win.client, doc_ids=[self.win.client.doc_id]) self.win.updateClient()
class ClientEditor(QWidget): def __init__(self, win): QWidget.__init__(self) self.win = win self.id = 0 title = QLabel("Client Data") fnt = title.font() fnt.setPointSize(20) fnt.setBold(True) title.setFont(fnt) self.layout = QGridLayout() self.layout.setColumnStretch(0, 1) self.number = QLineEdit() self.name = QLineEdit() self.email = QLineEdit() self.profession = QLineEdit() self.address = QLineEdit() self.mobile = QLineEdit() self.notes = QTextEdit() self.birthday = QDateEdit() self.birthday.setCalendarPopup(True) self.birthday.setDisplayFormat("dd.MM.yyyy") self.image = ImageSelector() self.image.setMinimumWidth(250) self.layout.addWidget(title, 0, 0, 1, 2) self.layout.addWidget(QLabel("Id"), 1, 0) self.layout.addWidget(self.number, 2, 0) self.layout.addWidget(QLabel("Name"), 3, 0) self.layout.addWidget(self.name, 4, 0) self.layout.addWidget(QLabel("Address"), 5, 0) self.layout.addWidget(self.address, 6, 0) self.layout.addWidget(QLabel("Email"), 7, 0) self.layout.addWidget(self.email, 8, 0) self.layout.addWidget(QLabel("Mobile"), 9, 0) self.layout.addWidget(self.mobile, 10, 0) self.layout.addWidget(QLabel("Profession"), 11, 0) self.layout.addWidget(self.profession, 12, 0) self.layout.addWidget(QLabel("Notes"), 17, 0) self.layout.addWidget(self.notes, 18, 0, 1, 2) self.layout.addWidget(self.image, 2, 1, 7, 1) self.layout.addWidget(QLabel("Birhday"), 9, 1) self.layout.addWidget(self.birthday, 10, 1) self.setLayout(self.layout) self.reload() self.number.textEdited.connect(self.clientChanged) self.name.textEdited.connect(self.clientChanged) self.address.textEdited.connect(self.clientChanged) self.email.textEdited.connect(self.clientChanged) self.mobile.textEdited.connect(self.clientChanged) self.profession.textEdited.connect(self.clientChanged) self.notes.textChanged.connect(self.clientChanged) self.birthday.dateChanged.connect(self.clientChanged) self.image.clicked.connect(self.seek) def reload(self): self.loading = True if self.win.client: self.number.setText(self.win.client["number"]) self.name.setText(self.win.client["name"]) self.address.setText(self.win.client["address"]) self.email.setText(self.win.client["email"]) self.mobile.setText(self.win.client["mobile"]) self.profession.setText(self.win.client["profession"]) self.notes.setText(self.win.client["notes"]) self.birthday.setDate( QDate(self.win.client["birthday_year"], self.win.client["birthday_month"], self.win.client["birthday_day"])) name = os.path.join(str(self.win.client.doc_id) + ".png") path = os.path.join(self.win.database, "images", name) if os.path.exists(path): self.image.setImage(QImage(path)) else: self.image.setImage(QImage(":/images/image_placeholder.png")) else: self.number.setText("") self.name.setText("") self.address.setText("") self.email.setText("") self.mobile.setText("") self.profession.setText("") self.notes.setText("") self.birthday.setDate(QDate(1900, 1, 1)) self.image.setImage(QImage(":/images/image_placeholder.png")) self.loading = False def clientChanged(self): if self.loading: return self.win.client["number"] = self.number.text() self.win.client["name"] = self.name.text() self.win.client["address"] = self.address.text() self.win.client["email"] = self.email.text() self.win.client["mobile"] = self.mobile.text() self.win.client["profession"] = self.profession.text() self.win.client["notes"] = self.notes.toPlainText() self.win.client["birthday_year"] = self.birthday.date().year() self.win.client["birthday_month"] = self.birthday.date().month() self.win.client["birthday_day"] = self.birthday.date().day() self.win.clients.update(self.win.client, doc_ids=[self.win.client.doc_id]) self.win.updateClient() def seek(self): fileName = "" dialog = QFileDialog() dialog.setFileMode(QFileDialog.AnyFile) dialog.setNameFilter("Images (*.png *.gif *.jpg);;All (*)") dialog.setWindowTitle("Load Image") dialog.setOption(QFileDialog.DontUseNativeDialog, True) dialog.setAcceptMode(QFileDialog.AcceptOpen) if dialog.exec(): fileName = dialog.selectedFiles()[0] del dialog if not fileName: return # copy file to database dir name = os.path.join(str(self.win.client.doc_id) + ".png") path = os.path.join(self.win.database, "images", name) shutil.copy(fileName, path) self.image.setImage(QImage(path)) self.clientChanged()