SkOSWindow* create_sk_window(void* hwnd, int argc, char** argv) { printf("Started\n"); SkCommandLineFlags::Parse(argc, argv); // Get the default Isolate created at startup. Isolate* isolate = Isolate::GetCurrent(); Global* global = new Global(isolate); // Set up things to look like a browser by creating // a console object that invokes our print function. const char* startupScript = "function Console() {}; \n" "Console.prototype.log = function() { \n" " var args = Array.prototype.slice.call(arguments).join(' '); \n" " print(args); \n" "}; \n" "console = new Console(); \n"; if (!global->parseScript(startupScript)) { printf("Failed to parse startup script: %s.\n", FLAGS_infile[0]); exit(1); } const char* script = "function onDraw(canvas) { \n" " canvas.fillStyle = '#00FF00'; \n" " canvas.fillRect(20, 20, 100, 100); \n" " canvas.inval(); \n" "} \n"; SkAutoTUnref<SkData> data; if (FLAGS_infile.count()) { data.reset(SkData::NewFromFileName(FLAGS_infile[0])); script = static_cast<const char*>(data->data()); } if (NULL == script) { printf("Could not load file: %s.\n", FLAGS_infile[0]); exit(1); } Path2D::AddToGlobal(global); if (!global->parseScript(script)) { printf("Failed to parse file: %s.\n", FLAGS_infile[0]); exit(1); } JsContext* jsContext = new JsContext(global); if (!jsContext->initialize()) { printf("Failed to initialize.\n"); exit(1); } SkV8ExampleWindow* win = new SkV8ExampleWindow(hwnd, jsContext); global->setWindow(win); return win; }
// Constructor. Thys happens when the class is declared. NotebookProperties::NotebookProperties(QWidget *parent) : QDialog(parent) { okPressed = false; setWindowTitle(tr("Notebook")); setWindowIcon(global.getIconResource(":notebookSmallIcon")); setLayout(&grid); syncBox.setText(tr("Synchronized")); syncBox.setChecked(true); syncBox.setEnabled(false); defaultNotebook.setText(tr("Default")); defaultNotebook.setChecked(false); defaultNotebook.setEnabled(true); connect(&name, SIGNAL(textChanged(const QString&)), this, SLOT(validateInput())); nameLabel.setText(tr("Name")); queryGrid.addWidget(&nameLabel, 1,1); queryGrid.addWidget(&name, 1, 2); queryGrid.addWidget(&syncBox, 2,2); queryGrid.addWidget(&defaultNotebook, 3,2); // queryGrid.setContentsMargins(10, 10, -10, -10); grid.addLayout(&queryGrid,1,1); ok.setText(tr("OK")); connect(&ok, SIGNAL(clicked()), this, SLOT(okButtonPressed())); cancel.setText(tr("Cancel")); connect(&cancel, SIGNAL(clicked()), this, SLOT(cancelButtonPressed())); buttonGrid.addWidget(&ok, 1, 1); buttonGrid.addWidget(&cancel, 1,2); grid.addLayout(&buttonGrid,2,1); this->setFont(global.getGuiFont(font())); }
LoginDialog::LoginDialog(QWidget *parent) : QDialog(parent) { okPressed = false; setWindowTitle(tr("NixNote Login")); setWindowIcon(global.getIconResource(":passwordIcon")); setLayout(&grid); password.setEchoMode(QLineEdit::Password); connect(&userid, SIGNAL(textChanged(const QString&)), this, SLOT(validateInput())); connect(&password, SIGNAL(textChanged(const QString&)), this, SLOT(validateInput())); useridLabel.setText(tr("Userid")); passwordLabel.setText(tr("Password")); passwordGrid.addWidget(&useridLabel, 1,1); passwordGrid.addWidget(&userid, 1, 2); passwordGrid.addWidget(&passwordLabel, 2,1); passwordGrid.addWidget(&password, 2, 2); passwordGrid.setContentsMargins(10, 10, -10, -10); grid.addLayout(&passwordGrid,1,1); ok.setText(tr("OK")); if (global.password == "" and global.username == "") ok.setEnabled(false); connect(&ok, SIGNAL(clicked()), this, SLOT(okButtonPressed())); cancel.setText(tr("Cancel")); connect(&cancel, SIGNAL(clicked()), this, SLOT(cancelButtonPressed())); buttonGrid.addWidget(&ok, 1, 1); buttonGrid.addWidget(&cancel, 1,2); grid.addLayout(&buttonGrid,2,1); grid.setSizeConstraint( QLayout::SetFixedSize ); this->setFont(global.getGuiFont(font())); }
/* method: setDataRootDirectory of class Global */ static int tolua_LuaAPI_Global_setDataRootDirectory00(lua_State* tolua_S) { #ifndef TOLUA_RELEASE tolua_Error tolua_err; if ( !tolua_isusertype(tolua_S,1,"Global",0,&tolua_err) || !tolua_isstring(tolua_S,2,0,&tolua_err) || !tolua_isnoobj(tolua_S,3,&tolua_err) ) goto tolua_lerror; else #endif { Global* self = (Global*) tolua_tousertype(tolua_S,1,0); const char* s = ((const char*) tolua_tostring(tolua_S,2,0)); #ifndef TOLUA_RELEASE if (!self) tolua_error(tolua_S,"invalid 'self' in function 'setDataRootDirectory'",NULL); #endif { self->setDataRootDirectory(s); } } return 0; #ifndef TOLUA_RELEASE tolua_lerror: tolua_error(tolua_S,"#ferror in function 'setDataRootDirectory'.",&tolua_err); return 0; #endif }
ScatterPlotWidget::ScatterPlotWidget(QWidget *parent) : QWidget(parent), ui(new Ui::ScatterPlotWidget), selectedTrips(NULL), selectionGraph(NULL) { ui->setupUi(this); attrib1 = getAttrib(ui->comboBox->currentText()); attrib2 = getAttrib(ui->comboBox_2->currentText()); // Global* global = Global::getInstance(); int numExtraFields = global->numExtraFields(); for(int i = 0 ; i < numExtraFields ; ++i){ ExtraField field = global->getExtraField(i); if(field.active){ ui->comboBox->addItem(field.screenName); ui->comboBox_2->addItem(field.screenName); } } // connect slots that takes care that when an axis is selected, only that direction can be dragged and zoomed: connect(ui->customPlot, SIGNAL(mousePress(QMouseEvent*)), this, SLOT(mousePress())); connect(ui->customPlot, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(mouseWheel())); // updatePlot(); }
void NMainMenuBar::createThemeMenu(QMenu *parentMenu) { QMenu *menu = parentMenu->addMenu(tr("Theme")); QStringList list = global.getThemeNames(); QFont f = global.getGuiFont(QFont()); global.settings->beginGroup(INI_GROUP_APPEARANCE); QString userTheme = global.settings->value("themeName", DEFAULT_THEME_NAME).toString(); global.settings->endGroup(); // Setup themes (we expect to find the DEFAULT_THEME_NAME theme as first one) for (int i = 0; i < list.size(); i++) { QString themeName(list[i]); if ((i == 0) && (QString::compare(themeName, DEFAULT_THEME_NAME, Qt::CaseInsensitive) != 0)) { QLOG_ERROR() << "First theme is expected to be " << DEFAULT_THEME_NAME; } QAction *themeAction = new QAction(themeName, this); themeAction->setData(themeName); themeAction->setCheckable(true); themeAction->setFont(f); connect(themeAction, SIGNAL(triggered()), parent, SLOT(reloadIcons())); if (themeName == userTheme) { themeAction->setChecked(true); } themeActions.append(themeAction); } menu->addActions(themeActions); menu->setFont(f); }
int Player::getScore() { Global *g = Global::get(); int computedScore = 0; for (Item &item : items) { computedScore += item.getValue(); } return (computedScore * g->getDifficulty() + getSteps()); }
int main(int argc, char **argv) { // expecting a filename if (argc < 2) { fprintf(stderr, "You have to specify at least one filename\n"); return -1; } bool ret = true; { JSLock lock; // create interpreter w/ global object Global* global = new Global(); RefPtr<Interpreter> interp = new Interpreter(global); ExecState *exec = interp->globalExec(); MyObject *myObject = new MyObject(); RefPtr<RootObject> root = RootObject::create(0, interp); global->put(exec, Identifier("myInterface"), Instance::createRuntimeObject(Instance::BalLanguage, (void *)myObject, root)); for (int i = 1; i < argc; i++) { const char *code = readJavaScriptFromFile(argv[i]); if (code) { // run Completion comp(interp->evaluate("", 0, code)); /*if (comp.complType() == Throw) { JSValue *exVal = comp.value(); char *msg = exVal->toString(exec).ascii(); int lineno = -1; if (exVal->type() == ObjectType) { JSValue *lineVal = exVal->getObject()->get(exec, Identifier("line")); if (lineVal->type() == NumberType) lineno = int(lineVal->toNumber(exec)); } if (lineno != -1) fprintf(stderr,"Exception, line %d: %s\n",lineno,msg); else fprintf(stderr,"Exception: %s\n",msg); ret = false; } else if (comp.complType() == ReturnValue) { char *msg = comp.value()->toString(interp->globalExec()).ascii(); fprintf(stderr,"Return value: %s\n",msg); }*/ } } delete myObject; } // end block, so that Interpreter and global get deleted return ret ? 0 : 3; }
//***************************************** //* This class is used to connect to the //* database. //***************************************** DatabaseConnection::DatabaseConnection(QString connection) { dbLocked = Unlocked; this->connection = connection; QLOG_DEBUG() << "SQL drivers available: " << QSqlDatabase::drivers(); QLOG_TRACE() << "Adding database SQLITE"; conn = QSqlDatabase::addDatabase("QSQLITE", connection); QLOG_TRACE() << "Setting DB name"; conn.setDatabaseName(global.fileManager.getDbDirPath("nixnote.db")); QLOG_TRACE() << "Opening database"; if (!conn.open()) { QLOG_ERROR() << "Error opening database: " << conn.lastError(); exit(16); } if (connection == "nixnote") global.db = this; QLOG_TRACE() << "Preparing tables"; // Start preparing the tables configStore = new ConfigStore(this); dataStore = new DataStore(this); NSqlQuery tempTable(this); // tempTable.exec("pragma cache_size=8096"); // tempTable.exec("pragma page_size=8096"); tempTable.exec("pragma busy_timeout=50000"); tempTable.exec("pragma journal_mode=wal"); // tempTable.exec("pragma SQLITE_THREADSAFE=2"); if (connection == "nixnote") { tempTable.exec("pragma COMPILE_OPTIONS"); QLOG_DEBUG() << "*** SQLITE COMPILE OPTIONS ***"; while (tempTable.next()) { QLOG_DEBUG() << tempTable.value(0).toString(); } int value = global.getDatabaseVersion(); if (value < 2) { QLOG_DEBUG() << "*****************"; QLOG_DEBUG() << "Upgrading Database"; DatabaseUpgrade dbu; dbu.fixSql(); } global.setDatabaseVersion(2); } QLOG_TRACE() << "Creating filter table"; tempTable.exec("Create table if not exists filter (lid integer)"); tempTable.exec("delete from filter"); QLOG_TRACE() << "Adding to filter table"; tempTable.exec("insert into filter select distinct lid from NoteTable;"); QLOG_TRACE() << "Addition complete"; tempTable.finish(); }
TreeWidgetEditor::TreeWidgetEditor(QTreeWidget *parent) : QLineEdit(parent) { this->parent = parent; this->setFont(global.getGuiFont(font())); lid = 0; stackName = ""; connect(this, SIGNAL(returnPressed()), SLOT(textChanged())); QString css = global.getThemeCss("treeWidgetEditorCss"); if (css!="") this->setStyleSheet(css); }
void LocalePreferences::saveValues() { int dateFormat = getDateFormatNo(); int timeFormat = getTimeFormatNo(); QString translation = getTranslation(); global.settings->beginGroup(INI_GROUP_LOCALE); global.settings->setValue("translation", translation); global.settings->setValue("dateFormat", dateFormat); global.settings->setValue("timeFormat", timeFormat); global.settings->endGroup(); global.setDateFormat(dateFormat); global.setTimeFormat(timeFormat); }
PopplerViewer::PopplerViewer(const QString &mimeType, const QString &reslid, QWidget *parent) : QWidget(parent) { this->mimeType = mimeType; this->lid = reslid.toInt(); printImageFile = global.fileManager.getTmpDirPath() + QString::number(lid) +QString("-print.png"); QString file = global.fileManager.getDbaDirPath() + reslid +".pdf"; doc = Poppler::Document::load(file); if (doc == NULL || doc->isLocked()) return; currentPage = 0; totalPages = doc->numPages(); image = new QImage(doc->page(currentPage)->renderToImage()); scene = new QGraphicsScene(); view = new PopplerGraphicsView(scene); view->filename = file; item = new QGraphicsPixmapItem(QPixmap::fromImage(*image)); image->save(printImageFile); // This is in case we want to print a note. Otherwise it isn't used. scene->addItem(item); view->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum); QHBoxLayout *buttonLayout = new QHBoxLayout(); pageLabel = new QLabel(tr("Page ") +QString::number(currentPage+1) + QString(tr(" of ") +QString::number(totalPages)), this); pageLeft = new QPushButton(); pageRight = new QPushButton(); pageRight->setMaximumWidth(30); pageLeft->setMaximumWidth(30); pageLeft->setIcon(global.getIconResource(":leftArrowIcon")); pageRight->setIcon(global.getIconResource(":rightArrowIcon")); buttonLayout->addStretch(100); buttonLayout->addWidget(pageLeft); buttonLayout->addWidget(pageLabel); buttonLayout->addWidget(pageRight); buttonLayout->addStretch(100); QVBoxLayout *layout = new QVBoxLayout(this); layout->addLayout(buttonLayout); layout->addWidget(view); this->setLayout(layout); connect(pageRight, SIGNAL(clicked()), this, SLOT(pageRightPressed())); connect(pageLeft, SIGNAL(clicked()), this, SLOT(pageLeftPressed())); if (totalPages == 1) { pageRight->setEnabled(false); } pageLeft->setEnabled(false); }
// Load the list of font names void EditorButtonBar::loadFontNames() { if (global.forceWebFonts){ QStringList fontFamilies; fontFamilies.append("Gotham"); fontFamilies.append("Georgia"); fontFamilies.append("Helvetica"); fontFamilies.append("Courier New"); fontFamilies.append("Times New Roman"); fontFamilies.append("Times"); fontFamilies.append("Trebuchet"); fontFamilies.append("Verdana"); fontFamilies.sort(); bool first = true; for (int i = 0; i < fontFamilies.size(); i++) { fontNames->addItem(fontFamilies[i], fontFamilies[i].toLower()); QFont f; global.getGuiFont(f); f.setFamily(fontFamilies[i]); fontNames->setItemData(i, QVariant(f), Qt::FontRole); if (first) { loadFontSizeComboBox(fontFamilies[i]); first=false; } } return; } // Load up the list of font names QFontDatabase fonts; QStringList fontFamilies = fonts.families(); fontFamilies.append(tr("Times")); fontFamilies.sort(); bool first = true; for (int i = 0; i < fontFamilies.size(); i++) { fontNames->addItem(fontFamilies[i], fontFamilies[i].toLower()); QFont f; global.getGuiFont(f); f.setFamily(fontFamilies[i]); if (global.previewFontsInDialog()) fontNames->setItemData(i, QVariant(f), Qt::FontRole); if (first) { loadFontSizeComboBox(fontFamilies[i]); first=false; } } }
LocationEditor::LocationEditor(QWidget *parent) : QToolButton(parent) { QPalette pal; pal.setColor(backgroundRole(), QPalette::Base); setPalette(pal); this->setFont(global.getGuiFont(font())); inactiveColor = "QToolButton {background-color: transparent; border-radius: 0px; border:none; margin 0px; padding: 4px} "; this->setCursor(Qt::PointingHandCursor); this->setStyleSheet(inactiveColor); defaultText = QString(tr("Click to set location...")); this->setText(defaultText); actionMenu = new QMenu(); editAction = actionMenu->addAction(tr("Edit...")); clearAction = actionMenu->addAction(tr("Clear")); viewAction = actionMenu->addAction(tr("View on map")); connect(editAction, SIGNAL(triggered()), this, SLOT(buttonClicked())); connect(viewAction, SIGNAL(triggered()), this, SLOT(viewClicked())); connect(clearAction, SIGNAL(triggered()), this, SLOT(clearClicked())); setAutoRaise(false); setMenu(actionMenu); this->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); this->reloadIcons(); connect(this, SIGNAL(clicked()), this, SLOT(buttonClicked())); hide(); }
// Delete an item from the tree. We really just hide it. void NTagView::deleteRequested() { QList<QTreeWidgetItem*> items = selectedItems(); qint32 lid = items[0]->data(NAME_POSITION, Qt::UserRole).toInt(); if (global.confirmDeletes()) { QMessageBox msgBox; msgBox.setIcon(QMessageBox::Question); msgBox.setText(tr("Are you sure you want to delete this tag?")); msgBox.setWindowTitle(tr("Verify Delete")); msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); msgBox.setDefaultButton(QMessageBox::No); int ret = msgBox.exec(); if (ret == QMessageBox::No) return; } TagTable table(global.db); table.deleteTag(lid); // NTagViewItem *ptr = (NTagViewItem*)items[0]; // ptr->setHidden(true); // Now remove it in the datastore NTagViewItem *ptr = dataStore.take(items[0]->data(NAME_POSITION, Qt::UserRole).toInt()); emit(tagDeleted(lid, ptr->data(NAME_POSITION, Qt::DisplayRole).toString())); delete ptr; }
// Delete an item from the tree. We really just hide it. void NTagView::deleteRequested() { QList<QTreeWidgetItem*> items = selectedItems(); if (global.confirmDeletes()) { QMessageBox msgBox; msgBox.setIcon(QMessageBox::Question); if (items.size() == 1) msgBox.setText(tr("Are you sure you want to delete this tag?")); else msgBox.setText(tr("Are you sure you want to delete all selected tags?")); msgBox.setWindowTitle(tr("Verify Delete")); msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); msgBox.setDefaultButton(QMessageBox::No); int ret = msgBox.exec(); if (ret == QMessageBox::No) return; } for (int i=0; i<items.size(); i++) { // Delete from the DB qint32 lid = items[i]->data(NAME_POSITION, Qt::UserRole).toInt(); TagTable table(global.db); table.deleteTag(lid); // Now remove selected tags NTagViewItem *ptr = dataStore.take(items[i]->data(NAME_POSITION, Qt::UserRole).toInt()); QList<QTreeWidgetItem*> children = ptr->takeChildren(); ptr->parent()->addChildren(children); ptr->parent()->removeChild(ptr); emit(tagDeleted(lid, ptr->data(NAME_POSITION, Qt::DisplayRole).toString())); delete ptr; } }
QSObject QuickInterpreter::object(const QString &name) const { QSObject g = env()->globalObject(); Global *global = (Global*)&g; // ### ugly QSObject obj; if (name.isEmpty()) { obj = g; } else { int p = name.lastIndexOf('.'); if (p == -1) obj = global->get(name); else obj = global->getQualified(name); } return obj; }
NoteHistorySelect::NoteHistorySelect(QWidget *parent) : QDialog(parent) { importPressed = false; this->setWindowTitle(tr("Note History")); cancelButton.setText(tr("Cancel")); importButton.setText(tr("Import")); importButton.setEnabled(false); replace = new QCheckBox(); replace->setCheckable(true); replace->setChecked(false); replace->setText(tr("Replace current note?")); connect(&importButton, SIGNAL(clicked()), this, SLOT(importButtonPressed())); connect(&cancelButton, SIGNAL(clicked()), this, SLOT(cancelButtonPressed())); connect(&list, SIGNAL(itemSelectionChanged()), this, SLOT(enableImport())); QVBoxLayout *mainLayout = new QVBoxLayout(this); QHBoxLayout *entryLayout = new QHBoxLayout(this); entryLayout->addWidget(&list); entryLayout->addWidget(&importButton); mainLayout->addLayout(entryLayout); mainLayout->addWidget(replace); this->setLayout(mainLayout); QHBoxLayout *buttonLayout = new QHBoxLayout(this); buttonLayout->addWidget(&importButton); buttonLayout->addWidget(&cancelButton); mainLayout->addLayout(buttonLayout); this->setFont(global.getGuiFont(font())); }
void NMainMenuBar::createSortMenu(QMenu *parentMenu) { sortMenu = parentMenu->addMenu(tr("Sort notes by")); QFont f = global.getGuiFont(QFont()); QActionGroup *menuActionGroup = new QActionGroup(this); menuActionGroup->setExclusive(true); addSortAction(sortMenu, menuActionGroup, f, tr("Relevance, Date updated [desc]"), INI_VALUE_SORTORDER_DEFAULT); addSortAction(sortMenu, menuActionGroup, f, tr("Relevance, Date updated [asc]"), "relevance desc, dateUpdated asc"); addSortAction(sortMenu, menuActionGroup, f, tr("Relevance, Date created [desc]"), "relevance desc, dateCreated desc"); addSortAction(sortMenu, menuActionGroup, f, tr("Relevance, Date created [asc]"), "relevance desc, dateCreated asc"); addSortAction(sortMenu, menuActionGroup, f, tr("Relevance, Title [desc]"), "relevance desc, title desc"); addSortAction(sortMenu, menuActionGroup, f, tr("Relevance, Title [asc]"), "relevance desc, title asc"); sortMenu->addSeparator(); addSortAction(sortMenu, menuActionGroup, f, tr("Date updated [desc]"), "dateUpdated desc"); addSortAction(sortMenu, menuActionGroup, f, tr("Date updated [asc]"), "dateUpdated asc"); addSortAction(sortMenu, menuActionGroup, f, tr("Date created [desc]"), "dateCreated desc"); addSortAction(sortMenu, menuActionGroup, f, tr("Date created [asc]"), "dateCreated asc"); addSortAction(sortMenu, menuActionGroup, f, tr("Title [desc]"), "title desc"); addSortAction(sortMenu, menuActionGroup, f, tr("Title [asc]"), "title asc"); addSortAction(sortMenu, menuActionGroup, f, tr("Size [desc]"), "size desc, dateUpdated desc"); addSortAction(sortMenu, menuActionGroup, f, tr("Has todo [desc]"), "hasTodo desc, dateUpdated desc"); addSortAction(sortMenu, menuActionGroup, f, tr("Unsynced first"), "isDirty desc, dateUpdated desc"); sortMenu->setFont(f); }
void preGameTracker(int x, int y) { globe.getGlobal()->mX = x; globe.getGlobal()->mY = y; if (x > 1.5) { menu = ( y / 150); } }
//**************************************************** //* Constructor //**************************************************** TagEditorNewTag::TagEditorNewTag(QWidget *parent) : QLineEdit(parent) { QLOG_TRACE_IN() << typeid(*this).name(); account = 0; this->setCursor(Qt::PointingHandCursor); // Setup the note title editor QPalette pal; pal.setColor(backgroundRole(), QPalette::Base); setPalette(pal); this->setFont(global.getGuiFont(font())); inactiveColor = "QLineEdit {background-color: transparent; border-radius: 0px;} "; activeColor = "QLineEdit {border: 1px solid #808080; background-color: white; border-radius: 4px;} "; this->setStyleSheet(inactiveColor); this->setPlaceholderText(tr("Click to add tag...")); connect(this, SIGNAL(textChanged(QString)), this, SLOT(textModified(QString))); // connect(this, SIGNAL(focussed(bool)), this, SLOT(gainedFocus(bool))); completer = new QCompleter(this); connect(completer, SIGNAL(activated(QString)), this, SLOT(mouseCompleterSelection(QString))); loadCompleter(); connect(this, SIGNAL(returnPressed()), this, SLOT(enterPressed())); hide(); QLOG_TRACE_OUT() << typeid(*this).name(); }
void NoteHistorySelect::loadData(QList<NoteVersionId> &versions) { // Add the current generation QListWidgetItem *item = new QListWidgetItem(&list); item->setData(Qt::UserRole, 0); QString text = tr("Current copy on Evernote"); item->setText(text); list.addItem(item); this->versions = &versions; for (int i=0; i<versions.size(); i++) { QListWidgetItem *item = new QListWidgetItem(&list); item->setData(Qt::UserRole, versions.at(i).updateSequenceNum); QString text; QDateTime timestamp; timestamp.setTime_t(versions.at(i).saved/1000); if (timestamp.date() == QDate::currentDate()) text = tr("Today") +" " + timestamp.time().toString(Qt::SystemLocaleShortDate); if (timestamp.date() == QDate::currentDate().addDays(-1)) text = tr("Yesterday") +" " + timestamp.time().toString(Qt::SystemLocaleShortDate); text = timestamp.toString(global.getDateTimeFormat()); text = text + " : "+ versions.at(i).title; item->setText(text); list.addItem(item); } }
void Global::loadScenes() { string sz_scenes = global.readFile("./config/scenes.cfg"); JSONValue *j_val = JSON::parse(sz_scenes.c_str()); ASSERT_WITH_CODE(j_val != NULL, "Config file corrupted!...", return); JSONObject j_scenes_obj = j_val->asObject(); _scenes.clear(); for(JSONObject::iterator it_scene = j_scenes_obj.begin(); it_scene != j_scenes_obj.end(); ++it_scene) { map<string, map<string, Value> > sources; JSONObject j_sources_obj = it_scene->second->asObject(); for(JSONObject::iterator it_sources = j_sources_obj.begin(); it_sources != j_sources_obj.end(); ++it_sources) { map<string, Value> source_settings; JSONObject j_source_settings_obj = it_sources->second->asObject(); for(JSONObject::iterator it_source_settings = j_source_settings_obj.begin(); it_source_settings != j_source_settings_obj.end(); ++it_source_settings) { Value vec(it_source_settings->second->asNumber()); source_settings[it_source_settings->first] = vec; } sources[it_sources->first] = source_settings; } _scenes[it_scene->first] = sources; } delete j_val; }
void FavoritesView::buildTreeEntry(FavoritesViewItem *parent, const FavoritesRecord *record) { FavoritesViewItem *item = new FavoritesViewItem(); item->setFlags(item->flags() & ~Qt::ItemIsDropEnabled); item->record.lid = record->lid; item->setData(NAME_POSITION, Qt::UserRole, record->lid); item->record.type = record->type; item->record.target = record->target; item->record.order = record->order; item->setText(NAME_POSITION, record->displayName); switch (record->type) { case FavoritesRecord::Tag : item->setIcon(NAME_POSITION, global.getIconResource(":tagIcon")); break; case FavoritesRecord::Note : item->setIcon(NAME_POSITION, global.getIconResource(":newNoteIcon")); break; case FavoritesRecord::ConflictNotebook : item->setIcon(NAME_POSITION, global.getIconResource(":notebookConflictIcon")); break; case FavoritesRecord::LinkedNotebook : item->setIcon(NAME_POSITION, global.getIconResource(":notebookLinkedIcon")); break; case FavoritesRecord::LinkedStack : item->setIcon(NAME_POSITION, global.getIconResource(":silhouetteIcon")); break; case FavoritesRecord::LocalNotebook : item->setIcon(NAME_POSITION, global.getIconResource(":locaNotebookIcon")); break; case FavoritesRecord::Search : item->setIcon(NAME_POSITION, global.getIconResource(":searchIcon")); break; case FavoritesRecord::SharedNotebook : item->setIcon(NAME_POSITION, global.getIconResource(":notebookSharedIcon")); break; case FavoritesRecord::SynchronizedNotebook : item->setIcon(NAME_POSITION, global.getIconResource(":notebookSmallIcon")); break; case FavoritesRecord::NotebookStack : item->setIcon(NAME_POSITION, global.getIconResource(":stackIcon")); break; } dataStore.insert(record->lid, item); if (record->target.toInt() > 0) targetStore.insert(record->target.toInt(), item); parent->addChild(item); }
void Mplayer::playback_ended() { if (running) { get_class<Movie>(dgettext("mms-movie-mplayer", "Video"))->set_movie_playback(false); Global *global = S_Global::get_instance(); global->set_playback("Audio"); broken_pipe=true; running = false; Render *render = S_Render::get_instance(); render->device->hide_video(); run::close_pipe(p); ScreenUpdater *screen_updater = S_ScreenUpdater::get_instance(); screen_updater->timer.deactivate("mplayer status"); } }
void Menu::render(Global &global) { gfx->SelectTexture(0, menu_object); gfx->SelectVertexBuffer(Model::quad_vertex); gfx->SelectIndexBuffer(Model::quad_index); for(unsigned int i = 0; i < menu_list.size(); i++) { menu_t *item = menu_list[i]; if (item->state == menu_state) { if (item->flag & 1) { gfx->clear(); global.Select(); global.Params(matrix, 0); gfx->DrawArrayTri(0, 0, 6, 4); // gfx->SelectShader(0); // gfx->DeselectTexture(0); gfx->cleardepth(); } break; } } for(unsigned int i = 0; i < menu_list.size(); i++) { menu_t *item = menu_list[i]; if (item->state == menu_state) { if (item->flag & 2) { // draw model } else if (item->flag & 4) { // draw texture } else { vec3 color(item->color[0], item->color[1], item->color[2]); draw_text(item->msg, item->position[0], item->position[1], item->scale, color); } } } }
void Mplayer::setup_playback(const std::pair<bool, Pipe>& result, bool window) { if (result.first) { Global *global = S_Global::get_instance(); global->set_playback("Movie"); p = result.second; broken_pipe = false; running = true; if (window) in_fullscreen = false; else in_fullscreen = true; get_class<Movie>(dgettext("mms-movie-mplayer", "Video"))->set_movie_playback(true); } }
Global<Threadpool> Threadpool::CreateCustomPool(DWORD minThread, DWORD maxThread) { Global<Threadpool> pool = make_global<Threadpool>(); #ifndef PLATFORM_UNIX pool->InitializeCustomPool(); if (minThread) { pool->SetThreadMin(minThread); } if (maxThread) { pool->SetThreadMax(maxThread); } #endif return pool; }
Global::Lock::Lock ( Global& object ) : myLocation(::GlobalLock(object.handle())) { if ( myLocation == 0 ) { const ::DWORD error = ::GetLastError(); UNCHECKED_WIN32C_ERROR(GlobalLock, error); } }
void Kunder::nyKunde() { /* Kunde* temp; temp = new Kunde(++sisteBrukt); kundeListe->add(temp); */ //Midlertidlig variabel Kunde* temp; //Lager en ny kunde og legger kunden til i kundelisten temp = new Kunde(++sisteBrukt); kundeListe->add(temp); char navn[STRLEN]; char adresse[STRLEN]; char postNr[STRLEN]; char telefon[STRLEN]; char epost[STRLEN]; //Brukeren skriver inn navnet på kunden cout << "Legg inn ny kunde: \nNavn:"; cin.ignore(); cin.getline(navn, STRLEN); temp->setNavn(navn); //Brukeren skriver inn adressen på kunden cout << "\nAddresse: "; cin.ignore(); cin.getline(adresse, STRLEN); temp->setAddresse(adresse); //Brukeren skriver inn postnummeret på kunden cout << "\nPostnummer: "; cin.ignore(); cin.getline(postNr, STRLEN); temp->setPostNr(postNr); //Brukeren skriver inn telefonnummeret på kunden cout << "\nTelefon: "; cin.ignore(); cin.getline(telefon, STRLEN); temp->setTelefon(telefon); //Brukeren skriver inn eposten på kunden cout << "\nEpost: "; cin.ignore(); cin.getline(epost, STRLEN); temp->setEpost(epost); //Kundenummeret blir skrevet ut cin.ignore(); cout << "Kunden er nå opprettet med kundenummer" << sisteBrukt << "\n\n"; temp->setKundeNr(sisteBrukt); gl.skrivMeny(); }