summaryrefslogtreecommitdiffstats
path: root/kio/kfile/kopenwith.h
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commitce4a32fe52ef09d8f5ff1dd22c001110902b60a2 (patch)
tree5ac38a06f3dde268dc7927dc155896926aaf7012 /kio/kfile/kopenwith.h
downloadtdelibs-ce4a32fe52ef09d8f5ff1dd22c001110902b60a2.tar.gz
tdelibs-ce4a32fe52ef09d8f5ff1dd22c001110902b60a2.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kio/kfile/kopenwith.h')
-rw-r--r--kio/kfile/kopenwith.h209
1 files changed, 209 insertions, 0 deletions
diff --git a/kio/kfile/kopenwith.h b/kio/kfile/kopenwith.h
new file mode 100644
index 000000000..c343816aa
--- /dev/null
+++ b/kio/kfile/kopenwith.h
@@ -0,0 +1,209 @@
+//
+/* This file is part of the KDE libraries
+ Copyright (C) 2000 David Faure <faure@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ 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 __open_with_h__
+#define __open_with_h__
+
+#include <qdialog.h>
+
+#include <kurl.h>
+#include <krun.h>
+#include <kservice.h>
+
+class KApplicationTree;
+class KURLRequester;
+
+class QWidget;
+class QCheckBox;
+class QPushButton;
+class QLabel;
+
+class KOpenWithDlgPrivate;
+
+/* ------------------------------------------------------------------------- */
+/**
+ * "Open with" dialog box.
+ * Used automatically by KRun, and used by libkonq.
+ *
+ * @author David Faure <faure@kde.org>
+ */
+class KIO_EXPORT KOpenWithDlg : public QDialog //#TODO: Use KDialogBase for KDE4
+{
+ Q_OBJECT
+public:
+
+ /**
+ * Create a dialog that asks for a application to open a given
+ * URL(s) with.
+ *
+ * @param urls the URLs that should be opened. The list can be empty,
+ * if the dialog is used to choose an application but not for some particular URLs.
+ * @param parent parent widget
+ */
+ KOpenWithDlg( const KURL::List& urls, QWidget *parent = 0L );
+
+ /**
+ * Create a dialog that asks for a application to open a given
+ * URL(s) with.
+ *
+ * @param urls is the URL that should be opened
+ * @param text appears as a label on top of the entry box.
+ * @param value is the initial value of the line
+ * @param parent parent widget
+ */
+ KOpenWithDlg( const KURL::List& urls, const QString& text, const QString& value,
+ QWidget *parent = 0L );
+
+ /**
+ * Create a dialog to select a service for a given service type.
+ * Note that this dialog doesn't apply to URLs.
+ *
+ * @param serviceType the service type we want to choose an application for.
+ * @param value is the initial value of the line
+ * @param parent parent widget
+ */
+ KOpenWithDlg( const QString& serviceType, const QString& value,
+ QWidget *parent = 0L );
+
+ /**
+ * Create a dialog to select an application
+ * Note that this dialog doesn't apply to URLs.
+ *
+ * @param parent parent widget
+ * @since 3.1
+ */
+ KOpenWithDlg( QWidget *parent = 0L );
+
+ /**
+ * Destructor
+ */
+ ~KOpenWithDlg();
+
+ /**
+ * @return the text the user entered
+ */
+ QString text() const;
+ /**
+ * Hide the "Do not &close when command exits" Checkbox
+ */
+ void hideNoCloseOnExit();
+ /**
+ * Hide the "Run in &terminal" Checkbox
+ */
+ void hideRunInTerminal();
+ /**
+ * @return the chosen service in the application tree
+ * Can be null, if the user typed some text and didn't select a service.
+ */
+ KService::Ptr service() const { return m_pService; }
+ /**
+ * Set whether a new .desktop file should be created if the user selects an
+ * application for which no corresponding .desktop file can be found.
+ *
+ * Regardless of this setting a new .desktop file may still be created if
+ * the user has chosen to remember the file association.
+ *
+ * The default is false: no .desktop files are created.
+ * @since 3.2
+ */
+ void setSaveNewApplications(bool b);
+
+public slots:
+ /**
+ * The slot for clearing the edit widget
+ */
+ void slotClear();
+ void slotSelected( const QString&_name, const QString& _exec );
+ void slotHighlighted( const QString& _name, const QString& _exec );
+ void slotTextChanged();
+ void slotTerminalToggled(bool);
+ void slotDbClick();
+ void slotOK();
+
+protected slots:
+ /**
+ * Reimplemented from QDialog::accept() to save history of the combobox
+ */
+ virtual void accept();
+
+protected:
+
+ /**
+ * Determine service type from URLs
+ */
+ void setServiceType( const KURL::List& _urls );
+
+ /**
+ * Create a dialog that asks for a application to open a given
+ * URL(s) with.
+ *
+ * @param text appears as a label on top of the entry box.
+ * @param value is the initial value of the line
+ */
+ void init( const QString& text, const QString& value );
+
+ KURLRequester * edit;
+ QString m_command;
+
+ KApplicationTree* m_pTree;
+ QLabel *label;
+
+ QString qName, qServiceType;
+ bool m_terminaldirty;
+ QCheckBox *terminal, *remember, *nocloseonexit;
+ QPushButton *UNUSED;
+ QPushButton *UNUSED2;
+
+ KService::Ptr m_pService;
+
+ KOpenWithDlgPrivate *d;
+};
+
+/* ------------------------------------------------------------------------- */
+
+#ifndef KDE_NO_COMPAT
+/**
+ * This class handles the displayOpenWithDialog call, made by KRun
+ * when it has no idea what to do with a URL.
+ * It displays the open-with dialog box.
+ *
+ * If you use KRun you _need_ to create an instance of KFileOpenWithHandler
+ * (except if you can make sure you only use it for executables or
+ * Type=Application desktop files)
+ *
+ *
+ */
+class KIO_EXPORT_DEPRECATED KFileOpenWithHandler : public KOpenWithHandler
+{
+public:
+ KFileOpenWithHandler() : KOpenWithHandler() {}
+ virtual ~KFileOpenWithHandler() {}
+
+ /**
+ * Opens an open-with dialog box for @p urls
+ * @returns true if the operation succeeded
+ */
+ virtual bool displayOpenWithDialog( const KURL::List& urls );
+};
+#endif
+
+
+/* ------------------------------------------------------------------------- */
+
+#endif