Add ability to show debug page from translator window
Also always enable chromium debug mode
This commit is contained in:
parent
4dd2d2ddb6
commit
2f1779ee9b
@ -34,5 +34,7 @@ Basically it is a combination of screen capture, OCR and translation tools.
|
|||||||
|
|
||||||
## Attributions
|
## Attributions
|
||||||
|
|
||||||
* icons made by [Smashicons](https://www.flaticon.com/authors/smashicons)
|
* icons made by
|
||||||
|
[Smashicons](https://www.flaticon.com/authors/smashicons),
|
||||||
|
[Freepik](https://www.flaticon.com/authors/freepik),
|
||||||
from [Flaticon](https://www.flaticon.com/)
|
from [Flaticon](https://www.flaticon.com/)
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
<file alias="st_error.png">share/images/STIconRed.png</file>
|
<file alias="st_error.png">share/images/STIconRed.png</file>
|
||||||
<file alias="loadImages.png">share/images/loadImages.png</file>
|
<file alias="loadImages.png">share/images/loadImages.png</file>
|
||||||
<file alias="loadImages@2x.png">share/images/loadImages@2x.png</file>
|
<file alias="loadImages@2x.png">share/images/loadImages@2x.png</file>
|
||||||
|
<file alias="debug.png">share/images/debug.png</file>
|
||||||
|
<file alias="debug@2x.png">share/images/debug@2x.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
<qresource prefix="/translations">
|
<qresource prefix="/translations">
|
||||||
<file alias="screentranslator_ru.qm">share/translations/screentranslator_ru.qm</file>
|
<file alias="screentranslator_ru.qm">share/translations/screentranslator_ru.qm</file>
|
||||||
|
BIN
share/images/debug.png
Normal file
BIN
share/images/debug.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 641 B |
BIN
share/images/debug@2x.png
Normal file
BIN
share/images/debug@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
@ -41,19 +41,18 @@ Translator::Translator(Manager &manager, const Settings &settings)
|
|||||||
, url_(new QLineEdit(this))
|
, url_(new QLineEdit(this))
|
||||||
, loadImages_(
|
, loadImages_(
|
||||||
new QAction(QIcon(":/icons/loadImages.png"), tr("Load images"), this))
|
new QAction(QIcon(":/icons/loadImages.png"), tr("Load images"), this))
|
||||||
|
, showDebugAction_(new QAction(QIcon(":/icons/debug.png"), tr("Debug"), this))
|
||||||
, tabs_(new QTabWidget(this))
|
, tabs_(new QTabWidget(this))
|
||||||
{
|
{
|
||||||
#ifdef DEVELOP
|
|
||||||
{
|
{
|
||||||
QTcpSocket socket;
|
QTcpSocket socket;
|
||||||
if (socket.bind()) {
|
if (socket.bind()) {
|
||||||
quint16 port = socket.localPort();
|
debugPort_ = socket.localPort();
|
||||||
LTRACE() << "debug port" << port;
|
qputenv("QTWEBENGINE_REMOTE_DEBUGGING",
|
||||||
qputenv("QTWEBENGINE_REMOTE_DEBUGGING", QString::number(port).toUtf8());
|
QString::number(debugPort_).toUtf8());
|
||||||
socket.close();
|
socket.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
setObjectName("Translator");
|
setObjectName("Translator");
|
||||||
|
|
||||||
@ -65,6 +64,7 @@ Translator::Translator(Manager &manager, const Settings &settings)
|
|||||||
toolBar->addWidget(new QLabel(tr("Url:"), this));
|
toolBar->addWidget(new QLabel(tr("Url:"), this));
|
||||||
toolBar->addWidget(url_);
|
toolBar->addWidget(url_);
|
||||||
toolBar->addAction(loadImages_);
|
toolBar->addAction(loadImages_);
|
||||||
|
toolBar->addAction(showDebugAction_);
|
||||||
|
|
||||||
auto layout = new QVBoxLayout(detailsFrame);
|
auto layout = new QVBoxLayout(detailsFrame);
|
||||||
layout->addWidget(toolBar);
|
layout->addWidget(toolBar);
|
||||||
@ -85,6 +85,8 @@ Translator::Translator(Manager &manager, const Settings &settings)
|
|||||||
loadImages_->setCheckable(true);
|
loadImages_->setCheckable(true);
|
||||||
connect(loadImages_, &QAction::toggled, //
|
connect(loadImages_, &QAction::toggled, //
|
||||||
this, &Translator::setPageLoadImages);
|
this, &Translator::setPageLoadImages);
|
||||||
|
connect(showDebugAction_, &QAction::triggered, //
|
||||||
|
this, &Translator::showDebugView);
|
||||||
|
|
||||||
connect(tabs_, &QTabWidget::currentChanged, //
|
connect(tabs_, &QTabWidget::currentChanged, //
|
||||||
this, &Translator::udpateCurrentPage);
|
this, &Translator::udpateCurrentPage);
|
||||||
@ -171,6 +173,16 @@ void Translator::createPage(const QString &scriptName,
|
|||||||
log->document()->setMaximumBlockCount(1000);
|
log->document()->setMaximumBlockCount(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Translator::showDebugView()
|
||||||
|
{
|
||||||
|
if (!debugView_)
|
||||||
|
debugView_ = std::make_unique<QWebEngineView>();
|
||||||
|
debugView_->load(
|
||||||
|
QUrl::fromUserInput("http://localhost:" + QString::number(debugPort_)));
|
||||||
|
debugView_->show();
|
||||||
|
debugView_->activateWindow();
|
||||||
|
}
|
||||||
|
|
||||||
WebPage *Translator::currentPage() const
|
WebPage *Translator::currentPage() const
|
||||||
{
|
{
|
||||||
const auto index = tabs_->currentIndex();
|
const auto index = tabs_->currentIndex();
|
||||||
|
@ -35,13 +35,17 @@ private:
|
|||||||
void processQueue();
|
void processQueue();
|
||||||
void markTranslated(const TaskPtr &task);
|
void markTranslated(const TaskPtr &task);
|
||||||
void createPage(const QString &scriptName, const QString &scriptText);
|
void createPage(const QString &scriptName, const QString &scriptText);
|
||||||
|
void showDebugView();
|
||||||
|
|
||||||
Manager &manager_;
|
Manager &manager_;
|
||||||
const Settings &settings_;
|
const Settings &settings_;
|
||||||
QWebEngineView *view_;
|
QWebEngineView *view_;
|
||||||
|
std::unique_ptr<QWebEngineView> debugView_;
|
||||||
QLineEdit *url_;
|
QLineEdit *url_;
|
||||||
QAction *loadImages_;
|
QAction *loadImages_;
|
||||||
|
QAction *showDebugAction_;
|
||||||
QTabWidget *tabs_;
|
QTabWidget *tabs_;
|
||||||
std::vector<TaskPtr> queue_;
|
std::vector<TaskPtr> queue_;
|
||||||
std::map<QString, std::unique_ptr<WebPage>> pages_;
|
std::map<QString, std::unique_ptr<WebPage>> pages_;
|
||||||
|
quint16 debugPort_{0};
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user