diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | 2bda8f7717adf28da4af0d34fb82f63d2868c31d (patch) | |
tree | 8d927b7b47a90c4adb646482a52613f58acd6f8c /kedit | |
download | tdeutils-2bda8f7717adf28da4af0d34fb82f63d2868c31d.tar.gz tdeutils-2bda8f7717adf28da4af0d34fb82f63d2868c31d.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdeutils@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kedit')
-rw-r--r-- | kedit/ChangeLog | 113 | ||||
-rw-r--r-- | kedit/KEdit.desktop | 82 | ||||
-rw-r--r-- | kedit/Makefile.am | 35 | ||||
-rw-r--r-- | kedit/README | 192 | ||||
-rw-r--r-- | kedit/TODO | 6 | ||||
-rw-r--r-- | kedit/color.ui | 129 | ||||
-rw-r--r-- | kedit/kedit.cpp | 1377 | ||||
-rw-r--r-- | kedit/kedit.h | 229 | ||||
-rw-r--r-- | kedit/kedit.kcfg | 45 | ||||
-rw-r--r-- | kedit/keditui.rc | 10 | ||||
-rw-r--r-- | kedit/ktextfiledlg.cpp | 212 | ||||
-rw-r--r-- | kedit/ktextfiledlg.h | 74 | ||||
-rw-r--r-- | kedit/misc.ui | 123 | ||||
-rw-r--r-- | kedit/misc.ui.h | 14 | ||||
-rw-r--r-- | kedit/pixmaps/Makefile.am | 2 | ||||
-rw-r--r-- | kedit/pixmaps/hi16-app-kedit.png | bin | 0 -> 990 bytes | |||
-rw-r--r-- | kedit/pixmaps/hi22-app-kedit.png | bin | 0 -> 1654 bytes | |||
-rw-r--r-- | kedit/pixmaps/hi32-app-kedit.png | bin | 0 -> 2683 bytes | |||
-rw-r--r-- | kedit/pixmaps/hi48-app-kedit.png | bin | 0 -> 4385 bytes | |||
-rw-r--r-- | kedit/pixmaps/hi64-app-kedit.png | bin | 0 -> 8377 bytes | |||
-rw-r--r-- | kedit/prefs.kcfgc | 7 | ||||
-rw-r--r-- | kedit/version.h | 2 |
22 files changed, 2652 insertions, 0 deletions
diff --git a/kedit/ChangeLog b/kedit/ChangeLog new file mode 100644 index 0000000..92be832 --- /dev/null +++ b/kedit/ChangeLog @@ -0,0 +1,113 @@ +2000-02-14 Kurt Granroth <granroth@kde.org> + + * Converted UI to use XML merging instead of manual creation of + menus and toolbars + + +2000-01-29 Charles Samuels <charles@altair.dhs.org> + + * Bug fixes + * KAboutData stuff + +1999-10-16 Harri Porten <porten@kde.org> + + * made kedit Unicode clean (patch provided by Ming-Che Chuang + <r8921131@ms1.cc.ntu.edu.tw>) + +1999-05-23 Dirk A. Mueller <dmuell@gmx.net> + + * kedit.cpp: Switched to the Qt 2.0 DnD classes. You can drop + QUrlDrag on the Toplevelwidget, and QUrlDrag+QTextDrag on the + QMultiLineWidget. + +1999-02-11 Harri Porten <porten@kde.org> + + * kedit.cpp: removed accelerator char & from tooltips. + * bug#87: attach all QMessageBoxes to their corresponding + dialog widget instead of 'this', ie. KEdit. This makes them always + stay on top and prevents screwed textcolors (reported and + solution provided by Alex Hayward <xelah@ferret.lmh.ox.ac.uk>) + +1999-02-08 Harri Porten <porten@kde.org> + + * kedit.cpp: quote filename for printing + * keditcl1.cpp: translate "Untitled" to trigger "Save As..." + dialog when saving. + +1998-10-12 Harri Porten <porten@kde.org> + + * added an option to turn on/off saving of backup copies + +Thu Jun 25 19:12:44 MEST 1998 Matthias Ettrich <ettrich@kde.org> + + * Word wrap fixed + +Fri Jan 9 18:04:16 MET 1998 Stefan Taferner <taferner@kde.org> + + * Added standard accelerator keys + +Sat Dec 6 03:17:49 1997 Bernd Johannes Wuebben <wuebben@petit.cornell.edu> + + * Finally implemented word wrap correctly. Should work fine now + under both auto-indent-mode and normal-mode. I expect the + implementation + to still have a little quirk here and there, but in general it should + work now. It was quite a bit of work for only a few lines of code. + Something is still amiss with the Qt mline widget -- it gave me lots + of problems and most of the implemntation turned out to be an ugly + trial and error procedure. + + * keditcl1.cpp: implemented control-k control-y emacs like kill buffer + threw out KEdit.cpp KEdit.h and introduced keditcl.h keditcl1.cpp + keditcl2.cpp + +Fri Oct 24 01:19:54 1997 Bernd Johannes Wuebben <wuebben@petit.cornell.edu> + + * kedit.cpp: lots of clean ups and fixes that were necessary because + of Qt 1.31. I replaced at message and query dialogs with the new + warning and information dialogs. + +Thu Sep 25 22:37:22 1997 Bernd Johannes Wuebben <wuebben@petit.cornell.edu> + + * non-modal search and replace dialogs + * centered about, search and replace dialogs + * bug fixes + +Sat Aug 30 23:27:51 1997 Teilnehmer 8 <wuebben@kray.dinet.de (Teilnehmer 8)> + + * added Klocale support + +Mon Aug 4 19:23:59 1997 Bernd Johannes Wuebben <wuebben@petit.cornell.edu> + + * Better about box with logo ( code from kreversi ) + +Sat Aug 2 22:55:53 1997 Bernd Johannes Wuebben <wuebben@petit.cornell.edu> + + * KEdit.cpp: various fixes + * kedit.cpp fixed the 'malformed URL' bug that popped up + since KURL had changed its behavior + +Thu Jul 24 20:13:53 1997 Bernd Johannes Wuebben <wuebben@petit.cornell.edu> + + * kedit.cpp: made kedit work with the new libs + +Mon Jul 21 22:43:07 1997 Bernd Johannes Wuebben <wuebben@petit.cornell.edu> + + * kedit.cpp: implemented mailing + +Sun Jul 20 16:59:27 1997 Bernd Johannes Wuebben <wuebben@petit.cornell.edu> + + * KEdit.cpp: Fixed permissions bug + Change line and column numbering to start at 1 + instead of 0 + +Mon Jun 16 18:33:56 1997 Bernd Johannes Wuebben <wuebben@petit.cornell.edu> + + * kedit.cpp: files dropped onto kedit are now opened with read and + write permissions. + +Thu May 22 15:02:23 1997 Bernd Johannes Wuebben <wuebben@petit.cornell.edu> + + * KEdit.cpp: the file open dialogs will now remember the last + directory visited. + diff --git a/kedit/KEdit.desktop b/kedit/KEdit.desktop new file mode 100644 index 0000000..f4e3abc --- /dev/null +++ b/kedit/KEdit.desktop @@ -0,0 +1,82 @@ +[Desktop Entry] +MimeType=text/plain; +GenericName=Simple Text Editor +GenericName[ar]=محرر نصوص بسيط +GenericName[bg]=Текстов редактор +GenericName[bs]=Jednostavni tekst editor +GenericName[ca]=Editor de text +GenericName[cs]=Jednoduchý textový editor +GenericName[cy]=Golygydd Testun Syml +GenericName[da]=Simpel teksteditor +GenericName[de]=Einfacher Texteditor +GenericName[el]=Απλός επεξεργαστής κειμένου +GenericName[eo]=Simpla Tekstredaktilo +GenericName[es]=Editor de texto sencillo +GenericName[et]=Lihtne tekstiredaktor +GenericName[eu]=Testu Editore Soila +GenericName[fa]=ویرایشگر سادۀ متن +GenericName[fi]=Tekstieditori +GenericName[fr]=Éditeur de texte élémentaire +GenericName[ga]=Eagarthóir Téacs Simplí +GenericName[he]=עורך טקסט פשוט +GenericName[hi]=सादा पाठ संपादक +GenericName[hu]=Egyszerű szövegszerkesztő +GenericName[is]=Einfaldur textaritill +GenericName[it]=Semplice editor di testi +GenericName[ja]=シンプルなテキストエディタ +GenericName[ka]=მარტივი ტექსტის რედაქტორი +GenericName[kk]=Қарапайым мәтін редакторы +GenericName[km]=កម្មវិធីនិពន្ធអត្ថបទ +GenericName[lt]=Paprastas teksto redaktorius +GenericName[mk]=Едноставен уредувач на текст +GenericName[ms]=Penyunting Teks Ringkas +GenericName[nb]=Enkelt skriveprogram +GenericName[nds]=Eenfach Texteditor +GenericName[ne]=सामान्य पाठ सम्पादक +GenericName[nl]=Eenvoudige teksteditor +GenericName[nn]=Enkelt skriveprogram +GenericName[pa]=ਸਧਾਰਨ ਪਾਠ ਸੰਪਾਦਕ +GenericName[pl]=Prosty edytor tekstu +GenericName[pt]=Editor de Texto Simples +GenericName[pt_BR]=Editor de Texto Simples +GenericName[ro]=Editor simplu de text +GenericName[ru]=Простой текстовый редактор +GenericName[sk]=Jednoduchý textový editor +GenericName[sl]=Preprost urejevalnik besedil +GenericName[sr]=Једноставни уређивач текста +GenericName[sr@Latn]=Jednostavni uređivač teksta +GenericName[sv]=Enkel texteditor +GenericName[ta]=சுலப உரை தொகுப்பான் +GenericName[tg]=Муҳаррири Оддии Матн +GenericName[tr]=Basit Metin Düzenleyici +GenericName[uk]=Простий редактор текстів +GenericName[uz]=Oddiy matn tahrirchi +GenericName[uz@cyrillic]=Оддий матн таҳрирчи +GenericName[wa]=Simpe aspougneu di tecse +GenericName[zh_CN]=简单文本编辑器 +GenericName[zh_TW]=簡單的文字編輯器 +Exec=kedit -caption "%c" %i %m %u +Icon=kedit +Path= +DocPath=kedit/index.html +Type=Application +Terminal=false +Name=KEdit +Name[af]=Kredigeer +Name[eo]=Redaktilo +Name[hi]=के-एडिट +Name[hr]=Uređivač +Name[lv]=KRediģēt +Name[ne]=केडीई सम्पादन +Name[pa]=ਕਸੰਪਦਾਕ +Name[pl]=Edytor +Name[sv]=Kedit +Name[ta]=கேதொகுப்பு +Name[tg]=KТаҳрир +Name[th]=แก้ไขข้อความ +Name[ven]=U sengulusa ha K +Name[xh]=Abahleli Be K +Name[zh_TW]=KDE 編輯器 +X-KDE-StartupNotify=true +X-DCOP-ServiceType=Multi +Categories=Qt;KDE;TextEditor; diff --git a/kedit/Makefile.am b/kedit/Makefile.am new file mode 100644 index 0000000..6870eb6 --- /dev/null +++ b/kedit/Makefile.am @@ -0,0 +1,35 @@ +# +# KEdit Makefile.am +# +# Copyright 1997 Bernd Johannes Wuebben, wuebben@math.cornell.edu +# +# + +INCLUDES = $(all_includes) + +bin_PROGRAMS = +lib_LTLIBRARIES = +kdeinit_LTLIBRARIES = kedit.la + +kedit_la_SOURCES = kedit.cpp ktextfiledlg.cpp misc.ui color.ui prefs.kcfgc +kedit_la_LIBADD = -lkdeprint $(LIB_KFILE) +kedit_la_LDFLAGS = -module -avoid-version $(KDE_PLUGIN) $(all_libraries) + +noinst_HEADERS = kedit.h ktextfiledlg.h\ + version.h misc.ui.h + +METASOURCES = AUTO + +SUBDIRS = pixmaps + +xdg_apps_DATA = KEdit.desktop +kde_kcfg_DATA = kedit.kcfg + +EXTRA_DIST = $(xdg_apps_DATA) + +rcdir = $(kde_datadir)/kedit +rc_DATA = keditui.rc + +messages: rc.cpp + $(XGETTEXT) rc.cpp *.cpp -o $(podir)/kedit.pot + diff --git a/kedit/README b/kedit/README new file mode 100644 index 0000000..909e9e5 --- /dev/null +++ b/kedit/README @@ -0,0 +1,192 @@ +kedit 0.7 +========= + +Fixed up word wrap in auto-indent and normal mode and implemented emacs +still ctrl-k ctrl-y kill-ring. KEdit should be quite usable now. + +kedit 0.5 +========= + +This is release 0.5 of KEdit. + +There are quite a number internal as external changes. The biggest +problem were a number of bugs that the underlying QMultiLineWidget +exhibits in Qt 1.2. For anything I started, be it find, replace, +word-wrap, indent-mode, loading, saving, I hit upon bugs in the +multiline widget and had to find work-arounds. This is the main +reason, why this new release took so long. However, the Trolls were +very responsive to my bug reports and helped me in finding work +arounds. The next release of qt, qt 1.3 should have a much better +multiline widget. Thanks, Trolls! + +One of the consequences of this is that find, find/replace, word-warp +and indent mode don't "feel right". They, as you will notice feel slow +and sluggish. We have to wait for qt 1.3 for this to improve. However +Qt 1.3 might well break some of the work arounds in place now, but I +will make a good effort to bring out a new version of kedit as soon as +qt 1.3 appears. + +I made so many changes, that I wouldn't be surprise if I broke some +basic functionality. Please test kedit and let me know immediately if +you think you found a bug. I will fix the problem as soon as +possible. + +Note: You need smgl-tools 0.99 if you want to regenerate the provided + documentation in ps, html, dvi format for the sgml source. + +Changes: + o adopted new kde look + o found workaround for faster loading and saving. + o find dialog working properly + o find/replace dialog working properly + o Indent Mode + o Goto Line + o Fill Column + o Word Wrap + o Documentation is now provided in sgml, ps, dvi, and html + o Rewrote the underlying kedit widget, so that it can now be used in + other applications such as kmail. + o rewrites, rewrites, rewrites .... still there is more + historical baggage left to get rid of.... + +TODO: + + o recently opened files list + o remember last directory the user opened a file in. + o Paragraph formatting + o Spell Checking (maybe) + o Option to turn backup file creation off. + o better support for net-files. + +Problems: + + o Help will only work with the next release of kdelibs. Alternatively + you can copy a copy of kedit.html, kedit.gif into + $(KDEDIR)/docs/HTML + + o kedit has currently problems to deal with color-scheme changes + without restarting kedit. I have made the necessary changes to + libkdecore to deal with this problem. You will however have to wait + for the next kdelibs release. At that time I will also bring out + a new version of kedit that will take advantage of those changes. + + +There is still lots to be done, but I hope you will find kedit a useful +little editor already. + +Best Regards, +Bernd + +wuebben@kde.org +wuebben@math.cornell.edu + +kedit+ 0.4.1 +============ + +Solved the "tab" problem. kedit+ is now Makefile proof. :-) + +kedit+ 0.4 +========== + +A few last minute changes to kedit+ 0.2 introduced an embarrassing bug, +which didn't let you "save as" an "Untitled" document. I fixed that +bug, and while I was at it I added colors to the Options dialog. +Now you can also set the fore- and background colors of kedit+. +Martin Konold suggested I bump the version number to something larger +than 0.3.1 which was the last release of kedit. + +Hope you will find this editor useful. + +I STILL NEED AN OPEN-FOLDER ICON !!!! PLEAE HELP :-) + +Best Regards, Bernd + +wuebben@kde.org +wuebben@math.cornell.edu + +kedit+ 0.2 +========== + +This is kedit+ a simple text editor for the KDE project. I have taken +Alex Sanda's kedit and turned it into what I believe to be +a useful little editor. I had to rewrite many parts of the original +kedit and added, as you will surely notice, many new features. +Nevertheless, it is still no emacs and will never be one ;-) + +I have tried to contact Alex, but haven't heard back from him. +Should kedit+ become kedit? kedit has not been developed for +about 4 month .... + + +HELP WANTED: I need an open-folder icon !!! + +I hope you like kedit+, the next Generation :-) + + +Bernd Wuebben +wuebben@kde.org +wuebben@math.cornell.edu + + +======================================================================== + + Kedit 0.3.1, small editor for the KDE project. + + +Kedit is a small, simple and almost featureless :) editor, just like +the well-known Notepad. It is suitable only for small editing tasks, or +as a simple textfile browser. + +Currently, kedit is in a very early development stage. It can load, +save/saveas files, and - of course - it can edit those files :) There is +some room for improvements, but I really want this editor to be small and +simple. + +Kedit can open multiple windows (so you can edit multiple files), without +having multiple copies of the whole program in memory. + + + +Changes +======= + +Version 0.3.1 (Martin Hartig, hartig@mathematik.uni-kl.de, 21.2.97) + +- usage of the kdehelp browser, HTML help text added + +Version 0.3 (Torben Weiss, weiss@kde.org, 4.2.97 ) + +- Drag and Drop added + +- Added network access. Can load any file kfm can. To use this feature you + must run kfm. If none is running kedit will start one on demand. + +- Can save files everywhere kfm can, this means right now that you can + write to ftp servers. + +- Using libkdecore and libkfm. This means you need libkde-0.61 and + kfm-0.51 or greater installed + +- Fixed some bugs + +- Works with any amount of windows now + +- Changed some key bindings, but not all + +- You can call + make + make install + + +TODO: + Implement search again (and maybe replace), including regexp + support. At the moment, only the search dialog has been implemented. + + Clean up some stuff, make it more user-friendly(tm). + + Keybindings: I'am sure, they are currently not kde-conform. + + Use (a not existing) KFileDialog that lets you enter URLs + + + Bernd diff --git a/kedit/TODO b/kedit/TODO new file mode 100644 index 0000000..b386630 --- /dev/null +++ b/kedit/TODO @@ -0,0 +1,6 @@ +o clean up what happens if you interrupt an ftp file load +o file_save_url need an error dialog +o save indent mode option +o key accel for end of document beginning of document +o Paragraph formatting + diff --git a/kedit/color.ui b/kedit/color.ui new file mode 100644 index 0000000..e171491 --- /dev/null +++ b/kedit/color.ui @@ -0,0 +1,129 @@ +<!DOCTYPE UI><UI version="3.2" stdsetdef="1"> +<class>Color</class> +<widget class="QWidget"> + <property name="name"> + <cstring>Color</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>365</width> + <height>196</height> + </rect> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <spacer row="3" column="1"> + <property name="name"> + <cstring>spacer1</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>41</width> + <height>111</height> + </size> + </property> + </spacer> + <widget class="KColorButton" row="1" column="1"> + <property name="name"> + <cstring>kcfg_TextColor</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string></string> + </property> + </widget> + <widget class="KColorButton" row="2" column="1"> + <property name="name"> + <cstring>kcfg_BackgroundColor</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string></string> + </property> + </widget> + <widget class="QCheckBox" row="0" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>kcfg_CustomColor</cstring> + </property> + <property name="text"> + <string>Use &custom colors</string> + </property> + </widget> + <widget class="QLabel" row="1" column="0"> + <property name="name"> + <cstring>textLabel1</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>&Foreground color:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>kcfg_TextColor</cstring> + </property> + </widget> + <widget class="QLabel" row="2" column="0"> + <property name="name"> + <cstring>textLabel2</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>&Background color:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>kcfg_BackgroundColor</cstring> + </property> + </widget> + </grid> +</widget> +<connections> + <connection> + <sender>kcfg_CustomColor</sender> + <signal>toggled(bool)</signal> + <receiver>textLabel1</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>kcfg_CustomColor</sender> + <signal>toggled(bool)</signal> + <receiver>textLabel2</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>kcfg_CustomColor</sender> + <signal>toggled(bool)</signal> + <receiver>kcfg_TextColor</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>kcfg_CustomColor</sender> + <signal>toggled(bool)</signal> + <receiver>kcfg_BackgroundColor</receiver> + <slot>setEnabled(bool)</slot> + </connection> +</connections> +<layoutdefaults spacing="6" margin="11"/> +<includehints> + <includehint>kcolorbutton.h</includehint> +</includehints> +</UI> diff --git a/kedit/kedit.cpp b/kedit/kedit.cpp new file mode 100644 index 0000000..a255cd9 --- /dev/null +++ b/kedit/kedit.cpp @@ -0,0 +1,1377 @@ + /* + + $Id$ + + Copyright (C) 1997 Bernd Johannes Wuebben + wuebben@math.cornell.edu + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + */ + +#include <sys/types.h> +#include <stdlib.h> +#include <unistd.h> + +#include <qlayout.h> +#include <qtimer.h> +#include <qpaintdevicemetrics.h> +#include <qpainter.h> + +#include <kaboutdata.h> +#include <kaction.h> +#include <kapplication.h> +#include <kcmdlineargs.h> +#include <kconfigdialog.h> +#include <kcursor.h> +#include <keditcl.h> +#include <kfileitem.h> +#include <kfontdialog.h> +#include <kio/netaccess.h> +#include <kmessagebox.h> +#include <kprinter.h> +#include <ksavefile.h> +#include <kstatusbar.h> +#include <kspell.h> +#include <kurldrag.h> + +#include "ktextfiledlg.h" +#include "kedit.h" +#include "misc.h" +#include "color.h" +#include "prefs.h" + +#include <kdebug.h> + + +QPtrList<TopLevel> *TopLevel::windowList = 0; + +int default_open = TopLevel::OPEN_READWRITE; + +TopLevel::TopLevel (QWidget *, const char *name) + : KMainWindow ( 0,name ), kspellconfigOptions(0), + eframe(0), newWindow(false), kspell(0) +{ + if (!windowList) + { + windowList = new QPtrList<TopLevel>; + windowList->setAutoDelete( FALSE ); + } + windowList->append( this ); + + statusbar_timer = new QTimer(this); + connect(statusbar_timer, SIGNAL(timeout()),this,SLOT(timer_slot())); + + connect(kapp,SIGNAL(kdisplayPaletteChanged()),this,SLOT(set_colors())); + + setupStatusBar(); + setupActions(); + + readSettings(); + + setupEditWidget(); + + if (!initialGeometrySet()) + resize( QSize(550, 400).expandedTo(minimumSizeHint())); + setupGUI(ToolBar | Keys | StatusBar | Create); + setAutoSaveSettings(); + + setAcceptDrops(true); + + setFileCaption(); +} + + +TopLevel::~TopLevel () +{ + windowList->remove( this ); +} + + +void TopLevel::setupEditWidget() +{ + if (!eframe) + { + eframe = new KEdit (this, "eframe"); + eframe->setOverwriteEnabled(true); + + connect(eframe, SIGNAL(CursorPositionChanged()),this, + SLOT(statusbar_slot())); + connect(eframe, SIGNAL(toggle_overwrite_signal()),this, + SLOT(toggle_overwrite())); + connect(eframe, SIGNAL(gotUrlDrop(QDropEvent*)), this, + SLOT(urlDrop_slot(QDropEvent*))); + connect(eframe, SIGNAL(undoAvailable(bool)),undoAction, + SLOT(setEnabled(bool))); + connect(eframe, SIGNAL(redoAvailable(bool)),redoAction, + SLOT(setEnabled(bool))); + connect(eframe, SIGNAL(copyAvailable(bool)),cutAction, + SLOT(setEnabled(bool))); + connect(eframe, SIGNAL(copyAvailable(bool)),copyAction, + SLOT(setEnabled(bool))); + connect( eframe, SIGNAL(selectionChanged()),this, + SLOT(slotSelectionChanged())); + connect( eframe, SIGNAL(modificationChanged( bool)), + SLOT(setFileCaption())); + + undoAction->setEnabled(false); + redoAction->setEnabled(false); + cutAction->setEnabled(false); + copyAction->setEnabled(false); + + setCentralWidget(eframe); + eframe->setMinimumSize(200, 100); + } + + if( Prefs::wrapMode() == Prefs::EnumWrapMode::FixedColumnWrap ) + { + eframe->setWordWrap(QMultiLineEdit::FixedColumnWidth); + eframe->setWrapColumnOrWidth(Prefs::wrapColumn()); + } + else if( Prefs::wrapMode() == Prefs::EnumWrapMode::SoftWrap ) + { + eframe->setWordWrap(QMultiLineEdit::WidgetWidth); + } + else + { + eframe->setWordWrap(QMultiLineEdit::NoWrap); + } + + eframe->setFont( Prefs::font() ); + int w = eframe->fontMetrics().width("M"); + eframe->setTabStopWidth(8*w); + + eframe->setModified(false); + + setSensitivity(); + + eframe->setFocus(); + + set_colors(); + + /* + right_mouse_button = new QPopupMenu; + + right_mouse_button->insertItem (i18n("Open..."), + this, SLOT(file_open())); + right_mouse_button->insertItem (SmallIcon("filesave"),i18n("Save"), + this, SLOT(file_save())); + right_mouse_button->insertItem (SmallIcon("filesaveas"),i18n("Save As..."), + this, SLOT(file_save_as())); + right_mouse_button->insertSeparator(-1); + right_mouse_button->insertItem(i18n("Copy"), + this, SLOT(copy())); + right_mouse_button->insertItem(i18n("Paste"), + this, SLOT(paste())); + right_mouse_button->insertItem(i18n("Cut"), + this, SLOT(cut())); + right_mouse_button->insertItem(i18n("Select All"), + this, SLOT(select_all())); + eframe->installRBPopup(right_mouse_button); + */ +} + + +void TopLevel::slotSelectionChanged() +{ + bool state = eframe->hasSelectedText(); + cutAction->setEnabled( state ); + copyAction->setEnabled( state ); +} + + +void TopLevel::setupActions() +{ + // setup File menu + KStdAction::openNew(this, SLOT(file_new()), actionCollection()); + KStdAction::open(this, SLOT(file_open()), actionCollection()); + recent = KStdAction::openRecent(this, SLOT(openRecent(const KURL&)), + actionCollection()); + KStdAction::save(this, SLOT(file_save()), actionCollection()); + KStdAction::saveAs(this, SLOT(file_save_as()), actionCollection()); + KStdAction::close(this, SLOT(file_close()), actionCollection()); + KStdAction::print(this, SLOT(print()), actionCollection()); + KStdAction::mail(this, SLOT(mail()), actionCollection()); + KStdAction::quit(this, SLOT(close()), actionCollection()); + + // setup edit menu + undoAction = KStdAction::undo(this, SLOT(undo()), actionCollection()); + redoAction = KStdAction::redo(this, SLOT(redo()), actionCollection()); + cutAction = KStdAction::cut(this, SLOT(cut()), actionCollection()); + copyAction = KStdAction::copy(this, SLOT(copy()), actionCollection()); + KStdAction::pasteText(this, SLOT(paste()), actionCollection()); + KStdAction::selectAll(this, SLOT(select_all()), actionCollection()); + KStdAction::find(this, SLOT(search()), actionCollection()); + KStdAction::findNext(this, SLOT(search_again()), actionCollection()); + KStdAction::replace(this, SLOT(replace()), actionCollection()); + + (void)new KAction(i18n("&Insert File..."), 0, this, SLOT(file_insert()), + actionCollection(), "insert_file"); + (void)new KAction(i18n("In&sert Date"), 0, this, SLOT(insertDate()), + actionCollection(), "insert_date"); + (void)new KAction(i18n("Cl&ean Spaces"), 0, this, SLOT(clean_space()), + actionCollection(), "clean_spaces"); + + // setup Tools menu + KStdAction::spelling(this, SLOT(spellcheck()), actionCollection()); + + // setup Go menu + KStdAction::gotoLine(this, SLOT(gotoLine()), actionCollection()); + + KStdAction::preferences(this, SLOT(showSettings()), actionCollection()); +} + +void TopLevel::setupStatusBar() +{ + statusBar()->insertItem("", ID_GENERAL, 10 ); + statusBar()->insertFixedItem( i18n("OVR"), ID_INS_OVR ); + statusBar()->insertFixedItem( i18n("Line:000000 Col: 000"), ID_LINE_COLUMN ); + + statusBar()->setItemAlignment( ID_GENERAL, AlignLeft|AlignVCenter ); + statusBar()->setItemAlignment( ID_LINE_COLUMN, AlignLeft|AlignVCenter ); + statusBar()->setItemAlignment( ID_INS_OVR, AlignLeft|AlignVCenter ); + + statusBar()->changeItem( i18n("Line: 1 Col: 1"), ID_LINE_COLUMN ); + statusBar()->changeItem( i18n("INS"), ID_INS_OVR ); +} + + +void TopLevel::saveProperties(KConfig* config) +{ + if(m_url.isEmpty() && !eframe->isModified()) + return; + + config->writeEntry("url",m_url.url()); + config->writeEntry("modified",eframe->isModified()); + + int line, col; + eframe->getCursorPosition(&line, &col); + config->writeEntry("current_line", line); + config->writeEntry("current_column", col); + + if(eframe->isModified()) + { + QString name = m_url.url(); + if (name.isEmpty()) + name = QString("kedit%1-%2").arg(getpid()).arg((long)this); + QString tmplocation = kapp->tempSaveName(m_url.url()); + config->writeEntry("saved_to",tmplocation); + saveFile(tmplocation, false, m_url.fileEncoding()); + } +} + + +void TopLevel::readProperties(KConfig* config){ + KURL url = config->readPathEntry("url"); + QString filename = config->readPathEntry("saved_to"); + + QString encoding = url.fileEncoding(); + int modified = config->readNumEntry("modified",0); + int line = config->readNumEntry("current_line", 0); + int col = config->readNumEntry("current_column", 0); + int result = KEDIT_RETRY; + + if(!filename.isEmpty()) + { + if (modified) + { + result = openFile(filename, OPEN_READWRITE, url.fileEncoding()); + } + else + { + result = openFile(filename, OPEN_READWRITE, url.fileEncoding()); + } + } + else + { + openURL(url, OPEN_READWRITE); + modified = false; + result = KEDIT_OK; + } + + if (result == KEDIT_OK) + { + m_url = url; + eframe->setModified(modified); + eframe->setCursorPosition(line, col); + setFileCaption(); + statusbar_slot(); + } +} + + +void TopLevel::undo() +{ + eframe->undo(); +} + + +void TopLevel::redo() +{ + eframe->redo(); +} + + +void TopLevel::copy() +{ + eframe->copy(); +} + + +void TopLevel::select_all() +{ + eframe->selectAll(); +} + + +void TopLevel::insertDate(){ + + int line, column; + + QString string; + QDate dt = QDate::currentDate(); + string = KGlobal::locale()->formatDate(dt); + + eframe->getCursorPosition(&line,&column); + eframe->insertAt(string,line,column); + eframe->setModified(TRUE); + + statusbar_slot(); +} + +void TopLevel::paste(){ + + eframe->paste(); + eframe->setModified(TRUE); + + statusbar_slot(); +} + + +void TopLevel::cut(){ + + eframe->cut(); + eframe->setModified(TRUE); + statusbar_slot(); + +} + + +void TopLevel::file_new() +{ + TopLevel *t = new TopLevel (); + t->show(); + return; +} + +void TopLevel::clean_space() +{ + eframe->cleanWhiteSpace(); +} + +void TopLevel::spellcheck() +{ + if (!eframe) return; + + if (kspell) return; // In progress + + statusBar()->changeItem(i18n("Spellcheck: Started."), ID_GENERAL); + + initSpellConfig(); + kspell = new KSpell(this, i18n("Spellcheck"), this, + SLOT( spell_started(KSpell *)), kspellconfigOptions); + + connect (kspell, SIGNAL ( death()), + this, SLOT ( spell_finished( ))); + + connect (kspell, SIGNAL (progress (unsigned int)), + this, SLOT (spell_progress (unsigned int))); + connect (kspell, SIGNAL (misspelling (const QString &, const QStringList &, unsigned int)), + eframe, SLOT (misspelling (const QString &, const QStringList &, unsigned int))); + connect (kspell, SIGNAL (corrected (const QString &, const QString &, unsigned int)), + eframe, SLOT (corrected (const QString &, const QString &, unsigned int))); + connect (kspell, SIGNAL (done(const QString&)), + this, SLOT (spell_done(const QString&))); +} + + +void TopLevel::spell_started( KSpell *) +{ + eframe->spellcheck_start(); + kspell->setProgressResolution(2); + kspell->check(eframe->text()); +} + + +void TopLevel::spell_progress (unsigned int percent) +{ + QString s; + s = i18n("Spellcheck: %1% complete").arg(percent); + + statusBar()->changeItem (s, ID_GENERAL); +} + + +void TopLevel::spell_done(const QString& newtext) +{ + eframe->spellcheck_stop(); + if (kspell->dlgResult() == 0) + { + eframe->setText( newtext); + statusBar()->changeItem (i18n("Spellcheck: Aborted."), ID_GENERAL); + } + else + { + statusBar()->changeItem (i18n("Spellcheck: Complete."), ID_GENERAL); + } + kspell->cleanUp(); +} + +// Replace ISpell with the name of the actual spell checker. +// TODO: Use %1 in the original string instead when string freeze is over. +QString TopLevel::replaceISpell(QString msg, int client) +{ + switch(client) + { + case KS_CLIENT_ISPELL: msg.replace("ISpell", "<b>ispell</b>"); break; + case KS_CLIENT_ASPELL: msg.replace("ISpell", "<b>aspell</b>"); break; + case KS_CLIENT_HSPELL: msg.replace("ISpell", "<b>hspell</b>"); break; + } + msg.replace("\n", "<p>"); + return "<qt>"+msg+"</qt>"; +} + +void TopLevel::spell_finished( ) +{ + KSpell::spellStatus status = kspell->status(); + int client = kspellconfigOptions->client(); + delete kspell; + kspell = 0; + if (status == KSpell::Error) + { + KMessageBox::sorry(this, replaceISpell(i18n("ISpell could not be started.\n" + "Please make sure you have ISpell properly configured and in your PATH."), client)); + } + else if (status == KSpell::Crashed) + { + eframe->spellcheck_stop(); + statusBar()->changeItem (i18n("Spellcheck: Crashed."), ID_GENERAL); + KMessageBox::sorry(this, replaceISpell(i18n("ISpell seems to have crashed."), client)); + } +} + + +void TopLevel::file_open( void ) +{ + + while( 1 ) + { + KURL url = KTextFileDialog::getOpenURLwithEncoding( + QString::null, QString::null, this, + i18n("Open File")); + if( url.isEmpty() ) + { + return; + } + + KIO::UDSEntry entry; + KIO::NetAccess::stat(url, entry, this); + KFileItem fileInfo(entry, url); + if (fileInfo.size() > 2097152 && // 2MB large/small enough? + KMessageBox::warningContinueCancel(this, + i18n("The file you have requested is larger than KEdit is designed for. " + "Please ensure you have enough system resources available to safely load this file, " + "or consider using a program that is designed to handle large files such as KWrite."), + i18n("Attempting to Open Large File"), + KStdGuiItem::cont(), "attemptingToOpenLargeFile") == KMessageBox::Cancel) + { + return; + } + + TopLevel *toplevel; + if( !m_url.isEmpty() || eframe->isModified() ) + { + toplevel = new TopLevel(); + if( toplevel == 0 ) + { + return; + } + } + else + { + toplevel = this; + } + + QString tmpfile; + KIO::NetAccess::download( url, tmpfile, toplevel ); + + int result = toplevel->openFile( tmpfile, 0, url.fileEncoding()); + KIO::NetAccess::removeTempFile( tmpfile ); + + if( result == KEDIT_OK ) + { + if( toplevel != this ) { toplevel->show(); } + toplevel->m_url = url; + toplevel->setFileCaption(); + recent->addURL( url ); + toplevel->eframe->setModified(false); + toplevel->setGeneralStatusField(i18n("Done")); + toplevel->statusbar_slot(); + break; + } + else if( result == KEDIT_RETRY ) + { + if( toplevel != this ) { delete toplevel; } + } + else + { + if( toplevel != this ) { delete toplevel; } + break; + } + } + +} + +void TopLevel::file_insert() +{ + while( 1 ) + { + KURL url = KTextFileDialog::getOpenURLwithEncoding( + QString::null, QString::null, this, + i18n("Insert File"), "", KStdGuiItem::insert().text()); + if( url.isEmpty() ) + { + return; + } + + QString tmpfile; + KIO::NetAccess::download( url, tmpfile, this ); + int result = openFile( tmpfile, OPEN_INSERT, url.fileEncoding(), true ); + KIO::NetAccess::removeTempFile( tmpfile ); + + if( result == KEDIT_OK ) + { + recent->addURL( url ); + eframe->setModified(true); + setGeneralStatusField(i18n("Done")); + statusbar_slot(); + } + else if( result == KEDIT_RETRY ) + { + continue; + } + return; + } +} + +bool TopLevel::queryExit() +{ + // save recent files menu + config = kapp->config(); + recent->saveEntries( config ); + config->sync(); + + return true; +} + +bool TopLevel::queryClose() +{ + queryExit(); + int result; + + if ( !eframe->isModified() ) + return true; + + QString msg = i18n("" + "This document has been modified.\n" + "Would you like to save it?" ); + switch( KMessageBox::warningYesNoCancel( this, msg, QString::null, + KStdGuiItem::save(), KStdGuiItem::discard() ) ) + { + case KMessageBox::Yes: // Save, then exit + if ( m_url.isEmpty()) + { + file_save_as(); + if ( eframe->isModified() ) + return false; // Still modified? Don't exit! + } + else + { + result = saveURL(m_url); + if ( result == KEDIT_USER_CANCEL ) + return false; // Don't exit. + + if ( result != KEDIT_OK) + { + msg = i18n("" + "Could not save the file.\n" + "Exit anyways?"); + switch( KMessageBox::warningContinueCancel( this, msg, QString::null, KStdGuiItem::quit() ) ) + { + case KMessageBox::Continue: + return true; // Exit. + case KMessageBox::Cancel: + default: + return false; // Don't exit. + } + } + } + + case KMessageBox::No: // Don't save but exit. + return true; + + case KMessageBox::Cancel: // Don't save and don't exit. + default: + return false; // Don't exit... + } + + return true; // Exit. +} + + +void TopLevel::openRecent(const KURL& url) +{ + if (!m_url.isEmpty() || eframe->isModified()) + { + TopLevel *t = new TopLevel (0,0); + t->show(); + t->openRecent(url); + return; + } + openURL( url, OPEN_READWRITE ); +} + + +void TopLevel::file_close() +{ + if( eframe->isModified() ) + { + QString msg = i18n("This document has been modified.\n" + "Would you like to save it?" ); + switch( KMessageBox::warningYesNoCancel( this, msg, QString::null, + KStdGuiItem::save(), KStdGuiItem::discard() ) ) + { + case KMessageBox::Yes: // Save, then close + file_save(); + if (eframe->isModified()) + return; // Error during save. + break; + + case KMessageBox::No: // Don't save but close. + break; + + case KMessageBox::Cancel: // Don't save and don't close. + return; + break; + } + } + eframe->clear(); + eframe->setModified(false); + m_url = KURL(); + setFileCaption(); + statusbar_slot(); +} + + +void TopLevel::file_save() +{ + if (m_url.isEmpty()) + { + file_save_as(); + return; + } + + int result = KEDIT_OK; + + result = saveURL(m_url); // error messages are handled by saveFile + + if ( result == KEDIT_OK ){ + QString string; + string = i18n("Wrote: %1").arg(m_caption); + setGeneralStatusField(string); + } +} + + +void TopLevel::setGeneralStatusField(const QString &text){ + + statusbar_timer->stop(); + + statusBar()->changeItem(text,ID_GENERAL); + statusbar_timer->start(10000,TRUE); // single shot + +} + + +void TopLevel::file_save_as() +{ + KURL u; + while(true) + { + u = KTextFileDialog::getSaveURLwithEncoding( + m_url.url(), QString::null, this, + i18n("Save File As"), + m_url.fileEncoding()); + + if (u.isEmpty()) + return; + + if ( KIO::NetAccess::exists(u, false, this) ) + { + int result = KMessageBox::warningContinueCancel( this, + i18n( "A file named \"%1\" already exists. " + "Are you sure you want to overwrite it?" ).arg( u.prettyURL() ), + i18n( "Overwrite File?" ), + i18n( "Overwrite" ) ); + + if (result != KMessageBox::Continue) + continue; + } + break; + } + + int result = saveURL(u); // error messages are handled by saveFile + + if ( result == KEDIT_OK ) + { + m_url = u; + setFileCaption(); + QString string = i18n("Saved as: %1").arg(m_caption); + setGeneralStatusField(string); + recent->addURL( u ); + } +} + + + +void TopLevel::mail() +{ + // + // Default subject string + // + QString defaultsubject = name(); + int index = defaultsubject.findRev('/'); + if( index != -1) + defaultsubject = defaultsubject.right(defaultsubject.length() - index - 1 ); + + kapp->invokeMailer( QString::null, QString::null, QString::null, + defaultsubject, eframe->text() ); +} + +/* +void TopLevel::fancyprint(){ + + QPrinter prt; + char buf[200]; + if ( prt.setup(0) ) { + + int y =10; + QPainter p; + p.begin( &prt ); + p.setFont( eframe->font() ); + QFontMetrics fm = p.fontMetrics(); + + int numlines = eframe->numLines(); + for(int i = 0; i< numlines; i++){ + y += fm.ascent(); + QString line; + line = eframe->textLine(i); + line.replace( QRegExp("\t"), " " ); + strncpy(buf,line.local8Bit(),160); + for (int j = 0 ; j <150; j++){ + if (!isprint(buf[j])) + buf[j] = ' '; + } + buf[line.length()] = '\0'; + p.drawText( 10, y, buf ); + y += fm.descent(); + } + + p.end(); + } + return ; +} +*/ + +void TopLevel::helpselected(){ + + kapp->invokeHelp( ); + +} + + +void TopLevel::search(){ + + eframe->search(); + statusbar_slot(); +} + +void TopLevel::replace(){ + eframe->replace(); + statusbar_slot(); +} + + + +void TopLevel::showSettings() +{ + if(KConfigDialog::showDialog("settings")) + return; + + initSpellConfig(); + KConfigDialog* dialog = new SettingsDialog(this, "settings", Prefs::self(), kspellconfigOptions); + + connect(dialog, SIGNAL(settingsChanged()), this, SLOT(updateSettings())); + dialog->show(); +} + +void TopLevel::initSpellConfig() +{ + if (!kspellconfigOptions) + kspellconfigOptions = new KSpellConfig(0 , "SpellingSettings", 0, false ); +} + +void TopLevel::search_again() +{ + eframe->repeatSearch(); + statusbar_slot(); +} + +void TopLevel::setFileCaption() +{ + if (m_url.isEmpty()) + { + m_caption = i18n("[New Document]"); + } + else + { + if (m_url.isLocalFile()) + { + if (QDir::currentDirPath() == m_url.directory()) + m_caption = m_url.fileName(); + else + m_caption = m_url.path(); + } + else + { + KURL url(m_url); + url.setQuery(QString::null); + m_caption = url.prettyURL(); + } + QString encoding = m_url.fileEncoding(); + if (!encoding.isEmpty()) + m_caption += QString(" (%1)").arg(encoding); + } + setCaption(m_caption, eframe->isModified()); +} + + +void TopLevel::gotoLine() { + eframe->doGotoLine(); +} + +void TopLevel::statusbar_slot(){ + + QString linenumber; + + linenumber = i18n("Line: %1 Col: %2") + .arg(eframe->currentLine() + 1) + .arg(eframe->currentColumn() +1); + + statusBar()->changeItem(linenumber,ID_LINE_COLUMN); +} + +void TopLevel::print() +{ + bool aborted = false; + QString headerLeft = i18n("Date: %1").arg(KGlobal::locale()->formatDate(QDate::currentDate(),true)); + QString headerMid = i18n("File: %1").arg(m_caption); + QString headerRight; + + QFont printFont = eframe->font(); + QFont headerFont(printFont); + headerFont.setBold(true); + + QFontMetrics printFontMetrics(printFont); + QFontMetrics headerFontMetrics(headerFont); + + KPrinter *printer = new KPrinter; + if(printer->setup(this, i18n("Print %1").arg(m_caption))) { + // set up KPrinter + printer->setFullPage(false); + printer->setCreator("KEdit"); + if ( !m_caption.isEmpty() ) + printer->setDocName(m_caption); + + QPainter *p = new QPainter; + p->begin( printer ); + + QPaintDeviceMetrics metrics( printer ); + + int dy = 0; + + p->setFont(headerFont); + int w = printFontMetrics.width("M"); + p->setTabStops(8*w); + + int page = 1; + int lineCount = 0; + int maxLineCount = eframe->numLines(); + + + while(true) { + headerRight = QString("#%1").arg(page); + dy = headerFontMetrics.lineSpacing(); + QRect body( 0, dy*2, metrics.width(), metrics.height()-dy*2); + + p->drawText(0, 0, metrics.width(), dy, Qt::AlignLeft, headerLeft); + p->drawText(0, 0, metrics.width(), dy, Qt::AlignHCenter, headerMid); + p->drawText(0, 0, metrics.width(), dy, Qt::AlignRight, headerRight); + + QPen pen; + pen.setWidth(3); + p->setPen(pen); + + p->drawLine(0, dy+dy/2, metrics.width(), dy+dy/2); + + int y = dy*2; + while(lineCount < maxLineCount) { + QString text = eframe->textLine(lineCount); + if( text.isEmpty() ) + text = " "; // don't ignore empty lines + QRect r = p->boundingRect(0, y, body.width(), body.height(), + QPainter::ExpandTabs | QPainter::WordBreak, text); + + dy = r.height(); + + if (y+dy > metrics.height()) break; + + p->drawText(0, y, metrics.width(), metrics.height() - y, + QPainter::ExpandTabs | QPainter::WordBreak, text); + + y += dy; + lineCount++; + } + if (lineCount >= maxLineCount) + break; + + printer->newPage(); + page++; + } + + p->end(); + delete p; + } + delete printer; + if (aborted) + setGeneralStatusField(i18n("Printing aborted.")); + else + setGeneralStatusField(i18n("Printing complete.")); +} + + + +void TopLevel::setSensitivity (){ + +} + + +int TopLevel::saveURL( const KURL& _url ) +{ + if ( !_url.isValid() ) + { + KMessageBox::sorry(this, i18n("Malformed URL")); + return KEDIT_RETRY; + } + + // Just a usual file ? + if ( _url.isLocalFile() ) + { + return saveFile( _url.path(), true, _url.fileEncoding() ); + } + + KTempFile tmpFile; + tmpFile.setAutoDelete(true); + eframe->setModified( true ); + saveFile( tmpFile.name(), false, _url.fileEncoding() ); + + if (KIO::NetAccess::upload( tmpFile.name(), _url, this ) == false) + { + KMessageBox::error(this, "Could not save remote file"); + return KEDIT_RETRY; + } + + return true; +} + + +int TopLevel::openFile( const QString& _filename, int _mode, const QString &encoding, bool _undoAction ) +{ + QFileInfo info(_filename); + + if(info.isDir()) + { + KMessageBox::sorry(this, i18n("You have specified a folder")); + return KEDIT_RETRY; + } + + if(!info.exists() || !info.isFile()) + { + if ((_mode & OPEN_NEW) != 0) + return KEDIT_OK; + KMessageBox::sorry(this, i18n("The specified file does not exist")); + return KEDIT_RETRY; + } + + QFile file(_filename); + + if(!file.open(IO_ReadOnly)) + { + KMessageBox::sorry(this, i18n("You do not have read permission to this file.")); + return KEDIT_RETRY; + } + + QTextStream stream(&file); + QTextCodec *codec; + if (!encoding.isEmpty()) + codec = QTextCodec::codecForName(encoding.latin1()); + else + codec = QTextCodec::codecForLocale(); + stream.setCodec(codec); + + if ((_mode & OPEN_INSERT) == 0) + { + eframe->clear(); + } + if ( ! _undoAction ) + eframe->setUndoRedoEnabled(false); + + eframe->insertText( &stream ); + eframe->setModified(false); + + if ( !_undoAction) + eframe->setUndoRedoEnabled(true); + + return KEDIT_OK; + +} + + +int TopLevel::saveFile( const QString& _filename, bool backup, const QString& encoding ) +{ + QFileInfo info(_filename); + bool bSoftWrap = (Prefs::wrapMode() == Prefs::EnumWrapMode::SoftWrap); + + if(info.isDir()) + { + KMessageBox::sorry(this, i18n("You have specified a folder")); + return KEDIT_RETRY; + } + + if (backup && Prefs::backupCopies() && QFile::exists(_filename)) + { + if (!KSaveFile::backupFile(_filename)) + { + KMessageBox::sorry(this, i18n("Unable to make a backup of the original file.")); + } + } + + // WABA: We don't use KSaveFile because it doesn't preserve hard/soft + // links when saving. Most applications don't care about this, but an + // editor is supposed to preserve such things. + + QFile file(_filename); + if(!file.open(IO_WriteOnly)) + { + KMessageBox::sorry(this, i18n("Unable to write to file.")); + return KEDIT_RETRY; + } + + QTextStream textStream(&file); + QTextCodec *codec; + if (!encoding.isEmpty()) + codec = QTextCodec::codecForName(encoding.latin1()); + else + codec = QTextCodec::codecForLocale(); + textStream.setCodec(codec); + + eframe->saveText( &textStream, bSoftWrap ); + file.close(); + + if(file.status()) + { + KMessageBox::sorry(this, i18n("Could not save file.")); + return KEDIT_RETRY; + } + eframe->setModified(false); + return KEDIT_OK; +} + + +void TopLevel::openURL( const KURL& _url, int _mode ) +{ + if ( !_url.isValid() ) + { + QString string; + string = i18n( "Malformed URL\n%1").arg(_url.url()); + + KMessageBox::sorry(this, string); + return; + } + + QString target; + int result = KEDIT_OK; + if (KIO::NetAccess::download(_url, target, this)) + { + result = openFile(target, _mode, _url.fileEncoding()); + } + else + { + if ((_mode & OPEN_NEW) == 0) + { + KMessageBox::error(this, i18n("Cannot download file.")); + return; + } + } + if (result == KEDIT_OK) + { + m_url = _url; + setFileCaption(); + recent->addURL(_url); + eframe->setModified(false); + setGeneralStatusField(i18n("Done")); + } +} + +void TopLevel::urlDrop_slot(QDropEvent* e) { + + dropEvent(e); +} + +void TopLevel::dragEnterEvent(QDragEnterEvent* e) +{ + e->accept(KURLDrag::canDecode(e)); +} + +void TopLevel::dropEvent(QDropEvent* e) +{ + + KURL::List list; + + // This should never happen, but anyway... + if(!KURLDrag::decode(e, list)) + return; + + bool first = true; + for ( KURL::List::ConstIterator it = list.begin(); it != list.end(); ++it) + { + // Load the first file in this window + if ( first && !eframe->isModified() ) + { + openURL( *it, OPEN_READWRITE ); + } + else + { + setGeneralStatusField(i18n("New Window")); + TopLevel *t = new TopLevel (); + t->show (); + setGeneralStatusField(i18n("New Window Created")); + t->openURL( *it, OPEN_READWRITE ); + setGeneralStatusField(i18n("Load Command Done")); + } + first = false; + } +} + +void TopLevel::timer_slot(){ + + statusBar()->changeItem("",ID_GENERAL); + +} + + +void TopLevel::set_colors() +{ + QPalette mypalette = (eframe->palette()).copy(); + + QColorGroup ncgrp( mypalette.active() ); + + if (Prefs::customColor()) + { + ncgrp.setColor(QColorGroup::Text, Prefs::textColor()); + ncgrp.setColor(QColorGroup::Base, Prefs::backgroundColor()); + } + else + { + ncgrp.setColor(QColorGroup::Text, KGlobalSettings::textColor()); + ncgrp.setColor(QColorGroup::Base, KGlobalSettings::baseColor()); + } + + mypalette.setActive(ncgrp); + mypalette.setDisabled(ncgrp); + mypalette.setInactive(ncgrp); + + eframe->setPalette(mypalette); +} + + +void TopLevel::updateSettings( void ) +{ + readSettings(); + setupEditWidget(); +} + +void TopLevel::readSettings( void ) +{ + recent->loadEntries( kapp->config() ); +} + + +void TopLevel::toggle_overwrite(){ + + if(eframe->isOverwriteMode()){ + statusBar()->changeItem("OVR",ID_INS_OVR); + } + else{ + statusBar()->changeItem("INS",ID_INS_OVR); + } + +} + +static const char description[] = I18N_NOOP("KDE text editor"); + +static const KCmdLineOptions options[] = +{ + { "encoding <encoding>", I18N_NOOP("Encoding to use for the following documents"), 0 }, + { "+file", I18N_NOOP("File or URL to open"), 0 }, + KCmdLineLastOption +}; + +extern "C" KDE_EXPORT int kdemain (int argc, char **argv) +{ + bool have_top_window = false; + + KAboutData aboutData( "kedit", I18N_NOOP("KEdit"), + KEDITVERSION, description, KAboutData::License_GPL, + "(c) 1997-2000, Bernd Johannes Wuebben"); + aboutData.addAuthor("Bernd Johannes Wuebben",0, "wuebben@kde.org"); + KCmdLineArgs::init( argc, argv, &aboutData ); + KCmdLineArgs::addCmdLineOptions( options ); + + KApplication a; + //CT KIO::Job::initStatic(); + if ( a.isRestored() ) + { + int n = 1; + while (TopLevel::canBeRestored(n)) + { + TopLevel *tl = new TopLevel(); + tl->restore(n); + n++; + have_top_window = true; + } + } + else + { + have_top_window = false; + KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); + + const QString encoding = args->getOption("encoding"); + const bool doEncoding = args->isSet("encoding") && + QTextCodec::codecForName(encoding.latin1()); + + for(int i = 0; i < args->count(); i++) + { + TopLevel *t = new TopLevel; + t->show (); + have_top_window = true; + + KURL url = args->url(i); + + if(doEncoding) + url.setFileEncoding(encoding); + + t->openURL( url, default_open | TopLevel::OPEN_NEW ); + } + args->clear(); + } + + if(!have_top_window) + { + TopLevel *t = new TopLevel (); + t->show (); + } + + return a.exec (); +} + +SettingsDialog::SettingsDialog(QWidget *parent, const char *name,KConfigSkeleton *config, KSpellConfig *_spellConfig) + : KConfigDialog(parent, name, config), + spellConfig(_spellConfig), spellConfigChanged(false) +{ + // Font + QWidget *font = new QWidget(0, "FontSetting"); + QVBoxLayout *topLayout = new QVBoxLayout(font, 0, KDialog::spacingHint()); + KFontChooser *mFontChooser = new KFontChooser(font, "kcfg_Font", false, QStringList(), false, 6); + topLayout->addWidget(mFontChooser); + addPage(font, i18n("Font"), "fonts", i18n("Editor Font")); + + // Color + Color *color = new Color(0, "ColorSettings"); + addPage(color, i18n("Color"), "colorize", i18n("Text Color in Editor Area")); + + // Spelling + addPage(spellConfig, i18n("Spelling"), + "spellcheck", i18n("Spelling Checker")); + connect(spellConfig, SIGNAL(configChanged()), this, SLOT(slotSpellConfigChanged())); + + // Miscellaneous + Misc *miscOptions = new Misc(0, "MiscSettings"); + addPage(miscOptions, i18n("Miscellaneous"), "misc"); +} + +void SettingsDialog::updateSettings() +{ + spellConfig->writeGlobalSettings(); +} + +void SettingsDialog::updateWidgets() +{ + spellConfig->readGlobalSettings(); + spellConfigChanged = false; +} + +void SettingsDialog::updateWidgetsDefault() +{ +} + +bool SettingsDialog::hasChanged() +{ + return spellConfigChanged; +} + +bool SettingsDialog::isDefault() +{ + return true; +} + +void SettingsDialog::slotSpellConfigChanged() +{ + spellConfigChanged = true; + updateButtons(); +} + +#include "kedit.moc" + diff --git a/kedit/kedit.h b/kedit/kedit.h new file mode 100644 index 0000000..a39eb4d --- /dev/null +++ b/kedit/kedit.h @@ -0,0 +1,229 @@ +/* + + $Id$ + + Copyright (C) 1997 Bernd Johannes Wuebben + wuebben@math.cornell.edu + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + */ + +#ifndef _KEDIT_H_ +#define _KEDIT_H_ + +#include <qtextcodec.h> +#include <qptrdict.h> + +#include "version.h" + +#include <kmainwindow.h> + +class KEdit; +class KSpell; +class KSpellConfig; +class QTimer; +class KAction; +class KRecentFilesAction; + +namespace KIO { class Job; } + +// StatusBar field IDs +#define ID_LINE_COLUMN 1 +#define ID_INS_OVR 2 +#define ID_GENERAL 3 + +class TopLevel : public KMainWindow +{ + Q_OBJECT + +public: + enum { KEDIT_OK = 0, + KEDIT_OS_ERROR = 1, + KEDIT_USER_CANCEL = 2 , + KEDIT_RETRY = 3, + KEDIT_NOPERMISSIONS = 4}; + + enum { OPEN_READWRITE = 1, + OPEN_READONLY = 2, + OPEN_INSERT = 4, + OPEN_NEW = 8 }; + + TopLevel( QWidget *parent=0, const char *name=0 ); + ~TopLevel(); + + /** + * Reads a file into the edit widget. + * + * @return KEDIT_OK on success + */ + int openFile( const QString& _filename, int _mode, const QString &encoding, bool _undoAction = false ); + + /** + * Saves the edit widget to a file. + * + * @return KEDIT_OK on success + */ + int saveFile( const QString& _filename, bool backup, const QString &encoding); + + /** + * Works like openFile but is able to open remote files + */ + void openURL( const KURL& _url, int _mode ); + + /** + * Saves the current text to the URL '_url'. + * + * @return KEDIT::KEDIT_OK on success + */ + + int saveURL( const KURL& _url ); + + /** + * Only show the window when the following load action is successful. + **/ + void setNewWindow() { newWindow = true; } + + /** + * set url + */ + void setUrl(const KURL &url) { m_url = url; } + + /// List of all windows + static QPtrList<TopLevel> *windowList; + //QPopupMenu *right_mouse_button; + + bool queryExit( void ); + bool queryClose( void ); + +protected: + void setSensitivity(); + void setupEditWidget(); + void setupStatusBar(); + void setupActions(); + void initSpellConfig(); + +private: + KSpellConfig *kspellconfigOptions; + +public: // Should not be! + KEdit *eframe; +private: + KURL m_url; + QString m_caption; + + bool newWindow; + int statusID, toolID, indentID; + QTimer *statusbar_timer; + KRecentFilesAction *recent; + KAction *cutAction; + KAction *copyAction; + KAction *undoAction; + KAction *redoAction; + + int open_mode; + + KConfig *config; + + KSpell *kspell; // Current spell checking object + + /* + * The source, the destination of the copy, and the open mode + * for each job being run (job ptr is the dict key). + */ + QPtrDict <QString> m_sNet; + QPtrDict <QString> m_sLocal; + QPtrDict <int> m_openMode; + + // Session management + void saveProperties(KConfig*); + void readProperties(KConfig*); + +public slots: + void openRecent(const KURL&); + void gotoLine(); + void mail(); + void setGeneralStatusField(const QString &string); + void undo(); + void redo(); + void copy(); + void paste(); + void cut(); + void insertDate(); + void print(); + void select_all(); + void clean_space(); + void timer_slot(); + void file_open(); + void file_new(); + void file_insert(); + void setFileCaption(); + void statusbar_slot(); + void file_close(); + void file_save(); + void file_save_as(); + void helpselected(); + void search(); + void replace(); + void search_again(); + void toggle_overwrite(); + + void spellcheck(); + void spell_started ( KSpell *); + void spell_progress (unsigned int percent); + void spell_done(const QString&); + void spell_finished(); + + void urlDrop_slot(QDropEvent* e); + + void set_colors(); + +protected: + /// Drag and Drop + void dragEnterEvent(QDragEnterEvent* e); + void dropEvent(QDropEvent* e); + +private slots: + void updateSettings(); + void readSettings(); + void showSettings(); + void slotSelectionChanged(); + QString replaceISpell(QString msg, int client); +}; + +class SettingsDialog: public KConfigDialog { +Q_OBJECT + +public: + SettingsDialog(QWidget *parent, const char *name,KConfigSkeleton *config, KSpellConfig *_spellConfig); + +protected slots: + void updateSettings(); + void updateWidgets(); + void updateWidgetsDefault(); + void slotSpellConfigChanged(); + +protected: + bool hasChanged(); + bool isDefault(); + +private: + KSpellConfig *spellConfig; + bool spellConfigChanged; +}; + + +#endif + diff --git a/kedit/kedit.kcfg b/kedit/kedit.kcfg new file mode 100644 index 0000000..a647737 --- /dev/null +++ b/kedit/kedit.kcfg @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="UTF-8"?> +<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0 + http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" > + <include>kstandarddirs.h</include> + <kcfgfile name="keditrc"/> + <group name="Text Font"> + <entry name="Font" type="Font" key="KEditFont"> + <label>Font</label> + <default code="true">KGlobalSettings::fixedFont()</default> + </entry> + </group> + <group name="General Options"> + <entry name="CustomColor" type="Bool"> + <label>Use custom colors.</label> + <default>false</default> + </entry> + <entry name="TextColor" type="Color" key="ForeColor"> + <label>Text color</label> + <default code="true">KGlobalSettings::textColor()</default> + </entry> + <entry name="BackgroundColor" type="Color" key="BackColor"> + <label>Background color</label> + <default code="true">KGlobalSettings::baseColor()</default> + </entry> + <entry name="WrapMode" type="Enum"> + <label>Wrapping mode</label> + <choices> + <choice name="NoWrap"/> + <choice name="SoftWrap"/> + <choice name="FixedColumnWrap"/> + </choices> + <default>SoftWrap</default> + </entry> + <entry name="WrapColumn" type="Int"> + <label>Wrap at column</label> + <default>79</default> + </entry> + <entry name="BackupCopies" type="Bool"> + <label>Make backup when saving a file</label> + <default>true</default> + </entry> + </group> +</kcfg> diff --git a/kedit/keditui.rc b/kedit/keditui.rc new file mode 100644 index 0000000..f071204 --- /dev/null +++ b/kedit/keditui.rc @@ -0,0 +1,10 @@ +<!DOCTYPE kpartgui> +<kpartgui name="kedit" version="2"> +<MenuBar> + <Menu name="edit"><text>&Edit</text> + <Action name="insert_file"/> + <Action name="insert_date"/> + <Action name="clean_spaces"/> + </Menu> +</MenuBar> +</kpartgui> diff --git a/kedit/ktextfiledlg.cpp b/kedit/ktextfiledlg.cpp new file mode 100644 index 0000000..1e1a322 --- /dev/null +++ b/kedit/ktextfiledlg.cpp @@ -0,0 +1,212 @@ +// -*- c++ -*- +/* This file is part of the KDE libraries + Copyright (C) 2001 Wolfram Diestel <wolfram@steloj.de> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include <qlabel.h> +#include <qvbox.h> + +#include <klocale.h> +#include <kcharsets.h> +#include <kdiroperator.h> +#include <krecentdocument.h> +#include <ktoolbar.h> +#include <kpushbutton.h> + +#include "ktextfiledlg.h" + +KTextFileDialog::KTextFileDialog(const QString& startDir, + const QString& filter, + QWidget *parent, const char* name, + bool modal) + : KFileDialog(startDir, filter, parent, name, modal) +{ + /* + // insert encoding action into toolbar + KSelectAction *mEncoding = new KSelectAction( + i18n( "Set &Encoding" ), 0, this, + SLOT( slotSetEncoding() ), this, + "encoding" ); + + QStringList encodings = KGlobal::charsets()->descriptiveEncodingNames(); + encodings.prepend( i18n( "Default encoding" ) ); + mEncoding->setItems( encodings ); + mEncoding->setCurrentItem(0); + QStringList::Iterator it; + int i = 0; + for( it = encodings.begin(); it != encodings.end(); ++it) { + if ( (*it).contains( encodingStr ) ) { + mEncoding->setCurrentItem( i ); + break; + } + i++; + } + + KToolBar *tb = toolBar(); + mEncoding->plug( tb, 7 ); + */ + + KAction* mEncoding = new KAction( + i18n("Select Encoding..."), 0, + this, SLOT( slotShowEncCombo() ), this, "encoding"); + + mEncoding->setIcon( QString::fromLatin1("charset") ); + + KToolBar *tb = toolBar(); + mEncoding->plug( tb, pathComboIndex() - 1 ); +} + +KTextFileDialog::~KTextFileDialog() {} + +void KTextFileDialog::setEncoding(const QString& encoding) { + enc = encoding; +} + + + +void KTextFileDialog::slotShowEncCombo() +{ + // Modal widget asking the user about charset + // + KDialogBase *encDlg; + QLabel *label; + QComboBox *encCombo; + QVBox *vbox; + + // Create widgets, and display using geometry management + encDlg = new KDialogBase( this, + "Encoding Dialog", true, i18n("Select Encoding"), + KDialogBase::Ok | KDialogBase::Cancel ); + vbox = new QVBox( encDlg ); + vbox->setSpacing( KDialog::spacingHint() ); + encDlg->setMainWidget( vbox ); + label = new QLabel( vbox ); + label->setAlignment( AlignLeft | AlignVCenter ); + label->setText(i18n("Select encoding for text file: ")); + + encCombo = new QComboBox(vbox); + encCombo->setInsertionPolicy(QComboBox::NoInsertion); + encCombo->insertItem(i18n("Default Encoding")); + + QStringList encodings = KGlobal::charsets()->descriptiveEncodingNames(); + encodings.prepend( i18n( "Default encoding" ) ); + encCombo->insertStringList( encodings ); + encCombo->setCurrentItem(0); + QStringList::Iterator it; + int i = 1; + for( it = encodings.begin(); it != encodings.end(); ++it) { + + if ( (*it).contains( encoding() ) ) { + encCombo->setCurrentItem( i ); + break; + } + + i++; + } + + connect( encDlg->actionButton( KDialogBase::Ok ), SIGNAL(clicked()), + encDlg, SLOT(accept()) ); + connect( encDlg->actionButton( KDialogBase::Cancel ), SIGNAL(clicked()), + encDlg, SLOT(reject()) ); + + encDlg->setMinimumSize( 300, 120); + + if ( encDlg->exec() == QDialog::Accepted ) { + // set encoding + if (encCombo->currentItem() == 0) { // Default + setEncoding(""); + } else { + setEncoding(KGlobal::charsets()-> + encodingForName(encCombo->currentText())); + } + } + + + delete encDlg; +} + + +KURL KTextFileDialog::getOpenURLwithEncoding( + const QString& startDir, + const QString& filter, + QWidget *parent, + const QString& caption, + const QString& encoding, + const QString& buttontext) +{ + KTextFileDialog dlg(startDir, filter, parent, "filedialog", true); + dlg.setEncoding(encoding); + dlg.setOperationMode( Opening ); + + dlg.setCaption(caption.isNull() ? i18n("Open") : caption); + dlg.ops->clearHistory(); + if (!buttontext.isEmpty()) + dlg.okButton()->setText(buttontext); + dlg.exec(); + + KURL url = dlg.selectedURL(); + if (url.isValid()) { + if ( url.isLocalFile() ) + KRecentDocument::add( url.path(-1) ); + else + KRecentDocument::add( url.url(-1), true ); + } + + // append encoding to the URL params + url.setFileEncoding(dlg.encoding()); + + return url; +} + +KURL KTextFileDialog::getSaveURLwithEncoding( + const QString& dir, const QString& filter, + QWidget *parent, + const QString& caption, + const QString& encoding) +{ + KTextFileDialog dlg(dir, filter, parent, "filedialog", true); + dlg.setEncoding(encoding); + dlg.setOperationMode( Saving ); + + dlg.setCaption(caption.isNull() ? i18n("Save As") : caption); + dlg.setKeepLocation( true ); + + dlg.exec(); + + KURL url = dlg.selectedURL(); + if (url.isValid()) { + if ( url.isLocalFile() ) + KRecentDocument::add( url.path(-1) ); + else + KRecentDocument::add( url.url(-1) ); + } + + // append encoding to the URL params + url.setFileEncoding(dlg.encoding()); + + return url; +} + +#include "ktextfiledlg.moc" + + + + + + + diff --git a/kedit/ktextfiledlg.h b/kedit/ktextfiledlg.h new file mode 100644 index 0000000..ba15be2 --- /dev/null +++ b/kedit/ktextfiledlg.h @@ -0,0 +1,74 @@ +// -*- c++ -*- +/* This file is part of the KDE libraries + Copyright (C) 2001 Wolfram Diestel <wolfram@steloj.de> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef __KTEXTFILEDLG_H__ +#define __KTEXTFILEDLG_H__ + +#include <kfiledialog.h> + +class QComboBox; +class QTextCodec; +class QString; +class KURL; + +/** + * Provides filedialog with a tollbar button for + a char encoding selection. The selected encoding + is returned as parameter charset in the query part + of the URL. This is helps to save the charset together with + the filename in the recent files list. + */ +class KTextFileDialog : public KFileDialog +{ + Q_OBJECT + + public: + KTextFileDialog(const QString& startDir, const QString& filter, + QWidget *parent, const char *name, + bool modal); + + ~KTextFileDialog(); + + static KURL getOpenURLwithEncoding( + const QString& startDir = QString::null, + const QString& filter= QString::null, + QWidget *parent= 0, + const QString& caption = QString::null, + const QString& encoding = QString::null, + const QString& buttonText = QString::null); + + static KURL getSaveURLwithEncoding( + const QString& dir, const QString& filter, + QWidget *parent, + const QString& caption, + const QString& encoding = QString::null); + + QString &encoding() { return enc; } + void setEncoding(const QString& encoding); + + protected slots: + void slotShowEncCombo(); + + private: + QString enc; +}; + + +#endif diff --git a/kedit/misc.ui b/kedit/misc.ui new file mode 100644 index 0000000..2a30333 --- /dev/null +++ b/kedit/misc.ui @@ -0,0 +1,123 @@ +<!DOCTYPE UI><UI version="3.2" stdsetdef="1"> +<class>Misc</class> +<widget class="QWidget"> + <property name="name"> + <cstring>Misc</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>300</width> + <height>164</height> + </rect> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <widget class="QLabel" row="0" column="0"> + <property name="name"> + <cstring>textLabel3</cstring> + </property> + <property name="text"> + <string>&Word wrap:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>kcfg_WrapMode</cstring> + </property> + </widget> + <widget class="QSpinBox" row="1" column="1"> + <property name="name"> + <cstring>kcfg_WrapColumn</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="maxValue"> + <number>999999999</number> + </property> + </widget> + <widget class="QCheckBox" row="2" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>kcfg_BackupCopies</cstring> + </property> + <property name="text"> + <string>Make &backup when saving a file</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + <widget class="QComboBox" row="0" column="1"> + <item> + <property name="text"> + <string>Disable Wrapping</string> + </property> + </item> + <item> + <property name="text"> + <string>Soft Wrapping</string> + </property> + </item> + <item> + <property name="text"> + <string>At Specified Column</string> + </property> + </item> + <property name="name"> + <cstring>kcfg_WrapMode</cstring> + </property> + </widget> + <spacer row="3" column="1"> + <property name="name"> + <cstring>spacer2</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>101</height> + </size> + </property> + </spacer> + <widget class="QLabel" row="1" column="0"> + <property name="name"> + <cstring>wrapLabel</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>Wrap &column:</string> + </property> + <property name="buddy" stdset="0"> + <cstring>kcfg_WrapColumn</cstring> + </property> + </widget> + </grid> +</widget> +<connections> + <connection> + <sender>kcfg_WrapMode</sender> + <signal>activated(int)</signal> + <receiver>Misc</receiver> + <slot>settingsWrapMode(int)</slot> + </connection> +</connections> +<includes> + <include location="local" impldecl="in implementation">misc.ui.h</include> +</includes> +<slots> + <slot>settingsWrapMode( int mode )</slot> +</slots> +<layoutdefaults spacing="6" margin="11"/> +</UI> diff --git a/kedit/misc.ui.h b/kedit/misc.ui.h new file mode 100644 index 0000000..339c944 --- /dev/null +++ b/kedit/misc.ui.h @@ -0,0 +1,14 @@ +/**************************************************************************** +** ui.h extension file, included from the uic-generated form implementation. +** +** If you wish to add, delete or rename functions or slots use +** Qt Designer which will update this file, preserving your code. Create an +** init() function in place of a constructor, and a destroy() function in +** place of a destructor. +*****************************************************************************/ +void Misc::settingsWrapMode( int mode ) +{ + bool state = ((mode == 2) ? true : false); + kcfg_WrapColumn->setEnabled( state ); + wrapLabel->setEnabled( state ); +} diff --git a/kedit/pixmaps/Makefile.am b/kedit/pixmaps/Makefile.am new file mode 100644 index 0000000..798615d --- /dev/null +++ b/kedit/pixmaps/Makefile.am @@ -0,0 +1,2 @@ +KDE_ICON = kedit + diff --git a/kedit/pixmaps/hi16-app-kedit.png b/kedit/pixmaps/hi16-app-kedit.png Binary files differnew file mode 100644 index 0000000..d212377 --- /dev/null +++ b/kedit/pixmaps/hi16-app-kedit.png diff --git a/kedit/pixmaps/hi22-app-kedit.png b/kedit/pixmaps/hi22-app-kedit.png Binary files differnew file mode 100644 index 0000000..6c0c574 --- /dev/null +++ b/kedit/pixmaps/hi22-app-kedit.png diff --git a/kedit/pixmaps/hi32-app-kedit.png b/kedit/pixmaps/hi32-app-kedit.png Binary files differnew file mode 100644 index 0000000..5dbf6bc --- /dev/null +++ b/kedit/pixmaps/hi32-app-kedit.png diff --git a/kedit/pixmaps/hi48-app-kedit.png b/kedit/pixmaps/hi48-app-kedit.png Binary files differnew file mode 100644 index 0000000..21d42dc --- /dev/null +++ b/kedit/pixmaps/hi48-app-kedit.png diff --git a/kedit/pixmaps/hi64-app-kedit.png b/kedit/pixmaps/hi64-app-kedit.png Binary files differnew file mode 100644 index 0000000..64a1ad0 --- /dev/null +++ b/kedit/pixmaps/hi64-app-kedit.png diff --git a/kedit/prefs.kcfgc b/kedit/prefs.kcfgc new file mode 100644 index 0000000..0e2e195 --- /dev/null +++ b/kedit/prefs.kcfgc @@ -0,0 +1,7 @@ +# Code generation options for kconfig_compiler +File=kedit.kcfg +#IncludeFiles=defines.h +ClassName=Prefs +Singleton=true +#CustomAdditions=true +#Mutators=Zoom diff --git a/kedit/version.h b/kedit/version.h new file mode 100644 index 0000000..c1b3b2a --- /dev/null +++ b/kedit/version.h @@ -0,0 +1,2 @@ +#define KEDITVERSION "1.3" + |