summaryrefslogtreecommitdiffstats
path: root/src/ksquirrel-libs-configurator
diff options
context:
space:
mode:
Diffstat (limited to 'src/ksquirrel-libs-configurator')
-rw-r--r--src/ksquirrel-libs-configurator/Makefile.am16
-rw-r--r--src/ksquirrel-libs-configurator/klc.cpp115
-rw-r--r--src/ksquirrel-libs-configurator/klc.ui190
-rw-r--r--src/ksquirrel-libs-configurator/klc.ui.h161
-rwxr-xr-xsrc/ksquirrel-libs-configurator/ksquirrel-libs-configurator3
-rw-r--r--src/ksquirrel-libs-configurator/main.cpp61
6 files changed, 546 insertions, 0 deletions
diff --git a/src/ksquirrel-libs-configurator/Makefile.am b/src/ksquirrel-libs-configurator/Makefile.am
new file mode 100644
index 0000000..2dd4785
--- /dev/null
+++ b/src/ksquirrel-libs-configurator/Makefile.am
@@ -0,0 +1,16 @@
+INCLUDES = $(all_includes) -I$(srcdir)
+
+bin_PROGRAMS = ksquirrel-libs-configurator-real
+bin_SCRIPTS = ksquirrel-libs-configurator
+
+ksquirrel_libs_configurator_real_SOURCES = main.cpp klc.ui
+ksquirrel_libs_configurator_real_LDADD = $(KDE_LDFLAGS) $(QT_LDFLAGS) $(LIB_TDEIO) $(LIB_TDEUI) -lDCOP $(LIB_TDECORE) $(LIB_TQT)
+ksquirrel_libs_configurator_real_LDFLAGS = $(all_libraries) $(KDE_LDFLAGS) $(QT_LDFLAGS) $(LIB_TDEIO) $(LIB_TDEUI) -lDCOP $(LIB_TDECORE) $(LIB_TQT)
+
+AM_CXXFLAGS = $(ksquirrellibs_CFLAGS)
+
+messages:
+ LIST=`find . -name \*.h -o -name \*.hh -o -name \*.H -o -name \*.hxx -o -name \*.hpp -o -name \*.cpp -o -name \*.cc -o -name \*.cxx -o -name \*.ecpp -o -name \*.C`; \
+ if test -n "$$LIST"; then \
+ $(XGETTEXT) $$LIST -o $(podir)/ksquirrel.pot; \
+ fi
diff --git a/src/ksquirrel-libs-configurator/klc.cpp b/src/ksquirrel-libs-configurator/klc.cpp
new file mode 100644
index 0000000..4f9a3ef
--- /dev/null
+++ b/src/ksquirrel-libs-configurator/klc.cpp
@@ -0,0 +1,115 @@
+#include <kdialog.h>
+#include <tdelocale.h>
+/****************************************************************************
+** Form implementation generated from reading ui file './klc.ui'
+**
+** Created: Птн Дек 7 20:18:10 2007
+** by: The User Interface Compiler ($Id: tqt/main.cpp 3.3.7 edited Aug 31 2005 $)
+**
+** WARNING! All changes made in this file will be lost!
+****************************************************************************/
+
+#include "klc.h"
+
+#include <tqvariant.h>
+#include <kdirlister.h>
+#include <tdeio/job.h>
+#include <tqheader.h>
+#include <tqtimer.h>
+#include <tdeio/netaccess.h>
+#include <tdeapplication.h>
+#include <dcopclient.h>
+#include <tqpushbutton.h>
+#include <tqlistview.h>
+#include <tqlabel.h>
+#include <tqlayout.h>
+#include <tqtooltip.h>
+#include <tqwhatsthis.h>
+#include "./klc.ui.h"
+
+/*
+ * Constructs a KLC as a child of 'parent', with the
+ * name 'name' and widget flags set to 'f'.
+ */
+KLC::KLC( TQWidget* parent, const char* name, WFlags fl )
+ : TQWidget( parent, name, fl )
+{
+ if ( !name )
+ setName( "KLC" );
+ KLCLayout = new TQGridLayout( this, 1, 1, 11, 6, "KLCLayout");
+
+ layout1 = new TQHBoxLayout( 0, 0, 6, "layout1");
+ spacer1 = new TQSpacerItem( 371, 26, TQSizePolicy::Expanding, TQSizePolicy::Minimum );
+ layout1->addItem( spacer1 );
+
+ pushApply = new TQPushButton( this, "pushApply" );
+ layout1->addWidget( pushApply );
+
+ pushClose = new TQPushButton( this, "pushClose" );
+ layout1->addWidget( pushClose );
+
+ KLCLayout->addMultiCellLayout( layout1, 2, 2, 0, 1 );
+
+ listDisabled = new TQListView( this, "listDisabled" );
+ listDisabled->addColumn( tr2i18n( "..." ) );
+ listDisabled->setEnabled( FALSE );
+ listDisabled->setAllColumnsShowFocus( TRUE );
+ listDisabled->setResizeMode( TQListView::AllColumns );
+
+ KLCLayout->addWidget( listDisabled, 1, 1 );
+
+ textLabel1_2 = new TQLabel( this, "textLabel1_2" );
+
+ KLCLayout->addWidget( textLabel1_2, 0, 1 );
+
+ textLabel1 = new TQLabel( this, "textLabel1" );
+
+ KLCLayout->addWidget( textLabel1, 0, 0 );
+
+ listEnabled = new TQListView( this, "listEnabled" );
+ listEnabled->addColumn( tr2i18n( "..." ) );
+ listEnabled->setEnabled( FALSE );
+ listEnabled->setAllColumnsShowFocus( TRUE );
+ listEnabled->setResizeMode( TQListView::AllColumns );
+
+ KLCLayout->addWidget( listEnabled, 1, 0 );
+ languageChange();
+ resize( TQSize(586, 425).expandedTo(minimumSizeHint()) );
+ clearWState( WState_Polished );
+
+ // signals and slots connections
+ connect( pushApply, TQ_SIGNAL( clicked() ), this, TQ_SLOT( slotApply() ) );
+ connect( pushClose, TQ_SIGNAL( clicked() ), this, TQ_SLOT( close() ) );
+
+ // tab order
+ setTabOrder( listEnabled, listDisabled );
+ setTabOrder( listDisabled, pushApply );
+ setTabOrder( pushApply, pushClose );
+ init();
+}
+
+/*
+ * Destroys the object and frees any allocated resources
+ */
+KLC::~KLC()
+{
+ destroy();
+ // no need to delete child widgets, TQt does it all for us
+}
+
+/*
+ * Sets the strings of the subwidgets using the current
+ * language.
+ */
+void KLC::languageChange()
+{
+ setCaption( tr2i18n( "Codec manager" ) );
+ pushApply->setText( tr2i18n( "Apply" ) );
+ pushClose->setText( tr2i18n( "Close" ) );
+ listDisabled->header()->setLabel( 0, tr2i18n( "..." ) );
+ textLabel1_2->setText( tr2i18n( "<b>Select codecs to enable:</b>" ) );
+ textLabel1->setText( tr2i18n( "<b>Select codecs to disable:</b>" ) );
+ listEnabled->header()->setLabel( 0, tr2i18n( "..." ) );
+}
+
+#include "klc.moc"
diff --git a/src/ksquirrel-libs-configurator/klc.ui b/src/ksquirrel-libs-configurator/klc.ui
new file mode 100644
index 0000000..624d07b
--- /dev/null
+++ b/src/ksquirrel-libs-configurator/klc.ui
@@ -0,0 +1,190 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>KLC</class>
+<widget class="TQWidget">
+ <property name="name">
+ <cstring>KLC</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>586</width>
+ <height>425</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Codec manager</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="TQLayoutWidget" row="2" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>layout1</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer>
+ <property name="name">
+ <cstring>spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>371</width>
+ <height>26</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>pushApply</cstring>
+ </property>
+ <property name="text">
+ <string>Apply</string>
+ </property>
+ </widget>
+ <widget class="TQPushButton">
+ <property name="name">
+ <cstring>pushClose</cstring>
+ </property>
+ <property name="text">
+ <string>Close</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="TQListView" row="1" column="1">
+ <column>
+ <property name="text">
+ <string>...</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <property name="name">
+ <cstring>listDisabled</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="allColumnsShowFocus">
+ <bool>true</bool>
+ </property>
+ <property name="resizeMode">
+ <enum>AllColumns</enum>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="0" column="1">
+ <property name="name">
+ <cstring>textLabel1_2</cstring>
+ </property>
+ <property name="text">
+ <string>&lt;b&gt;Select codecs to enable:&lt;/b&gt;</string>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>&lt;b&gt;Select codecs to disable:&lt;/b&gt;</string>
+ </property>
+ </widget>
+ <widget class="TQListView" row="1" column="0">
+ <column>
+ <property name="text">
+ <string>...</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <property name="name">
+ <cstring>listEnabled</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="allColumnsShowFocus">
+ <bool>true</bool>
+ </property>
+ <property name="resizeMode">
+ <enum>AllColumns</enum>
+ </property>
+ </widget>
+ </grid>
+</widget>
+<connections>
+ <connection>
+ <sender>pushApply</sender>
+ <signal>clicked()</signal>
+ <receiver>KLC</receiver>
+ <slot>slotApply()</slot>
+ </connection>
+ <connection>
+ <sender>pushClose</sender>
+ <signal>clicked()</signal>
+ <receiver>KLC</receiver>
+ <slot>close()</slot>
+ </connection>
+</connections>
+<tabstops>
+ <tabstop>listEnabled</tabstop>
+ <tabstop>listDisabled</tabstop>
+ <tabstop>pushApply</tabstop>
+ <tabstop>pushClose</tabstop>
+</tabstops>
+<includes>
+ <include location="global" impldecl="in declaration">tdefileitem.h</include>
+ <include location="global" impldecl="in declaration">kurl.h</include>
+ <include location="global" impldecl="in implementation">kdirlister.h</include>
+ <include location="global" impldecl="in implementation">tdeio/job.h</include>
+ <include location="global" impldecl="in implementation">tqheader.h</include>
+ <include location="global" impldecl="in implementation">tqtimer.h</include>
+ <include location="global" impldecl="in implementation">tdeio/netaccess.h</include>
+ <include location="global" impldecl="in implementation">tdeapplication.h</include>
+ <include location="global" impldecl="in implementation">dcopclient.h</include>
+ <include location="local" impldecl="in implementation">klc.ui.h</include>
+</includes>
+<forwards>
+ <forward>class KDirLister;</forward>
+ <forward>namespace TDEIO { class Job; }</forward>
+</forwards>
+<variables>
+ <variable access="private">KURL base, backup;</variable>
+ <variable access="private">KDirLister *lister;</variable>
+ <variable access="private">TQString backupDir;</variable>
+ <variable access="private">bool changed;</variable>
+</variables>
+<slots>
+ <slot access="private">slotLoad()</slot>
+ <slot access="private">slotApply()</slot>
+ <slot access="private">slotCompleted( const KURL &amp; u )</slot>
+ <slot access="private">slotNewItems( const KFileItemList &amp; list )</slot>
+ <slot access="private">slotDeleteItem( KFileItem * fi )</slot>
+ <slot access="private">slotDelResult( TDEIO::Job * job )</slot>
+</slots>
+<functions>
+ <function access="private" specifier="non virtual">init()</function>
+ <function access="private" specifier="non virtual">destroy()</function>
+ <function access="private" specifier="non virtual">moveCodecs( bool e2d )</function>
+ <function access="protected">closeEvent( TQCloseEvent * ev )</function>
+</functions>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/src/ksquirrel-libs-configurator/klc.ui.h b/src/ksquirrel-libs-configurator/klc.ui.h
new file mode 100644
index 0000000..9d0ab7c
--- /dev/null
+++ b/src/ksquirrel-libs-configurator/klc.ui.h
@@ -0,0 +1,161 @@
+/****************************************************************************
+** ui.h extension file, included from the uic-generated form implementation.
+**
+** If you want to add, delete, or rename functions or slots, use
+** TQt Designer to update this file, preserving your code.
+**
+** You should not define a constructor or destructor in this file.
+** Instead, write your code in functions called init() and destroy().
+** These will automatically be called by the form's constructor and
+** destructor.
+*****************************************************************************/
+
+#if !defined(QT_STRINGIFY)
+# define QT_STRINGIFY2(x) #x
+# define QT_STRINGIFY(x) QT_STRINGIFY2(x)
+#endif
+
+void KLC::init()
+{
+ changed = false;
+
+ listEnabled->setSorting(0);
+ listEnabled->header()->hide();
+
+ listDisabled->setSorting(0);
+ listDisabled->header()->hide();
+
+ lister = new KDirLister;
+ connect(lister, TQ_SIGNAL(completed(const KURL &)), this, TQ_SLOT(slotCompleted(const KURL &)));
+ connect(lister, TQ_SIGNAL(deleteItem(KFileItem *)), this, TQ_SLOT(slotDeleteItem(KFileItem *)));
+ connect(lister, TQ_SIGNAL(newItems(const KFileItemList &)), this, TQ_SLOT(slotNewItems(const KFileItemList &)));
+
+ base = KURL::fromPathOrURL(QT_STRINGIFY(SQ_KLIBS));
+
+ backup = base;
+ backup.addPath("backup");
+
+ backupDir = backup.path();
+
+ TDEIO::NetAccess::mkdir(backup, this);
+
+ TQTimer::singleShot(0, this, TQ_SLOT(slotLoad()));
+}
+
+void KLC::slotLoad()
+{
+ lister->openURL(base);
+ lister->openURL(backup, true);
+}
+
+void KLC::destroy()
+{
+ delete lister;
+}
+
+void KLC::slotApply()
+{
+ changed = true;
+
+ moveCodecs(true);
+ moveCodecs(false);
+}
+
+void KLC::moveCodecs(bool e2d)
+{
+ KURL::List list;
+ KURL codec;
+
+ TQListViewItemIterator it(e2d ? listEnabled : listDisabled);
+ TQCheckListItem *li;
+
+ while((li = static_cast<TQCheckListItem *>(it.current())))
+ {
+ if(li->isOn())
+ {
+ codec = e2d ? base : backup;
+ codec.addPath(li->text());
+ list.append(codec);
+ }
+
+ ++it;
+ }
+
+ TDEIO::Job *job = TDEIO::move(list, e2d ? backup : base);
+
+ connect(job, TQ_SIGNAL(result(TDEIO::Job *)), this, TQ_SLOT(slotDelResult(TDEIO::Job *)));
+}
+
+void KLC::slotCompleted(const KURL &u)
+{
+ if(u == base)
+ {
+ listEnabled->setEnabled(true);
+ listEnabled->setCurrentItem(listEnabled->firstChild());
+ }
+ else
+ {
+ listDisabled->setEnabled(true);
+ listDisabled->setCurrentItem(listDisabled->firstChild());
+ }
+}
+
+void KLC::slotNewItems(const KFileItemList &list)
+{
+ KFileItemListIterator it(list);
+ KFileItem *fi;
+ TQString soname = TQString::fromLatin1(".so.%1").arg(QT_STRINGIFY(SQ_KL_VER));
+
+ while((fi = it.current()))
+ {
+ if(fi->isFile() && fi->name().endsWith(soname))
+ new TQCheckListItem(fi->url().directory().startsWith(backupDir) ? listDisabled:listEnabled, fi->name(), TQCheckListItem::CheckBox);
+
+ ++it;
+ }
+}
+
+void KLC::slotDeleteItem(KFileItem *fi)
+{
+ TQListView *l = fi->url().directory().startsWith(backupDir) ? listDisabled:listEnabled;
+
+ TQListViewItemIterator it(l);
+ TQCheckListItem *li;
+ TQListViewItem *li2;
+
+ while((li = static_cast<TQCheckListItem *>(it.current())))
+ {
+ if(li->text() == fi->name())
+ {
+ li2 = li->itemBelow();
+
+ if(!li2)
+ li2 = li->itemAbove();
+
+ delete li;
+
+ l->setCurrentItem(li2);
+ l->setSelected(li2, true);
+
+ return;
+ }
+
+ ++it;
+ }
+}
+
+void KLC::slotDelResult(TDEIO::Job *job)
+{
+ if(job && job->error())
+ job->showErrorDialog(this);
+}
+
+void KLC::closeEvent(TQCloseEvent *ev)
+{
+ TQString data;
+
+ if(changed)
+ tdeApp->dcopClient()->send("ksquirrel", "ksquirrel", "reload_codecs()", data);
+
+ ev->accept();
+}
diff --git a/src/ksquirrel-libs-configurator/ksquirrel-libs-configurator b/src/ksquirrel-libs-configurator/ksquirrel-libs-configurator
new file mode 100755
index 0000000..d09c739
--- /dev/null
+++ b/src/ksquirrel-libs-configurator/ksquirrel-libs-configurator
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+tdesu --nonewdcop -c "${0}-real"
diff --git a/src/ksquirrel-libs-configurator/main.cpp b/src/ksquirrel-libs-configurator/main.cpp
new file mode 100644
index 0000000..4bfc26c
--- /dev/null
+++ b/src/ksquirrel-libs-configurator/main.cpp
@@ -0,0 +1,61 @@
+/***************************************************************************
+ main.cpp - description
+ -------------------
+ begin : Dec 03 2007
+ copyright : (C) 2007 by Baryshev Dmitry
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+
+#include <tdeapplication.h>
+#include <tdecmdlineargs.h>
+#include <tdeaboutdata.h>
+#include <tdeglobal.h>
+#include <tdelocale.h>
+
+#include "klc.h"
+
+static TDECmdLineOptions options[] =
+{
+ TDECmdLineLastOption
+};
+
+int main(int argc, char *argv[])
+{
+ const TQCString App = "ksquirrel-libs-configurator";
+
+ TDEAboutData aboutData(
+ "ksquirrel-libs-configurator",
+ "ksquirrel-libs-configurator",
+ "0.1",
+ I18N_NOOP("ksquirrel-libs-configurator"),
+ TDEAboutData::License_GPL,
+ "(c) 2007 Baryshev Dmitry",
+ TQString(),
+ "http://ksquirrel.sourceforge.net",
+
+ TDECmdLineArgs::init(argc, argv, &aboutData);
+ TDECmdLineArgs::addCmdLineOptions(options);
+
+ TDEApplication app;
+
+ TDEGlobal::locale()->insertCatalogue("ksquirrel");
+ TDEGlobal::locale()->setActiveCatalogue("ksquirrel");
+
+ KLC *klc = new KLC(0, App);
+
+ app.setMainWidget(klc);
+
+ klc->show();
+
+ return app.exec();
+}