Quellcode durchsuchen

Fixed a couple of UI quirks

- Fixed a bug resulting in layout errors in NewPilot and NewTail Dialogues
- Fixed a bug that activated badInputReceived in NewFlightDialog when a new tail was added
Felix vor 3 Jahren
Ursprung
Commit
b80713c61e

+ 0 - 25
mainwindow.cpp

@@ -61,30 +61,6 @@ MainWindow::MainWindow(QWidget *parent)
     // retreive completion lists and maps
     completionData.init();
 
-    /*
-    // Create a spacer for the toolbar to separate left and right parts
-    auto *spacer = new QWidget();
-    spacer->setMinimumWidth(1);
-    spacer->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);
-    // Set up Toolbar
-    ui->actionHome->setIcon(QIcon(Opl::Assets::ICON_TOOLBAR_HOME));
-    ui->actionNewFlight->setIcon(QIcon(Opl::Assets::ICON_TOOLBAR_NEW_FLIGHT));
-    ui->actionLogbook->setIcon(QIcon(Opl::Assets::ICON_TOOLBAR_LOGBOOK));
-    ui->actionAircraft->setIcon(QIcon(Opl::Assets::ICON_TOOLBAR_AIRCRAFT));
-    ui->actionPilots->setIcon(QIcon(Opl::Assets::ICON_TOOLBAR_PILOT));
-    ui->toolBar->insertWidget(ui->actionSettings, spacer); // spacer goes here
-    ui->actionBackup->setIcon(QIcon(Opl::Assets::ICON_TOOLBAR_BACKUP));
-    ui->actionSettings->setIcon(QIcon(Opl::Assets::ICON_TOOLBAR_SETTINGS));
-    ui->actionQuit->setIcon(QIcon(Opl::Assets::ICON_TOOLBAR_QUIT));
-    ui->toolBar->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);
-
-    const auto buttons = ui->toolBar->findChildren<QWidget *>();
-    ui->toolBar->setIconSize(QSize(64, 64));
-    for (const auto &button : buttons) {
-        button->setMinimumWidth(128);
-    }
-    */
-
     // Construct Widgets
     homeWidget = new HomeWidget(this);
     ui->stackedWidget->addWidget(homeWidget);
@@ -129,7 +105,6 @@ MainWindow::MainWindow(QWidget *parent)
     toolBar->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);
     addToolBar(Qt::ToolBarArea::LeftToolBarArea, toolBar);
 
