summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-12-22 18:24:31 (UTC)
committer llornkcor <llornkcor>2002-12-22 18:24:31 (UTC)
commit3ae485ccb47ca618bc00d96a0e81c978a1cfbdaf (patch) (side-by-side diff)
treef4a50457221d593f258d2f3f3d55c7b47a7b976d
parentc82ed38520b4038678ab0ab0c9f0ba147d8791ea (diff)
downloadopie-3ae485ccb47ca618bc00d96a0e81c978a1cfbdaf.zip
opie-3ae485ccb47ca618bc00d96a0e81c978a1cfbdaf.tar.gz
opie-3ae485ccb47ca618bc00d96a0e81c978a1cfbdaf.tar.bz2
use ofontselector, and temp fix for dialog crash
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/tinykate/libkate/view/kateview.cpp2
-rw-r--r--noncore/apps/tinykate/libkate/view/kateviewdialog.cpp37
-rw-r--r--noncore/apps/tinykate/libkate/view/kateviewdialog.h2
3 files changed, 30 insertions, 11 deletions
diff --git a/noncore/apps/tinykate/libkate/view/kateview.cpp b/noncore/apps/tinykate/libkate/view/kateview.cpp
index 6453458..63e941f 100644
--- a/noncore/apps/tinykate/libkate/view/kateview.cpp
+++ b/noncore/apps/tinykate/libkate/view/kateview.cpp
@@ -1837,1025 +1837,1025 @@ void KateView::redoMultiple(int count) {
myDoc->redo(c, count);
myDoc->updateViews();
}
void KateView::undoHistory()
{
UndoHistory *undoH;
undoH = new UndoHistory(this, this, "UndoHistory", true);
undoH->setCaption(i18n("Undo/Redo History"));
connect(this,SIGNAL(newUndo()),undoH,SLOT(newUndo()));
connect(undoH,SIGNAL(undo(int)),this,SLOT(undoMultiple(int)));
connect(undoH,SIGNAL(redo(int)),this,SLOT(redoMultiple(int)));
undoH->exec();
delete undoH;
}
static void kwview_addToStrList(QStringList &list, const QString &str) {
if (list.count() > 0) {
if (list.first() == str) return;
QStringList::Iterator it;
it = list.find(str);
if (*it != 0L) list.remove(it);
if (list.count() >= 16) list.remove(list.fromLast());
}
list.prepend(str);
}
void KateView::find() {
SearchDialog *searchDialog;
if (!myDoc->hasMarkedText()) searchFlags &= ~KateView::sfSelected;
searchDialog = new SearchDialog(this, myDoc->searchForList, myDoc->replaceWithList,
searchFlags & ~KateView::sfReplace);
// If the user has marked some text we use that otherwise
// use the word under the cursor.
QString str;
if (myDoc->hasMarkedText())
str = markedText();
if (str.isEmpty())
str = currentWord();
if (!str.isEmpty())
{
str.replace(QRegExp("^\n"), "");
int pos=str.find("\n");
if (pos>-1)
str=str.left(pos);
searchDialog->setSearchText( str );
}
myViewInternal->focusOutEvent(0L);// QT bug ?
if (searchDialog->exec() == QDialog::Accepted) {
kwview_addToStrList(myDoc->searchForList, searchDialog->getSearchFor());
searchFlags = searchDialog->getFlags() | (searchFlags & KateView::sfPrompt);
initSearch(s, searchFlags);
findAgain(s);
}
delete searchDialog;
}
void KateView::replace() {
SearchDialog *searchDialog;
if (isReadOnly()) return;
if (!myDoc->hasMarkedText()) searchFlags &= ~KateView::sfSelected;
searchDialog = new SearchDialog(this, myDoc->searchForList, myDoc->replaceWithList,
searchFlags | KateView::sfReplace);
// If the user has marked some text we use that otherwise
// use the word under the cursor.
QString str;
if (myDoc->hasMarkedText())
str = markedText();
if (str.isEmpty())
str = currentWord();
if (!str.isEmpty())
{
str.replace(QRegExp("^\n"), "");
int pos=str.find("\n");
if (pos>-1)
str=str.left(pos);
searchDialog->setSearchText( str );
}
myViewInternal->focusOutEvent(0L);// QT bug ?
if (searchDialog->exec() == QDialog::Accepted) {
// myDoc->recordReset();
kwview_addToStrList(myDoc->searchForList, searchDialog->getSearchFor());
kwview_addToStrList(myDoc->replaceWithList, searchDialog->getReplaceWith());
searchFlags = searchDialog->getFlags();
initSearch(s, searchFlags);
replaceAgain();
}
delete searchDialog;
}
void KateView::gotoLine() {
GotoLineDialog *dlg;
PointStruc cursor;
dlg = new GotoLineDialog(this, myViewInternal->cursor.y + 1, myDoc->numLines());
// dlg = new GotoLineDialog(myViewInternal->cursor.y + 1, this);
if (dlg->exec() == QDialog::Accepted) {
// myDoc->recordReset();
cursor.x = 0;
cursor.y = dlg->getLine() - 1;
myDoc->needPreHighlight(cursor.y);
myViewInternal->updateCursor(cursor);
myViewInternal->center();
myViewInternal->updateView(KateView::ufUpdateOnScroll);
myDoc->updateViews(this); //uptade all other views except this one
}
delete dlg;
}
void KateView::initSearch(SConfig &s, int flags) {
s.flags = flags;
s.setPattern(myDoc->searchForList.first());
if (!(s.flags & KateView::sfFromBeginning)) {
// If we are continuing a backward search, make sure we do not get stuck
// at an existing match.
s.cursor = myViewInternal->cursor;
TextLine::Ptr textLine = myDoc->getTextLine(s.cursor.y);
QString const txt(textLine->getText(),textLine->length());
const QString searchFor= myDoc->searchForList.first();
int pos = s.cursor.x-searchFor.length()-1;
if ( pos < 0 ) pos = 0;
pos= txt.find(searchFor, pos, s.flags & KateView::sfCaseSensitive);
if ( s.flags & KateView::sfBackward )
{
if ( pos <= s.cursor.x ) s.cursor.x= pos-1;
}
else
if ( pos == s.cursor.x ) s.cursor.x++;
} else {
if (!(s.flags & KateView::sfBackward)) {
s.cursor.x = 0;
s.cursor.y = 0;
} else {
s.cursor.x = -1;
s.cursor.y = myDoc->lastLine();
}
s.flags |= KateView::sfFinished;
}
if (!(s.flags & KateView::sfBackward)) {
if (!(s.cursor.x || s.cursor.y))
s.flags |= KateView::sfFinished;
}
s.startCursor = s.cursor;
}
void KateView::continueSearch(SConfig &s) {
if (!(s.flags & KateView::sfBackward)) {
s.cursor.x = 0;
s.cursor.y = 0;
} else {
s.cursor.x = -1;
s.cursor.y = myDoc->lastLine();
}
s.flags |= KateView::sfFinished;
s.flags &= ~KateView::sfAgain;
}
void KateView::findAgain(SConfig &s) {
int query;
PointStruc cursor;
QString str;
QString searchFor = myDoc->searchForList.first();
if( searchFor.isEmpty() ) {
find();
return;
}
do {
query = KMessageBox::Cancel;
if (myDoc->doSearch(s,searchFor)) {
cursor = s.cursor;
if (!(s.flags & KateView::sfBackward))
s.cursor.x += s.matchedLength;
myViewInternal->updateCursor(s.cursor); //does deselectAll()
exposeFound(cursor,s.matchedLength,(s.flags & KateView::sfAgain) ? 0 : KateView::ufUpdateOnScroll,false);
} else {
if (!(s.flags & KateView::sfFinished)) {
// ask for continue
if (!(s.flags & KateView::sfBackward)) {
// forward search
str = i18n("End of document reached.\n"
"Continue from the beginning?");
query = KMessageBox::warningContinueCancel(this,
str, i18n("Find"), i18n("Continue"));
} else {
// backward search
str = i18n("Beginning of document reached.\n"
"Continue from the end?");
query = KMessageBox::warningContinueCancel(this,
str, i18n("Find"), i18n("Continue"));
}
continueSearch(s);
} else {
// wrapped
KMessageBox::sorry(this,
i18n("Search string '%1' not found!").arg(searchFor),
i18n("Find"));
}
}
} while (query == KMessageBox::Continue);
}
void KateView::replaceAgain() {
if (isReadOnly())
return;
replaces = 0;
if (s.flags & KateView::sfPrompt) {
doReplaceAction(-1);
} else {
doReplaceAction(KateView::srAll);
}
}
void KateView::doReplaceAction(int result, bool found) {
int rlen;
PointStruc cursor;
bool started;
QString searchFor = myDoc->searchForList.first();
QString replaceWith = myDoc->replaceWithList.first();
rlen = replaceWith.length();
switch (result) {
case KateView::srYes: //yes
myDoc->recordStart(this, s.cursor, configFlags,
KateActionGroup::ugReplace, true);
myDoc->recordReplace(s.cursor, s.matchedLength, replaceWith);
replaces++;
if (s.cursor.y == s.startCursor.y && s.cursor.x < s.startCursor.x)
s.startCursor.x += rlen - s.matchedLength;
if (!(s.flags & KateView::sfBackward)) s.cursor.x += rlen;
myDoc->recordEnd(this, s.cursor, configFlags | KateView::cfPersistent);
break;
case KateView::srNo: //no
if (!(s.flags & KateView::sfBackward)) s.cursor.x += s.matchedLength;
break;
case KateView::srAll: //replace all
deleteReplacePrompt();
do {
started = false;
while (found || myDoc->doSearch(s,searchFor)) {
if (!started) {
found = false;
myDoc->recordStart(this, s.cursor, configFlags,
KateActionGroup::ugReplace);
started = true;
}
myDoc->recordReplace(s.cursor, s.matchedLength, replaceWith);
replaces++;
if (s.cursor.y == s.startCursor.y && s.cursor.x < s.startCursor.x)
s.startCursor.x += rlen - s.matchedLength;
if (!(s.flags & KateView::sfBackward)) s.cursor.x += rlen;
}
if (started) myDoc->recordEnd(this, s.cursor,
configFlags | KateView::cfPersistent);
} while (!askReplaceEnd());
return;
case KateView::srCancel: //cancel
deleteReplacePrompt();
return;
default:
replacePrompt = 0L;
}
do {
if (myDoc->doSearch(s,searchFor)) {
//text found: highlight it, show replace prompt if needed and exit
cursor = s.cursor;
if (!(s.flags & KateView::sfBackward)) cursor.x += s.matchedLength;
myViewInternal->updateCursor(cursor); //does deselectAll()
exposeFound(s.cursor,s.matchedLength,(s.flags & KateView::sfAgain) ? 0 : KateView::ufUpdateOnScroll,true);
if (replacePrompt == 0L) {
replacePrompt = new ReplacePrompt(this);
myDoc->setPseudoModal(replacePrompt);//disable();
connect(replacePrompt,SIGNAL(clicked()),this,SLOT(replaceSlot()));
replacePrompt->show(); //this is not modal
}
return; //exit if text found
}
//nothing found: repeat until user cancels "repeat from beginning" dialog
} while (!askReplaceEnd());
deleteReplacePrompt();
}
void KateView::exposeFound(PointStruc &cursor, int slen, int flags, bool replace) {
int x1, x2, y1, y2, xPos, yPos;
VConfig c;
myViewInternal->getVConfig(c);
myDoc->selectLength(cursor,slen,c.flags);
TextLine::Ptr textLine = myDoc->getTextLine(cursor.y);
x1 = myDoc->textWidth(textLine,cursor.x) -10;
x2 = myDoc->textWidth(textLine,cursor.x + slen) +20;
y1 = myDoc->fontHeight*cursor.y -10;
y2 = y1 + myDoc->fontHeight +30;
xPos = myViewInternal->xPos;
yPos = myViewInternal->yPos;
if (x1 < 0) x1 = 0;
if (replace) y2 += 90;
if (x1 < xPos || x2 > xPos + myViewInternal->width()) {
xPos = x2 - myViewInternal->width();
}
if (y1 < yPos || y2 > yPos + myViewInternal->height()) {
xPos = x2 - myViewInternal->width();
yPos = myDoc->fontHeight*cursor.y - height()/3;
}
myViewInternal->setPos(xPos, yPos);
myViewInternal->updateView(flags);// | ufPos,xPos,yPos);
myDoc->updateViews(this);
}
void KateView::deleteReplacePrompt() {
myDoc->setPseudoModal(0L);
}
bool KateView::askReplaceEnd() {
QString str;
int query;
myDoc->updateViews();
if (s.flags & KateView::sfFinished) {
// replace finished
str = i18n("%1 replacement(s) made").arg(replaces);
KMessageBox::information(this, str, i18n("Replace"));
return true;
}
// ask for continue
if (!(s.flags & KateView::sfBackward)) {
// forward search
str = i18n("%1 replacement(s) made.\n"
"End of document reached.\n"
"Continue from the beginning?").arg(replaces);
query = KMessageBox::questionYesNo(this, str, i18n("Replace"),
i18n("Continue"), i18n("Stop"));
} else {
// backward search
str = i18n("%1 replacement(s) made.\n"
"Beginning of document reached.\n"
"Continue from the end?").arg(replaces);
query = KMessageBox::questionYesNo(this, str, i18n("Replace"),
i18n("Continue"), i18n("Stop"));
}
replaces = 0;
continueSearch(s);
return (query == KMessageBox::No);
}
void KateView::replaceSlot() {
doReplaceAction(replacePrompt->result(),true);
}
void KateView::installPopup(QPopupMenu *rmb_Menu)
{
rmbMenu = rmb_Menu;
}
void KateView::readConfig()
{
KConfig *config = KGlobal::config();
config->setGroup("Kate View");
searchFlags = config->readNumEntry("SearchFlags", KateView::sfPrompt);
configFlags = config->readNumEntry("ConfigFlags", configFlags) & ~KateView::cfMark;
config->sync();
}
void KateView::writeConfig()
{
KConfig *config = KGlobal::config();
config->setGroup("Kate View");
config->writeEntry("SearchFlags",searchFlags);
config->writeEntry("ConfigFlags",configFlags);
config->sync();
}
void KateView::readSessionConfig(KConfig *config)
{
PointStruc cursor;
myViewInternal->xPos = config->readNumEntry("XPos");
myViewInternal->yPos = config->readNumEntry("YPos");
cursor.x = config->readNumEntry("CursorX");
cursor.y = config->readNumEntry("CursorY");
myViewInternal->updateCursor(cursor);
myIconBorder = config->readBoolEntry("IconBorder on");
setIconBorder(myIconBorder);
}
void KateView::writeSessionConfig(KConfig *config)
{
config->writeEntry("XPos",myViewInternal->xPos);
config->writeEntry("YPos",myViewInternal->yPos);
config->writeEntry("CursorX",myViewInternal->cursor.x);
config->writeEntry("CursorY",myViewInternal->cursor.y);
config->writeEntry("IconBorder on", myIconBorder);
}
void KateView::configDialog()
{
#warning fixme
#if 1
KDialogBase *kd = new KDialogBase(KDialogBase::IconList,
i18n("Configure Editor"),
KDialogBase::Ok | KDialogBase::Cancel |
KDialogBase::Help ,
KDialogBase::Ok, this, "tabdialog");
// color options
QFrame *page=kd->addPage(i18n("Colors"));
(new QVBoxLayout(page))->setAutoAdd(true);
ColorConfig *colorConfig = new ColorConfig(page);
QColor* colors = getColors();
colorConfig->setColors(colors);
page = kd->addPage(i18n("Fonts"));
(new QVBoxLayout(page))->setAutoAdd(true);
FontConfig *fontConfig = new FontConfig(page);
fontConfig->setFont (myDoc->getFont());
// indent options
page=kd->addPage(i18n("Indent"));
(new QVBoxLayout(page))->setAutoAdd(true);
IndentConfigTab *indentConfig = new IndentConfigTab(page, this);
// select options
page=kd->addPage(i18n("Select"));
(new QVBoxLayout(page))->setAutoAdd(true);
SelectConfigTab *selectConfig = new SelectConfigTab(page, this);
// edit options
page=kd->addPage(i18n("Edit"));
(new QVBoxLayout(page))->setAutoAdd(true);
EditConfigTab *editConfig = new EditConfigTab(page, this);
HighlightDialogPage *hlPage;
HlManager *hlManager;
HlDataList hlDataList;
ItemStyleList defaultStyleList;
hlManager = HlManager::self();
defaultStyleList.setAutoDelete(true);
hlManager->getDefaults(defaultStyleList);
hlDataList.setAutoDelete(true);
//this gets the data from the KConfig object
hlManager->getHlDataList(hlDataList);
page=kd->addPage(i18n("Highlighting"));
(new QVBoxLayout(page))->setAutoAdd(true);
hlPage = new HighlightDialogPage(hlManager, &defaultStyleList, &hlDataList, 0, page);
kd->showMaximized();
if (kd->exec()) {
// color options
colorConfig->getColors(colors);
myDoc->setFont (fontConfig->getFont());
applyColors();
// indent options
indentConfig->getData(this);
// select options
selectConfig->getData(this);
// edit options
editConfig->getData(this);
// spell checker
hlManager->setHlDataList(hlDataList);
hlManager->setDefaults(defaultStyleList);
hlPage->saveData();
}
- delete kd;
+// delete kd;
#endif
}
int KateView::getHl() {
return myDoc->highlightNum();
}
void KateView::setDontChangeHlOnSave()
{
myDoc->setDontChangeHlOnSave();
}
void KateView::setHl(int n) {
myDoc->setHighlight(n);
myDoc->setDontChangeHlOnSave();
myDoc->updateViews();
}
int KateView::getEol() {
return myDoc->eolMode;
}
void KateView::setEol(int eol) {
if (isReadOnly())
return;
myDoc->eolMode = eol;
myDoc->setModified(true);
}
void KateView::paintEvent(QPaintEvent *e) {
int x, y;
QRect updateR = e->rect(); // update rectangle
// debug("Update rect = ( %i, %i, %i, %i )",
// updateR.x(),updateR.y(), updateR.width(), updateR.height() );
int ux1 = updateR.x();
int uy1 = updateR.y();
int ux2 = ux1 + updateR.width();
int uy2 = uy1 + updateR.height();
QPainter paint;
paint.begin(this);
QColorGroup g = colorGroup();
x = width();
y = height();
paint.setPen(g.dark());
if (uy1 <= 0) paint.drawLine(0,0,x-2,0);
if (ux1 <= 0) paint.drawLine(0,1,0,y-2);
paint.setPen(black);
if (uy1 <= 1) paint.drawLine(1,1,x-3,1);
if (ux1 <= 1) paint.drawLine(1,2,1,y-3);
paint.setPen(g.midlight());
if (uy2 >= y-1) paint.drawLine(1,y-2,x-3,y-2);
if (ux2 >= x-1) paint.drawLine(x-2,1,x-2,y-2);
paint.setPen(g.light());
if (uy2 >= y) paint.drawLine(0,y-1,x-2,y-1);
if (ux2 >= x) paint.drawLine(x-1,0,x-1,y-1);
x -= 2 + 16;
y -= 2 + 16;
if (ux2 > x && uy2 > y) {
paint.fillRect(x,y,16,16,g.background());
}
paint.end();
}
void KateView::resizeEvent(QResizeEvent *) {
// debug("Resize %d, %d",e->size().width(),e->size().height());
//myViewInternal->resize(width() -20, height() -20);
myViewInternal->tagAll();
myViewInternal->updateView(0/*ufNoScroll*/);
}
// Applies a new pattern to the search context.
void SConfig::setPattern(QString &newPattern) {
bool regExp = (flags & KateView::sfRegularExpression);
m_pattern = newPattern;
if (regExp) {
m_regExp.setCaseSensitive(flags & KateView::sfCaseSensitive);
m_regExp.setPattern(m_pattern);
}
}
// Applies the search context to the given string, and returns whether a match was found. If one is,
// the length of the string matched is also returned.
int SConfig::search(QString &text, int index) {
bool regExp = (flags & KateView::sfRegularExpression);
bool caseSensitive = (flags & KateView::sfCaseSensitive);
if (flags & KateView::sfBackward) {
if (regExp) {
index = text.findRev(m_regExp, index);
}
else {
index = text.findRev(m_pattern, index, caseSensitive);
}
}
else {
if (regExp) {
index = text.find(m_regExp, index);
}
else {
index = text.find(m_pattern, index, caseSensitive);
}
}
// Work out the matched length.
if (index != -1)
{
if (regExp) {
m_regExp.match(text, index, &matchedLength, false);
}
else {
matchedLength = m_pattern.length();
}
}
return index;
}
void KateView::setActive (bool b)
{
active = b;
}
bool KateView::isActive ()
{
return active;
}
void KateView::setFocus ()
{
QWidget::setFocus ();
emit gotFocus (this);
}
bool KateView::eventFilter (QObject *object, QEvent *event)
{
if ( (event->type() == QEvent::FocusIn) )
emit gotFocus (this);
if ( (event->type() == QEvent::KeyPress) )
{
QKeyEvent * ke=(QKeyEvent *)event;
if ((ke->key()==Qt::Key_Tab) || (ke->key()==Qt::Key_BackTab))
{
myViewInternal->keyPressEvent(ke);
return true;
}
}
return QWidget::eventFilter (object, event);
}
void KateView::findAgain (bool back)
{
bool b= (searchFlags & sfBackward) > 0;
initSearch(s, (searchFlags & ((b==back)?~sfBackward:~0) & ~sfFromBeginning) // clear flag for forward searching
| sfPrompt | sfAgain | ((b!=back)?sfBackward:0) );
if (s.flags & sfReplace)
replaceAgain();
else
KateView::findAgain(s);
}
void KateView::slotEditCommand ()
{
#warning fixme
/*
bool ok;
QString cmd = KLineEditDlg::getText("Editing Command", "", &ok, this);
if (ok)
myDoc->cmd()->execCmd (cmd, this);*/
}
void KateView::setIconBorder (bool enable)
{
myIconBorder = enable;
if (myIconBorder)
{
myViewInternal->move(myViewInternal->iconBorderWidth+2, 2);
myViewInternal->leftBorder->show();
}
else
{
myViewInternal->leftBorder->hide();
myViewInternal->move(2, 2);
}
}
void KateView::toggleIconBorder ()
{
setIconBorder (!myIconBorder);
}
void KateView::gotoMark (Kate::Mark *mark)
{
PointStruc cursor;
cursor.x = 0;
cursor.y = mark->line;
myDoc->needPreHighlight(cursor.y);
myViewInternal->updateCursor(cursor);
myViewInternal->center();
myViewInternal->updateView(KateView::ufUpdateOnScroll);
myDoc->updateViews(this);
}
void KateView::toggleBookmark ()
{
TextLine::Ptr line = myDoc->getTextLine (currentLine());
if (line->mark()&KateDocument::Bookmark)
line->delMark(KateDocument::Bookmark);
else
line->addMark(KateDocument::Bookmark);
myDoc->tagLines (currentLine(), currentLine());
myDoc->updateViews();
}
void KateView::clearBookmarks()
{
QList<Kate::Mark> list = myDoc->marks();
for (int i=0; (uint) i < list.count(); i++)
{
if (list.at(i)->type&KateDocument::Bookmark)
{
myDoc->getTextLine(list.at(i)->line)->delMark(KateDocument::Bookmark);
myDoc->tagLines(list.at(i)->line, list.at(i)->line);
}
}
myDoc->updateViews();
}
void KateView::bookmarkMenuAboutToShow()
{
#warning fixme
#if 0
bookmarkMenu->popupMenu()->clear ();
bookmarkToggle->plug (bookmarkMenu->popupMenu());
bookmarkClear->plug (bookmarkMenu->popupMenu());
bookmarkMenu->popupMenu()->insertSeparator ();
list = myDoc->marks();
for (int i=0; (uint) i < list.count(); i++)
{
if (list.at(i)->type&KateDocument::Bookmark)
{
QString bText = textLine(list.at(i)->line);
bText.truncate(32);
bText.append ("...");
bookmarkMenu->popupMenu()->insertItem ( QString("%1 - \"%2\"").arg(list.at(i)->line).arg(bText), this, SLOT (gotoBookmark(int)), 0, i );
}
}
#endif
}
void KateView::gotoBookmark (int n)
{
gotoMark (list.at(n));
}
int KateView::getHlCount ()
{
return HlManager::self()->highlights();
}
QString KateView::getHlName (int z)
{
return HlManager::self()->hlName(z);
}
QString KateView::getHlSection (int z)
{
return HlManager::self()->hlSection (z);
}
void KateView::slotIncFontSizes ()
{
QFont font = myDoc->getFont();
font.setPointSize (font.pointSize()+2);
myDoc->setFont (font);
}
void KateView::slotDecFontSizes ()
{
QFont font = myDoc->getFont();
font.setPointSize (font.pointSize()-2);
myDoc->setFont (font);
}
const char*bookmark_xpm[]={
"12 16 4 1",
"b c #808080",
"a c #000080",
"# c #0000ff",
". c None",
"............",
"............",
"........###.",
".......#...a",
"......#.##.a",
".....#.#..aa",
"....#.#...a.",
"...#.#.a.a..",
"..#.#.a.a...",
".#.#.a.a....",
"#.#.a.a.....",
"#.#a.a...bbb",
"#...a..bbb..",
".aaa.bbb....",
"............",
"............"};
const char* breakpoint_xpm[]={
"11 16 6 1",
"c c #c6c6c6",
". c None",
"# c #000000",
"d c #840000",
"a c #ffffff",
"b c #ff0000",
"...........",
"...........",
"...#####...",
"..#aaaaa#..",
".#abbbbbb#.",
"#abbbbbbbb#",
"#abcacacbd#",
"#abbbbbbbb#",
"#abcacacbd#",
"#abbbbbbbb#",
".#bbbbbbb#.",
"..#bdbdb#..",
"...#####...",
"...........",
"...........",
"..........."};
const char*breakpoint_bl_xpm[]={
"11 16 7 1",
"a c #c0c0ff",
"# c #000000",
"c c #0000c0",
"e c #0000ff",
"b c #dcdcdc",
"d c #ffffff",
". c None",
"...........",
"...........",
"...#####...",
"..#ababa#..",
".#bcccccc#.",
"#acccccccc#",
"#bcadadace#",
"#acccccccc#",
"#bcadadace#",
"#acccccccc#",
".#ccccccc#.",
"..#cecec#..",
"...#####...",
"...........",
"...........",
"..........."};
const char*breakpoint_gr_xpm[]={
"11 16 6 1",
"c c #c6c6c6",
"d c #2c2c2c",
"# c #000000",
". c None",
"a c #ffffff",
"b c #555555",
"...........",
"...........",
"...#####...",
"..#aaaaa#..",
".#abbbbbb#.",
"#abbbbbbbb#",
"#abcacacbd#",
"#abbbbbbbb#",
"#abcacacbd#",
"#abbbbbbbb#",
".#bbbbbbb#.",
"..#bdbdb#..",
"...#####...",
"...........",
"...........",
"..........."};
const char*ddd_xpm[]={
"11 16 4 1",
"a c #00ff00",
"b c #000000",
". c None",
"# c #00c000",
"...........",
"...........",
"...........",
"#a.........",
"#aaa.......",
"#aaaaa.....",
"#aaaaaaa...",
"#aaaaaaaaa.",
"#aaaaaaa#b.",
"#aaaaa#b...",
"#aaa#b.....",
"#a#b.......",
"#b.........",
"...........",
"...........",
"..........."};
KateIconBorder::KateIconBorder(KateView *view, KateViewInternal *internalView)
: QWidget(view), myView(view), myInternalView(internalView)
{
lmbSetsBreakpoints = true;
}
KateIconBorder::~KateIconBorder()
{
}
void KateIconBorder::paintLine(int i)
{
if (!myView->myIconBorder) return;
QPainter p(this);
int fontHeight = myView->doc()->fontHeight;
int y = i*fontHeight - myInternalView->yPos;
p.fillRect(0, y, myInternalView->iconBorderWidth-2, fontHeight, colorGroup().background());
p.setPen(white);
p.drawLine(myInternalView->iconBorderWidth-2, y, myInternalView->iconBorderWidth-2, y + fontHeight);
p.setPen(QColor(colorGroup().background()).dark());
p.drawLine(myInternalView->iconBorderWidth-1, y, myInternalView->iconBorderWidth-1, y + fontHeight);
TextLine *line = myView->doc()->getTextLine(i);
if (!line)
return;
if (line->mark()&KateDocument::Bookmark)
p.drawPixmap(2, y, QPixmap(bookmark_xpm)); /*
if (line && (line->breakpointId() != -1)) {
if (!line->breakpointEnabled())
p.drawPixmap(2, y, QPixmap(breakpoint_gr_xpm));
else if (line->breakpointPending())
p.drawPixmap(2, y, QPixmap(breakpoint_bl_xpm));
else
p.drawPixmap(2, y, QPixmap(breakpoint_xpm));
}
if (line->isExecutionPoint())
p.drawPixmap(2, y, QPixmap(ddd_xpm)); */
}
void KateIconBorder::paintEvent(QPaintEvent* e)
{
if (!myView->myIconBorder) return;
int lineStart = 0;
int lineEnd = 0;
QRect updateR = e->rect();
KateDocument *doc = myView->doc();
int h = doc->fontHeight;
int yPos = myInternalView->yPos;
if (h) {
lineStart = (yPos + updateR.y()) / h;
lineEnd = QMAX((yPos + updateR.y() + updateR.height()) / h, (int)doc->numLines());
}
for(int i = lineStart; i <= lineEnd; ++i)
paintLine(i);
}
void KateIconBorder::mousePressEvent(QMouseEvent* e)
{
myInternalView->placeCursor( 0, e->y(), 0 );
KateDocument *doc = myView->doc();
int cursorOnLine = (e->y() + myInternalView->yPos) / doc->fontHeight;
TextLine *line = doc->getTextLine(cursorOnLine);
switch (e->button()) {
case LeftButton:
if (!line)
break;
else
diff --git a/noncore/apps/tinykate/libkate/view/kateviewdialog.cpp b/noncore/apps/tinykate/libkate/view/kateviewdialog.cpp
index a311042..6a19e01 100644
--- a/noncore/apps/tinykate/libkate/view/kateviewdialog.cpp
+++ b/noncore/apps/tinykate/libkate/view/kateviewdialog.cpp
@@ -1,556 +1,573 @@
/***************************************************************************
kateviewdialog.cpp - description
-------------------
copyright : (C) 2001 by The Kate Team
(C) 2002 by Joseph Wenninger
email : kwrite-devel@kde.org
jowenn@kde.org
***************************************************************************/
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
// Dialogs
#include <stdio.h>
#include <stdlib.h>
#include <qgrid.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qlistbox.h>
#include <qspinbox.h>
#include <qcombobox.h>
#include <qgroupbox.h>
#include <qlineedit.h>
#include <qcheckbox.h>
#include <qcollection.h>
#include <qpushbutton.h>
#include <qobjectlist.h>
#include <qradiobutton.h>
#include <qwhatsthis.h>
#include <qstringlist.h>
#include <klocale.h>
#include <kcolorbtn.h>
#include <qcombobox.h>
#include <kglobal.h>
#include <qvbox.h>
#include <qspinbox.h>
#include <kfontdialog.h>
#include "../document/katedocument.h"
#include "kateviewdialog.h"
+#include <opie/ofontselector.h>
+
SearchDialog::SearchDialog( QWidget *parent, QStringList &searchFor, QStringList &replaceWith, int flags )
: KDialogBase( parent, 0L, true, i18n( "Find Text" ), Ok | Cancel, Ok )
, m_replace( 0L )
{
QWidget *page = new QWidget( this );
setMainWidget( page );
QVBoxLayout *topLayout = new QVBoxLayout( page, 0, spacingHint() );
m_search = new QComboBox( true, page );
m_search->insertStringList( searchFor );
m_search->setMinimumWidth( m_search->sizeHint().width() );
m_search->lineEdit()->selectAll();
QLabel *label = new QLabel( m_search, i18n( "&Text To Find:" ), page );
m_optRegExp = new QCheckBox( i18n( "Regular Expression" ), page );
topLayout->addWidget( label );
topLayout->addWidget( m_search );
topLayout->addWidget( m_optRegExp );
if( flags & KateView::sfReplace )
{
// make it a replace dialog
setCaption( i18n( "Replace Text" ) );
m_replace = new QComboBox( true, page );
m_replace->insertStringList( replaceWith );
m_replace->setMinimumWidth( m_search->sizeHint().width() );
label = new QLabel( m_replace, i18n( "&Replace With:" ), page );
//m_optPlaceholders = new QCheckBox( i18n( "&Use Placeholders" ), page );
topLayout->addWidget( label );
topLayout->addWidget( m_replace );
//topLayout->addWidget( m_optPlaceholders );
}
QGroupBox *group = new QGroupBox( i18n( "Options" ), page );
topLayout->addWidget( group, 10 );
QGridLayout *gbox = new QGridLayout( group, 5, 2, spacingHint() );
gbox->addRowSpacing( 0, fontMetrics().lineSpacing() );
gbox->setRowStretch( 4, 10 );
m_opt1 = new QCheckBox( i18n( "C&ase Sensitive" ), group );
gbox->addWidget( m_opt1, 1, 0 );
m_opt2 = new QCheckBox(i18n("&Whole Words Only" ), group );
gbox->addWidget( m_opt2, 2, 0 );
m_opt3 = new QCheckBox(i18n("&From Beginning" ), group );
gbox->addWidget( m_opt3, 3, 0 );
m_opt4 = new QCheckBox(i18n("Find &Backwards" ), group );
gbox->addWidget( m_opt4, 1, 1 );
m_opt5 = new QCheckBox(i18n("&Selected Text" ), group );
gbox->addWidget( m_opt5, 2, 1 );
m_opt1->setChecked( flags & KateView::sfCaseSensitive );
m_opt2->setChecked( flags & KateView::sfWholeWords );
m_opt3->setChecked( flags & KateView::sfFromBeginning );
m_optRegExp->setChecked( flags & KateView::sfRegularExpression );
m_opt4->setChecked( flags & KateView::sfBackward );
m_opt5->setChecked( flags & KateView::sfSelected );
if( m_replace )
{
m_opt6 = new QCheckBox( i18n( "&Prompt On Replace" ), group );
m_opt6->setChecked( flags & KateView::sfPrompt );
gbox->addWidget( m_opt6, 3, 1 );
}
m_search->setFocus();
}
QString SearchDialog::getSearchFor()
{
return m_search->currentText();
}
QString SearchDialog::getReplaceWith()
{
return m_replace->currentText();
}
int SearchDialog::getFlags()
{
int flags = 0;
if( m_opt1->isChecked() ) flags |= KateView::sfCaseSensitive;
if( m_opt2->isChecked() ) flags |= KateView::sfWholeWords;
if( m_opt3->isChecked() ) flags |= KateView::sfFromBeginning;
if( m_opt4->isChecked() ) flags |= KateView::sfBackward;
if( m_opt5->isChecked() ) flags |= KateView::sfSelected;
if( m_optRegExp->isChecked() ) flags |= KateView::sfRegularExpression;
if( m_replace )
{
if( m_opt6->isChecked() )
flags |= KateView::sfPrompt;
flags |= KateView::sfReplace;
}
return flags;
}
void SearchDialog::slotOk()
{
if ( !m_search->currentText().isEmpty() )
{
if ( !m_optRegExp->isChecked() )
{
accept();
}
else
{
// Check for a valid regular expression.
QRegExp regExp( m_search->currentText() );
if ( regExp.isValid() )
accept();
}
}
}
void SearchDialog::setSearchText( const QString &searchstr )
{
m_search->insertItem( searchstr, 0 );
m_search->setCurrentItem( 0 );
m_search->lineEdit()->selectAll();
}
// this dialog is not modal
ReplacePrompt::ReplacePrompt( QWidget *parent )
: KDialogBase(parent, 0L, false, i18n( "Replace Text" ),
User3 | User2 | User1 | Close, User3, true,
i18n("&All"), i18n("&No"), i18n("&Yes")) {
QWidget *page = new QWidget(this);
setMainWidget(page);
QBoxLayout *topLayout = new QVBoxLayout( page, 0, spacingHint() );
QLabel *label = new QLabel(i18n("Replace this occurence?"),page);
topLayout->addWidget(label );
}
void ReplacePrompt::slotUser1( void ) { // All
done(KateView::srAll);
}
void ReplacePrompt::slotUser2( void ) { // No
done(KateView::srNo);
}
void ReplacePrompt::slotUser3( void ) { // Yes
accept();
}
void ReplacePrompt::done(int r) {
setResult(r);
emit clicked();
}
void ReplacePrompt::closeEvent(QCloseEvent *) {
reject();
}
GotoLineDialog::GotoLineDialog(QWidget *parent, int line, int max)
: KDialogBase(parent, 0L, true, i18n("Goto Line"), Ok | Cancel, Ok) {
QWidget *page = new QWidget(this);
setMainWidget(page);
QVBoxLayout *topLayout = new QVBoxLayout( page, 0, spacingHint() );
e1 = new QSpinBox(page);
e1->setMinValue(1);
e1->setMaxValue(max);
e1->setValue((int)line);
QLabel *label = new QLabel( e1,i18n("&Goto Line:"), page );
topLayout->addWidget(label);
topLayout->addWidget(e1);
topLayout->addSpacing(spacingHint()); // A little bit extra space
topLayout->addStretch(10);
e1->setFocus();
}
int GotoLineDialog::getLine() {
return e1->value();
}
const int IndentConfigTab::flags[] = {KateView::cfAutoIndent, KateView::cfSpaceIndent,
KateView::cfBackspaceIndents,KateView::cfTabIndents, KateView::cfKeepIndentProfile, KateView::cfKeepExtraSpaces};
IndentConfigTab::IndentConfigTab(QWidget *parent, KateView *view)
: QWidget(parent, 0L)
{
QVBoxLayout *layout = new QVBoxLayout(this, 0, KDialog::spacingHint() );
int configFlags = view->config();
opt[0] = new QCheckBox(i18n("&Auto Indent"), this);
layout->addWidget(opt[0], 0, AlignLeft);
opt[0]->setChecked(configFlags & flags[0]);
opt[1] = new QCheckBox(i18n("Indent With &Spaces"), this);
layout->addWidget(opt[1], 0, AlignLeft);
opt[1]->setChecked(configFlags & flags[1]);
opt[2] = new QCheckBox(i18n("&Backspace Key Indents"), this);
layout->addWidget(opt[2], 0, AlignLeft);
opt[2]->setChecked(configFlags & flags[2]);
opt[3] = new QCheckBox(i18n("&Tab Key Indents"), this);
layout->addWidget(opt[3], 0, AlignLeft);
opt[3]->setChecked(configFlags & flags[3]);
opt[4] = new QCheckBox(i18n("Keep Indent &Profile"), this);
layout->addWidget(opt[4], 0, AlignLeft);
// opt[4]->setChecked(configFlags & flags[4]);
opt[4]->setChecked(true);
opt[4]->hide();
opt[5] = new QCheckBox(i18n("&Keep Extra Spaces"), this);
layout->addWidget(opt[5], 0, AlignLeft);
opt[5]->setChecked(configFlags & flags[5]);
layout->addStretch();
// What is this? help
QWhatsThis::add(opt[0], i18n("When <b>Auto indent</b> is on, KateView will indent new lines to equal the indent on the previous line.<p>If the previous line is blank, the nearest line above with text is used"));
QWhatsThis::add(opt[1], i18n("Check this if you want to indent with spaces rather than tabs.<br>A Tab will be converted to <u>Tab-width</u> as set in the <b>edit</b> options"));
QWhatsThis::add(opt[2], i18n("This allows the <b>backspace</b> key to be used to indent."));
QWhatsThis::add(opt[3], i18n("This allows the <b>tab</b> key to be used to indent."));
QWhatsThis::add(opt[4], i18n("This retains current indentation settings for future documents."));
QWhatsThis::add(opt[5], i18n("Indentations of more than the selected number of spaces will not be shortened."));
}
void IndentConfigTab::getData(KateView *view) {
int configFlags, z;
configFlags = view->config();
for (z = 0; z < numFlags; z++) {
configFlags &= ~flags[z];
if (opt[z]->isChecked()) configFlags |= flags[z];
}
view->setConfig(configFlags);
}
const int SelectConfigTab::flags[] = {KateView::cfPersistent, KateView::cfDelOnInput,
KateView::cfMouseAutoCopy, KateView::cfSingleSelection, KateView::cfVerticalSelect, KateView::cfXorSelect};
SelectConfigTab::SelectConfigTab(QWidget *parent, KateView *view)
: QWidget(parent, 0L)
{
QVBoxLayout *layout = new QVBoxLayout(this, 0, KDialog::spacingHint() );
int configFlags = view->config();
opt[0] = new QCheckBox(i18n("&Persistent Selections"), this);
layout->addWidget(opt[0], 0, AlignLeft);
opt[0]->setChecked(configFlags & flags[0]);
opt[1] = new QCheckBox(i18n("&Overwrite Selections"), this);
layout->addWidget(opt[1], 0, AlignLeft);
opt[1]->setChecked(configFlags & flags[1]);
opt[2] = new QCheckBox(i18n("Mouse &Autocopy"), this);
layout->addWidget(opt[2], 0, AlignLeft);
opt[2]->setChecked(configFlags & flags[2]);
opt[3] = new QCheckBox(i18n("&X11-like Single Selection"), this);
layout->addWidget(opt[3], 0, AlignLeft);
opt[3]->setChecked(configFlags & flags[3]);
opt[4] = new QCheckBox(i18n("&Vertical Selections"), this);
layout->addWidget(opt[4], 0, AlignLeft);
opt[4]->setChecked(configFlags & flags[4]);
opt[5] = new QCheckBox(i18n("&Toggle Old"), this);
layout->addWidget(opt[5], 0, AlignLeft);
opt[5]->setChecked(configFlags & flags[5]);
layout->addStretch();
// What is this? help
QWhatsThis::add(opt[0], i18n("Enabling this prevents key input or cursor movement by way of the arrow keys from causing the elimination of text selection.<p><b>Note:</b> If the Overwrite Selections option is activated then any typed character input or paste operation will replace the selected text."));
QWhatsThis::add(opt[1], i18n("When this is on, any keyed character input or paste operation will replace the selected text."));
QWhatsThis::add(opt[2], i18n("When this is on, any text selected with the mouse will be automatically copied to the clipboard."));
QWhatsThis::add(opt[3], i18n("Not implemented yet."));
QWhatsThis::add(opt[4], i18n("Enabling this allows you to make vertical selections."));
QWhatsThis::add(opt[5], i18n("Not yet implemented."));
}
void SelectConfigTab::getData(KateView *view) {
int configFlags, z;
configFlags = view->config();
for (z = 0; z < numFlags; z++) {
configFlags &= ~flags[z]; // clear flag
if (opt[z]->isChecked()) configFlags |= flags[z]; // set flag if checked
}
view->setConfig(configFlags);
}
const int EditConfigTab::flags[] = {KateView::cfWordWrap, KateView::cfReplaceTabs, KateView::cfRemoveSpaces,
KateView::cfAutoBrackets, KateView::cfGroupUndo, KateView::cfShowTabs, KateView::cfSmartHome,
KateView::cfPageUDMovesCursor, KateView::cfWrapCursor};
EditConfigTab::EditConfigTab(QWidget *parent, KateView *view)
: QWidget(parent, 0L) {
QHBoxLayout *mainLayout;
QVBoxLayout *cbLayout, *leLayout;
int configFlags;
mainLayout = new QHBoxLayout(this, 0, KDialog::spacingHint() );
// checkboxes
cbLayout = new QVBoxLayout( mainLayout );
configFlags = view->config();
opt[0] = new QCheckBox(i18n("&Word wrap"), this);
cbLayout->addWidget(opt[0], 0, AlignLeft);
opt[0]->setChecked(view->doc()->wordWrap());
opt[1] = new QCheckBox(i18n("Replace &tabs with spaces"), this);
cbLayout->addWidget(opt[1], 0, AlignLeft);
opt[1]->setChecked(configFlags & flags[1]);
opt[2] = new QCheckBox(i18n("&Remove trailing spaces"), this);
cbLayout->addWidget(opt[2], 0, AlignLeft);
opt[2]->setChecked(configFlags & flags[2]);
opt[3] = new QCheckBox(i18n("&Auto brackets"), this);
cbLayout->addWidget(opt[3], 0, AlignLeft);
opt[3]->setChecked(configFlags & flags[3]);
opt[4] = new QCheckBox(i18n("Group &undos"), this);
cbLayout->addWidget(opt[4], 0, AlignLeft);
opt[4]->setChecked(configFlags & flags[4]);
opt[5] = new QCheckBox(i18n("&Show tabs"), this);
cbLayout->addWidget(opt[5], 0, AlignLeft);
opt[5]->setChecked(configFlags & flags[5]);
opt[6] = new QCheckBox(i18n("Smart &home"), this);
cbLayout->addWidget(opt[6], 0, AlignLeft);
opt[6]->setChecked(configFlags & flags[6]);
opt[7] = new QCheckBox(i18n("&Page up/down moves cursor"), this);
cbLayout->addWidget(opt[7], 0, AlignLeft);
opt[7]->setChecked(configFlags & flags[7]);
opt[8] = new QCheckBox(i18n("Wrap &cursor"), this);
cbLayout->addWidget(opt[8], 0, AlignLeft);
opt[8]->setChecked(configFlags & flags[8]);
cbLayout->addStretch();
// edit lines
leLayout = new QVBoxLayout();
mainLayout->addLayout(leLayout,10);
e1 = new QSpinBox(this);
e1->setMinValue(20);
e1->setMaxValue( 200);
e1->setValue((int)(view->doc()->wordWrapAt()));
#warning fixme e1->setLabel(i18n("Wrap Words At:"));
e2 = new QSpinBox(this);
e2->setMinValue(1);
e2->setMaxValue(16);
e2->setValue((int)view->tabWidth());
#warning fixme e2->setLabel(i18n("Tab/Indent Width:"));
e3 = new QSpinBox(this);
e3->setMinValue(5);
e3->setMaxValue( 30000);
#warning fixme e3->setLabel(i18n("Undo steps:"));
e3->setValue((int)view->undoSteps());
leLayout->addWidget(e1, 0, AlignLeft);
leLayout->addWidget(e2, 0, AlignLeft);
leLayout->addWidget(e3, 0, AlignLeft);
QVBox *box = new QVBox (this);
leLayout->addWidget (box, 0, AlignLeft);
new QLabel (i18n("Encoding:"), box);
encoding = new QComboBox(box);
#warning fixme
#if 0
encoding->insertStringList (KGlobal::charsets()->availableEncodingNames());
encoding->setCurrentItem (KGlobal::charsets()->availableEncodingNames().findIndex(view->doc()->encoding()));
#endif
leLayout->addStretch();
// What is this? help
QWhatsThis::add(opt[0], i18n("Word wrap is a feature that causes the editor to automatically start a new line of text and move (wrap) the cursor to the beginning of that new line. KateView will automatically start a new line of text when the current line reaches the length specified by the Wrap Words At: option.<p><b>NOTE:<b> Word Wrap will not change existing lines or wrap them for easy reading as in some applications."));
QWhatsThis::add(e1, i18n("If the Word Wrap option is selected this entry determines the length (in characters) at which the editor will automatically start a new line."));
QWhatsThis::add(opt[1], i18n("KateView will replace any tabs with the number of spaces indicated in the Tab Width: entry."));
QWhatsThis::add(e2, i18n("If the Replace Tabs By Spaces option is selected this entry determines the number of spaces with which the editor will automatically replace tabs."));
QWhatsThis::add(opt[2], i18n("KateView will automatically eliminate extra spaces at the ends of lines of text."));
QWhatsThis::add(opt[3], i18n("When the user types a left bracket ([,(, or {) KateView automatically enters the right bracket (}, ), or ]) to the right of the cursor."));
QWhatsThis::add(opt[4], i18n("Checking this will cause sequences of similar actions to be undone at once."));
QWhatsThis::add(opt[5], i18n("The editor will display a symbol to indicate the presence of a tab in the text."));
QWhatsThis::add(opt[6], i18n("Not yet implemented."));
QWhatsThis::add(opt[7], i18n("If this is selected, the insertion cursor will be moved to the first/last line when pressing the page up/down buttons.<p>If not selected, it will remain at it's relative position in the visible text."));
QWhatsThis::add(e3, i18n("Sets the number of undo/redo steps to record. More steps uses more memory."));
QWhatsThis::add(opt[8], i18n("When on, moving the insertion cursor using the <b>Left</b> and <b>Right</b> keys will go on to previous/next line at beginning/end of the line, similar to most editors.<p>When off, the insertion cursor cannot be moved left of the line start, but it can be moved off the line end, which can be very handy for programmers."));
}
void EditConfigTab::getData(KateView *view)
{
int configFlags, z;
configFlags = view->config();
for (z = 1; z < numFlags; z++) {
configFlags &= ~flags[z];
if (opt[z]->isChecked()) configFlags |= flags[z];
}
view->setConfig(configFlags);
view->setEncoding (encoding->currentText());
view->doc()->setWordWrapAt(e1->value());
view->doc()->setWordWrap (opt[0]->isChecked());
view->setTabWidth(e2->value());
view->setUndoSteps(e3->value());
}
ColorConfig::ColorConfig( QWidget *parent, char *name )
: QWidget( parent, name )
{
QGridLayout *glay = new QGridLayout( this, 6, 2, 0, KDialog::spacingHint());
glay->setColStretch(1,1);
glay->setRowStretch(5,1);
QLabel *label;
label = new QLabel( i18n("Background:"), this);
label->setAlignment( AlignRight|AlignVCenter );
m_back = new KColorButton( this );
glay->addWidget( label, 0, 0 );
glay->addWidget( m_back, 0, 1 );
label = new QLabel( i18n("Selected:"), this);
label->setAlignment( AlignRight|AlignVCenter );
m_selected = new KColorButton( this );
glay->addWidget( label, 2, 0 );
glay->addWidget( m_selected, 2, 1 );
// QWhatsThis help
QWhatsThis::add(m_back, i18n("Sets the background color of the editing area"));
QWhatsThis::add(m_selected, i18n("Sets the background color of the selection. To set the text color for selected text, use the &quot;<b>Configure Highlighting</b>&quot; dialog."));
}
ColorConfig::~ColorConfig()
{
}
void ColorConfig::setColors(QColor *colors)
{
m_back->setColor( colors[0] );
m_selected->setColor( colors[1] );
}
void ColorConfig::getColors(QColor *colors)
{
colors[0] = m_back->color();
colors[1] = m_selected->color();
}
FontConfig::FontConfig( QWidget *parent, char *name )
: QWidget( parent, name )
{
// sizemanagment
QGridLayout *grid = new QGridLayout( this, 1, 1 );
-#if 0
- m_fontchooser = new KFontChooser ( this );
- m_fontchooser->enableColumn(KFontChooser::StyleList, false);
- grid->addWidget( m_fontchooser, 0, 0);
-
- connect (m_fontchooser, SIGNAL (fontSelected( const QFont & )), this, SLOT (slotFontSelected( const QFont & )));
-#endif
+// QString familyStr = cfg. readEntry ( "FontFamily", "Helvetica" );
+// QString styleStr = cfg. readEntry ( "FontStyle", "Regular" );
+// int size = cfg. readNumEntry ( "FontSize", 10 );
+// OFontSelector *m_fontselect;
+
+ m_fontselect = new OFontSelector ( false, this, "FontTab" );
+// m_fontselect-> setSelectedFont ( familyStr, styleStr, size );
+// QWhatsThis::add( m_fontselect,
+// tr( "Select the desired name, style and size of the default font applications will use." ) );
+
+ connect( m_fontselect, SIGNAL( fontSelected ( const QFont & )),
+ this, SLOT( slotFontSelected( const QFont & )));
+ grid->addWidget( m_fontselect, 0, 0);
+
+
+// #if 0
+// m_fontchooser = new KFontChooser ( this );
+// m_fontchooser->enableColumn(KFontChooser::StyleList, false);
+// grid->addWidget( m_fontchooser, 0, 0);
+
+// connect (m_fontchooser, SIGNAL (fontSelected( const QFont & )), this, SLOT (slotFontSelected( const QFont & )));
+// #endif
}
FontConfig::~FontConfig()
{
}
void FontConfig::setFont ( const QFont &font )
{
-#if 0
- m_fontchooser->setFont (font);
+//#if 0
+m_fontselect->setFont (font);
myFont = font;
-#endif
+//#endif
}
void FontConfig::slotFontSelected( const QFont &font )
{
myFont = font;
}
diff --git a/noncore/apps/tinykate/libkate/view/kateviewdialog.h b/noncore/apps/tinykate/libkate/view/kateviewdialog.h
index 60f30bd..2ce5a11 100644
--- a/noncore/apps/tinykate/libkate/view/kateviewdialog.h
+++ b/noncore/apps/tinykate/libkate/view/kateviewdialog.h
@@ -1,194 +1,196 @@
/***************************************************************************
kateviewdialog.h - description
-------------------
copyright : (C) 2001 by The Kate Team
(C) 2002 by Joseph Wenninger
email : kwrite-devel@kde.org
jowenn@kde.org
***************************************************************************/
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
// Dialogs
#ifndef _KWDIALOG_H_
#define _KWDIALOG_H_
class QCheckBox;
class QLineEdit;
class QPushButton;
class QRadioButton;
class QSpinBox;
class KColorButton;
class QComboBox;
#include <kdialogbase.h>
+#include <opie/ofontselector.h>
#include "kateview.h"
class SearchDialog : public KDialogBase
{
Q_OBJECT
public:
SearchDialog( QWidget *parent, QStringList &searchFor, QStringList &replaceWith, int flags );
QString getSearchFor();
QString getReplaceWith();
int getFlags();
void setSearchText( const QString &searchstr );
protected slots:
void slotOk();
protected:
QComboBox *m_search;
QComboBox *m_replace;
QCheckBox *m_opt1;
QCheckBox *m_opt2;
QCheckBox *m_opt3;
QCheckBox *m_optRegExp;
QCheckBox *m_opt4;
QCheckBox *m_opt5;
QCheckBox *m_opt6;
};
class ReplacePrompt : public KDialogBase
{
Q_OBJECT
public:
ReplacePrompt(QWidget *parent);
signals:
void clicked();
protected slots:
void slotUser1( void ); // All
void slotUser2( void ); // No
void slotUser3( void ); // Yes
virtual void done(int);
protected:
void closeEvent(QCloseEvent *);
};
class GotoLineDialog : public KDialogBase
{
Q_OBJECT
public:
GotoLineDialog(QWidget *parent, int line, int max);
int getLine();
protected:
QSpinBox *e1;
QPushButton *btnOK;
};
class IndentConfigTab : public QWidget
{
Q_OBJECT
public:
IndentConfigTab(QWidget *parent, KateView *);
void getData(KateView *);
protected:
static const int numFlags = 6;
static const int flags[numFlags];
QCheckBox *opt[numFlags];
};
class SelectConfigTab : public QWidget
{
Q_OBJECT
public:
SelectConfigTab(QWidget *parent, KateView *);
void getData(KateView *);
protected:
static const int numFlags = 6;
static const int flags[numFlags];
QCheckBox *opt[numFlags];
};
class EditConfigTab : public QWidget
{
Q_OBJECT
public:
EditConfigTab(QWidget *parent, KateView *);
void getData(KateView *);
protected:
static const int numFlags = 9;
static const int flags[numFlags];
QCheckBox *opt[numFlags];
QComboBox *encoding;
QSpinBox *e1;
QSpinBox *e2;
QSpinBox *e3;
};
class ColorConfig : public QWidget
{
Q_OBJECT
public:
ColorConfig( QWidget *parent = 0, char *name = 0 );
~ColorConfig();
void setColors( QColor * );
void getColors( QColor * );
private:
KColorButton *m_back;
KColorButton *m_selected;
};
class FontConfig : public QWidget
{
Q_OBJECT
public:
FontConfig( QWidget *parent = 0, char *name = 0 );
~FontConfig();
void setFont ( const QFont &font );
QFont getFont ( ) { return myFont; };
private:
+ OFontSelector *m_fontselect;
// class KFontChooser *m_fontchooser;
QFont myFont;
private slots:
void slotFontSelected( const QFont &font );
};
#endif //_KWDIALOG_H_