From ba712c3b5420ed461b8b7a1fdd14849e622ae974 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Sun, 7 Apr 2013 15:20:43 -0700 Subject: Start creating the Qt UI This is based on several commits from Tomaz - mingled together and mildly extended by Dirk (mostly Makefile hacking). All Qt UI related stuff should eventually move into the qt-ui directory. So the Makefile rules for moc and uic have been adjusted accordingly. The MainWindow class has been moved into its own file in qt-ui (but just with a placeholder, the existing class has simply been ifdef'ed out in qt-gui.cpp for the moment). We still have a couple of Qt things in qt-gui.cpp in the main directory... all this needs to move into the qt-ui directory and be built with separate .h files. Right now we have the one-off Makefile rule to create the qt-gui.moc file from the qt-gui.cpp file. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- Makefile | 40 ++- qt-gui.cpp | 7 +- qt-ui/maintab.cpp | 10 + qt-ui/maintab.h | 20 ++ qt-ui/maintab.ui | 810 ++++++++++++++++++++++++++++++++++++++++++++++++ qt-ui/mainwindow.cpp | 11 + qt-ui/mainwindow.h | 24 ++ qt-ui/mainwindow.ui | 297 ++++++++++++++++++ qt-ui/plotareascene.cpp | 0 qt-ui/plotareascene.h | 0 10 files changed, 1204 insertions(+), 15 deletions(-) create mode 100644 qt-ui/maintab.cpp create mode 100644 qt-ui/maintab.h create mode 100644 qt-ui/maintab.ui create mode 100644 qt-ui/mainwindow.cpp create mode 100644 qt-ui/mainwindow.h create mode 100644 qt-ui/mainwindow.ui create mode 100644 qt-ui/plotareascene.cpp create mode 100644 qt-ui/plotareascene.h diff --git a/Makefile b/Makefile index aa42db2cf..c14d0b931 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ VERSION=3.0.2 CC=gcc CFLAGS=-Wall -Wno-pointer-sign -g $(CLCFLAGS) -DGSEAL_ENABLE CXX=g++ -CXXFLAGS=-Wall -g $(CLCFLAGS) -DQT_NO_KEYWORDS +CXXFLAGS=-Wall -g $(CLCFLAGS) -fPIC -DQT_NO_KEYWORDS INSTALL=install PKGCONFIG=pkg-config XML2CONFIG=xml2-config @@ -182,10 +182,13 @@ LIBS = $(LIBQT) $(LIBXML2) $(LIBXSLT) $(LIBSQLITE3) $(LIBGTK) $(LIBGCONF2) $(LIB MSGLANGS=$(notdir $(wildcard po/*.po)) MSGOBJS=$(addprefix share/locale/,$(MSGLANGS:.po=.UTF-8/LC_MESSAGES/subsurface.mo)) + +QTOBJS = qt-ui/maintab.o qt-ui/mainwindow.o qt-ui/plotareascene.o + OBJS = main.o dive.o time.o profile.o info.o equipment.o divelist.o divelist-gtk.o deco.o planner.o \ parse-xml.o save-xml.o libdivecomputer.o print.o uemis.o uemis-downloader.o \ qt-gui.o statistics.o file.o cochran.o device.o download-dialog.o prefs.o \ - webservice.o sha1.o $(GPSOBJ) $(OSSUPPORT).o $(RESFILE) + webservice.o sha1.o $(GPSOBJ) $(OSSUPPORT).o $(RESFILE) $(QTOBJS) DEPS = $(wildcard .dep/*.dep) @@ -298,36 +301,45 @@ MOCFLAGS = $(filter -I%, $(CXXFLAGS) $(EXTRA_FLAGS)) $(filter -D%, $(CXXFLAGS) $ %.o: %.c @echo ' CC' $< - @mkdir -p .dep + @mkdir -p .dep .dep/qt-ui @$(CC) $(CFLAGS) $(EXTRA_FLAGS) -MD -MF .dep/$@.dep -c -o $@ $< %.o: %.cpp @echo ' CXX' $< - @mkdir -p .dep + @mkdir -p .dep .dep/qt-ui @$(CXX) $(CXXFLAGS) $(EXTRA_FLAGS) -MD -MF .dep/$@.dep -c -o $@ $< -# This rule is for running the moc on QObject subclasses defined in the .h -# files. -# To activate this rule, add .moc.o to the OBJS variable. -%.moc.cpp: %.h - @echo ' MOC' $< - @$(MOC) $(MOCFLAGS) $< -o $@ - # This rule is for running the moc on QObject subclasses defined in the .cpp # files; remember to #include ".moc" at the end of the .cpp file, or # you'll get linker errors ("undefined vtable for...") # To activate this rule, you need another rule on the .o file, like: # file.o: file.moc + +qt-ui/%.moc: qt-ui/%.h + @echo ' MOC' $< + @$(MOC) -i $(MOCFLAGS) $< -o $@ + +# this is just here for qt-gui.cpp +# should be removed once all the Qt UI code has been moved into qt-ui + %.moc: %.cpp @echo ' MOC' $< @$(MOC) -i $(MOCFLAGS) $< -o $@ -qt-gui.o: main-window.ui.h qt-gui.moc +# This creates the ui headers. +# To activate this rule, you need to add the ui_*.h file to the .o file: +# file.o: ui_file.h -%.ui.h: ui/%.ui +qt-ui/ui_%.h: qt-ui/%.ui @echo ' UIC' $< @$(UIC) $< -o $@ +qt-gui.o: qt-gui.moc + +qt-ui/maintab.o: qt-ui/maintab.moc qt-ui/ui_maintab.h + +qt-ui/mainwindow.o: qt-ui/mainwindow.moc qt-ui/ui_mainwindow.h + share/locale/%.UTF-8/LC_MESSAGES/subsurface.mo: po/%.po po/%.aliases mkdir -p $(dir $@) msgfmt -c -o $@ po/$*.po @@ -355,7 +367,7 @@ doc: clean: rm -f $(OBJS) *~ $(NAME) $(NAME).exe po/*~ po/subsurface-new.pot \ - $(VERSION_FILE) + $(VERSION_FILE) qt-ui/*.moc qt-ui/ui_*.h rm -rf share .dep -include $(DEPS) diff --git a/qt-gui.cpp b/qt-gui.cpp index 285f2082d..e46f4765f 100644 --- a/qt-gui.cpp +++ b/qt-gui.cpp @@ -24,10 +24,11 @@ #include "webservice.h" #include "version.h" #include "libdivecomputer.h" -#include "main-window.ui.h" +#include "qt-ui/mainwindow.h" #include #include + #include #include #include @@ -1737,6 +1738,9 @@ static gboolean notebook_tooltip (GtkWidget *widget, gint x, gint y, } } +#if NEEDS_TO_MOVE_TO_QT_UI +/* this appears to have moved - but it's very different in qt-ui */ + class MainWindow: public QMainWindow, private Ui::MainWindow { Q_OBJECT @@ -1850,6 +1854,7 @@ QStringList MainWindow::fileNameFilters() const ; return filters; } +#endif /* NEEDS_TO_MOVE_TO_QT_UI */ void init_ui(int *argcp, char ***argvp) { diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp new file mode 100644 index 000000000..4569958c8 --- /dev/null +++ b/qt-ui/maintab.cpp @@ -0,0 +1,10 @@ +#include "maintab.h" +#include "ui_maintab.h" + +MainTab::MainTab(QWidget *parent) : QTabWidget(parent), + ui(new Ui::MainTab()) +{ + ui->setupUi(this); +} + +#include "maintab.moc" diff --git a/qt-ui/maintab.h b/qt-ui/maintab.h new file mode 100644 index 000000000..40904ab12 --- /dev/null +++ b/qt-ui/maintab.h @@ -0,0 +1,20 @@ +#ifndef MAINTAB_H +#define MAINTAB_H + +#include + +namespace Ui +{ + class MainTab; +} + +class MainTab : public QTabWidget +{ + Q_OBJECT +public: + MainTab(QWidget *parent); +private: + Ui::MainTab *ui; +}; + +#endif \ No newline at end of file diff --git a/qt-ui/maintab.ui b/qt-ui/maintab.ui new file mode 100644 index 000000000..a0aec4358 --- /dev/null +++ b/qt-ui/maintab.ui @@ -0,0 +1,810 @@ + + + MainTab + + + + 0 + 0 + 400 + 320 + + + + TabWidget + + + 0 + + + + Dive Info + + + + + + + + + 75 + true + + + + SAC: + + + + + + + + 75 + true + + + + OTU: + + + + + + + + 75 + true + + + + 0²/He: + + + + + + + + 75 + true + + + + Gas Used: + + + + + + + TextLabel + + + + + + + TextLabel + + + + + + + TextLabel + + + + + + + TextLabel + + + + + + + + + 10 + + + + + + 75 + true + + + + Dive Time: + + + + + + + + 75 + true + + + + Surf Interv: + + + + + + + + 75 + true + + + + Avg Depth: + + + + + + + TextLabel + + + + + + + TextLabel + + + + + + + + 75 + true + + + + Air Press: + + + + + + + + 75 + true + + + + Max Depth: + + + + + + + TextLabel + + + + + + + TextLabel + + + + + + + + 75 + true + + + + Air Temp: + + + + + + + TextLabel + + + + + + + + 75 + true + + + + Visibility: + + + + + + + + 75 + true + + + + Water Temp: + + + + + + + TextLabel + + + + + + + TextLabel + + + + + + + TextLabel + + + + + + + TextLabel + + + + + + + + 75 + true + + + + Date: + + + + + + + + + Qt::Vertical + + + + 20 + 112 + + + + + + + + + Dive Notes + + + + + + Location + + + + + + + + + + Divemaster + + + + + + + Buddy + + + + + + + + + + + + + Rating + + + + + + + Suit + + + + + + + + + + + + + Notes + + + + + + + + + + + Equipment + + + + + + Qt::Vertical + + + + Cylinders + + + + + + + + + + + Edit + + + + + + + Add + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Delete + + + + + + + + + + Weight + + + + + + + + + + + Edit + + + + + + + Add + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Delete + + + + + + + + + + + + + + Stats + + + + + + 10 + + + + + + 75 + true + + + + Max Depth + + + + + + + + 75 + true + + + + Min Depth + + + + + + + + 75 + true + + + + Avg Depth + + + + + + + TextLabel + + + + + + + TextLabel + + + + + + + TextLabel + + + + + + + + 75 + true + + + + Max SAC + + + + + + + + 75 + true + + + + Min SAC + + + + + + + + 75 + true + + + + Avg SAC + + + + + + + TextLabel + + + + + + + TextLabel + + + + + + + TextLabel + + + + + + + + + 10 + + + 0 + + + + + + 75 + true + + + + Dives + + + Qt::AlignBottom|Qt::AlignLeading|Qt::AlignLeft + + + + + + + + 75 + true + + + + Max Temp + + + + + + + + 75 + true + + + + Min Temp + + + + + + + + 75 + true + + + + Avg Temp + + + + + + + TextLabel + + + + + + + TextLabel + + + + + + + TextLabel + + + + + + + TextLabel + + + + + + + + 75 + true + + + + Total Time + + + + + + + + 75 + true + + + + Avg Time + + + + + + + + 75 + true + + + + Longest Dive + + + + + + + + 75 + true + + + + Shortest Dive + + + + + + + TextLabel + + + + + + + TextLabel + + + + + + + TextLabel + + + + + + + TextLabel + + + + + + + + + Qt::Vertical + + + + 20 + 85 + + + + + + + + + + diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp new file mode 100644 index 000000000..851d1aa1c --- /dev/null +++ b/qt-ui/mainwindow.cpp @@ -0,0 +1,11 @@ +#include "mainwindow.h" +#include "ui_mainwindow.h" + +#include + +MainWindow::MainWindow() : ui(new Ui::MainWindow()) +{ + ui->setupUi(this); +} + +#include "mainwindow.moc" diff --git a/qt-ui/mainwindow.h b/qt-ui/mainwindow.h new file mode 100644 index 000000000..9e15e58b4 --- /dev/null +++ b/qt-ui/mainwindow.h @@ -0,0 +1,24 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include + +namespace Ui +{ + class MainWindow; +} + +class DiveInfo; +class DiveNotes; +class Stats; +class Equipment; + +class MainWindow : public QMainWindow{ + Q_OBJECT +public: + MainWindow(); +private: + Ui::MainWindow *ui; +}; + +#endif \ No newline at end of file diff --git a/qt-ui/mainwindow.ui b/qt-ui/mainwindow.ui new file mode 100644 index 000000000..b99d10222 --- /dev/null +++ b/qt-ui/mainwindow.ui @@ -0,0 +1,297 @@ + + + MainWindow + + + + 0 + 0 + 763 + 548 + + + + MainWindow + + + + + + + Qt::Vertical + + + + Qt::Horizontal + + + + + + + + + + + Qt::Horizontal + + + + + + + + + 0 + 0 + 763 + 19 + + + + + File + + + + + + + + + + + + + + + + + + + Log + + + + + + + + + + + + + + + View + + + + + + + + + + + Filter + + + + + + Planner + + + + + + Help + + + + + + + + + + + + + + New + + + Ctrl+N + + + + + Open + + + Ctrl+O + + + + + Save + + + Ctrl+S + + + + + Save as + + + Ctrl+Shift+S + + + + + Close + + + Ctrl+W + + + + + Import Files + + + Ctrl+I + + + + + Export UDDF + + + + + Print + + + Ctrl+P + + + + + Preferences + + + + + Quit + + + Ctrl+Q + + + + + Download from Dive computer + + + + + Download from Web Service + + + + + Edit Device Names + + + + + Add Dive + + + + + Renumber + + + + + Auto Group + + + + + Toggle Zoom + + + + + Yearly Statistics + + + + + List + + + + + Profile + + + + + Info + + + + + Tree + + + + + Prev DC + + + + + Next DC + + + + + Select Events + + + + + Input Plan + + + + + About Subsurface + + + + + User Manual + + + + + + MainTab + QWidget +
maintab.h
+ 1 +
+
+ + +
diff --git a/qt-ui/plotareascene.cpp b/qt-ui/plotareascene.cpp new file mode 100644 index 000000000..e69de29bb diff --git a/qt-ui/plotareascene.h b/qt-ui/plotareascene.h new file mode 100644 index 000000000..e69de29bb -- cgit v1.2.3-70-g09d2