diff --git a/src/lib/3rdparty/lineedit.cpp b/src/lib/3rdparty/lineedit.cpp index 2ddf43c9b..e8278b44b 100644 --- a/src/lib/3rdparty/lineedit.cpp +++ b/src/lib/3rdparty/lineedit.cpp @@ -18,11 +18,15 @@ #include "lineedit.h" #include "qzsettings.h" +#include #include #include -#include #include +#include #include +#include +#include +#include SideWidget::SideWidget(QWidget* parent) : QWidget(parent) @@ -102,6 +106,95 @@ bool LineEdit::event(QEvent* event) return QLineEdit::event(event); } +#define ACCEL_KEY(k) QLatin1Char('\t') + QString(QKeySequence(k)) + +// Modified QLineEdit::createStandardContextMenu to support icons and PasteAndGo action +QMenu* LineEdit::createContextMenu(QAction* pasteAndGoAction) +{ + QMenu* popup = new QMenu(this); + popup->setObjectName(QSL("qt_edit_menu")); + + QAction* action = 0; + + if (!isReadOnly()) { + action = popup->addAction(QIcon::fromTheme(QSL("edit-undo")), tr("&Undo") + ACCEL_KEY(QKeySequence::Undo)); + action->setEnabled(isUndoAvailable()); + connect(action, SIGNAL(triggered()), SLOT(undo())); + + action = popup->addAction(QIcon::fromTheme(QSL("edit-redo")), tr("&Redo") + ACCEL_KEY(QKeySequence::Redo)); + action->setEnabled(isRedoAvailable()); + connect(action, SIGNAL(triggered()), SLOT(redo())); + + popup->addSeparator(); + } + +#ifndef QT_NO_CLIPBOARD + if (!isReadOnly()) { + action = popup->addAction(QIcon::fromTheme(QSL("edit-cut")), tr("Cu&t") + ACCEL_KEY(QKeySequence::Cut)); + action->setEnabled(hasSelectedText() && echoMode() == QLineEdit::Normal); + connect(action, SIGNAL(triggered()), SLOT(cut())); + } + + action = popup->addAction(QIcon::fromTheme(QSL("edit-copy")), tr("&Copy") + ACCEL_KEY(QKeySequence::Copy)); + action->setEnabled(hasSelectedText() && echoMode() == QLineEdit::Normal); + connect(action, SIGNAL(triggered()), SLOT(copy())); + + if (!isReadOnly()) { + action = popup->addAction(QIcon::fromTheme(QSL("edit-paste")), tr("&Paste") + ACCEL_KEY(QKeySequence::Paste)); + action->setEnabled(!QApplication::clipboard()->text().isEmpty()); + connect(action, SIGNAL(triggered()), SLOT(paste())); + + pasteAndGoAction->setEnabled(action->isEnabled()); + popup->addAction(pasteAndGoAction); + } +#endif + + if (!isReadOnly()) { + action = popup->addAction(QIcon::fromTheme(QSL("edit-delete")), tr("Delete") + ACCEL_KEY(QKeySequence::Delete)); + action->setEnabled(hasSelectedText()); + connect(action, SIGNAL(triggered()), this, SLOT(slotDelete())); + + action = popup->addAction(QIcon::fromTheme(QSL("edit-clear")), tr("Clear All")); + connect(action, SIGNAL(triggered()), this, SLOT(clear())); + } + + if (!popup->isEmpty()) { + popup->addSeparator(); + } + + action = popup->addAction(QIcon::fromTheme(QSL("edit-select-all")), tr("Select All") + ACCEL_KEY(QKeySequence::SelectAll)); + action->setEnabled(!text().isEmpty() && selectedText() == text()); + connect(action, SIGNAL(triggered()), SLOT(selectAll())); + +#if !defined(QT_NO_IM) + QInputContext* qic = inputContext(); + if (qic) { + QList imActions = qic->actions(); + for (int i = 0; i < imActions.size(); ++i) { + popup->addAction(imActions.at(i)); + } + } +#endif + + // Hack to get QUnicodeControlCharacterMenu + QMenu* tmp = createStandardContextMenu(); + QAction* lastAction = !tmp->actions().isEmpty() ? tmp->actions().last() : 0; + + if (lastAction && lastAction->menu() && lastAction->menu()->inherits("QUnicodeControlCharacterMenu")) { + tmp->removeAction(lastAction); + lastAction->setParent(0); + QMenu* m = lastAction->menu(); + m->setParent(popup); + popup->addMenu(m); + + delete lastAction; + } + + delete tmp; + + return popup; +} + void LineEdit::addWidget(QWidget* widget, WidgetPosition position) { if (!widget) { @@ -200,6 +293,13 @@ void LineEdit::updateTextMargins() setTextMargins(left, top, right, bottom); } +void LineEdit::slotDelete() +{ + if (hasSelectedText()) { + del(); + } +} + void LineEdit::focusInEvent(QFocusEvent* event) { if (event->reason() == Qt::MouseFocusReason && qzSettings->selectAllOnClick) { diff --git a/src/lib/3rdparty/lineedit.h b/src/lib/3rdparty/lineedit.h index e4740dcd2..e9e8ac78b 100644 --- a/src/lib/3rdparty/lineedit.h +++ b/src/lib/3rdparty/lineedit.h @@ -100,6 +100,8 @@ public slots: void setLeftMargin(int margin); void updateTextMargins(); + void slotDelete(); + protected: void focusInEvent(QFocusEvent* event); void mousePressEvent(QMouseEvent* event); @@ -107,6 +109,8 @@ protected: void mouseDoubleClickEvent(QMouseEvent* event); bool event(QEvent* event); + QMenu* createContextMenu(QAction* pasteAndGoAction); + private: void init(); diff --git a/src/lib/navigation/locationbar.cpp b/src/lib/navigation/locationbar.cpp index b9eaddae0..f711b3cd1 100644 --- a/src/lib/navigation/locationbar.cpp +++ b/src/lib/navigation/locationbar.cpp @@ -18,16 +18,10 @@ #include "locationbar.h" #include "browserwindow.h" #include "tabbedwebview.h" -#include "rssmanager.h" #include "mainapplication.h" -#include "clickablelabel.h" #include "webpage.h" #include "tabwidget.h" #include "bookmarksicon.h" -#include "progressbar.h" -#include "statusbarmessage.h" -#include "toolbutton.h" -#include "searchenginesmanager.h" #include "siteicon.h" #include "goicon.h" #include "rssicon.h" @@ -37,16 +31,14 @@ #include "qzsettings.h" #include "colors.h" #include "autofillicon.h" +#include "searchenginesmanager.h" #include "completer/locationcompleter.h" -#include -#include #include -#include -#include -#include +#include #include #include +#include LocationBar::LocationBar(BrowserWindow* window) : LineEdit(window) @@ -367,56 +359,13 @@ void LocationBar::contextMenuEvent(QContextMenuEvent* event) connect(m_pasteAndGoAction, SIGNAL(triggered()), this, SLOT(pasteAndGo())); } - if (!m_clearAction) { - m_clearAction = new QAction(QIcon::fromTheme("edit-clear"), tr("Clear All"), this); - connect(m_clearAction, SIGNAL(triggered()), this, SLOT(clear())); - } - - QMenu* tempMenu = createStandardContextMenu(); - QMenu menu(this); - - int i = 0; - foreach (QAction* act, tempMenu->actions()) { - menu.addAction(act); - - switch (i) { - case 0: - act->setIcon(QIcon::fromTheme("edit-undo")); - break; - case 1: - act->setIcon(QIcon::fromTheme("edit-redo")); - break; - case 3: - act->setIcon(QIcon::fromTheme("edit-cut")); - break; - case 4: - act->setIcon(QIcon::fromTheme("edit-copy")); - break; - case 5: - act->setIcon(QIcon::fromTheme("edit-paste")); - menu.addAction(act); - menu.addAction(m_pasteAndGoAction); - break; - case 6: - act->setIcon(QIcon::fromTheme("edit-delete")); - menu.addAction(act); - menu.addAction(m_clearAction); - break; - case 8: - act->setIcon(QIcon::fromTheme("edit-select-all")); - break; - } - ++i; - } - - m_pasteAndGoAction->setEnabled(!QApplication::clipboard()->text().isEmpty()); + QMenu* menu = createContextMenu(m_pasteAndGoAction); + menu->setAttribute(Qt::WA_DeleteOnClose); // Prevent choosing first option with double rightclick QPoint pos = event->globalPos(); - QPoint p(pos.x(), pos.y() + 1); - menu.exec(p); - - tempMenu->deleteLater(); + pos.setY(pos.y() + 1); + menu->popup(pos); } void LocationBar::showEvent(QShowEvent* event) diff --git a/src/lib/navigation/locationbar.h b/src/lib/navigation/locationbar.h index e6749469c..34bee4295 100644 --- a/src/lib/navigation/locationbar.h +++ b/src/lib/navigation/locationbar.h @@ -18,15 +18,12 @@ #ifndef LOCATIONBAR_H #define LOCATIONBAR_H -#include - #include "qzcommon.h" #include "lineedit.h" class QStringListModel; class BrowserWindow; -class LineEdit; class LocationCompleter; class ClickableLabel; class TabbedWebView; @@ -50,9 +47,6 @@ public slots: void setText(const QString &text); void showUrl(const QUrl &url); -protected: - void paintEvent(QPaintEvent* event); - signals: void loadUrl(const QUrl &url); @@ -93,10 +87,10 @@ private: void keyPressEvent(QKeyEvent* event); void keyReleaseEvent(QKeyEvent* event); void dropEvent(QDropEvent* event); + void paintEvent(QPaintEvent* event); QUrl createUrl() const; QString convertUrlToText(const QUrl &url) const; - void refreshTextFormat(); LocationCompleter* m_completer; @@ -114,6 +108,7 @@ private: QAction* m_pasteAndGoAction; QAction* m_clearAction; + bool m_rssIconVisible; bool m_holdingAlt; int m_loadProgress; diff --git a/src/lib/navigation/websearchbar.cpp b/src/lib/navigation/websearchbar.cpp index 9d279d556..03a18739d 100644 --- a/src/lib/navigation/websearchbar.cpp +++ b/src/lib/navigation/websearchbar.cpp @@ -267,67 +267,24 @@ void WebSearchBar::contextMenuEvent(QContextMenuEvent* event) connect(m_pasteAndGoAction, SIGNAL(triggered()), this, SLOT(pasteAndGo())); } - if (!m_clearAction) { - m_clearAction = new QAction(QIcon::fromTheme("edit-clear"), tr("Clear All"), this); - connect(m_clearAction, SIGNAL(triggered()), this, SLOT(clear())); - } + QMenu* menu = createContextMenu(m_pasteAndGoAction); + menu->setAttribute(Qt::WA_DeleteOnClose); - QMenu* tempMenu = createStandardContextMenu(); - QMenu menu(this); - - int i = 0; - foreach (QAction* act, tempMenu->actions()) { - menu.addAction(act); - - switch (i) { - case 0: - act->setIcon(QIcon::fromTheme("edit-undo")); - break; - case 1: - act->setIcon(QIcon::fromTheme("edit-redo")); - break; - case 3: - act->setIcon(QIcon::fromTheme("edit-cut")); - break; - case 4: - act->setIcon(QIcon::fromTheme("edit-copy")); - break; - case 5: - act->setIcon(QIcon::fromTheme("edit-paste")); - menu.addAction(act); - menu.addAction(m_pasteAndGoAction); - break; - case 6: - act->setIcon(QIcon::fromTheme("edit-delete")); - menu.addAction(act); - menu.addAction(m_clearAction); - break; - case 8: - act->setIcon(QIcon::fromTheme("edit-select-all")); - break; - } - ++i; - } - - menu.addSeparator(); - QAction* act = menu.addAction(tr("Show suggestions")); + menu->addSeparator(); + QAction* act = menu->addAction(tr("Show suggestions")); act->setCheckable(true); act->setChecked(qzSettings->showSearchSuggestions); connect(act, SIGNAL(triggered(bool)), this, SLOT(enableSearchSuggestions(bool))); - QAction* instantSearch = menu.addAction(tr("Search when engine changed")); + QAction* instantSearch = menu->addAction(tr("Search when engine changed")); instantSearch->setCheckable(true); instantSearch->setChecked(qzSettings->searchOnEngineChange); connect(instantSearch, SIGNAL(triggered(bool)), this, SLOT(instantSearchChanged(bool))); - m_pasteAndGoAction->setEnabled(!QApplication::clipboard()->text().isEmpty()); - // Prevent choosing first option with double rightclick QPoint pos = event->globalPos(); - QPoint p(pos.x(), pos.y() + 1); - menu.exec(p); - - tempMenu->deleteLater(); + pos.setY(pos.y() + 1); + menu->popup(pos); } void WebSearchBar::focusOutEvent(QFocusEvent* e) diff --git a/translations/empty.ts b/translations/empty.ts index 262132413..49b5d44cf 100644 --- a/translations/empty.ts +++ b/translations/empty.ts @@ -368,7 +368,7 @@ Please install latest version of QupZilla. - + Database (plaintext) @@ -1067,99 +1067,99 @@ Please install latest version of QupZilla. BrowserWindow - + QupZilla - + Private Browsing Enabled - + IP Address of current page - + (Private Browsing) - + %1 - QupZilla - + &Menu Bar - + &Navigation Toolbar - + &Bookmarks Toolbar - + &Tabs on Top - + Other - + HTML files - + Image files - + Text files - + All files - + Open file... - + QupZilla %1 (%2) - + There are still %1 open tabs and your session won't be stored. Are you sure to close this window? - + Don't ask again - + There are still open tabs @@ -2424,24 +2424,62 @@ Are you sure to close this window? - LocationBar + LineEdit - - Enter URL address or search on %1 + + &Undo - - Paste And &Go + + &Redo - + + Cu&t + + + + + &Copy + + + + + &Paste + + + + + Delete + + + + Clear All - + + Select All + + + + + LocationBar + + + Enter URL address or search on %1 + + + + + Paste And &Go + + + + .co.uk Append domain name on ALT + Enter = Should be different for every country @@ -2463,22 +2501,22 @@ Are you sure to close this window? MainApplication - + QupZilla is not currently your default browser. Would you like to make it your default browser? - + Always perform this check when starting QupZilla. - + Default Browser - + QupZilla is a new, fast and secure open-source WWW browser. QupZilla is licensed under GPL version 3 or (at your option) any later version. It is based on WebKit core and Qt Framework. @@ -2486,252 +2524,252 @@ Are you sure to close this window? MainMenu - + &About QupZilla - + Pr&eferences - + Quit - + &File - + New Tab - + &New Window - + New &Private Window - + Open Location - + Open &File... - + Close Window - + &Save Page As... - + Save Page Screen - + Send Link... - + &Print... - + &Edit - + &Undo - + &Redo - + &Cut - + C&opy - + &Paste - + Select &All - + &Find - + &View - + Toolbars - + Sidebar - + Character &Encoding - + Sta&tus Bar - + &Stop - + &Reload - + Zoom &In - + Zoom &Out - + Reset - + &Caret Browsing - + &Page Source - + &FullScreen - + &Tools - + &Web Search - + Site &Info - + &Download Manager - + &Cookies Manager - + &AdBlock - + RSS &Reader - + Web In&spector - + Clear Recent &History - + &Help - + About &Qt - + Information about application - + Configuration Information - + Report &Issue - + Restore &Closed Tab @@ -2855,8 +2893,8 @@ Are you sure to close this window? - - + + Clear history @@ -3193,7 +3231,7 @@ Are you sure to close this window? - + %1 - QupZilla @@ -3273,7 +3311,7 @@ Are you sure to close this window? - + Note: You cannot delete active profile. @@ -3506,7 +3544,7 @@ Are you sure to close this window? - Don't quit upon closing last tab + Don't close window upon closing last tab @@ -4172,89 +4210,89 @@ Are you sure to close this window? - - + + Default - + Set as default - + OSD Notification - + Drag it on the screen to place it where you want. - + Choose download location... - + Choose stylesheet location... - + Deleted - + Choose executable location... - + Choose cache path... - + New Profile - + Enter the new profile's name: - - + + Error! - + This profile already exists! - + Cannot create profile directory! - + Confirmation - + Are you sure to permanently delete "%1" profile? This action cannot be undone! - + Select Color @@ -5165,7 +5203,7 @@ After adding or removing certificate paths, it is neccessary to restart QupZilla - + Add Search Engine @@ -5188,27 +5226,27 @@ After adding or removing certificate paths, it is neccessary to restart QupZilla SearchEnginesManager - + Search Engine Added - + Search Engine "%1" has been successfully added. - + Search Engine is not valid! - + Error - + Error while adding Search Engine <br><b>Error Message: </b> %1 @@ -5877,7 +5915,7 @@ After adding or removing certificate paths, it is neccessary to restart QupZilla - + Currently you have %n opened tab(s) @@ -5886,24 +5924,24 @@ After adding or removing certificate paths, it is neccessary to restart QupZilla - - - + + + New tab - + Restore All Closed Tabs - + Clear list - + Empty @@ -6055,173 +6093,173 @@ After adding or removing certificate paths, it is neccessary to restart QupZilla WebPage - + QupZilla cannot handle <b>%1:</b> links. The requested link is <ul><li>%2</li></ul>Do you want QupZilla to try open this link in system application? - + Remember my choice for this protocol - + External Protocol Request - + To show this page, QupZilla must resend request which do it again (like searching on making an shopping, which has been already done.) - + Confirm form resubmission - + Select files to upload... - + Server refused the connection - + Server closed the connection - + Server not found - + Connection timed out - + Untrusted connection - + Temporary network failure - + Proxy connection refused - + Proxy server not found - + Proxy connection timed out - + Proxy authentication required - + Content not found - + Unknown network error - + AdBlocked Content - + Blocked by <i>%1</i> - + Content Access Denied - + Error code %1 - + Failed loading page - + QupZilla can't load page. - + QupZilla can't load page from %1. - + Check the address for typing errors such as <b>ww.</b>example.com instead of <b>www.</b>example.com - + If you are unable to load any pages, check your computer's network connection. - + If your computer or network is protected by a firewall or proxy, make sure that QupZilla is permitted to access the Web. - + Try Again - + JavaScript alert - + Prevent this page from creating additional dialogs - + Choose file... - + Cannot read data from <b>%1</b>. Upload was cancelled! - + Cannot read file! @@ -6234,27 +6272,22 @@ After adding or removing certificate paths, it is neccessary to restart QupZilla - + Add %1 ... - + Paste And &Search - - Clear All - - - - + Show suggestions - + Search when engine changed