Browse Source

ui beautifying

pull/952/head
hypnosis-i2p 7 years ago
parent
commit
ec76381a0b
  1. 9
      qt/i2pd_qt/TunnelPane.cpp
  2. 2
      qt/i2pd_qt/TunnelPane.h
  3. 30
      qt/i2pd_qt/mainwindow.cpp
  4. 3
      qt/i2pd_qt/mainwindow.h
  5. 21
      qt/i2pd_qt/mainwindow.ui

9
qt/i2pd_qt/TunnelPane.cpp

@ -231,11 +231,20 @@ void TunnelPane::deleteTunnelForm() {
} }
void TunnelPane::highlightWrongInput(QString warningText, QWidget* controlWithWrongInput) { void TunnelPane::highlightWrongInput(QString warningText, QWidget* controlWithWrongInput) {
bool redVisible = wrongInputPane->isVisible();
wrongInputPane->setVisible(true); wrongInputPane->setVisible(true);
wrongInputLabel->setText(warningText); wrongInputLabel->setText(warningText);
if(!redVisible)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 {
bool redVisible = wrongInputPane->isVisible();
wrongInputPane->setVisible(false);
if(redVisible)mainWindow->adjustSizesAccordingToWrongLabel();
}

2
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;

30
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,7 +632,9 @@ 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.");
bool redVisible = ui->wrongInputLabel->isVisible();
ui->wrongInputLabel->setVisible(false); ui->wrongInputLabel->setVisible(false);
if(redVisible)adjustSizesAccordingToWrongLabel();
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"));
@ -851,9 +856,34 @@ 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());
}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());
}
}
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();
} }

3
qt/i2pd_qt/mainwindow.h

@ -387,7 +387,6 @@ 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:
@ -446,7 +445,9 @@ public:
Ui::StatusButtonsForm* statusButtonsUI; Ui::StatusButtonsForm* statusButtonsUI;
Ui::routerCommandsWidget* routerCommandsUI; Ui::routerCommandsWidget* routerCommandsUI;
Ui::GeneralSettingsContentsForm* uiSettings; Ui::GeneralSettingsContentsForm* uiSettings;
void adjustSizesAccordingToWrongLabel();
private: private:
int settingsTitleLabelNominalHeight;
TextBrowserTweaked1 * textBrowser; TextBrowserTweaked1 * textBrowser;
QWidget * routerCommandsParent; QWidget * routerCommandsParent;
PageWithBackButton * pageWithBackButton; PageWithBackButton * pageWithBackButton;

21
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>1</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>
@ -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