From 1cf3eb2174458a0b844287b9c265fc4e92464177 Mon Sep 17 00:00:00 2001 From: nils Date: Wed, 22 Dec 2010 23:06:04 +0000 Subject: added comment action (to insert > at every line) in edit menu, added drag and drop handling and exported textedit to its own class git-svn-id: http://cpunk.de/svn/src/gpg4usb/trunk@407 34ebc366-c3a9-4b3c-9f84-69acf7962910 --- gpgwin.cpp | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'gpgwin.cpp') diff --git a/gpgwin.cpp b/gpgwin.cpp index 77e10d7..1ca52c8 100644 --- a/gpgwin.cpp +++ b/gpgwin.cpp @@ -32,7 +32,7 @@ GpgWin::GpgWin() QString appPath = qApp->applicationDirPath(); iconPath = appPath + "/icons/"; - edit = new QPlainTextEdit(); + edit = new TextEdit(); setCentralWidget(edit); // setAcceptDrops(true); @@ -69,6 +69,7 @@ GpgWin::GpgWin() loadFile(args[1]); } } + setAcceptDrops(true); } void GpgWin::restoreSettings() @@ -188,6 +189,10 @@ void GpgWin::createActions() "clipboard")); connect(copyAct, SIGNAL(triggered()), edit, SLOT(copy())); + commentAct = new QAction(tr("Co&mment"), this); + commentAct->setToolTip(tr("Insert > in front of every line")); + connect(commentAct, SIGNAL(triggered()), edit, SLOT(comment())); + selectallAct = new QAction(tr("Select &All"), this); selectallAct->setIcon(QIcon(iconPath + "edit.png")); selectallAct->setShortcut(QKeySequence::SelectAll); @@ -295,6 +300,7 @@ void GpgWin::createMenus() editMenu->addAction(cutAct); editMenu->addAction(pasteAct); editMenu->addAction(selectallAct); + editMenu->addAction(commentAct); editMenu->addSeparator(); editMenu->addAction(openSettingsAct); @@ -795,7 +801,6 @@ void GpgWin::fileEncryption() void GpgWin::openSettingsDialog() { new SettingsDialog(this); -// restoreSettings(); // Iconsize QSize iconSize = settings.value("toolbar/iconsize", QSize(32, 32)).toSize(); this->setIconSize(iconSize); @@ -804,3 +809,18 @@ void GpgWin::openSettingsDialog() Qt::ToolButtonStyle buttonStyle = static_cast(settings.value("toolbar/iconstyle", Qt::ToolButtonTextUnderIcon).toUInt()); this->setToolButtonStyle(buttonStyle); } +void GpgWin::dropEvent(QDropEvent* event) +{ + edit->setPlainText(event->mimeData()->text()); + qDebug() << "drop event main"; + //qDebug() << "hallo"; +// event->acceptProposedAction(); +} + +void GpgWin::dragEnterEvent(QDragEnterEvent *event) +{ + //qDebug() << "hallo"; + qDebug() << event->mimeData()->text(); + if (event->mimeData()->hasFormat("text/plain")) + event->acceptProposedAction(); +} -- cgit v1.2.3