void ATMainWindow_c::iconActivated(QSystemTrayIcon::ActivationReason reason) { switch (reason) { case QSystemTrayIcon::Trigger: if ( m_lastTrayTrigger.elapsed() > MIN_TRIGGER_TIMER ) { if ( isVisible() ) { hideWindow(); } else { showNormal(); IF_WIN32( ::SetForegroundWindow( winId() ) ); } m_lastTrayTrigger.restart(); } break; //case QSystemTrayIcon::DoubleClick: // break; //case QSystemTrayIcon::MiddleClick: // break; default: ; } }
void ATMainWindow_c::HotKey( unsigned short /*lo*/, unsigned short /*hi*/ ) { if ( isVisible() ) { hideWindow(); } else { showNormal(); IF_WIN32( ::SetForegroundWindow( winId() ) ); } }
int main(int argc, char **argv) { char *filename; int fix = 0; #ifdef _WIN32 _fmode = _O_BINARY; setmode(_fileno(stdin), _O_BINARY); setmode(_fileno(stdout), _O_BINARY); setmode(_fileno(stderr), _O_BINARY); #endif if (argc < 2) { printf("Usage: %s [--fix] <file.aof>\n", argv[0]); exit(1); } else if (argc == 2) { filename = argv[1]; } else if (argc == 3) { if (strcmp(argv[1],"--fix") != 0) { printf("Invalid argument: %s\n", argv[1]); exit(1); } filename = argv[2]; fix = 1; } else { printf("Invalid arguments\n"); exit(1); } FILE *fp = fopen(filename,IF_WIN32("r+b","r+")); if (fp == NULL) { printf("Cannot open file: %s\n", filename); exit(1); } struct redis_stat sb; if (redis_fstat(fileno(fp),&sb) == -1) { printf("Cannot stat file: %s\n", filename); exit(1); } off_t size = sb.st_size; if (size == 0) { printf("Empty file: %s\n", filename); exit(1); } off_t pos = process(fp); off_t diff = size-pos; printf("AOF analyzed: size=%lld, ok_up_to=%lld, diff=%lld\n", (PORT_LONGLONG) size, (PORT_LONGLONG) pos, (PORT_LONGLONG) diff); if (diff > 0) { if (fix) { char buf[2]; printf("This will shrink the AOF from %lld bytes, with %lld bytes, to %lld bytes\n",(PORT_LONGLONG)size,(PORT_LONGLONG)diff,(PORT_LONGLONG)pos); printf("Continue? [y/N]: "); if (fgets(buf,sizeof(buf),stdin) == NULL || strncasecmp(buf,"y",1) != 0) { printf("Aborting...\n"); exit(1); } if (ftruncate(fileno(fp), pos) == -1) { printf("Failed to truncate AOF\n"); exit(1); } else { printf("Successfully truncated AOF\n"); } } else { printf("AOF is not valid\n"); exit(1); } } else { printf("AOF is valid\n"); } fclose(fp); return 0; }