int main(int argc, char *argv[]) { QApplication app(argc, argv); QPixmap pixmap("/home/dev/temp/temp_text_viewer/text_viewer/src/temp.png"); QSplashScreen *splash = new QSplashScreen(pixmap); QTextCodec *utfcodec = QTextCodec::codecForName("UTF-8"); QTextCodec::setCodecForTr(utfcodec); QTextCodec::setCodecForCStrings(utfcodec); splash->show(); loadModules(splash); splash->hide(); MainWindow window; window.showMaximized(); return app.exec(); }
int main(int argc, char *argv[]) { // Wait for keyboard to appear before displaying anything KeyDetection::waitForKeyboard(); QFile f("/sys/module/bcm2708/parameters/boardrev"); f.open(f.ReadOnly); int rev = f.readAll().trimmed().toInt(); f.close(); qDebug() << "Board revision is " << rev; int gpioChannel; if (rev == 2 || rev == 3) gpioChannel = 0; else gpioChannel = 2; QApplication a(argc, argv); RightButtonFilter rbf; GpioInput gpio(gpioChannel); bool runinstaller = false; bool gpio_trigger = false; bool keyboard_trigger = true; bool force_trigger = false; QString defaultLang = "en"; QString defaultKeyboard = "gb"; QString defaultDisplay = "0"; QString defaultPartition = "800"; // Process command-line arguments for (int i=1; i<argc; i++) { // Flag to indicate first boot if (strcmp(argv[i], "-runinstaller") == 0) runinstaller = true; // Enables use of GPIO 3 to force NOOBS to launch by pulling low else if (strcmp(argv[i], "-gpiotriggerenable") == 0) gpio_trigger = true; // Disables use of keyboard to trigger recovery GUI else if (strcmp(argv[i], "-keyboardtriggerdisable") == 0) keyboard_trigger = false; // Forces display of recovery GUI every time else if (strcmp(argv[i], "-forcetrigger") == 0) force_trigger = true; // Allow default language to be specified in commandline else if (strcmp(argv[i], "-lang") == 0) { if (argc > i+1) defaultLang = argv[i+1]; } // Allow default keyboard layout to be specified in commandline else if (strcmp(argv[i], "-kbdlayout") == 0) { if (argc > i+1) defaultKeyboard = argv[i+1]; } // Allow default display mode to be specified in commandline else if (strcmp(argv[i], "-dispmode") == 0) { if (argc > i+1) defaultDisplay = --argv[i+1]; } // Allow default boot partition to be specified in commandline else if (strcmp(argv[i], "-partition") == 0) { if (argc > i+1) defaultPartition = argv[i+1]; } } // Intercept right mouse clicks sent to the title bar a.installEventFilter(&rbf); #ifdef Q_WS_QWS QWSServer::setCursorVisible(false); #endif // Set wallpaper and icon, if we have resource files for that if (QFile::exists(":/icons/raspberry_icon.png")) a.setWindowIcon(QIcon(":/icons/raspberry_icon.png")); #ifdef Q_WS_QWS QWSServer::setBackground(BACKGROUND_COLOR); #endif QSplashScreen *splash = new QSplashScreen(QPixmap(":/wallpaper.png")); splash->show(); QApplication::processEvents(); // If -runinstaller is not specified, only continue if SHIFT is pressed, GPIO is triggered, // or no OS is installed (/dev/mmcblk0p5 does not exist) bool bailout = !runinstaller && !force_trigger && !(gpio_trigger && (gpio.value() == 0 )) && !(keyboard_trigger && KeyDetection::isF10pressed()) && QFile::exists(FAT_PARTITION_OF_IMAGE); // Keyboard detection done, load normal hid driver //QProcess::execute("/sbin/modprobe usbhid"); // Default to booting first extended partition putFileContents("/sys/module/bcm2708/parameters/reboot_part", "5\n"); if (bailout) { splash->hide(); reboot_to_extended(defaultPartition, true); } #ifdef Q_WS_QWS QWSServer::setCursorVisible(true); #endif // Main window in the middle of screen MainWindow mw(defaultDisplay, splash); mw.setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, mw.size(), a.desktop()->availableGeometry())); mw.show(); #ifdef ENABLE_LANGUAGE_CHOOSER // Language chooser at the bottom center LanguageDialog* ld = new LanguageDialog(defaultLang, defaultKeyboard); ld->setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignHCenter | Qt::AlignBottom, ld->size(), a.desktop()->availableGeometry())); ld->show(); #endif a.exec(); reboot_to_extended(defaultPartition, false); return 0; }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { // Setup UI components ui->setupUi(this); ui->tableTabWidget->tabBar()->tabButton(0, QTabBar::RightSide)->resize(0, 0); QList<int> sizes; sizes << 100 << 1000; ui->splitter->setSizes(sizes); // Start splash screen QPixmap pixmap(":/images/resources/aperture_blue.png"); QSplashScreen *splash = new QSplashScreen(pixmap); splash->show(); // Open Database _dbManager = new DatabaseManager(this); QString messageResult = _dbManager->openDB(); if(messageResult != NULL) { QMessageBox::critical(this, tr("Database Error"), "The database could not be opened: \n" + messageResult); ui->statusBar->showMessage("Open Database unsuccessful"); } else { ui->statusBar->showMessage("Database Connected"); messageResult = _dbManager->createCustomerAndInvoiceTables(); if(messageResult != NULL){ QMessageBox::critical(this, tr("Database Error"), "The tables could not be created: \n" + messageResult); } // Load the customer List _customerTableModel = new QSqlTableModel(this); _customerTableModel->setTable("customer"); _customerTableModel->select(); ui->listView->setModel(_customerTableModel); ui->listView->setModelColumn(1); // _customerModel = _dbManager->loadCustomerList(); // if(_customerModel != NULL) { // ui->listView->setModel(_customerModel); // ui->statusBar->showMessage("Successfully loaded customer list"); // } else { // QMessageBox::critical(this, tr("Database Error"), "The database could not load the customer list"); // ui->statusBar->showMessage("Database: Load customer list unsuccessful"); // } // Load all Invoice table _invoiceTableModel = new QSqlTableModel(this); _invoiceTableModel->setTable("invoice"); _invoiceTableModel->select(); ui->tableView->setModel(_invoiceTableModel); // _invoiceModel = _dbManager.loadInvoiceTable(); // if(_invoiceModel != NULL) { // ui->tableView->setModel(_invoiceModel); // ui->statusBar->showMessage("Successfully loaded invoice table"); // } else { // QMessageBox::critical(this, tr("Database Error"), "The database could not load the invoice table"); // ui->statusBar->showMessage("Database: Load invoice table unsuccessful"); // } } //QThread::sleep(3); splash->hide(); }
int main(int argc, char *argv[]) { bool hasTouchScreen = QFile::exists("/sys/devices/platform/rpi_ft5406"); // Unless we have a touch screen, wait for keyboard to appear before displaying anything if (!hasTouchScreen) KeyDetection::waitForKeyboard(); int rev = readBoardRevision(); qDebug() << "Board revision is " << rev; int gpioChannel; if (rev == 2 || rev == 3) gpioChannel = 0; else gpioChannel = 2; QApplication a(argc, argv); RightButtonFilter rbf; LongPressHandler lph; GpioInput gpio(gpioChannel); bool runinstaller = false; bool gpio_trigger = false; bool keyboard_trigger = true; bool force_trigger = false; QString defaultLang = "en"; QString defaultKeyboard = "gb"; QString defaultDisplay = "0"; QString defaultPartition = "800"; // Process command-line arguments for (int i=1; i<argc; i++) { // Flag to indicate first boot if (strcmp(argv[i], "-runinstaller") == 0) runinstaller = true; // Enables use of GPIO 3 to force NOOBS to launch by pulling low else if (strcmp(argv[i], "-gpiotriggerenable") == 0) gpio_trigger = true; // Disables use of keyboard to trigger recovery GUI else if (strcmp(argv[i], "-keyboardtriggerdisable") == 0) keyboard_trigger = false; // Forces display of recovery GUI every time else if (strcmp(argv[i], "-forcetrigger") == 0) force_trigger = true; // Allow default language to be specified in commandline else if (strcmp(argv[i], "-lang") == 0) { if (argc > i+1) defaultLang = argv[i+1]; } // Allow default keyboard layout to be specified in commandline else if (strcmp(argv[i], "-kbdlayout") == 0) { if (argc > i+1) defaultKeyboard = argv[i+1]; } // Allow default display mode to be specified in commandline else if (strcmp(argv[i], "-dispmode") == 0) { if (argc > i+1) defaultDisplay = --argv[i+1]; } // Allow default boot partition to be specified in commandline else if (strcmp(argv[i], "-partition") == 0) { if (argc > i+1) defaultPartition = argv[i+1]; } } // Intercept right mouse clicks sent to the title bar a.installEventFilter(&rbf); // Treat long holds as double-clicks if (hasTouchScreen) a.installEventFilter(&lph); #ifdef Q_WS_QWS QWSServer::setCursorVisible(false); #endif QDir settingsdir; settingsdir.mkdir("/settings"); // Set wallpaper and icon, if we have resource files for that if (QFile::exists(":/icons/raspberry_icon.png")) a.setWindowIcon(QIcon(":/icons/raspberry_icon.png")); #ifdef Q_WS_QWS QWSServer::setBackground(BACKGROUND_COLOR); #endif QSplashScreen *splash = new QSplashScreen(QPixmap(":/wallpaper.png")); splash->show(); QApplication::processEvents(); // Wait for drive device to show up QString drive; bool driveReady = false; QTime t; t.start(); while (t.elapsed() < 10000) { if (drive.isEmpty()) { /* We do not know the exact drive name to wait for */ drive = findRecoveryDrive(); if (!drive.isEmpty()) { driveReady = true; break; } } else if (drive.startsWith("/dev")) { if (QFile::exists(drive)) { driveReady = true; break; } } QApplication::processEvents(QEventLoop::WaitForMoreEvents, 100); } if (!driveReady) { QMessageBox::critical(NULL, "Files not found", QString("Cannot find the drive with NOOBS files %1").arg(drive), QMessageBox::Close); return 1; } qDebug() << "NOOBS drive:" << drive; // If -runinstaller is not specified, only continue if SHIFT is pressed, GPIO is triggered, // or no OS is installed (/settings/installed_os.json does not exist) bool bailout = !runinstaller && !force_trigger && !(gpio_trigger && (gpio.value() == 0 )) && hasInstalledOS(drive); if (bailout && keyboard_trigger) { t.start(); while (t.elapsed() < 2000) { QApplication::processEvents(QEventLoop::WaitForMoreEvents, 10); if (QApplication::queryKeyboardModifiers().testFlag(Qt::ShiftModifier)) { bailout = false; qDebug() << "Shift detected"; break; } if (hasTouchScreen && QApplication::mouseButtons().testFlag(Qt::LeftButton)) { bailout = false; qDebug() << "Tap detected"; break; } } } if (bailout) { splash->hide(); showBootMenu(drive, defaultPartition, true); } #ifdef Q_WS_QWS QWSServer::setCursorVisible(true); #endif // Main window in the middle of screen MainWindow mw(drive, defaultDisplay, splash); mw.setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, mw.size(), a.desktop()->availableGeometry())); mw.show(); #ifdef ENABLE_LANGUAGE_CHOOSER // Language chooser at the bottom center LanguageDialog* ld = new LanguageDialog(defaultLang, defaultKeyboard); ld->setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignHCenter | Qt::AlignBottom, ld->size(), a.desktop()->availableGeometry())); ld->show(); #endif a.exec(); showBootMenu(drive, defaultPartition, false); return 0; }
int main( int argc, char **argv ) { //ENABLE_LEAK_CHECK(); //_CrtSetBreakAlloc(49937); socket_startup(); curl_global_init(CURL_GLOBAL_NOTHING); #ifdef __APPLE__ // The following needs to be done before the application is created, otherwise loading platforms plugin fails. QDir dir(argv[0]); dir.cdUp(); dir.cdUp(); dir.cd("plugins"); QApplication::setLibraryPaths(QStringList(dir.absolutePath())); #endif /////// can be removed for non-qt-guis //////////// #ifdef ANDROID QApplication a(argc, argv); a.setApplicationName("PokerTH"); #else SharedTools::QtSingleApplication a( "PokerTH", argc, argv ); if (a.sendMessage("Wake up!")) { return 0; } #endif //create defaultconfig ConfigFile *myConfig = new ConfigFile(argv[0], false); Log *myLog = new Log(myConfig); // set PlastiqueStyle even for mac-version to prevent artefacts on styled widgets #if QT_VERSION < 0x050000 a.setStyle(new QPlastiqueStyle); #endif QString myAppDataPath = QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str()); //set QApplication default font QFontDatabase::addApplicationFont (myAppDataPath +"fonts/n019003l.pfb"); QFontDatabase::addApplicationFont (myAppDataPath +"fonts/DejaVuSans-Bold.ttf"); #ifdef _WIN32 QString font1String("QApplication, QWidget, QDialog { font-size: 12px; }"); #elif __APPLE__ // QString font1String("font-family: \"Lucida Grande\";"); QString font1String("QApplication, QWidget, QDialog { font-size: 11px; }"); #elif ANDROID QString font1String("QApplication, QWidget, QDialog { font-family: \"Nimbus Sans L\"; font-size: 26px; }"); QPalette p = a.palette(); p.setColor(QPalette::Button, QColor::fromRgb(80,80,80)); p.setColor(QPalette::Base, QColor::fromRgb(80,80,80)); p.setColor(QPalette::Window, QColor::fromRgb(50,50,50)); p.setColor(QPalette::ButtonText, QColor::fromRgb(255,255,255)); p.setColor(QPalette::Disabled, QPalette::ButtonText, QColor::fromRgb(130,130,130)); p.setColor(QPalette::WindowText, QColor::fromRgb(255,255,255)); p.setColor(QPalette::Disabled, QPalette::WindowText, QColor::fromRgb(100,100,100)); p.setColor(QPalette::Text, QColor::fromRgb(255,255,255)); p.setColor(QPalette::Disabled, QPalette::Text, QColor::fromRgb(100,100,100)); p.setColor(QPalette::Link, QColor::fromRgb(192,192,255)); p.setColor(QPalette::LinkVisited, QColor::fromRgb(192,192,255)); a.setPalette(p); #elif MAEMO QString font1String("QApplication, QWidget, QDialog { font-family: \"Nimbus Sans L\"; font-size: 22px; }"); QPalette p = a.palette(); p.setColor(QPalette::Button, QColor::fromRgb(80,80,80)); p.setColor(QPalette::Base, QColor::fromRgb(80,80,80)); p.setColor(QPalette::Window, QColor::fromRgb(50,50,50)); p.setColor(QPalette::ButtonText, QColor::fromRgb(255,255,255)); p.setColor(QPalette::Disabled, QPalette::ButtonText, QColor::fromRgb(100,100,100)); p.setColor(QPalette::WindowText, QColor::fromRgb(255,255,255)); p.setColor(QPalette::Disabled, QPalette::WindowText, QColor::fromRgb(100,100,100)); p.setColor(QPalette::Text, QColor::fromRgb(255,255,255)); p.setColor(QPalette::Disabled, QPalette::Text, QColor::fromRgb(100,100,100)); p.setColor(QPalette::Link, QColor::fromRgb(192,192,255)); p.setColor(QPalette::LinkVisited, QColor::fromRgb(192,192,255)); a.setPalette(p); #else QString font1String("QApplication, QWidget, QDialog { font-family: \"Nimbus Sans L\"; font-size: 12px; }"); #endif a.setStyleSheet(font1String + " QDialogButtonBox, QMessageBox { dialogbuttonbox-buttons-have-icons: 1; dialog-ok-icon: url(:/gfx/dialog_ok_apply.png); dialog-cancel-icon: url(:/gfx/dialog_close.png); dialog-close-icon: url(:/gfx/dialog_close.png); dialog-yes-icon: url(:/gfx/dialog_ok_apply.png); dialog-no-icon: url(:/gfx/dialog_close.png) }"); #ifdef ANDROID //check if custom background pictures for the resolution are there. Otherwise create them! QString UserDataDir = QString::fromUtf8(myConfig->readConfigString("UserDataDir").c_str()); QDesktopWidget dw; int screenWidth = dw.screenGeometry().width(); int screenHeight = dw.screenGeometry().height(); QString customStartWindowBgFileString(UserDataDir+"/startwindowbg10_"+QString::number(screenWidth)+"x"+QString::number(screenHeight)+".png"); QString customWelcomePokerTHFileString(UserDataDir+"/welcomepokerth10_"+QString::number(screenWidth)+"x"+QString::number(screenHeight)+".png"); QFile customStartWindowBgFile(customStartWindowBgFileString); QFile customWelcomePokerTHFile(customWelcomePokerTHFileString); QSplashScreen preSplashFirstRun; if(!customStartWindowBgFile.exists()) { //load preSplashPix to show that PokerTH is already running during first time pics calculation QPixmap prePixBase(":/gfx/logoChip3D.png"); QPixmap prePix(300, 200); prePix.fill(Qt::transparent); // force alpha channel { QPainter painter(&prePix); painter.drawPixmap(0, 0, prePixBase); painter.setPen(Qt::white); painter.drawText(10, 160, "loading ..."); } preSplashFirstRun.setPixmap(prePix); preSplashFirstRun.show(); QPixmap pix(":/android/android-data/gfx/gui/misc/startwindowbg10_mobile.png"); pix = pix.scaled(screenWidth, screenHeight, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation); pix.save(customStartWindowBgFileString); } if(!customWelcomePokerTHFile.exists()) { QPixmap base(customStartWindowBgFileString); //scale overlay "have a lot of fun" at first QPixmap overlay(":/android/android-data/gfx/gui/misc/welcomepokerth10_mobile.png"); overlay = overlay.scaled(screenWidth, screenHeight, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation); QPixmap result(base.width(), base.height()); result.fill(Qt::transparent); // force alpha channel { QPainter painter(&result); painter.drawPixmap(0, 0, base); painter.drawPixmap(0, 0, overlay); } result.save(customWelcomePokerTHFileString); preSplashFirstRun.hide(); } QPixmap pixmap; if(customWelcomePokerTHFile.exists()) { pixmap.load(QFileInfo(customWelcomePokerTHFile).absoluteFilePath()); } else { //if custom welcome pic could not be saved locally we need to scale it on the fly pixmap.load(":/android/android-data/gfx/gui/misc/welcomepokerth10_mobile.png"); pixmap = pixmap.scaled(screenWidth, screenHeight, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation); } #else QPixmap pixmap(myAppDataPath + "gfx/gui/misc/welcomepokerth10_desktop.png"); #endif StartSplash splash(pixmap); if(!myConfig->readConfigInt("DisableSplashScreenOnStartup")) { splash.show(); splash.showMessage(QString("Version %1").arg(POKERTH_BETA_RELEASE_STRING), 0x0042, QColor(255,255,255)); } //Set translations QTranslator qtTranslator; qtTranslator.load(QString(myAppDataPath +"translations/qt_") + QString::fromStdString(myConfig->readConfigString("Language"))); a.installTranslator(&qtTranslator); QTranslator translator; translator.load(QString(myAppDataPath +"translations/pokerth_") + QString::fromStdString(myConfig->readConfigString("Language"))); a.installTranslator(&translator); qRegisterMetaType<unsigned>("unsigned"); qRegisterMetaType<boost::shared_ptr<Game> >("boost::shared_ptr<Game>"); qRegisterMetaType<ServerStats>("ServerStats"); qRegisterMetaType<DenyGameInvitationReason>("DenyGameInvitationReason"); /////////////////////////////////////////////////// startWindowImpl mainWin(myConfig,myLog); #ifdef ANDROID mainWin.show(); #else a.setActivationWindow(&mainWin, true); #endif int retVal = a.exec(); curl_global_cleanup(); socket_cleanup(); return retVal; }