int main(int argc, char *argv[]) { QApplication app(argc, argv); tool_data_t *tool = process_arguments(argc, argv); QString tool_name = ""; QStringList tool_args; if (tool != NULL) { tool_name = tool->name; tool_args = tool->arguments; delete tool; } drgui_main_window_t main_win(tool_name, tool_args); main_win.show(); return app.exec(); }
/* Start CPU-X in NCurses mode */ void start_tui_ncurses(Labels *data) { int startx, starty, ch = 0; const SizeInfo info = { .height = LINE_COUNT, .width = 70, .start = 1, .tb = 2, .tm = 26, .te = 48 }; NThrd refr = { .data = data, .info = info }; WINDOW *win; MSG_VERBOSE(_("Starting NCurses TUI...")); setenv("TERMINFO", "/lib/terminfo", 0); freopen("/dev/null", "a", stderr); initscr(); cbreak(); noecho(); curs_set(0); halfdelay(0); nodelay(stdscr, TRUE); keypad(stdscr, TRUE); if(opts->color) { start_color(); opts->color &= has_colors(); } if(PORTABLE_BINARY && new_version != NULL) { print_new_version(); erase(); } starty = (LINES - info.height) / 2; /* Calculating for a center placement of the window */ startx = (COLS - info.width) / 2; win = newwin(info.height, info.width, starty, startx); refr.win = win; refresh(); main_win(win, info, data); ntab_cpu(win, info, data); timeout(opts->refr_time * 1000); printw(_("Press 'h' to see help.\n")); while(ch != 'q') { ch = getch(); switch(ch) { case KEY_LEFT: /* Switch to left tab */ if(page > NO_CPU) { page--; main_win(win, info, data); (*func_ptr[page])(win, info, data); } break; case KEY_RIGHT: /* Switch to right tab */ if(page < NO_ABOUT) { page++; main_win(win, info, data); (*func_ptr[page])(win, info, data); } break; case KEY_DOWN: if(page == NO_CPU && opts->selected_core > 0) { opts->selected_core--; print_activecore(win); } else if(page == NO_CACHES && opts->bw_test > 0) { opts->bw_test--; print_activetest(win, data); } else if(page == NO_BENCH && data->b_data->duration > 1) { data->b_data->duration--; print_paramduration(win, info, data); } break; case KEY_NPAGE: if(page == NO_BENCH && data->b_data->threads > 1 && !data->b_data->run) { data->b_data->threads--; print_paramthreads(win, info, data); } break; case KEY_UP: if(page == NO_CPU && (int) opts->selected_core < data->cpu_count - 1) { opts->selected_core++; print_activecore(win); } else if(page == NO_CACHES && (int) opts->bw_test < data->w_data->test_count - 1) { opts->bw_test++; print_activetest(win, data); } else if(page == NO_BENCH && data->b_data->duration < 60 * 24) { data->b_data->duration++; print_paramduration(win, info, data); } break; case KEY_PPAGE: if(page == NO_BENCH && data->b_data->threads < data->cpu_count && !data->b_data->run) { data->b_data->threads++; print_paramthreads(win, info, data); } break; case 'f': if(page == NO_BENCH && !data->b_data->run) { data->b_data->fast_mode = true; start_benchmarks(data); } else if(page == NO_BENCH && data->b_data->run) data->b_data->run = false; break; case 's': if(page == NO_BENCH && !data->b_data->run) { data->b_data->fast_mode = false; start_benchmarks(data); } else if(page == NO_BENCH && data->b_data->run) data->b_data->run = false; break; case 'h': erase(); print_help(); erase(); refresh(); main_win(win, info, data); (*func_ptr[page])(win, info, data); break; case ERR: /* Refresh dynamic labels */ if(page == NO_CPU || page == NO_CACHES || page == NO_SYSTEM || page == NO_GRAPHICS || page == NO_BENCH) nrefresh(&refr); break; case KEY_RESIZE: /* Resize window */ erase(); starty = (LINES - info.height) / 2; startx = (COLS - info.width) / 2; mvwin(win, starty, startx); refresh(); main_win(win, info, data); (*func_ptr[page])(win, info, data); break; default: break; } } endwin(); labels_free(data); } /************************* Private functions *************************/ /* Clean window */ static void wclrscr(WINDOW *pwin) { int y, x, maxy, maxx; getmaxyx(pwin, maxy, maxx); for(y = 0; y < maxy; y++) { for(x = 0; x < maxx; x++) mvwaddch(pwin, y, x, ' '); } }
/* Start CPU-X in NCurses mode */ void start_tui_ncurses(Labels *data) { int startx, starty, ch = 0; const SizeInfo info = { .height = LINE_COUNT, .width = 70, .start = 1, .tb = 2, .tm = 22, .te = 38 }; NThrd refr = { .data = data, .info = info }; WINDOW *win; MSG_VERBOSE(_("Starting NCurses TUI...")); setenv("TERMINFO", "/lib/terminfo", 0); freopen("/dev/null", "a", stderr); initscr(); cbreak(); noecho(); curs_set(0); halfdelay(0); nodelay(stdscr, TRUE); keypad(stdscr, TRUE); if(opts->color) { start_color(); opts->color &= has_colors(); } starty = (LINES - info.height) / 2; /* Calculating for a center placement of the window */ startx = (COLS - info.width) / 2; win = newwin(info.height, info.width, starty, startx); refr.win = win; printw("Press 'q' to exit; use right/left key to change tab"); refresh(); main_win(win, info, data); ntab_cpu(win, info, data); timeout(opts->refr_time * 1000); while(ch != 'q') { ch = getch(); switch(ch) { case KEY_LEFT: /* Switch to left tab */ if(page > NO_CPU) { page--; main_win(win, info, data); (*func_ptr[page])(win, info, data); } break; case KEY_RIGHT: /* Switch to right tab */ if(page < NO_ABOUT) { page++; main_win(win, info, data); (*func_ptr[page])(win, info, data); } break; case ERR: /* Refresh dynamic labels */ if(page == NO_CPU || page == NO_CACHES || page == NO_SYSTEM || page == NO_GRAPHICS) nrefresh(&refr); break; case KEY_RESIZE: /* Resize window */ erase(); starty = (LINES - info.height) / 2; startx = (COLS - info.width) / 2; mvwin(win, starty, startx); printw("Press 'q' to exit; use right/left key to change tab"); refresh(); main_win(win, info, data); (*func_ptr[page])(win, info, data); break; default: break; } } endwin(); labels_free(data); } /************************* Private functions *************************/ /* Clean window */ static void wclrscr(WINDOW *pwin) { int y, x, maxy, maxx; getmaxyx(pwin, maxy, maxx); for(y = 0; y < maxy; y++) { for(x = 0; x < maxx; x++) mvwaddch(pwin, y, x, ' '); } }
int Login_win() { const char title[] = "中国人民银行现代化支付系统"; const char opermesg[]="柜员号:"; /* message to be appeared on the screen */ const char pwdmesg[]= "密码 :"; int row,col; /* to store the number of rows and * * the number of colums of the screen */ char id[USR_LEN + 1]; char pwd[PASSWORD_LEN + 1]; char ch; int ret(0); initscr(); /* start the curses mode */ getmaxyx(stdscr,row,col); /* get the number of rows and columns */ WINDOW * loginwin; loginwin = main_win(); mvwprintw(loginwin,row/2 - 3,(col-strlen(title))/2,"%s",title); mvwprintw(loginwin,row/2,(col-strlen(opermesg))/2 - 2,"%s",opermesg);/* print the message at the center of the screen */ mvwprintw(loginwin,row/2 + 2,(col-strlen(pwdmesg))/2 - 2,"%s",pwdmesg);/* print the message at the center of the screen */ wrefresh(loginwin); raw(); noecho(); //当执行wgetch()函数的时候关闭键盘回显 keypad(loginwin,TRUE); string login_id; const char * strSQL = "select pwd,operid from operinfo where operid = '000001' "; db2_exec_query(oper , strSQL); do { clear_line(loginwin,row/2,(col-strlen(opermesg))/2 + 6,USR_LEN); read_line(loginwin,id,USR_LEN,0); ret = check_operid(id); if(ret == -2) { show_msg(loginwin,"Importation is NULL,input again"); continue; } else if(ret == -1) { show_msg(loginwin,"The format importation is wrong,input 0-9 digit"); continue; } login_id.assign(id); if( !(oper.operid == login_id) ) { mvwprintw(loginwin,LINES - 2,0,"User ID is not exist,Please press any key to continue"); wrefresh(loginwin); wgetch(loginwin); clear_line(loginwin,LINES - 2,0,100); continue; } else break; }while(1); //refresh(); int ret1(0); do { clear_line(loginwin,row/2 + 2,(col-strlen(pwdmesg))/2 + 6,PASSWORD_LEN); read_line(loginwin,pwd,PASSWORD_LEN,1); wrefresh(loginwin); //ret1 = check_operpwd(pwd); //if(ret1 == -1) //{ // show_msg(loginwin,"Input Invalid,Please press any key to continue"); // continue; //} GetOperPasswdMd5(pwd); mvwprintw(loginwin,LINES - 4, 0, "1 md5: %s ",operpwd.c_str()); mvwprintw(loginwin,LINES - 5, 0, "2 md5: %s ",oper.pwd); if( !(oper.pwd == operpwd) ) { clear_line(loginwin,LINES - 2,0,100); mvwprintw(loginwin,LINES - 2,0,"User Passwd is invalid,Please press any key to continue"); clear_line(loginwin,LINES - 2,0,100); read_line(loginwin,pwd,PASSWORD_LEN,1); continue; } else { break; } }while(1); //clear_line(loginwin,LINES - 2,0,100); //mvwprintw(loginwin,LINES - 2, 0, "操作员 %s 签到成功...",id); wrefresh(loginwin); destroy_win(loginwin); clear_win(stdscr,0,0,24,80); //多窗口操作清窗口操作 wrefresh(stdscr); endwin(); return 0; }