mirror of
				https://github.com/subsurface/subsurface.git
				synced 2025-02-19 22:16:15 +00:00 
			
		
		
		
	filter: create a primitive "create filter preset" dialog
The dialog asks the user for a name and warns if the name already exists, i.e. an old filter preset will be overwritten. Possibly, this should contain an auto-completion facility in the case that the user wants to overwrite old presets. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
		
							parent
							
								
									2f5223035a
								
							
						
					
					
						commit
						581eb1f563
					
				
					 7 changed files with 194 additions and 24 deletions
				
			
		|  | @ -12,6 +12,7 @@ | |||
| #include <QClipboard> | ||||
| 
 | ||||
| #include "core/file.h" | ||||
| #include "core/filterpreset.h" | ||||
| #include "core/divesite.h" | ||||
| #include "desktop-widgets/mainwindow.h" | ||||
| #include "core/qthelper.h" | ||||
|  | @ -478,6 +479,31 @@ void DiveComponentSelection::buttonClicked(QAbstractButton *button) | |||
| 	} | ||||
| } | ||||
| 
 | ||||
| AddFilterPresetDialog::AddFilterPresetDialog(QWidget *parent) | ||||
| { | ||||
| 	ui.setupUi(this); | ||||
| 	connect(ui.name, &QLineEdit::textChanged, this, &AddFilterPresetDialog::nameChanged); | ||||
| 	connect(ui.buttonBox, &QDialogButtonBox::accepted, this, &AddFilterPresetDialog::accept); | ||||
| 	connect(ui.buttonBox, &QDialogButtonBox::rejected, this, &AddFilterPresetDialog::reject); | ||||
| 	nameChanged(ui.name->text()); | ||||
| } | ||||
| 
 | ||||
| void AddFilterPresetDialog::nameChanged(const QString &text) | ||||
| { | ||||
| 	QString trimmed = text.trimmed(); | ||||
| 	bool isEmpty = trimmed.isEmpty(); | ||||
| 	bool exists = !isEmpty && filter_preset_id(trimmed) >= 0; | ||||
| 	ui.duplicateWarning->setVisible(exists); | ||||
| 	ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!isEmpty); | ||||
| } | ||||
| 
 | ||||
| QString AddFilterPresetDialog::doit() | ||||
| { | ||||
| 	if (exec() == QDialog::Accepted) | ||||
| 		return ui.name->text().trimmed(); | ||||
| 	return QString(); | ||||
| } | ||||
| 
 | ||||
| TextHyperlinkEventFilter::TextHyperlinkEventFilter(QTextEdit *txtEdit) : QObject(txtEdit), | ||||
| 	textEdit(txtEdit), | ||||
| 	scrollView(textEdit->viewport()) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue