summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/tinykate/libkate/document/katedialogs.cpp54
1 files changed, 25 insertions, 29 deletions
diff --git a/noncore/apps/tinykate/libkate/document/katedialogs.cpp b/noncore/apps/tinykate/libkate/document/katedialogs.cpp
index f4edd7e..b492c26 100644
--- a/noncore/apps/tinykate/libkate/document/katedialogs.cpp
+++ b/noncore/apps/tinykate/libkate/document/katedialogs.cpp
@@ -3,242 +3,238 @@
3 ------------------- 3 -------------------
4 copyright : (C) 2001 by The Kate Team 4 copyright : (C) 2001 by The Kate Team
5 (C) 2002 by Joseph Wenninger 5 (C) 2002 by Joseph Wenninger
6 email : kwrite-devel@kde.org 6 email : kwrite-devel@kde.org
7 jowenn@kde.org 7 jowenn@kde.org
8 8
9 ***************************************************************************/ 9 ***************************************************************************/
10 10
11/*************************************************************************** 11/***************************************************************************
12 * * 12 * *
13 * This program is free software; you can redistribute it and/or modify * 13 * This program is free software; you can redistribute it and/or modify *
14 * it under the terms of the GNU General Public License as published by * 14 * it under the terms of the GNU General Public License as published by *
15 * the Free Software Foundation; either version 2 of the License, or * 15 * the Free Software Foundation; either version 2 of the License, or *
16 * (at your option) any later version. * 16 * (at your option) any later version. *
17 * * 17 * *
18 ***************************************************************************/ 18 ***************************************************************************/
19#include "katedialogs.h" 19#include "katedialogs.h"
20#include <klocale.h> 20#include <klocale.h>
21#include <kdebug.h> 21#include <kdebug.h>
22#include <qgroupbox.h> 22#include <qgroupbox.h>
23#include <qvgroupbox.h> 23#include <qvgroupbox.h>
24#include <qhgroupbox.h> 24#include <qhgroupbox.h>
25#include <qhbox.h> 25#include <qhbox.h>
26#include <qvbox.h> 26#include <qvbox.h>
27#include <qlayout.h> 27#include <qlayout.h>
28#include <qpushbutton.h> 28#include <qpushbutton.h>
29#include <qwidgetstack.h> 29#include <qwidgetstack.h>
30#include <qlabel.h> 30#include <qlabel.h>
31#include <qlistview.h> 31#include <qlistview.h>
32#include <qlineedit.h> 32#include <qlineedit.h>
33#include <qcombobox.h> 33#include <qcombobox.h>
34#include <qcheckbox.h> 34#include <qcheckbox.h>
35//FIXME #include <kcharsets.h> 35//FIXME #include <kcharsets.h>
36#include <kglobal.h> 36#include <kglobal.h>
37#include <qmap.h> 37#include <qmap.h>
38#include <kmessagebox.h> 38#include <kmessagebox.h>
39#include <kstddirs.h> 39#include <kstddirs.h>
40 40
41 41
42/******************************************************************************************************************* 42/*******************************************************************************************************************
43* Context Editor * 43* Context Editor *
44*******************************************************************************************************************/ 44*******************************************************************************************************************/
45 45
46StyleChanger::StyleChanger( QWidget *parent ) 46StyleChanger::StyleChanger( QWidget *parent )
47 : QWidget(parent) 47 : QWidget(parent)
48{ 48{
49 QLabel *label; 49 QLabel *label;
50 50
51 QGridLayout *glay = new QGridLayout( this, 4, 3, 0, KDialog::spacingHint() ); 51 QGridLayout *glay = new QGridLayout( this, 2, 6, 0, KDialog::spacingHint() );
52 CHECK_PTR(glay); 52 CHECK_PTR(glay);
53 glay->addColSpacing( 1, KDialog::spacingHint() ); // Looks better 53 glay->addColSpacing( 1, KDialog::spacingHint() ); // Looks better
54 glay->setColStretch( 2, 10 ); 54 glay->addColSpacing( 3, KDialog::spacingHint() );
55 glay->addColSpacing( 5, KDialog::spacingHint() );
55 56
56 col = new KColorButton(this); 57 col = new KColorButton(this);
57 CHECK_PTR(col); 58 CHECK_PTR(col);
58 connect(col,SIGNAL(changed(const QColor&)),this,SLOT(changed())); 59 connect(col,SIGNAL(changed(const QColor&)),this,SLOT(changed()));
59 label = new QLabel(col,i18n("Normal:"),this); 60 label = new QLabel(col,i18n("Normal:"),this);
60 CHECK_PTR(label); 61 CHECK_PTR(label);
61 glay->addWidget(label,0,0); 62 glay->addWidget(label,0,0);
62 glay->addWidget(col,1,0); 63 glay->addWidget(col,1,0);
63 64
64 selCol = new KColorButton(this); 65 selCol = new KColorButton(this);
65 CHECK_PTR(selCol); 66 CHECK_PTR(selCol);
66 connect(selCol,SIGNAL(changed(const QColor&)),this,SLOT(changed())); 67 connect(selCol,SIGNAL(changed(const QColor&)),this,SLOT(changed()));
67 label = new QLabel(selCol,i18n("Selected:"),this); 68 label = new QLabel(selCol,i18n("Selected:"),this);
68 CHECK_PTR(label); 69 CHECK_PTR(label);
69 glay->addWidget(label,2,0); 70 glay->addWidget(label,0,2);
70 glay->addWidget(selCol,3,0); 71 glay->addWidget(selCol,1,2);
71 72
72 bold = new QCheckBox(i18n("Bold"),this); 73 bold = new QCheckBox(i18n("Bold"),this);
73 CHECK_PTR(bold); 74 CHECK_PTR(bold);
74 connect(bold,SIGNAL(clicked()),SLOT(changed())); 75 connect(bold,SIGNAL(clicked()),SLOT(changed()));
75 glay->addWidget(bold,1,2); 76 glay->addWidget(bold,0,4);
76 77
77 italic = new QCheckBox(i18n("Italic"),this); 78 italic = new QCheckBox(i18n("Italic"),this);
78 CHECK_PTR(italic); 79 CHECK_PTR(italic);
79 connect(italic,SIGNAL(clicked()),SLOT(changed())); 80 connect(italic,SIGNAL(clicked()),SLOT(changed()));
80 glay->addWidget(italic,2,2); 81 glay->addWidget(italic,1,4);
81} 82}
82 83
83void StyleChanger::setRef(ItemStyle *s) { 84void StyleChanger::setRef(ItemStyle *s) {
84 85
85 style = s; 86 style = s;
86 col->setColor(style->col); 87 col->setColor(style->col);
87 selCol->setColor(style->selCol); 88 selCol->setColor(style->selCol);
88 bold->setChecked(style->bold); 89 bold->setChecked(style->bold);
89 italic->setChecked(style->italic); 90 italic->setChecked(style->italic);
90 91
91} 92}
92 93
93void StyleChanger::setEnabled(bool enable) { 94void StyleChanger::setEnabled(bool enable) {
94 95
95 col->setEnabled(enable); 96 col->setEnabled(enable);
96 selCol->setEnabled(enable); 97 selCol->setEnabled(enable);
97 bold->setEnabled(enable); 98 bold->setEnabled(enable);
98 italic->setEnabled(enable); 99 italic->setEnabled(enable);
99} 100}
100 101
101void StyleChanger::changed() { 102void StyleChanger::changed() {
102 103
103 if (style) { 104 if (style) {
104 style->col = col->color(); 105 style->col = col->color();
105 style->selCol = selCol->color(); 106 style->selCol = selCol->color();
106 style->bold = bold->isChecked(); 107 style->bold = bold->isChecked();
107 style->italic = italic->isChecked(); 108 style->italic = italic->isChecked();
108 } 109 }
109} 110}
110 111
111HighlightDialog::HighlightDialog( HlManager *hlManager, ItemStyleList *styleList, 112HighlightDialog::HighlightDialog( HlManager *hlManager, ItemStyleList *styleList,
112 HlDataList *highlightDataList, 113 HlDataList *highlightDataList,
113 int hlNumber, QWidget *parent, 114 int hlNumber, QWidget *parent,
114 const char *name, bool modal ) 115 const char *name, bool modal )
115 :KDialogBase(parent,name,modal,i18n("Highlight Settings"), Ok|Cancel, Ok) 116 :KDialogBase(parent,name,modal,i18n("Highlight Settings"), Ok|Cancel, Ok)
116{ 117{
117// QVBox *page = makeVBoxMainWidget(); 118// QVBox *page = makeVBoxMainWidget();
118 QFrame *page=addPage("FIXME"); 119 QFrame *page=addPage("FIXME");
119 (new QVBoxLayout(page))->setAutoAdd(true); 120 (new QVBoxLayout(page))->setAutoAdd(true);
120 content=new HighlightDialogPage(hlManager,styleList,highlightDataList,hlNumber,page); 121 content=new HighlightDialogPage(hlManager,styleList,highlightDataList,hlNumber,page);
121} 122}
122 123
123void HighlightDialog::done(int r) 124void HighlightDialog::done(int r)
124{ 125{
125 kdDebug(13010)<<"HighlightDialod done"<<endl; 126 kdDebug(13010)<<"HighlightDialod done"<<endl;
126 content->saveData(); 127 content->saveData();
127 KDialogBase::done(r); 128 KDialogBase::done(r);
128} 129}
129 130
130HighlightDialogPage::HighlightDialogPage(HlManager *hlManager, ItemStyleList *styleList, 131HighlightDialogPage::HighlightDialogPage(HlManager *hlManager, ItemStyleList *styleList,
131 HlDataList* highlightDataList, 132 HlDataList* highlightDataList,
132 int hlNumber,QWidget *parent, const char *name) 133 int hlNumber,QWidget *parent, const char *name)
133 :QTabWidget(parent,name),defaultItemStyleList(styleList),hlData(0L) 134 :QTabWidget(parent,name),defaultItemStyleList(styleList),hlData(0L)
134 135
135{ 136{
136 137
137 // defaults ========================================================= 138 // defaults =========================================================
138 139
139 QFrame *page1 = new QFrame(this); 140 QFrame *page1 = new QFrame(this);
140 addTab(page1,i18n("&Defaults")); 141 addTab(page1,i18n("&Defaults"));
141 QGridLayout *grid = new QGridLayout(page1, 1, 1); 142 QGridLayout *grid = new QGridLayout(page1, 1, 1);
142 143
143 QVGroupBox *dvbox1 = new QVGroupBox( i18n("Default Item Styles"), page1 ); 144 QVGroupBox *dvbox1 = new QVGroupBox( i18n("Default Item Styles"), page1 );
144 /*QLabel *label = */new QLabel( i18n("Item:"), dvbox1 ); 145 /*QLabel *label = */new QLabel( i18n("Item:"), dvbox1 );
145 QComboBox *styleCombo = new QComboBox( false, dvbox1 ); 146 QComboBox *styleCombo = new QComboBox( false, dvbox1 );
146 defaultStyleChanger = new StyleChanger( dvbox1 ); 147 defaultStyleChanger = new StyleChanger( dvbox1 );
147 for( int i = 0; i < hlManager->defaultStyles(); i++ ) { 148 for( int i = 0; i < hlManager->defaultStyles(); i++ ) {
148 styleCombo->insertItem(hlManager->defaultStyleName(i)); 149 styleCombo->insertItem(hlManager->defaultStyleName(i));
149 } 150 }
150 connect(styleCombo, SIGNAL(activated(int)), this, SLOT(defaultChanged(int))); 151 connect(styleCombo, SIGNAL(activated(int)), this, SLOT(defaultChanged(int)));
151 grid->addWidget(dvbox1, 0,0); 152 grid->addWidget(dvbox1, 0,0);
152 153
153 defaultChanged(0); 154 defaultChanged(0);
154 155
155 // highlight modes ===================================================== 156 // highlight modes =====================================================
156 157
157 QFrame *page2 = new QFrame(this); 158 QFrame *page2 = new QFrame(this);
158 addTab(page2,i18n("&Highlight Modes")); 159 addTab(page2,i18n("&Highlight Modes"));
159 //grid = new QGridLayout(page2,2,2);
160 QVBoxLayout *bl=new QVBoxLayout(page2); 160 QVBoxLayout *bl=new QVBoxLayout(page2);
161 bl->setAutoAdd(true); 161 bl->setAutoAdd(true);
162 QHGroupBox *hbox1 = new QHGroupBox( i18n("Config Select"), page2 ); 162 QGroupBox *gbox1 = new QGroupBox( 2, Qt::Horizontal, i18n("Config Select"), page2 );
163 hbox1->layout()->setMargin(5); 163 gbox1->layout()->setMargin(5);
164 QVBox *vbox1=new QVBox(hbox1); 164 QGroupBox *gbox2 = new QGroupBox( 2, Qt::Horizontal, i18n("Item Style"), page2 );
165// grid->addMultiCellWidget(vbox1,0,0,0,1); 165 gbox2->layout()->setMargin(5);
166 QVGroupBox *vbox2 = new QVGroupBox( i18n("Item Style"), page2 ); 166
167// grid->addWidget(vbox2,1,0); 167 QLabel *label = new QLabel( i18n("Highlight:"), gbox1 );
168 QVGroupBox *vbox3 = new QVGroupBox( i18n("Highlight Auto Select"), hbox1 ); 168 hlCombo = new QComboBox( false, gbox1 );
169 //grid->addWidget(vbox3,1,1); 169 hlCombo->setSizePolicy( QSizePolicy( QSizePolicy::Maximum, QSizePolicy::Minimum ) );
170
171 QLabel *label = new QLabel( i18n("Highlight:"), vbox1 );
172 hlCombo = new QComboBox( false, vbox1 );
173 QHBox *modHl = new QHBox(vbox1);
174// connect(new QPushButton(i18n("New"),modHl),SIGNAL(clicked()),this,SLOT(hlNew())); 170// connect(new QPushButton(i18n("New"),modHl),SIGNAL(clicked()),this,SLOT(hlNew()));
175// connect(new QPushButton(i18n("Edit"),modHl),SIGNAL(clicked()),this,SLOT(hlEdit())); 171// connect(new QPushButton(i18n("Edit"),modHl),SIGNAL(clicked()),this,SLOT(hlEdit()));
176 connect( hlCombo, SIGNAL(activated(int)), 172 connect( hlCombo, SIGNAL(activated(int)),
177 this, SLOT(hlChanged(int)) ); 173 this, SLOT(hlChanged(int)) );
178 for( int i = 0; i < hlManager->highlights(); i++) { 174 for( int i = 0; i < hlManager->highlights(); i++) {
179 hlCombo->insertItem(hlManager->hlName(i)); 175 hlCombo->insertItem(hlManager->hlName(i));
180 } 176 }
181 hlCombo->setCurrentItem(hlNumber); 177 hlCombo->setCurrentItem(hlNumber);
182 178
179 label = new QLabel( i18n("File Extensions:"), gbox1 );
180 wildcards = new QLineEdit( gbox1 );
181 label = new QLabel( i18n("Mime Types:"), gbox1 );
182 mimetypes = new QLineEdit( gbox1 );
183 183
184 label = new QLabel( i18n("Item:"), vbox2 ); 184 label = new QLabel( i18n("Item:"), gbox2 );
185 itemCombo = new QComboBox( false, vbox2 ); 185 itemCombo = new QComboBox( false, gbox2 );
186 connect( itemCombo, SIGNAL(activated(int)), this, SLOT(itemChanged(int)) ); 186 connect( itemCombo, SIGNAL(activated(int)), this, SLOT(itemChanged(int)) );
187 187
188 label = new QLabel( i18n("File Extensions:"), vbox3 ); 188 styleDefault = new QCheckBox(i18n("Default"), gbox2 );
189 wildcards = new QLineEdit( vbox3 );
190 label = new QLabel( i18n("Mime Types:"), vbox3 );
191 mimetypes = new QLineEdit( vbox3 );
192
193
194 styleDefault = new QCheckBox(i18n("Default"), vbox2 );
195 connect(styleDefault,SIGNAL(clicked()),SLOT(changed())); 189 connect(styleDefault,SIGNAL(clicked()),SLOT(changed()));
196 styleChanger = new StyleChanger( vbox2 ); 190 gbox2->addSpace(1);
191 gbox2->addSpace(1);
192 styleChanger = new StyleChanger( gbox2 );
197 193
198 hlDataList = highlightDataList; 194 hlDataList = highlightDataList;
199 hlChanged(hlNumber); 195 hlChanged(hlNumber);
200} 196}
201 197
202 198
203void HighlightDialogPage::defaultChanged(int z) 199void HighlightDialogPage::defaultChanged(int z)
204{ 200{
205 defaultStyleChanger->setRef(defaultItemStyleList->at(z)); 201 defaultStyleChanger->setRef(defaultItemStyleList->at(z));
206} 202}
207 203
208 204
209void HighlightDialogPage::hlChanged(int z) 205void HighlightDialogPage::hlChanged(int z)
210{ 206{
211 writeback(); 207 writeback();
212 208
213 hlData = hlDataList->at(z); 209 hlData = hlDataList->at(z);
214 210
215 wildcards->setText(hlData->wildcards); 211 wildcards->setText(hlData->wildcards);
216 mimetypes->setText(hlData->mimetypes); 212 mimetypes->setText(hlData->mimetypes);
217 213
218 itemCombo->clear(); 214 itemCombo->clear();
219 for (ItemData *itemData = hlData->itemDataList.first(); itemData != 0L; 215 for (ItemData *itemData = hlData->itemDataList.first(); itemData != 0L;
220 itemData = hlData->itemDataList.next()) { 216 itemData = hlData->itemDataList.next()) {
221 kdDebug(13010) << itemData->name << endl; 217 kdDebug(13010) << itemData->name << endl;
222 itemCombo->insertItem(i18n(itemData->name.latin1())); 218 itemCombo->insertItem(i18n(itemData->name.latin1()));
223 } 219 }
224 220
225 itemChanged(0); 221 itemChanged(0);
226} 222}
227 223
228void HighlightDialogPage::itemChanged(int z) 224void HighlightDialogPage::itemChanged(int z)
229{ 225{
230 itemData = hlData->itemDataList.at(z); 226 itemData = hlData->itemDataList.at(z);
231 227
232 styleDefault->setChecked(itemData->defStyle); 228 styleDefault->setChecked(itemData->defStyle);
233 styleChanger->setRef(itemData); 229 styleChanger->setRef(itemData);
234} 230}
235 231
236void HighlightDialogPage::changed() 232void HighlightDialogPage::changed()
237{ 233{
238 itemData->defStyle = styleDefault->isChecked(); 234 itemData->defStyle = styleDefault->isChecked();
239} 235}
240 236
241void HighlightDialogPage::writeback() { 237void HighlightDialogPage::writeback() {
242 if (hlData) { 238 if (hlData) {
243 hlData->wildcards = wildcards->text(); 239 hlData->wildcards = wildcards->text();
244 hlData->mimetypes = mimetypes->text(); 240 hlData->mimetypes = mimetypes->text();