/** * @brief Constructor initializes WelcomeScreen and it's UI. * @param parent A pointer to the QWidget parent. */ WelcomeScreen::WelcomeScreen(QWidget *parent) : QWidget(parent), ui(new Ui::WelcomeScreen) { ui->setupUi(this); _start = ui->start_button; this->setWindowTitle("OMBI"); ui->how_to->setVisible(false); connect(ui->info_button, SIGNAL(clicked()), this, SLOT(toggleInfo())); // Testing variable, true or false (default). bool testing = false; // Add OMBI logo from Resources. QString logo(":/images/ombi-logo.png"); QPixmap img(logo); ui->logo->setPixmap(img); // Start municipalities slideshow. QMovie *movie = new QMovie(":/animations/muni-slideshow.gif"); ui->slideshow->setMovie(movie); movie->start(); // **Automated Testing Only** if (testing) { /* Test #1 - OMBI Logo */ if(img.isNull()) std::cout << "Test #1 - Logo: Fail" << std::endl; else std::cout << "Test #1 - Logo: Pass" << std::endl; /* Test #2 - OMBI Description */ if(ui->line9->text().isEmpty()) std::cout << "Test #2 - Description: Fail" << std::endl; else std::cout << "Test #2 - Description: Pass" << std::endl; } }
VideoWindow::VideoWindow() { setTitle("Video"); //setResizable(false); setGeometry({64, 64, 512, 480}); setStatusFont(application->proportionalFontBold); setStatusVisible(); canvas.setSize({512, 480}); layout.append(canvas, {~0, ~0}); append(layout); image logo(0, 32, 255u << 24, 255u << 16, 255u << 8, 255u << 0); logo.loadPNG(laevateinnLogo, sizeof laevateinnLogo); logo.alphaBlend(0x000000); unsigned cx = (512 - logo.width) / 2, cy = (480 - logo.height) / 2; for(unsigned y = 0; y < logo.height; y++) { uint32_t *dp = canvas.data() + (y + cy) * 512 + cx; const uint32_t *sp = (const uint32_t*)logo.data + y * logo.width; for(unsigned x = 0; x < logo.width; x++) { *dp++ = *sp++; } } canvas.update(); canvas.onMouseLeave = [&] { setStatusText(""); }; canvas.onMouseMove = [&](Position position) { uint32_t color = canvas.data()[position.y * 512 + position.x]; unsigned r = (color >> 19) & 31, g = (color >> 11) & 31, b = (color >> 3) & 31; setStatusText({ decimal(position.x / 2), ".", decimal((position.x & 1) * 5), ", ", decimal(position.y / 2), ".", decimal((position.y & 1) * 5), ", ", "0x", hex<4>((b << 10) + (g << 5) + (r << 0)) }); };
void decrypt(void) { get('d'); printf("Decrypted string is\n"); for(i=0;i<num;i++) { short num; char highfour,lowfour; num=s2[i]; lowfour=num&0xf; num>>=4; highfour=num&0xf; num=lowfour; num<<=4; num=num|highfour; printf("%c",num); } printf("\n"); printf("Press any key to continue.\n"); while (!getch()); logo(); }
void encrypt(void) { get('e'); printf("Encrypted string is\n*"); for(i=0;i<num;i++) { char ch; char highfour,lowfour; ch=s[i]; lowfour=ch&0xf; ch>>=4; highfour=ch&0xf; ch=lowfour; ch<<=4; ch=ch|highfour; printf("%d*",ch); } printf("\n"); printf("Press any key to continue.\n"); while (!getch()); logo(); }
KABC::Picture toPicture(const std::string &data, const std::string &mimetype) { QImage img; bool ret = false; QByteArray type(mimetype.data(), mimetype.size()); type = type.split('/').last(); // extract "jpeg" from "image/jpeg" if (QImageReader::supportedImageFormats().contains(type)) { ret = img.loadFromData(QByteArray::fromRawData(data.data(), data.size()), type.constData()); } else { ret = img.loadFromData(QByteArray::fromRawData(data.data(), data.size())); } if (!ret) { Warning() << "failed to load picture"; return KABC::Picture(); } KABC::Picture logo(img); if (logo.isEmpty()) { Warning() << "failed to read picture"; return KABC::Picture(); } return logo; }
AboutDialog::AboutDialog(QWidget *parent) : QDialog(parent), m_ui(new Ui::AboutDialog) { // Basic UI setup m_ui->setupUi(this); setWindowTitle("About"); QPixmap logo(":/res/icon.ico"); m_ui->lb_logo->setPixmap(logo); m_ui->lb_logo->setScaledContents(true); std::ostringstream s; s << "OPC UA -> MQTT Gateway client\n" << VERSION_S; m_ui->lb_about1->setText(std::string(s.str()).c_str()); m_ui->lb_about2->setOpenExternalLinks(true); m_ui->lb_about2->setTextInteractionFlags(Qt::LinksAccessibleByMouse | Qt::LinksAccessibleByKeyboard); m_ui->lb_about2->setText("<a href=\"https://github.com/harha/\">https://github.com/harha/</a>"); // Signal -> Slot connections connect(m_ui->pb_close, SIGNAL(clicked(bool)), this, SLOT(close())); }
std::string complete_version() { boost::format logo( "Versions:\n" " HPX: %s\n" " Boost: %s\n" "\n" "Build:\n" " Type: %s\n" " Date: %s\n" " Platform: %s\n" " Compiler: %s\n" " Standard Library: %s\n"); return boost::str(logo % build_string() % boost_version() % build_type() % build_date_time() % boost_platform() % boost_compiler() % boost_stdlib()); }
void MainMenu::Render() { Screen::Get().BeginScreenUpdate(); auto top = (Screen::Get().GetHeight() / 2) - 10; std::string logo( " .:. \n" " .:. \\|/ .:.\n" " _ \\|/ | \\|/\n" " _/_\\_ ___ <#> | \\|<#> |\n" " (\") /.-.\\ \\|<#>|/ \\| /\n" " _ //U\\\\ |(\")| | \\| /<#>/\n" " ( ) _ \\|_|/ /)v(\\ \\ |/ |/ \\|\n" " (_` )_('> | | \\/~\\/ \\| | |/\n" " (__,~_)8 ||| //_\\\\ |/ \\| / \\| /\n" " _YY_ _[|]_ /_____\\ \\| |/ |/\n" " \"\"\"\"\"\"\"\"'\"\"'\"\"'\"\"\"\"\"'\"\"\"\"'\"\"'\"\"\"'\"\"\"\"\"''\"'\"\"\"^^^^^^^^^^^^^^^^\n" " Harvest-Rogue " ); Screen::Get().WriteCenterText(top, logo); this->DrawMenu(); Screen::Get().EndScreenUpdate(); }
void YardCustomer::OnNew(wxCommandEvent& event) { wxBitmap logo("res/yast_sysadmin.png", wxBITMAP_TYPE_PNG); YardNewCustomer * wizard = new YardNewCustomer(this, -1, wxT("New Customer Wizard"), logo); YardNewCustomer1 * page1 = new YardNewCustomer1(wizard); YardNewCustomer2 * page2 = new YardNewCustomer2(wizard); YardNewCustomer3 * page3 = new YardNewCustomer3(wizard); YardNewCustomer4 * page4 = new YardNewCustomer4(wizard); wxWizardPageSimple::Chain(page1, page2); wxWizardPageSimple::Chain(page2, page3); wxWizardPageSimple::Chain(page3, page4); wxSize min = page4->GetMin(); wizard->SetPageSize(min); if ( wizard->RunWizard(page1) ) { wxLogDebug(wxT("Wizard completed OK")); YardCustType temp = wizard->GetCustomer(); YardDate now(wxDateTime::Now()); temp.SetSince(now); try { wxGetApp().DB().CustomerAdd(temp); } catch (YardDBException& e) { wxLogDebug(wxT("Error (customer not added): %s, %s"),e.what(), e.GetSQL().c_str()); } } wizard->Destroy(); }
int main(int argc, char *argv[]) { QApplication a(argc, argv); QTranslator t; QDate today = QDate::currentDate(); if ( today.month() == 4 && today.day() == 1 ) { t.load(":/translations/koi7.qm"); } else { t.load(":/translations/ru.qm"); } QApplication::installTranslator(&t); Settings::instance(); Logger::logger(); QPixmap logo(":/resources/logo.png"); QSplashScreen *splash = new QSplashScreen(logo, Qt::FramelessWindowHint | Qt::SplashScreen); splash->setMask( logo.mask() ); splash->show(); Settings::instance()->updateLocalData(); splash->close(); delete splash; LauncherWindow w; w.show(); return a.exec(); }
Card::Card(unsigned short num, GameWindow *window, QWidget *parent) : QWidget(parent), number(num), gameWindow(window) { state = new CardStateStatic(this); checkNullPointer(state); std::string path = std::string(Card::IMG_PATH) + std::to_string(number) + std::string(Card::IMG_EXT); QPixmap logo(path.c_str()); logo = logo.scaledToHeight(Card::DEFAULT_HEIGHT); int height = logo.height(), width = logo.width(); resize(width, height); label = new QLabel(this); checkNullPointer(label, [=]() { delete state; }); label->setGeometry(0, 0, width, height); label->setPixmap(logo); label->show(); }
void GUISettingsMenu::drawMenu() { video::IVideoDriver* driver = Environment->getVideoDriver(); { core::rect<s32> left( AbsoluteRect.UpperLeftCorner.X, AbsoluteRect.UpperLeftCorner.Y, AbsoluteRect.LowerRightCorner.X-550, AbsoluteRect.LowerRightCorner.Y ); core::rect<s32> right( AbsoluteRect.UpperLeftCorner.X+250, AbsoluteRect.UpperLeftCorner.Y, AbsoluteRect.LowerRightCorner.X, AbsoluteRect.LowerRightCorner.Y ); driver->draw2DRectangle(left, GUI_BG_BTM, GUI_BG_BTM, GUI_BG_BTM, GUI_BG_BTM, &AbsoluteClippingRect); driver->draw2DRectangle(right, GUI_BG_TOP, GUI_BG_BTM, GUI_BG_TOP, GUI_BG_BTM, &AbsoluteClippingRect); video::ITexture *texture = driver->getTexture(getTexturePath("menulogo.png").c_str()); if (texture != 0) { const core::dimension2d<u32>& img_origsize = texture->getOriginalSize(); core::rect<s32> logo( AbsoluteRect.UpperLeftCorner.X+25, AbsoluteRect.UpperLeftCorner.Y, AbsoluteRect.UpperLeftCorner.X+225, AbsoluteRect.UpperLeftCorner.Y+200 ); const video::SColor color(255,255,255,255); const video::SColor colors[] = {color,color,color,color}; driver->draw2DImage(texture, logo, core::rect<s32>(core::position2d<s32>(0,0),img_origsize), NULL, colors, true); } } gui::IGUIElement::draw(); }
CallWidget::CallWidget(QWidget* parent) : NavWidget(parent), ui(new Ui::CallWidget), menu_(new QMenu()), imDelegate_(new ImDelegate()) { ui->setupUi(this); pageAnim_ = new QPropertyAnimation(ui->welcomePage, "pos", this); setActualCall(nullptr); videoRenderer_ = nullptr; connect(ui->settingsButton, &QPushButton::clicked, this, &CallWidget::settingsButtonClicked); connect(ui->videoWidget, SIGNAL(setChatVisibility(bool)), ui->instantMessagingWidget, SLOT(setVisible(bool))); QPixmap logo(":/images/logo-ring-standard-coul.png"); ui->ringLogo->setPixmap(logo.scaledToHeight(100, Qt::SmoothTransformation)); ui->ringLogo->setAlignment(Qt::AlignHCenter); setupShareMenu(); GlobalInstances::setPixmapManipulator(std::unique_ptr<Interfaces::PixbufManipulator>(new Interfaces::PixbufManipulator())); try { callModel_ = &CallModel::instance(); connect(callModel_, SIGNAL(incomingCall(Call*)), this, SLOT(callIncoming(Call*))); connect(callModel_, SIGNAL(callStateChanged(Call*, Call::State)), this, SLOT(callStateChanged(Call*, Call::State))); connect(&AccountModel::instance() , SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)) , this , SLOT(findRingAccount(QModelIndex, QModelIndex, QVector<int>))); RecentModel::instance().peopleProxy()->setFilterRole(static_cast<int>(Ring::Role::Name)); RecentModel::instance().peopleProxy()->setFilterCaseSensitivity(Qt::CaseInsensitive); ui->smartList->setModel(RecentModel::instance().peopleProxy()); smartListDelegate_ = new SmartListDelegate(); ui->smartList->setSmartListItemDelegate(smartListDelegate_); PersonModel::instance().addCollection<PeerProfileCollection>(LoadOptions::FORCE_ENABLED); ProfileModel::instance().addCollection<LocalProfileCollection>(LoadOptions::FORCE_ENABLED); PersonModel::instance(). addCollection<WindowsContactBackend>(LoadOptions::FORCE_ENABLED); CategorizedContactModel::instance().setSortAlphabetical(false); CategorizedContactModel::instance().setUnreachableHidden(true); ui->contactView->setModel(&CategorizedContactModel::instance()); contactDelegate_ = new ContactDelegate(); ui->contactView->setItemDelegate(contactDelegate_); CategorizedHistoryModel::instance(). addCollection<LocalHistoryCollection>(LoadOptions::FORCE_ENABLED); ui->historyList->setModel(CategorizedHistoryModel::SortedProxy::instance().model()); CategorizedHistoryModel::SortedProxy::instance().model()->sort(0, Qt::DescendingOrder); ui->historyList->setHeaderHidden(true); historyDelegate_ = new HistoryDelegate(); ui->historyList->setItemDelegate(historyDelegate_); connect(CategorizedHistoryModel::SortedProxy::instance().model(), &QSortFilterProxyModel::layoutChanged, [=]() { auto idx = CategorizedHistoryModel::SortedProxy::instance().model()->index(0,0); if (idx.isValid()) ui->historyList->setExpanded(idx, true); }); connect(ui->smartList, &QTreeView::entered, this, &CallWidget::on_entered); smartListDelegate_ = new SmartListDelegate(); ui->smartList->setSmartListItemDelegate(smartListDelegate_); ui->historyList->setContextMenuPolicy(Qt::CustomContextMenu); connect(ui->historyList, &QListView::customContextMenuRequested, [=](const QPoint& pos){ if (ui->historyList->currentIndex().parent().isValid()) { QPoint globalPos = ui->historyList->mapToGlobal(pos); QMenu menu; ContactMethod* contactMethod = ui->historyList->currentIndex() .data(static_cast<int>(Call::Role::ContactMethod)).value<ContactMethod*>(); auto copyAction = new QAction(tr("Copy number"), this); menu.addAction(copyAction); connect(copyAction, &QAction::triggered, [=]() { QApplication::clipboard()->setText(contactMethod->uri()); }); if (not contactMethod->contact() || contactMethod->contact()->isPlaceHolder()) { auto addExisting = new QAction(tr("Add to contact"), this); menu.addAction(addExisting); connect(addExisting, &QAction::triggered, [=]() { ContactPicker contactPicker(contactMethod); contactPicker.move(globalPos.x(), globalPos.y() - (contactPicker.height()/2)); contactPicker.exec(); }); } menu.exec(globalPos); } }); findRingAccount(); setupOutOfCallIM(); setupSmartListMenu(); connect(ui->smartList, &SmartList::btnVideoClicked, this, &CallWidget::btnComBarVideoClicked); connect(RecentModel::instance().selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(smartListSelectionChanged(QItemSelection,QItemSelection))); connect(RecentModel::instance().selectionModel(), &QItemSelectionModel::selectionChanged, [=](const QItemSelection &selected, const QItemSelection &deselected) { Q_UNUSED(deselected) if (selected.size()) { auto idx = selected.indexes().first(); auto realIdx = RecentModel::instance().peopleProxy()->mapFromSource(idx); ui->smartList->selectionModel()->setCurrentIndex(realIdx, QItemSelectionModel::ClearAndSelect); } else ui->smartList->clearSelection(); }); } catch (const std::exception& e) {
static Bool initCitadel(void) { if (!read_cfg_messages()) { #ifdef WINCIT char Buffer[128]; sprintf(Buffer, getmsg(188), getmsg(671)); MessageBox(NULL, Buffer, NULL, MB_ICONSTOP | MB_OK); #else printf(getmsg(188), getmsg(671)); #endif return (FALSE); } checkfiles(); initExtDrivers(); get_os(); cfg.battr = 0xff; setscreen(); logo(TRUE); // no go for debug version; td32 go crash crash init_internal_sound(); // some mouse initialization technology!!!! initMouseHandler(); hideCounter = 1; if (time(NULL) < 700000000L) { #ifdef WINCIT MessageBox(NULL, getcfgmsg(119), NULL, MB_ICONSTOP | MB_OK); #else doccr(); doccr(); cPrintf(getcfgmsg(119)); doccr(); #endif dump_cfg_messages(); return (FALSE); } static char prompt[92]; static char citadel[92]; char *envprompt; char *citprompt; envprompt = getenv(getcfgmsg(120)); citprompt = getenv(getcfgmsg(121)); if (citprompt) { sprintf(prompt, getcfgmsg(122), citprompt); } else if (envprompt) { sprintf(prompt, getcfgmsg(123), envprompt); } else { strcpy(prompt, getcfgmsg(124)); } putenv(prompt); sprintf(citadel, getcfgmsg(125), programName, version); putenv(citadel); #ifndef WINCIT OC.whichIO = CONSOLE; OC.SetOutFlag(OUTOK); OC.Echo = BOTH; OC.setio(); #endif VerifyHeap(1); // If we aren't reconfiguring, load the tables... if (!reconfig) { // Start by reading ETC.TAB getcwd(etcpath, 64); FILE *fd; if ((fd = fopen(etcTab, FO_RB)) != NULL) { if (filelength(fileno(fd)) != (long) sizeof(config) || fread(&cfg, 1, sizeof(config), fd) != (long) sizeof(config)) { memset(&cfg, 0, sizeof(cfg)); reconfig = TRUE; } fclose(fd); unlink(etcTab); // If ETC.TAB could be loaded, load the rest if (!reconfig) { changedir(cfg.homepath); allocateTables(); if (!LogTab.Load() || !MessageDat.LoadTable() || !RoomTab.Load()) { reconfig = TRUE; } Cron.ReadTable(WC_TWpn); } } else { if (!batchmode) { #ifdef WINCIT MessageBox(NULL, "No ETC.TAB.", NULL, MB_ICONSTOP | MB_OK); #else doccr(); discardable *d; if ((d = readData(6)) != NULL) { int i; for (i = 0; ((char **) d->next->aux)[i][0] != '#'; i++) { cPrintf(pcts, ((char **) d->next->aux)[i]); doccr(); } doccr(); discardData(d); } else { cOutOfMemory(28); } DeinitializeTimer(); critical(FALSE); #endif exit(1); } reconfig = TRUE; } } if (reconfig) { cfg.attr = 7; #ifndef WINCIT pause(200); cls(SCROLL_SAVE); cCPrintf(getcfgmsg(126)); doccr(); #endif if (!configcit()) { #ifdef WINCIT MessageBox(NULL, getcfgmsg(127), NULL, MB_ICONSTOP | MB_OK); #else doccr(); doccr(); cPrintf(getcfgmsg(127)); doccr(); #endif dump_cfg_messages(); return (FALSE); } #ifndef WINCIT setdefaultTerm(TT_ANSI); CurrentUser->SetWidth(80); #endif Cron.ReadCronCit(WC_TWpn); } else { #ifndef WINCIT if (!CreateScrollBackBuffer()) { cPrintf(getcfgmsg(60)); doccr(); } #endif if (readconfigcit) // forced to read in config.cit { if (!readconfig(NULL, 1)) { #ifdef WINCIT MessageBox(NULL, getcfgmsg(129), NULL, MB_ICONSTOP | MB_OK); #else doccr(); doccr(); cPrintf(getcfgmsg(129)); doccr(); #endif dump_cfg_messages(); return (FALSE); } } } VerifyHeap(1); makeBorders(); readBordersDat(); if (cmd_nobells) { cfg.noBells = 2; } if (cmd_nochat) { cfg.noChat = TRUE; } if (cmd_mdata != CERROR) { cfg.mdata = cmd_mdata; } if (*cfg.f6pass) { if (SameString(cfg.f6pass, getmsg(670))) { ConsoleLock.LockF6(); } else { ConsoleLock.Lock(); } } #ifndef WINCIT if (cfg.ovrEms) { if (_OvrInitEms(0, 0, 0)) { cPrintf(getcfgmsg(130)); doccr(); pause(200); } } if (cfg.ovrExt) { if (_OvrInitExt(0, 0)) { cPrintf(getcfgmsg(131)); doccr(); pause(200); } } CommPort->Init(); setscreen(); #endif logo(TRUE); // no go for debug version; td32 go crash crash #ifndef WINCIT StatusLine.Update(WC_TWp); #endif if (cfg.msgpath[(strlen(cfg.msgpath) - 1)] == '\\') { cfg.msgpath[(strlen(cfg.msgpath) - 1)] = '\0'; } // move to home path changedir(cfg.homepath); char FileName[128]; ReIndexFileInfo(); // keep fileinfo.dat nice and pretty // open message file if (!MessageDat.OpenMessageFile(cfg.msgpath)) { illegal(getmsg(78), MessageDat.GetFilename()); } // Then room file sprintf(FileName, sbs, cfg.homepath, roomDat); openFile(FileName, &RoomFile); citOpen(cfg.trapfile, CO_A, &TrapFile); initMenus(); dump_cfg_messages(); if(!read_tr_messages()) { errorDisp(getmsg(172)); } else { #ifdef WINCIT trap(T_SYSOP, "", gettrmsg(37)); #else trap(T_SYSOP, gettrmsg(37)); #endif dump_tr_messages(); } read_cfg_messages(); // uh-oh! if (!GroupData.Load()) { return (FALSE); } if (!HallData.Load()) { return (FALSE); } getRoomPos(); if (cfg.accounting) { ReadGrpdataCit(WC_TWpn); } ReadExternalCit(WC_TWpn); ReadProtocolCit(WC_TWpn); ReadMdmresltCit(WC_TWpn); ReadCommandsCit(WC_TWpn); #ifndef WINCIT ReadMCICit(FALSE); CurrentRoom->Load(LOBBY); thisRoom = LOBBY; checkdir(); if (!slv_door) { CITWINDOW *w = CitWindowsMsg(NULL, getmsg(19)); Initport(); Initport(); if (w) { destroyCitWindow(w, FALSE); } } else { CommPort->Enable(); } OC.whichIO = MODEM; OC.setio(); #endif // record when we put system up time(&uptimestamp); #ifndef WINCIT setdefaultconfig(FALSE); Talley->Fill(); #endif logo(FALSE); VerifyHeap(1); dump_cfg_messages(); compactMemory(1); return (TRUE); }
void MenuScene::renderHud() { if (menu) { Image img; img.loadFromFile("img/logo.png"); int logoWidth = img.getSize().x; int logoHeight = img.getSize().y; Texture texture; texture.loadFromImage(img, Rect<int>(0,0, logoWidth,logoHeight)); RectangleShape logo(vec2(logoWidth,logoHeight)); logo.setTexture(&texture, true); logo.setPosition(app->getView().getCenter().x - logo.getLocalBounds().width/2, -80); app->draw(logo); if(first) writeText("Conecta los Wiimotes (pulsa 1+2)", -110); int ct = wInput.connectedCount; if(hasKeyboard) ct++; if(ct) { if(first) { if(ct == 1) writeText("1 wiimote conectado (max 4)", -60); else writeText(toString(ct)+" wiimotes conectados (max 4)", -60); } writeText("Objetivo: "+toString(objScore)+" puntos (puedes cambiarlo con +/-)", 30); if (ct < MIN_PLAYERS) writeText("Hacen falta minimo "+toString(MIN_PLAYERS)+" jugadores para jugar", 100); else writeText("Pulsa A para iniciar la partida", 100); writeText("Pulsa 1 para ver los creditos", 200); writeText("Pulsa HOME para salir del juego", 300); } } else if (credits) { Text t; t.setFont(font); t.setCharacterSize(40); t.setString(String("Pulsa B para volver al menu")); t.setPosition(20, 20); app->draw(t); writeText("FIRE SMASH", -280, 50); writeText("Desarrollado para Wiideojuegos 2012 por:", -200); writeText("David Balaghi Buil", -150); writeText("Dario Nieuwenhuis Nivela", -110); writeText("Librerias utilizadas:", -30); writeText("SFML 2.0", 20); writeText("BOX2D", 60); writeText("WiiUse", 100); writeText("Software utilizado:", 160); writeText("Qt Creator", 210); writeText("GIMP", 250); writeText("Ableton Live 8", 290); } }
//Flags FramelessWindowHint und WindowStaysOnTopHint nicht entfernen, sonst kann sich die //Anwendung nicht über die Software der Waage legen MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent, Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint), ui(new Ui::MainWindow) { setCursor(Qt::BlankCursor); //Settings auslesen QSettings* settings = new QSettings("config.ini",QSettings::IniFormat,this); int check = settings->value("Timer/check",10000).toInt(); QString startTimeString = settings->value("Timer/start","06:00").toString(); QString endTimeString = settings->value("Timer/end","17:00").toString(); QString ticksString = settings->value("Timer/ticks","").toString(); int x = settings->value("Position/x",100).toInt(); int y = settings->value("Position/y",100).toInt(); int width = settings->value("Size/width",200).toInt(); int height = settings->value("Size/height",200).toInt(); QString logoFileName = settings->value("Message/logo","").toString(); _operationMode = settings->value("System/operationmode",1).toInt(); delete settings; _start = QTime::fromString(startTimeString+":00"); _end = QTime::fromString(endTimeString+":00"); QStringList ticksList = ticksString.split('|'); for(int i=0;i<ticksList.count();i++) { QString tickString = ticksList.at(i); tickString += ":00"; QTime time = QTime::fromString(tickString); _ticks.append(time); } //Nächsten möglichen Alert bestimmen _tickIdx = 0; if (_ticks.count() > 0) { _nextTick = _ticks.at(_tickIdx); } ui->setupUi(this); if ((logoFileName == "") || (!QFile::exists(logoFileName))) { ui->logo->setVisible(false); } else { QPixmap logo(logoFileName); ui->logo->setPixmap( logo ); } if (_operationMode == 2) { ui->logo->setGeometry(x,y,width,height); ui->logo->updateGeometry(); ui->logo->setMouseTracking(true); ui->logo->installEventFilter(this); //Transparenter Hintergrund setAttribute(Qt::WA_TranslucentBackground); setStyleSheet("background:transparent;"); } else { ui->logo->setGeometry(0,0,width,height); ui->logo->updateGeometry(); move(x,y); resize(width,height); } _timer = new QTimer(this); _timer->setInterval(check); QObject::connect(_timer,SIGNAL(timeout()),this,SLOT(timeout())); _timer->start(); _popUpTimer = new QTimer(this); _popUpTimer->setInterval(10000); QObject::connect(_popUpTimer,SIGNAL(timeout()),this,SLOT(popUpTimeout())); }
int main (int argc, char *argv[]) { #ifdef WIN32 char *callname = argv[0]; #endif char linecopy[MAXLINE]; DATASET *dset = NULL; MODEL *model = NULL; ExecState state; char *line = NULL; int quiet = 0; int makepkg = 0; int load_datafile = 1; char filearg[MAXLEN]; char runfile[MAXLEN]; double scriptval = NADBL; CMD cmd; PRN *prn = NULL; PRN *cmdprn = NULL; int err = 0; #ifdef G_OS_WIN32 win32_set_gretldir(callname); #endif nls_init(); #ifdef HAVE_READLINE rl_bind_key(0x18, ctrl_x); #endif dset = datainfo_new(); if (dset == NULL) { noalloc(); } if (argc < 2) { load_datafile = 0; } else { gretlopt opt = 0; err = parse_options(&argc, &argv, &opt, &scriptval, filearg); if (!err && (opt & (OPT_DBOPEN | OPT_WEBDB))) { /* catch GUI-only options */ err = E_BADOPT; } if (err) { /* bad option */ usage(1); } else if (opt & (OPT_HELP | OPT_VERSION)) { /* we'll exit in these cases */ if (opt & OPT_HELP) { usage(0); } else { logo(0); exit(EXIT_SUCCESS); } } if (opt & (OPT_BATCH | OPT_RUNIT | OPT_MAKEPKG)) { if (*filearg == '\0') { /* we're missing a filename argument */ usage(1); } else { /* record argument (not a datafile) */ strcpy(runfile, filearg); load_datafile = 0; if (opt & OPT_BATCH) { batch = 1; } else if (opt & OPT_MAKEPKG) { batch = 1; makepkg = 1; } else { runit = 1; } } } else if (*filearg == '\0') { load_datafile = 0; } if (opt & OPT_QUIET) { quiet = 1; } if (opt & OPT_ENGLISH) { force_language(LANG_C); } } libgretl_init(); logo(quiet); if (!quiet) { session_time(NULL); } prn = gretl_print_new(GRETL_PRINT_STDOUT, &err); if (err) { noalloc(); } line = malloc(MAXLINE); if (line == NULL) { noalloc(); } #ifdef WIN32 win32_cli_read_rc(callname); #else cli_read_rc(); #endif /* WIN32 */ if (!batch) { strcpy(cmdfile, gretl_workdir()); strcat(cmdfile, "session.inp"); cmdprn = gretl_print_new_with_filename(cmdfile, &err); if (err) { errmsg(err, prn); return EXIT_FAILURE; } } if (load_datafile) { handle_datafile(filearg, runfile, dset, prn, cmdprn); } /* allocate memory for model */ model = allocate_working_model(); if (model == NULL) { noalloc(); } gretl_cmd_init(&cmd); gretl_exec_state_init(&state, 0, line, &cmd, model, prn); set_debug_read_func(get_interactive_line); /* print list of variables */ if (data_status) { varlist(dset, prn); } if (!na(scriptval)) { /* define "scriptopt" */ gretl_scalar_add("scriptopt", scriptval); } /* misc. interactive-mode setup */ if (!batch) { check_help_file(); fb = stdin; push_input_file(fb); if (!runit && !data_status) { fputs(_("Type \"open filename\" to open a data set\n"), stdout); } } #ifdef HAVE_READLINE initialize_readline(); #endif if (batch || runit) { /* re-initialize: will be incremented by "run" cmd */ runit = 0; if (makepkg) { set_gretl_echo(0); } if (strchr(runfile, ' ')) { sprintf(line, "run \"%s\"", runfile); } else { sprintf(line, "run %s", runfile); } err = cli_exec_line(&state, dset, cmdprn); if (err && fb == NULL) { exit(EXIT_FAILURE); } } *linecopy = '\0'; /* main command loop */ while (cmd.ci != QUIT && fb != NULL && !xout) { if (err && gretl_error_is_fatal()) { gretl_abort(linecopy); } if (gretl_execute_loop()) { if (gretl_loop_exec(&state, dset, NULL)) { return 1; } } else { err = cli_get_input_line(&state); if (err) { errmsg(err, prn); break; } } if (!state.in_comment) { if (cmd.context == FOREIGN || cmd.context == MPI || gretl_compiling_python(line)) { tailstrip(line); } else { err = maybe_get_input_line_continuation(line); if (err) { errmsg(err, prn); break; } } } strcpy(linecopy, line); tailstrip(linecopy); err = cli_exec_line(&state, dset, cmdprn); } /* end of get commands loop */ if (!err) { err = gretl_if_state_check(0); if (err) { errmsg(err, prn); } } if (makepkg && !err) { switch_ext(filearg, runfile, "gfn"); sprintf(line, "makepkg %s\n", filearg); cli_exec_line(&state, dset, cmdprn); } /* leak check -- try explicitly freeing all memory allocated */ destroy_working_model(model); destroy_dataset(dset); if (fb != stdin && fb != NULL) { fclose(fb); } free(line); gretl_print_destroy(prn); gretl_cmd_free(&cmd); libgretl_cleanup(); return 0; }
int main(int argc, char **argv) { char *rawfilename = NULL; int numiter = 250; int use_apc = 1; int use_normalization = 0; conjugrad_float_t lambda_single = F001; // 0.01 conjugrad_float_t lambda_pair = FInf; conjugrad_float_t lambda_pair_factor = F02; // 0.2 int conjugrad_k = 5; conjugrad_float_t conjugrad_eps = 0.01; parse_option *optList, *thisOpt; char *optstr; char *old_optstr = malloc(1); old_optstr[0] = 0; optstr = concat("r:i:n:w:k:e:l:ARh?", old_optstr); free(old_optstr); #ifdef OPENMP int numthreads = 1; old_optstr = optstr; optstr = concat("t:", optstr); free(old_optstr); #endif #ifdef CUDA int use_def_gpu = 0; old_optstr = optstr; optstr = concat("d:", optstr); free(old_optstr); #endif #ifdef MSGPACK char* msgpackfilename = NULL; old_optstr = optstr; optstr = concat("b:", optstr); free(old_optstr); #endif optList = parseopt(argc, argv, optstr); free(optstr); char* msafilename = NULL; char* matfilename = NULL; char* initfilename = NULL; conjugrad_float_t reweighting_threshold = F08; // 0.8 while(optList != NULL) { thisOpt = optList; optList = optList->next; switch(thisOpt->option) { #ifdef OPENMP case 't': numthreads = atoi(thisOpt->argument); #ifdef CUDA use_def_gpu = -1; // automatically disable GPU if number of threads specified #endif break; #endif #ifdef CUDA case 'd': use_def_gpu = atoi(thisOpt->argument); break; #endif #ifdef MSGPACK case 'b': msgpackfilename = thisOpt->argument; break; #endif case 'r': rawfilename = thisOpt->argument; break; case 'i': initfilename = thisOpt->argument; break; case 'n': numiter = atoi(thisOpt->argument); break; case 'w': reweighting_threshold = (conjugrad_float_t)atof(thisOpt->argument); break; case 'l': lambda_pair_factor = (conjugrad_float_t)atof(thisOpt->argument); break; case 'k': conjugrad_k = (int)atoi(thisOpt->argument); break; case 'e': conjugrad_eps = (conjugrad_float_t)atof(thisOpt->argument); break; case 'A': use_apc = 0; break; case 'R': use_normalization = 1; break; case 'h': case '?': usage(argv[0], 1); break; case 0: if(msafilename == NULL) { msafilename = thisOpt->argument; } else if(matfilename == NULL) { matfilename = thisOpt->argument; } else { usage(argv[0], 0); } break; default: die("Unknown argument"); } free(thisOpt); } if(msafilename == NULL || matfilename == NULL) { usage(argv[0], 0); } FILE *msafile = fopen(msafilename, "r"); if( msafile == NULL) { printf("Cannot open %s!\n\n", msafilename); return 2; } #ifdef JANSSON char* metafilename = malloc(2048); snprintf(metafilename, 2048, "%s.meta.json", msafilename); FILE *metafile = fopen(metafilename, "r"); json_t *meta; if(metafile == NULL) { // Cannot find .meta.json file - create new empty metadata meta = meta_create(); } else { // Load metadata from matfile.meta.json meta = meta_read_json(metafile); fclose(metafile); } json_object_set(meta, "method", json_string("ccmpred")); json_t *meta_step = meta_add_step(meta, "ccmpred"); json_object_set(meta_step, "version", json_string(__VERSION)); json_t *meta_parameters = json_object(); json_object_set(meta_step, "parameters", meta_parameters); json_t *meta_steps = json_array(); json_object_set(meta_step, "iterations", meta_steps); json_t *meta_results = json_object(); json_object_set(meta_step, "results", meta_results); #endif int ncol, nrow; unsigned char* msa = read_msa(msafile, &ncol, &nrow); fclose(msafile); int nsingle = ncol * (N_ALPHA - 1); int nvar = nsingle + ncol * ncol * N_ALPHA * N_ALPHA; int nsingle_padded = nsingle + N_ALPHA_PAD - (nsingle % N_ALPHA_PAD); int nvar_padded = nsingle_padded + ncol * ncol * N_ALPHA * N_ALPHA_PAD; #ifdef CURSES bool color = detect_colors(); #else bool color = false; #endif logo(color); #ifdef CUDA int num_devices, dev_ret; struct cudaDeviceProp prop; dev_ret = cudaGetDeviceCount(&num_devices); if(dev_ret != CUDA_SUCCESS) { num_devices = 0; } if(num_devices == 0) { printf("No CUDA devices available, "); use_def_gpu = -1; } else if (use_def_gpu < -1 || use_def_gpu >= num_devices) { printf("Error: %d is not a valid device number. Please choose a number between 0 and %d\n", use_def_gpu, num_devices - 1); exit(1); } else { printf("Found %d CUDA devices, ", num_devices); } if (use_def_gpu != -1) { cudaError_t err = cudaSetDevice(use_def_gpu); if(cudaSuccess != err) { printf("Error setting device: %d\n", err); exit(1); } cudaGetDeviceProperties(&prop, use_def_gpu); printf("using device #%d: %s\n", use_def_gpu, prop.name); size_t mem_free, mem_total; err = cudaMemGetInfo(&mem_free, &mem_total); if(cudaSuccess != err) { printf("Error getting memory info: %d\n", err); exit(1); } size_t mem_needed = nrow * ncol * 2 + // MSAs sizeof(conjugrad_float_t) * nrow * ncol * 2 + // PC, PCS sizeof(conjugrad_float_t) * nrow * ncol * N_ALPHA_PAD + // PCN sizeof(conjugrad_float_t) * nrow + // Weights (sizeof(conjugrad_float_t) * ((N_ALPHA - 1) * ncol + ncol * ncol * N_ALPHA * N_ALPHA_PAD)) * 4; setlocale(LC_NUMERIC, ""); printf("Total GPU RAM: %'17lu\n", mem_total); printf("Free GPU RAM: %'17lu\n", mem_free); printf("Needed GPU RAM: %'17lu ", mem_needed); if(mem_needed <= mem_free) { printf("✓\n"); } else { printf("⚠\n"); } #ifdef JANSSON json_object_set(meta_parameters, "device", json_string("gpu")); json_t* meta_gpu = json_object(); json_object_set(meta_parameters, "gpu_info", meta_gpu); json_object_set(meta_gpu, "name", json_string(prop.name)); json_object_set(meta_gpu, "mem_total", json_integer(mem_total)); json_object_set(meta_gpu, "mem_free", json_integer(mem_free)); json_object_set(meta_gpu, "mem_needed", json_integer(mem_needed)); #endif } else { printf("using CPU"); #ifdef JANSSON json_object_set(meta_parameters, "device", json_string("cpu")); #endif #ifdef OPENMP printf(" (%d thread(s))", numthreads); #ifdef JANSSON json_object_set(meta_parameters, "cpu_threads", json_integer(numthreads)); #endif #endif printf("\n"); } #else // CUDA printf("using CPU"); #ifdef JANSSON json_object_set(meta_parameters, "device", json_string("cpu")); #endif #ifdef OPENMP printf(" (%d thread(s))\n", numthreads); #ifdef JANSSON json_object_set(meta_parameters, "cpu_threads", json_integer(numthreads)); #endif #endif // OPENMP printf("\n"); #endif // CUDA conjugrad_float_t *x = conjugrad_malloc(nvar_padded); if( x == NULL) { die("ERROR: Not enough memory to allocate variables!"); } memset(x, 0, sizeof(conjugrad_float_t) * nvar_padded); // Auto-set lambda_pair if(isnan(lambda_pair)) { lambda_pair = lambda_pair_factor * (ncol - 1); } // fill up user data struct for passing to evaluate userdata *ud = (userdata *)malloc( sizeof(userdata) ); if(ud == 0) { die("Cannot allocate memory for user data!"); } ud->msa = msa; ud->ncol = ncol; ud->nrow = nrow; ud->nsingle = nsingle; ud->nvar = nvar; ud->lambda_single = lambda_single; ud->lambda_pair = lambda_pair; ud->weights = conjugrad_malloc(nrow); ud->reweighting_threshold = reweighting_threshold; if(initfilename == NULL) { // Initialize emissions to pwm init_bias(x, ud); } else { // Load potentials from file read_raw(initfilename, ud, x); } // optimize with default parameters conjugrad_parameter_t *param = conjugrad_init(); param->max_iterations = numiter; param->epsilon = conjugrad_eps; param->k = conjugrad_k; param->max_linesearch = 5; param->alpha_mul = F05; param->ftol = 1e-4; param->wolfe = F02; int (*init)(void *) = init_cpu; int (*destroy)(void *) = destroy_cpu; conjugrad_evaluate_t evaluate = evaluate_cpu; #ifdef OPENMP omp_set_num_threads(numthreads); if(numthreads > 1) { init = init_cpu_omp; destroy = destroy_cpu_omp; evaluate = evaluate_cpu_omp; } #endif #ifdef CUDA if(use_def_gpu != -1) { init = init_cuda; destroy = destroy_cuda; evaluate = evaluate_cuda; } #endif init(ud); #ifdef JANSSON json_object_set(meta_parameters, "reweighting_threshold", json_real(ud->reweighting_threshold)); json_object_set(meta_parameters, "apc", json_boolean(use_apc)); json_object_set(meta_parameters, "normalization", json_boolean(use_normalization)); json_t *meta_regularization = json_object(); json_object_set(meta_parameters, "regularization", meta_regularization); json_object_set(meta_regularization, "type", json_string("l2")); json_object_set(meta_regularization, "lambda_single", json_real(lambda_single)); json_object_set(meta_regularization, "lambda_pair", json_real(lambda_pair)); json_object_set(meta_regularization, "lambda_pair_factor", json_real(lambda_pair_factor)); json_t *meta_opt = json_object(); json_object_set(meta_parameters, "optimization", meta_opt); json_object_set(meta_opt, "method", json_string("libconjugrad")); json_object_set(meta_opt, "float_bits", json_integer((int)sizeof(conjugrad_float_t) * 8)); json_object_set(meta_opt, "max_iterations", json_integer(param->max_iterations)); json_object_set(meta_opt, "max_linesearch", json_integer(param->max_linesearch)); json_object_set(meta_opt, "alpha_mul", json_real(param->alpha_mul)); json_object_set(meta_opt, "ftol", json_real(param->ftol)); json_object_set(meta_opt, "wolfe", json_real(param->wolfe)); json_t *meta_msafile = meta_file_from_path(msafilename); json_object_set(meta_parameters, "msafile", meta_msafile); json_object_set(meta_msafile, "ncol", json_integer(ncol)); json_object_set(meta_msafile, "nrow", json_integer(nrow)); if(initfilename != NULL) { json_t *meta_initfile = meta_file_from_path(initfilename); json_object_set(meta_parameters, "initfile", meta_initfile); json_object_set(meta_initfile, "ncol", json_integer(ncol)); json_object_set(meta_initfile, "nrow", json_integer(nrow)); } double neff = 0; for(int i = 0; i < nrow; i++) { neff += ud->weights[i]; } json_object_set(meta_msafile, "neff", json_real(neff)); ud->meta_steps = meta_steps; #endif printf("\nWill optimize %d %ld-bit variables\n\n", nvar, sizeof(conjugrad_float_t) * 8); if(color) { printf("\x1b[1m"); } printf("iter\teval\tf(x) \t║x║ \t║g║ \tstep\n"); if(color) { printf("\x1b[0m"); } conjugrad_float_t fx; int ret; #ifdef CUDA if(use_def_gpu != -1) { conjugrad_float_t *d_x; cudaError_t err = cudaMalloc((void **) &d_x, sizeof(conjugrad_float_t) * nvar_padded); if (cudaSuccess != err) { printf("CUDA error No. %d while allocation memory for d_x\n", err); exit(1); } err = cudaMemcpy(d_x, x, sizeof(conjugrad_float_t) * nvar_padded, cudaMemcpyHostToDevice); if (cudaSuccess != err) { printf("CUDA error No. %d while copying parameters to GPU\n", err); exit(1); } ret = conjugrad_gpu(nvar_padded, d_x, &fx, evaluate, progress, ud, param); err = cudaMemcpy(x, d_x, sizeof(conjugrad_float_t) * nvar_padded, cudaMemcpyDeviceToHost); if (cudaSuccess != err) { printf("CUDA error No. %d while copying parameters back to CPU\n", err); exit(1); } err = cudaFree(d_x); if (cudaSuccess != err) { printf("CUDA error No. %d while freeing memory for d_x\n", err); exit(1); } } else { ret = conjugrad(nvar_padded, x, &fx, evaluate, progress, ud, param); } #else ret = conjugrad(nvar_padded, x, &fx, evaluate, progress, ud, param); #endif printf("\n"); printf("%s with status code %d - ", (ret < 0 ? "Exit" : "Done"), ret); if(ret == CONJUGRAD_SUCCESS) { printf("Success!\n"); } else if(ret == CONJUGRAD_ALREADY_MINIMIZED) { printf("Already minimized!\n"); } else if(ret == CONJUGRADERR_MAXIMUMITERATION) { printf("Maximum number of iterations reached.\n"); } else { printf("Unknown status code!\n"); } printf("\nFinal fx = %f\n\n", fx); FILE* out = fopen(matfilename, "w"); if(out == NULL) { printf("Cannot open %s for writing!\n\n", matfilename); return 3; } conjugrad_float_t *outmat = conjugrad_malloc(ncol * ncol); FILE *rawfile = NULL; if(rawfilename != NULL) { printf("Writing raw output to %s\n", rawfilename); rawfile = fopen(rawfilename, "w"); if(rawfile == NULL) { printf("Cannot open %s for writing!\n\n", rawfilename); return 4; } write_raw(rawfile, x, ncol); } #ifdef MSGPACK FILE *msgpackfile = NULL; if(msgpackfilename != NULL) { printf("Writing msgpack raw output to %s\n", msgpackfilename); msgpackfile = fopen(msgpackfilename, "w"); if(msgpackfile == NULL) { printf("Cannot open %s for writing!\n\n", msgpackfilename); return 4; } #ifndef JANSSON void *meta = NULL; #endif } #endif sum_submatrices(x, outmat, ncol); if(use_apc) { apc(outmat, ncol); } if(use_normalization) { normalize(outmat, ncol); } write_matrix(out, outmat, ncol, ncol); #ifdef JANSSON json_object_set(meta_results, "fx_final", json_real(fx)); json_object_set(meta_results, "num_iterations", json_integer(json_array_size(meta_steps))); json_object_set(meta_results, "opt_code", json_integer(ret)); json_t *meta_matfile = meta_file_from_path(matfilename); json_object_set(meta_results, "matfile", meta_matfile); if(rawfilename != NULL) { json_object_set(meta_results, "rawfile", meta_file_from_path(rawfilename)); } if(msgpackfilename != NULL) { json_object_set(meta_results, "msgpackfile", meta_file_from_path(msgpackfilename)); } fprintf(out, "#>META> %s", json_dumps(meta, JSON_COMPACT)); if(rawfile != NULL) { fprintf(rawfile, "#>META> %s", json_dumps(meta, JSON_COMPACT)); } #endif if(rawfile != NULL) { fclose(rawfile); } #ifdef MSGPACK if(msgpackfile != NULL) { write_raw_msgpack(msgpackfile, x, ncol, meta); fclose(msgpackfile); } #endif fflush(out); fclose(out); destroy(ud); conjugrad_free(outmat); conjugrad_free(x); conjugrad_free(ud->weights); free(ud); free(msa); free(param); printf("Output can be found in %s\n", matfilename); return 0; }
/****************************************************************************** * main * * * * Main function * ******************************************************************************/ int main(int argc, char *argv[]) { int error = 0, i=1; l4_threadid_t dummy_l4id = L4_NIL_ID, loader_id; // l4events_event_t event; // l4events_nr_t eventnr; CORBA_Environment _env = dice_default_environment; /* init */ do_args(argc, argv); my_l4id = l4thread_l4_id( l4thread_myself() ); LOG("Hello, I'm running as "l4util_idfmt, l4util_idstr(my_l4id)); /* ask for 'con' (timeout = 5000 ms) */ if (names_waitfor_name(CON_NAMES_STR, &con_l4id, 50000) == 0) { LOG("PANIC: %s not registered at names", CON_NAMES_STR); enter_kdebug("panic"); } if (names_waitfor_name("LOADER", &loader_id, 50000) == 0) { LOG("PANIC: LOADER not registered at names"); enter_kdebug("panic"); } if (con_if_openqry_call(&con_l4id, MY_SBUF_SIZE, 0, 0, L4THREAD_DEFAULT_PRIO, &vc_l4id, CON_VFB, &_env)) enter_kdebug("Ouch, open vc failed"); if (con_vc_smode_call(&vc_l4id, CON_OUT, &dummy_l4id, &_env)) enter_kdebug("Ouch, setup vc failed"); if (con_vc_graph_gmode_call(&vc_l4id, &gmode, &xres, &yres, &bits_per_pixel, &bytes_per_pixel, &bytes_per_line, &accel_flags, &fn_x, &fn_y, &_env)) enter_kdebug("Ouch, graph_gmode failed"); if (bytes_per_pixel != 2) { printf("Graphics mode not 2 bytes/pixel, exiting\n"); con_vc_close_call(&vc_l4id, &_env); exit(0); } if (create_logo()) enter_kdebug("Ouch, logo creation failed"); while (!error && (i>0)) { if ((error = clear_screen())) enter_kdebug("Ouch, clear_screen failed"); if ((error = logo())) enter_kdebug("Ouch, logo failed"); l4_sleep(500); i--; } if (con_vc_close_call(&vc_l4id, &_env)) enter_kdebug("Ouch, close vc failed?!"); LOG("Finally closed vc"); LOG("Going to bed ..."); names_register("CON_DEMO1"); /* my_id = l4_myself(); event.len=sizeof(l4_umword_t); *(l4_umword_t*)event.str=my_id.id.task; l4events_send(1, &event, &eventnr, L4EVENTS_SEND_ACK); l4events_get_ack(eventnr, L4_IPC_NEVER); */ return 0; }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { this->setFixedSize(this->size()); //setWindowFlags(windowFlags() ^ Qt::WindowMaximizeButtonHint); ui->setupUi(this); //initializam interfata //Pregatim imaginile //<<< //cap QPixmap head("C:/img/head.png"); ui->img1->setPixmap(head); //corp QPixmap body("C:/img/body.png"); ui->img1_2->setPixmap(body); //mana QPixmap lhand("C:/img/lhand.png"); ui->img1_3->setPixmap(lhand); //mana2 QPixmap rhand("C:/img/rhand.png"); ui->img1_4->setPixmap(rhand); //picior QPixmap rfeet("C:/img/rfeet.png"); ui->img1_5->setPixmap(rfeet); //complet QPixmap FULL("C:/img/FULL.png"); ui->img1_6->setPixmap(FULL); //logo QPixmap logo("C:/img/logo.png"); ui->img_logo->setPixmap(logo); //>>> //Main qDebug()<<categorii[0]; setWindowTitle("Spanzuratoarea"); //setam titlul //Setari interfata ui->lineEdit->setVisible(false); ui->pushButton_3->setVisible(false); ui->label_2->setVisible(false); ui->pushButton_4->setVisible(false); ui->butstatistici->setVisible(false); ui->buttop3->setVisible(false); ui->pushButton_8->setVisible(false); ui->stat1->setVisible(false); ui->stat1_2->setVisible(false); ui->statnume->setVisible(false); ui->statnume_2->setVisible(false); ui->statnume_3->setVisible(false); ui->statwins->setVisible(false); ui->statwins_2->setVisible(false); ui->statwins_3->setVisible(false); ui->butback->setVisible(false); ui->line_2->setVisible(false); ui->catanim->setVisible(false); ui->cataut->setVisible(false); ui->catfruct->setVisible(false); ui->catjud->setVisible(false); ui->catpict->setVisible(false); ui->catplant->setVisible(false); ui->cattari->setVisible(false); ui->lineEdit_3->setVisible(false); ui->label_3->setVisible(false); ui->label_4->setVisible(false); ui->img1->setVisible(false); ui->img1_2->setVisible(false); ui->img1_3->setVisible(false); ui->img1_4->setVisible(false); ui->img1_5->setVisible(false); ui->img1_6->setVisible(false); ui->groupBox->setVisible(false); ui->lineEdit_2->setVisible(false); ui->label_6->setVisible(false); ui->label_7->setVisible(false); ui->pushButton_9->setVisible(false); ui->pushButton_10->setVisible(false); ui->cataleat->setVisible(false); ui->butadmin->setVisible(false); ui->label->setVisible(false); //Conexiunea la baza de date utilizatori=QSqlDatabase::addDatabase("QSQLITE"); utilizatori.setDatabaseName("C:/sqlite/data.db"); if(utilizatori.open()) qDebug()<<"Baza de date e deschisa!"; else qDebug()<<"Baza de date nu e deschisa!"; }
int main() { struct timeval tv; powerON(POWER_ALL); //set mode 0, enable BG0 and set it to 3D videoSetMode(MODE_0_3D); //Use console videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE); //sub bg 0 will be used to print text vramSetBankC(VRAM_C_SUB_BG); SUB_BG0_CR = BG_MAP_BASE(31); BG_PALETTE_SUB[255] = RGB15(31,31,31); //by default font will be rendered with color 255 consoleInitDefault((u16*)SCREEN_BASE_BLOCK_SUB(31), (u16*)CHAR_BASE_BLOCK_SUB(0), 16); //iprintf("Starting up...\n"); // install the default exception handler defaultExceptionHandler(); //irqs are nice irqInit(); irqEnable(IRQ_VBLANK); // set the generic sound parameters setGenericSound( 11025, /* sample rate */ 127, /* volume */ 64, /* panning */ 1 ); /* sound format*/ glInit(); glEnable(GL_TEXTURE_2D); glEnable(GL_BLEND); //this should work the same as the normal gl call glViewPort(0,0,255,191); glClearColor(0,0,0,0); glClearDepth(0x7FFF); vramSetBankA(VRAM_A_TEXTURE); vramSetBankB(VRAM_B_TEXTURE); logo(); glGenTextures(1, &textureID); glBindTexture(0, textureID); glTexImage2D(0, 0, GL_RGB, TEXTURE_SIZE_256 , TEXTURE_SIZE_256, 0, TEXGEN_TEXCOORD , (u8*)die_bmp_bin); glGenTextures(1, &textureID2); glBindTexture(0, textureID2); glTexImage2D(0, 0, GL_RGBA, TEXTURE_SIZE_128 , TEXTURE_SIZE_128, 0, TEXGEN_TEXCOORD, (u8*)mario_bmp_bin); gettimeofday(&tv, NULL); //iprintf("Seeding with %d\n", tv.tv_usec); srand(tv.tv_usec); while(1){ gameLoop(); } return 0; }//end main
void AddresseeTest::serializeTest() { KContacts::Addressee addressee1, addressee2; KContacts::Picture logo(QStringLiteral("http://scottlandyard.info/pics/logo.png")); KContacts::Picture photo(QStringLiteral("http://scottlandyard.info/~sinclair/photo.png")); KContacts::Sound sound(QStringLiteral("http://scottlandyard.info/~sinclair/sound.wav")); QStringList emails; emails << QStringLiteral("*****@*****.**") << QStringLiteral("*****@*****.**"); KContacts::Key::List keys; keys << KContacts::Key(QStringLiteral("SecretKey")); QStringList categories; categories << QStringLiteral("Helper") << QStringLiteral("Friend"); QStringList customs; customs << QStringLiteral("FirstApp-FirstKey:FirstValue") << QStringLiteral("SecondApp-SecondKey:SecondValue") << QStringLiteral("ThirdApp-ThirdKey:ThirdValue"); addressee1.setUid(QStringLiteral("My uid")); addressee1.setName(QStringLiteral("John Sinclair")); addressee1.setFormattedName(QStringLiteral("Sinclair, John")); addressee1.setFamilyName(QStringLiteral("Sinclair")); addressee1.setGivenName(QStringLiteral("John")); addressee1.setAdditionalName(QStringLiteral("Bob")); addressee1.setPrefix(QStringLiteral("Sir")); addressee1.setSuffix(QStringLiteral("II")); addressee1.setNickName(QStringLiteral("ghosthunter")); addressee1.setBirthday(QDateTime(QDate(1982, 7, 19))); addressee1.setMailer(QStringLiteral("mutt")); addressee1.setTimeZone(KContacts::TimeZone(2)); addressee1.setGeo(KContacts::Geo(42, 23)); addressee1.setTitle(QStringLiteral("Ghost Hunter")); addressee1.setRole(QStringLiteral("Leader")); addressee1.setOrganization(QStringLiteral("Scottland Yard")); addressee1.setNote(QStringLiteral("Don't cross black deads way...")); addressee1.setProductId(QStringLiteral("ProductId45")); addressee1.setRevision(QDateTime(QDate(1982, 9, 15))); addressee1.setSortString(QStringLiteral("Name")); KContacts::ResourceLocatorUrl url; url.setUrl(QUrl(QStringLiteral("www.scottlandyard.info"))); addressee1.setUrl(url); addressee1.setSecrecy(KContacts::Secrecy(KContacts::Secrecy::Public)); addressee1.setLogo(logo); addressee1.setPhoto(photo); addressee1.setSound(sound); addressee1.setEmails(emails); addressee1.setKeys(keys); addressee1.setCategories(categories); addressee1.setCustoms(customs); addressee1.setChanged(false); QByteArray data; QDataStream s(&data, QIODevice::WriteOnly); s << addressee1; QDataStream t(&data, QIODevice::ReadOnly); t >> addressee2; QVERIFY(addressee1 == addressee2); }
void load() { system("cls"); system("color f8"); logo(); FILE *fp; char back[100]; printf("\n Load your phone book file:\n\n"); printf(" Please enter the name of the file: "); gets(input); fp = fopen(input,"r+"); while(fp==NULL) { system ("color fc"); printf("\n\n Error loading phone book file!\n"); printf("\n Please enter the name of the file again: "); gets(input); fp = fopen(input,"r+"); } system("cls"); system("color f8"); logo(); char line [1000]; const char *token; while ( fgets ( line, sizeof line, fp ) != NULL ) { if(strcmpi(line,"\n")!=0) { token = strtok(line, d); int col=1; while( token != NULL) { if(col==1) { contact[entry].first=strdup(token); col++; } else if(col==2) { contact[entry].last=strdup(token); col++; } else if(col==3) { contact[entry].ad=strdup(token); col++; } else if(col==4) { contact[entry].city=strdup(token); col++; } else if(col==5) { contact[entry].phone=strdup(token); col++; } token = strtok(NULL, d); } entry++; } } fclose ( fp ); system("cls"); logo(); printf("\n %d contacts from the file %s has been loaded successfully!\n",entry, input); printf("\n Use the command BACK to return to the main menu.\n\n COMMAND: "); gets(back); while(strcmpi(back,"BACK")!=0) { printf("\n You have entered an incorrect command. Please re-enter your command.\n\n COMMAND: "); gets(back); } main(); }
void AddresseeTest::storeTest() { KContacts::Addressee addressee; KContacts::Picture logo(QStringLiteral("http://scottlandyard.info/pics/logo.png")); KContacts::Picture photo(QStringLiteral("http://scottlandyard.info/~sinclair/photo.png")); KContacts::Sound sound(QStringLiteral("http://scottlandyard.info/~sinclair/sound.wav")); QStringList emails; emails << QStringLiteral("*****@*****.**") << QStringLiteral("*****@*****.**"); KContacts::Key::List keys; keys << KContacts::Key(QStringLiteral("SecretKey")); QStringList categories; categories << QStringLiteral("Helper") << QStringLiteral("Friend"); QStringList customs; customs << QStringLiteral("X-Danger: high"); KContacts::Gender gender(QStringLiteral("H")); addressee.setGender(gender); KContacts::Lang lang(QLatin1String("lang")); addressee.setLangs(KContacts::Lang::List() << lang); addressee.setUid(QStringLiteral("My uid")); addressee.setName(QStringLiteral("John Sinclair")); addressee.setFormattedName(QStringLiteral("Sinclair, John")); addressee.setFamilyName(QStringLiteral("Sinclair")); addressee.setGivenName(QStringLiteral("John")); addressee.setAdditionalName(QStringLiteral("Bob")); addressee.setPrefix(QStringLiteral("Sir")); addressee.setSuffix(QStringLiteral("II")); addressee.setNickName(QStringLiteral("ghosthunter")); addressee.setBirthday(QDate(1982, 7, 19)); addressee.setMailer(QStringLiteral("mutt")); addressee.setTimeZone(KContacts::TimeZone(2)); addressee.setGeo(KContacts::Geo(42, 23)); addressee.setTitle(QStringLiteral("Ghost Hunter")); addressee.setRole(QStringLiteral("Leader")); addressee.setOrganization(QStringLiteral("Scottland Yard")); addressee.setNote(QStringLiteral("Don't cross black deads way...")); addressee.setProductId(QStringLiteral("ProductId45")); addressee.setRevision(QDateTime(QDate(1982, 9, 15))); addressee.setSortString(QStringLiteral("Name")); KContacts::ResourceLocatorUrl url; url.setUrl(QUrl(QStringLiteral("www.scottlandyard.info"))); addressee.setUrl(url); addressee.setSecrecy(KContacts::Secrecy(KContacts::Secrecy::Public)); addressee.setLogo(logo); addressee.setPhoto(photo); addressee.setSound(sound); addressee.setEmails(emails); addressee.setKeys(keys); addressee.setCategories(categories); addressee.setCustoms(customs); addressee.setKind(QStringLiteral("foo")); addressee.setChanged(false); KContacts::Impp imp; imp.setType(KContacts::Impp::GaduGadu); imp.setAddress(QStringLiteral("*****@*****.**")); KContacts::Impp::List listImp; listImp << imp; addressee.setImppList(listImp); QVERIFY(addressee.imppList() == listImp); QVERIFY(addressee.langs() == (KContacts::Lang::List() << lang)); QVERIFY(addressee.gender() == gender); QVERIFY(addressee.uid() == QStringLiteral("My uid")); QVERIFY(addressee.name() == QStringLiteral("John Sinclair")); QVERIFY(addressee.formattedName() == QStringLiteral("Sinclair, John")); QVERIFY(addressee.familyName() == QStringLiteral("Sinclair")); QVERIFY(addressee.givenName() == QStringLiteral("John")); QVERIFY(addressee.additionalName() == QStringLiteral("Bob")); QVERIFY(addressee.prefix() == QStringLiteral("Sir")); QVERIFY(addressee.suffix() == QStringLiteral("II")); QVERIFY(addressee.nickName() == QStringLiteral("ghosthunter")); QVERIFY(addressee.birthday().date() == QDate(1982, 7, 19)); QVERIFY(addressee.birthday().time() == QTime(0, 0)); QVERIFY(!addressee.birthdayHasTime()); QVERIFY(addressee.mailer() == QStringLiteral("mutt")); QVERIFY(addressee.timeZone() == KContacts::TimeZone(2)); QVERIFY(addressee.geo() == KContacts::Geo(42, 23)); QVERIFY(addressee.title() == QStringLiteral("Ghost Hunter")); QVERIFY(addressee.role() == QStringLiteral("Leader")); QVERIFY(addressee.organization() == QStringLiteral("Scottland Yard")); QVERIFY(addressee.note() == QStringLiteral("Don't cross black deads way...")); QVERIFY(addressee.productId() == QStringLiteral("ProductId45")); QVERIFY(addressee.revision() == QDateTime(QDate(1982, 9, 15))); QVERIFY(addressee.sortString() == QStringLiteral("Name")); QVERIFY(addressee.url() == url); QVERIFY(addressee.secrecy() == KContacts::Secrecy(KContacts::Secrecy::Public)); QVERIFY(addressee.logo() == logo); QVERIFY(addressee.photo() == photo); QVERIFY(addressee.sound() == sound); QVERIFY(addressee.emails() == emails); QVERIFY(addressee.keys() == keys); QVERIFY(addressee.categories() == categories); QVERIFY(addressee.customs() == customs); QVERIFY(addressee.changed() == false); QCOMPARE(addressee.kind(), QStringLiteral("foo")); }
bool WorkbenchUtil::SetDepartmentLogoPreference(const QString &logoResource, ctkPluginContext *context) { // The logo must be available in the local filesystem. We check if we have not already extracted the // logo from the plug-in or if this plug-ins timestamp is newer then the already extracted logo timestamp. // If one of the conditions is true, extract it and write it to the plug-in specific storage location. const QString logoFileName = logoResource.mid(logoResource.lastIndexOf('/')+1); const QString logoPath = context->getDataFile("").absoluteFilePath(); bool extractLogo = true; QFileInfo logoFileInfo(logoPath + "/" + logoFileName); if (logoFileInfo.exists()) { // The logo has been extracted previously. Check if the plugin timestamp is newer, which // means it might contain an updated logo. QString pluginLocation = QUrl(context->getPlugin()->getLocation()).toLocalFile(); if (!pluginLocation.isEmpty()) { QFileInfo pluginFileInfo(pluginLocation); if (logoFileInfo.lastModified() > pluginFileInfo.lastModified()) { extractLogo = false; } } } if (extractLogo) { // Extract the logo from the shared library and write it to disk. QFile logo(logoResource); if (logo.open(QIODevice::ReadOnly)) { QFile localLogo(logoPath + "/" + logoFileName); if (localLogo.open(QIODevice::WriteOnly)) { localLogo.write(logo.readAll()); } } } logoFileInfo.refresh(); if (logoFileInfo.exists()) { // Get the preferences service ctkServiceReference prefServiceRef = context->getServiceReference<berry::IPreferencesService>(); berry::IPreferencesService* prefService = NULL; if (prefServiceRef) { prefService = context->getService<berry::IPreferencesService>(prefServiceRef); } if (prefService) { prefService->GetSystemPreferences()->Put("DepartmentLogo", qPrintable(logoFileInfo.absoluteFilePath())); } else { BERRY_WARN << "Preferences service not available, unable to set custom logo."; return false; } } else { BERRY_WARN << "Custom logo at " << logoFileInfo.absoluteFilePath().toStdString() << " does not exist"; return false; } return true; }
MainWindow::MainWindow(QWidget *parent) : QWidget(parent), _ui(new Ui::MainWindow), _tarsnapLogo(this), _menuBar(NULL), _appMenu(NULL), _actionAbout(this), _useSIPrefixes(false), _purgeTimerCount(0), _purgeCountdownWindow(this) { _ui->setupUi(this); _ui->backupListWidget->setAttribute(Qt::WA_MacShowFocusRect, false); _ui->archiveListWidget->setAttribute(Qt::WA_MacShowFocusRect, false); _ui->jobListWidget->setAttribute(Qt::WA_MacShowFocusRect, false); QPixmap logo(":/resources/icons/tarsnap.png"); _tarsnapLogo.setPixmap(logo.scaled(200, 100, Qt::KeepAspectRatio, Qt::SmoothTransformation)); _tarsnapLogo.adjustSize(); _tarsnapLogo.lower(); _tarsnapLogo.show(); Ui::aboutWidget aboutUi; aboutUi.setupUi(&_aboutWindow); aboutUi.versionLabel->setText(tr("version ") + QCoreApplication::applicationVersion()); _aboutWindow.setWindowFlags(Qt::CustomizeWindowHint|Qt::WindowCloseButtonHint); connect(aboutUi.checkUpdateButton, &QPushButton::clicked, [=](){ QDesktopServices::openUrl(QUrl("https://github.com/Tarsnap/tarsnap-gui/releases")); }); if(_menuBar.isNativeMenuBar()) { _actionAbout.setMenuRole(QAction::AboutRole); connect(&_actionAbout, SIGNAL(triggered()), &_aboutWindow, SLOT(show())); _appMenu.addAction(&_actionAbout); _menuBar.addMenu(&_appMenu); } connect(_ui->aboutButton, SIGNAL(clicked()), &_aboutWindow, SLOT(show())); _ui->mainContentSplitter->setCollapsible(0, false); _ui->journalLog->hide(); _ui->archiveDetailsWidget->hide(); _ui->jobDetailsWidget->hide(); connect(&Debug::instance(), SIGNAL(message(QString)), this , SLOT(appendToConsoleLog(QString)) , Qt::QueuedConnection); loadSettings(); // Ui actions _ui->mainTabWidget->setCurrentWidget(_ui->backupTab); _ui->settingsToolbox->setCurrentWidget(_ui->settingsAccountPage); _ui->archiveListWidget->addAction(_ui->actionRefresh); connect(_ui->actionRefresh, SIGNAL(triggered()), _ui->archiveListWidget , SIGNAL(getArchiveList()), Qt::QueuedConnection); _ui->backupListWidget->addAction(_ui->actionClearList); connect(_ui->actionClearList, SIGNAL(triggered()), _ui->backupListWidget , SLOT(clear()), Qt::QueuedConnection); _ui->backupListWidget->addAction(_ui->actionBrowseItems); connect(_ui->actionBrowseItems, SIGNAL(triggered()), this, SLOT(browseForBackupItems())); _ui->jobListWidget->addAction(_ui->actionAddJob); connect(_ui->actionAddJob, SIGNAL(triggered()), this, SLOT(addJobClicked())); _ui->jobListWidget->addAction(_ui->actionJobBackup); connect(_ui->actionJobBackup, SIGNAL(triggered()), _ui->jobListWidget, SLOT(backupSelectedItems())); _ui->settingsTab->addAction(_ui->actionRefreshStats); connect(_ui->actionRefreshStats, SIGNAL(triggered()), this, SIGNAL(getOverallStats())); this->addAction(_ui->actionGoBackup); this->addAction(_ui->actionGoBrowse); this->addAction(_ui->actionGoJobs); this->addAction(_ui->actionGoSettings); this->addAction(_ui->actionGoHelp); connect(_ui->actionGoBackup, &QAction::triggered, [=](){ _ui->mainTabWidget->setCurrentWidget(_ui->backupTab); }); connect(_ui->actionGoBrowse, &QAction::triggered, [=](){ _ui->mainTabWidget->setCurrentWidget(_ui->archivesTab); }); connect(_ui->actionGoJobs, &QAction::triggered, [=](){ _ui->mainTabWidget->setCurrentWidget(_ui->jobsTab); }); connect(_ui->actionGoSettings, &QAction::triggered, [=](){ _ui->mainTabWidget->setCurrentWidget(_ui->settingsTab); }); connect(_ui->actionGoHelp, &QAction::triggered, [=](){ _ui->mainTabWidget->setCurrentWidget(_ui->helpTab); }); connect(_ui->backupListInfoLabel, SIGNAL(linkActivated(QString)), this, SLOT(browseForBackupItems())); connect(_ui->backupButton, SIGNAL(clicked()), this, SLOT(backupButtonClicked())); connect(_ui->appendTimestampCheckBox, SIGNAL(toggled(bool)), this, SLOT(appendTimestampCheckBoxToggled(bool))); connect(_ui->accountMachineUseHostnameButton, SIGNAL(clicked()), this, SLOT(accountMachineUseHostnameButtonClicked())); connect(_ui->accountMachineKeyBrowseButton, SIGNAL(clicked()), this, SLOT(accountMachineKeyBrowseButtonClicked())); connect(_ui->tarsnapPathBrowseButton, SIGNAL(clicked()), this, SLOT(tarsnapPathBrowseButtonClicked())); connect(_ui->tarsnapCacheBrowseButton, SIGNAL(clicked()), this, SLOT(tarsnapCacheBrowseButton())); connect(_ui->repairCacheButton, SIGNAL(clicked()), this, SLOT(repairCacheButtonClicked())); connect(_ui->purgeArchivesButton, SIGNAL(clicked()), this, SLOT(purgeArchivesButtonClicked())); connect(_ui->runSetupWizard, SIGNAL(clicked()), this, SLOT(runSetupWizardClicked())); connect(_ui->expandJournalButton, SIGNAL(toggled(bool)), this, SLOT(expandJournalButtonToggled(bool))); connect(_ui->downloadsDirBrowseButton, SIGNAL(clicked()), this, SLOT(downloadsDirBrowseButtonClicked())); connect(_ui->busyWidget, SIGNAL(clicked()), this, SLOT(cancelRunningTasks())); connect(&_purgeTimer, SIGNAL(timeout()), this, SLOT(purgeTimerFired())); // Settings page connect(_ui->accountUserLineEdit, SIGNAL(editingFinished()), this, SLOT(commitSettings())); connect(_ui->accountMachineLineEdit, SIGNAL(editingFinished()), this, SLOT(commitSettings())); connect(_ui->accountMachineKeyLineEdit, SIGNAL(editingFinished()), this, SLOT(commitSettings())); connect(_ui->tarsnapPathLineEdit, SIGNAL(editingFinished()), this, SLOT(commitSettings())); connect(_ui->tarsnapCacheLineEdit, SIGNAL(editingFinished()), this, SLOT(commitSettings())); connect(_ui->aggressiveNetworkingCheckBox, SIGNAL(toggled(bool)), this, SLOT(commitSettings())); connect(_ui->accountMachineKeyLineEdit, SIGNAL(textChanged(QString)), this, SLOT(validateMachineKeyPath())); connect(_ui->tarsnapPathLineEdit, SIGNAL(textChanged(QString)), this, SLOT(validateTarsnapPath())); connect(_ui->tarsnapCacheLineEdit, SIGNAL(textChanged(QString)), this, SLOT(validateTarsnapCache())); connect(_ui->siPrefixesCheckBox, SIGNAL(toggled(bool)), this, SLOT(commitSettings())); connect(_ui->preservePathsCheckBox, SIGNAL(toggled(bool)), this, SLOT(commitSettings())); connect(_ui->downloadsDirLineEdit, SIGNAL(editingFinished()), this, SLOT(commitSettings())); connect(_ui->traverseMountCheckBox, SIGNAL(toggled(bool)), this, SLOT(commitSettings())); connect(_ui->followSymLinksCheckBox, SIGNAL(toggled(bool)), this, SLOT(commitSettings())); connect(_ui->skipFilesSpinBox, SIGNAL(editingFinished()), this, SLOT(commitSettings())); // Backup and Browse connect(_ui->backupListWidget, SIGNAL(itemTotals(qint64,qint64)), this , SLOT(updateBackupItemTotals(qint64, qint64))); connect(_ui->archiveListWidget, SIGNAL(getArchiveList()), this, SIGNAL(getArchiveList())); connect(this, SIGNAL(archiveList(QList<ArchivePtr >)) , _ui->archiveListWidget, SLOT(addArchives(QList<ArchivePtr >))); connect(_ui->archiveListWidget, SIGNAL(inspectArchive(ArchivePtr)), this , SLOT(displayInspectArchive(ArchivePtr))); connect(_ui->archiveListWidget, SIGNAL(deleteArchives(QList<ArchivePtr>)), this , SIGNAL(deleteArchives(QList<ArchivePtr>))); connect(_ui->archiveListWidget, SIGNAL(restoreArchive(ArchivePtr,ArchiveRestoreOptions)), this, SIGNAL(restoreArchive(ArchivePtr,ArchiveRestoreOptions))); connect(_ui->mainTabWidget, SIGNAL(currentChanged(int)), this, SLOT(currentPaneChanged(int))); // Jobs connect(_ui->addJobButton, SIGNAL(clicked()), this, SLOT(addJobClicked()), Qt::QueuedConnection); connect(_ui->jobDetailsWidget, SIGNAL(cancel()), this, SLOT(hideJobDetails()), Qt::QueuedConnection); connect(_ui->jobDetailsWidget, SIGNAL(jobAdded(JobPtr)), _ui->jobListWidget, SLOT(addJob(JobPtr)), Qt::QueuedConnection); connect(_ui->jobDetailsWidget, SIGNAL(jobAdded(JobPtr)), this, SLOT(displayJobDetails(JobPtr)), Qt::QueuedConnection); connect(_ui->jobDetailsWidget, SIGNAL(inspectJobArchive(ArchivePtr)), this, SLOT(displayInspectArchive(ArchivePtr)), Qt::QueuedConnection); connect(_ui->jobDetailsWidget, SIGNAL(restoreJobArchive(ArchivePtr,ArchiveRestoreOptions)), this, SIGNAL(restoreArchive(ArchivePtr,ArchiveRestoreOptions)), Qt::QueuedConnection); connect(_ui->jobDetailsWidget, SIGNAL(deleteJobArchives(QList<ArchivePtr>)), this, SIGNAL(deleteArchives(QList<ArchivePtr>)), Qt::QueuedConnection); connect(_ui->jobDetailsWidget, SIGNAL(enableSave(bool)), _ui->addJobButton, SLOT(setEnabled(bool)), Qt::QueuedConnection); connect(_ui->jobListWidget, SIGNAL(displayJobDetails(JobPtr)), this, SLOT(displayJobDetails(JobPtr)), Qt::QueuedConnection); connect(_ui->jobListWidget, SIGNAL(backupJob(BackupTaskPtr)), this, SIGNAL(backupNow(BackupTaskPtr)), Qt::QueuedConnection); connect(_ui->jobListWidget, SIGNAL(restoreArchive(ArchivePtr,ArchiveRestoreOptions)), this, SIGNAL(restoreArchive(ArchivePtr,ArchiveRestoreOptions)), Qt::QueuedConnection); connect(_ui->jobListWidget, SIGNAL(deleteJobArchives(QList<ArchivePtr>)), this, SIGNAL(deleteArchives(QList<ArchivePtr>)), Qt::QueuedConnection); //lambda slots to quickly update various UI components connect(_ui->archiveListWidget, &ArchiveListWidget::getArchiveList, [=](){updateStatusMessage(tr("Refreshing archives list..."));}); connect(this, &MainWindow::archiveList, [=](){updateStatusMessage(tr("Refreshing archives list...done"));}); connect(this, &MainWindow::loadArchiveStats, [=](const ArchivePtr archive){updateStatusMessage(tr("Fetching details for archive <i>%1</i>.").arg(archive->name()));}); connect(this, &MainWindow::loadArchiveContents, [=](const ArchivePtr archive){updateStatusMessage(tr("Fetching contents for archive <i>%1</i>.").arg(archive->name()));}); connect(_ui->archiveListWidget, &ArchiveListWidget::deleteArchives, [=](const QList<ArchivePtr> archives){archivesDeleted(archives,false);}); connect(_ui->backupNameLineEdit, &QLineEdit::textChanged, [=](const QString text){ if(text.isEmpty()) { _ui->backupButton->setEnabled(false); _ui->appendTimestampCheckBox->setChecked(false); } else if(_ui->backupListWidget->count()) { _ui->backupButton->setEnabled(true); } }); connect(this, &MainWindow::restoreArchive, [=](const ArchivePtr archive){updateStatusMessage(tr("Restoring archive <i>%1</i>...").arg(archive->name()));}); connect(_ui->downloadsDirLineEdit, &QLineEdit::textChanged, [=](){ QFileInfo file(_ui->downloadsDirLineEdit->text()); if(file.exists() && file.isDir() && file.isWritable()) _ui->downloadsDirLineEdit->setStyleSheet("QLineEdit{color:black;}"); else _ui->downloadsDirLineEdit->setStyleSheet("QLineEdit{color:red;}"); }); connect(_ui->jobListWidget, &JobListWidget::backupJob, [=](BackupTaskPtr backup){ connect(backup, SIGNAL(statusUpdate(const TaskStatus&)), this, SLOT(backupTaskUpdate(const TaskStatus&)), Qt::QueuedConnection); });
int main( int argc, char * argv[] ) { int version = 4; int mype = 0; #ifdef MPI int nranks; MPI_Status stat; MPI_Init(&argc, &argv); MPI_Comm_size(MPI_COMM_WORLD, &nranks); MPI_Comm_rank(MPI_COMM_WORLD, &mype); #endif #ifdef PAPI papi_serial_init(); #endif srand(time(NULL) * (mype+1)); Input input = set_default_input(); read_CLI( argc, argv, &input ); calculate_derived_inputs( &input ); if( mype == 0 ) logo(version); #ifdef OPENMP omp_set_num_threads(input.nthreads); #endif Params params = build_tracks( &input ); CommGrid grid = init_mpi_grid( input ); if( mype == 0 ) print_input_summary(input); float res; float keff = 1.0; int num_iters = 1; double time_transport = 0; double time_flux_exchange = 0; double time_renormalize_flux = 0; double time_update_sources = 0; double time_compute_keff = 0; double start, stop; if(mype==0) { center_print("SIMULATION", 79); border_print(); } for( int i = 0; i < num_iters; i++) { // Transport Sweep start = get_time(); transport_sweep(¶ms, &input); stop = get_time(); time_transport += stop-start; // Domain Boundary Flux Exchange (MPI) #ifdef MPI start = get_time(); fast_transfer_boundary_fluxes(params, input, grid); stop = get_time(); time_flux_exchange += stop-start; #endif // Flux Renormalization start = get_time(); renormalize_flux(params,input, grid); stop = get_time(); time_renormalize_flux += stop-start; // Update Source Regions start = get_time(); res = update_sources(params, input, keff); stop = get_time(); time_update_sources += stop-start; // Calculate K-Effective start = get_time(); keff = compute_keff(params, input, grid); stop = get_time(); time_compute_keff += stop-start; if( mype == 0 ) printf("keff = %f\n", keff); } double time_total = time_transport + time_flux_exchange + time_renormalize_flux + time_update_sources + time_compute_keff; if( mype == 0 ) { border_print(); center_print("RESULTS SUMMARY", 79); border_print(); printf("Transport Sweep Time: %6.2lf sec (%4.1lf%%)\n", time_transport, 100*time_transport/time_total); printf("Domain Flux Exchange Time: %6.2lf sec (%4.1lf%%)\n", time_flux_exchange, 100*time_flux_exchange/time_total); printf("Flux Renormalization Time: %6.2lf sec (%4.1lf%%)\n", time_renormalize_flux, 100*time_renormalize_flux/time_total); printf("Update Source Time: %6.2lf sec (%4.1lf%%)\n", time_update_sources, 100*time_update_sources/time_total); printf("K-Effective Calc Time: %6.2lf sec (%4.1lf%%)\n", time_compute_keff, 100*time_compute_keff/time_total); printf("Total Time: %6.2lf sec\n", time_total); } long tracks_per_second = 2 * input.ntracks/time_transport; #ifdef MPI MPI_Barrier(grid.cart_comm_3d); long global_tps = 0; MPI_Reduce( &tracks_per_second, // Send Buffer &global_tps, // Receive Buffer 1, // Element Count MPI_LONG, // Element Type MPI_SUM, // Reduciton Operation Type 0, // Master Rank grid.cart_comm_3d ); // MPI Communicator MPI_Barrier(grid.cart_comm_3d); tracks_per_second = global_tps; #endif if( mype == 0 ) { printf("Time per Intersection: "); printf("%.2lf ns\n", time_per_intersection( input, time_transport )); border_print(); } free_2D_tracks( params.tracks_2D ); free_tracks( params.tracks ); #ifdef MPI MPI_Finalize(); #endif return 0; }
ContestantApp::ContestantApp ( QWidget* parent ) : QMainWindow ( parent ), m_dlg ( new Ui::contestant_app_dlg ), DISCONNECT_INFORMATION ( tr ( "There will be a penalty for disconnecting." ) ), DISCONNECT_QUESTION ( tr ( "Are you sure you want to exit the program?" ) ), UNAUTH_TEXT ( tr ( "Unable to obtain authorization." ) ), UNAUTH_INFORMATION ( tr ( "Username or password may be incorrect." ) ) { m_login_dlg = new Ui::login_dlg; m_welcome_dlg = new Ui::welcome_dlg; m_elims_dlg = new Ui::elims_dlg; m_semifinals_dlg = new Ui::semifinals_dlg; m_finalsChoice_dlg = new Ui::finalsChoice_dlg; m_finalsIdent_dlg = new Ui::finalsIdent_dlg; m_summary_dlg = new Ui::summary_dlg; m_ending_dlg = new Ui::ending_dlg; m_dlg->setupUi( this ); QPixmap logo("resources/logo.png"); m_dlg->cerb_logo_lbl->setPixmap(logo); //this->hide(); m_welcome_w = new QDialog( this ); m_welcome_dlg->setupUi( m_welcome_w ); m_welcome_w->hide(); m_elims_w = new QDialog( this ); m_elims_dlg->setupUi( m_elims_w ); m_elims_w->hide(); m_semifinals_w = new QDialog( this ); m_semifinals_dlg->setupUi( m_semifinals_w ); m_semifinals_w->hide(); m_finalsChoice_w = new QDialog( this ); m_finalsChoice_dlg->setupUi( m_finalsChoice_w ); m_finalsChoice_w->hide(); m_finalsIdent_w = new QDialog( this ); m_finalsIdent_dlg->setupUi( m_finalsIdent_w ); m_finalsIdent_w->hide(); m_summary_w = new QDialog( this ); m_summary_dlg->setupUi( m_summary_w ); m_summary_w->hide(); m_ending_w = new QDialog( this ); m_ending_dlg->setupUi( m_ending_w ); m_ending_w->hide(); m_login_w = new QDialog( this ); m_login_dlg->setupUi( m_login_w ); m_login_w->show(); m_network = new ContestantNetwork ( this ); timer = new QTimer( this ); connect( m_network, SIGNAL ( onConnect() ), this, SLOT ( onConnect() ) ); connect( m_network, SIGNAL ( onDisconnect() ), this, SLOT ( onDisconnect() ) ); connect( m_network, SIGNAL ( onAuthenticate ( bool ) ), this, SLOT ( onAuthenticate ( bool ) ) ); connect( m_network, SIGNAL ( onContestStateChange ( int, CONTEST_STATUS ) ), this, SLOT ( onContestStateChange ( int, CONTEST_STATUS ) ) ); connect( m_network, SIGNAL ( onQuestionStateChange ( ushort, ushort, QUESTION_STATUS ) ), this, SLOT ( onQuestionStateChange ( ushort, ushort, QUESTION_STATUS ) ) ); connect( m_network, SIGNAL ( onContestTime ( ushort ) ), this, SLOT ( onContestTime ( ushort ) ) ); connect( m_network, SIGNAL ( onQData ( QString ) ), this, SLOT ( onQData ( QString ) ) ); connect( m_network, SIGNAL ( onAData ( bool ) ), this, SLOT ( onAData ( bool ) ) ); connect( m_network, SIGNAL ( onContestError ( ERROR_MESSAGES ) ), this, SLOT ( onContestError ( ERROR_MESSAGES ) ) ); connect( m_network, SIGNAL(onError(QString)), this, SLOT ( onError ( QString ) ) ); // connections for the login dialog connect( m_login_dlg->login_btn, SIGNAL ( clicked() ), this, SLOT ( login() ) ); connect( m_login_dlg->exit_btn, SIGNAL ( clicked() ), this, SLOT ( exit() ) ); // connections for the welcome dialog connect( m_welcome_dlg->start_btn, SIGNAL ( clicked() ), this, SLOT ( welcomeStart() ) ); // connections for the elims and semis dialog connect( m_elims_dlg->prev_btn, SIGNAL ( clicked() ), this, SLOT ( elimSemiPrev() ) ); connect( m_elims_dlg->next_btn, SIGNAL ( clicked() ), this, SLOT ( elimSemiNext() ) ); connect( m_semifinals_dlg->prev_btn, SIGNAL ( clicked() ), this, SLOT ( elimSemiPrev() ) ); connect( m_semifinals_dlg->next_btn, SIGNAL ( clicked() ), this, SLOT ( elimSemiNext() ) ); // connections for summary dialog connect( m_summary_dlg->review_btn, SIGNAL( clicked() ), this, SLOT( review() ) ); connect( m_summary_dlg->submit_btn, SIGNAL( clicked() ), this, SLOT( submit() ) ); // connections for finals dialog connect( m_finalsChoice_dlg->submit_btn, SIGNAL( clicked() ), this, SLOT( finalsSubmit() ) ); connect( m_finalsIdent_dlg->submit_btn, SIGNAL( clicked() ), this, SLOT( finalsSubmit() ) ); // connections for ending dialog connect( m_ending_dlg->exit_btn, SIGNAL( clicked() ), this, SLOT( exit() ) ); // slot for timer connect( timer, SIGNAL( timeout() ), this, SLOT( updateTimer() ) ); // Get the client configuration from XmlUtil qCount = 0; time = 0; status = CONTEST_STOPPED; qStatus = QUESTION_STOPPED; connected = false; loggedIn = false; closing = false; }
int main(void) { char *cadastro_login(); char *cadastro_senha(); char *buscarLivro(); int logo(); int a,b,c,d,nc; int logado; int op; char login[1][20], senha[1][20]; struct cadastro logando[3]; logo(); printf("\t\t1 - FAZER CADASTRO\n\n"); printf("\t\t2 - FAZER LOGIN E CONTINUAR COM SUA RESERVA.\n\n"); printf("\t\t3 - VOLTAR A PAGINA DE BUSCA.\n\n"); printf("\t\t4 - SAIR DO SISTEMA.\n\n"); scanf("%d", &op); /* inicio de uma estrutura de decisão: CADASTRAR USUÁRIO, LOGAR NO SISTEMA OU VOLTAR A BUSCA DE LIVROS. */ if (op == 1) { printf("\nDigite o numero de usuarios que deseja cadastrar.: \n"); scanf("%d",&nc); for (a=0;a<nc;a++){ memcpy(logando[a].user, cadastro_login(), 50); memcpy(logando[a].pass, cadastro_senha(), 50); } }else if (op == 3){ exit(0);//buscarLivro(); //Voltar para a pagina de buscac. }else if (op == 4){ exit(0); //Sai do Sistema. } system("cls"); printf("\n\tLogon\n"); printf("\n\tLogin: "******" %s",login[0]); printf("\n\tSenha: "); scanf(" %s",senha[0]); for (c=0;c<3;c++) { if ((strcmp(login[0],logando[c].user)!=0) || (strcmp(senha[0],logando[c].pass)!=0)) { logado = 1; //login e/ou senha incorretos } else if(strcmp(login[0],logando[c].user)==0) { if (strcmp(senha[0],logando[c].pass)==0) { logado = 2; //logado com sucesso break; } } } if (logado==1) { printf("\nLogin e/ou senha incorretos(s)\n"); system("pause"); system("cls"); main(); } else if (logado==2) { printf("\nLogado com sucesso!\nBem-vindo(a) %s\n",login[0]); } return 0; }
/****************************************************************************** * main * * * * Main function * ******************************************************************************/ int main(int argc, char *argv[]) { int error = 0; l4_threadid_t dummy_l4id = L4_NIL_ID; CORBA_Environment _env = dice_default_environment; /* init */ do_args(argc, argv); my_l4id = l4thread_l4_id( l4thread_myself() ); LOG("Hello, I'm running as "l4util_idfmt, l4util_idstr(my_l4id)); /* ask for 'con' (timeout = 5000 ms) */ if (names_waitfor_name(CON_NAMES_STR, &con_l4id, 50000) == 0) { LOG("PANIC: %s not registered at names", CON_NAMES_STR); enter_kdebug("panic"); } if (con_if_openqry_call(&con_l4id, MY_SBUF_SIZE, 0, 0, L4THREAD_DEFAULT_PRIO, &vc_l4id, CON_VFB, &_env)) enter_kdebug("Ouch, open vc failed"); if (con_vc_smode_call(&vc_l4id, CON_OUT, &dummy_l4id, &_env)) enter_kdebug("Ouch, setup vc failed"); if (con_vc_graph_gmode_call(&vc_l4id, &gmode, &xres, &yres, &bits_per_pixel, &bytes_per_pixel, &bytes_per_line, &accel_flags, &fn_x, &fn_y, &_env)) enter_kdebug("Ouch, graph_gmode failed"); if (bytes_per_pixel != 2) { printf("Graphics mode not 2 bytes/pixel, exiting\n"); con_vc_close_call(&vc_l4id, &_env); exit(0); } if (create_logo()) enter_kdebug("Ouch, logo creation failed"); while (!error) { if ((error = clear_screen())) enter_kdebug("Ouch, clear_screen failed"); if ((error = logo())) enter_kdebug("Ouch, logo failed"); l4_sleep(2000); } if (con_vc_close_call(&vc_l4id, &_env)) enter_kdebug("Ouch, close vc failed?!"); LOG("Finally closed vc"); LOG("Going to bed ..."); l4_sleep(-1); return 0; }