Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore repetitions when watching clipboard (workaround) #56

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ void MainWindow::createMenus()
QMenu *fmenu = menuBar()->addMenu(tr("&File"));

enterAct = fmenu->addAction(QIcon(":/images/key_enter.png"), tr("&Search"),
this, SLOT(viewSearch()), tr("Ctrl+F"));
[this]{ lastClipboardText.clear(); viewSearch(); }, tr("Ctrl+F"));
CONNECT_BUSY(enterAct);
openBookAct = fmenu->addAction(QIcon(":/images/bookopen.png"),
tr("&Open book"),
Expand Down Expand Up @@ -251,7 +251,7 @@ void MainWindow::createToolBars()

searchBar->addAction(clearEditAct);
searchTextEdit = new QLineEdit(this);
connect(searchTextEdit, SIGNAL(returnPressed()), SLOT(viewSearch()));
connect(searchTextEdit, &QLineEdit::returnPressed, [this]{ lastClipboardText.clear(); viewSearch(); });
connect(searchTextEdit, SIGNAL(textChanged(QString)),
SLOT(changeSearchText(QString)));
connect(clearEditAct, SIGNAL(triggered()), searchTextEdit, SLOT(clear()));
Expand Down Expand Up @@ -1255,9 +1255,10 @@ void MainWindow::searchClientText(const QString &str, bool raiseWindow)
{
if (raiseWindow)
raise();
if (str.isEmpty()) {
if (str.isEmpty() || str == lastClipboardText) {
return;
}
lastClipboardText = str;
if (isBusy()) {
clientText << str;
return;
Expand Down Expand Up @@ -1297,10 +1298,10 @@ void MainWindow::aboutQolibri()

if (!gitCommitDate.isEmpty())
msg += tr("<p>Commit date: %1</p>").arg(gitCommitDate);

if (website.isValid())
msg += QString("<p><a href='%1'>%1</a></p>").arg(website.toString());

msg += tr("<p>Based on <a href='%1'>%1</a></p>").arg("http://qolibri.sourceforge.jp");
msg += tr("<p>Compiled against Qt version %1</p>").arg(QT_VERSION_STR);

Expand Down
4 changes: 2 additions & 2 deletions src/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ private slots:
void connectClipboard(bool enable);
void viewInfo(Book *book);
void viewPseudoSearch(SearchDirection direction);
void viewSearch();
void viewSearch(const QString &str, const SearchMethod &method);
void viewSearch(SearchDirection d, const QString &str);
void viewWeb(const QString &name, const QString &url);
Expand Down Expand Up @@ -109,6 +108,7 @@ private slots:


private:
void viewSearch();
void createActions();
void createMenus();
void createToolBars();
Expand Down Expand Up @@ -184,7 +184,7 @@ private slots:
QClipboard::Mode watchClipboardMode;
int watchClipboardSelectionDelay;
bool watchClipboardRaiseWindow;
QString lastClipboardText;
};

#endif