Merge branch 'master' of github.com:Sankore/Sankore-3.1

preferencesAboutTextFull
Ivan Ilin 13 years ago
commit d79f36eb9b
  1. 19
      src/board/UBBoardController.cpp
  2. 29
      src/frameworks/UBPlatformUtils.h
  3. 9
      src/frameworks/UBPlatformUtils_linux.cpp
  4. 16
      src/frameworks/UBPlatformUtils_mac.mm
  5. 7
      src/frameworks/UBPlatformUtils_win.cpp
  6. 5
      src/gui/UBDownloadWidget.cpp
  7. 79
      src/gui/UBLibraryWidget.cpp
  8. 1
      src/gui/UBLibraryWidget.h

@ -1846,7 +1846,7 @@ void UBBoardController::processMimeData(const QMimeData* pMimeData, const QPoint
QString qsHtml = pMimeData->html();
QString url = UBApplication::urlFromHtml(qsHtml);
if(!("" == url))
if("" != url)
{
downloadURL(url, pPos);
return;
@ -1883,7 +1883,22 @@ void UBBoardController::processMimeData(const QMimeData* pMimeData, const QPoint
if (pMimeData->hasText())
{
mActiveScene->addText(pMimeData->text(), pPos);
if("" != pMimeData->text()){
mActiveScene->addText(pMimeData->text(), pPos);
}
else{
#ifdef Q_WS_MACX
// With Safari, in 95% of the drops, the mime datas are hidden in Apple Web Archive pasteboard type.
// This is due to the way Safari is working so we have to dig into the pasteboard in order to retrieve
// the data.
QString qsUrl = UBPlatformUtils::urlFromClipboard();
if("" != qsUrl){
// We finally got the url of the dropped ressource! Let's import it!
downloadURL(qsUrl, pPos);
return;
}
#endif
}
}
}

@ -90,44 +90,31 @@ class UBPlatformUtils
UBPlatformUtils();
virtual ~UBPlatformUtils();
static void initializeKeyboardLayouts();
static void destroyKeyboardLayouts();
static int nKeyboardLayouts;
static UBKeyboardLocale** keyboardLayouts;
static void initializeKeyboardLayouts();
static void destroyKeyboardLayouts();
static int nKeyboardLayouts;
static UBKeyboardLocale** keyboardLayouts;
public:
static void init();
static void destroy();
static void destroy();
static QString applicationResourcesDirectory();
static void hideFile(const QString &filePath);
static void setFileType(const QString &filePath, unsigned long fileType);
static void fadeDisplayOut();
static void fadeDisplayIn();
static QString preferredTranslation();
static QString preferredLanguage();
static bool hasVirtualKeyboard();
//static void showVirtualKeyboard();
static void runInstaller(const QString &installerFilePath);
static void bringPreviousProcessToFront();
static QString osUserLoginName();
static void setDesktopMode(bool desktop);
static void setWindowNonActivableFlag(QWidget* widget, bool nonAcivable);
static void setWindowNonActivableFlag(QWidget* widget, bool nonAcivable);
static QString computerName();
static UBKeyboardLocale** getKeyboardLayouts(int& nCount);
static UBKeyboardLocale** getKeyboardLayouts(int& nCount);
static QString urlFromClipboard();
};

@ -331,3 +331,12 @@ void UBPlatformUtils::destroyKeyboardLayouts()
delete [] keyboardLayouts;
keyboardLayouts = NULL;
}
QString UBPlatformUtils::urlFromClipboard()
{
QString qsRet;
// Not used on Linux
return qsRet;
}

@ -12,6 +12,8 @@
#import <Foundation/NSAutoreleasePool.h>
#import <Carbon/Carbon.h>
#import <APELite.h>
#import <WebKit/WebKit.h>
#import <AppKit/AppKit.h>
NSString* bundleShortVersion(NSBundle *bundle)
@ -537,3 +539,17 @@ void UBPlatformUtils::initializeKeyboardLayouts()
void UBPlatformUtils::destroyKeyboardLayouts()
{}
QString UBPlatformUtils::urlFromClipboard()
{
QString qsRet;
NSPasteboard* pPasteboard = [NSPasteboard pasteboardWithName:@"Apple CFPasteboard drag"];
WebArchive* pArchive = [[WebArchive alloc] initWithData:[pPasteboard dataForType:@"com.apple.webarchive"]];
qsRet = [[[[pArchive mainResource] URL] absoluteString] UTF8String];
[pArchive release];
return qsRet;
}

