TDE graphics utilities
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

135 lines
4.5KB

  1. // infodialog.cpp
  2. //
  3. // (C) 2001-2003 Stefan Kebekus
  4. // Distributed under the GPL
  5. #include <config.h>
  6. #include <kdebug.h>
  7. #include <tdeio/global.h>
  8. #include <klocale.h>
  9. #include <tqfile.h>
  10. #include <tqlabel.h>
  11. #include <tqlayout.h>
  12. #include <tqregexp.h>
  13. #include <tqtextview.h>
  14. #include <tqtooltip.h>
  15. #include <tqvariant.h>
  16. #include <tqwhatsthis.h>
  17. #include "dviFile.h"
  18. #include "fontpool.h"
  19. #include "infodialog.h"
  20. infoDialog::infoDialog( TQWidget* parent )
  21. : KDialogBase( Tabbed, i18n("Document Info"), Ok, Ok, parent, "Document Info", false, false)
  22. {
  23. TQFrame *page1 = addPage( i18n("DVI File") );
  24. TQVBoxLayout *topLayout1 = new TQVBoxLayout( page1, 0, 6 );
  25. TextLabel1 = new TQTextView( page1, "TextLabel1" );
  26. TQToolTip::add( TextLabel1, i18n("Information on the currently loaded DVI-file.") );
  27. topLayout1->addWidget( TextLabel1 );
  28. TQFrame *page2 = addPage( i18n("Fonts") );
  29. TQVBoxLayout *topLayout2 = new TQVBoxLayout( page2, 0, 6 );
  30. TextLabel2 = new TQTextView( page2, "TextLabel1" );
  31. TextLabel2->setMinimumWidth(fontMetrics().maxWidth()*40);
  32. TextLabel2->setMinimumHeight(fontMetrics().height()*10);
  33. TQToolTip::add( TextLabel2, i18n("Information on currently loaded fonts.") );
  34. TQWhatsThis::add( TextLabel2, i18n("This text field shows detailed information about the currently loaded fonts. "
  35. "This is useful for experts who want to locate problems in the setup of TeX or KDVI.") );
  36. topLayout2->addWidget( TextLabel2 );
  37. TQFrame *page3 = addPage( i18n("External Programs") );
  38. TQVBoxLayout *topLayout3 = new TQVBoxLayout( page3, 0, 6 );
  39. TextLabel3 = new TQTextView( page3, "TextLabel1" );
  40. TextLabel3->setText( i18n("No output from any external program received.") );
  41. TQToolTip::add( TextLabel3, i18n("Output of external programs.") );
  42. TQWhatsThis::add( TextLabel3, i18n("KDVI uses external programs, such as MetaFont, dvipdfm or dvips. "
  43. "This text field shows the output of these programs. "
  44. "That is useful for experts who want to find problems in the setup of TeX or KDVI.") );
  45. topLayout3->addWidget( TextLabel3 );
  46. MFOutputReceived = false;
  47. headline = TQString();
  48. pool = TQString();
  49. }
  50. void infoDialog::setDVIData(dvifile *dviFile)
  51. {
  52. TQString text = "";
  53. if (dviFile == NULL)
  54. text = i18n("There is no DVI file loaded at the moment.");
  55. else {
  56. text.append("<table WIDTH=\"100%\" NOSAVE >");
  57. text.append(TQString("<tr><td><b>%1</b></td> <td>%2</td></tr>").arg(i18n("Filename")).arg(dviFile->filename));
  58. TQFile file(dviFile->filename);
  59. if (file.exists())
  60. text.append(TQString("<tr><td><b>%1</b></td> <td>%2</td></tr>").arg(i18n("File Size")).arg(TDEIO::convertSize(file.size())));
  61. else
  62. text.append(TQString("<tr><td><b> </b></td> <td>%1</td></tr>").arg(i18n("The file does no longer exist.")));
  63. text.append(TQString("<tr><td><b> </b></td> <td> </td></tr>"));
  64. text.append(TQString("<tr><td><b>%1</b></td> <td>%2</td></tr>").arg(i18n("#Pages")).arg(dviFile->total_pages));
  65. text.append(TQString("<tr><td><b>%1</b></td> <td>%2</td></tr>").arg(i18n("Generator/Date")).arg(dviFile->generatorString));
  66. } // else (dviFile == NULL)
  67. TextLabel1->setText( text );
  68. }
  69. void infoDialog::setFontInfo(fontPool *fp)
  70. {
  71. TextLabel2->setText(fp->status());
  72. }
  73. void infoDialog::outputReceiver(const TQString& _op)
  74. {
  75. TQString op = _op;
  76. op = op.replace( TQRegExp("<"), "&lt;" );
  77. if (MFOutputReceived == false) {
  78. TextLabel3->setText("<b>"+headline+"</b><br>");
  79. headline = TQString();
  80. }
  81. // It seems that the TQTextView wants that we append only full lines.
  82. // We see to that.
  83. pool = pool+op;
  84. int idx = pool.findRev("\n");
  85. while(idx != -1) {
  86. TQString line = pool.left(idx);
  87. pool = pool.mid(idx+1);
  88. // If the Output of the kpsewhich program contains a line starting
  89. // with "kpathsea:", this means that a new MetaFont-run has been
  90. // started. We filter these lines out and print them in boldface.
  91. int startlineindex = line.find("kpathsea:");
  92. if (startlineindex != -1) {
  93. int endstartline = line.find("\n",startlineindex);
  94. TQString startLine = line.mid(startlineindex,endstartline-startlineindex);
  95. if (MFOutputReceived)
  96. TextLabel3->append("<hr>\n<b>"+startLine+"</b>");
  97. else
  98. TextLabel3->append("<b>"+startLine+"</b>");
  99. TextLabel3->append(line.mid(endstartline));
  100. } else
  101. TextLabel3->append(line);
  102. idx = pool.findRev("\n");
  103. }
  104. MFOutputReceived = true;
  105. }
  106. void infoDialog::clear(const TQString& op)
  107. {
  108. headline = op;
  109. pool = TQString();
  110. MFOutputReceived = false;
  111. }
  112. #include "infodialog.moc"