blob: d9fa449a12665505102272a3cd5f8f7c525eebae [file] [log] [blame] [raw]
/* PC GO Screen Shooter
Copyright 2007-2014 PC GO Ld.
Copyright 2015-2017 Rivoreo
Original are from Qt Demos
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*/
#include "screenshot.h"
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <QtGui/QApplication>
#include <QtGui/QSpinBox>
int main(int argc, char *argv[]) {
unsigned int delay = 0;
if(argc > 1 && (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-h") == 0)) {
fprintf(stderr, "Usage: %s [--style <QStyle name>] [--delay <number>]\n", argv[0]);
return -1;
}
for(int i=1; i<argc; i++) if(strcmp(argv[i], "--style") == 0) {
char *arg = argv[i + 1];
if(!arg) {
fprintf(stderr, "%s: Option %s requires an argument\n", argv[0], argv[i]);
return -1;
}
QApplication::setStyle(arg);
for(int j=i; j<argc-1; j++) argv[j] = argv[j+2];
argc -= 2;
}
QApplication a(argc, argv);
for(int i=1; i<argc; i++) if(strcmp(argv[i], "--delay") == 0) {
char *arg = argv[i + 1];
if(!arg) {
fprintf(stderr, "%s: Option %s requires an argument\n", argv[0], argv[i]);
return -1;
}
if(!isdigit(*arg)) {
fprintf(stderr, "%s: '%s' is not an unsigned number\n", argv[0], arg);
return 1;
}
delay = atoi(arg);
sleep(delay);
for(int j=i; j<argc-1; j++) argv[j] = argv[j+2];
argc -= 2;
}
ScreenShot screenshot;
if(delay) screenshot.delaySpinBox->setValue(delay);
screenshot.show();
screenshot.move(screenshot.center());
return a.exec();
}