1
mirror of https://invent.kde.org/network/falkon.git synced 2024-09-21 17:52:10 +02:00

[Code] Small changes in showing context menu in url and searchbar

- may fix occasional crashes in Ubuntu
This commit is contained in:
nowrep 2012-10-11 19:57:12 +02:00
parent 288d2caafe
commit ba84fa2d7a
4 changed files with 14 additions and 21 deletions

View File

@ -49,7 +49,6 @@ LocationBar::LocationBar(QupZilla* mainClass)
: LineEdit(mainClass) : LineEdit(mainClass)
, p_QupZilla(mainClass) , p_QupZilla(mainClass)
, m_webView(0) , m_webView(0)
, m_menu(new QMenu(this))
, m_pasteAndGoAction(0) , m_pasteAndGoAction(0)
, m_clearAction(0) , m_clearAction(0)
, m_holdingAlt(false) , m_holdingAlt(false)
@ -324,13 +323,11 @@ void LocationBar::contextMenuEvent(QContextMenuEvent* event)
} }
QMenu* tempMenu = createStandardContextMenu(); QMenu* tempMenu = createStandardContextMenu();
m_menu->clear(); QMenu menu(this);
int i = 0; int i = 0;
foreach(QAction * act, tempMenu->actions()) { foreach(QAction * act, tempMenu->actions()) {
act->setParent(m_menu); menu.addAction(act);
tempMenu->removeAction(act);
m_menu->addAction(act);
switch (i) { switch (i) {
case 0: case 0:
@ -347,13 +344,13 @@ void LocationBar::contextMenuEvent(QContextMenuEvent* event)
break; break;
case 5: case 5:
act->setIcon(QIcon::fromTheme("edit-paste")); act->setIcon(QIcon::fromTheme("edit-paste"));
m_menu->addAction(act); menu.addAction(act);
m_menu->addAction(m_pasteAndGoAction); menu.addAction(m_pasteAndGoAction);
break; break;
case 6: case 6:
act->setIcon(QIcon::fromTheme("edit-delete")); act->setIcon(QIcon::fromTheme("edit-delete"));
m_menu->addAction(act); menu.addAction(act);
m_menu->addAction(m_clearAction); menu.addAction(m_clearAction);
break; break;
case 8: case 8:
act->setIcon(QIcon::fromTheme("edit-select-all")); act->setIcon(QIcon::fromTheme("edit-select-all"));
@ -362,14 +359,14 @@ void LocationBar::contextMenuEvent(QContextMenuEvent* event)
++i; ++i;
} }
tempMenu->deleteLater();
m_pasteAndGoAction->setEnabled(!QApplication::clipboard()->text().isEmpty()); m_pasteAndGoAction->setEnabled(!QApplication::clipboard()->text().isEmpty());
//Prevent choosing first option with double rightclick // Prevent choosing first option with double rightclick
QPoint pos = event->globalPos(); QPoint pos = event->globalPos();
QPoint p(pos.x(), pos.y() + 1); QPoint p(pos.x(), pos.y() + 1);
m_menu->popup(p); menu.exec(p);
tempMenu->deleteLater();
} }
void LocationBar::focusInEvent(QFocusEvent* event) void LocationBar::focusInEvent(QFocusEvent* event)
@ -595,7 +592,7 @@ void LocationBar::paintEvent(QPaintEvent* event)
{ {
if (hasFocus() || text().isEmpty() || m_forceLineEditPaintEvent) { if (hasFocus() || text().isEmpty() || m_forceLineEditPaintEvent) {
LineEdit::paintEvent(event); LineEdit::paintEvent(event);
if(m_forceLineEditPaintEvent) { if (m_forceLineEditPaintEvent) {
m_forceLineEditPaintEvent = false; m_forceLineEditPaintEvent = false;
update(); update();
} }

View File

@ -115,7 +115,6 @@ private:
QupZilla* p_QupZilla; QupZilla* p_QupZilla;
TabbedWebView* m_webView; TabbedWebView* m_webView;
QMenu* m_menu;
QAction* m_pasteAndGoAction; QAction* m_pasteAndGoAction;
QAction* m_clearAction; QAction* m_clearAction;

View File

@ -303,8 +303,6 @@ void WebSearchBar::contextMenuEvent(QContextMenuEvent* event)
++i; ++i;
} }
tempMenu->deleteLater();
menu.addSeparator(); menu.addSeparator();
QAction* act = menu.addAction(tr("Show suggestions")); QAction* act = menu.addAction(tr("Show suggestions"));
act->setCheckable(true); act->setCheckable(true);
@ -318,10 +316,12 @@ void WebSearchBar::contextMenuEvent(QContextMenuEvent* event)
m_pasteAndGoAction->setEnabled(!QApplication::clipboard()->text().isEmpty()); m_pasteAndGoAction->setEnabled(!QApplication::clipboard()->text().isEmpty());
//Prevent choosing first option with double rightclick // Prevent choosing first option with double rightclick
QPoint pos = event->globalPos(); QPoint pos = event->globalPos();
QPoint p(pos.x(), pos.y() + 1); QPoint p(pos.x(), pos.y() + 1);
menu.exec(p); menu.exec(p);
tempMenu->deleteLater();
} }
void WebSearchBar::focusOutEvent(QFocusEvent* e) void WebSearchBar::focusOutEvent(QFocusEvent* e)

View File

@ -70,9 +70,6 @@ $translating_moreinfo = "Więcej informacji o tłumaczeniu <a href='https://gith
$creators = "Kto tworzy QupZillę?"; $creators = "Kto tworzy QupZillę?";
$creators_text = "Właścicielem projektu i głównym programistą jest student z Republiki Czeskiej, <b>David Rosca</b> (nowrep).<br/> $creators_text = "Właścicielem projektu i głównym programistą jest student z Republiki Czeskiej, <b>David Rosca</b> (nowrep).<br/>
Poza kodowaniem, użytkownicy współtworzą tłumaczenia na wiele języków i wspierają QupZillę. Lista osób współtworzących dostępna jest <a href='https://github.com/QupZilla/qupzilla/blob/master/AUTHORS'>tutaj</a> [github].<br/><br/>Możesz także dołączyć do kanału IRC <b>#qupzilla</b> w sieci irc.freenode.net aby porozmawiać z osobami zaangażowanymi w rozwój QupZilli."; Poza kodowaniem, użytkownicy współtworzą tłumaczenia na wiele języków i wspierają QupZillę. Lista osób współtworzących dostępna jest <a href='https://github.com/QupZilla/qupzilla/blob/master/AUTHORS'>tutaj</a> [github].<br/><br/>Możesz także dołączyć do kanału IRC <b>#qupzilla</b> w sieci irc.freenode.net aby porozmawiać z osobami zaangażowanymi w rozwój QupZilli.";
// You can delete these (commented) lines after you translate $creators and $creators_text
//$contributors = "Contributors";
//$contributors_text = "Full list of contributors can be found on <a href='https://github.com/nowrep/QupZilla/blob/master/AUTHORS'>github</a>.<br/>You can also join IRC channel #qupzilla at irc.freenode.net.";
$share_with_friends = "Podziel się ze znajomymi!"; $share_with_friends = "Podziel się ze znajomymi!";
$share_with_friends_text = "Lubisz QupZillę? W takim razie podziel się nią ze swoimi znajomymi!"; $share_with_friends_text = "Lubisz QupZillę? W takim razie podziel się nią ze swoimi znajomymi!";
?> ?>