summaryrefslogtreecommitdiff
path: root/core
authorllornkcor <llornkcor>2002-03-19 00:25:30 (UTC)
committer llornkcor <llornkcor>2002-03-19 00:25:30 (UTC)
commitfbe272267851eeda20bf48aee9a01ac4dd1143c2 (patch) (side-by-side diff)
treeeb2aaea05277d12e66c712c7d109c99c1e3f8f7d /core
parent342ac04976065864b351c6b36087a483a8932da7 (diff)
downloadopie-fbe272267851eeda20bf48aee9a01ac4dd1143c2.zip
opie-fbe272267851eeda20bf48aee9a01ac4dd1143c2.tar.gz
opie-fbe272267851eeda20bf48aee9a01ac4dd1143c2.tar.bz2
added config entry
Diffstat (limited to 'core') (more/less context) (show whitespace changes)
-rw-r--r--core/apps/textedit/textedit.cpp9
-rw-r--r--core/apps/textedit/textedit.h1
-rw-r--r--core/apps/textedit/textedit.pro4
3 files changed, 10 insertions, 4 deletions
diff --git a/core/apps/textedit/textedit.cpp b/core/apps/textedit/textedit.cpp
index d3f5fb4..f56d5d3 100644
--- a/core/apps/textedit/textedit.cpp
+++ b/core/apps/textedit/textedit.cpp
@@ -191,96 +191,97 @@ void QpeEditor::find ( const QString &txt, bool caseSensitive,
wrap = FALSE;
// emit searchWrapped();
} else {
getCursorPosition( &line, &col );
}
//ignore backwards for now....
if ( !backwards ) {
for ( ; ; ) {
if ( line >= numLines() ) {
wrap = TRUE;
//emit notFound();
break;
}
int findCol = getString( line )->find( txt, col, caseSensitive );
if ( findCol >= 0 ) {
setCursorPosition( line, findCol, FALSE );
col = findCol + txt.length();
setCursorPosition( line, col, TRUE );
//found = TRUE;
break;
}
line++;
col = 0;
}
}
}
#else
#error "Must make a QpeEditor that inherits QTextEdit"
#endif
static const int nfontsizes = 6;
static const int fontsize[nfontsizes] = {8,10,12,14,18,24};
TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
: QMainWindow( parent, name, f ), bFromDocView( FALSE )
{
doc = 0;
edited=FALSE;
edited1=FALSE;
setToolBarsMovable( FALSE );
+ connect( qApp,SIGNAL( aboutToQuit()),SLOT( cleanUp()) );
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 );
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() ) );
a->addTo( bar );
a->addTo( file );
a = new QAction( tr( "Save" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( save() ) );
file->insertSeparator();
a->addTo( file );
a = new QAction( tr( "Save As" ), QPixmap(( const char** ) filesave_xpm ) , QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( saveAs() ) );
a->addTo( file );
a = new QAction( tr( "Cut" ), Resource::loadPixmap( "cut" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
a->addTo( editBar );
a->addTo( edit );
a = new QAction( tr( "Copy" ), Resource::loadPixmap( "copy" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) );
a->addTo( editBar );
a->addTo( edit );
a = new QAction( tr( "Paste" ), Resource::loadPixmap( "paste" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
a->addTo( editBar );
a->addTo( edit );
@@ -362,108 +363,112 @@ TextEdit::TextEdit( QWidget *parent, const char *name, WFlags f )
a->addTo( edit );
a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) );
a->addTo( searchBar );
edit->insertSeparator();
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() ) );
resize( 200, 300 );
// setFontSize(defsize,TRUE);
FontDatabase fdb;
QFont defaultFont=editor->font();
QFontInfo fontInfo(defaultFont);
cfg.setGroup("Font");
QString family = cfg.readEntry("Family", fontInfo.family());
QString style = cfg.readEntry("Style", fdb.styleString(defaultFont));
int i_size = cfg.readNumEntry("Size", fontInfo.pointSize()/10);
QString charSet = cfg.readEntry("CharSet", QFont::encodingName( fontInfo.charSet()) );
defaultFont = fdb.font(family,style,i_size,charSet);
editor->setFont( defaultFont);
wa->setOn(wrap);
updateCaption();
cfg.setGroup("View");
if(cfg.readEntry("startNew","TRUE") == "TRUE") {
nStart->setOn(TRUE);
fileNew();
} else {
fileOpen();
}
viewSelection = cfg.readNumEntry( "FileView", 0 );
}
-TextEdit::~TextEdit()
+void TextEdit::cleanUp()
{
// save();
-
Config cfg("TextEdit");
cfg.setGroup("View");
QFont f = editor->font();
cfg.writeEntry("FontSize",f.pointSize());
cfg.writeEntry("Bold",f.bold());
cfg.writeEntry("Italic",f.italic());
cfg.writeEntry("Wrap",editor->wordWrap() == QMultiLineEdit::WidgetWidth);
cfg.writeEntry( "FileView", viewSelection );
+
+}
+
+TextEdit::~TextEdit()
+{
}
void TextEdit::zoomIn()
{
setFontSize(editor->font().pointSize()+1,FALSE);
}
void TextEdit::zoomOut()
{
setFontSize(editor->font().pointSize()-1,TRUE);
}
void TextEdit::setFontSize(int sz, bool round_down_not_up)
{
int s=10;
for (int i=0; i<nfontsizes; i++) {
if ( fontsize[i] == sz ) {
s = sz;
break;
} else if ( round_down_not_up ) {
if ( fontsize[i] < sz )
s = fontsize[i];
} else {
if ( fontsize[i] > sz ) {
s = fontsize[i];
break;
}
}
}
QFont f = editor->font();
f.setPointSize(s);
editor->setFont(f);
zin->setEnabled(s != fontsize[nfontsizes-1]);
zout->setEnabled(s != fontsize[0]);
}
void TextEdit::setBold(bool y)
{
QFont f = editor->font();
f.setBold(y);
editor->setFont(f);
}
void TextEdit::setItalic(bool y)
{
diff --git a/core/apps/textedit/textedit.h b/core/apps/textedit/textedit.h
index aca2933..a70b581 100644
--- a/core/apps/textedit/textedit.h
+++ b/core/apps/textedit/textedit.h
@@ -26,94 +26,95 @@
#include "fileBrowser.h"
#include "fileSaver.h"
#include <qpe/filemanager.h>
#include <qmainwindow.h>
#include <qmultilineedit.h>
#include <qlist.h>
#include <qmap.h>
class QAction;
class QWidgetStack;
class QToolButton;
class QPopupMenu;
class QToolBar;
class QLineEdit;
class QAction;
class FileSelector;
class QpeEditor;
class QPopupMenu;
class TextEdit : public QMainWindow
{
Q_OBJECT
public:
TextEdit( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
~TextEdit();
QPopupMenu *font;
QAction *nStart;
bool edited, edited1;
void openFile( const QString & );
public slots:
void editorChanged();
protected:
void closeEvent( QCloseEvent *e );
private slots:
void setDocument(const QString&);
void changeFont();
void fileNew();
void fileRevert();
void fileOpen();
void changeStartConfig(bool);
bool save();
bool saveAs();
+ void cleanUp();
void editCut();
void editCopy();
void editPaste();
void editFind();
void editDelete();
void findNext();
void findClose();
void search();
void accept();
void newFile( const DocLnk & );
void openFile( const DocLnk & );
void showEditTools();
void zoomIn();
void zoomOut();
void setBold(bool y);
void setItalic(bool y);
void setWordWrap(bool y);
private:
void colorChanged( const QColor &c );
void clear();
void updateCaption( const QString &name=QString::null );
void setFontSize(int sz, bool round_down_not_up);
private:
fileSaver *fileSaveDlg;
fileBrowser *browseForFiles;
QpeEditor* editor;
QToolBar *menu, *editBar, *searchBar;
QLineEdit *searchEdit;
DocLnk *doc;
bool searchVisible;
bool bFromDocView;
int viewSelection;
QAction *zin, *zout;
QString currentFileName;
};
#endif
diff --git a/core/apps/textedit/textedit.pro b/core/apps/textedit/textedit.pro
index 1301aed..37ddf15 100644
--- a/core/apps/textedit/textedit.pro
+++ b/core/apps/textedit/textedit.pro
@@ -1,15 +1,15 @@
TEMPLATE = app
CONFIG += qt warn_on release
DESTDIR = $(OPIEDIR)/bin
HEADERS = textedit.h fileBrowser.h fontDialog.h fileSaver.h filePermissions.h inputDialog.h
SOURCES = main.cpp textedit.cpp fileBrowser.cpp fontDialog.cpp fileSaver.cpp filePermissions.cpp inputDialog.cpp
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
LIBS += -lqpe
TARGET = textedit
-TRANSLATIONS = ../i18n/de/textedit.ts
-TRANSLATIONS = ../i18n/pt_BR/textedit.ts
+TRANSLATIONS += ../i18n/de/textedit.ts
+TRANSLATIONS += ../i18n/pt_BR/textedit.ts