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

2
daemon/HTTPServer.h

@ -89,7 +89,7 @@ namespace http @@ -89,7 +89,7 @@ namespace http
void ShowTransports (std::stringstream& s);
void ShowSAMSessions (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
} // i2p

2
qt/i2pd_qt/DelayedSaveManager.h

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

6
qt/i2pd_qt/DelayedSaveManagerImpl.cpp

@ -21,10 +21,10 @@ bool DelayedSaveManagerImpl::isSaverValid() { @@ -21,10 +21,10 @@ bool DelayedSaveManagerImpl::isSaverValid() {
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;
this->focusOnTunnel = focusOnTunnel;
this->tunnelNameToFocus = tunnelNameToFocus;
tunnelNameToFocus = tunnelNameToFocus_;
lastDataSerialSeen=dataSerial;
assert(isSaverValid());
TIMESTAMP_TYPE now = getTime();
@ -135,6 +135,6 @@ bool DelayedSaveManagerImpl::needsFocusOnTunnel() { @@ -135,6 +135,6 @@ bool DelayedSaveManagerImpl::needsFocusOnTunnel() {
return focusOnTunnel;
}
std::string DelayedSaveManagerImpl::getTunnelNameToFocus() {
std::string& DelayedSaveManagerImpl::getTunnelNameToFocus() {
return tunnelNameToFocus;
}

8
qt/i2pd_qt/DelayedSaveManagerImpl.h

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

7
qt/i2pd_qt/TunnelConfig.h

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

5
qt/i2pd_qt/TunnelPane.cpp

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

2
qt/i2pd_qt/TunnelPane.h

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

36
qt/i2pd_qt/mainwindow.cpp

@ -664,6 +664,36 @@ void MainWindow::loadAllConfigs(SaverImpl* saverPtr){ @@ -664,6 +664,36 @@ void MainWindow::loadAllConfigs(SaverImpl* saverPtr){
//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 */
bool MainWindow::saveAllConfigs(bool focusOnTunnel, std::string tunnelNameToFocus){
QString cannotSaveSettings = QApplication::tr("Cannot save settings.");
@ -681,6 +711,7 @@ bool MainWindow::saveAllConfigs(bool focusOnTunnel, std::string tunnelNameToFocu @@ -681,6 +711,7 @@ bool MainWindow::saveAllConfigs(bool focusOnTunnel, std::string tunnelNameToFocu
}
}
delayedSaveManagerPtr->delayedSave(++dataSerial, focusOnTunnel, tunnelNameToFocus);
//onLoggingOptionsChange();
return true;
}
@ -725,6 +756,7 @@ void MainWindow::appendTunnelForms(std::string tunnelNameToFocus) { @@ -725,6 +756,7 @@ void MainWindow::appendTunnelForms(std::string tunnelNameToFocus) {
ServerTunnelConfig* stc = tunconf->asServerTunnelConfig();
if(stc){
ServerTunnelPane * tunnelPane=new ServerTunnelPane(&tunnelsPageUpdateListener, stc, ui->wrongInputLabel, ui->wrongInputLabel, this);
tunconf->setTunnelPane(tunnelPane);
int h=tunnelPane->appendServerTunnelForm(stc, ui->tunnelsScrollAreaWidgetContents, tunnelPanes.size(), height);
height+=h;
//qDebug() << "tun.height:" << height << "sz:" << tunnelPanes.size();
@ -738,6 +770,7 @@ void MainWindow::appendTunnelForms(std::string tunnelNameToFocus) { @@ -738,6 +770,7 @@ void MainWindow::appendTunnelForms(std::string tunnelNameToFocus) {
ClientTunnelConfig* ctc = tunconf->asClientTunnelConfig();
if(ctc){
ClientTunnelPane * tunnelPane=new ClientTunnelPane(&tunnelsPageUpdateListener, ctc, ui->wrongInputLabel, ui->wrongInputLabel, this);
tunconf->setTunnelPane(tunnelPane);
int h=tunnelPane->appendClientTunnelForm(ctc, ui->tunnelsScrollAreaWidgetContents, tunnelPanes.size(), height);
height+=h;
//qDebug() << "tun.height:" << height << "sz:" << tunnelPanes.size();
@ -854,7 +887,8 @@ void MainWindow::anchorClickedHandler(const QUrl & link) { @@ -854,7 +887,8 @@ void MainWindow::anchorClickedHandler(const QUrl & link) {
pageWithBackButton->show();
textBrowser->hide();
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()));
}
}

3
qt/i2pd_qt/mainwindow.h

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

Loading…
Cancel
Save