@ -1,6 +1,8 @@
# include "mainwindow.h"
# include "mainwindow.h"
# include "ui_mainwindow.h"
# include "ui_mainwindow.h"
# include "ui_statusbuttons.h"
# include "ui_statusbuttons.h"
# include "ui_statushtmlpaneform.h"
# include <sstream>
# include <QMessageBox>
# include <QMessageBox>
# include <QTimer>
# include <QTimer>
# include <QFile>
# include <QFile>
@ -10,6 +12,8 @@
# include "FS.h"
# include "FS.h"
# include "Log.h"
# include "Log.h"
# include "HTTPServer.h"
# ifndef ANDROID
# ifndef ANDROID
# include <QtDebug>
# include <QtDebug>
# endif
# endif
@ -28,6 +32,8 @@ MainWindow::MainWindow(QWidget *parent) :
# ifndef ANDROID
# ifndef ANDROID
, quitting ( false )
, quitting ( false )
# endif
# endif
, wasSelectingAtStatusMainPage ( false )
, showHiddenInfoStatusMainPage ( false )
, ui ( new Ui : : MainWindow )
, ui ( new Ui : : MainWindow )
, statusButtonsUI ( new Ui : : StatusButtonsForm )
, statusButtonsUI ( new Ui : : StatusButtonsForm )
, i2pController ( nullptr )
, i2pController ( nullptr )
@ -40,6 +46,8 @@ MainWindow::MainWindow(QWidget *parent) :
{
{
ui - > setupUi ( this ) ;
ui - > setupUi ( this ) ;
statusButtonsUI - > setupUi ( ui - > statusButtonsPane ) ;
statusButtonsUI - > setupUi ( ui - > statusButtonsPane ) ;
//,statusHtmlUI(new Ui::StatusHtmlPaneForm)
//statusHtmlUI->setupUi(lastStatusWidgetui->statusWidget);
ui - > statusButtonsPane - > setFixedSize ( 171 , 300 ) ;
ui - > statusButtonsPane - > setFixedSize ( 171 , 300 ) ;
ui - > verticalLayout - > setGeometry ( QRect ( 0 , 0 , 171 , ui - > verticalLayout - > geometry ( ) . height ( ) ) ) ;
ui - > verticalLayout - > setGeometry ( QRect ( 0 , 0 , 171 , ui - > verticalLayout - > geometry ( ) . height ( ) ) ) ;
//ui->statusButtonsPane->adjustSize();
//ui->statusButtonsPane->adjustSize();
@ -75,8 +83,17 @@ MainWindow::MainWindow(QWidget *parent) :
createTrayIcon ( ) ;
createTrayIcon ( ) ;
# endif
# endif
QObject : : connect ( ui - > statusPagePushButton , SIGNAL ( released ( ) ) , this , SLOT ( showStatusPage ( ) ) ) ;
textBrowser = new TextBrowserTweaked1 ( ) ;
setStatusButtonsVisible ( true ) ;
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 - > settingsPagePushButton , SIGNAL ( released ( ) ) , this , SLOT ( showSettingsPage ( ) ) ) ;
QObject : : connect ( ui - > tunnelsPagePushButton , SIGNAL ( released ( ) ) , this , SLOT ( showTunnelsPage ( ) ) ) ;
QObject : : connect ( ui - > tunnelsPagePushButton , SIGNAL ( released ( ) ) , this , SLOT ( showTunnelsPage ( ) ) ) ;
@ -243,6 +260,49 @@ void MainWindow::setStatusButtonsVisible(bool visible) {
ui - > statusButtonsPane - > setVisible ( 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
//TODO
void MainWindow : : resizeEvent ( QResizeEvent * event )
void MainWindow : : resizeEvent ( QResizeEvent * event )
{
{
@ -363,6 +423,7 @@ void MainWindow::handleGracefulQuitTimerEvent() {
MainWindow : : ~ MainWindow ( )
MainWindow : : ~ MainWindow ( )
{
{
qDebug ( " Destroying main window " ) ;
qDebug ( " Destroying main window " ) ;
delete statusMainPageUpdateTimer ;
for ( QList < MainWindowItem * > : : iterator it = configItems . begin ( ) ; it ! = configItems . end ( ) ; + + it ) {
for ( QList < MainWindowItem * > : : iterator it = configItems . begin ( ) ; it ! = configItems . end ( ) ; + + it ) {
MainWindowItem * item = * it ;
MainWindowItem * item = * it ;
item - > deleteLater ( ) ;
item - > deleteLater ( ) ;
@ -642,3 +703,4 @@ void MainWindow::addClientTunnelPushButtonReleased() {
void MainWindow : : setI2PController ( i2p : : qt : : Controller * controller_ ) {
void MainWindow : : setI2PController ( i2p : : qt : : Controller * controller_ ) {
this - > i2pController = controller_ ;
this - > i2pController = controller_ ;
}
}