From d796c9dd933ab96ec83b9a634feedd5d32e1ba3f Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Tue, 8 Nov 2011 12:31:36 -0600 Subject: Test conversion to TQt3 from Qt3 8c6fc1f8e35fd264dd01c582ca5e7549b32ab731 --- tools/designer/examples/richedit/richedit.ui.h | 120 +++++++++++++++++++++++++ 1 file changed, 120 insertions(+) create mode 100644 tools/designer/examples/richedit/richedit.ui.h (limited to 'tools/designer/examples/richedit/richedit.ui.h') diff --git a/tools/designer/examples/richedit/richedit.ui.h b/tools/designer/examples/richedit/richedit.ui.h new file mode 100644 index 000000000..e6acad87b --- /dev/null +++ b/tools/designer/examples/richedit/richedit.ui.h @@ -0,0 +1,120 @@ +void EditorForm::init() +{ + textEdit->setFocus(); + + TQFontDatabase fonts; + fontComboBox->insertStringList( fonts.families() ); + TQString font = textEdit->family(); + font = font.lower(); + for ( int i = 0 ; i < fontComboBox->count(); i++ ) { + if ( font == fontComboBox->text( i ) ) { + fontComboBox->setCurrentItem( i ); + break; + } + } +} + +void EditorForm::fileExit() +{ + if ( saveAndContinue( "Exit" ) ) + qApp->exit(); +} + +void EditorForm::fileNew() +{ + if ( saveAndContinue( "New" ) ) + textEdit->clear(); +} + +void EditorForm::fileOpen() +{ + if ( saveAndContinue( "Open" ) ) { + TQString fn( TQFileDialog::getOpenFileName( + TQString::null, + "Rich Text Files (*.htm*)", this ) ); + if ( !fn.isEmpty() ) { + fileName = fn; + TQFile file( fileName ); + if ( file.open( IO_ReadOnly ) ) { + TQTextStream ts( &file ); + textEdit->setText( ts.read() ); + } + } + } +} + +void EditorForm::fileSave() +{ + if ( fileName.isEmpty() ) { + fileSaveAs(); + } else { + TQFile f( fileName ); + if ( f.open( IO_WriteOnly ) ) { + TQTextStream ts( &f ); + ts << textEdit->text(); + textEdit->setModified( FALSE ); + } + } +} + +void EditorForm::fileSaveAs() +{ + TQString fn = TQFileDialog::getSaveFileName( + "", "Rich Text Files (*.htm*)", this ); + if ( !fn.isEmpty() ) { + fileName = fn; + fileSave(); + } +} + +void EditorForm::helpAbout() +{ + +} + +void EditorForm::helpContents() +{ + +} + +void EditorForm::helpIndex() +{ + +} + +void EditorForm::changeAlignment(TQAction * align) +{ + if ( align == leftAlignAction ) + textEdit->setAlignment( TQt::AlignLeft ); + else if ( align == rightAlignAction ) + textEdit->setAlignment( TQt::AlignRight ); + else if ( align == centerAlignAction ) + textEdit->setAlignment( TQt::AlignCenter ); +} + +int EditorForm::saveAndContinue(const TQString & action) +{ + int continueAction = 1; + + if ( textEdit->isModified() ) { + switch( TQMessageBox::information( + this, "Rich Edit", + "The document contains unsaved changes.\n" + "Do you want to save the changes?", + "&Save", "&Don't Save", "&Cancel " + action, + 0, // Enter == button 0 + 2 ) ) { // Escape == button 2 + case 0: // Save; continue + fileSave(); + break; + case 1: // Do not save; continue + break; + case 2: // Cancel + continueAction = 0; + break; + } + } + + return continueAction; +} + -- cgit v1.2.1