From 4c494a6c43f2d0130a686d59b93191c38030439b Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Tue, 16 Apr 2024 05:20:53 +0300 Subject: [PATCH] kdeplasma-addons: drop paste applet have not used it, ever.. Signed-off-by: Ivailo Monev --- kdeplasma-addons/applets/CMakeLists.txt | 1 - kdeplasma-addons/applets/paste/CMakeLists.txt | 24 --- kdeplasma-addons/applets/paste/Messages.sh | 4 - kdeplasma-addons/applets/paste/addmacro.cpp | 135 ------------- kdeplasma-addons/applets/paste/addmacro.h | 46 ----- kdeplasma-addons/applets/paste/appkey.cpp | 64 ------ kdeplasma-addons/applets/paste/appkey.h | 39 ---- kdeplasma-addons/applets/paste/appkey.ui | 78 -------- .../applets/paste/autopasteconfig.cpp | 123 ------------ .../applets/paste/autopasteconfig.h | 49 ----- .../applets/paste/autopasteconfig.ui | 98 ---------- kdeplasma-addons/applets/paste/configdata.cpp | 153 --------------- kdeplasma-addons/applets/paste/configdata.h | 59 ------ kdeplasma-addons/applets/paste/list.cpp | 147 -------------- kdeplasma-addons/applets/paste/list.h | 61 ------ kdeplasma-addons/applets/paste/list.ui | 56 ------ kdeplasma-addons/applets/paste/paste.cpp | 126 ------------ kdeplasma-addons/applets/paste/paste.h | 57 ------ .../applets/paste/pastemacroexpander.cpp | 185 ------------------ .../applets/paste/pastemacroexpander.h | 68 ------- .../applets/paste/plasma-applet-paste.desktop | 130 ------------ kdeplasma-addons/applets/paste/sendkeys.cpp | 78 -------- kdeplasma-addons/applets/paste/sendkeys.h | 30 --- .../applets/paste/snippetconfig.cpp | 167 ---------------- .../applets/paste/snippetconfig.h | 56 ------ .../applets/paste/snippetconfig.ui | 144 -------------- 26 files changed, 2178 deletions(-) delete mode 100644 kdeplasma-addons/applets/paste/CMakeLists.txt delete mode 100755 kdeplasma-addons/applets/paste/Messages.sh delete mode 100644 kdeplasma-addons/applets/paste/addmacro.cpp delete mode 100644 kdeplasma-addons/applets/paste/addmacro.h delete mode 100644 kdeplasma-addons/applets/paste/appkey.cpp delete mode 100644 kdeplasma-addons/applets/paste/appkey.h delete mode 100644 kdeplasma-addons/applets/paste/appkey.ui delete mode 100644 kdeplasma-addons/applets/paste/autopasteconfig.cpp delete mode 100644 kdeplasma-addons/applets/paste/autopasteconfig.h delete mode 100644 kdeplasma-addons/applets/paste/autopasteconfig.ui delete mode 100644 kdeplasma-addons/applets/paste/configdata.cpp delete mode 100644 kdeplasma-addons/applets/paste/configdata.h delete mode 100644 kdeplasma-addons/applets/paste/list.cpp delete mode 100644 kdeplasma-addons/applets/paste/list.h delete mode 100644 kdeplasma-addons/applets/paste/list.ui delete mode 100644 kdeplasma-addons/applets/paste/paste.cpp delete mode 100644 kdeplasma-addons/applets/paste/paste.h delete mode 100644 kdeplasma-addons/applets/paste/pastemacroexpander.cpp delete mode 100644 kdeplasma-addons/applets/paste/pastemacroexpander.h delete mode 100644 kdeplasma-addons/applets/paste/plasma-applet-paste.desktop delete mode 100644 kdeplasma-addons/applets/paste/sendkeys.cpp delete mode 100644 kdeplasma-addons/applets/paste/sendkeys.h delete mode 100644 kdeplasma-addons/applets/paste/snippetconfig.cpp delete mode 100644 kdeplasma-addons/applets/paste/snippetconfig.h delete mode 100644 kdeplasma-addons/applets/paste/snippetconfig.ui diff --git a/kdeplasma-addons/applets/CMakeLists.txt b/kdeplasma-addons/applets/CMakeLists.txt index d475861e..66078c22 100644 --- a/kdeplasma-addons/applets/CMakeLists.txt +++ b/kdeplasma-addons/applets/CMakeLists.txt @@ -11,4 +11,3 @@ add_subdirectory(spellcheck) add_subdirectory(timer) add_subdirectory(eyes) add_subdirectory(unitconverter) -add_subdirectory(paste) diff --git a/kdeplasma-addons/applets/paste/CMakeLists.txt b/kdeplasma-addons/applets/paste/CMakeLists.txt deleted file mode 100644 index ec2a59ca..00000000 --- a/kdeplasma-addons/applets/paste/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ -project(plasma-paste) - -set(paste_SRCS - paste.cpp - sendkeys.cpp - list.cpp - configdata.cpp - snippetconfig.cpp - autopasteconfig.cpp - appkey.cpp - pastemacroexpander.cpp - addmacro.cpp - list.ui - snippetconfig.ui - autopasteconfig.ui - appkey.ui -) - -kde4_add_plugin(plasma_applet_paste ${paste_SRCS}) -target_link_libraries(plasma_applet_paste - ${X11_X11_LIB} KDE4::kdeui KDE4::kio KDE4::plasma) - -install(TARGETS plasma_applet_paste DESTINATION ${KDE4_PLUGIN_INSTALL_DIR}) -install(FILES plasma-applet-paste.desktop DESTINATION ${KDE4_SERVICES_INSTALL_DIR}) diff --git a/kdeplasma-addons/applets/paste/Messages.sh b/kdeplasma-addons/applets/paste/Messages.sh deleted file mode 100755 index f12bb412..00000000 --- a/kdeplasma-addons/applets/paste/Messages.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -$EXTRACTRC *.ui >> rc.cpp -$XGETTEXT *.cpp *.h -o $podir/plasma_applet_paste.pot -rm -f rc.cpp diff --git a/kdeplasma-addons/applets/paste/addmacro.cpp b/kdeplasma-addons/applets/paste/addmacro.cpp deleted file mode 100644 index 34032659..00000000 --- a/kdeplasma-addons/applets/paste/addmacro.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright 2008 Petri Damsten - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "addmacro.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -AddMacro::AddMacro(QWidget* parent) -: KDialog(parent), m_params(0) -{ - setCaption(i18n("Add Macro")); - setButtons(KDialog::Ok | KDialog::Cancel); - - m_widget = new QWidget(this); - setMainWidget(m_widget); - - m_layout = new QVBoxLayout(m_widget); - m_layout->setMargin(0); - m_layout->setSpacing(spacingHint()); - - m_macrosComboBox = new KComboBox(m_widget); - const QMap& macros = PasteMacroExpander::instance().macros(); - foreach (const QString& macro, macros.keys()) { - m_macrosComboBox->addItem(macros[macro][0].toString(), macro); - } - connect(m_macrosComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(currentIndexChanged(int))); - m_layout->addWidget(m_macrosComboBox); - - currentIndexChanged(0); -} - -AddMacro::~AddMacro() -{ -} - -void AddMacro::currentIndexChanged(int index) -{ - delete m_params; - m_params = new QWidget(m_widget); - m_layout->addWidget(m_params); - QVBoxLayout* layout = new QVBoxLayout(m_params); - const QMap& macros = PasteMacroExpander::instance().macros(); - const QVariantList& params = macros[m_macrosComboBox->itemData(index).toString()]; - QWidget* w = 0; - - for (int i = 1; i < params.count(); ++i) { - MacroParam param = params[i].value(); - switch (param.type) { - case MacroParam::Int: - { - QHBoxLayout* l = new QHBoxLayout(m_params); - l->addWidget(new QLabel(param.name + ':', m_params)); - l->addWidget(w = new QSpinBox(m_params)); - layout->addItem(l); - break; - } - case MacroParam::String: - layout->addWidget(new QLabel(param.name + ':', m_params)); - layout->addWidget(w = new KLineEdit(m_params)); - break; - case MacroParam::Url: - layout->addWidget(new QLabel(param.name + ':')); - layout->addWidget(w = new KUrlRequester(m_params)); - break; - case MacroParam::Boolean: - layout->addWidget(w = new QCheckBox(param.name, m_params)); - break; - } - w->setObjectName(param.name); - } - layout->addStretch(1.0); -} - -QString AddMacro::macro() -{ - int index = m_macrosComboBox->currentIndex(); - const QMap& macros = PasteMacroExpander::instance().macros(); - QString macro = m_macrosComboBox->itemData(index).toString(); - const QVariantList& params = macros[m_macrosComboBox->itemData(index).toString()]; - QStringList values; - - for (int i = 1; i < params.count(); ++i) { - MacroParam param = params[i].value(); - switch (param.type) { - case MacroParam::Int: - { - QSpinBox* w = m_params->findChildren(param.name)[0]; - values.append(QString::number(w->value())); - break; - } - case MacroParam::String: - { - KLineEdit* w = m_params->findChildren(param.name)[0]; - values.append(w->text()); - break; - } - case MacroParam::Url: - { - KUrlRequester* w = m_params->findChildren(param.name)[0]; - values.append(w->url().prettyUrl()); - break; - } - case MacroParam::Boolean: - { - QCheckBox* w = m_params->findChildren(param.name)[0]; - values.append((w->checkState() == Qt::Unchecked) ? "false" : "true"); - break; - } - } - } - return QString("%{%1(%2)}").arg(macro).arg(values.join(", ")); -} - -#include "moc_addmacro.cpp" diff --git a/kdeplasma-addons/applets/paste/addmacro.h b/kdeplasma-addons/applets/paste/addmacro.h deleted file mode 100644 index c6f3f09a..00000000 --- a/kdeplasma-addons/applets/paste/addmacro.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2008 Petri Damsten - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef ADDMACRO_H -#define ADDMACRO_H - -#include -#include - -class KComboBox; -#include - -class AddMacro : public KDialog -{ - Q_OBJECT -public: - AddMacro(QWidget* parent); - ~AddMacro(); - - QString macro(); - -protected slots: - void currentIndexChanged(int index); - -private: - KComboBox* m_macrosComboBox; - QVBoxLayout* m_layout; - QWidget* m_widget; - QWidget* m_params; -}; - -#endif diff --git a/kdeplasma-addons/applets/paste/appkey.cpp b/kdeplasma-addons/applets/paste/appkey.cpp deleted file mode 100644 index f05dd697..00000000 --- a/kdeplasma-addons/applets/paste/appkey.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2008 Petri Damsten - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "appkey.h" -#include -#include - -AppKey::AppKey(QWidget *parent) - : KDialog(parent) -{ - setupUi(mainWidget()); - setButtons(KDialog::Ok | KDialog::Cancel); - pasteButton->setClearButtonShown(false); - connect(appButton, SIGNAL(clicked()), this, SLOT(appClicked())); - connect(pasteButton, SIGNAL(keySequenceChanged(QKeySequence)), - this, SLOT(enableWidgets())); - enableWidgets(); -} - -AppKey::~AppKey() -{ -} - -void AppKey::appClicked() -{ - appButton->setText(i18nc("Button to select an application by clicking on its window", - "Click application")); - appButton->setIcon(KIcon()); - connect(KWindowSystem::self(), SIGNAL(activeWindowChanged(WId)), - this, SLOT(activeWindowChanged(WId))); -} - -void AppKey::enableWidgets() -{ - enableButtonOk(!appButton->text().isEmpty() && !pasteButton->keySequence().isEmpty()); -} - -void AppKey::activeWindowChanged(WId id) -{ - KWindowInfo info = KWindowSystem::windowInfo(id, 0, NET::WM2WindowClass); - appButton->setText(info.windowClassClass()); - appButton->setIcon(KIcon(info.windowClassClass().toLower())); - app = info.windowClassClass(); - appButton->setChecked(false); - disconnect(KWindowSystem::self(), SIGNAL(activeWindowChanged(WId)), - this, SLOT(activeWindowChanged(WId))); - enableWidgets(); -} - -#include "moc_appkey.cpp" diff --git a/kdeplasma-addons/applets/paste/appkey.h b/kdeplasma-addons/applets/paste/appkey.h deleted file mode 100644 index 9fd7bad4..00000000 --- a/kdeplasma-addons/applets/paste/appkey.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2008 Petri Damsten - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef APPKEY_HEADER -#define APPKEY_HEADER - -#include "ui_appkey.h" -#include - -class AppKey : public KDialog, public Ui::AppKey -{ - Q_OBJECT -public: - AppKey(QWidget *parent = 0); - virtual ~AppKey(); - - QString app; - -protected slots: - void appClicked(); - void activeWindowChanged(WId id); - void enableWidgets(); -}; - -#endif // APPKEY_HEADER diff --git a/kdeplasma-addons/applets/paste/appkey.ui b/kdeplasma-addons/applets/paste/appkey.ui deleted file mode 100644 index b953fd3d..00000000 --- a/kdeplasma-addons/applets/paste/appkey.ui +++ /dev/null @@ -1,78 +0,0 @@ - - AppKey - - - - 0 - 0 - 216 - 80 - - - - - - - - - &Application: - - - appButton - - - - - - - true - - - false - - - - - - - &Paste key: - - - pasteButton - - - - - - - - - - - - Qt::Vertical - - - - 20 - 6 - - - - - - - - - KKeySequenceWidget - QWidget -
kkeysequencewidget.h
-
- - KPushButton - QPushButton -
kpushbutton.h
-
-
- -
diff --git a/kdeplasma-addons/applets/paste/autopasteconfig.cpp b/kdeplasma-addons/applets/paste/autopasteconfig.cpp deleted file mode 100644 index 0d407900..00000000 --- a/kdeplasma-addons/applets/paste/autopasteconfig.cpp +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright 2008 Petri Damsten - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "autopasteconfig.h" -#include "appkey.h" -#include "configdata.h" -#include -#include -#include -#include - -AutoPasteConfig::AutoPasteConfig(QWidget *parent) - : QWidget(parent) -{ - setupUi(this); - addButton->setIcon(KIcon("list-add")); - removeButton->setIcon(KIcon("list-remove")); - editButton->setIcon(KIcon("list-edit")); - pasteKeyButton->setClearButtonShown(false); - appsTreeView->setModel(&m_appModel); - m_appModel.setHorizontalHeaderLabels(QStringList() << i18n("Application") << i18n("Paste Key")); - connect(addButton, SIGNAL(clicked()), this, SLOT(addClicked())); - connect(removeButton, SIGNAL(clicked()), this, SLOT(removeClicked())); - connect(editButton, SIGNAL(clicked()), this, SLOT(editClicked())); - connect(autoPasteCheckBox, SIGNAL(clicked()), this, SLOT(enableWidgets())); - connect(appsTreeView->selectionModel(), - SIGNAL(currentChanged(QModelIndex,QModelIndex)), - this, SLOT(enableWidgets())); - enableWidgets(); -} - -AutoPasteConfig::~AutoPasteConfig() -{ -} - -void AutoPasteConfig::setData(const ConfigData &data) -{ - pasteKeyButton->setKeySequence(data.pasteKey); - autoPasteCheckBox->setChecked(data.autoPaste); - - foreach (const QString &key, data.specialApps.keys()) { - QStandardItem *appItem = new QStandardItem(KIcon(key.toLower()), key); - QStandardItem *keyItem = new QStandardItem(data.specialApps[key].toString()); - m_appModel.appendRow(QList() << appItem << keyItem); - } - enableWidgets(); -} - -void AutoPasteConfig::getData(ConfigData *data) -{ - data->pasteKey = pasteKeyButton->keySequence(); - data->autoPaste = autoPasteCheckBox->isChecked(); - data->specialApps.clear(); - for (int i = 0; i < m_appModel.rowCount(); ++i) { - QStandardItem *appItem = m_appModel.item(i, 0); - QStandardItem *keyItem = m_appModel.item(i, 1); - data->specialApps[appItem->text()] = QKeySequence::fromString(keyItem->text()); - } -} - -void AutoPasteConfig::addClicked() -{ - QPointer dlg = new AppKey(this); - if (dlg->exec() == QDialog::Accepted) { - QStandardItem *appItem = new QStandardItem(KIcon(dlg->app.toLower()), dlg->app); - QStandardItem *keyItem = new QStandardItem(dlg->pasteButton->keySequence().toString()); - m_appModel.appendRow(QList() << appItem << keyItem); - enableWidgets(); - } - - delete dlg; -} - -void AutoPasteConfig::removeClicked() -{ - m_appModel.takeRow(appsTreeView->selectionModel()->currentIndex().row()); - enableWidgets(); -} - -void AutoPasteConfig::editClicked() -{ - QPointer dlg = new AppKey(this); - int row = appsTreeView->selectionModel()->currentIndex().row(); - QStandardItem *appItem = m_appModel.item(row, 0); - QStandardItem *keyItem = m_appModel.item(row, 1); - dlg->appButton->setText(appItem->text()); - dlg->appButton->setIcon(KIcon(appItem->text().toLower())); - dlg->pasteButton->setKeySequence(QKeySequence::fromString(keyItem->text())); - if (dlg->exec() == QDialog::Accepted) { - appItem->setText(dlg->app); - appItem->setIcon(KIcon(dlg->app.toLower())); - keyItem->setText(dlg->pasteButton->keySequence().toString()); - } - - delete dlg; -} - -void AutoPasteConfig::enableWidgets() -{ - addButton->setEnabled(autoPasteCheckBox->isChecked()); - removeButton->setEnabled(autoPasteCheckBox->isChecked() && - appsTreeView->selectionModel()->currentIndex().isValid()); - editButton->setEnabled(autoPasteCheckBox->isChecked() && - appsTreeView->selectionModel()->currentIndex().isValid()); - pasteKeyButton->setEnabled(autoPasteCheckBox->isChecked()); - appsTreeView->setEnabled(autoPasteCheckBox->isChecked()); -} - -#include "moc_autopasteconfig.cpp" diff --git a/kdeplasma-addons/applets/paste/autopasteconfig.h b/kdeplasma-addons/applets/paste/autopasteconfig.h deleted file mode 100644 index 9c046111..00000000 --- a/kdeplasma-addons/applets/paste/autopasteconfig.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2008 Petri Damsten - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef AUTOPASTECONFIG_HEADER -#define AUTOPASTECONFIG_HEADER - -#include -#include -#include "ui_autopasteconfig.h" - -class ConfigData; - -class AutoPasteConfig : public QWidget, public Ui::AutoPasteConfig -{ - Q_OBJECT -public: - AutoPasteConfig(QWidget *parent = 0); - virtual ~AutoPasteConfig(); - - void getData(ConfigData *data); - -public slots: - void setData(const ConfigData &data); - -protected slots: - void addClicked(); - void removeClicked(); - void editClicked(); - void enableWidgets(); - -private: - QStandardItemModel m_appModel; -}; - -#endif // AUTOPASTECONFIG_HEADER diff --git a/kdeplasma-addons/applets/paste/autopasteconfig.ui b/kdeplasma-addons/applets/paste/autopasteconfig.ui deleted file mode 100644 index a89ed5af..00000000 --- a/kdeplasma-addons/applets/paste/autopasteconfig.ui +++ /dev/null @@ -1,98 +0,0 @@ - - AutoPasteConfig - - - - 0 - 0 - 400 - 300 - - - - - - - - - Paste text automatically with: - - - - - - - - - - - - Use &special keys for these apps: - - - appsTreeView - - - - - - - false - - - true - - - false - - - true - - - false - - - - - - - - - &Add... - - - - - - - &Edit... - - - - - - - &Remove - - - - - - - - - - KKeySequenceWidget - QWidget -
kkeysequencewidget.h
-
-
- - autoPasteCheckBox - appsTreeView - addButton - editButton - removeButton - - -
diff --git a/kdeplasma-addons/applets/paste/configdata.cpp b/kdeplasma-addons/applets/paste/configdata.cpp deleted file mode 100644 index 8fdd1189..00000000 --- a/kdeplasma-addons/applets/paste/configdata.cpp +++ /dev/null @@ -1,153 +0,0 @@ -/* - * Copyright 2008 Petri Damsten - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "configdata.h" -#include -#include -#include -#include -#include -#include -#include -#include - -ConfigData::ConfigData() -{ - xmlFile = KStandardDirs::locateLocal("data", "plasma_applet_paste/snippets.xml"); - KDirWatch::self()->addFile(xmlFile); - connect(KDirWatch::self(), SIGNAL(dirty(QString)), this, SLOT(readEntries())); -} - -ConfigData::~ConfigData() -{ -} - -ConfigData &ConfigData::operator=(const KConfigGroup &rhs) -{ - KConfigGroup::operator=(rhs); - readEntries(); - return *this; -} - -#define CHECK(TYPE, VAR, READFUNC) { \ -TYPE tmp = READFUNC; \ -if (VAR != tmp) { \ - VAR = tmp; \ - change = true; \ -} } - -void ConfigData::readEntries() -{ - AppMap defApps; - defApps["Konsole"] = QKeySequence::fromString("Ctrl+Shift+V"); - QString defPaste = QKeySequence(QKeySequence::Paste).toString(); - bool change = false; - - CHECK(SnippetMap, snippets, readFromXmlFile()); - CHECK(bool, autoPaste, readEntry("auto_paste", true)); - CHECK(QKeySequence, pasteKey, QKeySequence::fromString(readEntry("paste_key", defPaste))); - CHECK(AppMap, specialApps, readKeySequenceMapEntry("special_apps", defApps)); - - if (change) { - emit changed(*this); - } -} - -void ConfigData::writeEntries() -{ - writeToXmlFile(snippets); - KConfigGroup::writeEntry("auto_paste", autoPaste); - KConfigGroup::writeEntry("paste_key", pasteKey.toString()); - writeEntry("special_apps", specialApps); -} - -void ConfigData::writeToXmlFile(SnippetMap value) -{ - // Make XML - QDomDocument doc("text_snippets"); - QDomElement root = doc.createElement("snippets"); - - doc.appendChild(doc.createProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\"")); - foreach (const QString &key, value.keys()) { - QDomElement snippet = doc.createElement("snippet"); - snippet.setAttribute("name", key); - snippet.setAttribute("icon", value[key][Icon]); - QDomText txt = doc.createTextNode(value[key][Text]); - snippet.appendChild(txt); - root.appendChild(snippet); - } - doc.appendChild(root); - - // Save to file - KSaveFile file(xmlFile); - - if (file.open()) { - QTextStream stream(&file); - doc.save(stream, 2); - stream.flush(); - } - file.finalize(); -} - -SnippetMap ConfigData::readFromXmlFile() -{ - // Read file - SnippetMap result; - QDomDocument doc("text_snippets"); - QFile file(xmlFile); - - if (file.open(QIODevice::ReadOnly)) { - if (doc.setContent(&file)) { - // Parse xml - QDomElement node = doc.documentElement().firstChildElement(); - while (!node.isNull()) { - if (node.tagName() == "snippet") { - result[node.attribute("name")] = QStringList() << - node.attribute("icon") << node.firstChild().toText().data(); - } - node = node.nextSiblingElement(); - } - return result; - } - file.close(); - } - result[i18n("Random Password")] = QStringList() << "object-unlocked" << "%{password(8)}"; - result[i18n("Current Date")] = QStringList() << "office-calendar" << "%{date()}"; - return result; -} - -void ConfigData::writeEntry(const char *pKey, AppMap value) -{ - QByteArray ba; - QDataStream ds(&ba, QIODevice::WriteOnly); - ds << value; - KConfigGroup::writeEntry(pKey, ba); -} - -AppMap ConfigData::readKeySequenceMapEntry(const char *pKey, AppMap defaultValue) -{ - AppMap result; - QByteArray ba = readEntry(pKey, QByteArray()); - if (ba.isEmpty()) { - return defaultValue; - } - QDataStream ds(&ba, QIODevice::ReadOnly); - ds >> result; - return result; -} - -#include "moc_configdata.cpp" diff --git a/kdeplasma-addons/applets/paste/configdata.h b/kdeplasma-addons/applets/paste/configdata.h deleted file mode 100644 index 7ca63b56..00000000 --- a/kdeplasma-addons/applets/paste/configdata.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2008 Petri Damsten - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef CONFIGDATA_HEADER -#define CONFIGDATA_HEADER - -#include -#include - -typedef QMap SnippetMap; -typedef QMap AppMap; - -class ConfigData : public QObject, public KConfigGroup -{ - Q_OBJECT -public: - enum DataIndex {Icon = 0, Text}; - - ConfigData(); - virtual ~ConfigData(); - - ConfigData &operator=(const KConfigGroup &rhs); - void writeEntries(); - void writeEntry(const char *pKey, AppMap value); - QMap readKeySequenceMapEntry(const char *pKey, - AppMap defaultValue = AppMap()); - - void writeToXmlFile(SnippetMap value); - SnippetMap readFromXmlFile(); - -public slots: - void readEntries(); - -signals: - void changed(const ConfigData&); - -public: - SnippetMap snippets; - bool autoPaste; - QKeySequence pasteKey; - AppMap specialApps; - QString xmlFile; -}; - -#endif // CONFIGDATA_HEADER diff --git a/kdeplasma-addons/applets/paste/list.cpp b/kdeplasma-addons/applets/paste/list.cpp deleted file mode 100644 index 6ccc1395..00000000 --- a/kdeplasma-addons/applets/paste/list.cpp +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright 2008 Petri Damsten - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "list.h" -#include "sendkeys.h" -#include "configdata.h" -#include "pastemacroexpander.h" - -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include - -ListForm::ListForm(QWidget *parent) - : QWidget(parent), m_hide(false), cfg(0) -{ - setupUi(this); - setAttribute(Qt::WA_NoSystemBackground); - icon->setPixmap(KIcon("edit-paste").pixmap(KIconLoader::SizeSmall, - KIconLoader::SizeSmall)); - - Plasma::Delegate *delegate = new Plasma::Delegate; - delegate->setRoleMapping(Plasma::Delegate::SubTitleRole, SubTitleRole); - delegate->setRoleMapping(Plasma::Delegate::SubTitleMandatoryRole, SubTitleMandatoryRole); - treeView->setItemDelegate(delegate); - m_listModel = new QStandardItemModel(this); - treeView->setModel(m_listModel); - treeView->setFocusPolicy(Qt::NoFocus); - - if (KGlobalSettings::singleClick()) { - connect(treeView, SIGNAL(clicked(QModelIndex)), - this, SLOT(clicked(QModelIndex))); - } else { - connect(treeView, SIGNAL(doubleClicked(QModelIndex)), - this, SLOT(clicked(QModelIndex))); - } - connect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()), this, SLOT(themeChanged())); - themeChanged(); -} - -ListForm::~ListForm() -{ -} - -void ListForm::setData(const ConfigData &data) -{ - m_listModel->clear(); - foreach (const QString &txt, data.snippets.keys()) { - QStandardItem *item = new QStandardItem(); - QString tmp = data.snippets[txt][ConfigData::Text]; - item->setData(txt, Qt::DisplayRole); - item->setData(false, SubTitleMandatoryRole); - item->setData(tmp.replace('\n', ' '), SubTitleRole); - item->setData(data.snippets[txt][ConfigData::Text], DataRole); - item->setData(KIcon(data.snippets[txt][ConfigData::Icon]), Qt::DecorationRole); - m_listModel->insertRow(0, item); - } - if (data.autoPaste) { - label->setText(i18n("Text &snippets (Click to paste text):")); - } else { - label->setText(i18n("Text &snippets (Click to copy text to clipboard):")); - } - cfg = &data; -} - -void ListForm::clicked(const QModelIndex &index) -{ - QList windows = KWindowSystem::stackingOrder(); - KWindowInfo info; - static const QStringList classes = - QStringList() << "Plasma" << "Plasma-desktop" << "Plasmoidviewer"; - - // Don't paste to plasma windows - for (int i = windows.count() - 1; i >= 0; --i) { - info = KWindowSystem::windowInfo(windows[i], 0, NET::WM2WindowClass); - //kDebug() << info.windowClassClass(); - if (classes.contains(info.windowClassClass())) { - if (i > 0) { - continue; - } - return; - } - break; - } - QString txt = m_listModel->data(index, DataRole).toString(); - PasteMacroExpander::instance().expandMacros(txt); - //kDebug() << txt; - QApplication::clipboard()->setText(txt); - emit textCopied(); - if (m_hide) { - hide(); - } - if (cfg->autoPaste) { - // Macro expander might change windows focus so activate windows after that - KWindowSystem::activateWindow(info.win()); - if (cfg->specialApps.contains(info.windowClassClass())) { - m_pasteKey = cfg->specialApps[info.windowClassClass()]; - } else { - m_pasteKey = cfg->pasteKey; - } - QTimer::singleShot(200, this, SLOT(paste())); - } - treeView->selectionModel()->clear(); -} - -void ListForm::paste() -{ - SendKeys::send(m_pasteKey); -} - -void ListForm::themeChanged() -{ - label->setStyleSheet(QString("QLabel{color:%1;}") - .arg(Plasma::Theme::defaultTheme()->color(Plasma::Theme::TextColor).name())); - setStyleSheet(QString(".ListForm{background-color:%1;}") - .arg(Plasma::Theme::defaultTheme()->color(Plasma::Theme::BackgroundColor).name())); -} - -void ListForm::setHideAfterClick(bool hide) -{ - m_hide = hide; -} - -#include "moc_list.cpp" diff --git a/kdeplasma-addons/applets/paste/list.h b/kdeplasma-addons/applets/paste/list.h deleted file mode 100644 index 4ba7ed1c..00000000 --- a/kdeplasma-addons/applets/paste/list.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2008 Petri Damsten - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef LIST_HEADER -#define LIST_HEADER - -#include -#include "ui_list.h" - -#include -class ConfigData; -#include - -class ListForm : public QWidget, public Ui::ListForm -{ - Q_OBJECT -public: - enum SpecificRoles { - DataRole = Qt::UserRole + 1, - SubTitleRole, - SubTitleMandatoryRole - }; - - ListForm(QWidget *parent = 0); - virtual ~ListForm(); - - void setHideAfterClick(bool hide); - -public slots: - void setData(const ConfigData &data); - -protected slots: - void clicked(const QModelIndex &index); - void paste(); - void themeChanged(); - -signals: - void textCopied(); - -private: - QStandardItemModel *m_listModel; - bool m_hide; - QKeySequence m_pasteKey; - const ConfigData *cfg; -}; - -#endif diff --git a/kdeplasma-addons/applets/paste/list.ui b/kdeplasma-addons/applets/paste/list.ui deleted file mode 100644 index 9b7771c9..00000000 --- a/kdeplasma-addons/applets/paste/list.ui +++ /dev/null @@ -1,56 +0,0 @@ - - ListForm - - - - 0 - 0 - 400 - 300 - - - - - 0 - - - - - - - - - - - - - - - 0 - 0 - - - - - - - treeView - - - - - - - - - false - - - true - - - - - - - diff --git a/kdeplasma-addons/applets/paste/paste.cpp b/kdeplasma-addons/applets/paste/paste.cpp deleted file mode 100644 index 1482ce27..00000000 --- a/kdeplasma-addons/applets/paste/paste.cpp +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright 2008 Petri Damsten - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "paste.h" -#include "list.h" -#include "snippetconfig.h" -#include "autopasteconfig.h" - -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include - -Paste::Paste(QObject *parent, const QVariantList &args) - : Plasma::PopupApplet(parent, args), m_list(0), m_snippetConfig(0) -{ - setHasConfigurationInterface(true); - setAspectRatioMode(Plasma::IgnoreAspectRatio); - resize(200, 300); - setPopupIcon("edit-paste"); -} - -Paste::~Paste() -{ - m_list->deleteLater(); - m_list = 0; -} - -void Paste::init() -{ - cfg = globalConfig(); - - m_list = new ListForm; - connect(&cfg, SIGNAL(changed(ConfigData)), m_list, SLOT(setData(ConfigData))); - connect(m_list, SIGNAL(textCopied()), this, SLOT(showOk())); - m_list->setData(cfg); -} - -void Paste::createConfigurationInterface(KConfigDialog *parent) -{ - m_snippetConfig = new SnippetConfig; - connect(&cfg, SIGNAL(changed(ConfigData)), - m_snippetConfig, SLOT(setData(ConfigData))); - m_snippetConfig->setData(cfg); - m_autoPasteConfig = new AutoPasteConfig; - connect(&cfg, SIGNAL(changed(ConfigData)), - m_autoPasteConfig, SLOT(setData(ConfigData))); - m_autoPasteConfig->setData(cfg); - - parent->addPage(m_snippetConfig, i18n("Texts"), "accessories-text-editor"); - parent->addPage(m_autoPasteConfig, i18n("Automatic Paste"), "edit-paste"); - connect(parent, SIGNAL(applyClicked()), this, SLOT(configAccepted())); - connect(parent, SIGNAL(okClicked()), this, SLOT(configAccepted())); - connect(m_snippetConfig->textEdit, SIGNAL(textChanged()), parent, SLOT(settingsModified())); - connect(m_snippetConfig->nameEdit, SIGNAL(textChanged(QString)), parent, SLOT(settingsModified())); - connect(m_snippetConfig->list, SIGNAL(itemSelectionChanged()), parent, SLOT(settingsModified())); - connect(m_snippetConfig->addMacroButton, SIGNAL(toggled(bool)), parent, SLOT(settingsModified())); - connect(m_snippetConfig->addButton, SIGNAL(toggled(bool)), parent, SLOT(settingsModified())); - connect(m_snippetConfig->removeButton, SIGNAL(toggled(bool)), parent, SLOT(settingsModified())); - connect(m_autoPasteConfig->autoPasteCheckBox, SIGNAL(toggled(bool)), parent, SLOT(settingsModified())); - connect(m_autoPasteConfig->addButton, SIGNAL(clicked()), parent, SLOT(settingsModified())); - connect(m_autoPasteConfig->editButton, SIGNAL(clicked()), parent, SLOT(settingsModified())); - connect(m_autoPasteConfig->removeButton, SIGNAL(clicked(bool)), parent, SLOT(settingsModified())); - connect(m_autoPasteConfig->pasteKeyButton, SIGNAL(keySequenceChanged(QKeySequence)), parent, SLOT(settingsModified())); - connect(m_autoPasteConfig->appsTreeView->model(), SIGNAL(dataChanged(QModelIndex,QModelIndex)), - parent, SLOT(settingsModified())); -} - -void Paste::configAccepted() -{ - m_snippetConfig->getData(&cfg); - m_autoPasteConfig->getData(&cfg); - m_list->setData(cfg); - cfg.writeEntries(); - emit configNeedsSaving(); -} - -void Paste::configChanged() -{ - cfg.readEntries(); -} - -void Paste::showOk() -{ - // Show ok icon like in DeviceNotifier - setPopupIcon("dialog-ok"); - m_list->icon->setPixmap(KIcon("dialog-ok").pixmap(KIconLoader::SizeSmall, - KIconLoader::SizeSmall)); - QTimer::singleShot(2000, this, SLOT(resetIcon())); -} - -void Paste::resetIcon() -{ - setPopupIcon("edit-paste"); - m_list->icon->setPixmap(KIcon("edit-paste").pixmap(KIconLoader::SizeSmall, - KIconLoader::SizeSmall)); -} - -QWidget *Paste::widget() -{ - return m_list; -} - -#include "moc_paste.cpp" diff --git a/kdeplasma-addons/applets/paste/paste.h b/kdeplasma-addons/applets/paste/paste.h deleted file mode 100644 index ef0e48d3..00000000 --- a/kdeplasma-addons/applets/paste/paste.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2008 Petri Damsten - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef PASTE_HEADER -#define PASTE_HEADER - -#include -#include - -class ListForm; -class SnippetConfig; -class AutoPasteConfig; -namespace Plasma { - class Icon; -} - -class Paste : public Plasma::PopupApplet -{ - Q_OBJECT - public: - Paste(QObject *parent, const QVariantList &args); - ~Paste(); - - virtual void init(); - virtual void createConfigurationInterface(KConfigDialog *parent); - virtual QWidget *widget(); - - public slots: - void showOk(); - void configAccepted(); - void resetIcon(); - void configChanged(); - - private: - ListForm *m_list; - SnippetConfig *m_snippetConfig; - AutoPasteConfig *m_autoPasteConfig; - ConfigData cfg; -}; - -K_EXPORT_PLASMA_APPLET(paste, Paste) - -#endif diff --git a/kdeplasma-addons/applets/paste/pastemacroexpander.cpp b/kdeplasma-addons/applets/paste/pastemacroexpander.cpp deleted file mode 100644 index d01d1c66..00000000 --- a/kdeplasma-addons/applets/paste/pastemacroexpander.cpp +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Copyright 2008 Petri Damsten - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "pastemacroexpander.h" - -#include -#include -#include - -#include - -#include -#include -#include -#include -#include - -class PasteMacroExpanderSingleton -{ - public: - PasteMacroExpander instance; -}; -K_GLOBAL_STATIC(PasteMacroExpanderSingleton, g_pasteMacroExpander) - -PasteMacroExpander& PasteMacroExpander::instance() - { - return g_pasteMacroExpander->instance; - } - -PasteMacroExpander::PasteMacroExpander(QWidget *parent) : QObject(parent) -{ - m_macros["exec"] = QVariantList() - << i18n("Execute Command And Get Output") - << QVariant::fromValue(MacroParam(i18n("Command"), MacroParam::Url)); - m_macros["date"] = QVariantList() - << i18n("Current Date"); - m_macros["time"] = QVariantList() - << i18n("Current Time"); - m_macros["file"] = QVariantList() - << i18n("Insert File Contents") - << QVariant::fromValue(MacroParam(i18n("File"), MacroParam::Url)); - m_macros["password"] = QVariantList() - << i18n("Random Password") - << QVariant::fromValue(MacroParam(i18n("Character count"), MacroParam::Int)) - << QVariant::fromValue(MacroParam(i18n("Lowercase letters"), MacroParam::Boolean)) - << QVariant::fromValue(MacroParam(i18n("Uppercase letters"), MacroParam::Boolean)) - << QVariant::fromValue(MacroParam(i18n("Numbers"), MacroParam::Boolean)) - << QVariant::fromValue(MacroParam(i18n("Symbols"), MacroParam::Boolean)); -} - -QMap PasteMacroExpander::macros() -{ - return m_macros; -} - -bool PasteMacroExpander::expandMacro(const QString &str, QStringList &ret) -{ - QString func; - QString args; - QString result; - int n; - - if ((n = str.indexOf('(')) > 0) { - func = str.left(n).trimmed(); - int m = str.lastIndexOf(')'); - args = str.mid(n + 1, m - n - 1); - } else { - func = str.trimmed(); - } - //kDebug() << str << func << args; - if (m_macros.keys().contains(func)) { - QMetaObject::invokeMethod(this, func.toAscii(), Qt::DirectConnection, - Q_RETURN_ARG(QString, result), - Q_ARG(QString, args)); - ret += result; - return true; - } - return false; -} - -QString PasteMacroExpander::date(const QString& args) -{ - Q_UNUSED(args) - return QDate::currentDate().toString(); -} - -QString PasteMacroExpander::time(const QString& args) -{ - Q_UNUSED(args) - return QTime::currentTime().toString(); -} - -QString PasteMacroExpander::exec(const QString& args) -{ - QProcess process; - - process.start(args, QProcess::ReadOnly); - process.waitForFinished(); - QByteArray ba = process.readAll(); - return QTextCodec::codecForLocale()->toUnicode(ba); -} - -QString PasteMacroExpander::file(const QString& args) -{ - QString tmpFile; - QString txt; - QWidget *p = qobject_cast(parent()); - - if (KIO::NetAccess::download(args, tmpFile, p)) { - QFile file(tmpFile); - if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { - txt = QTextCodec::codecForLocale()->toUnicode(file.readAll()); - } else { - KMessageBox::error(p, i18n("Could not open file: %1",tmpFile)); - } - KIO::NetAccess::removeTempFile(tmpFile); - } else { - KMessageBox::error(p, KIO::NetAccess::lastErrorString()); - } - return txt; -} - -QString PasteMacroExpander::password(const QString& args) -{ - QStringList a = args.split(',', QString::SkipEmptyParts); - static QStringList characterSets = QStringList() - << "abcdefghijklmnopqrstuvwxyz" - << "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - << "0123456789" - << "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"; - - int charCount = 8; - QString chars; - QString result; - - if (a.count() > 0) { - charCount = qMax(a[0].trimmed().toInt(), 8); - } - - if (a.count() > 1) { - chars += (a[1].trimmed() == "true") ? characterSets[0] : ""; - } - - if (a.count() > 2) { - chars += (a[2].trimmed() == "true") ? characterSets[1] : ""; - } - - if (a.count() > 3) { - chars += (a[3].trimmed() == "true") ? characterSets[2] : ""; - } - - if (a.count() > 4) { - chars += (a[4].trimmed() == "true") ? characterSets[3] : ""; - } - - // no character set arguments - if (chars.isEmpty()) { - chars = characterSets[0]; - chars += characterSets[1]; - chars += characterSets[2]; - } - - const int setSize = chars.count(); - for (int i = 0; i < charCount; ++i) { - result += chars[KRandom::randomMax(setSize)]; - } - //kDebug() << result; - return result; -} - -#include "moc_pastemacroexpander.cpp" diff --git a/kdeplasma-addons/applets/paste/pastemacroexpander.h b/kdeplasma-addons/applets/paste/pastemacroexpander.h deleted file mode 100644 index 6f878053..00000000 --- a/kdeplasma-addons/applets/paste/pastemacroexpander.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2008 Petri Damsten - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef PASTEMACROEXPANDER_HEADER -#define PASTEMACROEXPANDER_HEADER - -#include -#include -#include -#include - -class MacroParam -{ -public: - enum ParamType { - String = 0, - Int, - Boolean, - Url - }; - - explicit MacroParam(const QString& n = QString(), ParamType t = String) : name(n), type(t) {}; - QString name; - ParamType type; -}; - -Q_DECLARE_METATYPE(MacroParam) - -class PasteMacroExpander : public QObject, public KWordMacroExpander -{ - Q_OBJECT -public: - static PasteMacroExpander& instance(); - - QMap macros(); - -protected: - PasteMacroExpander(QWidget* parent = 0); - friend class PasteMacroExpanderSingleton; - - virtual bool expandMacro(const QString &str, QStringList &ret); - -protected slots: - QString exec(const QString& args); - QString date(const QString& args); - QString time(const QString& args); - QString file(const QString& args); - QString password(const QString& args); - -private: - QMap m_macros; -}; - -#endif // PASTEMACROEXPANDER_HEADER diff --git a/kdeplasma-addons/applets/paste/plasma-applet-paste.desktop b/kdeplasma-addons/applets/paste/plasma-applet-paste.desktop deleted file mode 100644 index 282bf4f5..00000000 --- a/kdeplasma-addons/applets/paste/plasma-applet-paste.desktop +++ /dev/null @@ -1,130 +0,0 @@ -[Desktop Entry] -Encoding=UTF-8 -Name=Paste -Name[ar]=ألصق -Name[ast]=Apegar -Name[bs]=Umetni -Name[ca]=Enganxa -Name[ca@valencia]=Apega -Name[cs]=Vložit -Name[da]=Indsæt -Name[de]=Einfügen -Name[el]=Επικόλληση -Name[en_GB]=Paste -Name[eo]=Glui -Name[es]=Pegar -Name[et]=Asetamine -Name[eu]=Itsatsi -Name[fi]=Liitä -Name[fr]=Coller -Name[ga]=Greamaigh -Name[gl]=Pegar -Name[he]=הדבק -Name[hr]=Zalijepi -Name[hu]=Beillesztés -Name[is]=Líma -Name[it]=Incolla -Name[ja]=Paste -Name[kk]=Енгізу -Name[km]=បិទភ្ជាប់ -Name[ko]=붙여넣을 곳 -Name[ku]=Pê Ve Bike -Name[lt]=Padėti -Name[lv]=Ielīmēt -Name[mr]=चिटकवा -Name[nb]=Lim inn -Name[nds]=Infögen -Name[nl]=Plakken -Name[nn]=Tekstbitar -Name[pa]=ਚੇਪੋ -Name[pl]=Wklej -Name[pt]=Colar -Name[pt_BR]=Colar -Name[ro]=Lipește -Name[ru]=Вставка текста -Name[sk]=Vložiť -Name[sl]=Prilepi -Name[sq]=Ngjit -Name[sr]=налепљивање -Name[sr@ijekavian]=наљепљивање -Name[sr@ijekavianlatin]=naljepljivanje -Name[sr@latin]=nalepljivanje -Name[sv]=Klistra in -Name[th]=แปะ -Name[tr]=Yapıştır -Name[ug]=چاپلا -Name[uk]=Вставка -Name[wa]=Aclaper -Name[x-test]=xxPastexx -Name[zh_CN]=粘贴 -Name[zh_TW]=貼上 -Comment=Paste text snippets -Comment[ar]=ألصق قطع من النص -Comment[ast]=Apegar fragmentos de testu -Comment[bs]=Umeće dijelove teksta -Comment[ca]=Enganxa retalls de text -Comment[ca@valencia]=Apega retalls de text -Comment[cs]=Vložit textové úryvky -Comment[da]=Indsætter tekststbidder. -Comment[de]=Textbaustein einfügen -Comment[el]=Επικόλληση δειγμάτων κειμένου -Comment[en_GB]=Paste text snippets -Comment[es]=Pegar fragmentos de texto -Comment[et]=Tekstijuppide asetamine -Comment[eu]=Itsatsi testu zatiak -Comment[fi]=Liitä tekstipalasia -Comment[fr]=Colle des fragments de texte -Comment[ga]=Greamaigh blúirí téacs -Comment[gl]=Pega retallos de texto -Comment[he]=מעתיק קטעי טקסט שונים -Comment[hr]=Zalijepi tekstualne svaštice -Comment[hu]=Szövegdarabok beillesztése -Comment[is]=Líma textabrot -Comment[it]=Incolla frammenti di testo -Comment[ja]=定型表現を貼り付けます -Comment[kk]=Мәтін үзінділерін енгізу -Comment[km]=បិទភ្ជាប់​ snippets អត្ថបទ -Comment[ko]=텍스트를 잠깐 붙여둘 곳 -Comment[ku]=Parî yên nivîsê pêve bike -Comment[lt]=Padėti teksto gabalėlius -Comment[lv]=Ielīmēt teksta fragmentus -Comment[mr]=मजकूर स्निपेट्स चिटकवा -Comment[nb]=Lim inn tekstbiter -Comment[nds]=Textsnippels infögen -Comment[nl]=Tekstfragmenten plakken -Comment[nn]=Lim inn tekstbitar -Comment[pa]=ਟੈਕਸਟ ਸਨਿੱਪਟ ਚੇਪੋ -Comment[pl]=Wklejanie fragmentów tekstu -Comment[pt]=Colar excertos de texto -Comment[pt_BR]=Cola trechos de texto -Comment[ro]=Lipește frînturi de text -Comment[ru]=Вставка маленьких текстовых шаблонов -Comment[sk]=Vloženie textových úryvkov -Comment[sl]=Prilepite besedilne izrezke -Comment[sr]=Налепљујте исечке текста -Comment[sr@ijekavian]=Наљепљујте исјечке текста -Comment[sr@ijekavianlatin]=Naljepljujte isječke teksta -Comment[sr@latin]=Nalepljujte isečke teksta -Comment[sv]=Klistra in textsnuttar -Comment[th]=แปะชิ้นส่วนต่าง ๆ ของข้อความ -Comment[tr]=Metin parçacıklarını yapıştırın -Comment[ug]=تېكىست پۇرۇچلىرىنى چاپلايدۇ -Comment[uk]=Вставка уривків тексту -Comment[wa]=Aclaper des bokets d' tecse -Comment[x-test]=xxPaste text snippetsxx -Comment[zh_CN]=粘贴文本片断 -Comment[zh_TW]=貼上文字片段 -Type=Service -Icon=edit-paste -ServiceTypes=Plasma/Applet - -X-KDE-Library=plasma_applet_paste -X-KDE-PluginInfo-Author=Petri Damstén -X-KDE-PluginInfo-Email=damu@iki.fi -X-KDE-PluginInfo-Name=paste -X-KDE-PluginInfo-Version=1.0 -X-KDE-PluginInfo-Website= -X-KDE-PluginInfo-Category=Utilities -X-KDE-PluginInfo-Depends= -X-KDE-PluginInfo-License=GPL -X-KDE-PluginInfo-EnabledByDefault=true diff --git a/kdeplasma-addons/applets/paste/sendkeys.cpp b/kdeplasma-addons/applets/paste/sendkeys.cpp deleted file mode 100644 index e8533d14..00000000 --- a/kdeplasma-addons/applets/paste/sendkeys.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright 2008 Petri Damsten - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "sendkeys.h" -#include -#include -#include -#include -#include -#include -#include - -void SendKeys::send(const QKeySequence &ks) -{ - for (uint i = 0; i < ks.count(); ++i) { - SendKeys::send(ks[i]); - } -} - -void SendKeys::send(uint k) -{ - Display *dsp = QX11Info::display(); - uint keycode = k & 0x01FFFFFF; - XKeyEvent event; - Window currentFocus; - int focusState; - - if (keycode < Qt::Key_Space || keycode > Qt::Key_ydiaeresis) { - return; - } - keycode = XKeysymToKeycode(dsp, keycode); - - event.display = dsp; - XGetInputFocus(dsp, ¤tFocus, &focusState); - event.window = currentFocus; - event.root = DefaultRootWindow(dsp); - event.subwindow = None; - event.time = CurrentTime; - event.x = 0; - event.y = 0; - event.x_root = 0; - event.y_root = 0; - event.same_screen = true; - event.type = KeyPress; - event.keycode = keycode; - event.state = 0; - if (k & Qt::ALT) { - event.state |= Mod1Mask; - } - if (k & Qt::CTRL) { - event.state |= ControlMask; - } - if (k & Qt::META) { - event.state |= Mod1Mask; - } - if (k & Qt::SHIFT) { - event.state |= ShiftMask; - } - XSendEvent(dsp, InputFocus, false, KeyPressMask, (XEvent *)&event); - - event.type = KeyRelease; - event.time = CurrentTime; - XSendEvent(dsp, InputFocus, false, KeyReleaseMask, (XEvent *)&event); -} diff --git a/kdeplasma-addons/applets/paste/sendkeys.h b/kdeplasma-addons/applets/paste/sendkeys.h deleted file mode 100644 index 1aa3eae1..00000000 --- a/kdeplasma-addons/applets/paste/sendkeys.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2008 Petri Damsten - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef SENDKEYS_HEADER -#define SENDKEYS_HEADER - -#include - -class SendKeys -{ -public: - static void send(const QKeySequence &ks); - static void send(uint k); -}; - -#endif diff --git a/kdeplasma-addons/applets/paste/snippetconfig.cpp b/kdeplasma-addons/applets/paste/snippetconfig.cpp deleted file mode 100644 index ec4acc72..00000000 --- a/kdeplasma-addons/applets/paste/snippetconfig.cpp +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright 2008 Petri Damsten - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include "snippetconfig.h" -#include "configdata.h" -#include "addmacro.h" -#include - -SnippetConfig::SnippetConfig(QWidget *parent) - : QWidget(parent) -{ - setupUi(this); - addButton->setIcon(KIcon("list-add")); - removeButton->setIcon(KIcon("list-remove")); - addMacroButton->setIcon(KIcon("system-run")); - connect(addButton, SIGNAL(clicked()), this, SLOT(addClicked())); - connect(removeButton, SIGNAL(clicked()), this, SLOT(removeClicked())); - connect(addMacroButton, SIGNAL(clicked()), this, SLOT(addMacroClicked())); - connect(list, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), - this, SLOT(currentItemChanged(QListWidgetItem*,QListWidgetItem*))); - connect(list, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), - this, SLOT(enableWidgets())); - connect(nameEdit, SIGNAL(textChanged(QString)), - this, SLOT(nameChanged(QString))); - connect(textEdit, SIGNAL(textChanged()), this, SLOT(textChanged())); - connect(iconButton, SIGNAL(iconChanged(QString)), - this, SLOT(iconChanged(QString))); - enableWidgets(); -} - -SnippetConfig::~SnippetConfig() -{ -} - -void SnippetConfig::setData(const ConfigData &data) -{ - list->clear(); - foreach (const QString &txt, data.snippets.keys()) { - if (!txt.isEmpty() || !data.snippets[txt].isEmpty()) { - QListWidgetItem *item = new QListWidgetItem(txt, list); - item->setData(TextRole, data.snippets[txt][ConfigData::Text]); - item->setData(IconNameRole, data.snippets[txt][ConfigData::Icon]); - item->setData(Qt::DecorationRole, KIcon(data.snippets[txt][ConfigData::Icon])); - } - } -} - -void SnippetConfig::getData(ConfigData *data) -{ - QListWidgetItem *current = list->currentItem(); - if (current) { - current->setData(Qt::UserRole, textEdit->toPlainText()); - } - data->snippets.clear(); - for (int i = 0; i < list->count(); ++i) { - QListWidgetItem *item = list->item(i); - if (!item->text().isEmpty() || !item->data(TextRole).toString().isEmpty()) { - data->snippets[item->text()] = QStringList() << - item->data(IconNameRole).toString() << item->data(TextRole).toString(); - } - } -} - -void SnippetConfig::addClicked() -{ - newItem(); - nameEdit->setFocus(); - nameEdit->selectAll(); -} - -void SnippetConfig::addMacroClicked() -{ - QPointer dlg = new AddMacro(this); - if (dlg->exec() == QDialog::Accepted) { - textEdit->insertPlainText(dlg->macro()); - } - delete dlg; -} - -void SnippetConfig::removeClicked() -{ - delete list->currentItem(); -} - -void SnippetConfig::currentItemChanged(QListWidgetItem *current, QListWidgetItem *previous) -{ - if (previous) { - previous->setData(TextRole, textEdit->toPlainText()); - previous->setData(IconNameRole, iconButton->icon()); - } - if (current) { - nameEdit->setText(current->text()); - textEdit->setPlainText(current->data(TextRole).toString()); - iconButton->setIcon(current->data(IconNameRole).toString()); - } else { - nameEdit->blockSignals(true); - textEdit->blockSignals(true); - nameEdit->setText(""); - textEdit->setPlainText(""); - iconButton->setIcon(""); - nameEdit->blockSignals(false); - textEdit->blockSignals(false); - } -} - -void SnippetConfig::nameChanged(const QString& name) -{ - QListWidgetItem *current = list->currentItem(); - - if (!current) { - current = newItem(QString(), name); - } - current->setText(name); -} - -void SnippetConfig::textChanged() -{ - QListWidgetItem *current = list->currentItem(); - - if (!current) { - newItem(textEdit->toPlainText()); - } -} -void SnippetConfig::enableWidgets() -{ - removeButton->setEnabled(list->selectionModel()->currentIndex().isValid()); - iconButton->setEnabled(list->selectionModel()->currentIndex().isValid()); -} - -void SnippetConfig::iconChanged(const QString &icon) -{ - QListWidgetItem *current = list->currentItem(); - - if (current) { - current->setData(IconNameRole, icon); - current->setData(Qt::DecorationRole, KIcon(icon)); - } -} - -QListWidgetItem *SnippetConfig::newItem(const QString& text, const QString& name) -{ - QListWidgetItem *item = new QListWidgetItem(name, list); - item->setData(TextRole, text); - item->setData(IconNameRole, "edit-paste"); - item->setData(Qt::DecorationRole, KIcon("edit-paste")); - list->setCurrentItem(item); - QTextCursor tc = textEdit->textCursor(); - tc.setPosition(text.size()); - textEdit->setTextCursor(tc); - return item; -} - -#include "moc_snippetconfig.cpp" diff --git a/kdeplasma-addons/applets/paste/snippetconfig.h b/kdeplasma-addons/applets/paste/snippetconfig.h deleted file mode 100644 index 8e008358..00000000 --- a/kdeplasma-addons/applets/paste/snippetconfig.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2008 Petri Damsten - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#ifndef SNIPPETCONFIG_HEADER -#define SNIPPETCONFIG_HEADER - -#include -#include -#include "ui_snippetconfig.h" - -#include -class ConfigData; - -class SnippetConfig : public QWidget, public Ui::SnippetConfig -{ - Q_OBJECT - enum SnippetRoles { TextRole = Qt::UserRole, IconNameRole }; -public: - SnippetConfig(QWidget *parent = 0); - virtual ~SnippetConfig(); - - void getData(ConfigData *data); - -public slots: - void setData(const ConfigData &data); - -protected slots: - void addClicked(); - void removeClicked(); - void addMacroClicked(); - void currentItemChanged(QListWidgetItem *current, QListWidgetItem *previous); - void nameChanged(const QString& name); - void textChanged(); - void enableWidgets(); - void iconChanged(const QString &icon); - -protected: - QListWidgetItem *newItem(const QString& text = QString(), - const QString& name = i18n("Untitled")); -}; - -#endif // SNIPPETCONFIG_HEADER diff --git a/kdeplasma-addons/applets/paste/snippetconfig.ui b/kdeplasma-addons/applets/paste/snippetconfig.ui deleted file mode 100644 index 958ab6e2..00000000 --- a/kdeplasma-addons/applets/paste/snippetconfig.ui +++ /dev/null @@ -1,144 +0,0 @@ - - Petri Damstén - SnippetConfig - - - - 0 - 0 - 562 - 433 - - - - Configure Paste Snippets - - - - - - - - &Texts: - - - list - - - - - - - - 0 - 0 - - - - - - - - - - - - - - - - &Name: - - - nameEdit - - - - - - - - - - - - - 0 - 0 - - - - - - - - - - Text to be &pasted: - - - textEdit - - - - - - - - 0 - 0 - - - - KTextEdit::NoWrap - - - false - - - - - - - &Add Macro... - - - - - - - - - &Add - - - - - - - &Remove - - - - - - - - - - - - KIconButton - QPushButton -
kicondialog.h
-
-
- - list - nameEdit - iconButton - addButton - removeButton - - -