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

3
qt/i2pd_qt/TunnelPane.h

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

57
qt/i2pd_qt/mainwindow.cpp

@ -75,6 +75,7 @@ MainWindow::MainWindow(QWidget *parent) : @@ -75,6 +75,7 @@ MainWindow::MainWindow(QWidget *parent) :
int w = 683;
int h = 3060;
ui->settingsContents->setFixedSize(w, h);
ui->settingsContents->setGeometry(QRect(0,0,w,h));
/*
QPalette pal(palette());
@ -86,8 +87,10 @@ MainWindow::MainWindow(QWidget *parent) : @@ -86,8 +87,10 @@ MainWindow::MainWindow(QWidget *parent) :
pal.setColor(QPalette::Background, Qt::red);
ui->wrongInputLabel->setAutoFillBackground(true);
ui->wrongInputLabel->setPalette(pal);
ui->wrongInputLabel->setMaximumHeight(ui->wrongInputLabel->sizeHint().height());
ui->wrongInputLabel->setVisible(false);
settingsTitleLabelNominalHeight = ui->settingsTitleLabel->height();
#ifndef ANDROID
createActions();
createTrayIcon();
@ -629,8 +632,6 @@ void MainWindow::loadAllConfigs(){ @@ -629,8 +632,6 @@ void MainWindow::loadAllConfigs(){
/** returns false iff not valid items present and save was aborted */
bool MainWindow::saveAllConfigs(){
QString cannotSaveSettings = QApplication::tr("Cannot save settings.");
ui->wrongInputLabel->setVisible(false);
programOptionsWriterCurrentSection="";
/*if(!logFileNameOption->lineEdit->text().trimmed().isEmpty())logOption->optionValue=boost::any(std::string("file"));
else logOption->optionValue=boost::any(std::string("stdout"));*/
@ -679,15 +680,22 @@ void FolderChooserItem::pushButtonReleased() { @@ -679,15 +680,22 @@ void FolderChooserItem::pushButtonReleased() {
}
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) {
QObject::connect(comboBox, SIGNAL(currentIndexChanged(int)), mainWindow, SLOT(saveAllConfigs()));
QObject::connect(comboBox, SIGNAL(currentIndexChanged(int)), mainWindow, SLOT(updated()));
}
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) {}
@ -751,6 +759,14 @@ void MainWindow::deleteTunnelForms() { @@ -751,6 +759,14 @@ void MainWindow::deleteTunnelForms() {
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) {
deleteTunnelForms();
for (std::map<std::string,TunnelConfig*>::iterator it=tunnelConfigs.begin(); it!=tunnelConfigs.end(); ++it) {
@ -851,9 +867,40 @@ void MainWindow::backClickedFromChild() { @@ -851,9 +867,40 @@ void MainWindow::backClickedFromChild() {
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) {
bool redVisible = ui->wrongInputLabel->isVisible();
ui->wrongInputLabel->setVisible(true);
ui->wrongInputLabel->setText(warningText);
if(!redVisible)adjustSizesAccordingToWrongLabel();
if(widgetToFocus){ui->settingsScrollArea->ensureWidgetVisible(widgetToFocus);widgetToFocus->setFocus();}
showSettingsPage();
}

5
qt/i2pd_qt/mainwindow.h

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

23
qt/i2pd_qt/mainwindow.ui

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

Loading…
Cancel
Save