Sophie

Sophie

distrib > Mandriva > cs4.0 > i586 > by-pkgid > fa9b6a46c8aad7f4f199c98596a0ec2a > files > 15

kdelibs-3.5.4-1.1.20060mlcs4.src.rpm

--- kio/kfile/kopenwith.h~	2005-11-01 20:39:18.000000000 +0100
+++ kio/kfile/kopenwith.h	2005-11-01 21:46:34.000000000 +0100
@@ -123,6 +123,7 @@
      * @since 3.2
      */
     void setSaveNewApplications(bool b);
+    void saveInMDVMenuStructure( const QString & filename, const QString &menuElement );
 
 public slots:
     /**
--- kio/kfile/kopenwith.cpp~	2005-11-01 20:39:18.000000000 +0100
+++ kio/kfile/kopenwith.cpp	2005-11-01 21:59:15.000000000 +0100
@@ -747,6 +747,8 @@
       maxPreference = offerList.first().preference();
   }
 
+  QString menuElement;
+  menuElement="?package(menu): needs=\"x11\" section=\".hidden\" ";
   KDesktopFile *desktop = 0;
   if (!oldPath.isEmpty() && (oldPath != newPath))
   {
@@ -766,18 +768,28 @@
   desktop->writeEntry("Type", QString::fromLatin1("Application"));
   desktop->writeEntry("Name", initialServiceName);
   desktop->writePathEntry("Exec", fullExec);
-  if (terminal->isChecked())
+  menuElement+="command=\"";
+  menuElement+=fullExec+"\" ";
+  menuElement+="title=\"";
+  menuElement+=initialServiceName+"\" ";
+  QString kdeOpt = "kde_opt=\"";
+  if (terminal->isChecked())
   {
     desktop->writeEntry("Terminal", true);
+    kdeOpt+="Terminal=1\\\\n";
     // only add --noclose when we are sure it is konsole we're using
     if (preferredTerminal == "konsole" && nocloseonexit->isChecked())
+    {
       desktop->writeEntry("TerminalOptions", "--noclose");
+      kdeOpt+=" TerminalOptions=--noclose\\\\n";
+    }
   }
   else
   {
     desktop->writeEntry("Terminal", false);
   }
   desktop->writeEntry("InitialPreference", maxPreference + 1);
+  kdeOpt+=QString( "InitialPreference=%1\\\\n" ).arg( maxPreference + 1 );
 
 
   if (bRemember || d->saveNewApps)
@@ -787,6 +799,7 @@
       mimeList.append(qServiceType);
     desktop->writeEntry("MimeType", mimeList, ';');
 
+    menuElement+=QString( "mimetypes=\"%1\"" ).arg( mimeList.join( ";") );
     if ( !qServiceType.isEmpty() )
     {
       // Also make sure the "auto embed" setting for this mimetype is off
@@ -795,7 +808,16 @@
       mimeDesktop.sync();
     }
   }
-
+  if ( newPath.contains( "Mandrakelinux/.hidden" ) && ( KStandardDirs::menu_type_by_version()!="kde" ))
+  {
+      QStringList categorieList = desktop->readListEntry("Categories", ';');
+      if ( !categorieList.contains("X-Mandrakelinux-.hidden"))
+          categorieList.append("X-Mandrakelinux-.hidden");
+      desktop->writeEntry( "Categories", categorieList, ";" );
+   //?package(xterm):  needs=X11  section="System/Terminals"  title="XTerm"  longtitle="The standard terminal emulator for the X Window System"  command="/usr/X11R6/bin/xterm -name Terminal"  icon="xterm-terminal.png"
+	  menuElement+=" " +kdeOpt+"\"";
+      saveInMDVMenuStructure( initialServiceName,menuElement );
+  }
   // write it all out to the file
   desktop->sync();
   delete desktop;
@@ -809,6 +831,38 @@
   accept();
 }
 
+void KOpenWithDlg::saveInMDVMenuStructure( const QString & filename, const QString &menuElement )
+{
+    QString menuPath;
+    QString tmp =KStandardDirs::menu_type_by_version();
+    if( tmp=="kde")
+        return;
+    else if ( tmp=="mdk" )
+    {
+        menuPath=".menu/";
+    }
+    else if ( tmp == "mdk-simplified" )
+    {
+        menuPath=".menu-simplified/";
+    }
+    else
+    {
+        kdDebug()<<" Error in type of menu\n";
+        return;
+    }
+	QFile menuStamp(QDir::homeDirPath ()+"/.menu-updates.stamp");
+	if( menuStamp.exists())
+			menuStamp.remove();
+	QDir dir;
+	dir.mkdir( QDir::homeDirPath ()+"/"+menuPath );
+    QFile saveMenuMDV( QDir::homeDirPath ()+"/"+menuPath+filename );
+    if ( saveMenuMDV.open( IO_WriteOnly ) ) {
+        QTextStream stream( &saveMenuMDV );
+        stream<<menuElement<<"\n";
+        saveMenuMDV.close();
+    }
+}
+
 QString KOpenWithDlg::pathToCopyEntry( QString path, QString menuId )
 {
    if( KStandardDirs::menu_type_by_version()=="kde")