Browse Source

Merge pull request #952 from hypnosis-i2p/openssl

ui beautifying + fixed tunnels invalid ui data handling
pull/958/head
orignal 7 years ago committed by GitHub
parent
commit
dca94f17d7
  1. 10
      qt/i2pd_qt/TunnelPane.cpp
  2. 3
      qt/i2pd_qt/TunnelPane.h
  3. 57
      qt/i2pd_qt/mainwindow.cpp
  4. 5
      qt/i2pd_qt/mainwindow.h
  5. 23
      qt/i2pd_qt/mainwindow.ui

10
qt/i2pd_qt/TunnelPane.cpp

@ -186,7 +186,8 @@ void TunnelPane::appendControlsForI2CPParameters(I2CPParameters& i2cpParameters,
void TunnelPane::updated() { void TunnelPane::updated() {
std::string oldName=tunnelConfig->getName(); std::string oldName=tunnelConfig->getName();
//validate and show red if invalid //validate and show red if invalid
if(!applyDataFromUIToTunnelConfig())return; hideWrongInputLabel();
if(!mainWindow->applyTunnelsUiToConfigs())return;
tunnelsPageUpdateListener->updated(oldName, tunnelConfig); tunnelsPageUpdateListener->updated(oldName, tunnelConfig);
} }
@ -199,6 +200,7 @@ void TunnelPane::deleteButtonReleased() {
switch (ret) { switch (ret) {
case QMessageBox::Ok: case QMessageBox::Ok:
// OK was clicked // OK was clicked
hideWrongInputLabel();
tunnelsPageUpdateListener->needsDeleting(tunnelConfig->getName()); tunnelsPageUpdateListener->needsDeleting(tunnelConfig->getName());
break; break;
case QMessageBox::Cancel: case QMessageBox::Cancel:
@ -233,9 +235,15 @@ void TunnelPane::deleteTunnelForm() {
void TunnelPane::highlightWrongInput(QString warningText, QWidget* controlWithWrongInput) { void TunnelPane::highlightWrongInput(QString warningText, QWidget* controlWithWrongInput) {
wrongInputPane->setVisible(true); wrongInputPane->setVisible(true);
wrongInputLabel->setText(warningText); wrongInputLabel->setText(warningText);
mainWindow->adjustSizesAccordingToWrongLabel();
if(controlWithWrongInput){ if(controlWithWrongInput){
mainWindow->ui->tunnelsScrollArea->ensureWidgetVisible(controlWithWrongInput); mainWindow->ui->tunnelsScrollArea->ensureWidgetVisible(controlWithWrongInput);
controlWithWrongInput->setFocus(); controlWithWrongInput->setFocus();
} }
mainWindow->showTunnelsPage(); mainWindow->showTunnelsPage();
} }
void TunnelPane::hideWrongInputLabel() const {
wrongInputPane->setVisible(false);
mainWindow->adjustSizesAccordingToWrongLabel();
}

3
qt/i2pd_qt/TunnelPane.h

@ -35,7 +35,7 @@ public:
void deleteTunnelForm(); void deleteTunnelForm();
void hideWrongInputLabel() const { wrongInputPane->setVisible(false); } void hideWrongInputLabel() const;
void highlightWrongInput(QString warningText, QWidget* controlWithWrongInput); void highlightWrongInput(QString warningText, QWidget* controlWithWrongInput);
virtual ServerTunnelPane* asServerTunnelPane()=0; virtual ServerTunnelPane* asServerTunnelPane()=0;
@ -95,7 +95,6 @@ protected:
public: public:
//returns false when invalid data at UI //returns false when invalid data at UI
virtual bool applyDataFromUIToTunnelConfig() { virtual bool applyDataFromUIToTunnelConfig() {
hideWrongInputLabel();
tunnelConfig->setName(nameLineEdit->text().toStdString()); tunnelConfig->setName(nameLineEdit->text().toStdString());
tunnelConfig->setType(readTunnelTypeComboboxData()); tunnelConfig->setType(readTunnelTypeComboboxData());
I2CPParameters& i2cpParams=tunnelConfig->getI2cpParameters(); I2CPParameters& i2cpParams=tunnelConfig->getI2cpParameters();

57
qt/i2pd_qt/mainwindow.cpp

@ -75,6 +75,7 @@ MainWindow::MainWindow(QWidget *parent) :
int w = 683; int w = 683;
int h = 3060; int h = 3060;
ui->settingsContents->setFixedSize(w, h); ui->settingsContents->setFixedSize(w, h);
ui->settingsContents->setGeometry(QRect(0,0,w,h));
/* /*
QPalette pal(palette()); QPalette pal(palette());
@ -86,8 +87,10 @@ MainWindow::MainWindow(QWidget *parent) :
pal.setColor(QPalette::Background, Qt::red); pal.setColor(QPalette::Background, Qt::red);
ui->wrongInputLabel->setAutoFillBackground(true); ui->wrongInputLabel->setAutoFillBackground(true);
ui->wrongInputLabel->setPalette(pal); ui->wrongInputLabel->setPalette(pal);
ui->wrongInputLabel->setMaximumHeight(ui->wrongInputLabel->sizeHint().height());
ui->wrongInputLabel->setVisible(false); ui->wrongInputLabel->setVisible(false);
settingsTitleLabelNominalHeight = ui->settingsTitleLabel->height();
#ifndef ANDROID #ifndef ANDROID
createActions(); createActions();
createTrayIcon(); createTrayIcon();
@ -629,8 +632,6 @@ void MainWindow::loadAllConfigs(){
/** 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 MainWindow::saveAllConfigs(){
QString cannotSaveSettings = QApplication::tr("Cannot save settings."); QString cannotSaveSettings = QApplication::tr("Cannot save settings.");
ui->wrongInputLabel->setVisible(false);
programOptionsWriterCurrentSection=""; programOptionsWriterCurrentSection="";
/*if(!logFileNameOption->lineEdit->text().trimmed().isEmpty())logOption->optionValue=boost::any(std::string("file")); /*if(!logFileNameOption->lineEdit->text().trimmed().isEmpty())logOption->optionValue=boost::any(std::string("file"));
else logOption->optionValue=boost::any(std::string("stdout"));*/ else logOption->optionValue=boost::any(std::string("stdout"));*/
@ -679,15 +680,22 @@ void FolderChooserItem::pushButtonReleased() {
} }
void BaseStringItem::installListeners(MainWindow *mainWindow) { void BaseStringItem::installListeners(MainWindow *mainWindow) {
QObject::connect(lineEdit, SIGNAL(textChanged(const QString &)), mainWindow, SLOT(saveAllConfigs())); QObject::connect(lineEdit, SIGNAL(textChanged(const QString &)), mainWindow, SLOT(updated()));
} }
void ComboBoxItem::installListeners(MainWindow *mainWindow) { void ComboBoxItem::installListeners(MainWindow *mainWindow) {
QObject::connect(comboBox, SIGNAL(currentIndexChanged(int)), mainWindow, SLOT(saveAllConfigs())); QObject::connect(comboBox, SIGNAL(currentIndexChanged(int)), mainWindow, SLOT(updated()));
} }
void CheckBoxItem::installListeners(MainWindow *mainWindow) { void CheckBoxItem::installListeners(MainWindow *mainWindow) {
QObject::connect(checkBox, SIGNAL(stateChanged(int)), mainWindow, SLOT(saveAllConfigs())); QObject::connect(checkBox, SIGNAL(stateChanged(int)), mainWindow, SLOT(updated()));
} }
void MainWindow::updated() {
ui->wrongInputLabel->setVisible(false);
adjustSizesAccordingToWrongLabel();
applyTunnelsUiToConfigs();
saveAllConfigs();
}
void MainWindowItem::installListeners(MainWindow *mainWindow) {} void MainWindowItem::installListeners(MainWindow *mainWindow) {}
@ -751,6 +759,14 @@ void MainWindow::deleteTunnelForms() {
tunnelPanes.clear(); tunnelPanes.clear();
} }
bool MainWindow::applyTunnelsUiToConfigs() {
for(std::list<TunnelPane*>::iterator it = tunnelPanes.begin(); it != tunnelPanes.end(); ++it) {
TunnelPane* tp = *it;
if(!tp->applyDataFromUIToTunnelConfig())return false;
}
return true;
}
void MainWindow::reloadTunnelsConfigAndUI(std::string tunnelNameToFocus) { void MainWindow::reloadTunnelsConfigAndUI(std::string tunnelNameToFocus) {
deleteTunnelForms(); deleteTunnelForms();
for (std::map<std::string,TunnelConfig*>::iterator it=tunnelConfigs.begin(); it!=tunnelConfigs.end(); ++it) { for (std::map<std::string,TunnelConfig*>::iterator it=tunnelConfigs.begin(); it!=tunnelConfigs.end(); ++it) {
@ -851,9 +867,40 @@ void MainWindow::backClickedFromChild() {
showStatusPage(statusPage); showStatusPage(statusPage);
} }
void MainWindow::adjustSizesAccordingToWrongLabel() {
if(ui->wrongInputLabel->isVisible()) {
int dh = ui->wrongInputLabel->height()+ui->verticalLayout_7->layout()->spacing();
ui->verticalLayout_7->invalidate();
ui->wrongInputLabel->adjustSize();
ui->stackedWidget->adjustSize();
ui->stackedWidget->setFixedHeight(531-dh);
ui->settingsPage->setFixedHeight(531-dh);
ui->verticalLayoutWidget_4->setGeometry(QRect(0, 0, 711, 531-dh));
ui->stackedWidget->setFixedHeight(531-dh);
ui->settingsScrollArea->setFixedHeight(531-dh-settingsTitleLabelNominalHeight-ui->verticalLayout_4->spacing());
ui->settingsTitleLabel->setFixedHeight(settingsTitleLabelNominalHeight);
ui->tunnelsScrollArea->setFixedHeight(531-dh-settingsTitleLabelNominalHeight-ui->horizontalLayout_42->geometry().height()-2*ui->verticalLayout_4->spacing());
ui->tunnelsTitleLabel->setFixedHeight(settingsTitleLabelNominalHeight);
}else{
ui->verticalLayout_7->invalidate();
ui->wrongInputLabel->adjustSize();
ui->stackedWidget->adjustSize();
ui->stackedWidget->setFixedHeight(531);
ui->settingsPage->setFixedHeight(531);
ui->verticalLayoutWidget_4->setGeometry(QRect(0, 0, 711, 531));
ui->stackedWidget->setFixedHeight(531);
ui->settingsScrollArea->setFixedHeight(531-settingsTitleLabelNominalHeight-ui->verticalLayout_4->spacing());
ui->settingsTitleLabel->setFixedHeight(settingsTitleLabelNominalHeight);
ui->tunnelsScrollArea->setFixedHeight(531-settingsTitleLabelNominalHeight-ui->horizontalLayout_42->geometry().height()-2*ui->verticalLayout_4->spacing());
ui->tunnelsTitleLabel->setFixedHeight(settingsTitleLabelNominalHeight);
}
}
void MainWindow::highlightWrongInput(QString warningText, QWidget* widgetToFocus) { void MainWindow::highlightWrongInput(QString warningText, QWidget* widgetToFocus) {
bool redVisible = ui->wrongInputLabel->isVisible();
ui->wrongInputLabel->setVisible(true); ui->wrongInputLabel->setVisible(true);
ui->wrongInputLabel->setText(warningText); ui->wrongInputLabel->setText(warningText);
if(!redVisible)adjustSizesAccordingToWrongLabel();
if(widgetToFocus){ui->settingsScrollArea->ensureWidgetVisible(widgetToFocus);widgetToFocus->setFocus();} if(widgetToFocus){ui->settingsScrollArea->ensureWidgetVisible(widgetToFocus);widgetToFocus->setFocus();}
showSettingsPage(); showSettingsPage();
} }

5
qt/i2pd_qt/mainwindow.h

@ -387,10 +387,10 @@ public:
//#endif //#endif
private: private:
enum StatusPage {main_page, commands, local_destinations, leasesets, tunnels, transit_tunnels, enum StatusPage {main_page, commands, local_destinations, leasesets, tunnels, transit_tunnels,
transports, i2p_tunnels, sam_sessions}; transports, i2p_tunnels, sam_sessions};
private slots: private slots:
void updated();
void handleQuitButton(); void handleQuitButton();
void handleGracefulQuitButton(); void handleGracefulQuitButton();
@ -446,7 +446,10 @@ public:
Ui::StatusButtonsForm* statusButtonsUI; Ui::StatusButtonsForm* statusButtonsUI;
Ui::routerCommandsWidget* routerCommandsUI; Ui::routerCommandsWidget* routerCommandsUI;
Ui::GeneralSettingsContentsForm* uiSettings; Ui::GeneralSettingsContentsForm* uiSettings;
void adjustSizesAccordingToWrongLabel();
bool applyTunnelsUiToConfigs();
private: private:
int settingsTitleLabelNominalHeight;
TextBrowserTweaked1 * textBrowser; TextBrowserTweaked1 * textBrowser;
QWidget * routerCommandsParent; QWidget * routerCommandsParent;
PageWithBackButton * pageWithBackButton; PageWithBackButton * pageWithBackButton;

23
qt/i2pd_qt/mainwindow.ui

@ -169,6 +169,9 @@
</item> </item>
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout_7"> <layout class="QVBoxLayout" name="verticalLayout_7">
<property name="sizeConstraint">
<enum>QLayout::SetMinAndMaxSize</enum>
</property>
<item> <item>
<widget class="QLabel" name="wrongInputLabel"> <widget class="QLabel" name="wrongInputLabel">
<property name="minimumSize"> <property name="minimumSize">
@ -606,7 +609,7 @@
<item> <item>
<widget class="QStackedWidget" name="stackedWidget"> <widget class="QStackedWidget" name="stackedWidget">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
@ -624,11 +627,11 @@
</size> </size>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>2</number>
</property> </property>
<widget class="QWidget" name="statusPage"> <widget class="QWidget" name="statusPage">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
@ -670,7 +673,7 @@
</widget> </widget>
<widget class="QWidget" name="settingsPage"> <widget class="QWidget" name="settingsPage">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
@ -686,7 +689,7 @@
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_4"> <layout class="QVBoxLayout" name="verticalLayout_4">
<property name="sizeConstraint"> <property name="sizeConstraint">
<enum>QLayout::SetMaximumSize</enum> <enum>QLayout::SetMinAndMaxSize</enum>
</property> </property>
<item> <item>
<widget class="QLabel" name="settingsTitleLabel"> <widget class="QLabel" name="settingsTitleLabel">
@ -702,6 +705,12 @@
</item> </item>
<item> <item>
<widget class="QScrollArea" name="settingsScrollArea"> <widget class="QScrollArea" name="settingsScrollArea">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="verticalScrollBarPolicy"> <property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOn</enum> <enum>Qt::ScrollBarAlwaysOn</enum>
</property> </property>
@ -750,7 +759,7 @@
<enum>QLayout::SetMinAndMaxSize</enum> <enum>QLayout::SetMinAndMaxSize</enum>
</property> </property>
<item> <item>
<widget class="QLabel" name="label_5"> <widget class="QLabel" name="tunnelsTitleLabel">
<property name="font"> <property name="font">
<font> <font>
<pointsize>15</pointsize> <pointsize>15</pointsize>
@ -869,7 +878,7 @@
</widget> </widget>
<widget class="QWidget" name="quitPage"> <widget class="QWidget" name="quitPage">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>

Loading…
Cancel
Save