PERFORCE change 164187 for review
Jonathan Anderson
jona at FreeBSD.org
Fri Jun 12 17:16:02 UTC 2009
http://perforce.freebsd.org/chv.cgi?CH=164187
Change 164187 by jona at jona-trustedbsd-kent on 2009/06/12 17:15:39
KDE powerboxes - 'test' requests powerboxes from kpowerboxserver using D-Bus IPC
Affected files ...
.. //depot/projects/trustedbsd/capabilities/cap-support/kpowerboxserver/CMakeLists.txt#3 edit
.. //depot/projects/trustedbsd/capabilities/cap-support/kpowerboxserver/cleanup.sh#1 add
.. //depot/projects/trustedbsd/capabilities/cap-support/kpowerboxserver/kpowerboxserver.cpp#2 edit
.. //depot/projects/trustedbsd/capabilities/cap-support/kpowerboxserver/kpowerboxserver.h#2 edit
.. //depot/projects/trustedbsd/capabilities/cap-support/kpowerboxserver/powerbox.h#2 edit
.. //depot/projects/trustedbsd/capabilities/cap-support/kpowerboxserver/test.cpp#1 add
Differences ...
==== //depot/projects/trustedbsd/capabilities/cap-support/kpowerboxserver/CMakeLists.txt#3 (text+ko) ====
@@ -1,16 +1,23 @@
cmake_minimum_required(VERSION 2.6)
-project(kpowerboxtest)
+project(kpowerboxserver)
find_package(KDE4 REQUIRED)
find_package(Qt4 REQUIRED)
include(${QT_USE_FILE})
-set(test_SRC kpowerboxtest.cpp kpowerboxserver.cpp)
+set(server_SRC main.cpp kpowerboxserver.cpp)
+set(server_MOC_HDRS kpowerboxserver.h)
+#qt4_wrap_cpp(server_MOC_SRC ${server_MOC_HDRS})
+#KDE4_AUTOMOC(${server_SRC})
+
+
+set(test_SRC test.cpp)
-qt4_automoc(${source})
+kde4_add_executable(test ${test_SRC})
+target_link_libraries(test ${QT_LIBRARIES} ${KDE4_KDEUI_LIBS})
-kde4_add_executable(kpowerboxtest ${test_SRC})
-target_link_libraries(kpowerboxtest ${QT_LIBRARIES} ${KDE4_KDEUI_LIBS} ${KDE4_KFILE_LIBS})
+kde4_add_executable(kpowerboxserver ${server_SRC})# ${server_MOC_SRC})
+target_link_libraries(kpowerboxserver ${QT_LIBRARIES} ${KDE4_KDEUI_LIBS} ${KDE4_KFILE_LIBS})
==== //depot/projects/trustedbsd/capabilities/cap-support/kpowerboxserver/kpowerboxserver.cpp#2 (text+ko) ====
@@ -4,12 +4,8 @@
#include <iostream>
-#include <fcntl.h>
-#include <unistd.h>
-
#include "powerbox.h"
-#include "kpowerboxserver.moc"
-
+#include "kpowerboxserver.h"
KPowerBoxServer::KPowerBoxServer()
@@ -18,19 +14,11 @@
}
-QMap<int,QString> KPowerBoxServer::showKDEPowerbox(struct capbox_options *options)
+QStringList
+KPowerBoxServer::showKDEPowerbox(int operation, QString title, QString parent,
+ QString startDir, QString filter, bool allowMultipleSelections)
{
- QMap<int,QString> fileDescriptors;
-
- if(options->ui != CAPBOX_KDE)
- {
- fileDescriptors[-1] =
- "Error: this is a KDE powerbox; we can only handle UI type CAPBOX_KDE";
-
- return fileDescriptors;
- }
-
- if(options->mult)
+ if(allowMultipleSelections)
{
// TODO: get KDE to support WId for multi-select dialogs
std::cerr
@@ -38,56 +26,45 @@
<< " dialogs, so we can't support multiple selection (for now)"
<< std::endl;
- options->mult = false;
+ allowMultipleSelections = false;
}
- QString startDir = options->start_path;
- QString filter = options->filter;
- WId parent = options->parent_window;
- QString title = options->window_title;
+ int base = 10;
+ if(parent.startsWith("0x"))
+ {
+ parent.replace("0x", "");
+ base = 16;
+ }
+ WId parentWId = parent.toLong(NULL, base);
QStringList filenames;
- switch(options->operation)
+ switch(operation)
{
case OPEN_FILE:
- if(options->mult)
+ if(allowMultipleSelections)
+ // TODO: multiple selection via WId
filenames =
KFileDialog::getOpenFileNames(startDir, filter, NULL, title);
else
filenames <<
- KFileDialog::getOpenFileNameWId(startDir, filter, parent, title);
+ KFileDialog::getOpenFileNameWId(startDir, filter, parentWId, title);
break;
case SAVE_FILE:
filenames <<
- KFileDialog::getSaveFileNameWId(startDir, filter, parent, title);
+ KFileDialog::getSaveFileNameWId(startDir, filter, parentWId, title);
break;
case SELECT_DIR:
+ // TODO: directory selection via WId
filenames <<
KFileDialog::getExistingDirectory(startDir, NULL, title);
break;
}
-
- for(int i = 0; i < filenames.size(); i++)
- {
- QString filename = filenames.at(i);
-
- int flags = 0;
- if((options->rights & 6) == 6) flags |= O_RDWR;
- else if((options->rights & 6) == 4) flags |= O_RDONLY;
- else if((options->rights & 6) == 2) flags |= O_WRONLY;
-
-// if(options->rights & 1) flags |= O_EXEC; TODO: no O_EXEC under Linux?
-
- int fd = open(filename.toStdString().c_str(), flags);
- fileDescriptors[fd] = filename;
- }
-
- return fileDescriptors;
+ return filenames;
}
==== //depot/projects/trustedbsd/capabilities/cap-support/kpowerboxserver/kpowerboxserver.h#2 (text+ko) ====
@@ -1,7 +1,13 @@
-#include <QtCore/QMap>
+
+#ifndef KPOWERBOX_SERVER
+#define KPOWERBOX_SERVER
+
+#include <QtCore/QList>
#include <QtCore/QObject>
#include <QtCore/QString>
+#include <QtGui/QtGui>
+
#include "powerbox.h"
@@ -12,6 +18,7 @@
{
Q_OBJECT
+
public:
KPowerBoxServer();
@@ -20,8 +27,26 @@
/**
* Shows a KDE-based PowerBox.
*
- * @return a map of file descriptors and their associated file names
+ * This is a very long list of parameters, but we have to use Qt-friendly types
+ * in order for Qt to do the D-Bus marshalling and unmarshalling for us.
+ *
+ * @param operation what we're doing (see powerbox.h)
+ * @param title the title of the dialog box
+ * @param parent ID of the parent window (to pop up in front of)
+ * @param startDir where to look for files
+ * @param filter selection filter (e.g. "*.cpp")
+ * @param allowMultipleSelections allow multiple selection
+ *
+ * @return a list of file names
*/
- QMap<int,QString> showKDEPowerbox(struct capbox_options *options);
+ Q_SCRIPTABLE QStringList showKDEPowerbox(
+ int operation,
+ QString title,
+ QString parent,
+ QString startDir,
+ QString filter,
+ bool allowMultipleSelections = false);
};
+#endif
+
==== //depot/projects/trustedbsd/capabilities/cap-support/kpowerboxserver/powerbox.h#2 (text+ko) ====
More information about the p4-projects
mailing list