49 #include <QtGui/QPainter>
50 #include <QtGui/QCheckBox>
51 #include <QtGui/QGroupBox>
52 #include <QtGui/QPrintDialog>
53 #include <QtGui/QPrinter>
54 #include <QtGui/QApplication>
56 #include <QtGui/QLabel>
57 #include <QtGui/QLayout>
58 #include <QtCore/QStringList>
76 qreal left, right, top, bottom;
77 printer.getPageMargins(&left, &top, &right, &bottom, QPrinter::Millimeter);
81 right = margins.
readEntry(
"right", right);
82 bottom = margins.
readEntry(
"bottom", bottom);
84 printer.setPageMargins(left, top, right, bottom, QPrinter::Millimeter);
93 qreal left, right, top, bottom;
94 printer.getPageMargins(&left, &top, &right, &bottom, QPrinter::Millimeter);
122 parentWidget=QApplication::activeWindow();
127 printer.setPrintRange(QPrinter::Selection);
128 printDialog->setOption(QAbstractPrintDialog::PrintSelection,
true);
131 if ( printDialog->exec() )
138 renderer.setPrinterFriendly(
true);
140 QPainter paint( &printer );
147 uint pdmWidth = printer.width();
148 uint pdmHeight = printer.height();
152 uint maxWidth = pdmWidth;
153 int headerWidth = pdmWidth;
154 bool pageStarted =
true;
158 bool selectionOnly = (printDialog->printRange() == QAbstractPrintDialog::Selection);
159 bool useGuide = kpts->printGuide();
161 bool printLineNumbers = kpts->printLineNumbers();
162 uint lineNumberWidth( 0 );
165 QFont headerFont(kphf->font());
167 bool useHeader = kphf->useHeader();
168 QColor headerBgColor(kphf->headerBackground());
169 QColor headerFgColor(kphf->headerForeground());
170 uint headerHeight( 0 );
172 bool headerDrawBg =
false;
174 bool useFooter = kphf->useFooter();
175 QColor footerBgColor(kphf->footerBackground());
176 QColor footerFgColor(kphf->footerForeground());
177 uint footerHeight( 0 );
179 bool footerDrawBg =
false;
182 renderer.config()->setSchema( kpl->colorScheme() );
183 bool useBackground = kpl->useBackground();
184 bool useBox = kpl->useBox();
185 int boxWidth(kpl->boxWidth());
186 QColor boxColor(kpl->boxColor());
187 int innerMargin = useBox ? kpl->boxMargin() : 6;
190 int maxHeight = (useBox ? pdmHeight-innerMargin : pdmHeight);
191 uint currentPage( 1 );
194 const int fontHeight = renderer.fontHeight();
207 firstline = selectionRange.
start().
line();
208 lastline = selectionRange.
end().
line();
209 lineCount = firstline;
212 if ( printLineNumbers )
218 lineNumberWidth = renderer.currentFontMetrics().width( s );
220 int _adj = renderer.currentFontMetrics().width(
"5" );
222 maxWidth -= (lineNumberWidth + _adj);
223 xstart += lineNumberWidth + _adj;
226 if ( useHeader || useFooter )
232 QDateTime dt = QDateTime::currentDateTime();
248 tags[
"f"].prepend( s );
249 tags[
"U"].prepend( s );
252 QRegExp reTags(
"%([dDfUhuyY])" );
256 headerDrawBg = kphf->useHeaderBackground();
257 headerHeight = QFontMetrics( headerFont ).height();
258 if ( useBox || headerDrawBg )
259 headerHeight += innerMargin * 2;
261 headerHeight += 1 + QFontMetrics( headerFont ).leading();
263 headerTagList = kphf->headerFormat();
264 QMutableStringListIterator it(headerTagList);
265 while ( it.hasNext() ) {
267 int pos = reTags.indexIn( tag );
271 rep = tags[reTags.cap( 1 )];
272 tag.replace( (uint)pos, 2, rep );
274 pos = reTags.indexIn( tag, pos );
279 if (!headerBgColor.isValid())
280 headerBgColor = Qt::lightGray;
281 if (!headerFgColor.isValid())
282 headerFgColor = Qt::black;
287 footerDrawBg = kphf->useFooterBackground();
288 footerHeight = QFontMetrics( headerFont ).height();
289 if ( useBox || footerDrawBg )
290 footerHeight += 2*innerMargin;
294 footerTagList = kphf->footerFormat();
295 QMutableStringListIterator it(footerTagList);
296 while ( it.hasNext() ) {
298 int pos = reTags.indexIn( tag );
302 rep = tags[reTags.cap( 1 )];
303 tag.replace( (uint)pos, 2, rep );
305 pos = reTags.indexIn( tag, pos );
310 if (!footerBgColor.isValid())
311 footerBgColor = Qt::lightGray;
312 if (!footerFgColor.isValid())
313 footerFgColor = Qt::black;
315 maxHeight -= footerHeight;
323 xstart += innerMargin;
324 maxWidth -= innerMargin * 2;
330 if (!boxColor.isValid())
331 boxColor = Qt::black;
335 maxWidth -= ( ( boxWidth + innerMargin ) * 2 );
336 xstart += boxWidth + innerMargin;
338 maxHeight -= boxWidth;
346 if ( !headerTagList.filter(
"%P").isEmpty() || !footerTagList.filter(
"%P").isEmpty() )
348 kDebug(13020)<<
"'%P' found! calculating number of pages...";
349 int pageHeight = maxHeight;
351 pageHeight -= ( headerHeight + innerMargin );
353 pageHeight -= innerMargin;
354 const int linesPerPage = pageHeight / fontHeight;
360 for (
unsigned int i = firstline; i <= lastline; ++i) {
363 renderer.layoutLine(rangeptr, (
int)maxWidth,
false);
366 int totalPages = (totalLines / linesPerPage)
367 + ((totalLines % linesPerPage) > 0 ? 1 : 0);
377 QStringList::Iterator it;
378 for ( it=headerTagList.begin(); it!=headerTagList.end(); ++it )
379 (*it).replace( re,
QString(
"%1" ).arg( totalPages ) );
380 for ( it=footerTagList.begin(); it!=footerTagList.end(); ++it )
381 (*it).replace( re,
QString(
"%1" ).arg( totalPages ) );
388 while ( lineCount <= lastline )
390 if ( y + fontHeight > maxHeight )
392 kDebug(13020)<<
"Starting new page,"<<lineCount<<
"lines up to now.";
394 paint.resetTransform();
404 paint.setPen(headerFgColor);
405 paint.setFont(headerFont);
407 paint.fillRect(0, 0, headerWidth, headerHeight, headerBgColor);
408 if (headerTagList.count() == 3)
410 int valign = ( (useBox||headerDrawBg||useBackground) ?
411 Qt::AlignVCenter : Qt::AlignTop );
412 int align = valign|Qt::AlignLeft;
413 int marg = ( useBox || headerDrawBg ) ? innerMargin : 0;
414 if ( useBox ) marg += boxWidth;
416 for (
int i=0; i<3; i++)
418 s = headerTagList[i];
419 if (s.indexOf(
"%p") != -1) s.replace(
"%p", QString::number(currentPage));
420 paint.drawText(marg, 0, headerWidth-(marg*2), headerHeight, align, s);
421 align = valign|(i == 0 ? Qt::AlignHCenter : Qt::AlignRight);
424 if ( ! ( headerDrawBg || useBox || useBackground ) )
426 paint.drawLine( 0, headerHeight-1, headerWidth, headerHeight-1 );
429 y += headerHeight + innerMargin;
434 paint.setPen(footerFgColor);
435 if ( ! ( footerDrawBg || useBox || useBackground ) )
436 paint.drawLine( 0, maxHeight + innerMargin - 1, headerWidth, maxHeight + innerMargin - 1 );
438 paint.fillRect(0, maxHeight+innerMargin+boxWidth, headerWidth, footerHeight, footerBgColor);
439 if (footerTagList.count() == 3)
441 int align = Qt::AlignVCenter|Qt::AlignLeft;
442 int marg = ( useBox || footerDrawBg ) ? innerMargin : 0;
443 if ( useBox ) marg += boxWidth;
445 for (
int i=0; i<3; i++)
447 s = footerTagList[i];
448 if (s.indexOf(
"%p") != -1) s.replace(
"%p", QString::number(currentPage));
449 paint.drawText(marg, maxHeight+innerMargin, headerWidth-(marg*2), footerHeight, align, s);
450 align = Qt::AlignVCenter|(i == 0 ? Qt::AlignHCenter : Qt::AlignRight);
459 int _y = y, _h = maxHeight - y;
463 _h += 2 * innerMargin;
477 paint.fillRect( 0, _y, pdmWidth, _h, renderer.config()->backgroundColor());
482 paint.setPen(QPen(boxColor, boxWidth));
483 paint.drawRect(0, 0, pdmWidth, pdmHeight);
485 paint.drawLine(0, headerHeight, headerWidth, headerHeight);
490 paint.fillRect( 0, maxHeight+innerMargin, headerWidth, boxWidth, boxColor );
493 if ( useGuide && currentPage == 1 )
505 QColor _defaultPen = _defaultAttributes.at(0)->foreground().color();
506 paint.setPen(_defaultPen);
510 _marg += (2*boxWidth) + (2*innerMargin);
514 _marg += 2*innerMargin;
516 y += 1 + innerMargin;
520 QFont _titleFont = renderer.config()->font();
521 _titleFont.setBold(
true);
522 paint.setFont( _titleFont );
524 paint.drawText(
QRect(_marg, y, pdmWidth-(2*_marg), maxHeight - y),
525 Qt::AlignTop|Qt::AlignHCenter,
526 i18n(
"Typographical Conventions for %1", _hlName ), &_r );
527 int _w = pdmWidth - (_marg*2) - (innerMargin*2);
528 int _x = _marg + innerMargin;
529 y += _r.height() + innerMargin;
530 paint.drawLine( _x, y, _x + _w, y );
531 y += 1 + innerMargin;
535 _widest = qMax(QFontMetrics(attribute->font()).width(attribute->
name().section(
':',1,1)), _widest);
537 int _guideCols = _w/( _widest + innerMargin );
540 int _cw = _w/_guideCols;
543 _titleFont.setUnderline(
true);
548 QString _name = attribute->
name().section(
':',1,1);
549 if ( _hl != _hlName && _hl != _currentHlName ) {
550 _currentHlName = _hl;
554 paint.setFont(_titleFont);
555 paint.setPen(_defaultPen);
556 paint.drawText( _x, y, _w, fontHeight, Qt::AlignTop, _hl +
' ' +
i18n(
"text") );
563 paint.setPen( _attr.foreground().color() );
564 paint.setFont( _attr.font() );
566 if (_attr.hasProperty(QTextFormat::BackgroundBrush) ) {
567 QRect _rect = QFontMetrics(_attr.font()).boundingRect(_name);
568 _rect.moveTo(_x + ((_i%_guideCols)*_cw), y);
569 paint.fillRect(_rect, _attr.background() );
572 paint.drawText(( _x + ((_i%_guideCols)*_cw)), y, _cw, fontHeight, Qt::AlignTop, _name );
575 if ( _i && ! ( _i%_guideCols ) )
583 paint.setPen ( _defaultPen );
585 paint.fillRect( 0, y+innerMargin, headerWidth, boxWidth, boxColor );
589 paint.drawRect( _marg, _ystart, pdmWidth-(2*_marg), y-_ystart+innerMargin );
592 y += ( useBox ? boxWidth : 1 ) + (innerMargin*2);
595 paint.translate(xstart,y);
599 if ( printLineNumbers )
601 paint.setFont( renderer.config()->font() );
602 paint.setPen( renderer.config()->lineNumberColor() );
603 paint.drawText( (( useBox || useBackground ) ? innerMargin : 0)-xstart, 0,
604 lineNumberWidth, fontHeight,
605 Qt::AlignRight,
QString(
"%1").arg( lineCount + 1 ) );
612 renderer.layoutLine(rangeptr, (
int)maxWidth,
false);
618 int _x = renderer.cursorToX(rangeptr->
viewLine(0), selectionRange.
start());
621 paint.translate(-_xadjust, 0);
622 paint.setClipRegion(QRegion( _x, 0, _x1 - _x, rangeptr->
viewLineCount()*fontHeight));
625 else if (lineCount == firstline || lineCount == lastline) {
626 QRegion region(0, 0, maxWidth, rangeptr->
viewLineCount()*fontHeight);
628 if ( lineCount == firstline) {
629 region = region.subtracted(QRegion(0, 0, renderer.cursorToX(rangeptr->
viewLine(0), selectionRange.
start()), fontHeight));
632 if (lineCount == lastline) {
634 region = region.subtracted(QRegion(_x, 0, maxWidth-_x, fontHeight));
637 paint.setClipRegion(region);
645 int proceedLines = _lines;
647 proceedLines = qMin((maxHeight - y) / fontHeight, remainder);
649 paint.translate(0, -(_lines-remainder)*fontHeight+1);
650 paint.setClipRect(0, (_lines-remainder)*fontHeight+1, maxWidth, proceedLines*fontHeight);
651 remainder -= proceedLines;
653 else if (y + fontHeight * _lines > maxHeight) {
654 remainder = _lines - ((maxHeight-y)/fontHeight);
655 paint.setClipRect(0, 0, maxWidth, (_lines-remainder)*fontHeight+1);
658 renderer.paintTextLine(paint, rangeptr, 0, (
int)maxWidth);
660 paint.setClipping(
false);
661 paint.translate(_xadjust, (fontHeight * (_lines-remainder)));
663 y += fontHeight * proceedLines;
680 setWindowTitle(
i18n(
"Te&xt Settings") );
682 QVBoxLayout *lo =
new QVBoxLayout (
this );
684 cbLineNumbers =
new QCheckBox(
i18n(
"Print line &numbers"),
this );
685 lo->addWidget( cbLineNumbers );
687 cbGuide =
new QCheckBox(
i18n(
"Print &legend"),
this );
688 lo->addWidget( cbGuide );
695 cbLineNumbers->setWhatsThis(
i18n(
696 "<p>If enabled, line numbers will be printed on the left side of the page(s).</p>") );
697 cbGuide->setWhatsThis(
i18n(
698 "<p>Print a box displaying typographical conventions for the document type, as "
699 "defined by the syntax highlighting being used.</p>") );
711 return cbLineNumbers->isChecked();
716 return cbGuide->isChecked();
719 void KatePrintTextSettings::readSettings()
722 KConfigGroup printGroup( config,
"Kate Print Settings" );
725 bool isLineNumbersChecked = textGroup.readEntry(
"LineNumbers",
false );
726 cbLineNumbers->setChecked( isLineNumbersChecked );
728 bool isLegendChecked = textGroup.readEntry(
"Legend",
false );
729 cbGuide->setChecked( isLegendChecked );
732 void KatePrintTextSettings::writeSettings()
735 KConfigGroup printGroup( config,
"Kate Print Settings" );
739 textGroup.writeEntry(
"Legend",
printGuide() );
750 setWindowTitle(
i18n(
"Hea&der && Footer") );
752 QVBoxLayout *lo =
new QVBoxLayout (
this );
755 QHBoxLayout *lo1 =
new QHBoxLayout ();
756 lo->addLayout( lo1 );
757 cbEnableHeader =
new QCheckBox(
i18n(
"Pr&int header"),
this );
758 lo1->addWidget( cbEnableHeader );
759 cbEnableFooter =
new QCheckBox(
i18n(
"Pri&nt footer"),
this );
760 lo1->addWidget( cbEnableFooter );
763 QHBoxLayout *lo2 =
new QHBoxLayout();
764 lo->addLayout( lo2 );
765 lo2->addWidget(
new QLabel(
i18n(
"Header/footer font:"),
this ) );
766 lFontPreview =
new QLabel(
this );
767 lFontPreview->setFrameStyle( QFrame::Panel|QFrame::Sunken );
768 lo2->addWidget( lFontPreview );
769 lo2->setStretchFactor( lFontPreview, 1 );
771 lo2->addWidget( btnChooseFont );
772 connect( btnChooseFont, SIGNAL(clicked()),
this, SLOT(
setHFFont()) );
776 gbHeader->setTitle(
i18n(
"Header Properties"));
777 QGridLayout* grid =
new QGridLayout(gbHeader);
778 lo->addWidget( gbHeader );
781 grid->addWidget(lHeaderFormat, 0, 0);
783 KHBox *hbHeaderFormat =
new KHBox( gbHeader );
784 grid->addWidget(hbHeaderFormat, 0, 1);
786 leHeaderLeft =
new KLineEdit( hbHeaderFormat );
787 leHeaderCenter =
new KLineEdit( hbHeaderFormat );
788 leHeaderRight =
new KLineEdit( hbHeaderFormat );
789 lHeaderFormat->setBuddy( leHeaderLeft );
791 leHeaderLeft->setContextMenuPolicy(Qt::CustomContextMenu);
792 leHeaderCenter->setContextMenuPolicy(Qt::CustomContextMenu);
793 leHeaderRight->setContextMenuPolicy(Qt::CustomContextMenu);
798 grid->addWidget(
new QLabel(
i18n(
"Colors:"), gbHeader ), 1, 0);
800 KHBox *hbHeaderColors =
new KHBox( gbHeader );
801 grid->addWidget(hbHeaderColors, 1, 1);
806 lHeaderFgCol->setBuddy( kcbtnHeaderFg );
807 cbHeaderEnableBgColor =
new QCheckBox(
i18n(
"Bac&kground"), hbHeaderColors );
811 gbFooter->setTitle(
i18n(
"Footer Properties"));
812 grid =
new QGridLayout(gbFooter);
813 lo->addWidget( gbFooter );
817 grid->addWidget(lFooterFormat, 0, 0);
819 KHBox *hbFooterFormat =
new KHBox( gbFooter );
820 grid->addWidget(hbFooterFormat, 0, 1);
823 leFooterLeft =
new KLineEdit( hbFooterFormat );
824 leFooterCenter =
new KLineEdit( hbFooterFormat );
825 leFooterRight =
new KLineEdit( hbFooterFormat );
826 lFooterFormat->setBuddy( leFooterLeft );
828 leFooterLeft->setContextMenuPolicy(Qt::CustomContextMenu);
829 leFooterCenter->setContextMenuPolicy(Qt::CustomContextMenu);
830 leFooterRight->setContextMenuPolicy(Qt::CustomContextMenu);
835 grid->addWidget(
new QLabel(
i18n(
"Colors:"), gbFooter ), 1, 0);
837 KHBox *hbFooterColors =
new KHBox( gbFooter );
838 grid->addWidget(hbFooterColors, 1, 1);
843 lFooterBgCol->setBuddy( kcbtnFooterFg );
844 cbFooterEnableBgColor =
new QCheckBox(
i18n(
"&Background"), hbFooterColors );
850 connect( cbEnableHeader, SIGNAL(toggled(
bool)), gbHeader, SLOT(setEnabled(
bool)) );
851 connect( cbEnableFooter, SIGNAL(toggled(
bool)), gbFooter, SLOT(setEnabled(
bool)) );
852 connect( cbHeaderEnableBgColor, SIGNAL(toggled(
bool)), kcbtnHeaderBg, SLOT(setEnabled(
bool)) );
853 connect( cbFooterEnableBgColor, SIGNAL(toggled(
bool)), kcbtnFooterBg, SLOT(setEnabled(
bool)) );
856 cbEnableHeader->setChecked(
true );
858 leHeaderCenter->
setText(
"%f" );
859 leHeaderRight->
setText(
"%p" );
861 cbHeaderEnableBgColor->setChecked(
false );
864 cbEnableFooter->setChecked(
true );
865 leFooterRight->
setText(
"%U" );
867 cbFooterEnableBgColor->setChecked(
false );
871 QString s =
i18n(
"<p>Format of the page header. The following tags are supported:</p>");
873 "<ul><li><tt>%u</tt>: current user name</li>"
874 "<li><tt>%d</tt>: complete date/time in short format</li>"
875 "<li><tt>%D</tt>: complete date/time in long format</li>"
876 "<li><tt>%h</tt>: current time</li>"
877 "<li><tt>%y</tt>: current date in short format</li>"
878 "<li><tt>%Y</tt>: current date in long format</li>"
879 "<li><tt>%f</tt>: file name</li>"
880 "<li><tt>%U</tt>: full URL of the document</li>"
881 "<li><tt>%p</tt>: page number</li>"
882 "<li><tt>%P</tt>: total amount of pages</li>"
884 leHeaderRight->setWhatsThis(s + s1 );
885 leHeaderCenter->setWhatsThis(s + s1 );
886 leHeaderLeft->setWhatsThis(s + s1 );
887 s =
i18n(
"<p>Format of the page footer. The following tags are supported:</p>");
888 leFooterRight->setWhatsThis(s + s1 );
889 leFooterCenter->setWhatsThis(s + s1 );
890 leFooterLeft->setWhatsThis(s + s1 );
902 return lFontPreview->font();
907 return cbEnableHeader->isChecked();
913 l << leHeaderLeft->text() << leHeaderCenter->text() << leHeaderRight->text();
919 return kcbtnHeaderFg->
color();
924 return kcbtnHeaderBg->
color();
929 return cbHeaderEnableBgColor->isChecked();
934 return cbEnableFooter->isChecked();
940 l<< leFooterLeft->text() << leFooterCenter->text() << leFooterRight->text();
946 return kcbtnFooterFg->
color();
951 return kcbtnFooterBg->
color();
956 return cbFooterEnableBgColor->isChecked();
961 QFont fnt( lFontPreview->font() );
966 lFontPreview->setFont( fnt );
967 lFontPreview->setText(
QString(fnt.family() +
", %1pt").arg( fnt.pointSize() ) );
978 QMenu*
const contextMenu = lineEdit->createStandardContextMenu();
979 if (contextMenu == NULL) {
982 contextMenu->addSeparator();
985 QMenu* menu = contextMenu->addMenu(
i18n(
"Add Placeholder..."));
986 menu->setIcon(
KIcon(
"list-add"));
987 QAction* a = menu->addAction(
i18n(
"Current User Name") +
"\t%u");
989 a = menu->addAction(
i18n(
"Complete Date/Time (short format)") +
"\t%d");
991 a = menu->addAction(
i18n(
"Complete Date/Time (long format)") +
"\t%D");
993 a = menu->addAction(
i18n(
"Current Time") +
"\t%h");
995 a = menu->addAction(
i18n(
"Current Date (short format)") +
"\t%y");
997 a = menu->addAction(
i18n(
"Current Date (long format)") +
"\t%Y");
999 a = menu->addAction(
i18n(
"File Name") +
"\t%f");
1001 a = menu->addAction(
i18n(
"Full document URL") +
"\t%U");
1003 a = menu->addAction(
i18n(
"Page Number") +
"\t%p");
1005 a = menu->addAction(
i18n(
"Total Amount of Pages") +
"\t%P");
1008 QAction*
const result = contextMenu->exec(lineEdit->mapToGlobal(pos));
1010 QString placeHolder = result->data().toString();
1011 if (!placeHolder.isEmpty()) {
1012 lineEdit->insert(placeHolder);
1017 void KatePrintHeaderFooter::readSettings()
1020 KConfigGroup printGroup( config,
"Kate Print Settings" );
1023 KConfigGroup headerFooterGroup( &printGroup,
"HeaderFooter" );
1024 bool isHeaderEnabledChecked = headerFooterGroup.readEntry(
"HeaderEnabled",
true );
1025 cbEnableHeader->setChecked( isHeaderEnabledChecked );
1027 QString headerFormatLeft = headerFooterGroup.readEntry(
"HeaderFormatLeft",
"%y" );
1028 leHeaderLeft->
setText( headerFormatLeft );
1030 QString headerFormatCenter = headerFooterGroup.readEntry(
"HeaderFormatCenter",
"%f" );
1031 leHeaderCenter->
setText( headerFormatCenter );
1033 QString headerFormatRight = headerFooterGroup.readEntry(
"HeaderFormatRight",
"%p" );
1034 leHeaderRight->
setText( headerFormatRight );
1037 kcbtnHeaderFg->
setColor( headerForeground );
1039 bool isHeaderBackgroundChecked = headerFooterGroup.readEntry(
"HeaderBackgroundEnabled",
false );
1040 cbHeaderEnableBgColor->setChecked( isHeaderBackgroundChecked );
1043 kcbtnHeaderBg->
setColor( headerBackground );
1046 bool isFooterEnabledChecked = headerFooterGroup.readEntry(
"FooterEnabled",
true );
1047 cbEnableFooter->setChecked( isFooterEnabledChecked );
1049 QString footerFormatLeft = headerFooterGroup.readEntry(
"FooterFormatLeft",
QString() );
1050 leFooterLeft->
setText( footerFormatLeft );
1052 QString footerFormatCenter = headerFooterGroup.readEntry(
"FooterFormatCenter",
QString() );
1053 leFooterCenter->
setText( footerFormatCenter );
1055 QString footerFormatRight = headerFooterGroup.readEntry(
"FooterFormatRight",
"%U" );
1056 leFooterRight->
setText( footerFormatRight );
1059 kcbtnFooterFg->
setColor( footerForeground );
1061 bool isFooterBackgroundChecked = headerFooterGroup.readEntry(
"FooterBackgroundEnabled",
false );
1062 cbFooterEnableBgColor->setChecked( isFooterBackgroundChecked );
1065 kcbtnFooterBg->
setColor( footerBackground );
1068 QFont headerFooterFont = headerFooterGroup.readEntry(
"HeaderFooterFont",
QFont() );
1069 lFontPreview->setFont( headerFooterFont );
1070 lFontPreview->setText(
QString(headerFooterFont.family() +
", %1pt").arg( headerFooterFont.pointSize() ) );
1073 void KatePrintHeaderFooter::writeSettings()
1076 KConfigGroup printGroup( config,
"Kate Print Settings" );
1079 KConfigGroup headerFooterGroup( &printGroup,
"HeaderFooter" );
1080 headerFooterGroup.writeEntry(
"HeaderEnabled",
useHeader() );
1083 headerFooterGroup.writeEntry(
"HeaderFormatLeft", format[0] );
1084 headerFooterGroup.writeEntry(
"HeaderFormatCenter", format[1] );
1085 headerFooterGroup.writeEntry(
"HeaderFormatRight", format[2] );
1091 headerFooterGroup.writeEntry(
"FooterEnabled",
useFooter() );
1094 headerFooterGroup.writeEntry(
"FooterFormatLeft", format[0] );
1095 headerFooterGroup.writeEntry(
"FooterFormatCenter", format[1] );
1096 headerFooterGroup.writeEntry(
"FooterFormatRight", format[2] );
1102 headerFooterGroup.writeEntry(
"HeaderFooterFont",
font() );
1114 setWindowTitle(
i18n(
"L&ayout") );
1116 QVBoxLayout *lo =
new QVBoxLayout (
this );
1119 lo->addWidget( hb );
1123 lSchema->setBuddy( cmbSchema );
1125 cbDrawBackground =
new QCheckBox(
i18n(
"Draw bac&kground color"),
this );
1126 lo->addWidget( cbDrawBackground );
1128 cbEnableBox =
new QCheckBox(
i18n(
"Draw &boxes"),
this );
1129 lo->addWidget( cbEnableBox );
1132 gbBoxProps->setTitle(
i18n(
"Box Properties"));
1133 QGridLayout* grid =
new QGridLayout(gbBoxProps);
1134 lo->addWidget( gbBoxProps );
1137 grid->addWidget(lBoxWidth, 0, 0);
1139 sbBoxWidth->setRange( 1, 100 );
1140 sbBoxWidth->setSingleStep( 1 );
1141 grid->addWidget(sbBoxWidth, 0, 1);
1142 lBoxWidth->setBuddy( sbBoxWidth );
1145 grid->addWidget(lBoxMargin, 1, 0);
1147 sbBoxMargin->setRange( 0, 100 );
1148 sbBoxMargin->setSingleStep( 1 );
1149 grid->addWidget(sbBoxMargin, 1, 1);
1150 lBoxMargin->setBuddy( sbBoxMargin );
1153 grid->addWidget(lBoxColor, 2, 0);
1155 grid->addWidget(kcbtnBoxColor, 2, 1);
1156 lBoxColor->setBuddy( kcbtnBoxColor );
1158 connect( cbEnableBox, SIGNAL(toggled(
bool)), gbBoxProps, SLOT(setEnabled(
bool)) );
1160 lo->addStretch( 1 );
1162 sbBoxMargin->setValue( 6 );
1163 gbBoxProps->setEnabled(
false );
1169 cmbSchema->setCurrentIndex (cmbSchema->findData (
QVariant(
"Printing")));
1172 cmbSchema->setWhatsThis(
i18n(
1173 "Select the color scheme to use for the print." ) );
1174 cbDrawBackground->setWhatsThis(
i18n(
1175 "<p>If enabled, the background color of the editor will be used.</p>"
1176 "<p>This may be useful if your color scheme is designed for a dark background.</p>") );
1177 cbEnableBox->setWhatsThis(
i18n(
1178 "<p>If enabled, a box as defined in the properties below will be drawn "
1179 "around the contents of each page. The Header and Footer will be separated "
1180 "from the contents with a line as well.</p>") );
1181 sbBoxWidth->setWhatsThis(
i18n(
1182 "The width of the box outline" ) );
1183 sbBoxMargin->setWhatsThis(
i18n(
1184 "The margin inside boxes, in pixels") );
1185 kcbtnBoxColor->setWhatsThis(
i18n(
1186 "The line color to use for boxes") );
1198 return cmbSchema->itemData(cmbSchema->currentIndex()).toString();
1203 return cbDrawBackground->isChecked();
1208 return cbEnableBox->isChecked();
1213 return sbBoxWidth->value();
1218 return sbBoxMargin->value();
1223 return kcbtnBoxColor->
color();
1226 void KatePrintLayout::readSettings()
1229 KConfigGroup printGroup(config,
"Kate Print Settings");
1235 int index = cmbSchema->findData (
QVariant (colorScheme));
1237 cmbSchema->setCurrentIndex ( index );
1239 bool isBackgroundChecked = layoutGroup.readEntry(
"BackgroundColorEnabled",
false );
1240 cbDrawBackground->setChecked( isBackgroundChecked );
1242 bool isBoxChecked = layoutGroup.readEntry(
"BoxEnabled",
false );
1243 cbEnableBox->setChecked( isBoxChecked );
1245 int boxWidth = layoutGroup.readEntry(
"BoxWidth", 1 );
1246 sbBoxWidth->setValue( boxWidth );
1248 int boxMargin = layoutGroup.readEntry(
"BoxMargin", 6 );
1249 sbBoxMargin->setValue( boxMargin );
1252 kcbtnBoxColor->
setColor( boxColor );
1255 void KatePrintLayout::writeSettings()
1258 KConfigGroup printGroup(config,
"Kate Print Settings");
1261 layoutGroup.writeEntry(
"ColorScheme",
colorScheme() );
1262 layoutGroup.writeEntry(
"BackgroundColorEnabled",
useBackground() );
1263 layoutGroup.writeEntry(
"BoxEnabled",
useBox() );
1264 layoutGroup.writeEntry(
"BoxWidth",
boxWidth() );
1265 layoutGroup.writeEntry(
"BoxMargin",
boxMargin() );
1266 layoutGroup.writeEntry(
"BoxColor",
boxColor() );
1273 #include "kateprinter.moc"
virtual const QString & documentName() const
KateBuffer & buffer()
Get access to buffer of this document.
void setSchema(const QString &schema)
QScriptValue i18n(QScriptContext *context, QScriptEngine *engine)
i18n("text", arguments [optional])
KateTextLayout viewLine(int viewLine) const
void setEditable(bool editable)
static int getFont(QFont &theFont, const KFontChooser::DisplayFlags &flags=KFontChooser::NoDisplayFlags, QWidget *parent=0L, Qt::CheckState *sizeIsRelativeState=0L)
KateHighlighting * highlight() const
virtual KTextEditor::View * activeView() const
int defaultStyleIndex() const
virtual bool blockSelection() const =0
virtual bool selection() const =0
void writeEntry(const QString &key, const QVariant &value, WriteConfigFlags pFlags=Normal)
void setLine(int line, int virtualLine=-1)
Only pass virtualLine if you know it (and thus we shouldn't try to look it up)
static KateGlobal * self()
Kate Part Internal stuff ;)
QString formatTime(const QTime &pTime, bool includeSecs=false, bool isDuration=false) const
QPrintDialog * createPrintDialog(QPrinter *printer, PageSelectPolicy pageSelectPolicy, const QList< QWidget * > &customTabs, QWidget *parent=0)
static QDebug kDebug(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
QString translatedName() const
construct translated name for shipped schemas
KSharedConfigPtr config()
virtual QWidget * widget()
int lastLine() const
gets the last line number (lines() - 1)
Handles all of the work of rendering the text (used for the views and printing)
KatePrintLayout(QWidget *parent=0)
KateRendererConfig * config() const
Configuration.
QString loginName() const
QString pathOrUrl() const
virtual int lines() const
Class representing the folding information for a TextBuffer.
int viewLineCount() const
void getKateExtendedAttributeList(const QString &schema, QList< KateExtendedAttribute::Ptr > &, KConfig *cfg=0)
QString formatDateTime(const QDateTime &dateTime, DateFormat format=ShortDate, bool includeSecs=false) const
static void writeSettings(QPrinter &printer)
QString fileName(const DirectoryOptions &options=IgnoreTrailingSlash) const
KatePrintTextSettings(QWidget *parent=0)
void setSpacing(int space)
virtual const Range & selectionRange() const =0
void getDefaults(const QString &schema, KateAttributeList &, KConfig *cfg=0)
QString formatDate(const QDate &date, DateFormat format=LongDate) const
static bool print(KateDocument *doc)
static void readSettings(QPrinter &printer)
const QString & name() const
virtual void setText(const QString &)
KateView * activeKateView() const
T readEntry(const QString &key, const T &aDefault) const
static KateHlManager * self()
QStringList list(const QString &fileClass)