-
     // check database version (Debug)
     if (aDB->dbRevision() < aDB->getMinimumDatabaseRevision()) {
         QString message = tr("Your database is out of date."

+ 6 - 1
mainwindow.h

@@ -133,7 +133,12 @@ protected:
      */
     void resizeEvent(QResizeEvent *event) override
     {
-        int icon_size = (this->height() / 12);
+        int icon_size;
+        if (this->height() < 780)
+            icon_size = (this->height() / 13);
+        else
+            icon_size = (this->height() / 12);
+
         auto tool_bar = this->findChild<QToolBar*>();
         tool_bar->setIconSize(QSize(icon_size, icon_size));
     }

+ 2 - 2
mainwindow.ui

@@ -7,7 +7,7 @@
     <x>0</x>
     <y>0</y>
     <width>1280</width>
-    <height>800</height>
+    <height>720</height>
    </rect>
   </property>
   <property name="sizePolicy">
@@ -19,7 +19,7 @@
   <property name="minimumSize">
    <size>
     <width>1280</width>
-    <height>800</height>
+    <height>720</height>
    </size>
   </property>
   <property name="maximumSize">

+ 15 - 19
src/gui/dialogues/newflightdialog.cpp

@@ -282,7 +282,7 @@ void NewFlightDialog::updateBlockTimeLabel()
  * \brief NewFlightDialog::addNewTail If the user input is not in the aircraftList, the user
  * is prompted if he wants to add a new entry to the database
  */
-void NewFlightDialog::addNewTail(QLineEdit& parent_line_edit)
+bool NewFlightDialog::addNewTail(QLineEdit& parent_line_edit)
 {
     QMessageBox::StandardButton reply;
     reply = QMessageBox::question(this, tr("No Aircraft found"),
@@ -307,14 +307,12 @@ void NewFlightDialog::addNewTail(QLineEdit& parent_line_edit)
 
             // update Line Edit
             parent_line_edit.setText(completionData.tailsIdMap.value(aDB->getLastEntry(ADatabaseTable::tails)));
-            emit parent_line_edit.editingFinished();
+            return true;
         } else {
-            parent_line_edit.setText(QString());
-            parent_line_edit.setFocus();
+            return false;
         }
     } else {
-        parent_line_edit.setText(QString());
-        parent_line_edit.setFocus();
+        return false;
     }
 }
 
@@ -322,7 +320,7 @@ void NewFlightDialog::addNewTail(QLineEdit& parent_line_edit)
  * \brief NewFlightDialog::addNewPilot If the user input is not in the pilotNameList, the user
  * is prompted if he wants to add a new entry to the database
  */
-void NewFlightDialog::addNewPilot(QLineEdit& parent_line_edit)
+bool NewFlightDialog::addNewPilot(QLineEdit& parent_line_edit)
 {
     QMessageBox::StandardButton reply;
     reply = QMessageBox::question(this, tr("No Pilot found"),
@@ -347,14 +345,12 @@ void NewFlightDialog::addNewPilot(QLineEdit& parent_line_edit)
 
             // update Line Edit
             parent_line_edit.setText(completionData.pilotsIdMap.value(aDB->getLastEntry(ADatabaseTable::pilots)));
-            emit parent_line_edit.editingFinished();
+            return true;
         } else {
-            parent_line_edit.setText(QString());
-            parent_line_edit.setFocus();
+            return false;
         }
-    } else {
-        parent_line_edit.setText(QString());
-    }
+    } else
+        return false;
 }
 
 /*!
@@ -523,6 +519,8 @@ void NewFlightDialog::onPilotNameLineEdit_editingFinshed()
         line_edit->setText(completionData.pilotsIdMap.value(1));
         if (line_edit->objectName() == QLatin1String("picNameLineEdit"))
             ui->functionComboBox->setCurrentIndex(0);
+        else if (line_edit->objectName() == QLatin1String("sicNameLineEdit"))
+            ui->functionComboBox->setCurrentIndex(2);
 
         onGoodInputReceived(line_edit);
         return;
@@ -550,8 +548,8 @@ void NewFlightDialog::onPilotNameLineEdit_editingFinshed()
         return;
     }
 
-    onBadInputReceived(line_edit);
-    addNewPilot(*line_edit);
+    if(!addNewPilot(*line_edit))
+        onBadInputReceived(line_edit);
 }
 
 void NewFlightDialog::onLocationLineEdit_editingFinished()
@@ -606,10 +604,8 @@ void NewFlightDialog::on_acftLineEdit_editingFinished()
     }
 
     if (!(line_edit->text() == QString()))
-        addNewTail(*line_edit);
-    // Mark as bad input and prompt for adding new tail
-    onBadInputReceived(line_edit);
-
+        if(!addNewTail(*line_edit))
+            onBadInputReceived(line_edit);
 }
 
 void NewFlightDialog::on_doftLineEdit_editingFinished()

+ 2 - 2
src/gui/dialogues/newflightdialog.h

@@ -141,8 +141,8 @@ private:
     void setNightCheckboxes();
     void updateBlockTimeLabel();
 
-    void addNewTail(QLineEdit& parent_line_edit);
-    void addNewPilot(QLineEdit& parent_line_edit);
+    bool addNewTail(QLineEdit& parent_line_edit);
+    bool addNewPilot(QLineEdit& parent_line_edit);
 
     RowData_T prepareFlightEntryData();
 

+ 44 - 2
src/gui/dialogues/newpilot.ui

@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>640</width>
-    <height>480</height>
+    <width>230</width>
+    <height>252</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -23,6 +23,12 @@
    </item>
    <item row="0" column="1">
     <widget class="QLineEdit" name="lastnameLineEdit">
+     <property name="minimumSize">
+      <size>
+       <width>140</width>
+       <height>0</height>
+      </size>
+     </property>
      <property name="maxLength">
       <number>40</number>
      </property>
@@ -37,6 +43,12 @@
    </item>
    <item row="1" column="1">
     <widget class="QLineEdit" name="firstnameLineEdit">
+     <property name="minimumSize">
+      <size>
+       <width>140</width>
+       <height>0</height>
+      </size>
+     </property>
      <property name="maxLength">
       <number>40</number>
      </property>
@@ -51,6 +63,12 @@
    </item>
    <item row="2" column="1">
     <widget class="QLineEdit" name="companyLineEdit">
+     <property name="minimumSize">
+      <size>
+       <width>140</width>
+       <height>0</height>
+      </size>
+     </property>
      <property name="maxLength">
       <number>69</number>
      </property>
@@ -65,6 +83,12 @@
    </item>
    <item row="3" column="1">
     <widget class="QLineEdit" name="aliasLineEdit">
+     <property name="minimumSize">
+      <size>
+       <width>140</width>
+       <height>0</height>
+      </size>
+     </property>
      <property name="maxLength">
       <number>40</number>
      </property>
@@ -79,6 +103,12 @@
    </item>
    <item row="4" column="1">
     <widget class="QLineEdit" name="employeeidLineEdit">
+     <property name="minimumSize">
+      <size>
+       <width>140</width>
+       <height>0</height>
+      </size>
+     </property>
      <property name="text">
       <string/>
      </property>
@@ -96,6 +126,12 @@
    </item>
    <item row="5" column="1">
     <widget class="QLineEdit" name="phoneLineEdit">
+     <property name="minimumSize">
+      <size>
+       <width>140</width>
+       <height>0</height>
+      </size>
+     </property>
      <property name="maxLength">
       <number>40</number>
      </property>
@@ -110,6 +146,12 @@
    </item>
    <item row="6" column="1">
     <widget class="QLineEdit" name="emailLineEdit">
+     <property name="minimumSize">
+      <size>
+       <width>140</width>
+       <height>0</height>
+      </size>
+     </property>
      <property name="maxLength">
       <number>40</number>
      </property>

+ 2 - 3
src/gui/dialogues/newtail.ui

@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>470</width>
-    <height>768</height>
+    <width>350</width>
+    <height>351</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -220,7 +220,6 @@
      </property>
      <property name="font">
       <font>
-       <weight>75</weight>
        <bold>true</bold>
       </font>
      </property>

+ 64 - 57
src/gui/widgets/aircraftwidget.ui

@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>1318</width>
-    <height>706</height>
+    <width>1024</width>
+    <height>768</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -25,34 +25,37 @@
     </widget>
    </item>
    <item row="0" column="1" rowspan="3">
+    <widget class="Line" name="line">
+     <property name="orientation">
+      <enum>Qt::Vertical</enum>
+     </property>
+    </widget>
+   </item>
+   <item row="0" column="2">
     <widget class="QStackedWidget" name="stackedWidget">
      <widget class="QWidget" name="welcomePageTails">
       <layout class="QGridLayout" name="gridLayout">
-       <item row="1" column="1">
-        <widget class="QLabel" name="searchLabel">
+       <item row="3" column="0">
+        <spacer name="horizontalSpacer">
          <property name="minimumSize">
           <size>
            <width>0</width>
            <height>0</height>
           </size>
          </property>
-         <property name="text">
-          <string>Search:</string>
+         <property name="orientation">
+          <enum>Qt::Horizontal</enum>
          </property>
-        </widget>
-       </item>
-       <item row="1" column="2">
-        <widget class="QLineEdit" name="aircraftSearchLineEdit">
-         <property name="minimumSize">
+         <property name="sizeHint" stdset="0">
           <size>
-           <width>0</width>
-           <height>0</height>
+           <width>130</width>
+           <height>20</height>
           </size>
          </property>
-        </widget>
+        </spacer>
        </item>
-       <item row="2" column="1">
-        <widget class="QLabel" name="label_2">
+       <item row="3" column="1" colspan="3">
+        <widget class="QLabel" name="welcomeLabel">
          <property name="minimumSize">
           <size>
            <width>0</width>
@@ -60,37 +63,25 @@
           </size>
          </property>
          <property name="text">
-          <string>Search in:</string>
+          <string>Select an Aircraft from the List to show or edit details.</string>
          </property>
         </widget>
        </item>
-       <item row="2" column="2">
-        <widget class="QComboBox" name="aircraftSearchComboBox">
+       <item row="2" column="1">
+        <widget class="QLabel" name="label_2">
          <property name="minimumSize">
           <size>
            <width>0</width>
            <height>0</height>
           </size>
          </property>
-         <item>
-          <property name="text">
-           <string>Registration</string>
-          </property>
-         </item>
-         <item>
-          <property name="text">
-           <string>Type</string>
-          </property>
-         </item>
-         <item>
-          <property name="text">
-           <string>Company</string>
-          </property>
-         </item>
+         <property name="text">
+          <string>Search in:</string>
+         </property>
         </widget>
        </item>
-       <item row="3" column="0">
-        <spacer name="horizontalSpacer">
+       <item row="4" column="4">
+        <spacer name="verticalSpacer_2">
          <property name="minimumSize">
           <size>
            <width>0</width>
@@ -98,18 +89,28 @@
           </size>
          </property>
          <property name="orientation">
-          <enum>Qt::Horizontal</enum>
+          <enum>Qt::Vertical</enum>
          </property>
          <property name="sizeHint" stdset="0">
           <size>
-           <width>130</width>
-           <height>20</height>
+           <width>20</width>
+           <height>286</height>
           </size>
          </property>
         </spacer>
        </item>
-       <item row="3" column="1" colspan="2">
-        <widget class="QLabel" name="welcomeLabel">
+       <item row="1" column="2" colspan="2">
+        <widget class="QLineEdit" name="aircraftSearchLineEdit">
+         <property name="minimumSize">
+          <size>
+           <width>220</width>
+           <height>0</height>
+          </size>
+         </property>
+        </widget>
+       </item>
+       <item row="1" column="1">
+        <widget class="QLabel" name="searchLabel">
          <property name="minimumSize">
           <size>
            <width>0</width>
@@ -117,11 +118,11 @@
           </size>
          </property>
          <property name="text">
-          <string>Select an Aircraft from the List to show or edit details.</string>
+          <string>Search:</string>
          </property>
         </widget>
        </item>
-       <item row="3" column="3">
+       <item row="3" column="4">
         <spacer name="horizontalSpacer_2">
          <property name="minimumSize">
           <size>
@@ -140,26 +141,32 @@
          </property>
         </spacer>
        </item>
-       <item row="4" column="3">
-        <spacer name="verticalSpacer_2">
+       <item row="2" column="2" colspan="2">
+        <widget class="QComboBox" name="aircraftSearchComboBox">
          <property name="minimumSize">
           <size>
-           <width>0</width>
+           <width>220</width>
            <height>0</height>
           </size>
          </property>
-         <property name="orientation">
-          <enum>Qt::Vertical</enum>
-         </property>
-         <property name="sizeHint" stdset="0">
-          <size>
-           <width>20</width>
-           <height>286</height>
-          </size>
-         </property>
-        </spacer>
+         <item>
+          <property name="text">
+           <string>Registration</string>
+          </property>
+         </item>
+         <item>
+          <property name="text">
+           <string>Type</string>
+          </property>
+         </item>
+         <item>
+          <property name="text">
+           <string>Company</string>
+          </property>
+         </item>
+        </widget>
        </item>
-       <item row="0" column="3">
+       <item row="0" column="4">
         <spacer name="verticalSpacer">
          <property name="minimumSize">
           <size>

+ 12 - 5
src/gui/widgets/pilotswidget.ui

@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>1280</width>
-    <height>720</height>
+    <width>1024</width>
+    <height>768</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -30,7 +30,7 @@
      </property>
     </widget>
    </item>
-   <item row="0" column="1" rowspan="3">
+   <item row="0" column="2" rowspan="3">
     <widget class="QStackedWidget" name="stackedWidget">
      <property name="currentIndex">
       <number>0</number>
@@ -73,7 +73,7 @@
         <widget class="QLineEdit" name="pilotSearchLineEdit">
          <property name="minimumSize">
           <size>
-           <width>0</width>
+           <width>220</width>
            <height>0</height>
           </size>
          </property>
@@ -109,7 +109,7 @@
         <widget class="QComboBox" name="pilotsSearchComboBox">
          <property name="minimumSize">
           <size>
-           <width>0</width>
+           <width>220</width>
            <height>0</height>
           </size>
          </property>
@@ -218,6 +218,13 @@
      </property>
     </widget>
    </item>
+   <item row="0" column="1" rowspan="3">
+    <widget class="Line" name="line">
+     <property name="orientation">
+      <enum>Qt::Vertical</enum>
+     </property>
+    </widget>
+   </item>
   </layout>
  </widget>
  <resources/>