Disabled Accessibility on SheetTableView
This commit is contained in:
committed by
Chris Hennes
parent
c71e551556
commit
3f3a548b22
@@ -37,11 +37,11 @@
|
||||
|
||||
#include "DlgSettingsImp.h"
|
||||
#include "SpreadsheetView.h"
|
||||
#include "SheetTableViewAccessibleInterface.h"
|
||||
#include "ViewProviderSpreadsheet.h"
|
||||
#include "Workbench.h"
|
||||
|
||||
|
||||
// use a different name to CreateCommand()
|
||||
// use a different name to CreateCommand()
|
||||
void CreateSpreadsheetCommands(void);
|
||||
|
||||
void loadSpreadsheetResource()
|
||||
@@ -52,52 +52,51 @@ void loadSpreadsheetResource()
|
||||
}
|
||||
|
||||
namespace SpreadsheetGui {
|
||||
class Module : public Py::ExtensionModule<Module>
|
||||
{
|
||||
public:
|
||||
Module() : Py::ExtensionModule<Module>("SpreadsheetGui")
|
||||
class Module : public Py::ExtensionModule<Module>
|
||||
{
|
||||
public:
|
||||
Module() : Py::ExtensionModule<Module>("SpreadsheetGui")
|
||||
{
|
||||
add_varargs_method("open",&Module::open
|
||||
);
|
||||
initialize("This module is the SpreadsheetGui module."); // register with Python
|
||||
}
|
||||
);
|
||||
initialize("This module is the SpreadsheetGui module."); // register with Python
|
||||
}
|
||||
|
||||
~Module() override {}
|
||||
~Module() override {}
|
||||
|
||||
private:
|
||||
Py::Object open(const Py::Tuple& args)
|
||||
{
|
||||
char* Name;
|
||||
private:
|
||||
Py::Object open(const Py::Tuple& args)
|
||||
{
|
||||
char* Name;
|
||||
const char* DocName=nullptr;
|
||||
if (!PyArg_ParseTuple(args.ptr(), "et|s","utf-8",&Name,&DocName))
|
||||
throw Py::Exception();
|
||||
std::string EncodedName = std::string(Name);
|
||||
PyMem_Free(Name);
|
||||
throw Py::Exception();
|
||||
std::string EncodedName = std::string(Name);
|
||||
PyMem_Free(Name);
|
||||
|
||||
try {
|
||||
Base::FileInfo file(EncodedName);
|
||||
try {
|
||||
Base::FileInfo file(EncodedName);
|
||||
App::Document *pcDoc = App::GetApplication().newDocument(DocName ? DocName : QT_TR_NOOP("Unnamed"));
|
||||
Spreadsheet::Sheet *pcSheet = static_cast<Spreadsheet::Sheet *>(pcDoc->addObject("Spreadsheet::Sheet", file.fileNamePure().c_str()));
|
||||
|
||||
pcSheet->importFromFile(EncodedName, '\t', '"', '\\');
|
||||
pcSheet->execute();
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
throw Py::RuntimeError(e.what());
|
||||
}
|
||||
pcSheet->importFromFile(EncodedName, '\t', '"', '\\');
|
||||
pcSheet->execute();
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
throw Py::RuntimeError(e.what());
|
||||
}
|
||||
|
||||
return Py::None();
|
||||
return Py::None();
|
||||
}
|
||||
};
|
||||
|
||||
PyObject* initModule()
|
||||
{
|
||||
return Base::Interpreter().addModule(new Module);
|
||||
}
|
||||
};
|
||||
|
||||
PyObject* initModule()
|
||||
{
|
||||
return Base::Interpreter().addModule(new Module);
|
||||
}
|
||||
|
||||
} // namespace SpreadsheetGui
|
||||
|
||||
|
||||
/* Python entry */
|
||||
PyMOD_INIT_FUNC(SpreadsheetGui)
|
||||
{
|
||||
@@ -109,6 +108,8 @@ PyMOD_INIT_FUNC(SpreadsheetGui)
|
||||
// instantiating the commands
|
||||
CreateSpreadsheetCommands();
|
||||
|
||||
QAccessible::installFactory(SpreadsheetGui::SheetTableViewAccessibleInterface::ifactory);
|
||||
|
||||
SpreadsheetGui::ViewProviderSheet::init();
|
||||
SpreadsheetGui::ViewProviderSheetPython::init();
|
||||
SpreadsheetGui::Workbench::init();
|
||||
|
||||
@@ -66,6 +66,8 @@ SET(SpreadsheetGui_SRCS
|
||||
SpreadsheetDelegate.cpp
|
||||
SheetTableView.cpp
|
||||
SheetTableView.h
|
||||
SheetTableViewAccessibleInterface.h
|
||||
SheetTableViewAccessibleInterface.cpp
|
||||
SheetModel.h
|
||||
SheetModel.cpp
|
||||
PreCompiled.cpp
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2023 Adrian Popescu *
|
||||
* <adrian-constantin.popescu@outlook.com> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
# include <QAction>
|
||||
# include <QApplication>
|
||||
# include <QClipboard>
|
||||
# include <QKeyEvent>
|
||||
# include <QMessageBox>
|
||||
# include <QMenu>
|
||||
# include <QMimeData>
|
||||
#endif
|
||||
|
||||
#include "SheetTableViewAccessibleInterface.h"
|
||||
|
||||
namespace SpreadsheetGui {
|
||||
|
||||
SheetTableViewAccessibleInterface::SheetTableViewAccessibleInterface(
|
||||
SpreadsheetGui::SheetTableView* w)
|
||||
: QAccessibleWidget(w)
|
||||
{
|
||||
}
|
||||
|
||||
QString SheetTableViewAccessibleInterface::text(QAccessible::Text t) const
|
||||
{
|
||||
if (t == QAccessible::Help)
|
||||
return QString::fromLatin1("Implement me");
|
||||
return QAccessibleWidget::text(t);
|
||||
}
|
||||
|
||||
QAccessibleInterface* SheetTableViewAccessibleInterface::childAt(int x, int y) const
|
||||
{
|
||||
return (QAccessibleInterface*)this;
|
||||
}
|
||||
|
||||
int SheetTableViewAccessibleInterface::indexOfChild(const QAccessibleInterface*) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SheetTableViewAccessibleInterface::childCount() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
QAccessibleInterface* SheetTableViewAccessibleInterface::focusChild() const
|
||||
{
|
||||
return (QAccessibleInterface*)this;
|
||||
}
|
||||
|
||||
QAccessibleInterface* SheetTableViewAccessibleInterface::child(int index) const
|
||||
{
|
||||
return (QAccessibleInterface*)this;
|
||||
}
|
||||
|
||||
QAccessibleInterface* SheetTableViewAccessibleInterface::ifactory(const QString& key, QObject* o)
|
||||
{
|
||||
if (key == QString::fromUtf8("SpreadsheetGui::SheetTableView"))
|
||||
return new SheetTableViewAccessibleInterface(
|
||||
static_cast<SpreadsheetGui::SheetTableView*>(o));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
58
src/Mod/Spreadsheet/Gui/SheetTableViewAccessibleInterface.h
Normal file
58
src/Mod/Spreadsheet/Gui/SheetTableViewAccessibleInterface.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2023 Adrian Popescu *
|
||||
* <adrian-constantin.popescu@outlook.com> *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
* This library is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU Library General Public *
|
||||
* License as published by the Free Software Foundation; either *
|
||||
* version 2 of the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This library is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Library General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Library General Public *
|
||||
* License along with this library; see the file COPYING.LIB. If not, *
|
||||
* write to the Free Software Foundation, Inc., 59 Temple Place, *
|
||||
* Suite 330, Boston, MA 02111-1307, USA *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef SHEETTABLEVIEW_INTERFACE_H
|
||||
#define SHEETTABLEVIEW_INTERFACE_H
|
||||
|
||||
#include <Mod/Spreadsheet/Gui/SheetTableView.h>
|
||||
#include <QtWidgets/qaccessiblewidget.h>
|
||||
|
||||
namespace SpreadsheetGui {
|
||||
|
||||
// Currently SheetTableViewAccessibleInterface below deactivates the
|
||||
// built-in QAccessibleTable interface, and all the accessibility
|
||||
// features.
|
||||
//
|
||||
// For a proper implementation, start by extending that
|
||||
// and ensure you're not queue-ing empty cells, or counting empty cells
|
||||
//
|
||||
// Otherwise it will hang - https://github.com/FreeCAD/FreeCAD/issues/8265
|
||||
|
||||
class SheetTableViewAccessibleInterface : public QAccessibleWidget
|
||||
{
|
||||
public:
|
||||
SheetTableViewAccessibleInterface(SpreadsheetGui::SheetTableView* w);
|
||||
|
||||
QString text(QAccessible::Text t) const override;
|
||||
|
||||
QAccessibleInterface* childAt(int x, int y) const override;
|
||||
int indexOfChild(const QAccessibleInterface*) const override;
|
||||
int childCount() const override;
|
||||
QAccessibleInterface* focusChild() const override;
|
||||
QAccessibleInterface* child(int index) const override;
|
||||
|
||||
static QAccessibleInterface* ifactory(const QString& key, QObject* o);
|
||||
};
|
||||
}
|
||||
|
||||
#endif // SHEETTABLEVIEW_INTERFACE_H
|
||||
Reference in New Issue
Block a user