Version: (using KDE KDE 3.1.1) Installed from: SuSE RPMs OS: Linux It is not easy to understand how KDE manages mimetypes and file associations. For example, I installed kmplot for testing mathematical functions. Files can be saved with the extension *.fkt. Unfortunately, KDE tells that this file is a text file. When choosing 'edit filetype' from the kontext menu, I get the mime text offered and it is not possible from there to add a new mimetype, or - worse - I assign a new program and have now changed the setting for all textfiles. The association of files, mimetypes and programs to open the files should be completely thought over to make it real easy to understand, easier than on Win or Mac
It's the other way around in KDE: mimetypes have associated filename patterns (mostly extensions), but you cannot associate the same pattern to more than one MIME type. It doesn't make sense: either it is one thing, or it's another. The problem in this case is that kmplot doesn't install a new type for itself.
Subject: kdeedu/kmplot/kmplot CVS commit by annma: patch from Albert Astals Cid, thanks a lot for debugging KmPlot It adds modifies kmplot a bit to accept opening files from command line and adds a new mimetype to kde. CCMAIL:59823-done@bugs.kde.org A x-kmplot.desktop 1.1 M +7 -1 MainDlg.cpp 1.28 M +3 -1 MainDlg.h 1.12 M +3 -0 Makefile.am 1.8 M +1 -0 kmplot.desktop 1.77 M +3 -1 main.cpp 1.13 --- kdeedu/kmplot/kmplot/MainDlg.cpp #1.27:1.28 @@ -32,4 +32,5 @@ #include <kedittoolbar.h> #include <kkeydialog.h> +#include <kurl.h> // local includes @@ -40,5 +41,5 @@ #include "misc.h" -MainDlg::MainDlg( const char* name ) : KMainWindow( 0, name ) +MainDlg::MainDlg( KCmdLineArgs* args, const char* name ) : KMainWindow( 0, name ) { init(); @@ -49,4 +50,5 @@ MainDlg::MainDlg( const char* name ) : K setupActions(); setupStatusBar(); + if (args -> count() > 0) openFile( args -> url(0).fileName() ); } @@ -228,5 +230,9 @@ void MainDlg::load() if ( d.isEmpty() ) return ; + openFile(d); +} +void MainDlg::openFile( QString d ) +{ init(); --- kdeedu/kmplot/kmplot/MainDlg.h #1.11:1.12 @@ -42,4 +42,5 @@ #include <kapplication.h> #include <kaction.h> +#include <kcmdlineargs.h> #include "kconfig.h" #include <klocale.h> @@ -71,5 +72,5 @@ class MainDlg : public KMainWindow public: - MainDlg( const char* name = NULL ); + MainDlg( KCmdLineArgs* args, const char* name = NULL ); virtual ~MainDlg(); friend class FktDlg; @@ -101,4 +102,5 @@ private: void setupStatusBar(); void addTag( QDomDocument &doc, QDomElement &parentTag, const QString tagName, const QString tagValue ); + void openFile( QString d ); void parseAxes( const QDomElement &n ); --- kdeedu/kmplot/kmplot/Makefile.am #1.7:1.8 @@ -13,4 +13,7 @@ METASOURCES = AUTO +appmimedir = $(kde_mimedir)/application +appmime_DATA = x-kmplot.desktop + # the library search path. kmplot_LDFLAGS = $(all_libraries) $(KDE_RPATH) --- kdeedu/kmplot/kmplot/kmplot.desktop #1.76:1.77 @@ -95,2 +95,3 @@ GenericName[zu]=Umcabangi Womcimbi Categories=Qt;KDE;Education;Math +MimeType=application/x-kmplot --- kdeedu/kmplot/kmplot/main.cpp #1.12:1.13 @@ -37,4 +37,5 @@ static const char description[] = static KCmdLineOptions options[] = { + { "+[URL]", I18N_NOOP( "File to open" ), 0 }, KCmdLineLastOption // INSERT YOUR COMMANDLINE OPTIONS HERE @@ -59,6 +60,7 @@ int main( int argc, char **argv ) KApplication ka; + KCmdLineArgs* args = KCmdLineArgs::parsedArgs(); kc = KGlobal::config(); - MainDlg *w = new MainDlg; + MainDlg *w = new MainDlg( args ); w->resize( 450, 400 ); //w->setPalette( QPalette( QColor( 255, 255, 255 ) ) );