From df57b657fdcc1ac4ff9cf7bdb81e0c7a575f7b3b Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Wed, 22 May 2013 09:17:18 -0300 Subject: Rework on the Equipment tab to make it look more Modern. Note that this is a WIP and it does break functionality - ie, not possible to add Equipments, but this will be fixed in the next commit. Removed add / edit / remove buttons, only a single '+' icon appears on the widget now. the edit / delete will be done in place. Signed-off-by: Tomaz Canabrava --- qt-ui/maintab.cpp | 30 +++++++++ qt-ui/maintab.h | 4 ++ qt-ui/maintab.ui | 180 +++++++++++------------------------------------------- 3 files changed, 68 insertions(+), 146 deletions(-) (limited to 'qt-ui') diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index 10645c12f..bbd9ebad8 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -61,8 +61,38 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent), if (label) label->setAlignment(Qt::AlignHCenter); } + + /*Thid couldn't be done on the ui file because element + is floating, instead of being fixed on the layout. */ + QIcon plusIcon(":plus"); + addCylinder = new QPushButton(plusIcon, QString(), ui->cylindersGroup); + addCylinder->setFlat(true); + addCylinder->setToolTip(tr("Add Cylinder")); + addWeight = new QPushButton(plusIcon, QString(), ui->weightGroup); + addWeight->setFlat(true); + addWeight->setToolTip(tr("Add Weight System")); +} + +// We need to manually position the 'plus' on cylinder and weight. +void MainTab::resizeEvent(QResizeEvent* event) +{ + if (ui->cylindersGroup->isVisible()) + addCylinder->setGeometry( ui->cylindersGroup->contentsRect().width() - 30, 2, 24,24); + + if (ui->weightGroup->isVisible()) + addWeight->setGeometry( ui->weightGroup->contentsRect().width() - 30, 2, 24,24); + + QTabWidget::resizeEvent(event); } +void MainTab::showEvent(QShowEvent* event) +{ + QTabWidget::showEvent(event); + addCylinder->setGeometry( ui->cylindersGroup->contentsRect().width() - 30, 2, 24,24); + addWeight->setGeometry( ui->weightGroup->contentsRect().width() - 30, 2, 24,24); +} + + bool MainTab::eventFilter(QObject* object, QEvent* event) { if (event->type() == QEvent::FocusIn) { diff --git a/qt-ui/maintab.h b/qt-ui/maintab.h index c571df086..2bdb63fbc 100644 --- a/qt-ui/maintab.h +++ b/qt-ui/maintab.h @@ -38,6 +38,8 @@ public: void reload(); bool eventFilter(QObject* , QEvent*); + virtual void resizeEvent(QResizeEvent* ); + virtual void showEvent(QShowEvent* ); public Q_SLOTS: void on_addCylinder_clicked(); @@ -63,6 +65,8 @@ private: CylindersModel *cylindersModel; NotesBackup notesBackup; struct dive* currentDive; + QPushButton *addCylinder; + QPushButton *addWeight; }; #endif diff --git a/qt-ui/maintab.ui b/qt-ui/maintab.ui index 0a31897a4..0784980eb 100644 --- a/qt-ui/maintab.ui +++ b/qt-ui/maintab.ui @@ -14,7 +14,7 @@ TabWidget - 0 + 1 @@ -78,22 +78,22 @@ - - - - - Rating - - - - - - - Visibility - - - - + + + + + Rating + + + + + + + Visibility + + + + @@ -110,14 +110,14 @@ - - - - - - - - + + + + + + + + @@ -151,55 +151,17 @@ Qt::Vertical - + Cylinders - + - - - - - - Edit - - - - - - - Add - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Delete - - - - - - + Weight @@ -207,44 +169,6 @@ - - - - - - Edit - - - - - - - Add - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Delete - - - - - @@ -271,24 +195,15 @@ - - 10 - - - 10 - - - 10 - - - 10 - 10 15 + + 10 + @@ -386,16 +301,7 @@ - - 10 - - - 10 - - - 10 - - + 10 @@ -598,16 +504,7 @@ - - 10 - - - 10 - - - 10 - - + 10 @@ -750,16 +647,7 @@ - - 10 - - - 10 - - - 10 - - + 10 -- cgit v1.2.3-70-g09d2