void ClipboardMonitor::readyRead() { m_socket->blockSignals(true); while ( m_socket->bytesAvailable() > 0 ) { QByteArray msg; if( !readMessage(m_socket, &msg) ) { log( tr("Cannot read message from server!"), LogError ); return; } ClipboardItem item; QDataStream in(&msg, QIODevice::ReadOnly); in >> item; /* Does server send settings for monitor? */ QByteArray settings_data = item.data()->data("application/x-copyq-settings"); if ( !settings_data.isEmpty() ) { QDataStream settings_in(settings_data); QVariantMap settings; settings_in >> settings; #ifdef COPYQ_LOG_DEBUG { COPYQ_LOG("Loading configuration:"); foreach (const QString &key, settings.keys()) { QVariant val = settings[key]; const QString str = val.canConvert<QStringList>() ? val.toStringList().join(",") : val.toString(); COPYQ_LOG( QString(" %1=%2").arg(key).arg(str) ); } } #endif if ( settings.contains("formats") ) m_formats = settings["formats"].toStringList(); #ifdef COPYQ_WS_X11 if ( settings.contains("copy_clipboard") ) m_copyclip = settings["copy_clipboard"].toBool(); if ( settings.contains("copy_selection") ) m_copysel = settings["copy_selection"].toBool(); if ( settings.contains("check_selection") ) m_checksel = settings["check_selection"].toBool(); #endif connect( QApplication::clipboard(), SIGNAL(changed(QClipboard::Mode)), this, SLOT(checkClipboard(QClipboard::Mode)) ); #ifdef COPYQ_WS_X11 checkClipboard(QClipboard::Selection); #endif checkClipboard(QClipboard::Clipboard); COPYQ_LOG("Configured"); } else {
void ClipboardMonitor::updateTimeout() { if (m_needCheckClipboard) { checkClipboard(QClipboard::Clipboard); #ifdef COPYQ_WS_X11 } else if (m_needCheckSelection) { checkClipboard(QClipboard::Selection); #endif } else if ( !m_newdata.isEmpty() ) { updateClipboard(); } }
void ClipboardMonitor::onMessageReceived(const QByteArray &message, int messageCode) { if (messageCode == MonitorPing) { sendMessage( QByteArray(), MonitorPong ); #ifdef Q_OS_WIN // Qt BUG: This needs to be called regularly so that QClipboard emits changed() signal. QApplication::clipboard()->mimeData(); #endif } else if (messageCode == MonitorSettings) { QDataStream stream(message); QVariantMap settings; stream >> settings; if ( hasLogLevel(LogDebug) ) { COPYQ_LOG("Loading configuration:"); foreach (const QString &key, settings.keys()) { QVariant val = settings[key]; const QString str = val.canConvert<QStringList>() ? val.toStringList().join(",") : val.toString(); COPYQ_LOG( QString(" %1=%2").arg(key).arg(str) ); } } if ( settings.contains("formats") ) m_formats = settings["formats"].toStringList(); #ifdef COPYQ_WS_X11 m_x11->loadSettings(settings); #endif connect( QApplication::clipboard(), SIGNAL(changed(QClipboard::Mode)), this, SLOT(checkClipboard(QClipboard::Mode)), Qt::UniqueConnection ); COPYQ_LOG("Configured"); } else if (messageCode == MonitorChangeClipboard) {
KMiniEdit::KMiniEdit() : KMainWindow(0) { edit = new QMultiLineEdit(this); setCentralWidget(edit); KStdAction::openNew(this, SLOT(fileNew()), actionCollection()); KStdAction::open(this, SLOT(fileOpen()), actionCollection()); recentAction = KStdAction::openRecent(0, 0, actionCollection()); recentAction->loadEntries(KGlobal::config()); connect(recentAction, SIGNAL(urlSelected(const KURL &)), this, SLOT(fileOpenRecent(const KURL &))); saveAction = KStdAction::save(this, SLOT(fileSave()), actionCollection()); checkEdited(); connect(edit, SIGNAL(textChanged()), this, SLOT(checkEdited())); KStdAction::saveAs(this, SLOT(fileSaveAs()), actionCollection()); KStdAction::close(this, SLOT(fileClose()), actionCollection()); KAction *a; a = KStdAction::undo(edit, SLOT(undo()), actionCollection()); a->setEnabled(false); connect(edit, SIGNAL(undoAvailable(bool)), a, SLOT(setEnabled(bool))); a = KStdAction::redo(edit, SLOT(redo()), actionCollection()); a->setEnabled(false); connect(edit, SIGNAL(redoAvailable(bool)), a, SLOT(setEnabled(bool))); a = KStdAction::cut(edit, SLOT(cut()), actionCollection()); a->setEnabled(false); connect(edit, SIGNAL(copyAvailable(bool)), a, SLOT(setEnabled(bool))); a = KStdAction::copy(edit, SLOT(copy()), actionCollection()); a->setEnabled(false); connect(edit, SIGNAL(copyAvailable(bool)), a, SLOT(setEnabled(bool))); pasteAction = KStdAction::paste(edit, SLOT(paste()), actionCollection()); checkClipboard(); connect(kapp->clipboard(), SIGNAL(dataChanged()), this, SLOT(checkClipboard())); KStdAction::selectAll(edit, SLOT(selectAll()), actionCollection()); createGUI(); }
KGetLinkView::KGetLinkView(QWidget *parent) : KDialog(parent), m_linkImporter(0) { setCaption(i18n("Import Links")); // proxy model to filter links m_proxyModel = new KGetSortFilterProxyModel(); m_proxyModel->setDynamicSortFilter(true); m_proxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive); QWidget *widget = new QWidget(this); ui.setupUi(widget); // set the Icons ui.importLinks->setIcon(KIcon("document-import")); ui.showAll->setIcon(KIcon("view-list-icons")); ui.showArchives->setIcon(KIcon("package-x-generic")); ui.showAudio->setIcon(KIcon("audio-x-generic")); ui.showImages->setIcon(KIcon("image-x-generic")); ui.showVideos->setIcon(KIcon("video-x-generic")); // set the ids for the filterButtonGroup ui.filterButtonGroup->setId(ui.showAll, KGetSortFilterProxyModel::NoFilter); ui.filterButtonGroup->setId(ui.showArchives, KGetSortFilterProxyModel::CompressedFiles); ui.filterButtonGroup->setId(ui.showAudio, KGetSortFilterProxyModel::AudioFiles); ui.filterButtonGroup->setId(ui.showImages, KGetSortFilterProxyModel::ImageFiles); ui.filterButtonGroup->setId(ui.showVideos, KGetSortFilterProxyModel::VideoFiles); ui.treeView->setModel(m_proxyModel); ui.progressBar->hide(); connect(ui.treeView, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(uncheckItem(const QModelIndex &))); connect(ui.textFilter, SIGNAL(textChanged(QString)), SLOT(setTextFilter(QString))); connect(ui.filterMode, SIGNAL(currentIndexChanged(int)), m_proxyModel, SLOT(setFilterMode(int))); connect(ui.filterButtonGroup, SIGNAL(buttonClicked(int)), m_proxyModel, SLOT(setFilterType(int))); connect(ui.filterButtonGroup, SIGNAL(buttonClicked(int)), SLOT(updateSelectionButtons())); connect(ui.urlRequester, SIGNAL(textChanged(const QString &)), SLOT(updateImportButtonStatus(const QString &))); connect(ui.selectAll, SIGNAL(clicked()), this, SLOT(checkAll())); connect(ui.deselectAll, SIGNAL(clicked()), this, SLOT(uncheckAll())); connect(ui.checkSelected, SIGNAL(clicked()), this, SLOT(slotCheckSelected())); connect(ui.invertSelection, SIGNAL(clicked()), this, SLOT(slotInvertSelection())); connect(this, SIGNAL(okClicked()), this, SLOT(slotStartLeech())); connect(ui.showWebContent, SIGNAL(stateChanged(int)), m_proxyModel, SLOT(setShowWebContent(int))); connect(ui.importLinks, SIGNAL(clicked()), this, SLOT(slotStartImport())); connect(ui.treeView->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)), SLOT(selectionChanged())); setMainWidget(widget); setButtonText(KDialog::Ok, i18nc("Download the items which have been selected","&Download Checked")); setButtonIcon(KDialog::Ok, KIcon("kget")); checkClipboard(); }
bool ClipboardMonitor::updateSelection(bool check) { // Wait while selection is incomplete, i.e. mouse button or // shift key is pressed. if ( m_x11->waitForKeyRelease() ) return false; if (check) checkClipboard(QClipboard::Selection); return true; }
KIconEditGrid::KIconEditGrid(QImage *image, QWidget *parent, const char *name) : KColorGrid(parent, name, 1) { initMetaObject(); img = image; selected = 0; //setBackgroundMode(NoBackground); //kdeColor(1); for(uint i = 0; i < 42; i++) iconcolors.append(iconpalette[i]); setupImageHandlers(); debug("Formats: %d", formats->count()); btndown = isselecting = ispasting = modified = false; //modified = false; img->create(32, 32, 32); img->fill(TRANSPARENT); //numcolors = 0; currentcolor = qRgb(0,0,0)|OPAQUE_MASK; setMouseTracking(true); setNumRows(32); setNumCols(32); fill(TRANSPARENT); connect( kapp->clipboard(), SIGNAL(dataChanged()), SLOT(checkClipboard())); // this is kind of a hack but the application global clipboard object // doesn't always send the signals. QTimer *cbtimer = new QTimer(this); connect( cbtimer, SIGNAL(timeout()), SLOT(checkClipboard())); cbtimer->start(2500); createCursors(); }
void ClipboardMonitor::updateSelection() { if ( !m_x11->isSelectionIncomplete() ) checkClipboard(QClipboard::Selection); }