Browse Source

some qt work. fixed on slow computers; now faster as delayed save is implemented

pull/1491/head
user 5 years ago
parent
commit
0e38e43315
  1. 4
      .gitignore
  2. 2
      daemon/HTTPServer.h
  3. 2
      qt/i2pd_qt/DelayedSaveManager.h
  4. 6
      qt/i2pd_qt/DelayedSaveManagerImpl.cpp
  5. 8
      qt/i2pd_qt/DelayedSaveManagerImpl.h
  6. 7
      qt/i2pd_qt/TunnelConfig.h
  7. 5
      qt/i2pd_qt/TunnelPane.cpp
  8. 2
      qt/i2pd_qt/TunnelPane.h
  9. 36
      qt/i2pd_qt/mainwindow.cpp
  10. 3
      qt/i2pd_qt/mainwindow.h

4
.gitignore vendored

@ -258,7 +258,7 @@ build/Makefile
# qt # qt
qt/i2pd_qt/*.ui.autosave qt/i2pd_qt/*.autosave
qt/i2pd_qt/*.ui.bk* qt/i2pd_qt/*.ui.bk*
qt/i2pd_qt/*.ui_* qt/i2pd_qt/*.ui_*
@ -268,3 +268,5 @@ android/libs/
#various logs #various logs
*LOGS/ *LOGS/
qt/build-*.sh*

2
daemon/HTTPServer.h

@ -89,7 +89,7 @@ namespace http
void ShowTransports (std::stringstream& s); void ShowTransports (std::stringstream& s);
void ShowSAMSessions (std::stringstream& s); void ShowSAMSessions (std::stringstream& s);
void ShowI2PTunnels (std::stringstream& s); void ShowI2PTunnels (std::stringstream& s);
void ShowLocalDestination (std::stringstream& s, const std::string& b32); void ShowLocalDestination (std::stringstream& s, const std::string& b32, uint32_t token);
} // http } // http
} // i2p } // i2p

2
qt/i2pd_qt/DelayedSaveManager.h

@ -18,7 +18,7 @@ public:
virtual bool appExiting()=0; virtual bool appExiting()=0;
virtual bool needsFocusOnTunnel()=0; virtual bool needsFocusOnTunnel()=0;
virtual std::string getTunnelNameToFocus()=0; virtual std::string& getTunnelNameToFocus()=0;
}; };
#endif // DELAYEDSAVEMANAGER_H #endif // DELAYEDSAVEMANAGER_H

6
qt/i2pd_qt/DelayedSaveManagerImpl.cpp

@ -21,10 +21,10 @@ bool DelayedSaveManagerImpl::isSaverValid() {
return saver != nullptr; return saver != nullptr;
} }
void DelayedSaveManagerImpl::delayedSave(DATA_SERIAL_TYPE dataSerial, bool focusOnTunnel, std::string tunnelNameToFocus) { void DelayedSaveManagerImpl::delayedSave(DATA_SERIAL_TYPE dataSerial, bool focusOnTunnel, std::string tunnelNameToFocus_) {
if(lastDataSerialSeen==dataSerial)return; if(lastDataSerialSeen==dataSerial)return;
this->focusOnTunnel = focusOnTunnel; this->focusOnTunnel = focusOnTunnel;
this->tunnelNameToFocus = tunnelNameToFocus; tunnelNameToFocus = tunnelNameToFocus_;
lastDataSerialSeen=dataSerial; lastDataSerialSeen=dataSerial;
assert(isSaverValid()); assert(isSaverValid());
TIMESTAMP_TYPE now = getTime(); TIMESTAMP_TYPE now = getTime();
@ -135,6 +135,6 @@ bool DelayedSaveManagerImpl::needsFocusOnTunnel() {
return focusOnTunnel; return focusOnTunnel;
} }
std::string DelayedSaveManagerImpl::getTunnelNameToFocus() { std::string& DelayedSaveManagerImpl::getTunnelNameToFocus() {
return tunnelNameToFocus; return tunnelNameToFocus;
} }

8
qt/i2pd_qt/DelayedSaveManagerImpl.h

@ -60,22 +60,22 @@ public:
static TIMESTAMP_TYPE getTime(); static TIMESTAMP_TYPE getTime();
bool needsFocusOnTunnel(); bool needsFocusOnTunnel();
std::string getTunnelNameToFocus(); std::string& getTunnelNameToFocus();
private: private:
Saver* saver; Saver* saver;
bool isSaverValid(); bool isSaverValid();
volatile DATA_SERIAL_TYPE lastDataSerialSeen; DATA_SERIAL_TYPE lastDataSerialSeen;
static constexpr TIMESTAMP_TYPE A_VERY_OBSOLETE_TIMESTAMP=DelayedSaveThread::A_VERY_OBSOLETE_TIMESTAMP; static constexpr TIMESTAMP_TYPE A_VERY_OBSOLETE_TIMESTAMP=DelayedSaveThread::A_VERY_OBSOLETE_TIMESTAMP;
TIMESTAMP_TYPE lastSaveStartedTimestamp; TIMESTAMP_TYPE lastSaveStartedTimestamp;
volatile bool exiting; bool exiting;
DelayedSaveThread* thread; DelayedSaveThread* thread;
void wakeThreadAndJoinThread(); void wakeThreadAndJoinThread();
volatile bool focusOnTunnel; bool focusOnTunnel;
std::string tunnelNameToFocus; std::string tunnelNameToFocus;
}; };

7
qt/i2pd_qt/TunnelConfig.h

@ -40,6 +40,9 @@ public:
class ClientTunnelConfig; class ClientTunnelConfig;
class ServerTunnelConfig; class ServerTunnelConfig;
class TunnelPane;
class TunnelConfig { class TunnelConfig {
/* /*
const char I2P_TUNNELS_SECTION_TYPE_CLIENT[] = "client"; const char I2P_TUNNELS_SECTION_TYPE_CLIENT[] = "client";
@ -54,6 +57,7 @@ class TunnelConfig {
*/ */
QString type; QString type;
std::string name; std::string name;
TunnelPane* tunnelPane;
public: public:
TunnelConfig(std::string name_, QString& type_, I2CPParameters& i2cpParameters_): TunnelConfig(std::string name_, QString& type_, I2CPParameters& i2cpParameters_):
type(type_), name(name_), i2cpParameters(i2cpParameters_) {} type(type_), name(name_), i2cpParameters(i2cpParameters_) {}
@ -68,7 +72,8 @@ public:
virtual void saveToStringStream(std::stringstream& out)=0; virtual void saveToStringStream(std::stringstream& out)=0;
virtual ClientTunnelConfig* asClientTunnelConfig()=0; virtual ClientTunnelConfig* asClientTunnelConfig()=0;
virtual ServerTunnelConfig* asServerTunnelConfig()=0; virtual ServerTunnelConfig* asServerTunnelConfig()=0;
void setTunnelPane(TunnelPane* tp){this->tunnelPane = tp;}
TunnelPane* getTunnelPane() {return tunnelPane;}
private: private:
I2CPParameters i2cpParameters; I2CPParameters i2cpParameters;
}; };

