mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-27 14:29:21 +00:00
Transfer Drag&Drop handling from GuiWorkArea to GuiView.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19556 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
db59cc47ee
commit
3d1cfa550b
@ -30,31 +30,36 @@
|
||||
#include "support/filetools.h"
|
||||
#include "support/convert.h"
|
||||
#include "support/lstrings.h"
|
||||
#include "support/os.h"
|
||||
|
||||
#include "Buffer.h"
|
||||
#include "BufferView.h"
|
||||
#include "BufferList.h"
|
||||
#include "callback.h"
|
||||
#include "debug.h"
|
||||
#include "FuncRequest.h"
|
||||
#include "callback.h"
|
||||
#include "LyXRC.h"
|
||||
#include "LyX.h"
|
||||
#include "Session.h"
|
||||
#include "LyXFunc.h"
|
||||
#include "LyXRC.h"
|
||||
#include "MenuBackend.h"
|
||||
#include "Buffer.h"
|
||||
#include "BufferList.h"
|
||||
#include "Session.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QApplication>
|
||||
#include <QCloseEvent>
|
||||
#include <QDesktopWidget>
|
||||
#include <QDragEnterEvent>
|
||||
#include <QDropEvent>
|
||||
#include <QHBoxLayout>
|
||||
#include <QList>
|
||||
#include <QMimeData>
|
||||
#include <QPixmap>
|
||||
#include <QPushButton>
|
||||
#include <QStatusBar>
|
||||
#include <QToolBar>
|
||||
#include <QTabBar>
|
||||
#include <QDesktopWidget>
|
||||
#include <QUrl>
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QPushButton>
|
||||
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
@ -222,6 +227,9 @@ GuiView::GuiView(int id)
|
||||
if (!iconname.empty())
|
||||
setWindowIcon(QPixmap(toqstr(iconname.absFilename())));
|
||||
#endif
|
||||
|
||||
// For Drag&Drop.
|
||||
setAcceptDrops(true);
|
||||
}
|
||||
|
||||
|
||||
@ -320,6 +328,33 @@ void GuiView::closeEvent(QCloseEvent * close_event)
|
||||
}
|
||||
|
||||
|
||||
void GuiView::dragEnterEvent(QDragEnterEvent * event)
|
||||
{
|
||||
if (event->mimeData()->hasUrls())
|
||||
event->accept();
|
||||
/// \todo Ask lyx-devel is this is enough:
|
||||
/// if (event->mimeData()->hasFormat("text/plain"))
|
||||
/// event->acceptProposedAction();
|
||||
}
|
||||
|
||||
|
||||
void GuiView::dropEvent(QDropEvent* event)
|
||||
{
|
||||
QList<QUrl> files = event->mimeData()->urls();
|
||||
if (files.isEmpty())
|
||||
return;
|
||||
|
||||
LYXERR(Debug::GUI) << BOOST_CURRENT_FUNCTION
|
||||
<< " got URLs!" << endl;
|
||||
for (int i = 0; i!=files.size(); ++i) {
|
||||
string const file = support::os::internal_path(fromqstr(
|
||||
files.at(i).toLocalFile()));
|
||||
if (!file.empty())
|
||||
dispatch(FuncRequest(LFUN_FILE_OPEN, file));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GuiView::saveGeometry()
|
||||
{
|
||||
static bool done = false;
|
||||
|
@ -117,6 +117,11 @@ protected:
|
||||
virtual void moveEvent(QMoveEvent * e);
|
||||
|
||||
private:
|
||||
///
|
||||
void dragEnterEvent(QDragEnterEvent * ev);
|
||||
///
|
||||
void dropEvent(QDropEvent * ev);
|
||||
|
||||
/// focus the command buffer widget
|
||||
void focus_command_widget();
|
||||
|
||||
|
@ -18,32 +18,28 @@
|
||||
#include "QKeySymbol.h"
|
||||
#include "qt_helpers.h"
|
||||
|
||||
#include "LyXView.h"
|
||||
#include "frontends/LyXView.h"
|
||||
|
||||
#include "BufferView.h"
|
||||
#include "rowpainter.h"
|
||||
#include "Color.h"
|
||||
#include "debug.h"
|
||||
#include "FuncRequest.h"
|
||||
#include "Color.h"
|
||||
#include "version.h"
|
||||
#include "LyXRC.h"
|
||||
#include "rowpainter.h"
|
||||
#include "version.h"
|
||||
|
||||
#include "support/filetools.h" // LibFileSearch
|
||||
#include "support/os.h"
|
||||
#include "support/convert.h"
|
||||
|
||||
#include "graphics/GraphicsImage.h"
|
||||
#include "graphics/GraphicsLoader.h"
|
||||
|
||||
#include <QInputContext>
|
||||
#include <QLayout>
|
||||
#include <QMainWindow>
|
||||
#include <QMimeData>
|
||||
#include <QUrl>
|
||||
#include <QDragEnterEvent>
|
||||
#include <QPainter>
|
||||
#include <QScrollBar>
|
||||
#include <QTimer>
|
||||
#include <QInputContext>
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/current_function.hpp>
|
||||
@ -63,9 +59,6 @@ int const CursorWidth = 1;
|
||||
using std::endl;
|
||||
using std::string;
|
||||
|
||||
namespace os = lyx::support::os;
|
||||
|
||||
|
||||
namespace lyx {
|
||||
|
||||
using support::FileName;
|
||||
@ -271,31 +264,6 @@ void GuiWorkArea::adjustViewWithScrollBar(int)
|
||||
}
|
||||
|
||||
|
||||
void GuiWorkArea::dragEnterEvent(QDragEnterEvent * event)
|
||||
{
|
||||
if (event->mimeData()->hasUrls())
|
||||
event->accept();
|
||||
/// \todo Ask lyx-devel is this is enough:
|
||||
/// if (event->mimeData()->hasFormat("text/plain"))
|
||||
/// event->acceptProposedAction();
|
||||
}
|
||||
|
||||
|
||||
void GuiWorkArea::dropEvent(QDropEvent* event)
|
||||
{
|
||||
QList<QUrl> files = event->mimeData()->urls();
|
||||
if (files.isEmpty())
|
||||
return;
|
||||
|
||||
LYXERR(Debug::GUI) << "GuiWorkArea::dropEvent: got URIs!" << endl;
|
||||
for (int i = 0; i!=files.size(); ++i) {
|
||||
string const file = os::internal_path(fromqstr(files.at(i).toLocalFile()));
|
||||
if (!file.empty())
|
||||
dispatch(FuncRequest(LFUN_FILE_OPEN, file));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GuiWorkArea::focusInEvent(QFocusEvent * /*event*/)
|
||||
{
|
||||
// No need to do anything if we didn't change views...
|
||||
|
@ -117,10 +117,6 @@ public:
|
||||
private:
|
||||
void doGreyOut(QLPainter & pain);
|
||||
///
|
||||
void dragEnterEvent(QDragEnterEvent * ev);
|
||||
///
|
||||
void dropEvent(QDropEvent * ev);
|
||||
///
|
||||
void focusInEvent(QFocusEvent *);
|
||||
///
|
||||
void focusOutEvent(QFocusEvent *);
|
||||
|
Loading…
Reference in New Issue
Block a user