mirror of
https://bitbucket.org/smil3y/kde-extraapps.git
synced 2025-02-23 10:22:52 +00:00
kdeplasma-addons: reimplement konsoleprofiles applet
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
eb919cf73f
commit
183876c0c6
14 changed files with 262 additions and 583 deletions
|
@ -1,6 +1,20 @@
|
|||
project(konsoleprofiles)
|
||||
|
||||
install(DIRECTORY package/
|
||||
DESTINATION ${KDE4_DATA_INSTALL_DIR}/plasma/plasmoids/konsoleprofiles)
|
||||
set(konsoleprofiles_SRCS
|
||||
konsoleprofiles.cpp
|
||||
)
|
||||
|
||||
install(FILES package/metadata.desktop DESTINATION ${KDE4_SERVICES_INSTALL_DIR} RENAME plasma-applet-konsoleprofiles.desktop)
|
||||
kde4_add_plugin(plasma_applet_konsoleprofiles ${konsoleprofiles_SRCS})
|
||||
target_link_libraries(plasma_applet_konsoleprofiles
|
||||
KDE4::plasma
|
||||
)
|
||||
|
||||
install(
|
||||
TARGETS plasma_applet_konsoleprofiles
|
||||
DESTINATION ${KDE4_PLUGIN_INSTALL_DIR}
|
||||
)
|
||||
|
||||
install(
|
||||
FILES plasma-applet-konsoleprofiles.desktop
|
||||
DESTINATION ${KDE4_SERVICES_INSTALL_DIR}
|
||||
)
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#! /usr/bin/env bash
|
||||
# only need to change the name of the applet
|
||||
$XGETTEXT `find . -name \*.qml` -L Java -o $podir/konsoleprofiles.pot
|
||||
#!/bin/bash
|
||||
$EXTRACTRC `find . -name \*.rc -o -name \*.ui -o -name \*.kcfg` >> rc.cpp
|
||||
$XGETTEXT `find . -name \*.js -o -name \*.qml -o -name \*.cpp` -o $podir/konsoleprofiles.pot
|
||||
rm -f rc.cpp
|
||||
|
||||
|
|
194
kdeplasma-addons/applets/konsoleprofiles/konsoleprofiles.cpp
Normal file
194
kdeplasma-addons/applets/konsoleprofiles/konsoleprofiles.cpp
Normal file
|
@ -0,0 +1,194 @@
|
|||
/* This file is part of the KDE project
|
||||
Copyright (C) 2023 Ivailo Monev <xakepa10@gmail.com>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License version 2, as published by the Free Software Foundation.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public License
|
||||
along with this library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "konsoleprofiles.h"
|
||||
|
||||
#include <QTimer>
|
||||
#include <QFileInfo>
|
||||
#include <QGraphicsLinearLayout>
|
||||
#include <Plasma/IconWidget>
|
||||
#include <Plasma/Separator>
|
||||
#include <Plasma/ToolButton>
|
||||
#include <KDirWatch>
|
||||
#include <KStandardDirs>
|
||||
#include <KIcon>
|
||||
#include <KToolInvocation>
|
||||
#include <KDebug>
|
||||
|
||||
// standard issue margin/spacing
|
||||
static const int s_spacing = 4;
|
||||
|
||||
class KonsoleProfilesWidget : public QGraphicsWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
KonsoleProfilesWidget(KonsoleProfilesApplet* konsoleprofiles);
|
||||
|
||||
private Q_SLOTS:
|
||||
void slotUpdateLayout();
|
||||
void slotProfileClicked();
|
||||
|
||||
private:
|
||||
void addSpacer();
|
||||
|
||||
KonsoleProfilesApplet* m_konsoleprofiles;
|
||||
QGraphicsLinearLayout* m_layout;
|
||||
Plasma::IconWidget* m_iconwidget;
|
||||
Plasma::Separator* m_separator;
|
||||
QGraphicsWidget* m_spacer;
|
||||
QList<Plasma::ToolButton*> m_profilebuttons;
|
||||
KDirWatch* m_dirwatch;
|
||||
};
|
||||
|
||||
KonsoleProfilesWidget::KonsoleProfilesWidget(KonsoleProfilesApplet* konsoleprofiles)
|
||||
: QGraphicsWidget(konsoleprofiles),
|
||||
m_konsoleprofiles(konsoleprofiles),
|
||||
m_layout(nullptr),
|
||||
m_iconwidget(nullptr),
|
||||
m_separator(nullptr),
|
||||
m_spacer(nullptr),
|
||||
m_dirwatch(nullptr)
|
||||
{
|
||||
m_layout = new QGraphicsLinearLayout(Qt::Vertical, this);
|
||||
m_layout->setContentsMargins(0, 0, 0, 0);
|
||||
m_layout->setSpacing(s_spacing);
|
||||
|
||||
m_iconwidget = new Plasma::IconWidget(this);
|
||||
m_iconwidget->setOrientation(Qt::Horizontal);
|
||||
m_iconwidget->setAcceptHoverEvents(false);
|
||||
m_iconwidget->setAcceptedMouseButtons(Qt::NoButton);
|
||||
m_iconwidget->setText(i18n("Konsole Profiles"));
|
||||
m_iconwidget->setIcon("utilities-terminal");
|
||||
m_layout->addItem(m_iconwidget);
|
||||
|
||||
m_separator = new Plasma::Separator(this);
|
||||
m_layout->addItem(m_separator);
|
||||
|
||||
addSpacer();
|
||||
|
||||
setLayout(m_layout);
|
||||
|
||||
m_dirwatch = new KDirWatch(this);
|
||||
const QStringList konsoleprofiledirs = KGlobal::dirs()->findDirs("data", "konsole/");
|
||||
foreach (const QString &konsoleprofiledir, konsoleprofiledirs) {
|
||||
m_dirwatch->addDir(konsoleprofiledir);
|
||||
}
|
||||
connect(
|
||||
m_dirwatch, SIGNAL(dirty(QString)),
|
||||
this, SLOT(slotUpdateLayout())
|
||||
);
|
||||
}
|
||||
|
||||
void KonsoleProfilesWidget::slotUpdateLayout()
|
||||
{
|
||||
foreach (Plasma::ToolButton* profilebutton, m_profilebuttons) {
|
||||
m_layout->removeItem(profilebutton);
|
||||
}
|
||||
qDeleteAll(m_profilebuttons);
|
||||
m_profilebuttons.clear();
|
||||
if (m_spacer) {
|
||||
m_layout->removeItem(m_spacer);
|
||||
delete m_spacer;
|
||||
m_spacer = nullptr;
|
||||
}
|
||||
|
||||
bool hasprofiles = false;
|
||||
const QStringList konsoleprofiles = KGlobal::dirs()->findAllResources(
|
||||
"data", "konsole/*.profile",
|
||||
KStandardDirs::NoDuplicates
|
||||
);
|
||||
foreach (const QString &konsoleprofile, konsoleprofiles) {
|
||||
KConfig kconfig(konsoleprofile, KConfig::SimpleConfig);
|
||||
KConfigGroup kconfiggroup(&kconfig, "General");
|
||||
const QString profilename = QFileInfo(konsoleprofile).baseName();
|
||||
if (profilename.isEmpty()) {
|
||||
kWarning() << "empty profile name for" << konsoleprofile;
|
||||
continue;
|
||||
}
|
||||
hasprofiles = true;
|
||||
QString profileprettyname = kconfiggroup.readEntry("Name");
|
||||
if (profileprettyname.isEmpty()) {
|
||||
profileprettyname = profilename;
|
||||
}
|
||||
Plasma::ToolButton* profilebutton = new Plasma::ToolButton(this);
|
||||
profilebutton->setText(profileprettyname);
|
||||
profilebutton->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||
profilebutton->setProperty("_k_profile", profilename);
|
||||
connect(
|
||||
profilebutton, SIGNAL(clicked()),
|
||||
this, SLOT(slotProfileClicked())
|
||||
);
|
||||
m_profilebuttons.append(profilebutton);
|
||||
m_layout->addItem(profilebutton);
|
||||
}
|
||||
|
||||
addSpacer();
|
||||
adjustSize();
|
||||
}
|
||||
|
||||
void KonsoleProfilesWidget::addSpacer()
|
||||
{
|
||||
Q_ASSERT(!m_spacer);
|
||||
m_spacer = new QGraphicsWidget(this);
|
||||
m_spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
m_spacer->setMinimumSize(1, 1);
|
||||
m_layout->addItem(m_spacer);
|
||||
}
|
||||
|
||||
void KonsoleProfilesWidget::slotProfileClicked()
|
||||
{
|
||||
Plasma::ToolButton* profilebutton = qobject_cast<Plasma::ToolButton*>(sender());
|
||||
const QString profilename = profilebutton->property("_k_profile").toString();
|
||||
Q_ASSERT(!profilename.isEmpty());
|
||||
QStringList konsoleargs;
|
||||
konsoleargs << "--profile" << profilename;
|
||||
QString invocationerror;
|
||||
const int invocationresult = KToolInvocation::kdeinitExec("konsole", konsoleargs, &invocationerror);
|
||||
if (invocationresult != 0) {
|
||||
m_konsoleprofiles->showMessage(KIcon("dialog-error"), invocationerror, Plasma::ButtonOk);
|
||||
}
|
||||
}
|
||||
|
||||
KonsoleProfilesApplet::KonsoleProfilesApplet(QObject *parent, const QVariantList &args)
|
||||
: Plasma::PopupApplet(parent, args),
|
||||
m_konsoleprofileswidget(nullptr)
|
||||
{
|
||||
KGlobal::locale()->insertCatalog("konsoleprofiles");
|
||||
setAspectRatioMode(Plasma::AspectRatioMode::IgnoreAspectRatio);
|
||||
setPopupIcon("utilities-terminal");
|
||||
setPreferredSize(290, 340);
|
||||
m_konsoleprofileswidget = new KonsoleProfilesWidget(this);
|
||||
}
|
||||
|
||||
KonsoleProfilesApplet::~KonsoleProfilesApplet()
|
||||
{
|
||||
delete m_konsoleprofileswidget;
|
||||
}
|
||||
|
||||
void KonsoleProfilesApplet::init()
|
||||
{
|
||||
QTimer::singleShot(500, m_konsoleprofileswidget, SLOT(slotUpdateLayout()));
|
||||
}
|
||||
|
||||
QGraphicsWidget* KonsoleProfilesApplet::graphicsWidget()
|
||||
{
|
||||
return m_konsoleprofileswidget;
|
||||
}
|
||||
|
||||
#include "moc_konsoleprofiles.cpp"
|
||||
#include "konsoleprofiles.moc"
|
45
kdeplasma-addons/applets/konsoleprofiles/konsoleprofiles.h
Normal file
45
kdeplasma-addons/applets/konsoleprofiles/konsoleprofiles.h
Normal file
|
@ -0,0 +1,45 @@
|
|||
/* This file is part of the KDE project
|
||||
Copyright (C) 2023 Ivailo Monev <xakepa10@gmail.com>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License version 2, as published by the Free Software Foundation.
|
||||
|
||||
This library 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
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public License
|
||||
along with this library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef KONSOLEPROFILES_H
|
||||
#define KONSOLEPROFILES_H
|
||||
|
||||
#include <Plasma/PopupApplet>
|
||||
|
||||
class KonsoleProfilesWidget;
|
||||
|
||||
class KonsoleProfilesApplet : public Plasma::PopupApplet
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
KonsoleProfilesApplet(QObject *parent, const QVariantList &args);
|
||||
~KonsoleProfilesApplet();
|
||||
|
||||
// Plasma::Applet reimplementation
|
||||
void init() final;
|
||||
// Plasma::PopupApplet reimplementation
|
||||
QGraphicsWidget* graphicsWidget() final;
|
||||
|
||||
private:
|
||||
friend KonsoleProfilesWidget;
|
||||
KonsoleProfilesWidget *m_konsoleprofileswidget;
|
||||
};
|
||||
|
||||
K_EXPORT_PLASMA_APPLET(konsoleprofiles, KonsoleProfilesApplet)
|
||||
|
||||
#endif // KONSOLEPROFILES_H
|
|
@ -1,181 +0,0 @@
|
|||
/*****************************************************************************
|
||||
* Copyright (C) 2011, 2012 by Shaun Reich <shaun.reich@kdemail.net> *
|
||||
* *
|
||||
* 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 <http://www.gnu.org/licenses/>. *
|
||||
*****************************************************************************/
|
||||
|
||||
import QtQuick 1.1
|
||||
import org.kde.qtextracomponents 0.1
|
||||
|
||||
import org.kde.plasma.core 0.1 as PlasmaCore
|
||||
import org.kde.plasma.components 0.1 as PlasmaComponents
|
||||
|
||||
Item {
|
||||
id: konsoleProfiles
|
||||
|
||||
property int minimumWidth: 200
|
||||
property int minimumHeight: 300
|
||||
|
||||
function popupEventSlot(shown) {
|
||||
if (shown) {
|
||||
view.forceActiveFocus();
|
||||
}
|
||||
}
|
||||
|
||||
PlasmaCore.DataSource {
|
||||
id: profilesSource
|
||||
engine: "org.kde.konsoleprofiles"
|
||||
onSourceAdded: connectSource(source)
|
||||
onSourceRemoved: disconnectSource(source)
|
||||
|
||||
Component.onCompleted: connectedSources = sources
|
||||
}
|
||||
|
||||
PlasmaCore.SortFilterModel {
|
||||
id: profilesModel
|
||||
sortRole: "prettyName"
|
||||
sortOrder: "AscendingOrder"
|
||||
sourceModel: PlasmaCore.DataModel {
|
||||
dataSource: profilesSource
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
plasmoid.popupIcon = "utilities-terminal";
|
||||
plasmoid.aspectRatioMode = IgnoreAspectRatio;
|
||||
plasmoid.popupEvent.connect('popupEvent', popupEventSlot);
|
||||
}
|
||||
|
||||
PlasmaCore.Svg {
|
||||
id: lineSvg
|
||||
imagePath: "widgets/line"
|
||||
}
|
||||
|
||||
Row {
|
||||
id: headerRow
|
||||
anchors { left: parent.left; right: parent.right }
|
||||
|
||||
QIconItem {
|
||||
id: appIcon
|
||||
icon: QIcon("utilities-terminal")
|
||||
width: 32
|
||||
height: 32
|
||||
}
|
||||
|
||||
PlasmaComponents.Label {
|
||||
id: header
|
||||
text: i18n("Konsole Profiles")
|
||||
horizontalAlignment: Text.AlignHCenter | Text.AlignVCenter
|
||||
width: parent.width - appIcon.width * 2
|
||||
height: parent.height
|
||||
}
|
||||
}
|
||||
|
||||
PlasmaCore.SvgItem {
|
||||
id: separator
|
||||
|
||||
anchors { left: headerRow.left; right: headerRow.right; top: headerRow.bottom }
|
||||
svg: lineSvg
|
||||
elementId: "horizontal-line"
|
||||
height: lineSvg.elementSize("horizontal-line").height
|
||||
}
|
||||
|
||||
Text {
|
||||
id: textMetric
|
||||
visible: false
|
||||
// translated but not used, we just need length/height
|
||||
text: i18n("Arbitrary String Which Says Something")
|
||||
}
|
||||
|
||||
ListView {
|
||||
id: view
|
||||
|
||||
anchors { left: parent.left; right: scrollBar.left; bottom: parent.bottom; top: separator.bottom; topMargin: 5 }
|
||||
|
||||
model: profilesModel
|
||||
clip: true
|
||||
focus: true
|
||||
keyNavigationWraps: true
|
||||
|
||||
delegate: Item {
|
||||
id: listdelegate
|
||||
height: textMetric.paintedHeight * 2
|
||||
|
||||
anchors {
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
}
|
||||
|
||||
function openProfile() {
|
||||
var service = profilesSource.serviceForSource(model["DataEngineSource"])
|
||||
var operation = service.operationParameters("open")
|
||||
var job = service.startOperationCall("open", operation)
|
||||
}
|
||||
|
||||
PlasmaComponents.Label {
|
||||
id: profileText
|
||||
|
||||
anchors {
|
||||
verticalCenter: parent.verticalCenter
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
leftMargin: 10
|
||||
rightMargin: 10
|
||||
}
|
||||
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
text: model.prettyName
|
||||
elide: Text.ElideRight
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
height: parent.height + 15
|
||||
anchors { left: parent.left; right: parent.right;}
|
||||
hoverEnabled: true
|
||||
|
||||
onClicked: {
|
||||
openProfile();
|
||||
}
|
||||
|
||||
onEntered: {
|
||||
view.currentIndex = index;
|
||||
}
|
||||
}
|
||||
|
||||
Keys.onPressed: {
|
||||
if (event.key == Qt.Key_Enter || event.key == Qt.Key_Return)
|
||||
openProfile();
|
||||
}
|
||||
}
|
||||
|
||||
highlight: PlasmaComponents.Highlight {
|
||||
hover: true
|
||||
}
|
||||
|
||||
highlightMoveDuration: 250
|
||||
highlightMoveSpeed: 1
|
||||
}
|
||||
|
||||
PlasmaComponents.ScrollBar {
|
||||
id: scrollBar
|
||||
|
||||
anchors { bottom: parent.bottom; top: separator.top; right: parent.right }
|
||||
|
||||
orientation: Qt.Vertical
|
||||
stepSize: view.count / 4
|
||||
scrollButtonInterval: view.count / 4
|
||||
|
||||
flickableItem: view
|
||||
}
|
||||
}
|
|
@ -113,13 +113,12 @@ Comment[zh_TW]=列出並啟動 Konsole 設定檔
|
|||
Icon=utilities-terminal
|
||||
Type=Service
|
||||
X-KDE-ServiceTypes=Plasma/Applet,Plasma/PopupApplet
|
||||
X-KDE-Library=plasma_applet_konsoleprofiles
|
||||
|
||||
X-Plasma-API=declarativeappletscript
|
||||
X-Plasma-MainScript=ui/konsoleprofiles.qml
|
||||
X-Plasma-DefaultSize=290,340
|
||||
|
||||
X-KDE-PluginInfo-Author=Shaun Reich
|
||||
X-KDE-PluginInfo-Email=shaun.reich@kdemail.net
|
||||
X-KDE-PluginInfo-Author=Ivailo Monev
|
||||
X-KDE-PluginInfo-Email=xakepa10@gmail.com
|
||||
X-KDE-PluginInfo-Name=konsoleprofiles
|
||||
X-KDE-PluginInfo-Version=0.1
|
||||
X-KDE-PluginInfo-Website=
|
|
@ -1,2 +1 @@
|
|||
add_subdirectory(potd)
|
||||
add_subdirectory(konsoleprofiles)
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
set(konsoleprofilesengine_SRCS
|
||||
konsoleprofilesengine.cpp
|
||||
konsoleprofilesservice.cpp
|
||||
)
|
||||
|
||||
kde4_add_plugin(plasma_engine_konsoleprofiles ${konsoleprofilesengine_SRCS})
|
||||
target_link_libraries(plasma_engine_konsoleprofiles KDE4::plasma KDE4::kio)
|
||||
|
||||
install(TARGETS plasma_engine_konsoleprofiles DESTINATION ${KDE4_PLUGIN_INSTALL_DIR})
|
||||
install(FILES plasma-dataengine-konsoleprofiles.desktop DESTINATION ${KDE4_SERVICES_INSTALL_DIR} )
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
#! /usr/bin/env bash
|
||||
$XGETTEXT `find . -name \*.cpp` -o $podir/plasma_engine_konsoleprofiles.pot
|
|
@ -1,95 +0,0 @@
|
|||
/*****************************************************************************
|
||||
* Copyright (C) 2011 by Shaun Reich <shaun.reich@kdemail.net> *
|
||||
* Copyright (C) 2008 by Montel Laurent <montel@kde.org> *
|
||||
* *
|
||||
* 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 <http://www.gnu.org/licenses/>. *
|
||||
*****************************************************************************/
|
||||
|
||||
#include "konsoleprofilesengine.h"
|
||||
#include "konsoleprofilesservice.h"
|
||||
|
||||
#include <KStandardDirs>
|
||||
#include <KDirWatch>
|
||||
#include <QFileInfo>
|
||||
#include <kio/global.h>
|
||||
#include <KGlobalSettings>
|
||||
#include <KDebug>
|
||||
|
||||
KonsoleProfilesEngine::KonsoleProfilesEngine(QObject *parent, const QVariantList &args)
|
||||
: Plasma::DataEngine(parent, args),
|
||||
m_dirWatch(0)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
KonsoleProfilesEngine::~KonsoleProfilesEngine()
|
||||
{
|
||||
}
|
||||
|
||||
void KonsoleProfilesEngine::init()
|
||||
{
|
||||
kDebug() << "KonsoleProfilesDataEngine init";
|
||||
|
||||
m_dirWatch = new KDirWatch( this );
|
||||
loadProfiles();
|
||||
connect(m_dirWatch, SIGNAL(dirty(QString)), this, SLOT(profilesChanged()));
|
||||
}
|
||||
|
||||
Plasma::Service *KonsoleProfilesEngine::serviceForSource(const QString &source)
|
||||
{
|
||||
//create a new service for this profile's name, so it can be operated on.
|
||||
return new KonsoleProfilesService(this, source);
|
||||
}
|
||||
|
||||
void KonsoleProfilesEngine::profilesChanged()
|
||||
{
|
||||
//wipe the data clean, load it again. (there's not a better way of doing this but no big deal)
|
||||
removeAllSources();
|
||||
loadProfiles();
|
||||
}
|
||||
|
||||
void KonsoleProfilesEngine::loadProfiles()
|
||||
{
|
||||
const QStringList lst = KGlobal::dirs()->findDirs( "data", "konsole/" );
|
||||
for ( int i = 0; i < lst.count(); i++ )
|
||||
{
|
||||
m_dirWatch->addDir( lst[i] );
|
||||
}
|
||||
|
||||
const QStringList list = KGlobal::dirs()->findAllResources( "data", "konsole/*.profile", KStandardDirs::NoDuplicates );
|
||||
const QStringList::ConstIterator end = list.constEnd();
|
||||
for (QStringList::ConstIterator it = list.constBegin(); it != end; ++it)
|
||||
{
|
||||
QFileInfo info( *it );
|
||||
const QString profileName = KIO::decodeFileName( info.baseName() );
|
||||
QString niceName = profileName;
|
||||
KConfig cfg( *it, KConfig::SimpleConfig );
|
||||
|
||||
if ( cfg.hasGroup( "General" ) ) {
|
||||
KConfigGroup grp( &cfg, "General" );
|
||||
|
||||
if ( grp.hasKey( "Name" ) ) {
|
||||
niceName = grp.readEntry( "Name" );
|
||||
}
|
||||
|
||||
QString sourceName = "name:" + profileName;
|
||||
kDebug() << "adding sourcename: " << profileName << " ++" << niceName;
|
||||
setData(profileName, "prettyName", niceName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
K_EXPORT_PLASMA_DATAENGINE(konsoleprofilesengine, KonsoleProfilesEngine)
|
||||
|
||||
#include "moc_konsoleprofilesengine.cpp"
|
|
@ -1,46 +0,0 @@
|
|||
/*****************************************************************************
|
||||
* Copyright (C) 2011 by Shaun Reich <shaun.reich@kdemail.net> *
|
||||
* Copyright (C) 2008 by Montel Laurent <montel@kde.org> *
|
||||
* *
|
||||
* 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 <http://www.gnu.org/licenses/>. *
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef KONSOLEPROFILESENGINE_H
|
||||
#define KONSOLEPROFILESENGINE_H
|
||||
|
||||
#include <Plasma/DataEngine>
|
||||
|
||||
class KDirWatch;
|
||||
|
||||
class KonsoleProfilesEngine : public Plasma::DataEngine
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
KonsoleProfilesEngine(QObject *parent, const QVariantList &args);
|
||||
~KonsoleProfilesEngine();
|
||||
|
||||
void init();
|
||||
Plasma::Service *serviceForSource(const QString &source);
|
||||
|
||||
private Q_SLOTS:
|
||||
void profilesChanged();
|
||||
|
||||
private:
|
||||
void loadProfiles();
|
||||
|
||||
KDirWatch *m_dirWatch;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,64 +0,0 @@
|
|||
/*****************************************************************************
|
||||
* Copyright (C) 2011 by Shaun Reich <shaun.reich@kdemail.net> *
|
||||
* Copyright (C) 2008 by Montel Laurent <montel@kde.org> *
|
||||
* *
|
||||
* 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 <http://www.gnu.org/licenses/>. *
|
||||
*****************************************************************************/
|
||||
|
||||
#include "konsoleprofilesservice.h"
|
||||
|
||||
#include <QtCore/QMap>
|
||||
#include <KToolInvocation>
|
||||
#include <KDebug>
|
||||
|
||||
KonsoleProfilesService::KonsoleProfilesService(QObject* parent, const QString& profileName)
|
||||
: Plasma::Service(parent)
|
||||
{
|
||||
setName("org.kde.plasma.dataengine.konsoleprofiles");
|
||||
setOperationNames(
|
||||
QStringList()
|
||||
<< "open"
|
||||
);
|
||||
setDestination(profileName);
|
||||
}
|
||||
|
||||
Plasma::ServiceJob* KonsoleProfilesService::createJob(const QString& operation, const QMap<QString,QVariant>& parameters)
|
||||
{
|
||||
return new ProfileJob(this, operation, parameters);
|
||||
}
|
||||
|
||||
ProfileJob::ProfileJob(KonsoleProfilesService *service, const QString &operation, const QMap<QString, QVariant> ¶meters)
|
||||
: Plasma::ServiceJob(service->destination(), operation, parameters, service)
|
||||
{
|
||||
}
|
||||
|
||||
void ProfileJob::start()
|
||||
{
|
||||
// destination is the profile name, operation is e.g. "open"
|
||||
// QMap<QString, QVariant>jobParameters = parameters();
|
||||
const QString operation = operationName();
|
||||
|
||||
kDebug() << "SERVICE START...operation: " << operation << " dest: " << destination();
|
||||
if (operation == "open") {
|
||||
// Q_ASSERT(!jobParameters.isEmpty());
|
||||
|
||||
QStringList args;
|
||||
args << "--profile" << destination();
|
||||
KToolInvocation::kdeinitExec("konsole", args);
|
||||
|
||||
setResult(true);
|
||||
}
|
||||
}
|
||||
|
||||
#include "moc_konsoleprofilesservice.cpp"
|
|
@ -1,45 +0,0 @@
|
|||
/*****************************************************************************
|
||||
* Copyright (C) 2011 by Shaun Reich <shaun.reich@kdemail.net> *
|
||||
* Copyright (C) 2008 by Montel Laurent <montel@kde.org> *
|
||||
* *
|
||||
* 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 <http://www.gnu.org/licenses/>. *
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef KONSOLEPROFILESSERVICE_H
|
||||
#define KONSOLEPROFILESSERVICE_H
|
||||
|
||||
#include <Plasma/Service>
|
||||
#include <Plasma/ServiceJob>
|
||||
|
||||
class KonsoleProfilesService : public Plasma::Service
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
KonsoleProfilesService(QObject* parent, const QString& profileName);
|
||||
|
||||
protected:
|
||||
Plasma::ServiceJob* createJob(const QString& operation, const QMap<QString,QVariant>& parameters);
|
||||
};
|
||||
|
||||
class ProfileJob : public Plasma::ServiceJob
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ProfileJob(KonsoleProfilesService *service, const QString& operation, const QMap<QString, QVariant> ¶meters);
|
||||
void start();
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,127 +0,0 @@
|
|||
[Desktop Entry]
|
||||
Name=Konsole Profiles
|
||||
Name[ar]=تشكيلات كونسول
|
||||
Name[ast]=Perfiles de Konsole
|
||||
Name[bs]=Konzolini profili
|
||||
Name[ca]=Perfils del Konsole
|
||||
Name[ca@valencia]=Perfils del Konsole
|
||||
Name[cs]=Profily Konsole
|
||||
Name[da]=Konsole-profiler
|
||||
Name[de]=Konsole-Profile
|
||||
Name[el]=Προφίλ Konsole
|
||||
Name[en_GB]=Konsole Profiles
|
||||
Name[es]=Perfiles de Konsole
|
||||
Name[et]=Konsooli profiilid
|
||||
Name[eu]=Kontsolaren profilak
|
||||
Name[fi]=Konsole-profiilit
|
||||
Name[fr]=Profils de Konsole
|
||||
Name[ga]=Próifílí Konsole
|
||||
Name[gl]=Perfís de Konsole
|
||||
Name[he]=הפרופילים של Konsole
|
||||
Name[hr]=Profili u Konsoleu
|
||||
Name[hu]=Konsole profilok
|
||||
Name[is]=Konsole snið
|
||||
Name[it]=Profili di Konsole
|
||||
Name[ja]=Konsole プロファイル
|
||||
Name[kk]=Konsole профильдері
|
||||
Name[km]=ទម្រង់របស់ Konsole
|
||||
Name[ko]=Konsole 프로필
|
||||
Name[ku]=Profîlên Konsolê
|
||||
Name[lt]=Konsole profiliai
|
||||
Name[lv]=Konsole profili
|
||||
Name[mr]=कंसोल रूपरेषा
|
||||
Name[nb]=Konsole-profiler
|
||||
Name[nds]=Konsole-Profilen
|
||||
Name[nl]=Konsole-profielen
|
||||
Name[nn]=Konsoll-profilar
|
||||
Name[pa]=ਕਨਸੋਲ ਪਰੋਫਾਇਲ
|
||||
Name[pl]=Profile Konsoli
|
||||
Name[pt]=Perfis do Konsole
|
||||
Name[pt_BR]=Perfis do Konsole
|
||||
Name[ro]=Profiluri konsolă
|
||||
Name[ru]=Konsole: профили
|
||||
Name[sk]=Profily Konsole
|
||||
Name[sl]=Profili za Konsole
|
||||
Name[sr]=Конзолини профили
|
||||
Name[sr@ijekavian]=Конзолини профили
|
||||
Name[sr@ijekavianlatin]=Konsolini profili
|
||||
Name[sr@latin]=Konsolini profili
|
||||
Name[sv]=Terminalprofiler
|
||||
Name[th]=โพรไฟล์คอนโซล-K
|
||||
Name[tr]=Konsole Profilleri
|
||||
Name[uk]=Профілі Konsole
|
||||
Name[wa]=Profils di Konsole
|
||||
Name[x-test]=xxKonsole Profilesxx
|
||||
Name[zh_CN]=Konsole 配置集
|
||||
Name[zh_TW]=Konsole 設定檔
|
||||
Comment=List and launch Konsole profiles
|
||||
Comment[ar]=تعرض و تطلق تشكيلات كونسول
|
||||
Comment[ast]=Amuesa y anicia perfiles de Konsole
|
||||
Comment[bs]=Nabraja i pokreće profile Konzole
|
||||
Comment[ca]=Llista i executa els perfils del Konsole
|
||||
Comment[ca@valencia]=Llista i executa els perfils del Konsole
|
||||
Comment[cs]=Seznam a spouštění profilů Konsole
|
||||
Comment[da]=Vis og start Konsole-profiler.
|
||||
Comment[de]=Konsole-Profile anzeigen und starten
|
||||
Comment[el]=Εμφάνιση και εκτέλεση προφίλ της Konsole
|
||||
Comment[en_GB]=List and launch Konsole profiles
|
||||
Comment[es]=Muestra e inicia perfiles de Konsole
|
||||
Comment[et]=Konsooli profiilide näitamine ja käivitamine
|
||||
Comment[eu]=Zerrendatu eta jaurti Kontsolaren profilak
|
||||
Comment[fi]=Luettelee ja käynnistää Konsole-profiileja
|
||||
Comment[fr]=Permet d'afficher et de lancer des profils de Konsole
|
||||
Comment[ga]=Liostaigh agus tosaigh próifílí Konsole
|
||||
Comment[gl]=Enumera e inicia perfís de Konsole
|
||||
Comment[he]=הצג והפעל פרופילים של Konsole
|
||||
Comment[hr]=Navedi i pokreni profile u Konsoleu
|
||||
Comment[hu]=Konsole profilok listázása és indítása
|
||||
Comment[is]=Listar upp og ræsir Konsole snið
|
||||
Comment[it]=Elenca ed esegue i profili di Konsole
|
||||
Comment[ja]=Konsole のプロファイルを起動します
|
||||
Comment[kk]=Konsole профильдерін таңдап жегу
|
||||
Comment[km]=រាយ និងចាប់ផ្ដើមទម្រង់របស់ Konsole
|
||||
Comment[ko]=Konsole 프로필을 보고 실행하기
|
||||
Comment[ku]=Profîlên Konsolê lîste bike û bide destpêkirin
|
||||
Comment[lt]=Rikiuoti ir įkelti Konsole profilius
|
||||
Comment[lv]=Parāda un atver Konsole profilus
|
||||
Comment[mr]=कंसोल रूपरेषांची यादी व प्रक्षेपण करा
|
||||
Comment[nb]=List opp og start Konsole-profiler
|
||||
Comment[nds]=Konsole-Profilen oplisten un opropen
|
||||
Comment[nl]=Toon en start Konsole-profielen
|
||||
Comment[nn]=Vis og start Konsoll-profilar
|
||||
Comment[pa]=ਕਨਸੋਲ ਪਰੋਫਾਇਲ ਵੇਖੋ ਅਤੇ ਚਲਾਓ
|
||||
Comment[pl]=Wypisywanie i uruchamianie profili Konsoli
|
||||
Comment[pt]=Listar e invocar os perfis do Konsole
|
||||
Comment[pt_BR]=Lista e carrega os perfis do Konsole
|
||||
Comment[ro]=Enumeră și lansează profiluri de consolă
|
||||
Comment[ru]=Запуск Konsole для разных задач
|
||||
Comment[sk]=Zobrazenie a spustenie profilov Konsole
|
||||
Comment[sl]=Prikažite in zaženite profile za Konsole
|
||||
Comment[sr]=Набраја и покреће профиле Конзоле
|
||||
Comment[sr@ijekavian]=Набраја и покреће профиле Конзоле
|
||||
Comment[sr@ijekavianlatin]=Nabraja i pokreće profile Konsole
|
||||
Comment[sr@latin]=Nabraja i pokreće profile Konsole
|
||||
Comment[sv]=Lista och starta terminalprofiler
|
||||
Comment[th]=เรียกรายการและเรียกให้โพรไฟล์ของคอนโซล-K ให้ทำงาน
|
||||
Comment[tr]=Konsole profillerini listeleyin ve çalıştırın
|
||||
Comment[uk]=Перегляньте і запустіть профілі Konsole
|
||||
Comment[wa]=Fé l' djivêye des profils di Konsole eyet ls enonder
|
||||
Comment[x-test]=xxList and launch Konsole profilesxx
|
||||
Comment[zh_CN]=罗列和启动 Konsole 配置集
|
||||
Comment[zh_TW]=列出並啟動 Konsole 設定檔
|
||||
|
||||
Type=Service
|
||||
Icon=utilities-terminal
|
||||
|
||||
X-KDE-ServiceTypes=Plasma/DataEngine
|
||||
X-KDE-Library=plasma_engine_konsoleprofiles
|
||||
|
||||
X-KDE-PluginInfo-Author=Shaun Reich
|
||||
X-KDE-PluginInfo-Email=shaun.reich@kdemail.net
|
||||
X-KDE-PluginInfo-Name=org.kde.konsoleprofiles
|
||||
X-KDE-PluginInfo-Version=1.0
|
||||
X-KDE-PluginInfo-Website=
|
||||
X-KDE-PluginInfo-Category=Utiltities
|
||||
X-KDE-PluginInfo-Depends=
|
||||
X-KDE-PluginInfo-License=GPL
|
||||
X-KDE-PluginInfo-EnabledByDefault=true
|
Loading…
Add table
Reference in a new issue