diff options
-rw-r--r-- | Swift/QtUI/QtChatView.cpp | 1 | ||||
-rw-r--r-- | Swift/QtUI/QtWebView.cpp | 9 | ||||
-rw-r--r-- | Swift/QtUI/QtWebView.h | 2 |
3 files changed, 11 insertions, 1 deletions
diff --git a/Swift/QtUI/QtChatView.cpp b/Swift/QtUI/QtChatView.cpp index c533525..4c6a729 100644 --- a/Swift/QtUI/QtChatView.cpp +++ b/Swift/QtUI/QtChatView.cpp @@ -223,18 +223,19 @@ void QtChatView::decreaseFontSize() { void QtChatView::resizeFont(int fontSizeSteps) { fontSizeSteps_ = fontSizeSteps; double size = 1.0 + 0.2 * fontSizeSteps_; QString sizeString(QString().setNum(size, 'g', 3) + "em"); //qDebug() << "Setting to " << sizeString; const QWebElementCollection spans = document_.findAll("span"); foreach (QWebElement span, spans) { span.setStyleProperty("font-size", sizeString); } + webView_->setFontSizeIsMinimal(size == 1.0); } void QtChatView::resetView() { lastElement_ = QWebElement(); QString pageHTML = theme_->getTemplate(); pageHTML.replace("==bodyBackground==", "background-color:#e3e3e3"); pageHTML.replace(pageHTML.indexOf("%@"), 2, theme_->getBase()); if (pageHTML.count("%@") > 3) { pageHTML.replace(pageHTML.indexOf("%@"), 2, theme_->getMainCSS()); diff --git a/Swift/QtUI/QtWebView.cpp b/Swift/QtUI/QtWebView.cpp index 5d25071..5f9539e 100644 --- a/Swift/QtUI/QtWebView.cpp +++ b/Swift/QtUI/QtWebView.cpp @@ -33,18 +33,22 @@ void QtWebView::keyPressEvent(QKeyEvent* event) { event->count()); QWebView::keyPressEvent(translatedEvent); delete translatedEvent; } void QtWebView::dragEnterEvent(QDragEnterEvent*) { } +void QtWebView::setFontSizeIsMinimal(bool minimum) { + fontSizeIsMinimal = minimum; +} + void QtWebView::contextMenuEvent(QContextMenuEvent* ev) { // Filter out the relevant actions from the standard actions QMenu* menu = page()->createStandardContextMenu(); QList<QAction*> actions(menu->actions()); for (int i = 0; i < actions.size(); ++i) { QAction* action = actions.at(i); bool removeAction = true; for(size_t j = 0; j < filteredActions.size(); ++j) { if (action == pageAction(filteredActions[j])) { @@ -54,19 +58,22 @@ void QtWebView::contextMenuEvent(QContextMenuEvent* ev) { } if (removeAction) { menu->removeAction(action); } } // Add our own custom actions menu->addAction(tr("Clear"), this, SIGNAL(clearRequested())); menu->addAction(tr("Increase font size"), this, SIGNAL(fontGrowRequested())); - menu->addAction(tr("Decrease font size"), this, SIGNAL(fontShrinkRequested())); + QAction* shrink = new QAction(tr("Decrease font size"), this); + shrink->setEnabled(!fontSizeIsMinimal); + connect(shrink, SIGNAL(triggered()), this, SIGNAL(fontShrinkRequested())); + menu->addAction(shrink); menu->exec(ev->globalPos()); delete menu; } void QtWebView::focusInEvent(QFocusEvent* event) { QWebView::focusInEvent(event); emit gotFocus(); } diff --git a/Swift/QtUI/QtWebView.h b/Swift/QtUI/QtWebView.h index eb5a82d..202037f 100644 --- a/Swift/QtUI/QtWebView.h +++ b/Swift/QtUI/QtWebView.h @@ -12,23 +12,25 @@ namespace Swift { class QtWebView : public QWebView { Q_OBJECT public: QtWebView(QWidget* parent); void keyPressEvent(QKeyEvent* event); void dragEnterEvent(QDragEnterEvent *event); void contextMenuEvent(QContextMenuEvent* ev); + void setFontSizeIsMinimal(bool minimum); signals: void gotFocus(); void clearRequested(); void fontGrowRequested(); void fontShrinkRequested(); protected: void focusInEvent(QFocusEvent* event); private: std::vector<QWebPage::WebAction> filteredActions; + bool fontSizeIsMinimal; }; } |