mirror of
https://bitbucket.org/smil3y/kde-workspace.git
synced 2025-02-23 10:22:49 +00:00
kcontrol: drop support for scripts in autostart KCM
see the previous commit, also fixes detection of programs that are automatically started by using KStandardDirs to find the autostart directories Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
465db03878
commit
1a87bf0849
8 changed files with 6 additions and 255 deletions
|
@ -6,7 +6,6 @@ include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR})
|
|||
|
||||
set(kcm_autostart_PART_SRCS
|
||||
autostartitem.cpp
|
||||
addscriptdialog.cpp
|
||||
advanceddialog.cpp
|
||||
autostart.cpp
|
||||
)
|
||||
|
|
|
@ -1,103 +0,0 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2007 by Stephen Leaf *
|
||||
* smileaf@gmail.com *
|
||||
* 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, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA *
|
||||
***************************************************************************/
|
||||
|
||||
#include "addscriptdialog.h"
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QVBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QFileInfo>
|
||||
|
||||
#include <KLineEdit>
|
||||
#include <KLocale>
|
||||
#include <KUrlRequester>
|
||||
#include <KShell>
|
||||
#include <KMessageBox>
|
||||
|
||||
AddScriptDialog::AddScriptDialog (QWidget* parent)
|
||||
: KDialog( parent ) {
|
||||
QWidget *w = new QWidget( this );
|
||||
setButtons( Cancel|Ok );
|
||||
QVBoxLayout *lay= new QVBoxLayout;
|
||||
w->setLayout( lay );
|
||||
QLabel *lab = new QLabel( i18n( "Shell script path:" ), w );
|
||||
lay->addWidget( lab );
|
||||
m_url = new KUrlRequester( w );
|
||||
lay->addWidget( m_url );
|
||||
m_symlink = new QCheckBox( i18n( "Create as symlink" ), w ); //TODO fix text
|
||||
m_symlink->setChecked( true );
|
||||
lay->addWidget( m_symlink );
|
||||
connect( m_url->lineEdit(), SIGNAL(textChanged(QString)), SLOT(textChanged(QString)) );
|
||||
m_url->lineEdit()->setFocus();
|
||||
enableButtonOk(false);
|
||||
|
||||
setMainWidget( w );
|
||||
}
|
||||
|
||||
AddScriptDialog::~AddScriptDialog()
|
||||
{
|
||||
}
|
||||
|
||||
void AddScriptDialog::textChanged(const QString &text)
|
||||
{
|
||||
enableButtonOk(!text.isEmpty());
|
||||
}
|
||||
|
||||
void AddScriptDialog::accept()
|
||||
{
|
||||
if ( doBasicSanityCheck() )
|
||||
KDialog::accept();
|
||||
}
|
||||
|
||||
bool AddScriptDialog::doBasicSanityCheck()
|
||||
{
|
||||
const QString& path = KShell::tildeExpand(m_url->text());
|
||||
|
||||
QFileInfo file(path);
|
||||
|
||||
if ( ! file.isAbsolute() ) {
|
||||
KMessageBox::sorry( 0, i18n("\"%1\" is not an absolute path.", path) );
|
||||
return false;
|
||||
} else if ( ! file.exists() ) {
|
||||
KMessageBox::sorry( 0, i18n("\"%1\" does not exist.", path) );
|
||||
return false;
|
||||
} else if ( !file.isFile() ) {
|
||||
KMessageBox::sorry( 0, i18n("\"%1\" is not a file.", path) );
|
||||
return false;
|
||||
} else if ( ! file.isReadable() ) {
|
||||
KMessageBox::sorry( 0, i18n("\"%1\" is not readable.", path) );
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
KUrl AddScriptDialog::importUrl() const
|
||||
{
|
||||
return m_url->lineEdit()->text();
|
||||
}
|
||||
|
||||
bool AddScriptDialog::symLink() const
|
||||
{
|
||||
return m_symlink->isChecked();
|
||||
}
|
||||
|
||||
#include "moc_addscriptdialog.cpp"
|
|
@ -1,57 +0,0 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2007 by Stephen Leaf *
|
||||
* smileaf@gmail.com *
|
||||
* 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, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef ADDSCRIPTDIALOG_H
|
||||
#define ADDSCRIPTDIALOG_H
|
||||
|
||||
#include <KDialog>
|
||||
#include <KUrl>
|
||||
|
||||
class KUrlRequester;
|
||||
#include <QCheckBox>
|
||||
|
||||
class AddScriptDialog : public KDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AddScriptDialog(QWidget* parent=0);
|
||||
~AddScriptDialog();
|
||||
// Returns the Url of the script to be imported
|
||||
KUrl importUrl() const;
|
||||
bool symLink() const;
|
||||
|
||||
public slots:
|
||||
// reimplemented
|
||||
virtual void accept();
|
||||
|
||||
protected:
|
||||
virtual bool doBasicSanityCheck();
|
||||
|
||||
private slots:
|
||||
void textChanged(const QString &text);
|
||||
|
||||
private:
|
||||
KUrlRequester *m_url;
|
||||
QCheckBox* m_symlink;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -21,7 +21,6 @@
|
|||
|
||||
#include "autostart.h"
|
||||
#include "autostartitem.h"
|
||||
#include "addscriptdialog.h"
|
||||
#include "advanceddialog.h"
|
||||
|
||||
#include <QDir>
|
||||
|
@ -63,7 +62,6 @@ K_PLUGIN_FACTORY(AutostartFactory, registerPlugin<Autostart>();)
|
|||
|
||||
setButtons(Help);
|
||||
|
||||
connect( widget->btnAddScript, SIGNAL(clicked()), SLOT(slotAddScript()) );
|
||||
connect( widget->btnAddProgram, SIGNAL(clicked()), SLOT(slotAddProgram()) );
|
||||
connect( widget->btnRemove, SIGNAL(clicked()), SLOT(slotRemoveCMD()) );
|
||||
connect( widget->btnAdvanced, SIGNAL(clicked()), SLOT(slotAdvanced()) );
|
||||
|
@ -121,23 +119,10 @@ void Autostart::addItem( DesktopStartItem* item, const QString& name, const QStr
|
|||
item->setText( COL_STATUS, disabled ? i18nc( "The program won't be run", "Disabled" ) : i18nc( "The program will be run", "Enabled" ));
|
||||
}
|
||||
|
||||
void Autostart::addItem(ScriptStartItem* item, const QString& name, const QString& command )
|
||||
{
|
||||
Q_ASSERT( item );
|
||||
item->setText( COL_NAME, name );
|
||||
item->setText( COL_COMMAND, command );
|
||||
}
|
||||
|
||||
|
||||
void Autostart::load()
|
||||
{
|
||||
// share/autostart may *only* contain .desktop files
|
||||
// shutdown and env may *only* contain scripts, links or binaries
|
||||
// autostart on the otherhand may contain all of the above.
|
||||
// share/autostart is special as it overrides entries found in $KDEDIR/share/autostart
|
||||
m_paths << KGlobalSettings::autostartPath() // All new entries should go here
|
||||
<< componentData().dirs()->localkdedir() + "share/autostart/" // For Importing purposes
|
||||
<< componentData().dirs()->localxdgconfdir() + "autostart/" ; //xdg-config autostart dir
|
||||
m_paths << componentData().dirs()->resourceDirs("autostart"); //xdg-config autostart dir
|
||||
|
||||
widget->listCMD->clear();
|
||||
|
||||
|
@ -149,13 +134,7 @@ void Autostart::load()
|
|||
boldFont.setBold( true );
|
||||
m_programItem->setData ( 0, Qt::FontRole, boldFont );
|
||||
|
||||
m_scriptItem = new QTreeWidgetItem( widget->listCMD );
|
||||
m_scriptItem->setText( 0, i18n( "Script File" ));
|
||||
m_scriptItem->setFlags(m_scriptItem->flags()^Qt::ItemIsSelectable);
|
||||
m_scriptItem->setData ( 0, Qt::FontRole, boldFont);
|
||||
|
||||
widget->listCMD->expandItem( m_programItem );
|
||||
widget->listCMD->expandItem( m_scriptItem );
|
||||
|
||||
foreach (const QString& path, m_paths) {
|
||||
if (! KGlobal::dirs()->exists(path))
|
||||
|
@ -198,18 +177,6 @@ void Autostart::load()
|
|||
indexPath = 0; //.kde/share/autostart and .config/autostart load destkop at startup
|
||||
addItem(item, config.readName(), grp.readEntry("Exec"), disabled );
|
||||
}
|
||||
else
|
||||
{
|
||||
ScriptStartItem *item = new ScriptStartItem( fi.absoluteFilePath(), m_scriptItem,this );
|
||||
if ( fi.isSymLink() ) {
|
||||
QString link = fi.readLink();
|
||||
addItem(item, filename, link );
|
||||
}
|
||||
else
|
||||
{
|
||||
addItem( item, filename, filename );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//Update button
|
||||
|
@ -272,22 +239,6 @@ void Autostart::slotAddProgram()
|
|||
addItem( item, service->name(), service->exec() , false);
|
||||
}
|
||||
|
||||
void Autostart::slotAddScript()
|
||||
{
|
||||
AddScriptDialog * addDialog = new AddScriptDialog(this);
|
||||
int result = addDialog->exec();
|
||||
if (result == QDialog::Accepted) {
|
||||
if (addDialog->symLink())
|
||||
KIO::link(addDialog->importUrl(), m_paths[0]);
|
||||
else
|
||||
KIO::copy(addDialog->importUrl(), m_paths[0]);
|
||||
|
||||
ScriptStartItem * item = new ScriptStartItem( m_paths[0] + addDialog->importUrl().fileName(), m_scriptItem,this );
|
||||
addItem( item, addDialog->importUrl().fileName(), addDialog->importUrl().fileName() );
|
||||
}
|
||||
delete addDialog;
|
||||
}
|
||||
|
||||
void Autostart::slotRemoveCMD()
|
||||
{
|
||||
QTreeWidgetItem* item = widget->listCMD->currentItem();
|
||||
|
@ -300,16 +251,6 @@ void Autostart::slotRemoveCMD()
|
|||
KIO::del(startItem->fileName().path() );
|
||||
delete item;
|
||||
}
|
||||
else
|
||||
{
|
||||
ScriptStartItem * scriptItem = dynamic_cast<ScriptStartItem*>( item );
|
||||
if ( scriptItem )
|
||||
{
|
||||
m_scriptItem->takeChild( m_scriptItem->indexOfChild( scriptItem ) );
|
||||
KIO::del(scriptItem->fileName().path() );
|
||||
delete item;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Autostart::slotEditCMD(QTreeWidgetItem* ent)
|
||||
|
|
|
@ -46,11 +46,9 @@ public:
|
|||
|
||||
protected:
|
||||
void addItem(DesktopStartItem *item, const QString& name, const QString& command, bool disabled );
|
||||
void addItem(ScriptStartItem *item, const QString& name, const QString& command );
|
||||
|
||||
private slots:
|
||||
void slotAddProgram();
|
||||
void slotAddScript();
|
||||
void slotRemoveCMD();
|
||||
void slotEditCMD(QTreeWidgetItem*);
|
||||
bool slotEditCMD(const KFileItem&);
|
||||
|
@ -60,7 +58,7 @@ private slots:
|
|||
void slotAdvanced();
|
||||
|
||||
private:
|
||||
QTreeWidgetItem *m_programItem, *m_scriptItem;
|
||||
QTreeWidgetItem *m_programItem;
|
||||
QStringList m_paths;
|
||||
|
||||
Ui_AutostartConfig *widget;
|
||||
|
|
|
@ -28,27 +28,20 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" >
|
||||
<widget class="QPushButton" name="btnAddScript" >
|
||||
<property name="text" >
|
||||
<string>Add Script...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" >
|
||||
<widget class="QPushButton" name="btnRemove" >
|
||||
<property name="text" >
|
||||
<string>&Remove</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1" >
|
||||
<item row="2" column="1" >
|
||||
<widget class="QPushButton" name="btnProperties" >
|
||||
<property name="text" >
|
||||
<string>&Properties...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1" >
|
||||
<item row="5" column="1" >
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Vertical</enum>
|
||||
|
@ -61,14 +54,14 @@
|
|||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="4" column="1" >
|
||||
<item row="3" column="1" >
|
||||
<widget class="Line" name="line" >
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1" >
|
||||
<item row="4" column="1" >
|
||||
<widget class="QPushButton" name="btnAdvanced" >
|
||||
<property name="text" >
|
||||
<string>Advanced...</string>
|
||||
|
|
|
@ -68,14 +68,4 @@ DesktopStartItem::~DesktopStartItem()
|
|||
{
|
||||
}
|
||||
|
||||
ScriptStartItem::ScriptStartItem( const QString &service, QTreeWidgetItem *parent, Autostart* autostart )
|
||||
: AutoStartItem( service, parent,autostart )
|
||||
{
|
||||
}
|
||||
|
||||
ScriptStartItem::~ScriptStartItem()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
#include "moc_autostartitem.cpp"
|
||||
|
|
|
@ -49,14 +49,4 @@ public:
|
|||
~DesktopStartItem();
|
||||
};
|
||||
|
||||
|
||||
class ScriptStartItem : public AutoStartItem
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ScriptStartItem( const QString &service, QTreeWidgetItem *parent, Autostart* );
|
||||
~ScriptStartItem();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue