MCPcopy Create free account
hub / github.com/baumgarr/nixnote2 / screenCapture

Method screenCapture

nixnote.cpp:3157–3232  ·  view source on GitHub ↗

Screen capture request.

Source from the content-addressed store, hash-verified

3155//* Screen capture request.
3156//*********************************************************************
3157void NixNote::screenCapture() {
3158 if (noteButton->property("currentNoteButton").toInt() != NewScreenNote) {
3159 noteButton->setText(screenCaptureButton->text());
3160 noteButton->setIcon(screenCaptureButton->icon());
3161 noteButton->setProperty("currentNoteButton", NewScreenNote);
3162 }
3163 this->hide();
3164 sleep(1);
3165
3166 ScreenCapture sc;
3167 sc.exec();
3168 QPixmap pix = sc.getSelection();
3169 this->show();
3170 ConfigStore cs(global.db);
3171 qint32 lid = cs.incrementLidCounter();
3172
3173 QCryptographicHash md5hash(QCryptographicHash::Md5);
3174 QByteArray data;
3175 QBuffer buffer(&data);
3176 buffer.open(QIODevice::WriteOnly);
3177 pix.save(&buffer, "PNG");
3178
3179 QByteArray hash = md5hash.hash(data, QCryptographicHash::Md5);
3180
3181 // * Start setting up the new note
3182 Note newNote;
3183 newNote.guid = QString::number(lid);
3184 newNote.title = tr("Screen Capture");
3185
3186 NotebookTable bookTable(global.db);
3187 QString notebook;
3188 notebook = bookTable.getDefaultNotebookGuid();
3189 newNote.notebookGuid = notebook;
3190
3191 QString newNoteBody = QString("<?xml version=\"1.0\" encoding=\"UTF-8\"?>")+
3192 QString("<!DOCTYPE en-note SYSTEM \"http://xml.evernote.com/pub/enml2.dtd\">")+
3193 QString("<en-note style=\"word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;\">");
3194
3195 QString mime = "image/png";
3196 QString enMedia =QString("<en-media hash=\"") +hash.toHex() +QString("\" border=\"0\"")
3197 +QString(" type=\"" +mime +"\" ")
3198 +QString("/>");
3199 newNoteBody.append(enMedia + QString("</en-note>"));
3200 newNote.content = newNoteBody;
3201 newNote.active = true;
3202 newNote.created = QDateTime::currentMSecsSinceEpoch();;
3203 newNote.updated = newNote.created;
3204 newNote.updateSequenceNum = 0;
3205
3206 NoteTable ntable(global.db);
3207 ntable.add(lid, newNote, true);
3208 QString noteGuid = ntable.getGuid(lid);
3209 qint32 noteLid = lid;
3210 lid = cs.incrementLidCounter();
3211
3212
3213 // Start creating the new resource
3214 Resource newRes;

Callers 2

trayActivatedMethod · 0.95

Calls 11

getSelectionMethod · 0.80
showMethod · 0.80
incrementLidCounterMethod · 0.80
openMethod · 0.80
saveMethod · 0.80
QStringClass · 0.50
setTextMethod · 0.45
execMethod · 0.45
addMethod · 0.45
getGuidMethod · 0.45

Tested by

no test coverage detected