author | llornkcor <llornkcor> | 2002-10-09 19:06:44 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-10-09 19:06:44 (UTC) |
commit | 381ad47090a7dcf79d1d4fd11fff87ff565fb36b (patch) (side-by-side diff) | |
tree | a7f3b79d610dea39515936d8361fd1c03c9da4d8 /core/apps/textedit/textedit.cpp | |
parent | c80818d8388c07c1606a70306aea0c9a1e17ea3c (diff) | |
download | opie-381ad47090a7dcf79d1d4fd11fff87ff565fb36b.zip opie-381ad47090a7dcf79d1d4fd11fff87ff565fb36b.tar.gz opie-381ad47090a7dcf79d1d4fd11fff87ff565fb36b.tar.bz2 |
split features up
Diffstat (limited to 'core/apps/textedit/textedit.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/apps/textedit/textedit.cpp | 70 |
1 files changed, 47 insertions, 23 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp index 6844023..f3937b1 100644 --- a/core/apps/textedit/textedit.cpp +++ b/core/apps/textedit/textedit.cpp @@ -253,24 +253,26 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) ); setIcon( Resource::loadPixmap( "TextEditor" ) ); QPEToolBar *bar = new QPEToolBar( this ); bar->setHorizontalStretchable( TRUE ); menu = bar; QPEMenuBar *mb = new QPEMenuBar( bar ); QPopupMenu *file = new QPopupMenu( this ); QPopupMenu *edit = new QPopupMenu( this ); + QPopupMenu *advancedMenu = new QPopupMenu(this); + font = new QPopupMenu( this ); bar = new QPEToolBar( this ); editBar = bar; QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); a->addTo( bar ); a->addTo( file ); a = new QAction( tr( "Open" ), Resource::loadPixmap( "fileopen" ), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); @@ -315,45 +317,54 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) a->addTo( edit ); zin = new QAction( tr("Zoom in"), QString::null, 0, this, 0 ); connect( zin, SIGNAL( activated() ), this, SLOT( zoomIn() ) ); zin->addTo( font ); zout = new QAction( tr("Zoom out"), QString::null, 0, this, 0 ); connect( zout, SIGNAL( activated() ), this, SLOT( zoomOut() ) ); zout->addTo( font ); font->insertSeparator(); +// font->insertSeparator(); + font->insertItem(tr("Font"), this, SLOT(changeFont()) ); + font->insertSeparator(); + font->insertItem(tr("Advanced Features"), advancedMenu); + QAction *wa = new QAction( tr("Wrap lines"), QString::null, 0, this, 0 ); connect( wa, SIGNAL( toggled(bool) ), this, SLOT( setWordWrap(bool) ) ); wa->setToggleAction(TRUE); - wa->addTo( font ); - - font->insertSeparator(); - font->insertItem(tr("Font"), this, SLOT(changeFont()) ); - - font->insertSeparator(); + wa->addTo( advancedMenu); nStart = new QAction( tr("Start with new file"), QString::null, 0, this, 0 ); connect( nStart, SIGNAL( toggled(bool) ), this, SLOT( changeStartConfig(bool) ) ); nStart->setToggleAction(TRUE); - nStart->addTo( font ); + nStart->addTo( advancedMenu ); - nAdvanced = new QAction( tr("Advanced features"), QString::null, 0, this, 0 ); - connect( nAdvanced, SIGNAL( toggled(bool) ), this, SLOT( doAdvanced(bool) ) ); + nAdvanced = new QAction( tr("Prompt on Exit"), QString::null, 0, this, 0 ); + connect( nAdvanced, SIGNAL( toggled(bool) ), this, SLOT( doPrompt(bool) ) ); nAdvanced->setToggleAction(TRUE); - nAdvanced->addTo( font ); + nAdvanced->addTo( advancedMenu ); + + desktopAction = new QAction( tr("Always open linked file"), QString::null, 0, this, 0 ); + connect( desktopAction, SIGNAL( toggled(bool) ), this, SLOT( doDesktop(bool) ) ); + desktopAction->setToggleAction(TRUE); + desktopAction->addTo( advancedMenu); + filePermAction = new QAction( tr("File Permissions"), QString::null, 0, this, 0 ); + connect( filePermAction, SIGNAL( toggled(bool) ), this, SLOT( doFilePerms(bool) ) ); + filePermAction->setToggleAction(TRUE); + filePermAction->addTo( advancedMenu); font->insertSeparator(); font->insertItem(tr("About"), this, SLOT( doAbout()) ); mb->insertItem( tr( "File" ), file ); mb->insertItem( tr( "Edit" ), edit ); mb->insertItem( tr( "View" ), font ); searchBar = new QPEToolBar(this); addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); @@ -377,80 +388,85 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f ) a = new QAction( tr( "Delete" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( editDelete() ) ); a->addTo( edit ); searchBar->hide(); editor = new QpeEditor( this ); setCentralWidget( editor ); editor->setFrameStyle( QFrame::Panel | QFrame::Sunken ); connect( editor, SIGNAL( textChanged() ), this, SLOT( editorChanged() ) ); Config cfg("TextEdit"); - - cfg. setGroup ( "Font" ); + cfg. setGroup ( "Font" ); QFont defaultFont = editor-> font ( ); QString family = cfg. readEntry ( "Family", defaultFont. family ( )); int size = cfg. readNumEntry ( "Size", defaultFont. pointSize ( )); int weight = cfg. readNumEntry ( "Weight", defaultFont. weight ( )); bool italic = cfg. readBoolEntry ( "Italic", defaultFont. italic ( )); defaultFont = QFont ( family, size, weight, italic ); editor-> setFont ( defaultFont ); updateCaption(); cfg.setGroup ( "View" ); - useAdvancedFeatures = cfg. readBoolEntry ( "AdvancedFeatures", false ); - - if ( useAdvancedFeatures ) - nAdvanced-> setOn ( true ); - + promptExit = cfg. readBoolEntry ( "PromptExit", false ); + openDesktop = cfg. readBoolEntry ( "OpenDesktop", true ); + filePerms = cfg. readBoolEntry ( "FilePermissions", false ); + + if(promptExit ) nAdvanced->setOn ( true ); + if(openDesktop) desktopAction->setOn ( true ); + if(filePerms) filePermAction->setOn ( true ); + bool wrap = cfg. readBoolEntry ( "Wrap", true ); wa-> setOn ( wrap ); setWordWrap ( wrap ); if(cfg.readEntry("startNew","TRUE") == "TRUE") { nStart->setOn(TRUE); fileNew(); } else { fileOpen(); } viewSelection = cfg.readNumEntry( "FileView", 0 ); } TextEdit::~TextEdit() { - if( edited1 & !useAdvancedFeatures ) + if( edited1 & promptExit ) saveAs(); } void TextEdit::cleanUp() { qDebug("cleanUp");// save(); Config cfg ( "TextEdit" ); cfg. setGroup ( "Font" ); QFont f = editor->font(); cfg. writeEntry ( "Family", f. family ( )); cfg. writeEntry ( "Size", f. pointSize ( )); cfg. writeEntry ( "Weight", f. weight ( )); cfg. writeEntry ( "Italic", f. italic ( )); cfg. setGroup ( "View" ); cfg. writeEntry ( "Wrap", editor-> wordWrap ( ) == QMultiLineEdit::WidgetWidth ); cfg. writeEntry ( "FileView", viewSelection ); - cfg. writeEntry ( "AdvancedFeatures", useAdvancedFeatures ); + + cfg. writeEntry ( "PromptExit", promptExit ); + cfg. writeEntry ( "OpenDesktop", openDesktop ); + cfg. writeEntry ( "FilePermissions", filePerms ); } void TextEdit::accept() { if( edited1) saveAs(); exit(0); } void TextEdit::zoomIn() { setFontSize(editor->font().pointSize()+1,FALSE); } @@ -613,25 +629,25 @@ void TextEdit::newFile( const DocLnk &f ) { editor->setFocus(); doc = new DocLnk(nf); currentFileName = "Unnamed"; qDebug("newFile "+currentFileName); updateCaption( currentFileName); // editor->setEdited( FALSE); } void TextEdit::openFile( const QString &f ) { qDebug("filename is "+ f); QString filer; // bFromDocView = TRUE; - if(f.find(".desktop",0,TRUE) != -1 && useAdvancedFeatures) { + if(f.find(".desktop",0,TRUE) != -1 && !openDesktop) { switch ( QMessageBox::warning(this,tr("Text Editor"), tr("Text Editor has detected<BR>you selected a <B>.desktop</B> file.<BR>Open <B>.desktop</B> file or <B>linked</B> file?"), tr(".desktop File"),tr("Linked Document"),0,1,1) ) { case 0: filer = f; break; case 1: DocLnk sf(f); filer = sf.file(); break; } @@ -814,25 +830,25 @@ bool TextEdit::saveAs() { nf.setFile( fileNm); doc = new DocLnk(nf); // editor->setText(rt); // qDebug("openFile doclnk "+currentFileName); doc->setName( currentFileName); updateCaption( currentFileName); FileManager fm; if ( !fm.saveFile( *doc, rt ) ) { return false; } - if( useAdvancedFeatures ) { + if( filePerms ) { filePermissions *filePerm; filePerm = new filePermissions(this, tr("Permissions"),true,0,(const QString &)fileNm); filePerm->showMaximized(); filePerm->exec(); if( filePerm) delete filePerm; } } editor->setEdited( false); edited1 = false; edited = false; @@ -938,24 +954,32 @@ void TextEdit::receive(const QCString&msg, const QByteArray&) { if ( msg == "setDocument(QString)" ) { qDebug("bugger all"); } } void TextEdit::doAbout() { QMessageBox::about(0,tr("Text Edit"),tr("Text Edit is copyright<BR>" "2000 Trolltech AS, and<BR>" "2002 by <B>L. J. Potter <BR>llornkcor@handhelds.org</B><BR>" "and is licensed under the GPL")); } -void TextEdit::doAdvanced(bool b) { - useAdvancedFeatures=b; +void TextEdit::doPrompt(bool b) { + promptExit=b; +} + +void TextEdit::doDesktop(bool b) { + openDesktop=b; +} + +void TextEdit::doFilePerms(bool b) { + filePerms=b; } void TextEdit::editPasteTimeDate() { #ifndef QT_NO_CLIPBOARD QClipboard *cb = QApplication::clipboard(); QDateTime dt = QDateTime::currentDateTime(); cb->setText( dt.toString()); editor->paste(); #endif } |