-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error msg and routine renaming (with bugfix) #90
Merged
wenatuhs
merged 10 commits into
xopt-org:1.1.3
from
shamin-slac:error_msg_and_routine_renaming
Sep 11, 2024
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
7f2aaeb
added expandable error message box for objective validation error
7c69c48
added routine renaming feature (routine name is still routine db prim…
482e1e4
fix update_routine to query record to update with name instead of old…
5063092
added expandable error message box for objective validation error
031ef1b
added routine renaming feature (routine name is still routine db prim…
3012ce3
fix update_routine to query record to update with name instead of old…
b7d83f0
Merge pull request #1 from slaclab/1.1.3
shamin-slac 55487b9
Fix renaming routine while editing other properties
841b250
Resolve merge conflict
e50723e
Merge branch 'error_msg_and_routine_renaming' of github.com:shamin-sl…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import sys | ||
from PyQt5.QtWidgets import (QDialog, QMessageBox, QVBoxLayout, QHBoxLayout, | ||
QLabel, QPushButton, QTextEdit) | ||
from PyQt5.QtGui import QTextOption, QFont, QFontDatabase | ||
|
||
class ExpandableMessageBox(QDialog): | ||
def __init__(self, icon=None, title="Message", text="", detailedText="", parent=None): | ||
super().__init__(parent) | ||
|
||
# Main layout | ||
mainLayout = QVBoxLayout(self) | ||
|
||
# Top layout for icon and main text | ||
topLayout = QHBoxLayout() | ||
self.iconLabel = QLabel() | ||
if icon: | ||
self.iconLabel.setPixmap(icon.pixmap(64, 64)) | ||
self.textLabel = QLabel(text) | ||
self.textLabel.setMinimumWidth(280) | ||
self.textLabel.setWordWrap(True) | ||
font = QFont() | ||
font.setBold(True) | ||
self.textLabel.setFont(font) | ||
topLayout.addWidget(self.iconLabel) | ||
topLayout.addWidget(self.textLabel, 1) | ||
mainLayout.addLayout(topLayout) | ||
|
||
# Detailed text area setup | ||
self.detailedTextWidget = QTextEdit() | ||
self.detailedTextWidget.setText(detailedText) | ||
self.detailedTextWidget.setReadOnly(True) | ||
self.detailedTextWidget.setWordWrapMode(QTextOption.WrapAtWordBoundaryOrAnywhere) | ||
monoFont = QFontDatabase.systemFont(QFontDatabase.FixedFont) | ||
monoFont.setPointSize(9) | ||
self.detailedTextWidget.setFont(monoFont) | ||
self.detailedTextWidget.setVisible(False) # Initially hidden | ||
|
||
# Button to show/hide details | ||
self.toggleButton = QPushButton("Show Details") | ||
self.toggleButton.clicked.connect(self.toggle_details) | ||
|
||
# Layouts for the detailed text and button | ||
self.detailLayout = QVBoxLayout() | ||
self.detailLayout.addWidget(self.detailedTextWidget) | ||
self.detailLayout.addWidget(self.toggleButton) | ||
|
||
# Add the detailed text area and toggle button to the main layout | ||
mainLayout.addLayout(self.detailLayout) | ||
|
||
# Buttons | ||
self.buttonBox = QHBoxLayout() | ||
self.okButton = QPushButton("OK") | ||
self.okButton.clicked.connect(self.accept) | ||
self.buttonBox.addWidget(self.okButton) | ||
mainLayout.addLayout(self.buttonBox) | ||
|
||
# Set window properties | ||
self.setWindowTitle(title) | ||
self.resize(420, 250) | ||
|
||
def toggle_details(self): | ||
if self.detailedTextWidget.isVisible(): | ||
self.detailedTextWidget.setVisible(False) | ||
self.toggleButton.setText("Show Details") | ||
else: | ||
self.detailedTextWidget.setVisible(True) | ||
self.toggleButton.setText("Hide Details") | ||
|
||
def setText(self, text): | ||
self.textLabel.setText(text) | ||
|
||
def setDetailedText(self, detailedText): | ||
self.detailedTextWidget.setText(detailedText) | ||
|
||
def setIcon(self, icon): | ||
# This maps the QMessageBox icons to the QDialog | ||
iconMap = { | ||
QMessageBox.Information: QMessageBox.standardIcon(QMessageBox.Information), | ||
QMessageBox.Warning: QMessageBox.standardIcon(QMessageBox.Warning), | ||
QMessageBox.Critical: QMessageBox.standardIcon(QMessageBox.Critical), | ||
QMessageBox.Question: QMessageBox.standardIcon(QMessageBox.Question), | ||
} | ||
standardIcon = iconMap.get(icon) | ||
if standardIcon: | ||
self.iconLabel.setPixmap(standardIcon) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that we got several duplicated lines possibly due to conflict merging, not a big deal though. I'll just merge and fix it :)