@ -368,3 +368,10 @@ void UBPlatformUtils::destroyKeyboardLayouts()
delete [] keyboardLayouts;
keyboardLayouts = NULL;
}
QString UBPlatformUtils::urlFromClipboard()
{
QString qsRet;
// Not implemented yet
return qsRet;
}

@ -66,11 +66,6 @@ UBDownloadWidget::UBDownloadWidget(QWidget *parent, const char *name):QWidget(pa
*/
UBDownloadWidget::~UBDownloadWidget()
{
if(NULL != mpItem)
{
delete mpItem;
mpItem = NULL;
}
if(NULL != mpCancelBttn)
{
delete mpCancelBttn;

@ -27,6 +27,7 @@
#include "core/UBDownloadManager.h"
#include "frameworks/UBFileSystemUtils.h"
#include "frameworks/UBPlatformUtils.h"
#include "core/memcheck.h"
@ -348,18 +349,30 @@ void UBLibraryWidget::dropEvent(QDropEvent *event)
}
}
}
else
{
else{
bool bDropAccepted = false;
if (pMimeData->hasImage())
{
qDebug() << "hasImage";
QImage image = qvariant_cast<QImage>(pMimeData->imageData());
mLibraryController->importImageOnLibrary(image);
bDropAccepted = true;
// We must check the URLs first because an image dropped from the web can contains the image datas, as well as the URLs
// and if we want to display the download widget in order to make the user wait for the end of the download, we need
// to check the URLs first!
if (pMimeData->hasUrls()){
qDebug() << "hasUrls";
QList<QUrl> urlList = pMimeData->urls();
for (int i = 0; i < urlList.size() && i < 32; ++i){
QString filePath;
#ifdef Q_WS_MACX
filePath = QUrl(urlList.at(i)).toString();
#else
filePath = QUrl(urlList.at(i).path()).toLocalFile();
#endif
mLibraryController->importItemOnLibrary(filePath);
bDropAccepted = true;
}
}
else if (pMimeData->hasHtml())
{
// When an HTML is present, it means that we dropped something from the web. Normally, the HTML contains the element
// of the webpage and has a 'src' attribute containing the URL of the web ressource. Here we are looking for this
// 'src' attribute, get its value and download the ressource from this URL.
else if (pMimeData->hasHtml()){
qDebug() << "hasHtml";
QString html = pMimeData->html();
QString url = UBApplication::urlFromHtml(html);
@ -369,37 +382,47 @@ void UBLibraryWidget::dropEvent(QDropEvent *event)
bDropAccepted = true;
}
}
else if (pMimeData->hasText())
{
else if (pMimeData->hasText()){
// On linux external dragged element are considered as text;
qDebug() << "hasText: " << pMimeData->text();
QString filePath = QUrl(pMimeData->text()).toLocalFile();
mLibraryController->importItemOnLibrary(filePath);
bDropAccepted = true;
}
else if (pMimeData->hasUrls())
{
qDebug() << "hasUrls";
QList<QUrl> urlList = pMimeData->urls();
for (int i = 0; i < urlList.size() && i < 32; ++i)
{
QString filePath = QUrl(urlList.at(i).path()).toLocalFile();
if("" != filePath){
mLibraryController->importItemOnLibrary(filePath);
bDropAccepted = true;
}
else{
#ifdef Q_WS_MACX
// With Safari, in 95% of the drops, the mime datas are hidden in Apple Web Archive pasteboard type.
// This is due to the way Safari is working so we have to dig into the pasteboard in order to retrieve
// the data.
QString qsUrl = UBPlatformUtils::urlFromClipboard();
if("" != qsUrl){
// We finally got the url of the dropped ressource! Let's import it!
mLibraryController->importItemOnLibrary(qsUrl);
bDropAccepted = true;
}
#endif
}
}
else
{
else if (pMimeData->hasImage()){
qDebug() << "hasImage";
QImage image = qvariant_cast<QImage>(pMimeData->imageData());
mLibraryController->importImageOnLibrary(image);
bDropAccepted = true;
}
else{
qWarning() << "Cannot import data";
}
if(bDropAccepted)
{
if(bDropAccepted){
onRefreshCurrentFolder();
#ifdef Q_WS_MACX
event->acceptProposedAction();
#else
event->accept();
#endif
}
else
{
else{
event->ignore();
}
}

@ -79,6 +79,7 @@ private:
void refreshView();
void generateItems();
void appendChainedElement(UBChainedLibElement* element, UBChainedLibElement* toElem);
UBLibElement* elementAt(QPoint p);
UBLibElement* elementFromFilePath(const QString& filePath);
UBLibraryController* mLibraryController;

Loading…
Cancel
Save