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
wilder-5.14
Luboš Luňák 9 years ago
parent 14d3df9854
commit 37014e643c
  1. 11
      klipper/history.cpp
  2. 1
      klipper/history.h
  3. 1
      klipper/klipper.cpp
  4. 7
      klipper/klipperpopup.cpp
  5. 1
      klipper/klipperpopup.h

@ -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 ) {

@ -136,6 +136,7 @@ Q_SIGNALS:
*/
void topChanged();
void topIsUserSelectedSet();
private:
/**

@ -115,6 +115,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 );

@ -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);
}

@ -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

Loading…
Cancel
Save