From 2bef4cb3d3230915e5e673f10910ff8f520a0c19 Mon Sep 17 00:00:00 2001 From: deva Date: Tue, 3 May 2005 09:22:12 +0000 Subject: Implemented the gui part of the info object. --- src/Makefile.am | 1 + src/info_gui.cc | 34 +++++++++++++++++++++++++++++++++- src/info_gui.h | 12 +++++++++++- src/mainwindow.cc | 7 +++++-- src/mainwindow.h | 5 ++++- src/miav.cc | 11 ++++++++--- 6 files changed, 62 insertions(+), 8 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index ce9cf72..b934ed1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -2,6 +2,7 @@ ## TODO: Move ffmpeg, libxml and libsdl into configure.in AM_CXXFLAGS := $(CXXFLAGS) $(EXTRA_CXXFLAGS) -I../include $(QT_CXXFLAGS) \ + -DQT_THREAD_SUPPORT \ -DPIXMAPS=\"$(datadir)/pixmaps\" \ -DETC=\"$(prefix)/etc/miav\" \ -I/usr/include/ffmpeg diff --git a/src/info_gui.cc b/src/info_gui.cc index 0718021..376a19f 100644 --- a/src/info_gui.cc +++ b/src/info_gui.cc @@ -39,8 +39,12 @@ #include #include -InfoGui::InfoGui(): Info() +#include "messagebox.h" + +InfoGui::InfoGui(QApplication *a, QWidget *p): Info() { + qapp = a; + parent = p; } InfoGui::~InfoGui() @@ -60,6 +64,18 @@ void InfoGui::error(char *fmt, ...) vsprintf(buf, fmt, argp); va_end(argp); + fprintf(stderr, "lock(); + fprintf(stderr, "!"); fflush(stderr); + MessageBox(parent, + TXT_ERROR_TITLE, + buf, + TYPE_OK, + ICON_ERROR).exec(); + fprintf(stderr, "!"); fflush(stderr); + qapp->unlock(); + fprintf(stderr, "!>"); fflush(stderr); + // End of safezone pthread_mutex_unlock(&mutex); } @@ -77,6 +93,14 @@ void InfoGui::warn(char *fmt, ...) vsprintf(buf, fmt, argp); va_end(argp); + qapp->lock(); + MessageBox(parent, + TXT_WARNING_TITLE, + buf, + TYPE_OK, + ICON_WARNING).exec(); + qapp->unlock(); + // End of safezone pthread_mutex_unlock(&mutex); } @@ -94,6 +118,14 @@ void InfoGui::info(char *fmt, ...) vsprintf(buf, fmt, argp); va_end(argp); + qapp->lock(); + MessageBox(parent, + TXT_INFO_TITLE, + buf, + TYPE_OK, + ICON_INFO).exec(); + qapp->unlock(); + // End of safezone pthread_mutex_unlock(&mutex); } diff --git a/src/info_gui.h b/src/info_gui.h index 28860b6..269f827 100644 --- a/src/info_gui.h +++ b/src/info_gui.h @@ -37,14 +37,22 @@ #ifndef __MIAV_INFO_GUI_H__ #define __MIAV_INFO_GUI_H__ +#define TXT_ERROR_TITLE "Der er opstået en fejl!" +#define TXT_WARNING_TITLE "Advarsel" +#define TXT_INFO_TITLE "Information" + + #include "info.h" +#include +#include + #include #include class InfoGui: public Info { public: - InfoGui(); + InfoGui(QApplication *a, QWidget *p); ~InfoGui(); void error(char* fmt, ...); @@ -52,6 +60,8 @@ public: void info(char* fmt, ...); private: + QApplication *qapp; + QWidget *parent; pthread_mutex_t mutex; }; diff --git a/src/mainwindow.cc b/src/mainwindow.cc index eda7dc9..577058f 100644 --- a/src/mainwindow.cc +++ b/src/mainwindow.cc @@ -31,6 +31,9 @@ /* * $Log$ + * Revision 1.25 2005/05/03 09:22:12 deva + * Implemented the gui part of the info object. + * * Revision 1.24 2005/05/03 08:31:59 deva * Removed the error object, and replaced it with a more generic info object. * @@ -91,10 +94,10 @@ //#define WITH_DV -MainWindow::MainWindow( QWidget* parent, const char* name ) +MainWindow::MainWindow(QApplication *qApp, QWidget* parent, const char* name ) : QWidget( parent, name, WStyle_Customize | WStyle_NoBorder ) { - info = new InfoGui(); + info = new InfoGui(qApp, this); video_width = config->readInt("video_width"); video_height = config->readInt("video_height"); diff --git a/src/mainwindow.h b/src/mainwindow.h index 78bdd75..5f0fe93 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -31,6 +31,9 @@ /* * $Log$ + * Revision 1.12 2005/05/03 09:22:12 deva + * Implemented the gui part of the info object. + * * Revision 1.11 2005/05/03 08:31:59 deva * Removed the error object, and replaced it with a more generic info object. * @@ -101,7 +104,7 @@ class MainWindow : public QWidget { Q_OBJECT public: - MainWindow(QWidget* parent = 0, const char* name = 0); + MainWindow(QApplication *qApp, QWidget* parent = 0, const char* name = 0); ~MainWindow(); void message(char* msg); diff --git a/src/miav.cc b/src/miav.cc index daac99d..1518795 100644 --- a/src/miav.cc +++ b/src/miav.cc @@ -31,6 +31,9 @@ /* * $Log$ + * Revision 1.8 2005/05/03 09:22:12 deva + * Implemented the gui part of the info object. + * * Revision 1.7 2005/05/03 08:31:59 deva * Removed the error object, and replaced it with a more generic info object. * @@ -72,7 +75,11 @@ enum { int grab(int argc, char *argv[]) { #ifdef USE_GUI QApplication miav_grab( argc, argv ); - MainWindow mainwindow; + + InfoGui info(&miav_grab, NULL); + config = new MiavConfig(ETC"/miav.conf", &info); + + MainWindow mainwindow(&miav_grab); miav_grab.setMainWidget( &mainwindow ); return miav_grab.exec(); #else /* USE_GUI */ @@ -138,8 +145,6 @@ int main(int argc, char *argv[]) switch(mode) { case MODE_GRAB: { - InfoGui info; - config = new MiavConfig(ETC"/miav.conf", &info); return grab(argc - 2, &argv[2]); } case MODE_SERVER: -- cgit v1.2.3