summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuboš Luňák <[email protected]>2017-04-17 13:13:53 +0200
committerLuboš Luňák <[email protected]>2017-04-26 11:06:01 +0200
commitf78b0869f01d255d0e17a0a246e5a9456f2bba4e (patch)
tree60229bd11dc4df058393b7c09f9d1471a2c8044c
parent17eeb58ae42596195d6a841c06d17721b7af2c14 (diff)
selecting the topmost klipper item should always set it as clipboard contents
Without this, that wasn't always the case if the top item was only the mouse selection. This was presumably broken by 2e47d84772. Also explicitly check the popup item, since it's now owned by Klipper. BUG: 348390 BUG: 251222
-rw-r--r--klipper/history.cpp11
-rw-r--r--klipper/history.h1
-rw-r--r--klipper/klipper.cpp1
-rw-r--r--klipper/klipperpopup.cpp7
-rw-r--r--klipper/klipperpopup.h1
5 files changed, 21 insertions, 0 deletions
diff --git a/klipper/history.cpp b/klipper/history.cpp
index 9640c23..36b00e9 100644
--- a/klipper/history.cpp
+++ b/klipper/history.cpp
@@ -140,8 +140,19 @@ void History::slotMoveToTop(QAction* action) {
}
void History::slotMoveToTop(const QByteArray& uuid) {
+ const QModelIndex item = m_model->indexOf(uuid);
+ if (item.isValid() && item.row() == 0) {
+ // The item is already at the top, but it still may be not be set as the actual clipboard
+ // contents, normally this happens if the item is only in the X11 mouse selection but
+ // not in the Ctrl+V clipboard.
+ emit topChanged();
+ m_topIsUserSelected = true;
+ emit topIsUserSelectedSet();
+ return;
+ }
m_model->moveToTop(uuid);
m_topIsUserSelected = true;
+ emit topIsUserSelectedSet();
}
void History::setMaxSize( unsigned max_size ) {
diff --git a/klipper/history.h b/klipper/history.h
index 7690ffd..7001450 100644
--- a/klipper/history.h
+++ b/klipper/history.h
@@ -136,6 +136,7 @@ Q_SIGNALS:
*/
void topChanged();
+ void topIsUserSelectedSet();
private:
/**
diff --git a/klipper/klipper.cpp b/klipper/klipper.cpp
index 8de19fb..78e7f86 100644
--- a/klipper/klipper.cpp
+++ b/klipper/klipper.cpp
@@ -117,6 +117,7 @@ Klipper::Klipper(QObject* parent, const KSharedConfigPtr& config, KlipperMode mo
m_popup = new KlipperPopup(m_history);
m_popup->setShowHelp(m_mode == KlipperMode::Standalone);
connect(m_history, &History::changed, m_popup, &KlipperPopup::slotHistoryChanged);
+ connect(m_history, &History::topIsUserSelectedSet, m_popup, &KlipperPopup::slotTopIsUserSelectedSet);
// we need that collection, otherwise KToggleAction is not happy :}
m_collection = new KActionCollection( this );
diff --git a/klipper/klipperpopup.cpp b/klipper/klipperpopup.cpp
index 12d3205..e0d35e5 100644
--- a/klipper/klipperpopup.cpp
+++ b/klipper/klipperpopup.cpp
@@ -175,6 +175,13 @@ void KlipperPopup::rebuild( const QString& filter ) {
m_dirty = false;
}
+void KlipperPopup::slotTopIsUserSelectedSet() {
+ if ( !m_dirty && m_nHistoryItems > 0 && history()->topIsUserSelected() ) {
+ actions().at(TOP_HISTORY_ITEM_INDEX)->setCheckable(true);
+ actions().at(TOP_HISTORY_ITEM_INDEX)->setChecked(true);
+ }
+}
+
void KlipperPopup::plugAction( QAction* action ) {
m_actions.append(action);
}
diff --git a/klipper/klipperpopup.h b/klipper/klipperpopup.h
index 3ba3d97..cf70ab9 100644
--- a/klipper/klipperpopup.h
+++ b/klipper/klipperpopup.h
@@ -61,6 +61,7 @@ public:
}
public Q_SLOTS:
void slotHistoryChanged() { m_dirty = true; }
+ void slotTopIsUserSelectedSet();
void slotAboutToShow();
/**
* set the top history item active, to easy kb navigation