|
@@ -88,11 +88,13 @@ void FbMainWindow::logDestroyed()
|
|
|
|
|
|
void FbMainWindow::treeDestroyed()
|
|
|
{
|
|
|
+ actionContents->setChecked(false);
|
|
|
dockTree = NULL;
|
|
|
}
|
|
|
|
|
|
void FbMainWindow::imgsDestroyed()
|
|
|
{
|
|
|
+ actionPictures->setChecked(false);
|
|
|
dockImgs = NULL;
|
|
|
}
|
|
|
|
|
@@ -434,15 +436,19 @@ void FbMainWindow::createActions()
|
|
|
|
|
|
menu->addSeparator();
|
|
|
|
|
|
- act = new QAction(tr("&Contents"), this);
|
|
|
+ actionContents = act = new QAction(tr("&Contents"), this);
|
|
|
+ act->setCheckable(true);
|
|
|
connect(act, SIGNAL(triggered()), this, SLOT(viewTree()));
|
|
|
menu->addAction(act);
|
|
|
|
|
|
- act = new QAction(tr("&Pictures"), this);
|
|
|
+ actionPictures = act = new QAction(tr("&Pictures"), this);
|
|
|
+ act->setCheckable(true);
|
|
|
connect(act, SIGNAL(triggered()), this, SLOT(viewImgs()));
|
|
|
menu->addAction(act);
|
|
|
|
|
|
actionInspect = act = new QAction(tr("&Web inspector"), this);
|
|
|
+ act->setCheckable(true);
|
|
|
+ connect(this, SIGNAL(showInspectorChecked(bool)), actionInspect, SLOT(setChecked(bool)));
|
|
|
menu->addAction(act);
|
|
|
|
|
|
menuBar()->addSeparator();
|
|
@@ -470,6 +476,7 @@ void FbMainWindow::createTree()
|
|
|
if (textFrame && centralWidget() == textFrame) {
|
|
|
dockTree = new FbDockWidget(tr("Contents"), this);
|
|
|
dockTree->setWidget(new FbTreeWidget(textFrame->view(), this));
|
|
|
+ connect(dockTree, SIGNAL(visibilityChanged(bool)), actionContents, SLOT(setChecked(bool)));
|
|
|
connect(dockTree, SIGNAL(destroyed()), SLOT(treeDestroyed()));
|
|
|
addDockWidget(Qt::LeftDockWidgetArea, dockTree);
|
|
|
}
|
|
@@ -480,6 +487,7 @@ void FbMainWindow::createImgs()
|
|
|
if (textFrame && centralWidget() == textFrame) {
|
|
|
dockImgs = new FbDockWidget(tr("Pictures"), this);
|
|
|
dockImgs->setWidget(new FbListWidget(textFrame->view(), this));
|
|
|
+ connect(dockImgs, SIGNAL(visibilityChanged(bool)), actionPictures, SLOT(setChecked(bool)));
|
|
|
connect(dockImgs, SIGNAL(destroyed()), SLOT(imgsDestroyed()));
|
|
|
addDockWidget(Qt::RightDockWidgetArea, dockImgs);
|
|
|
}
|
|
@@ -618,97 +626,7 @@ void FbMainWindow::checkScintillaUndo()
|
|
|
actionRedo->setEnabled(codeEdit->isRedoAvailable());
|
|
|
}
|
|
|
|
|
|
-void FbMainWindow::viewCode()
|
|
|
-{
|
|
|
- if (codeEdit && centralWidget() == codeEdit) return;
|
|
|
-
|
|
|
- bool load = false;
|
|
|
- QByteArray xml;
|
|
|
- if (textFrame) {
|
|
|
- textFrame->view()->save(&xml);
|
|
|
- isSwitched = true;
|
|
|
- load = true;
|
|
|
- }
|
|
|
-
|
|
|
- FB2DELETE(textFrame);
|
|
|
- FB2DELETE(dockTree);
|
|
|
- FB2DELETE(dockImgs);
|
|
|
- FB2DELETE(headTree);
|
|
|
-
|
|
|
- if (!codeEdit) {
|
|
|
- codeEdit = new FbCodeEdit;
|
|
|
- }
|
|
|
- if (load) codeEdit->load(xml);
|
|
|
- setCentralWidget(codeEdit);
|
|
|
- codeEdit->setFocus();
|
|
|
-
|
|
|
- FB2DELETE(toolEdit);
|
|
|
- QToolBar *tool = toolEdit = addToolBar(tr("Edit"));
|
|
|
- tool->addSeparator();
|
|
|
- tool->addAction(actionUndo);
|
|
|
- tool->addAction(actionRedo);
|
|
|
- tool->addSeparator();
|
|
|
- tool->addAction(actionCut);
|
|
|
- tool->addAction(actionCopy);
|
|
|
- tool->addAction(actionPaste);
|
|
|
- tool->addSeparator();
|
|
|
- tool->addAction(actionZoomIn);
|
|
|
- tool->addAction(actionZoomOut);
|
|
|
- tool->addAction(actionZoomReset);
|
|
|
- tool->setMovable(false);
|
|
|
-
|
|
|
- connect(codeEdit, SIGNAL(textChanged()), this, SLOT(documentWasModified()));
|
|
|
- connect(codeEdit, SIGNAL(textChanged()), this, SLOT(checkScintillaUndo()));
|
|
|
-
|
|
|
- connect(codeEdit, SIGNAL(copyAvailable(bool)), actionCut, SLOT(setEnabled(bool)));
|
|
|
- connect(codeEdit, SIGNAL(copyAvailable(bool)), actionCopy, SLOT(setEnabled(bool)));
|
|
|
-
|
|
|
- connect(actionUndo, SIGNAL(triggered()), codeEdit, SLOT(undo()));
|
|
|
- connect(actionRedo, SIGNAL(triggered()), codeEdit, SLOT(redo()));
|
|
|
-
|
|
|
- connect(actionCut, SIGNAL(triggered()), codeEdit, SLOT(cut()));
|
|
|
- connect(actionCopy, SIGNAL(triggered()), codeEdit, SLOT(copy()));
|
|
|
- connect(actionPaste, SIGNAL(triggered()), codeEdit, SLOT(paste()));
|
|
|
-
|
|
|
- connect(actionFind, SIGNAL(triggered()), codeEdit, SLOT(find()));
|
|
|
-
|
|
|
- connect(actionZoomIn, SIGNAL(triggered()), codeEdit, SLOT(zoomIn()));
|
|
|
- connect(actionZoomOut, SIGNAL(triggered()), codeEdit, SLOT(zoomOut()));
|
|
|
- connect(actionZoomReset, SIGNAL(triggered()), codeEdit, SLOT(zoomReset()));
|
|
|
-}
|
|
|
-
|
|
|
-void FbMainWindow::viewText()
|
|
|
-{
|
|
|
- if (textFrame && centralWidget() == textFrame) return;
|
|
|
-
|
|
|
- bool load = false;
|
|
|
- QString xml;
|
|
|
- if (codeEdit) {
|
|
|
- xml = codeEdit->text();
|
|
|
- isSwitched = true;
|
|
|
- load = true;
|
|
|
- }
|
|
|
-
|
|
|
- FB2DELETE(codeEdit);
|
|
|
- FB2DELETE(headTree);
|
|
|
- if (!textFrame) {
|
|
|
- textFrame = new FbTextFrame(this);
|
|
|
- }
|
|
|
- setCentralWidget(textFrame);
|
|
|
- textFrame->view()->setFocus();
|
|
|
- viewTree();
|
|
|
-
|
|
|
- FbTextEdit *textEdit = textFrame->view();
|
|
|
-
|
|
|
- connect(textEdit, SIGNAL(loadFinished(bool)), SLOT(loadFinished(bool)));
|
|
|
- connect(textEdit->pageAction(QWebPage::Undo), SIGNAL(changed()), SLOT(undoChanged()));
|
|
|
- connect(textEdit->pageAction(QWebPage::Redo), SIGNAL(changed()), SLOT(redoChanged()));
|
|
|
- connect(actionInspect, SIGNAL(triggered()), textFrame, SLOT(showInspector()));
|
|
|
-
|
|
|
- if (load) textFrame->view()->load(curFile, xml);
|
|
|
-}
|
|
|
-
|
|
|
-void FbMainWindow::loadFinished(bool)
|
|
|
+void FbMainWindow::createTextToolbar()
|
|
|
{
|
|
|
FbTextEdit * textEdit = textFrame->view();
|
|
|
FbTextPage * textPage = textEdit->page();
|
|
@@ -764,12 +682,44 @@ void FbMainWindow::loadFinished(bool)
|
|
|
tool->addAction(actionNote);
|
|
|
tool->addAction(actionLink);
|
|
|
tool->addAction(actionSection);
|
|
|
+}
|
|
|
|
|
|
- tool->addSeparator();
|
|
|
+void FbMainWindow::viewText()
|
|
|
+{
|
|
|
+ if (textFrame && centralWidget() == textFrame) return;
|
|
|
|
|
|
- tool->addAction(actionZoomIn);
|
|
|
- tool->addAction(actionZoomOut);
|
|
|
- tool->addAction(actionZoomReset);
|
|
|
+ if (textFrame) textFrame->hideInspector();
|
|
|
+
|
|
|
+ bool load = false;
|
|
|
+ QString xml;
|
|
|
+ if (codeEdit) {
|
|
|
+ xml = codeEdit->text();
|
|
|
+ isSwitched = true;
|
|
|
+ load = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ FB2DELETE(codeEdit);
|
|
|
+ FB2DELETE(headTree);
|
|
|
+ if (textFrame) {
|
|
|
+ createTextToolbar();
|
|
|
+ } else {
|
|
|
+ textFrame = new FbTextFrame(this, actionInspect);
|
|
|
+ }
|
|
|
+ setCentralWidget(textFrame);
|
|
|
+ textFrame->view()->setFocus();
|
|
|
+ viewTree();
|
|
|
+
|
|
|
+ FbTextEdit *textEdit = textFrame->view();
|
|
|
+
|
|
|
+ connect(textEdit, SIGNAL(loadFinished(bool)), SLOT(createTextToolbar()));
|
|
|
+ connect(textEdit->pageAction(QWebPage::Undo), SIGNAL(changed()), SLOT(undoChanged()));
|
|
|
+ connect(textEdit->pageAction(QWebPage::Redo), SIGNAL(changed()), SLOT(redoChanged()));
|
|
|
+
|
|
|
+ if (load) textFrame->view()->load(curFile, xml);
|
|
|
+
|
|
|
+ actionContents->setEnabled(true);
|
|
|
+ actionPictures->setEnabled(true);
|
|
|
+ actionInspect->setEnabled(true);
|
|
|
}
|
|
|
|
|
|
void FbMainWindow::viewHead()
|
|
@@ -787,7 +737,7 @@ void FbMainWindow::viewHead()
|
|
|
FB2DELETE(toolEdit);
|
|
|
|
|
|
if (!textFrame) {
|
|
|
- textFrame = new FbTextFrame(this);
|
|
|
+ textFrame = new FbTextFrame(this, actionInspect);
|
|
|
}
|
|
|
|
|
|
if (!headTree) {
|
|
@@ -825,6 +775,73 @@ void FbMainWindow::viewHead()
|
|
|
headTree->initToolbar(*toolEdit);
|
|
|
toolEdit->addSeparator();
|
|
|
toolEdit->setMovable(false);
|
|
|
+
|
|
|
+ actionContents->setEnabled(false);
|
|
|
+ actionPictures->setEnabled(false);
|
|
|
+ actionInspect->setEnabled(true);
|
|
|
+}
|
|
|
+
|
|
|
+void FbMainWindow::viewCode()
|
|
|
+{
|
|
|
+ if (codeEdit && centralWidget() == codeEdit) return;
|
|
|
+
|
|
|
+ bool load = false;
|
|
|
+ QByteArray xml;
|
|
|
+ if (textFrame) {
|
|
|
+ textFrame->view()->save(&xml);
|
|
|
+ isSwitched = true;
|
|
|
+ load = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ FB2DELETE(textFrame);
|
|
|
+ FB2DELETE(dockTree);
|
|
|
+ FB2DELETE(dockImgs);
|
|
|
+ FB2DELETE(headTree);
|
|
|
+
|
|
|
+ if (!codeEdit) {
|
|
|
+ codeEdit = new FbCodeEdit;
|
|
|
+ }
|
|
|
+ if (load) codeEdit->load(xml);
|
|
|
+ setCentralWidget(codeEdit);
|
|
|
+ codeEdit->setFocus();
|
|
|
+
|
|
|
+ FB2DELETE(toolEdit);
|
|
|
+ QToolBar *tool = toolEdit = addToolBar(tr("Edit"));
|
|
|
+ tool->addSeparator();
|
|
|
+ tool->addAction(actionUndo);
|
|
|
+ tool->addAction(actionRedo);
|
|
|
+ tool->addSeparator();
|
|
|
+ tool->addAction(actionCut);
|
|
|
+ tool->addAction(actionCopy);
|
|
|
+ tool->addAction(actionPaste);
|
|
|
+ tool->addSeparator();
|
|
|
+ tool->addAction(actionZoomIn);
|
|
|
+ tool->addAction(actionZoomOut);
|
|
|
+ tool->addAction(actionZoomReset);
|
|
|
+ tool->setMovable(false);
|
|
|
+
|
|
|
+ connect(codeEdit, SIGNAL(textChanged()), this, SLOT(documentWasModified()));
|
|
|
+ connect(codeEdit, SIGNAL(textChanged()), this, SLOT(checkScintillaUndo()));
|
|
|
+
|
|
|
+ connect(codeEdit, SIGNAL(copyAvailable(bool)), actionCut, SLOT(setEnabled(bool)));
|
|
|
+ connect(codeEdit, SIGNAL(copyAvailable(bool)), actionCopy, SLOT(setEnabled(bool)));
|
|
|
+
|
|
|
+ connect(actionUndo, SIGNAL(triggered()), codeEdit, SLOT(undo()));
|
|
|
+ connect(actionRedo, SIGNAL(triggered()), codeEdit, SLOT(redo()));
|
|
|
+
|
|
|
+ connect(actionCut, SIGNAL(triggered()), codeEdit, SLOT(cut()));
|
|
|
+ connect(actionCopy, SIGNAL(triggered()), codeEdit, SLOT(copy()));
|
|
|
+ connect(actionPaste, SIGNAL(triggered()), codeEdit, SLOT(paste()));
|
|
|
+
|
|
|
+ connect(actionFind, SIGNAL(triggered()), codeEdit, SLOT(find()));
|
|
|
+
|
|
|
+ connect(actionZoomIn, SIGNAL(triggered()), codeEdit, SLOT(zoomIn()));
|
|
|
+ connect(actionZoomOut, SIGNAL(triggered()), codeEdit, SLOT(zoomOut()));
|
|
|
+ connect(actionZoomReset, SIGNAL(triggered()), codeEdit, SLOT(zoomReset()));
|
|
|
+
|
|
|
+ actionContents->setEnabled(false);
|
|
|
+ actionPictures->setEnabled(false);
|
|
|
+ actionInspect->setEnabled(false);
|
|
|
}
|
|
|
|
|
|
void FbMainWindow::viewTree()
|