fb2main.cpp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  1. #include <QtGui>
  2. #include <QtDebug>
  3. #include <QTreeView>
  4. #include <QWebFrame>
  5. #include "fb2app.hpp"
  6. #include "fb2main.hpp"
  7. #include "fb2code.hpp"
  8. #include "fb2dlgs.hpp"
  9. #include "fb2dock.hpp"
  10. #include "fb2save.hpp"
  11. #include "fb2text.hpp"
  12. #include "fb2utils.h"
  13. //---------------------------------------------------------------------------
  14. // FbMainWindow
  15. //---------------------------------------------------------------------------
  16. FbMainWindow::FbMainWindow(const QString &filename, ViewMode mode)
  17. : QMainWindow()
  18. , noteEdit(0)
  19. , toolEdit(0)
  20. , inspector(0)
  21. , messageEdit(0)
  22. , isSwitched(false)
  23. , isUntitled(true)
  24. {
  25. connect(qApp, SIGNAL(logMessage(QString)), SLOT(logMessage(QString)));
  26. setUnifiedTitleAndToolBarOnMac(true);
  27. setAttribute(Qt::WA_DeleteOnClose);
  28. setWindowIcon(QIcon(":icon.ico"));
  29. mainDock = new FbMainDock(this);
  30. setCentralWidget(mainDock);
  31. createActions();
  32. createStatusBar();
  33. readSettings();
  34. QString filepath = filename.isEmpty() ? QString(":blank.fb2") : filename;
  35. mainDock->setMode(Fb::Text);
  36. setCurrentFile(filename);
  37. mainDock->load(filepath);
  38. }
  39. void FbMainWindow::logMessage(const QString &message)
  40. {
  41. if (!messageEdit) {
  42. messageEdit = new QTextEdit(this);
  43. connect(messageEdit, SIGNAL(destroyed()), SLOT(logDestroyed()));
  44. QDockWidget * dock = new FbLogDock(tr("Message log"), this);
  45. dock->setAttribute(Qt::WA_DeleteOnClose);
  46. dock->setFeatures(QDockWidget::AllDockWidgetFeatures);
  47. dock->setWidget(messageEdit);
  48. addDockWidget(Qt::BottomDockWidgetArea, dock);
  49. messageEdit->setMaximumHeight(80);
  50. }
  51. messageEdit->append(message);
  52. }
  53. void FbMainWindow::logShowed()
  54. {
  55. messageEdit->setMaximumHeight(QWIDGETSIZE_MAX);
  56. }
  57. void FbMainWindow::logDestroyed()
  58. {
  59. messageEdit = NULL;
  60. }
  61. void FbMainWindow::closeEvent(QCloseEvent *event)
  62. {
  63. if (maybeSave()) {
  64. writeSettings();
  65. event->accept();
  66. } else {
  67. event->ignore();
  68. }
  69. }
  70. void FbMainWindow::fileNew()
  71. {
  72. FbMainWindow *other = new FbMainWindow;
  73. other->move(x() + 40, y() + 40);
  74. other->show();
  75. }
  76. void FbMainWindow::fileOpen()
  77. {
  78. QString filename = QFileDialog::getOpenFileName(this, tr("Open file"), QString(), "Fiction book files (*.fb2)");
  79. if (filename.isEmpty()) return;
  80. FbMainWindow * existing = findFbMainWindow(filename);
  81. if (existing) {
  82. existing->show();
  83. existing->raise();
  84. existing->activateWindow();
  85. return;
  86. }
  87. if (isUntitled && !isWindowModified()) {
  88. mainDock->load(filename);
  89. } else {
  90. FbMainWindow * other = new FbMainWindow(filename, FB2);
  91. other->mainDock->load(filename);
  92. other->move(x() + 40, y() + 40);
  93. other->show();
  94. }
  95. }
  96. bool FbMainWindow::fileSave()
  97. {
  98. if (isUntitled) {
  99. return fileSaveAs();
  100. } else {
  101. return saveFile(curFile);
  102. }
  103. }
  104. bool FbMainWindow::fileSaveAs()
  105. {
  106. FbSaveDialog dlg(this, tr("Save As..."));
  107. dlg.selectFile(curFile);
  108. if (!dlg.exec()) return false;
  109. QString fileName = dlg.fileName();
  110. if (fileName.isEmpty()) return false;
  111. return saveFile(fileName, dlg.codec());
  112. }
  113. void FbMainWindow::about()
  114. {
  115. QString text = tr("<b>fb2edit</b> is an application for creating and editing FB2-files.");
  116. text += QString("<br>") += QString("<br>") += FbApplication::lastCommit();
  117. QMessageBox::about(this, tr("About fb2edit"), text);
  118. }
  119. void FbMainWindow::documentWasModified()
  120. {
  121. // setModified(isSwitched || codeEdit->isModified());
  122. }
  123. void FbMainWindow::setModified(bool modified)
  124. {
  125. QFileInfo info = windowFilePath();
  126. QString title = info.fileName();
  127. if (modified) title += QString("[*]");
  128. title += appTitle();
  129. setWindowTitle(title);
  130. setWindowModified(modified);
  131. }
  132. void FbMainWindow::createActions()
  133. {
  134. QAction * act;
  135. QMenu * menu;
  136. QToolBar * tool;
  137. FbTextEdit *text = mainDock->text();
  138. FbHeadEdit *head = mainDock->head();
  139. FbCodeEdit *code = mainDock->code();
  140. menu = menuBar()->addMenu(tr("&File"));
  141. tool = addToolBar(tr("File"));
  142. tool->setMovable(false);
  143. act = new QAction(FbIcon("document-new"), tr("&New"), this);
  144. act->setPriority(QAction::LowPriority);
  145. act->setShortcuts(QKeySequence::New);
  146. act->setStatusTip(tr("Create a new file"));
  147. connect(act, SIGNAL(triggered()), this, SLOT(fileNew()));
  148. menu->addAction(act);
  149. tool->addAction(act);
  150. act = new QAction(FbIcon("document-open"), tr("&Open..."), this);
  151. act->setShortcuts(QKeySequence::Open);
  152. act->setStatusTip(tr("Open an existing file"));
  153. connect(act, SIGNAL(triggered()), this, SLOT(fileOpen()));
  154. menu->addAction(act);
  155. tool->addAction(act);
  156. act = new QAction(FbIcon("document-save"), tr("&Save"), this);
  157. act->setShortcuts(QKeySequence::Save);
  158. act->setStatusTip(tr("Save the document to disk"));
  159. connect(act, SIGNAL(triggered()), this, SLOT(fileSave()));
  160. menu->addAction(act);
  161. tool->addAction(act);
  162. act = new QAction(FbIcon("document-save-as"), tr("Save &As..."), this);
  163. act->setShortcuts(QKeySequence::SaveAs);
  164. act->setStatusTip(tr("Save the document under a new name"));
  165. connect(act, SIGNAL(triggered()), this, SLOT(fileSaveAs()));
  166. menu->addAction(act);
  167. menu->addSeparator();
  168. act = new QAction(FbIcon("window-close"), tr("&Close"), this);
  169. act->setShortcuts(QKeySequence::Close);
  170. act->setStatusTip(tr("Close this window"));
  171. connect(act, SIGNAL(triggered()), this, SLOT(close()));
  172. menu->addAction(act);
  173. act = new QAction(FbIcon("application-exit"), tr("E&xit"), this);
  174. act->setShortcuts(QKeySequence::Quit);
  175. act->setStatusTip(tr("Exit the application"));
  176. connect(act, SIGNAL(triggered()), qApp, SLOT(closeAllWindows()));
  177. menu->addAction(act);
  178. menu = menuBar()->addMenu(tr("&Edit"));
  179. act = new FbTextAction(FbIcon("edit-undo"), tr("&Undo"), QWebPage::Undo, text);
  180. text->setAction(Fb::EditUndo, act);
  181. code->setAction(Fb::EditUndo, act);
  182. act->setPriority(QAction::LowPriority);
  183. act->setShortcut(QKeySequence::Undo);
  184. act->setEnabled(false);
  185. menu->addAction(act);
  186. act = new FbTextAction(FbIcon("edit-redo"), tr("&Redo"), QWebPage::Redo, text);
  187. text->setAction(Fb::EditRedo, act);
  188. code->setAction(Fb::EditRedo, act);
  189. act->setPriority(QAction::LowPriority);
  190. act->setShortcut(QKeySequence::Redo);
  191. act->setEnabled(false);
  192. menu->addAction(act);
  193. menu->addSeparator();
  194. act = new FbTextAction(FbIcon("edit-cut"), tr("Cu&t"), QWebPage::Cut, text);
  195. text->setAction(Fb::EditCut, act);
  196. code->setAction(Fb::EditCut, act);
  197. act->setShortcutContext(Qt::WidgetShortcut);
  198. act->setPriority(QAction::LowPriority);
  199. act->setShortcuts(QKeySequence::Cut);
  200. act->setStatusTip(tr("Cut the current selection's contents to the clipboard"));
  201. act->setEnabled(false);
  202. menu->addAction(act);
  203. act = new FbTextAction(FbIcon("edit-copy"), tr("&Copy"), QWebPage::Copy, text);
  204. text->setAction(Fb::EditCopy, act);
  205. code->setAction(Fb::EditCopy, act);
  206. act->setShortcutContext(Qt::WidgetShortcut);
  207. act->setPriority(QAction::LowPriority);
  208. act->setShortcuts(QKeySequence::Copy);
  209. act->setStatusTip(tr("Copy the current selection's contents to the clipboard"));
  210. act->setEnabled(false);
  211. menu->addAction(act);
  212. act = new FbTextAction(FbIcon("edit-paste"), tr("&Paste"), QWebPage::Paste, text);
  213. text->setAction(Fb::EditPaste, act);
  214. code->setAction(Fb::EditPaste, act);
  215. act->setShortcutContext(Qt::WidgetShortcut);
  216. act->setPriority(QAction::LowPriority);
  217. act->setShortcuts(QKeySequence::Paste);
  218. act->setStatusTip(tr("Paste the clipboard's contents into the current selection"));
  219. menu->addAction(act);
  220. act = new FbTextAction(tr("Paste (no style)"), QWebPage::PasteAndMatchStyle, text);
  221. text->setAction(Fb::PasteText, act);
  222. menu->addAction(act);
  223. menu->addSeparator();
  224. act = new QAction(FbIcon("edit-find"), tr("&Find..."), this);
  225. text->setAction(Fb::EditFind, act);
  226. code->setAction(Fb::EditFind, act);
  227. act->setShortcuts(QKeySequence::Find);
  228. menu->addAction(act);
  229. act = new QAction(FbIcon("edit-find-replace"), tr("&Replace..."), this);
  230. text->setAction(Fb::EditReplace, act);
  231. code->setAction(Fb::EditReplace, act);
  232. menu->addAction(act);
  233. act = new QAction(FbIcon("tools-check-spelling"), tr("&Check..."), this);
  234. code->setAction(Fb::CheckText, act);
  235. menu->addAction(act);
  236. menu->addSeparator();
  237. act = new QAction(FbIcon("preferences-desktop"), tr("&Settings"), this);
  238. act->setShortcuts(QKeySequence::Preferences);
  239. act->setStatusTip(tr("Application settings"));
  240. connect(act, SIGNAL(triggered()), SLOT(openSettings()));
  241. menu->addAction(act);
  242. menu = menuBar()->addMenu(tr("&Insert", "Main menu"));
  243. mainDock->addMenu(menu);
  244. act = new QAction(FbIcon("insert-image"), tr("&Image"), this);
  245. text->setAction(Fb::InsertImage, act);
  246. menu->addAction(act);
  247. act = new QAction(FbIcon("insert-text"), tr("&Footnote"), this);
  248. text->setAction(Fb::InsertNote, act);
  249. menu->addAction(act);
  250. act = new QAction(FbIcon("insert-link"), tr("&Hiperlink"), this);
  251. text->setAction(Fb::InsertLink, act);
  252. menu->addAction(act);
  253. menu->addSeparator();
  254. act = new QAction(tr("&Body"), this);
  255. text->setAction(Fb::InsertBody, act);
  256. menu->addAction(act);
  257. act = new QAction(FbIcon("insert-object"), tr("&Section"), this);
  258. text->setAction(Fb::InsertSection, act);
  259. menu->addAction(act);
  260. act = new QAction(tr("&Title"), this);
  261. text->setAction(Fb::InsertTitle, act);
  262. menu->addAction(act);
  263. act = new QAction(tr("&Epigraph"), this);
  264. text->setAction(Fb::InsertEpigraph, act);
  265. menu->addAction(act);
  266. act = new QAction(tr("&Annotation"), this);
  267. text->setAction(Fb::InsertAnnot, act);
  268. menu->addAction(act);
  269. act = new QAction(tr("&Subtitle"), this);
  270. text->setAction(Fb::InsertSubtitle, act);
  271. menu->addAction(act);
  272. act = new QAction(tr("&Cite"), this);
  273. text->setAction(Fb::InsertCite, act);
  274. menu->addAction(act);
  275. act = new QAction(tr("&Poem"), this);
  276. text->setAction(Fb::InsertPoem, act);
  277. menu->addAction(act);
  278. act = new QAction(tr("&Stanza"), this);
  279. text->setAction(Fb::InsertStanza, act);
  280. menu->addAction(act);
  281. act = new QAction(tr("&Author"), this);
  282. text->setAction(Fb::InsertAuthor, act);
  283. menu->addAction(act);
  284. act = new QAction(tr("&Date"), this);
  285. text->setAction(Fb::InsertDate, act);
  286. menu->addAction(act);
  287. menu->addSeparator();
  288. act = new QAction(tr("Simple text"), this);
  289. text->setAction(Fb::InsertText, act);
  290. menu->addAction(act);
  291. act = new FbTextAction(tr("Paragraph"), QWebPage::InsertParagraphSeparator, text);
  292. text->setAction(Fb::InsertParag, act);
  293. menu->addAction(act);
  294. menu = menuBar()->addMenu(tr("Fo&rmat"));
  295. mainDock->addMenu(menu);
  296. act = new FbTextAction(FbIcon("edit-clear"), tr("Clear format"), QWebPage::RemoveFormat, text);
  297. text->setAction(Fb::ClearFormat, act);
  298. menu->addAction(act);
  299. menu->addSeparator();
  300. act = new FbTextAction(FbIcon("format-text-bold"), tr("&Bold"), QWebPage::ToggleBold, text);
  301. text->setAction(Fb::TextBold, act);
  302. act->setShortcuts(QKeySequence::Bold);
  303. act->setCheckable(true);
  304. menu->addAction(act);
  305. act = new FbTextAction(FbIcon("format-text-italic"), tr("&Italic"), QWebPage::ToggleItalic, text);
  306. text->setAction(Fb::TextItalic, act);
  307. act->setShortcuts(QKeySequence::Italic);
  308. act->setCheckable(true);
  309. menu->addAction(act);
  310. act = new FbTextAction(FbIcon("format-text-strikethrough"), tr("&Strikethrough"), QWebPage::ToggleStrikethrough, text);
  311. text->setAction(Fb::TextStrike, act);
  312. act->setCheckable(true);
  313. menu->addAction(act);
  314. act = new FbTextAction(FbIcon("format-text-superscript"), tr("Su&perscript"), QWebPage::ToggleSuperscript, text);
  315. text->setAction(Fb::TextSup, act);
  316. act->setCheckable(true);
  317. menu->addAction(act);
  318. act = new FbTextAction(FbIcon("format-text-subscript"), tr("Su&bscript"), QWebPage::ToggleSubscript, text);
  319. text->setAction(Fb::TextSub, act);
  320. act->setCheckable(true);
  321. menu->addAction(act);
  322. act = new QAction(FbIcon("utilities-terminal"), tr("&Code"), this);
  323. text->setAction(Fb::TextCode, act);
  324. act->setCheckable(true);
  325. menu->addAction(act);
  326. menu->addSeparator();
  327. act = new QAction(FbIcon("format-indent-more"), tr("Create section"), text);
  328. text->setAction(Fb::SectionAdd, act);
  329. menu->addAction(act);
  330. act = new QAction(FbIcon("format-indent-less"), tr("Remove section"), text);
  331. text->setAction(Fb::SectionDel, act);
  332. menu->addAction(act);
  333. act = new QAction(FbIcon("format-justify-center"), tr("Make title"), text);
  334. text->setAction(Fb::TextTitle, act);
  335. menu->addAction(act);
  336. menu = menuBar()->addMenu(tr("&View"));
  337. tool->addSeparator();
  338. QActionGroup * viewGroup = new QActionGroup(this);
  339. act = new FbModeAction(mainDock, Fb::Text, FbIcon("x-office-document"), tr("&Text"));
  340. viewGroup->addAction(act);
  341. menu->addAction(act);
  342. tool->addAction(act);
  343. act->setChecked(true);
  344. act = new FbModeAction(mainDock, Fb::Head, FbIcon("document-properties"), tr("&Head"));
  345. viewGroup->addAction(act);
  346. menu->addAction(act);
  347. tool->addAction(act);
  348. act = new FbModeAction(mainDock, Fb::Code, FbIcon("text-x-generic"), tr("&XML"));
  349. viewGroup->addAction(act);
  350. menu->addAction(act);
  351. tool->addAction(act);
  352. #ifdef QT_DEBUG
  353. act = new FbModeAction(mainDock, Fb::Html, FbIcon("text-html"), tr("&HTML"));
  354. viewGroup->addAction(act);
  355. menu->addAction(act);
  356. #endif // _DEBUG
  357. menu->addSeparator();
  358. act = new QAction(FbIcon("zoom-in"), tr("Zoom in"), this);
  359. text->setAction(Fb::ZoomIn, act);
  360. code->setAction(Fb::ZoomIn, act);
  361. act->setShortcuts(QKeySequence::ZoomIn);
  362. menu->addAction(act);
  363. act = new QAction(FbIcon("zoom-out"), tr("Zoom out"), this);
  364. text->setAction(Fb::ZoomOut, act);
  365. code->setAction(Fb::ZoomOut, act);
  366. act->setShortcuts(QKeySequence::ZoomOut);
  367. menu->addAction(act);
  368. act = new QAction(FbIcon("zoom-original"), tr("Zoom original"), this);
  369. text->setAction(Fb::ZoomReset, act);
  370. code->setAction(Fb::ZoomReset, act);
  371. menu->addAction(act);
  372. menu->addSeparator();
  373. act = new QAction(tr("&Contents"), this);
  374. text->setAction(Fb::ViewContents, act);
  375. act->setCheckable(true);
  376. menu->addAction(act);
  377. act = new QAction(tr("&Pictures"), this);
  378. text->setAction(Fb::ViewPictures, act);
  379. act->setCheckable(true);
  380. menu->addAction(act);
  381. act = new QAction(tr("&Web inspector"), this);
  382. text->setAction(Fb::ViewInspector, act);
  383. act->setCheckable(true);
  384. menu->addAction(act);
  385. menuBar()->addSeparator();
  386. menu = menuBar()->addMenu(tr("&Help"));
  387. act = new QAction(FbIcon("help-about"), tr("&About"), this);
  388. act->setStatusTip(tr("Show the application's About box"));
  389. connect(act, SIGNAL(triggered()), this, SLOT(about()));
  390. menu->addAction(act);
  391. act = new QAction(tr("About &Qt"), this);
  392. act->setStatusTip(tr("Show the Qt library's About box"));
  393. connect(act, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
  394. menu->addAction(act);
  395. toolEdit = tool = addToolBar(tr("Edit"));
  396. tool->setMovable(false);
  397. tool->addSeparator();
  398. mainDock->setTool(tool);
  399. }
  400. void FbMainWindow::openSettings()
  401. {
  402. FbSetupDlg dlg(this);
  403. dlg.exec();
  404. }
  405. void FbMainWindow::createStatusBar()
  406. {
  407. statusBar()->showMessage(tr("Ready"));
  408. }
  409. void FbMainWindow::readSettings()
  410. {
  411. QSettings settings;
  412. QPoint pos = settings.value("pos", QPoint(200, 200)).toPoint();
  413. QSize size = settings.value("size", QSize(400, 400)).toSize();
  414. move(pos);
  415. resize(size);
  416. }
  417. void FbMainWindow::writeSettings()
  418. {
  419. QSettings settings;
  420. settings.setValue("pos", pos());
  421. settings.setValue("size", size());
  422. }
  423. bool FbMainWindow::maybeSave()
  424. {
  425. if (mainDock->isModified()) {
  426. QMessageBox::StandardButton ret;
  427. ret = QMessageBox::warning(this, qApp->applicationName(),
  428. tr("The document has been modified. Do you want to save your changes?"),
  429. QMessageBox::Save | QMessageBox::Discard
  430. | QMessageBox::Cancel);
  431. if (ret == QMessageBox::Save)
  432. return fileSave();
  433. else if (ret == QMessageBox::Cancel)
  434. return false;
  435. }
  436. return true;
  437. }
  438. bool FbMainWindow::saveFile(const QString &fileName, const QString &codec)
  439. {
  440. QFile file(fileName);
  441. if (!file.open(QFile::WriteOnly | QFile::Text)) {
  442. QMessageBox::warning(this, qApp->applicationName(), tr("Cannot write file %1: %2.").arg(fileName).arg(file.errorString()));
  443. return false;
  444. }
  445. bool ok = mainDock->save(&file, codec);
  446. setCurrentFile(fileName);
  447. return ok;
  448. }
  449. void FbMainWindow::setCurrentFile(const QString &filename)
  450. {
  451. if (filename.isEmpty()) {
  452. static int sequenceNumber = 1;
  453. curFile = QString("book%1.fb2").arg(sequenceNumber++);
  454. } else {
  455. QFileInfo info = filename;
  456. curFile = info.canonicalFilePath();
  457. }
  458. setWindowFilePath(curFile);
  459. setModified(false);
  460. }
  461. QString FbMainWindow::appTitle() const
  462. {
  463. return QString(" - ") += qApp->applicationName() += QString(" ") += qApp->applicationVersion();
  464. }
  465. FbMainWindow *FbMainWindow::findFbMainWindow(const QString &fileName)
  466. {
  467. QString canonicalFilePath = QFileInfo(fileName).canonicalFilePath();
  468. foreach (QWidget *widget, qApp->topLevelWidgets()) {
  469. FbMainWindow *mainWin = qobject_cast<FbMainWindow *>(widget);
  470. if (mainWin && mainWin->curFile == canonicalFilePath)
  471. return mainWin;
  472. }
  473. return 0;
  474. }
  475. /*
  476. void FbMainWindow::viewHead()
  477. {
  478. if (headTree && centralWidget() == headTree) return;
  479. if (textFrame) textFrame->hideInspector();
  480. FbTextPage *page = 0;
  481. if (codeEdit) {
  482. QString xml = codeEdit->text();
  483. page = new FbTextPage(this);
  484. if (!page->load(QString(), xml)) {
  485. delete page;
  486. return;
  487. }
  488. isSwitched = true;
  489. }
  490. FB2DELETE(dockTree);
  491. FB2DELETE(dockImgs);
  492. FB2DELETE(codeEdit);
  493. FB2DELETE(toolEdit);
  494. if (!textFrame) {
  495. textFrame = new FbTextFrame(this, actionInspect);
  496. FbTextEdit *textEdit = textFrame->view();
  497. if (page) {
  498. page->setParent(textEdit);
  499. textEdit->setPage(page);
  500. }
  501. }
  502. if (!headTree) {
  503. headTree = new FbHeadEdit(this);
  504. headTree->setText(textFrame->view());
  505. connect(headTree, SIGNAL(status(QString)), this, SLOT(status(QString)));
  506. }
  507. this->setFocus();
  508. textFrame->setParent(NULL);
  509. setCentralWidget(headTree);
  510. textFrame->setParent(this);
  511. headTree->updateTree();
  512. headTree->setFocus();
  513. if (textFrame) {
  514. actionUndo->disconnect();
  515. actionRedo->disconnect();
  516. actionCut->disconnect();
  517. actionCopy->disconnect();
  518. actionPaste->disconnect();
  519. actionTextBold->disconnect();
  520. actionTextItalic->disconnect();
  521. actionTextStrike->disconnect();
  522. actionTextSub->disconnect();
  523. actionTextSup->disconnect();
  524. }
  525. FB2DELETE(toolEdit);
  526. toolEdit = addToolBar(tr("Edit"));
  527. headTree->initToolbar(*toolEdit);
  528. toolEdit->addSeparator();
  529. toolEdit->setMovable(false);
  530. actionContents->setEnabled(false);
  531. actionPictures->setEnabled(false);
  532. actionInspect->setEnabled(true);
  533. }
  534. */
  535. void FbMainWindow::status(const QString &text)
  536. {
  537. statusBar()->showMessage(text);
  538. }