Commit c056b452 authored by Shubham  .'s avatar Shubham .
Browse files

Properly connect signal and slots for context sensitive help

parent af73ab36
......@@ -17,7 +17,6 @@
---
Copyright (C) 2009 Alexander Rieder <alexanderrieder@gmail.com>
*/
#include "cantor.h"
#include <KActionCollection>
#include <KConfigDialog>
......@@ -44,9 +43,10 @@
#include "lib/panelplugin.h"
#include "lib/worksheetaccess.h"
#include "backendchoosedialog.h"
#include "cantor.h"
#include "settings.h"
#include "ui_settings.h"
#include "backendchoosedialog.h"
CantorShell::CantorShell() : KParts::MainWindow(), m_part(nullptr)
{
......@@ -341,6 +341,7 @@ void CantorShell::addWorksheet(const QString& backendName)
{
connect(part, SIGNAL(setCaption(QString,QIcon)), this, SLOT(setTabCaption(QString,QIcon)));
connect(part, SIGNAL(worksheetSave(QUrl)), this, SLOT(onWorksheetSave(QUrl)));
m_parts.append(part);
int tab = m_tabWidget->addTab(part->widget(), i18n("Session %1", sessionCount++));
......
......@@ -29,7 +29,6 @@
#include <QMap>
class QTabWidget;
class KTextEdit;
class KRecentFilesAction;
namespace Cantor{
......@@ -115,7 +114,6 @@ private:
QTabWidget* m_tabWidget;
QList<QDockWidget*> m_panels;
QList<QAction*> m_newBackendActions;
QDockWidget* m_helpDocker;
KRecentFilesAction* m_recentProjectsAction;
// For better UX: set previous used filter in "Open" action as default filter
......
......@@ -147,6 +147,7 @@ CantorPart::CantorPart( QWidget *parentWidget, QObject *parent, const QVariantLi
connect(m_worksheet, &Worksheet::modified, this, static_cast<void (KParts::ReadWritePart::*)()>(&KParts::ReadWritePart::setModified));
connect(m_worksheet, &Worksheet::showHelp, this, &CantorPart::showHelp);
connect(m_worksheet, &Worksheet::loaded, this, &CantorPart::initialized);
connect(m_worksheet, &Worksheet::requestDocumentation, this, &CantorPart::requestDocumentation);
layout->addWidget(m_worksheetview);
setWidget(widget);
......
......@@ -84,6 +84,7 @@ Q_SIGNALS:
void setCaption(const QString& caption, const QIcon& icon);
void showHelp(const QString& help);
void worksheetSave(const QUrl& url);
void requestDocumentation(const QString&);
public Q_SLOTS:
void updateCaption();
......
......@@ -6,7 +6,6 @@ function(add_panel name)
INSTALL_NAMESPACE "cantor/panels")
target_link_libraries("cantor_${name}"
cantorpart
cantorlibs)
endfunction()
......
set( DocumentationPanelPlugin_SRCS
../../worksheet.cpp
../../worksheettextitem.cpp
documentationpanelplugin.cpp
documentationpanelwidget.cpp
)
......@@ -8,13 +6,10 @@ set( DocumentationPanelPlugin_SRCS
add_panel(documentationpanelplugin ${DocumentationPanelPlugin_SRCS})
target_link_libraries(cantor_documentationpanelplugin
cantorpart
cantorlibs
Qt5::Widgets
Qt5::Help
Qt5::Gui
Qt5::Core
Qt5::WebKitWidgets
Qt5::WebEngine
Qt5::WebEngineWidgets
Qt5::Xml)
Qt5::WebEngineWidgets)
......@@ -35,6 +35,7 @@ QWidget* DocumentationPanelPlugin::widget()
if(!m_widget)
{
m_widget = new DocumentationPanelWidget(parentWidget());
connect(parent()->parent(), SIGNAL(requestDocumentation(QString)), m_widget, SLOT(contextSensitiveHelp(QString)));
}
return m_widget;
......
......@@ -20,8 +20,6 @@
#include "cantor_macros.h"
#include "documentationpanelplugin.h"
#include "../../worksheet.h"
#include "../../worksheettextitem.h"
#include <KLocalizedString>
......@@ -88,9 +86,6 @@ DocumentationPanelWidget::DocumentationPanelWidget(QWidget* parent) :QWidget(par
connect(m_engine->contentWidget(), &QHelpContentWidget::linkActivated, this, &DocumentationPanelWidget::displayHelp);
connect(m_engine->indexWidget(), &QHelpIndexWidget::linkActivated, this, &DocumentationPanelWidget::displayHelp);
Worksheet* worksheet = new Worksheet(Cantor::Backend::getBackend(QLatin1String("maxima")), parent);
WorksheetTextItem* textItem = worksheet->currentTextItem();
connect(textItem, &WorksheetTextItem::requestDocumentation, this, &DocumentationPanelWidget::contextSensitiveHelp);
//connect(search, SIGNAL(clicked(bool)), this, SLOT(doSearch(QString)));
m_splitter = new QSplitter(Qt::Horizontal, this);
......@@ -115,7 +110,7 @@ void DocumentationPanelWidget::doSearch(const QString& str)
void DocumentationPanelWidget::contextSensitiveHelp(const QString& keyword)
{
qDebug() << "INSIDE DOCUMENTATION PANEL WIDGET" << keyword;
}
void DocumentationPanelWidget::loadDocumentation()
......
......@@ -47,10 +47,12 @@ class DocumentationPanelWidget : public QWidget
void loadDocumentation();
void unloadDocumentation();
public Q_SLOTS:
void contextSensitiveHelp(const QString&);
private Q_SLOTS:
void displayHelp(const QUrl&);
void doSearch(const QString&);
void contextSensitiveHelp(const QString&);
private:
QPointer<QHelpEngine> m_engine;
......
......@@ -261,6 +261,7 @@ class Worksheet : public QGraphicsScene
void pasteAvailable(bool);
void cut();
void copy();
void requestDocumentation(const QString&);
protected:
void contextMenuEvent(QGraphicsSceneContextMenuEvent*) override;
......
......@@ -478,7 +478,7 @@ void WorksheetTextItem::keyPressEvent(QKeyEvent *event)
// remove extra whitespaces from the selection
keyword = keyword.simplified();
keyword.replace(QStringLiteral(" "), QStringLiteral(""));
emit requestDocumentation(keyword);
emit worksheet()->requestDocumentation(keyword);
qDebug()<<"Searching help for "<<keyword;
return;
} else { // when the keyword is not under selection and the user presses key
......@@ -486,7 +486,7 @@ void WorksheetTextItem::keyPressEvent(QKeyEvent *event)
cursor.select(QTextCursor::WordUnderCursor);
setTextCursor(cursor);
const QString keyword = textCursor().selectedText();
emit requestDocumentation(keyword);
emit worksheet()->requestDocumentation(keyword);
qDebug()<<"Searching help for "<<keyword;
return;
}
......
......@@ -128,7 +128,6 @@ class WorksheetTextItem : public QGraphicsTextItem
void cutAvailable(bool);
void copyAvailable(bool);
void pasteAvailable(bool);
void requestDocumentation(const QString&);
public Q_SLOTS:
void insertTab();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment