improved display of Tor starting window

This commit is contained in:
csoler 2017-12-26 20:42:25 +01:00
parent 355a0b42e9
commit 390af949a8
6 changed files with 152 additions and 61 deletions

View File

@ -3,6 +3,7 @@
#include <QTimer> #include <QTimer>
#include <QFile> #include <QFile>
#include <QTcpServer> #include <QTcpServer>
#include <QGraphicsDropShadowEffect>
#include <iostream> #include <iostream>
@ -34,6 +35,19 @@ TorControlDialog::TorControlDialog(Tor::TorManager *tm,QWidget *parent)
QObject::connect(timer,SIGNAL(timeout()),this,SLOT(showLog())) ; QObject::connect(timer,SIGNAL(timeout()),this,SLOT(showLog())) ;
timer->start(500) ; timer->start(500) ;
// Hide some debug output for the released version
// torLog_TB->hide();
torBootstrapStatus_LB->hide();
label_2->hide();
setWindowFlags( Qt::Dialog | Qt::FramelessWindowHint );
adjustSize();
// QGraphicsDropShadowEffect *effect = new QGraphicsDropShadowEffect(this);
// effect->setBlurRadius(30.0);
// setGraphicsEffect(effect);
} }
void TorControlDialog::onIncomingConnection() void TorControlDialog::onIncomingConnection()
@ -66,7 +80,8 @@ void TorControlDialog::statusChanged()
case Tor::TorControl::TorReady: torstatus_str = "Tor ready" ; break ; case Tor::TorControl::TorReady: torstatus_str = "Tor ready" ; break ;
} }
torStatus_LB->setText(torstatus_str + "(" + status_str + ")") ; //torStatus_LB->setText(torstatus_str + "(" + status_str + ")") ;
torStatus_LB->setText(status_str) ;
QVariantMap qvm = mTorManager->control()->bootstrapStatus(); QVariantMap qvm = mTorManager->control()->bootstrapStatus();
QString bootstrapstatus_str ; QString bootstrapstatus_str ;
@ -79,23 +94,29 @@ void TorControlDialog::statusChanged()
QList<Tor::HiddenService*> hidden_services = mTorManager->control()->hiddenServices(); QList<Tor::HiddenService*> hidden_services = mTorManager->control()->hiddenServices();
if(hidden_services.empty()) if(hidden_services.empty())
hiddenService_LB->setText(QString("None")) ; {
hiddenServiceAddress_LB->setText(QString("[Not ready]")) ;
onionAddress_LB->setText(QString("[Not ready]")) ;
}
else else
{ {
QString hiddenservices_str ; QString hiddenservices_str ;
for(auto it(hidden_services.begin());it!=hidden_services.end();++it) for(auto it(hidden_services.begin());it!=hidden_services.end();++it)
{ {
hiddenservices_str += (*it)->hostname(); onionAddress_LB->setText((*it)->hostname());
for(auto it2((*it)->targets().begin());it2!=(*it)->targets().end();++it2) for(auto it2((*it)->targets().begin());it2!=(*it)->targets().end();++it2)
hiddenservices_str += QString::number((*it2).servicePort) + ":" + (*it2).targetAddress.toString() + ":" + QString::number((*it2).targetPort) + " " ; {
hiddenServiceAddress_LB->setText(QString::number((*it2).servicePort) + ":" + (*it2).targetAddress.toString() + ":" + QString::number((*it2).targetPort));
break ;
}
break ;
} }
hiddenService_LB->setText(hiddenservices_str) ;
} }
showLog(); showLog();
adjustSize();
} }
void TorControlDialog::showLog() void TorControlDialog::showLog()
@ -106,10 +127,9 @@ void TorControlDialog::showLog()
for(QStringList::const_iterator it(logmsgs.begin());it!=logmsgs.end();++it) for(QStringList::const_iterator it(logmsgs.begin());it!=logmsgs.end();++it)
s += *it + "\n" ; s += *it + "\n" ;
torLog_TB->setText(s) ; // torLog_TB->setText(s) ;
// QCoreApplication::processEvents() ;
// std::cerr << s.toStdString() << std::endl; std::cerr << s.toStdString() << std::endl;
} }
TorControlDialog::TorStatus TorControlDialog::checkForTor() TorControlDialog::TorStatus TorControlDialog::checkForTor()

View File

