Add ability to accept drops of files to the main window

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
pull/3/head
Michele Calgaro 1 year ago
parent 455025d23a
commit c0b1f3384c
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -38,6 +38,7 @@
#include <tqapplication.h>
#include <tqcheckbox.h>
#include <tqcursor.h>
#include <tqdragobject.h>
#include <tqfile.h>
#include <tqfiledialog.h>
#include <tqfileinfo.h>
@ -56,20 +57,16 @@
#include <tqextscintilla.h>
///-- #include <Qsci/qsciprinter.h>
///--
///-- using namespace tschweitzer;
// \defgroup grp_MainWindow All concerning main window functionality.
///-- using namespace tschweitzer;
/*
\class MainWindow
\ingroup grp_MainWindow
\brief Is the main window of UniversalIndentGUI
\brief Main window of UniversalIndentGUI-tqt
The MainWindow class is responsible for generating and displaying most of the gui elements.
Its look is set in the file "mainwindow.ui". An object for the indent handler is generated here
and user actions are being controlled. Is responsible for file open dialogs and indenter selection.
and user actions are being controlled. It is responsible for file open dialogs and indenter selection.
*/
/*
@ -82,9 +79,8 @@ MainWindow::MainWindow(TQString file2OpenOnStart, TQWidget *parent) :
m_encodingActionGroup(nullptr), m_saveEncodedActionGroup(nullptr),
m_highlighterActionGroup(nullptr), m_documentModified(false), m_previewToggled(true),
m_indentHandler(nullptr), m_centralSplitter(nullptr), m_settingsDialog(nullptr),
m_highlighter(nullptr), m_highlightingActions()
///_aboutDialogGraphicsView(nullptr)
///- m_textEditVScrollBar(nullptr), _toolBarWidget(nullptr)
m_highlighter(nullptr), m_highlightingActions(), m_toolBarWidget(nullptr)
///_aboutDialogGraphicsView(nullptr), m_textEditVScrollBar(nullptr)
{
// Init of some variables.
m_sourceCodeChanged = false;
@ -99,7 +95,7 @@ MainWindow::MainWindow(TQString file2OpenOnStart, TQWidget *parent) :
initMainWindow();
// Create toolbar and insert it into the main window.
initToolBar();
initToolBar();
// Create the text edit component using the TQScintilla widget.
initTextEditor();
@ -120,9 +116,9 @@ MainWindow::MainWindow(TQString file2OpenOnStart, TQWidget *parent) :
///-- _aboutDialogGraphicsView = new AboutDialogGraphicsView(m_aboutDialog, this);
connect(actionAboutUniversalIndentGUITQt, SIGNAL(activated()), this, SLOT(showAboutDialog()));
// Generate settings dialog box
m_settingsDialog = new UiGuiSettingsDialog(this, m_settings);
connect(actionShowSettings, SIGNAL(activated()), m_settingsDialog, SLOT(showDialog()));
// Generate settings dialog box
m_settingsDialog = new UiGuiSettingsDialog(this, m_settings);
connect(actionShowSettings, SIGNAL(activated()), m_settingsDialog, SLOT(showDialog()));
if (TQFile::exists(file2OpenOnStart))
{
@ -137,8 +133,8 @@ MainWindow::MainWindow(TQString file2OpenOnStart, TQWidget *parent) :
updateSyntaxHighlighting();
///-- // Enable accept dropping of files.
///-- setAcceptDrops(true);
// Enable accept dropping of files.
setAcceptDrops(true);
}
MainWindow::~MainWindow()
@ -1513,30 +1509,25 @@ void MainWindow::openFileFromRecentlyOpenedList(int recentlyOpenedActionId)
}
}
///-- /*
///-- \brief If the dragged in object contains urls/paths to a file, accept the drag.
///-- */
///-- void MainWindow::dragEnterEvent(TQDragEnterEvent *event)
///-- {
///-- if (event->mimeData()->hasUrls())
///-- {
///-- event->acceptProposedAction();
///-- }
///-- }
///--
///-- /*
///-- \brief If the dropped in object contains urls/paths to a file, open that file.
///-- */
///-- void MainWindow::dropEvent(TQDropEvent *event)
///-- {
///-- if (event->mimeData()->hasUrls())
///-- {
///-- TQString filePathName = event->mimeData()->urls().first().toLocalFile();
///-- openSourceFileDialog(filePathName);
///-- }
///--
///-- event->acceptProposedAction();
///-- }
/*
\brief If the dragged in object contains urls/paths to a file, accept the drag.
*/
void MainWindow::dragEnterEvent(TQDragEnterEvent *event)
{
event->accept(TQUriDrag::canDecode(event));
}
/*
\brief If the dropped in object contains urls/paths to a file, open that file.
*/
void MainWindow::dropEvent(TQDropEvent *event)
{
TQStringList droppedFileNames;
if (TQUriDrag::decodeLocalFiles(event, droppedFileNames))
{
openSourceFileDialog(droppedFileNames[0]);
}
}
/*
\brief Show the About dialog.

@ -33,11 +33,10 @@ class UiGuiSettings;
class UiGuiSettingsDialog;
class ToolBarWidget;
/// class TQActionGroup;
class TQextScintilla;
class TQSplitter;
class TQLabel;
class TQScrollBar;
class TQSplitter;
class TQTranslator;
@ -96,8 +95,8 @@ class MainWindow : public MainWindowBase
void initIndenter();
void initRecentlyOpenedList();
///-- void changeEvent(TQEvent *event);
///-- void dragEnterEvent(TQDragEnterEvent *event);
///-- void dropEvent(TQDropEvent *event);
void dragEnterEvent(TQDragEnterEvent *event);
void dropEvent(TQDropEvent *event);
TQSplitter *m_centralSplitter;
TQextScintilla *m_qSciSourceCodeEditor;

@ -127,7 +127,7 @@ void SettingsPaths::init()
tqDebug("Paths are:\n"
" m_applicationBinaryPath = %s\n"
" m_settingsPath = %s\n"
" m_globalFilesPath =%s\n"
" m_globalFilesPath = %s\n"
" m_indenterPath = %s\n"
" m_tempPath = %s\n"
"Running in portable mode = %s",

Loading…
Cancel
Save