mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 13:27:17 +01:00
qt ui - status main page now works
This commit is contained in:
parent
a79f614e12
commit
163cbcb89d
|
@ -185,7 +185,7 @@ namespace http {
|
|||
s << "<b>ERROR:</b> " << string << "<br>\r\n";
|
||||
}
|
||||
|
||||
static void ShowStatus (std::stringstream& s)
|
||||
void ShowStatus (std::stringstream& s, bool includeHiddenContent)
|
||||
{
|
||||
s << "<b>Uptime:</b> ";
|
||||
ShowUptime(s, i2p::context.GetUptime ());
|
||||
|
@ -233,33 +233,35 @@ namespace http {
|
|||
s << " (" << (double) i2p::transport::transports.GetTransitBandwidth () / 1024 << " KiB/s)<br>\r\n";
|
||||
s << "<b>Data path:</b> " << i2p::fs::GetDataDir() << "<br>\r\n";
|
||||
s << "<div class='slide'\r\n><label for='slide1'>Hidden content. Press on text to see.</label>\r\n<input type='checkbox' id='slide1'/>\r\n<p class='content'>\r\n";
|
||||
s << "<b>Router Ident:</b> " << i2p::context.GetRouterInfo().GetIdentHashBase64() << "<br>\r\n";
|
||||
s << "<b>Router Family:</b> " << i2p::context.GetRouterInfo().GetProperty("family") << "<br>\r\n";
|
||||
s << "<b>Router Caps:</b> " << i2p::context.GetRouterInfo().GetProperty("caps") << "<br>\r\n";
|
||||
s << "<b>Our external address:</b>" << "<br>\r\n" ;
|
||||
for (const auto& address : i2p::context.GetRouterInfo().GetAddresses())
|
||||
{
|
||||
switch (address->transportStyle)
|
||||
{
|
||||
case i2p::data::RouterInfo::eTransportNTCP:
|
||||
if (address->host.is_v6 ())
|
||||
s << "NTCP6 ";
|
||||
else
|
||||
s << "NTCP ";
|
||||
break;
|
||||
case i2p::data::RouterInfo::eTransportSSU:
|
||||
if (address->host.is_v6 ())
|
||||
s << "SSU6 ";
|
||||
else
|
||||
s << "SSU ";
|
||||
break;
|
||||
default:
|
||||
s << "Unknown ";
|
||||
}
|
||||
s << address->host.to_string() << ":" << address->port << "<br>\r\n";
|
||||
}
|
||||
s << "</p>\r\n</div>\r\n";
|
||||
s << "<b>Routers:</b> " << i2p::data::netdb.GetNumRouters () << " ";
|
||||
if(includeHiddenContent) {
|
||||
s << "<b>Router Ident:</b> " << i2p::context.GetRouterInfo().GetIdentHashBase64() << "<br>\r\n";
|
||||
s << "<b>Router Family:</b> " << i2p::context.GetRouterInfo().GetProperty("family") << "<br>\r\n";
|
||||
s << "<b>Router Caps:</b> " << i2p::context.GetRouterInfo().GetProperty("caps") << "<br>\r\n";
|
||||
s << "<b>Our external address:</b>" << "<br>\r\n" ;
|
||||
for (const auto& address : i2p::context.GetRouterInfo().GetAddresses())
|
||||
{
|
||||
switch (address->transportStyle)
|
||||
{
|
||||
case i2p::data::RouterInfo::eTransportNTCP:
|
||||
if (address->host.is_v6 ())
|
||||
s << "NTCP6 ";
|
||||
else
|
||||
s << "NTCP ";
|
||||
break;
|
||||
case i2p::data::RouterInfo::eTransportSSU:
|
||||
if (address->host.is_v6 ())
|
||||
s << "SSU6 ";
|
||||
else
|
||||
s << "SSU ";
|
||||
break;
|
||||
default:
|
||||
s << "Unknown ";
|
||||
}
|
||||
s << address->host.to_string() << ":" << address->port << "<br>\r\n";
|
||||
}
|
||||
}
|
||||
s << "</p>\r\n</div>\r\n";
|
||||
s << "<b>Routers:</b> " << i2p::data::netdb.GetNumRouters () << " ";
|
||||
s << "<b>Floodfills:</b> " << i2p::data::netdb.GetNumFloodfills () << " ";
|
||||
s << "<b>LeaseSets:</b> " << i2p::data::netdb.GetNumLeaseSets () << "<br>\r\n";
|
||||
|
||||
|
@ -797,7 +799,7 @@ namespace http {
|
|||
} else if (req.uri.find("cmd=") != std::string::npos) {
|
||||
HandleCommand (req, res, s);
|
||||
} else {
|
||||
ShowStatus (s);
|
||||
ShowStatus (s, true);
|
||||
res.add_header("Refresh", "10");
|
||||
}
|
||||
ShowPageTail (s);
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <map>
|
||||
#include <thread>
|
||||
#include <boost/asio.hpp>
|
||||
#include <sstream>
|
||||
#include "HTTP.h"
|
||||
|
||||
namespace i2p
|
||||
|
@ -75,6 +76,8 @@ namespace http
|
|||
boost::asio::io_service::work m_Work;
|
||||
boost::asio::ip::tcp::acceptor m_Acceptor;
|
||||
};
|
||||
|
||||
void ShowStatus (std::stringstream& s, bool includeHiddenContent);
|
||||
} // http
|
||||
} // i2p
|
||||
|
||||
|
|
|
@ -87,7 +87,8 @@ SOURCES += DaemonQT.cpp mainwindow.cpp \
|
|||
../../daemon/i2pd.cpp \
|
||||
../../daemon/I2PControl.cpp \
|
||||
../../daemon/UnixDaemon.cpp \
|
||||
../../daemon/UPnP.cpp
|
||||
../../daemon/UPnP.cpp \
|
||||
textbrowsertweaked1.cpp
|
||||
|
||||
#qt creator does not handle this well
|
||||
#SOURCES += $$files(../../libi2pd/*.cpp)
|
||||
|
@ -166,7 +167,8 @@ HEADERS += DaemonQT.h mainwindow.h \
|
|||
../../daemon/Daemon.h \
|
||||
../../daemon/HTTPServer.h \
|
||||
../../daemon/I2PControl.h \
|
||||
../../daemon/UPnP.h
|
||||
../../daemon/UPnP.h \
|
||||
textbrowsertweaked1.h
|
||||
|
||||
INCLUDEPATH += ../../libi2pd
|
||||
INCLUDEPATH += ../../libi2pd_client
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
#include "ui_statusbuttons.h"
|
||||
#include "ui_statushtmlpaneform.h"
|
||||
#include <sstream>
|
||||
#include <QMessageBox>
|
||||
#include <QTimer>
|
||||
#include <QFile>
|
||||
|
@ -10,6 +12,8 @@
|
|||
#include "FS.h"
|
||||
#include "Log.h"
|
||||
|
||||
#include "HTTPServer.h"
|
||||
|
||||
#ifndef ANDROID
|
||||
# include <QtDebug>
|
||||
#endif
|
||||
|
@ -28,6 +32,8 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
#ifndef ANDROID
|
||||
,quitting(false)
|
||||
#endif
|
||||
,wasSelectingAtStatusMainPage(false)
|
||||
,showHiddenInfoStatusMainPage(false)
|
||||
,ui(new Ui::MainWindow)
|
||||
,statusButtonsUI(new Ui::StatusButtonsForm)
|
||||
,i2pController(nullptr)
|
||||
|
@ -40,6 +46,8 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
{
|
||||
ui->setupUi(this);
|
||||
statusButtonsUI->setupUi(ui->statusButtonsPane);
|
||||
//,statusHtmlUI(new Ui::StatusHtmlPaneForm)
|
||||
//statusHtmlUI->setupUi(lastStatusWidgetui->statusWidget);
|
||||
ui->statusButtonsPane->setFixedSize(171,300);
|
||||
ui->verticalLayout->setGeometry(QRect(0,0,171,ui->verticalLayout->geometry().height()));
|
||||
//ui->statusButtonsPane->adjustSize();
|
||||
|
@ -75,8 +83,17 @@ MainWindow::MainWindow(QWidget *parent) :
|
|||
createTrayIcon();
|
||||
#endif
|
||||
|
||||
QObject::connect(ui->statusPagePushButton, SIGNAL(released()), this, SLOT(showStatusPage()));
|
||||
setStatusButtonsVisible(true);
|
||||
textBrowser = new TextBrowserTweaked1();
|
||||
ui->verticalLayout_2->addWidget(textBrowser);
|
||||
scheduleMainPageUpdates();
|
||||
|
||||
QObject::connect(ui->statusPagePushButton, SIGNAL(released()), this, SLOT(showStatusMainPage()));
|
||||
showStatusMainPage();
|
||||
QObject::connect(statusButtonsUI->mainPagePushButton, SIGNAL(released()), this, SLOT(showStatusMainPage()));
|
||||
QObject::connect(textBrowser, SIGNAL(mouseReleased()), this, SLOT(statusHtmlPageMouseReleased()));
|
||||
QObject::connect(textBrowser, SIGNAL(selectionChanged()), this, SLOT(statusHtmlPageSelectionChanged()));
|
||||
|
||||
|
||||
QObject::connect(ui->settingsPagePushButton, SIGNAL(released()), this, SLOT(showSettingsPage()));
|
||||
|
||||
QObject::connect(ui->tunnelsPagePushButton, SIGNAL(released()), this, SLOT(showTunnelsPage()));
|
||||
|
@ -243,6 +260,49 @@ void MainWindow::setStatusButtonsVisible(bool visible) {
|
|||
ui->statusButtonsPane->setVisible(visible);
|
||||
}
|
||||
|
||||
// see also: HTTPServer.cpp
|
||||
QString MainWindow::getStatusMainPageHtml(bool showHiddenInfo) {
|
||||
std::stringstream s;
|
||||
|
||||
i2p::http::ShowStatus (s, showHiddenInfo);
|
||||
|
||||
std::string str = s.str();
|
||||
return QString::fromStdString(str);
|
||||
}
|
||||
|
||||
void MainWindow::showStatusMainPage() {
|
||||
showHiddenInfoStatusMainPage=false;
|
||||
showStatusPage();
|
||||
textBrowser->setHtml(getStatusMainPageHtml(false));
|
||||
textBrowser->show();
|
||||
wasSelectingAtStatusMainPage=false;
|
||||
}
|
||||
|
||||
void MainWindow::scheduleMainPageUpdates() {
|
||||
statusMainPageUpdateTimer = new QTimer(this);
|
||||
connect(statusMainPageUpdateTimer, SIGNAL(timeout()), this, SLOT(updateStatusMainPage()));
|
||||
statusMainPageUpdateTimer->start(10*1000/*millis*/);
|
||||
}
|
||||
|
||||
void MainWindow::statusHtmlPageMouseReleased() {
|
||||
if(wasSelectingAtStatusMainPage){
|
||||
QString selection = textBrowser->textCursor().selectedText();
|
||||
if(!selection.isEmpty()&&!selection.isNull())return;
|
||||
}
|
||||
showHiddenInfoStatusMainPage=!showHiddenInfoStatusMainPage;
|
||||
textBrowser->setHtml(getStatusMainPageHtml(showHiddenInfoStatusMainPage));
|
||||
}
|
||||
|
||||
void MainWindow::statusHtmlPageSelectionChanged() {
|
||||
wasSelectingAtStatusMainPage=true;
|
||||
}
|
||||
|
||||
void MainWindow::updateStatusMainPage() {
|
||||
showHiddenInfoStatusMainPage=false;
|
||||
textBrowser->setHtml(getStatusMainPageHtml(showHiddenInfoStatusMainPage));
|
||||
}
|
||||
|
||||
|
||||
//TODO
|
||||
void MainWindow::resizeEvent(QResizeEvent *event)
|
||||
{
|
||||
|
@ -363,6 +423,7 @@ void MainWindow::handleGracefulQuitTimerEvent() {
|
|||
MainWindow::~MainWindow()
|
||||
{
|
||||
qDebug("Destroying main window");
|
||||
delete statusMainPageUpdateTimer;
|
||||
for(QList<MainWindowItem*>::iterator it = configItems.begin(); it!= configItems.end(); ++it) {
|
||||
MainWindowItem* item = *it;
|
||||
item->deleteLater();
|
||||
|
@ -642,3 +703,4 @@ void MainWindow::addClientTunnelPushButtonReleased() {
|
|||
void MainWindow::setI2PController(i2p::qt::Controller* controller_) {
|
||||
this->i2pController = controller_;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include "ServerTunnelPane.h"
|
||||
#include "ClientTunnelPane.h"
|
||||
#include "TunnelConfig.h"
|
||||
#include "textbrowsertweaked1.h"
|
||||
|
||||
#include "Config.h"
|
||||
#include "FS.h"
|
||||
|
@ -306,8 +307,9 @@ public:
|
|||
};
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
class StatusButtonsForm;
|
||||
class MainWindow;
|
||||
class StatusButtonsForm;
|
||||
class StatusHtmlPaneForm;
|
||||
}
|
||||
|
||||
using namespace i2p::client;
|
||||
|
@ -343,13 +345,23 @@ private slots:
|
|||
void iconActivated(QSystemTrayIcon::ActivationReason reason);
|
||||
void toggleVisibilitySlot();
|
||||
#endif
|
||||
void showStatusPage();
|
||||
void showStatusMainPage();
|
||||
void statusHtmlPageMouseReleased();
|
||||
void statusHtmlPageSelectionChanged();
|
||||
void updateStatusMainPage();
|
||||
void scheduleMainPageUpdates();
|
||||
|
||||
void showSettingsPage();
|
||||
void showTunnelsPage();
|
||||
void showRestartPage();
|
||||
void showQuitPage();
|
||||
|
||||
private:
|
||||
QTimer * statusMainPageUpdateTimer;
|
||||
bool wasSelectingAtStatusMainPage;
|
||||
bool showHiddenInfoStatusMainPage;
|
||||
|
||||
void showStatusPage();
|
||||
#ifndef ANDROID
|
||||
void createActions();
|
||||
void createTrayIcon();
|
||||
|
@ -362,6 +374,8 @@ private:
|
|||
Ui::MainWindow* ui;
|
||||
Ui::StatusButtonsForm* statusButtonsUI;
|
||||
|
||||
TextBrowserTweaked1 * textBrowser;
|
||||
|
||||
i2p::qt::Controller* i2pController;
|
||||
|
||||
protected:
|
||||
|
@ -373,6 +387,8 @@ protected:
|
|||
|
||||
void setStatusButtonsVisible(bool visible);
|
||||
|
||||
QString getStatusMainPageHtml(bool showHiddenInfo);
|
||||
|
||||
QList<MainWindowItem*> configItems;
|
||||
NonGUIOptionItem* logOption;
|
||||
NonGUIOptionItem* daemonOption;
|
||||
|
|
|
@ -6,19 +6,19 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>904</width>
|
||||
<width>908</width>
|
||||
<height>550</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>904</width>
|
||||
<width>908</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>950</width>
|
||||
<width>908</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
|
@ -34,13 +34,13 @@
|
|||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>904</width>
|
||||
<height>0</height>
|
||||
<width>908</width>
|
||||
<height>550</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<width>908</width>
|
||||
<height>550</height>
|
||||
</size>
|
||||
</property>
|
||||
|
@ -49,8 +49,8 @@
|
|||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>931</width>
|
||||
<height>715</height>
|
||||
<width>888</width>
|
||||
<height>530</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
|
@ -183,26 +183,32 @@
|
|||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<width>713</width>
|
||||
<height>713</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>2</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="statusPage">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<widget class="QWidget" name="verticalLayoutWidget_5">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>686</width>
|
||||
<width>713</width>
|
||||
<height>531</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetMinAndMaxSize</enum>
|
||||
<enum>QLayout::SetMaximumSize</enum>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
|
@ -217,17 +223,11 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetMaximumSize</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
@ -244,7 +244,7 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>706</width>
|
||||
<width>711</width>
|
||||
<height>531</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
@ -283,8 +283,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>684</width>
|
||||
<height>496</height>
|
||||
<width>80</width>
|
||||
<height>26</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
|
@ -3045,7 +3045,7 @@ Comma separated list of base64 identities:</string>
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>706</width>
|
||||
<width>711</width>
|
||||
<height>531</height>
|
||||
</rect>
|
||||
</property>
|
||||
|
@ -3110,7 +3110,7 @@ Comma separated list of base64 identities:</string>
|
|||
<widget class="QWidget" name="tunnelsScrollAreaWidgetContents">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>-18</x>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>699</width>
|
||||
<height>425</height>
|
||||
|
@ -3128,8 +3128,8 @@ Comma separated list of base64 identities:</string>
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>686</width>
|
||||
<height>496</height>
|
||||
<width>711</width>
|
||||
<height>531</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
|
@ -3183,8 +3183,8 @@ Comma separated list of base64 identities:</string>
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>686</width>
|
||||
<height>496</height>
|
||||
<width>711</width>
|
||||
<height>531</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="quitPageVerticalLayout">
|
||||
|
|
6
qt/i2pd_qt/textbrowsertweaked1.cpp
Normal file
6
qt/i2pd_qt/textbrowsertweaked1.cpp
Normal file
|
@ -0,0 +1,6 @@
|
|||
#include "textbrowsertweaked1.h"
|
||||
|
||||
TextBrowserTweaked1::TextBrowserTweaked1()
|
||||
{
|
||||
|
||||
}
|
22
qt/i2pd_qt/textbrowsertweaked1.h
Normal file
22
qt/i2pd_qt/textbrowsertweaked1.h
Normal file
|
@ -0,0 +1,22 @@
|
|||
#ifndef TEXTBROWSERTWEAKED1_H
|
||||
#define TEXTBROWSERTWEAKED1_H
|
||||
|
||||
#include <QTextBrowser>
|
||||
|
||||
class TextBrowserTweaked1 : public QTextBrowser
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TextBrowserTweaked1();
|
||||
|
||||
signals:
|
||||
void mouseReleased();
|
||||
|
||||
protected:
|
||||
void mouseReleaseEvent(QMouseEvent *event) {
|
||||
emit mouseReleased();
|
||||
}
|
||||
};
|
||||
|
||||
#endif // TEXTBROWSERTWEAKED1_H
|
Loading…
Reference in a new issue