Skip to content

Commit

Permalink
Remove global clipboard pointer.
Browse files Browse the repository at this point in the history
  • Loading branch information
baumgarr committed Dec 14, 2016
1 parent 0973154 commit c0e47c3
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 23 deletions.
1 change: 0 additions & 1 deletion global.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ Global::Global()
this->showGoodSyncMessagesInTray = false;
this->batchThumbnailCount = 4;
username = "";
this->clipboard = NULL;
this->defaultFontSize = 8;
this->countBehavior = Global::CountAll;
password = "";
Expand Down
1 change: 0 additions & 1 deletion global.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ class Global
QString server; // Evernote server to sync with
QSettings *settings; // Pointer to the nixnote config file. There is a different one for each account.
QSettings *globalSettings; // Pointer to all the config file that is common to all accounts.
QClipboard *clipboard; // System clipboard pointer
ShortcutKeys *shortcutKeys; // Keyboard shortcuts defined by the user
QList<qint32> expungedResources; // List of expunged resource LIDs
QFileSystemWatcher resourceWatcher; // Watcher for file system directories. New files here will create anote
Expand Down
28 changes: 12 additions & 16 deletions gui/nbrowserwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,7 @@ QString NBrowserWindow::buildPasteUrl(QString url) {
url.toLower().startsWith("mailto://") ||
url.toLower().startsWith("mailto:") ||
url.toLower().startsWith("ftp://")) {
QString newUrl = QString("<a href=\"") +global.clipboard->text()
QString newUrl = QString("<a href=\"") +QApplication::clipboard()->text()
+QString("\" title=\"") +url
+QString("\" >") +url +QString("</a>");
return newUrl;
Expand All @@ -895,8 +895,7 @@ void NBrowserWindow::pasteButtonPressed() {
return;
}

QClipboard *clipboard = global.clipboard;
const QMimeData *mime = clipboard->mimeData();
const QMimeData *mime = QApplication::clipboard()->mimeData();

if (mime->hasImage()) {
editor->setFocus();
Expand Down Expand Up @@ -975,7 +974,7 @@ void NBrowserWindow::pasteButtonPressed() {
// If we have a good return, then we can paste the link, otherwise we fall out
// to a normal paste.
if (goodrc) {
QString url = QString("<a href=\"%1\" title=\"%2\">%3</a>").arg(global.clipboard->text(), n.title, n.title);
QString url = QString("<a href=\"%1\" title=\"%2\">%3</a>").arg(QApplication::clipboard()->text(), n.title, n.title);
QLOG_DEBUG() << "HTML to insert:" << url;
QString script = QString("document.execCommand('insertHtml', false, '%1');").arg(url);
editor->page()->mainFrame()->evaluateJavaScript(script);
Expand Down Expand Up @@ -1006,12 +1005,12 @@ void NBrowserWindow::selectAllButtonPressed() {

// The paste without mime format was pressed
void NBrowserWindow::pasteWithoutFormatButtonPressed() {
const QMimeData *mime = global.clipboard->mimeData();
const QMimeData *mime = QApplication::clipboard()->mimeData();
if (!mime->hasText())
return;
QString text = mime->text();
global.clipboard->clear();
global.clipboard->setText(text, QClipboard::Clipboard);
QApplication::clipboard()->clear();
QApplication::clipboard()->setText(text, QClipboard::Clipboard);
this->editor->triggerPageAction(QWebPage::Paste);

// This is done because pasting into an encryption block
Expand Down Expand Up @@ -3270,8 +3269,7 @@ void NBrowserWindow::spellCheckPressed() {
if (dialog.ignoreAllPressed)
ignoreWords.append(currentWord);
if (dialog.replacePressed) {
QClipboard *clipboard = global.clipboard;
clipboard->setText(dialog.replacement);
QApplication::clipboard()->setText(dialog.replacement);
pasteButtonPressed();
}
if (dialog.addToDictionaryPressed) {
Expand Down Expand Up @@ -3321,8 +3319,8 @@ void NBrowserWindow::handleUrls(const QMimeData *mime) {
insertHtml("<div><br/></div>");
} else {
editor->setFocus();
global.clipboard->clear();
global.clipboard->setText(file, QClipboard::Clipboard);
QApplication::clipboard()->clear();
QApplication::clipboard()->setText(file, QClipboard::Clipboard);
this->editor->triggerPageAction(QWebPage::Paste);
}
}
Expand Down Expand Up @@ -3469,7 +3467,7 @@ void NBrowserWindow::copyNoteUrl() {
user.shardId +QString("/") +
n.guid +QString("/") +
n.guid + QString("/");
global.clipboard->setText(href, QClipboard::Clipboard);
QApplication::clipboard()->setText(href, QClipboard::Clipboard);
}


Expand Down Expand Up @@ -3597,8 +3595,7 @@ void NBrowserWindow::findReplaceInNotePressed() {
if (!found)
return;

QClipboard *clip = global.clipboard;
clip->setText(replace);
QApplication::clipboard()->setText(replace);
editor->pasteAction->trigger();
}

Expand All @@ -3619,8 +3616,7 @@ void NBrowserWindow::findReplaceAllInNotePressed() {
findReplace->getCaseSensitive() | QWebPage::FindWrapsAroundDocument);
if (!found)
return;
QClipboard *clip = global.clipboard;
clip->setText(replace);
QApplication::clipboard()->setText(replace);
editor->pasteAction->trigger();
}
}
Expand Down
2 changes: 1 addition & 1 deletion gui/ntableview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,7 @@ void NTableView::copyNoteLink() {
msgBox.setDefaultButton(QMessageBox::Ok);
msgBox.exec();
}
global.clipboard->setText(lidUrl);
QApplication::clipboard()->setText(lidUrl);
}


Expand Down
3 changes: 0 additions & 3 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,6 @@ int main(int argc, char *argv[])
}


// Save the clipboard
global.clipboard = QApplication::clipboard();

QLOG_DEBUG() << "Setting up NN";
NixNote *w = new NixNote();
w->setAttribute(Qt::WA_QuitOnClose);
Expand Down
1 change: 0 additions & 1 deletion nixnote.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <QFileDialog>
#include <QStringList>
#include <QDesktopServices>
#include <QClipboard>
#include <QPrintDialog>
#include <QPrintPreviewDialog>
#include <QStatusBar>
Expand Down

0 comments on commit c0e47c3

Please sign in to comment.