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

30
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,7 +632,9 @@ void MainWindow::loadAllConfigs(){ @@ -629,7 +632,9 @@ void MainWindow::loadAllConfigs(){
/** returns false iff not valid items present and save was aborted */
bool MainWindow::saveAllConfigs(){
QString cannotSaveSettings = QApplication::tr("Cannot save settings.");
bool redVisible = ui->wrongInputLabel->isVisible();
ui->wrongInputLabel->setVisible(false);
if(redVisible)adjustSizesAccordingToWrongLabel();
programOptionsWriterCurrentSection="";
/*if(!logFileNameOption->lineEdit->text().trimmed().isEmpty())logOption->optionValue=boost::any(std::string("file"));
@ -851,9 +856,34 @@ void MainWindow::backClickedFromChild() { @@ -851,9 +856,34 @@ 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());
}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) {
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();
}

3
qt/i2pd_qt/mainwindow.h

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

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