gwenhywfar  5.10.1
qt5/libtest.cpp
Go to the documentation of this file.
1 
2 #undef BUILDING_QT5_GUI
3 
4 #include "qt5_gui.hpp"
5 #include "../testdialogs/dlg_test.h"
6 
7 #include <gwenhywfar/gwenhywfar.h>
8 #include <gwenhywfar/gui.h>
9 #include <gwenhywfar/dialog.h>
10 #include <gwenhywfar/debug.h>
11 
12 #include <QApplication>
13 
14 #include <unistd.h>
15 
16 int test1(int argc, char **argv) {
17  QApplication a(argc, argv);
18  QT5_Gui *gui;
19  int rv;
20  GWEN_DIALOG *dlg;
21 
22  rv=GWEN_Init();
23  if (rv) {
24  DBG_ERROR_ERR(0, rv);
25  return 2;
26  }
27 
29 
30  /* create GUI */
31  gui=new QT5_Gui();
33 
34  dlg=Dlg_Test1_new();
35  if (dlg==NULL) {
36  fprintf(stderr, "Could not create dialog.\n");
37  return 2;
38  }
39 
40  rv=GWEN_Gui_ExecDialog(dlg, 0);
41  fprintf(stderr, "Result: %d\n", rv);
42 
43  return 0;
44 }
45 
46 
47 
48 int test2(int argc, char **argv) {
49  QApplication a(argc, argv);
50  QT5_Gui *gui;
51  QString lf;
52  int rv;
53  uint32_t pid;
54 
55  rv=GWEN_Init();
56  if (rv) {
57  DBG_ERROR_ERR(0, rv);
58  return 2;
59  }
60 
62 
63  /* create GUI */
64  gui=new QT5_Gui();
66 
67 
68 #if 0
70  "Progress-Title",
71  "This is an example progress with 2 steps"
72  "<html>This is an <strong>example</strong> progress with 2 steps</html>",
73  2,
74  0);
75 #else
77  "Progress-Title",
78  "This is an <b>example</b> progress with 2 steps",
79  2,
80  0);
81 #endif
82 
85  "MessageBox-Title",
86  "This message box should appear in the context of the open progress dialog",
87  "Button1",
88  "Button2",
89  "Button3",
90  pid);
93 
94  return 0;
95 }
96 
97 
98 
99 int test3(int argc, char **argv) {
100  int rv;
101  uint32_t id1;
102  uint32_t id2;
103  uint64_t i1;
104  uint64_t i2;
105  QApplication a(argc, argv);
106  QT5_Gui *gui;
107 
108  gui=new QT5_Gui();
110 
114  "Progress-Title",
115  "<html>"
116  "<p><b>This</b> is an example <i>text</i>..</p>"
117  "<p>As you can see <font color=red>colors</font> can "
118  "be used.</p>"
119  "</html>",
120  10,
121  0);
122  for (i1=1; i1<=10; i1++) {
123  char numbuf[128];
124 
125  snprintf(numbuf, sizeof(numbuf)-1, "Step %d\n", (int)i1);
130  "2nd progress",
131  "Starting 2nd progress...",
132  10,
133  id1);
134  for (i2=1; i2<=10; i2++) {
135  sleep(1);
136  fprintf(stderr, "Advancing %d/%d\n", (int)i1, (int)i2);
137  rv=GWEN_Gui_ProgressAdvance(id2, i2);
138  if (rv==GWEN_ERROR_USER_ABORTED) {
139  fprintf(stderr, "Aborted by user (2)\n");
140  break;
141  }
142  }
144 
145  rv=GWEN_Gui_ProgressAdvance(id1, i1);
146  if (rv==GWEN_ERROR_USER_ABORTED) {
147  fprintf(stderr, "Aborted by user (1)\n");
148  break;
149  }
150  }
151 
153 
154  return 0;
155 }
156 
157 
158 
159 int main(int argc, char **argv) {
160  return test1(argc, argv);
161  //return test2(argc, argv);
162  //return test3(argc, argv);
163 }
GWENHYWFAR_API int GWEN_Gui_ProgressLog(uint32_t id, GWEN_LOGGER_LEVEL level, const char *text)
Definition: gui_virtual.c:444
GWENHYWFAR_API int GWEN_Gui_ProgressAdvance(uint32_t id, uint32_t progress)
Definition: gui_virtual.c:420
void GWEN_Logger_SetLevel(const char *logDomain, GWEN_LOGGER_LEVEL l)
Definition: logger.c:627
int test3(int argc, char **argv)
Definition: qt5/libtest.cpp:99
#define NULL
Definition: binreloc.c:300
#define GWEN_GUI_PROGRESS_DELAY
Definition: gui.h:192
int main(int argc, char **argv)
#define DBG_ERROR_ERR(dbg_logger, dbg_err)
Definition: debug.h:113
GWENHYWFAR_API int GWEN_Gui_MessageBox(uint32_t flags, const char *title, const char *text, const char *b1, const char *b2, const char *b3, uint32_t guiid)
Definition: gui_virtual.c:342
GWENHYWFAR_API int GWEN_Gui_ExecDialog(GWEN_DIALOG *dlg, uint32_t guiid)
Definition: gui_virtual.c:559
struct GWEN_DIALOG GWEN_DIALOG
Definition: dialog.h:54
#define GWEN_GUI_MSG_FLAGS_TYPE_INFO
Definition: gui.h:281
int test1(int argc, char **argv)
Definition: qt5/libtest.cpp:16
GWENHYWFAR_API uint32_t GWEN_Gui_ProgressStart(uint32_t progressFlags, const char *title, const char *text, uint64_t total, uint32_t guiid)
Definition: gui_virtual.c:404
GWENHYWFAR_API int GWEN_Gui_ProgressEnd(uint32_t id)
Definition: gui_virtual.c:480
#define GWEN_GUI_PROGRESS_KEEP_OPEN
Definition: gui.h:198
GWEN_GUI * getCInterface()
Definition: cppgui.cpp:373
#define GWEN_GUI_PROGRESS_SHOW_PROGRESS
Definition: gui.h:197
#define GWEN_GUI_PROGRESS_SHOW_LOG
Definition: gui.h:193
int test2(int argc, char **argv)
Definition: qt5/libtest.cpp:48
GWEN_DIALOG * Dlg_Test1_new()
Definition: dlg_test.c:269
#define GWEN_ERROR_USER_ABORTED
Definition: error.h:65
void GWEN_Gui_SetGui(GWEN_GUI *gui)
Definition: gui.c:170
int GWEN_Init(void)
Definition: gwenhywfar.c:92
#define GWEN_GUI_PROGRESS_SHOW_ABORT
Definition: gui.h:194