@ -7,7 +7,7 @@ namespace Tor {
class TorManager ; class TorManager ;
} }
class TorControlDialog: public QDialog, public Ui::TorControlDialog class TorControlDialog: public QWidget, public Ui::TorControlDialog
{ {
Q_OBJECT Q_OBJECT

View File

@ -1,70 +1,134 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>TorControlDialog</class> <class>TorControlDialog</class>
<widget class="QDialog" name="TorControlDialog"> <widget class="QWidget" name="TorControlDialog">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>739</width> <width>600</width>
<height>489</height> <height>188</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle"> <property name="windowTitle">
<string>Dialog</string> <string>Dialog</string>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<layout class="QGridLayout" name="gridLayout"> <widget class="QLabel" name="label_6">
<item row="2" column="1"> <property name="font">
<widget class="QLabel" name="hiddenService_LB"> <font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Setting up Tor...</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_4">
<property name="text"> <property name="text">
<string>TextLabel</string> <string/>
</property>
<property name="pixmap">
<pixmap resource="../gui/icons.qrc">:/icons/tor-logo.png</pixmap>
</property>
<property name="scaledContents">
<bool>false</bool>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item>
<widget class="QLabel" name="label_2"> <layout class="QGridLayout" name="gridLayout">
<property name="text"> <item row="0" column="0">
<string>Tor bootstrap status:</string> <widget class="QLabel" name="label">
</property> <property name="text">
</widget> <string>Tor status:</string>
</item> </property>
<item row="1" column="1"> <property name="alignment">
<widget class="QLabel" name="torBootstrapStatus_LB"> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
<property name="text"> </property>
<string>TextLabel</string> </widget>
</property> </item>
</widget> <item row="0" column="1">
</item> <widget class="QLabel" name="torStatus_LB">
<item row="2" column="0"> <property name="text">
<widget class="QLabel" name="label_3"> <string>TextLabel</string>
<property name="text"> </property>
<string>Hidden service:</string> </widget>
</property> </item>
</widget> <item row="1" column="1">
</item> <widget class="QLabel" name="torBootstrapStatus_LB">
<item row="0" column="0"> <property name="text">
<widget class="QLabel" name="label"> <string>TextLabel</string>
<property name="text"> </property>
<string>Tor status:</string> </widget>
</property> </item>
</widget> <item row="2" column="0">
</item> <widget class="QLabel" name="label_3">
<item row="0" column="1"> <property name="text">
<widget class="QLabel" name="torStatus_LB"> <string>Hidden service address:</string>
<property name="text"> </property>
<string>TextLabel</string> <property name="alignment">
</property> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</widget> </property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Tor bootstrap status:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="hiddenServiceAddress_LB">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Onion address:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="onionAddress_LB">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
</layout>
</item> </item>
</layout> </layout>
</item> </item>
<item>
<widget class="QTextBrowser" name="torLog_TB"/>
</item>
</layout> </layout>
</widget> </widget>
<resources/> <resources>
<include location="../gui/icons.qrc"/>
</resources>
<connections/> <connections/>
</ui> </ui>

View File

@ -1,5 +1,6 @@
<RCC> <RCC>
<qresource prefix="/"> <qresource prefix="/">
<file>icons/onion.png</file>
<file>icons/svg/hidden.svg</file> <file>icons/svg/hidden.svg</file>
<file>icons/svg/randomness.svg</file> <file>icons/svg/randomness.svg</file>
<file>icons/svg/password.svg</file> <file>icons/svg/password.svg</file>

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -313,8 +313,6 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO);
// #endif // #endif
/* Start RetroShare */ /* Start RetroShare */
QSplashScreen splashScreen(QPixmap(":/images/logo/logo_splash.png")/* , Qt::WindowStaysOnTopHint*/);
QString sDefaultGXSIdToCreate = ""; QString sDefaultGXSIdToCreate = "";
switch (initResult) { switch (initResult) {
case RS_INIT_OK: case RS_INIT_OK:
@ -348,13 +346,13 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO);
sDefaultGXSIdToCreate = gd.getGXSNickname(); sDefaultGXSIdToCreate = gd.getGXSNickname();
} }
splashScreen.show(); //splashScreen.show();
} }
break; break;
case RS_INIT_HAVE_ACCOUNT: case RS_INIT_HAVE_ACCOUNT:
{ {
splashScreen.show(); //splashScreen.show();
splashScreen.showMessage(rshare.translate("SplashScreen", "Load profile"), Qt::AlignHCenter | Qt::AlignBottom); //splashScreen.showMessage(rshare.translate("SplashScreen", "Load profile"), Qt::AlignHCenter | Qt::AlignBottom);
RsPeerId preferredId; RsPeerId preferredId;
RsAccounts::GetPreferredAccountId(preferredId); RsAccounts::GetPreferredAccountId(preferredId);
@ -394,7 +392,12 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO);
TorControlDialog tcd(torManager) ; TorControlDialog tcd(torManager) ;
tcd.show(); tcd.show();
while(tcd.checkForHiddenService() != 1+TorControlDialog::HIDDEN_SERVICE_STATUS_OK) // runs until some status is reached: either tor works, or it fails. while(tcd.checkForHiddenService() != TorControlDialog::HIDDEN_SERVICE_STATUS_OK) // runs until some status is reached: either tor works, or it fails.
{
QCoreApplication::processEvents();
usleep(0.2*1000*1000) ;
}
for(uint32_t i=0;i<10;++i) // give some time (2 secs) to see what's going on
{ {
QCoreApplication::processEvents(); QCoreApplication::processEvents();
usleep(0.2*1000*1000) ; usleep(0.2*1000*1000) ;
@ -410,6 +413,9 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO);
} }
#endif #endif
QSplashScreen splashScreen(QPixmap(":/images/logo/logo_splash.png")/* , Qt::WindowStaysOnTopHint*/);
splashScreen.show();
splashScreen.showMessage(rshare.translate("SplashScreen", "Load configuration"), Qt::AlignHCenter | Qt::AlignBottom); splashScreen.showMessage(rshare.translate("SplashScreen", "Load configuration"), Qt::AlignHCenter | Qt::AlignBottom);
/* stop Retroshare if startup fails */ /* stop Retroshare if startup fails */