Added all previous functionality
authorBartosz Szatkowski <bulislaw@linux.com>
Tue, 31 Aug 2010 11:01:05 +0000 (13:01 +0200)
committerBartosz Szatkowski <bulislaw@linux.com>
Tue, 31 Aug 2010 11:01:05 +0000 (13:01 +0200)
trunk/src/base/gui/TranslationTextEdit.cpp
trunk/src/base/gui/TranslationTextEdit.h
trunk/src/base/gui/TranslationWidget.cpp

index dd46e02..d6b7d7a 100644 (file)
@@ -33,6 +33,7 @@ TranslationTextEdit::TranslationTextEdit(QWidget *parent) :
 
     connect(searchSelectedAction, SIGNAL(triggered()),
             this, SIGNAL(search()));
+    connect(page(), SIGNAL(selectionChanged()), this, SLOT(selection()));
 }
 
 void TranslationTextEdit::contextMenuEvent(QContextMenuEvent *e) {
@@ -54,4 +55,29 @@ void TranslationTextEdit::contextMenuEvent(QContextMenuEvent *e) {
 }
 
 
+void TranslationTextEdit::zoomIn() {
+    setZoomFactor(zoomFactor()*1.05);
+}
+
+void TranslationTextEdit::zoomOut() {
+    setZoomFactor(zoomFactor()*0.95);
+}
+
+void TranslationTextEdit::copy() {
+      pageAction(QWebPage::Copy)->trigger();
+}
+
+void TranslationTextEdit::selection() {
+    if(selectedText().size())
+        Q_EMIT copyAvailable(true);
+    else
+        Q_EMIT copyAvailable(false);
+}
+
+
+void TranslationTextEdit::selectAll() {
+    pageAction(QWebPage::SelectAll)->trigger();
+}
+
+
 
index 6f3fe3b..1c9adff 100644 (file)
@@ -34,8 +34,16 @@ class TranslationTextEdit : public QWebView
 public:
     explicit TranslationTextEdit(QWidget *parent = 0);
 
+public Q_SLOTS:
+    void zoomIn();
+    void zoomOut();
+    void copy();
+    void selection();
+    void selectAll();
+
 Q_SIGNALS:
     void search();
+    void copyAvailable(bool);
 
 protected:
     void contextMenuEvent(QContextMenuEvent *);
index 161cf0b..3cfc892 100644 (file)
@@ -235,26 +235,26 @@ void TranslationWidget::initializeUI() {
         showButtonsButton->setMinimumSize(searchButton->sizeHint());
 
         connect(zoomInButton, SIGNAL(clicked()),
-                textEdit, SLOT(zoomIn()));
+                webkit, SLOT(zoomIn()));
 
         connect(zoomOutButton, SIGNAL(clicked()),
-                textEdit, SLOT(zoomOut()));
+                webkit, SLOT(zoomOut()));
 
 
         connect(searchButton, SIGNAL(clicked()),
                 this, SLOT(searchSelected()));
 
         connect(copyButton, SIGNAL(clicked()),
-                textEdit, SLOT(copy()));
+                webkit, SLOT(copy()));
 
-        connect(textEdit, SIGNAL(copyAvailable(bool)),
+        connect(webkit, SIGNAL(copyAvailable(bool)),
                 searchButton, SLOT(setEnabled(bool)));
 
-        connect(textEdit, SIGNAL(copyAvailable(bool)),
+        connect(webkit, SIGNAL(copyAvailable(bool)),
                 copyButton, SLOT(setEnabled(bool)));
 
         connect(selectAllButton, SIGNAL(clicked()),
-                textEdit, SLOT(selectAll()));
+                webkit, SLOT(selectAll()));
 
         buttonsInitialized = false;
 
@@ -320,12 +320,12 @@ void TranslationWidget::hideEvent(QHideEvent* e) {
 void TranslationWidget::keyPressEvent(QKeyEvent* event) {
     switch (event->key()) {
         case Qt::Key_F7:
-        textEdit->zoomIn();
+        webkit->zoomIn();
         event->accept();
         break;
 
         case Qt::Key_F8:
-        textEdit->zoomOut();
+        webkit->zoomOut();
         event->accept();
         break;
     }