5
qt/i2pd_qt/TunnelPane.cpp

@ -83,6 +83,11 @@ void TunnelPane::setupTunnelPane(
retranslateTunnelForm(*this); retranslateTunnelForm(*this);
} }
void TunnelPane::deleteWidget() {
//gridLayoutWidget_2->deleteLater();
tunnelGroupBox->deleteLater();
}
void TunnelPane::appendControlsForI2CPParameters(I2CPParameters& i2cpParameters, int& gridIndex) { void TunnelPane::appendControlsForI2CPParameters(I2CPParameters& i2cpParameters, int& gridIndex) {
{ {
//number of hops of an inbound tunnel //number of hops of an inbound tunnel

2
qt/i2pd_qt/TunnelPane.h

@ -41,6 +41,8 @@ public:
virtual ServerTunnelPane* asServerTunnelPane()=0; virtual ServerTunnelPane* asServerTunnelPane()=0;
virtual ClientTunnelPane* asClientTunnelPane()=0; virtual ClientTunnelPane* asClientTunnelPane()=0;
void deleteWidget();
protected: protected:
MainWindow* mainWindow; MainWindow* mainWindow;
QWidget * wrongInputPane; QWidget * wrongInputPane;

36
qt/i2pd_qt/mainwindow.cpp

@ -664,6 +664,36 @@ void MainWindow::loadAllConfigs(SaverImpl* saverPtr){
//onLoggingOptionsChange(); //onLoggingOptionsChange();
} }
void MainWindow::layoutTunnels() {
int height=0;
ui->tunnelsScrollAreaWidgetContents->setGeometry(0,0,0,0);
for(std::map<std::string, TunnelConfig*>::iterator it = tunnelConfigs.begin(); it != tunnelConfigs.end(); ++it) {
const std::string& name=it->first;
TunnelConfig* tunconf = it->second;
TunnelPane * tunnelPane=tunconf->getTunnelPane();
if(!tunnelPane)continue;
int h=tunnelPane->height();
height+=h;
//qDebug() << "tun.height:" << height << "sz:" << tunnelPanes.size();
//int h=tunnelPane->appendClientTunnelForm(ctc, ui->tunnelsScrollAreaWidgetContents, tunnelPanes.size(), height);
}
//qDebug() << "tun.setting height:" << height;
ui->tunnelsScrollAreaWidgetContents->setGeometry(QRect(0, 0, 621, height));
/*QList<QWidget*> childWidgets = ui->tunnelsScrollAreaWidgetContents->findChildren<QWidget*>();
foreach(QWidget* widget, childWidgets)
widget->show();*/
}
void MainWindow::deleteTunnelFromUI(std::string tunnelName, TunnelConfig* cnf) {
TunnelPane* tp = cnf->getTunnelPane();
if(!tp)return;
tunnelPanes.remove(tp);
tp->deleteWidget();
layoutTunnels();
}
/** returns false iff not valid items present and save was aborted */ /** returns false iff not valid items present and save was aborted */
bool MainWindow::saveAllConfigs(bool focusOnTunnel, std::string tunnelNameToFocus){ bool MainWindow::saveAllConfigs(bool focusOnTunnel, std::string tunnelNameToFocus){
QString cannotSaveSettings = QApplication::tr("Cannot save settings."); QString cannotSaveSettings = QApplication::tr("Cannot save settings.");
@ -681,6 +711,7 @@ bool MainWindow::saveAllConfigs(bool focusOnTunnel, std::string tunnelNameToFocu
} }
} }
delayedSaveManagerPtr->delayedSave(++dataSerial, focusOnTunnel, tunnelNameToFocus); delayedSaveManagerPtr->delayedSave(++dataSerial, focusOnTunnel, tunnelNameToFocus);
//onLoggingOptionsChange(); //onLoggingOptionsChange();
return true; return true;
} }
@ -725,6 +756,7 @@ void MainWindow::appendTunnelForms(std::string tunnelNameToFocus) {
ServerTunnelConfig* stc = tunconf->asServerTunnelConfig(); ServerTunnelConfig* stc = tunconf->asServerTunnelConfig();
if(stc){ if(stc){
ServerTunnelPane * tunnelPane=new ServerTunnelPane(&tunnelsPageUpdateListener, stc, ui->wrongInputLabel, ui->wrongInputLabel, this); ServerTunnelPane * tunnelPane=new ServerTunnelPane(&tunnelsPageUpdateListener, stc, ui->wrongInputLabel, ui->wrongInputLabel, this);
tunconf->setTunnelPane(tunnelPane);
int h=tunnelPane->appendServerTunnelForm(stc, ui->tunnelsScrollAreaWidgetContents, tunnelPanes.size(), height); int h=tunnelPane->appendServerTunnelForm(stc, ui->tunnelsScrollAreaWidgetContents, tunnelPanes.size(), height);
height+=h; height+=h;
//qDebug() << "tun.height:" << height << "sz:" << tunnelPanes.size(); //qDebug() << "tun.height:" << height << "sz:" << tunnelPanes.size();
@ -738,6 +770,7 @@ void MainWindow::appendTunnelForms(std::string tunnelNameToFocus) {
ClientTunnelConfig* ctc = tunconf->asClientTunnelConfig(); ClientTunnelConfig* ctc = tunconf->asClientTunnelConfig();
if(ctc){ if(ctc){
ClientTunnelPane * tunnelPane=new ClientTunnelPane(&tunnelsPageUpdateListener, ctc, ui->wrongInputLabel, ui->wrongInputLabel, this); ClientTunnelPane * tunnelPane=new ClientTunnelPane(&tunnelsPageUpdateListener, ctc, ui->wrongInputLabel, ui->wrongInputLabel, this);
tunconf->setTunnelPane(tunnelPane);
int h=tunnelPane->appendClientTunnelForm(ctc, ui->tunnelsScrollAreaWidgetContents, tunnelPanes.size(), height); int h=tunnelPane->appendClientTunnelForm(ctc, ui->tunnelsScrollAreaWidgetContents, tunnelPanes.size(), height);
height+=h; height+=h;
//qDebug() << "tun.height:" << height << "sz:" << tunnelPanes.size(); //qDebug() << "tun.height:" << height << "sz:" << tunnelPanes.size();
@ -854,7 +887,8 @@ void MainWindow::anchorClickedHandler(const QUrl & link) {
pageWithBackButton->show(); pageWithBackButton->show();
textBrowser->hide(); textBrowser->hide();
std::stringstream s; std::stringstream s;
i2p::http::ShowLocalDestination(s,str.toStdString()); std::string strstd = str.toStdString();
i2p::http::ShowLocalDestination(s,strstd,0);
childTextBrowser->setHtml(QString::fromStdString(s.str())); childTextBrowser->setHtml(QString::fromStdString(s.str()));
} }
} }

3
qt/i2pd_qt/mainwindow.h

@ -513,6 +513,7 @@ protected:
NonGUIOptionItem* initNonGUIOption(ConfigOption option); NonGUIOptionItem* initNonGUIOption(ConfigOption option);
void loadAllConfigs(SaverImpl* saverPtr); void loadAllConfigs(SaverImpl* saverPtr);
void layoutTunnels();
public slots: public slots:
/** returns false iff not valid items present and save was aborted */ /** returns false iff not valid items present and save was aborted */
@ -540,6 +541,7 @@ private:
void appendTunnelForms(std::string tunnelNameToFocus); void appendTunnelForms(std::string tunnelNameToFocus);
void deleteTunnelForms(); void deleteTunnelForms();
void deleteTunnelFromUI(std::string tunnelName, TunnelConfig* cnf);
template<typename Section, typename Type> template<typename Section, typename Type>
std::string GetI2CPOption (const Section& section, const std::string& name, const Type& value) const std::string GetI2CPOption (const Section& section, const std::string& name, const Type& value) const
@ -585,6 +587,7 @@ private:
std::map<std::string,TunnelConfig*>::const_iterator it=tunnelConfigs.find(name); std::map<std::string,TunnelConfig*>::const_iterator it=tunnelConfigs.find(name);
if(it!=tunnelConfigs.end()){ if(it!=tunnelConfigs.end()){
TunnelConfig* tc=it->second; TunnelConfig* tc=it->second;
deleteTunnelFromUI(name, tc);
tunnelConfigs.erase(it); tunnelConfigs.erase(it);
delete tc; delete tc;
} }

Loading…
Cancel
Save