summaryrefslogtreecommitdiffstats
path: root/tqtinterface/qt4/tools/designer/examples/richedit/richedit.ui.h
diff options
context:
space:
mode:
Diffstat (limited to 'tqtinterface/qt4/tools/designer/examples/richedit/richedit.ui.h')
-rw-r--r--tqtinterface/qt4/tools/designer/examples/richedit/richedit.ui.h120
1 files changed, 120 insertions, 0 deletions
diff --git a/tqtinterface/qt4/tools/designer/examples/richedit/richedit.ui.h b/tqtinterface/qt4/tools/designer/examples/richedit/richedit.ui.h
new file mode 100644
index 0000000..087d8d0
--- /dev/null
+++ b/tqtinterface/qt4/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" ) )
+ tqApp->exit();
+}
+
+void EditorForm::fileNew()
+{
+ if ( saveAndContinue( "New" ) )
+ textEdit->clear();
+}
+
+void EditorForm::fileOpen()
+{
+ if ( saveAndContinue( "Open" ) ) {
+ TQString fn( TQFileDialog::getOpenFileName(
+ TQString(),
+ "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->tqsetAlignment( TQt::AlignLeft );
+ else if ( align == rightAlignAction )
+ textEdit->tqsetAlignment( TQt::AlignRight );
+ else if ( align == centerAlignAction )
+ textEdit->tqsetAlignment( TQt::AlignCenter );
+}
+
+int EditorForm::saveAndContinue(const TQString & action)
+{
+ int continueAction = 1;
+
+ if ( textEdit->isModified() ) {
+ switch( TQMessageBox::information(
+ this, "Rich Edit",
+ "The document tqcontains 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;
+}
+