xml \
xmlpatterns \
webkit
-
maemo5:QT += maemo5
TARGET = mdictionary
TEMPLATE = app
gui/MenuTabWidget.h \
gui/DictManagerWidget.h \
gui/DictTypeSelectDialog.h \
- gui/TranslationWidgetAutoResizer.h \
../includes/History.h \
gui/HistoryListDialog.h \
../includes/GUIInterface.h \
INSTALLS += target \
desktop \
icon64 \
- bookmarks
-
+ bookmarks
target.path = $$BINDIR
maemo5 {
desktop.path = $$DATADIR/applications/hildon
}
desktop.files += ../../../data/other/$${TARGET}.desktop
icon64.files += ../../../data/icons/64x64/$${TARGET}.png
-
bookmarks.path = $$LIBDIR
bookmarks.files += ../../../data/icons/16x16/staron.png
}
QWebView(parent)
{
searchSelectedAction = new QAction(tr("Search"), this);
+ copySelectedAction = new QAction(tr("Copy"), this);
+ selectAllAction = new QAction(tr("Select All"), this);
connect(searchSelectedAction, SIGNAL(triggered()),
this, SIGNAL(search()));
}
void TranslationTextEdit::contextMenuEvent(QContextMenuEvent *e) {
- //QMenu *menu = createStandardContextMenu(e->pos());
- //if(page()->selectedText().isEmpty())
- // searchSelectedAction->setEnabled(false);
- //else
- // searchSelectedAction->setEnabled(true);
+ QMenu *menu = new QMenu;
+ if(selectedText().isEmpty())
+ searchSelectedAction->setEnabled(false);
+ else
+ searchSelectedAction->setEnabled(true);
- //menu->addSeparator();
- //menu->addAction(searchSelectedAction);
+ menu->addAction(searchSelectedAction);
+ menu->addSeparator();
+ menu->addAction(pageAction(QWebPage::Copy));
+ menu->addAction(pageAction(QWebPage::SelectAll));
- //menu->exec(e->globalPos());
- //delete menu;
+ menu->exec(e->globalPos());
+ delete menu;
- //e->ignore();
+ e->ignore();
}
+
+
+
private:
QAction* searchSelectedAction;
+ QAction* copySelectedAction;
+ QAction* selectAllAction;
+
};
#endif // TRANSLATIONTEXTEDIT_H
//Created by Mateusz Półrola
#include "TranslationWidget.h"
-#include "TranslationWidgetAutoResizer.h"
#include <QDebug>
#ifdef Q_WS_MAEMO_5
#include <QtGui/QX11Info>
trans += t + "\n";
}
-
- QImage image(":icons/16x16/staron.png");
-// QTextDocument *document = textEdit->document();
-// document->addResource(QTextDocument::ImageResource,
-// QUrl("mydata://image.png"), QVariant(image));
-
- // QFile cssFile(QDir::homePath() + "/.mdictionary/style.css");
- // cssFile.open(QFile::ReadOnly);
- // document->addResource(QTextDocument::StyleSheetResource,
-// QUrl("mydata://style.css"),
-// QVariant(cssFile.readAll()));
-
-
trans=tr("<?xml version=\"1.0\" encoding=\"UTF-8\"?>") + tr("\n <ar>")
+ trans + tr("\n </ar>");
trans=XslConversion(trans);
trans.replace("$STAR$", "/usr/lib/mdictionary/staron.png");
- qDebug () << trans;
webkit->setHtml(trans, QUrl().fromLocalFile("/"));
void TranslationWidget::initializeUI() {
webkit = new TranslationTextEdit(this);
-// textEdit->setReadOnly(true);
-
- //resizer = new TranslationWidgetAutoResizer(textEdit);
- //connect(this, SIGNAL(updateSize()),
- //resizer, SLOT(textEditChanged()));
QWidget*w = new QWidget(this);
verticalLayout = new QVBoxLayout(w);
verticalLayout->addWidget(webkit);
-// textEdit->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- // textEdit->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
-
this->setWidget(w);
this->setWidgetResizable(true);
#ifdef Q_WS_MAEMO_5
hide();
#endif
- Q_EMIT search(webkit->page()->selectedText());
+ Q_EMIT search(webkit->selectedText().toLower());
}
#ifdef Q_WS_MAEMO_5
#include <QModelIndex>
#include <QtGui>
#include "../backbone/backbone.h"
-#include "TranslationWidgetAutoResizer.h"
#include <QtXml>
#include <QXmlQuery>
#include "TranslationTextEdit.h"
#endif
QVBoxLayout *verticalLayout;
QHBoxLayout* horizontalLayout;
- TranslationWidgetAutoResizer* resizer;
void initializeUI();
};
+++ /dev/null
-/*******************************************************************************
-
- This file is part of mDictionary.
-
- mDictionary is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- mDictionary is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with mDictionary. If not, see <http://www.gnu.org/licenses/>.
-
- Copyright 2010 Comarch S.A.
-
-*******************************************************************************/
-//! \file TranslationWidgetAutoResizer.h
-//! \brief Implements translation widget auto resizer
-//! \author Mateusz Półrola <mateusz.polrola@comarch.pl>a
-
-#ifndef TRANSLATIONWIDGETAUTORESIZER_H
-#define TRANSLATIONWIDGETAUTORESIZER_H
-
-#include <QtGui/qtextedit.h>
-class TranslationWidgetAutoResizer : public QObject
-{
- Q_OBJECT
-
-public:
- TranslationWidgetAutoResizer(QWidget *parent) :QObject(parent),
- textEdit(qobject_cast<QTextEdit* >((parent))),
- edit(qobject_cast<QFrame* >((parent))) {
-
- // connect(parent, SIGNAL(textChanged()), this,
- // SLOT(textEditChanged()));
- // connect(parent, SIGNAL(cursorPositionChanged()),
- // this, SLOT(textEditChanged()));
- }
-
-public Q_SLOTS:
- inline void textEditChanged();
-
-private:
- QTextEdit *textEdit;
- QFrame *edit;
-};
-
-void TranslationWidgetAutoResizer::textEditChanged() {
- QTextDocument *doc = textEdit->document();
-
- QSize s = doc->size().toSize();
-
- const QRect fr = edit->frameRect();
- const QRect cr = edit->contentsRect();
-
- edit->setMinimumHeight(qMax(70, s.height() + (fr.height() - cr.height()) -
- 1));
-
- edit->setMinimumHeight(qMax(70, s.height() + (fr.height() - cr.height()) -
- 1));
-}
-
-#endif // TRANSLATIONWIDGETAUTORESIZER_H