mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-11 01:22:10 +01:00
[Code] Small code cleanups
Mostly to silence a warnings from cppcheck [ci-skip]
This commit is contained in:
parent
325072881d
commit
72ab5de448
|
@ -158,16 +158,14 @@ QSize TabBar::tabSizeHint(int index, bool fast) const
|
|||
return QSize(-1, -1);
|
||||
}
|
||||
|
||||
static int PINNED_TAB_WIDTH = comboTabBarPixelMetric(ComboTabBar::PinnedTabWidth);
|
||||
static int MINIMUM_ACTIVE_TAB_WIDTH = comboTabBarPixelMetric(ComboTabBar::ActiveTabMinimumWidth);
|
||||
static int MAXIMUM_TAB_WIDTH = comboTabBarPixelMetric(ComboTabBar::NormalTabMaximumWidth);
|
||||
static int MINIMUM_TAB_WIDTH = comboTabBarPixelMetric(ComboTabBar::NormalTabMinimumWidth);
|
||||
const int pinnedTabWidth = comboTabBarPixelMetric(ComboTabBar::PinnedTabWidth);
|
||||
const int minTabWidth = comboTabBarPixelMetric(ComboTabBar::NormalTabMinimumWidth);
|
||||
|
||||
QSize size = ComboTabBar::tabSizeHint(index);
|
||||
|
||||
// The overflowed tabs have same size and we can use this fast method
|
||||
if (fast) {
|
||||
size.setWidth(index >= pinnedTabsCount() ? MINIMUM_TAB_WIDTH : PINNED_TAB_WIDTH);
|
||||
size.setWidth(index >= pinnedTabsCount() ? minTabWidth : pinnedTabWidth);
|
||||
return size;
|
||||
}
|
||||
|
||||
|
@ -175,7 +173,7 @@ QSize TabBar::tabSizeHint(int index, bool fast) const
|
|||
TabBar* tabBar = const_cast <TabBar*>(this);
|
||||
|
||||
if (webTab && webTab->isPinned()) {
|
||||
size.setWidth(PINNED_TAB_WIDTH);
|
||||
size.setWidth(pinnedTabWidth);
|
||||
}
|
||||
else {
|
||||
int availableWidth = mainTabBarWidth() - comboTabBarPixelMetric(ExtraReservedWidth);
|
||||
|
@ -185,25 +183,28 @@ QSize TabBar::tabSizeHint(int index, bool fast) const
|
|||
}
|
||||
|
||||
const int normalTabsCount = ComboTabBar::normalTabsCount();
|
||||
const int maxTabWidth = comboTabBarPixelMetric(ComboTabBar::NormalTabMaximumWidth);
|
||||
|
||||
if (availableWidth >= MAXIMUM_TAB_WIDTH * normalTabsCount) {
|
||||
m_normalTabWidth = MAXIMUM_TAB_WIDTH;
|
||||
if (availableWidth >= maxTabWidth * normalTabsCount) {
|
||||
m_normalTabWidth = maxTabWidth;
|
||||
size.setWidth(m_normalTabWidth);
|
||||
}
|
||||
else if (normalTabsCount > 0) {
|
||||
const int minActiveTabWidth = comboTabBarPixelMetric(ComboTabBar::ActiveTabMinimumWidth);
|
||||
|
||||
int maxWidthForTab = availableWidth / normalTabsCount;
|
||||
int realTabWidth = maxWidthForTab;
|
||||
bool adjustingActiveTab = false;
|
||||
|
||||
if (realTabWidth < MINIMUM_ACTIVE_TAB_WIDTH) {
|
||||
maxWidthForTab = normalTabsCount > 1 ? (availableWidth - MINIMUM_ACTIVE_TAB_WIDTH) / (normalTabsCount - 1) : 0;
|
||||
realTabWidth = MINIMUM_ACTIVE_TAB_WIDTH;
|
||||
if (realTabWidth < minActiveTabWidth) {
|
||||
maxWidthForTab = normalTabsCount > 1 ? (availableWidth - minActiveTabWidth) / (normalTabsCount - 1) : 0;
|
||||
realTabWidth = minActiveTabWidth;
|
||||
adjustingActiveTab = true;
|
||||
}
|
||||
|
||||
bool tryAdjusting = availableWidth >= MINIMUM_TAB_WIDTH * normalTabsCount;
|
||||
bool tryAdjusting = availableWidth >= minTabWidth * normalTabsCount;
|
||||
|
||||
if (m_showCloseOnInactive != 1 && tabsClosable() && availableWidth < (MINIMUM_TAB_WIDTH + 25) * normalTabsCount) {
|
||||
if (m_showCloseOnInactive != 1 && tabsClosable() && availableWidth < (minTabWidth + 25) * normalTabsCount) {
|
||||
// Hiding close buttons to save some space
|
||||
tabBar->setTabsClosable(false);
|
||||
tabBar->showCloseButton(currentIndex());
|
||||
|
@ -220,7 +221,7 @@ QSize TabBar::tabSizeHint(int index, bool fast) const
|
|||
// Fill any empty space (we've got from rounding) with active tab
|
||||
if (index == mainTabBarCurrentIndex()) {
|
||||
if (adjustingActiveTab) {
|
||||
m_activeTabWidth = (availableWidth - MINIMUM_ACTIVE_TAB_WIDTH
|
||||
m_activeTabWidth = (availableWidth - minActiveTabWidth
|
||||
- maxWidthForTab * (normalTabsCount - 1)) + realTabWidth;
|
||||
}
|
||||
else {
|
||||
|
@ -235,7 +236,7 @@ QSize TabBar::tabSizeHint(int index, bool fast) const
|
|||
}
|
||||
|
||||
// Restore close buttons according to preferences
|
||||
if (m_showCloseOnInactive != 2 && !tabsClosable() && availableWidth >= (MINIMUM_TAB_WIDTH + 25) * normalTabsCount) {
|
||||
if (m_showCloseOnInactive != 2 && !tabsClosable() && availableWidth >= (minTabWidth + 25) * normalTabsCount) {
|
||||
tabBar->setTabsClosable(true);
|
||||
|
||||
// Hide close buttons on pinned tabs
|
||||
|
|
|
@ -676,13 +676,6 @@ void WebView::bookmarkLink()
|
|||
}
|
||||
}
|
||||
|
||||
void WebView::showSourceOfSelection()
|
||||
{
|
||||
#if QTWEBKIT_FROM_2_2
|
||||
showSource(page()->mainFrame(), selectedHtml());
|
||||
#endif
|
||||
}
|
||||
|
||||
void WebView::openUrlInSelectedTab()
|
||||
{
|
||||
if (QAction* action = qobject_cast<QAction*>(sender())) {
|
||||
|
@ -989,14 +982,6 @@ void WebView::createContextMenu(QMenu* menu, const QWebHitTestResult &hitTest, c
|
|||
|
||||
menu->addSeparator();
|
||||
mApp->plugins()->populateWebViewMenu(menu, this, hitTest);
|
||||
|
||||
#if QTWEBKIT_FROM_2_2
|
||||
// still bugged? in 4.8 RC (it shows selection of webkit's internal source, not html from page)
|
||||
// it may or may not be bug, but this implementation is useless for us
|
||||
//
|
||||
// if (!selectedHtml().isEmpty())
|
||||
// menu->addAction(tr("Show source of selection"), this, SLOT(showSourceOfSelection()));
|
||||
#endif
|
||||
}
|
||||
|
||||
void WebView::createPageContextMenu(QMenu* menu, const QPoint &pos)
|
||||
|
@ -1011,63 +996,62 @@ void WebView::createPageContextMenu(QMenu* menu, const QPoint &pos)
|
|||
action->setIcon(IconProvider::standardIcon(QStyle::SP_ArrowForward));
|
||||
action->setEnabled(history()->canGoForward());
|
||||
|
||||
if (url() != QUrl("qupzilla:speeddial")) {
|
||||
|
||||
menu->addAction(m_actionReload);
|
||||
menu->addAction(m_actionStop);
|
||||
menu->addSeparator();
|
||||
|
||||
if (frameAtPos && page()->mainFrame() != frameAtPos) {
|
||||
m_clickedFrame = frameAtPos;
|
||||
Menu* frameMenu = new Menu(tr("This frame"));
|
||||
frameMenu->setCloseOnMiddleClick(true);
|
||||
frameMenu->addAction(tr("Show &only this frame"), this, SLOT(loadClickedFrame()));
|
||||
Action* act = new Action(IconProvider::newTabIcon(), tr("Show this frame in new &tab"));
|
||||
connect(act, SIGNAL(triggered()), this, SLOT(loadClickedFrameInNewTab()));
|
||||
connect(act, SIGNAL(ctrlTriggered()), this, SLOT(loadClickedFrameInBgTab()));
|
||||
frameMenu->addAction(act);
|
||||
frameMenu->addSeparator();
|
||||
frameMenu->addAction(QIcon::fromTheme(QSL("view-refresh")), tr("&Reload"), this, SLOT(reloadClickedFrame()));
|
||||
frameMenu->addAction(QIcon::fromTheme("document-print"), tr("Print frame"), this, SLOT(printClickedFrame()));
|
||||
frameMenu->addSeparator();
|
||||
frameMenu->addAction(QIcon::fromTheme("zoom-in"), tr("Zoom &in"), this, SLOT(clickedFrameZoomIn()));
|
||||
frameMenu->addAction(QIcon::fromTheme("zoom-out"), tr("&Zoom out"), this, SLOT(clickedFrameZoomOut()));
|
||||
frameMenu->addAction(QIcon::fromTheme("zoom-original"), tr("Reset"), this, SLOT(clickedFrameZoomReset()));
|
||||
frameMenu->addSeparator();
|
||||
frameMenu->addAction(QIcon::fromTheme("text-html"), tr("Show so&urce of frame"), this, SLOT(showClickedFrameSource()));
|
||||
|
||||
menu->addMenu(frameMenu);
|
||||
}
|
||||
|
||||
menu->addSeparator();
|
||||
menu->addAction(QIcon::fromTheme("bookmark-new"), tr("Book&mark page"), this, SLOT(bookmarkLink()));
|
||||
menu->addAction(QIcon::fromTheme("document-save"), tr("&Save page as..."), this, SLOT(savePageAs()));
|
||||
menu->addAction(QIcon::fromTheme("edit-copy"), tr("&Copy page link"), this, SLOT(copyLinkToClipboard()))->setData(url());
|
||||
menu->addAction(QIcon::fromTheme("mail-message-new"), tr("Send page link..."), this, SLOT(sendPageByMail()));
|
||||
menu->addAction(QIcon::fromTheme("document-print"), tr("&Print page"), this, SLOT(printPage()));
|
||||
menu->addSeparator();
|
||||
menu->addAction(QIcon::fromTheme("edit-select-all"), tr("Select &all"), this, SLOT(editSelectAll()));
|
||||
menu->addSeparator();
|
||||
|
||||
if (url().scheme() == QLatin1String("http") || url().scheme() == QLatin1String("https")) {
|
||||
const QUrl w3url = QUrl::fromEncoded("http://validator.w3.org/check?uri=" + QUrl::toPercentEncoding(url().toEncoded()));
|
||||
menu->addAction(QIcon(":icons/sites/w3.png"), tr("Validate page"), this, SLOT(openUrlInSelectedTab()))->setData(w3url);
|
||||
|
||||
QByteArray langCode = mApp->currentLanguage().left(2).toUtf8();
|
||||
const QUrl gturl = QUrl::fromEncoded("http://translate.google.com/translate?sl=auto&tl=" + langCode + "&u=" + QUrl::toPercentEncoding(url().toEncoded()));
|
||||
menu->addAction(QIcon(":icons/sites/translate.png"), tr("Translate page"), this, SLOT(openUrlInSelectedTab()))->setData(gturl);
|
||||
}
|
||||
|
||||
menu->addSeparator();
|
||||
menu->addAction(QIcon::fromTheme("text-html"), tr("Show so&urce code"), this, SLOT(showSource()));
|
||||
menu->addAction(QIcon::fromTheme("dialog-information"), tr("Show info ab&out site"), this, SLOT(showSiteInfo()));
|
||||
}
|
||||
|
||||
else {
|
||||
// Special menu for Speed Dial page
|
||||
if (url().toString() == QL1S("qupzilla:speeddial")) {
|
||||
menu->addSeparator();
|
||||
menu->addAction(QIcon::fromTheme("list-add"), tr("&Add New Page"), this, SLOT(addSpeedDial()));
|
||||
menu->addAction(IconProvider::settingsIcon(), tr("&Configure Speed Dial"), this, SLOT(configureSpeedDial()));
|
||||
return;
|
||||
}
|
||||
|
||||
menu->addAction(m_actionReload);
|
||||
menu->addAction(m_actionStop);
|
||||
menu->addSeparator();
|
||||
|
||||
if (frameAtPos && page()->mainFrame() != frameAtPos) {
|
||||
m_clickedFrame = frameAtPos;
|
||||
Menu* frameMenu = new Menu(tr("This frame"));
|
||||
frameMenu->setCloseOnMiddleClick(true);
|
||||
frameMenu->addAction(tr("Show &only this frame"), this, SLOT(loadClickedFrame()));
|
||||
Action* act = new Action(IconProvider::newTabIcon(), tr("Show this frame in new &tab"));
|
||||
connect(act, SIGNAL(triggered()), this, SLOT(loadClickedFrameInNewTab()));
|
||||
connect(act, SIGNAL(ctrlTriggered()), this, SLOT(loadClickedFrameInBgTab()));
|
||||
frameMenu->addAction(act);
|
||||
frameMenu->addSeparator();
|
||||
frameMenu->addAction(QIcon::fromTheme(QSL("view-refresh")), tr("&Reload"), this, SLOT(reloadClickedFrame()));
|
||||
frameMenu->addAction(QIcon::fromTheme("document-print"), tr("Print frame"), this, SLOT(printClickedFrame()));
|
||||
frameMenu->addSeparator();
|
||||
frameMenu->addAction(QIcon::fromTheme("zoom-in"), tr("Zoom &in"), this, SLOT(clickedFrameZoomIn()));
|
||||
frameMenu->addAction(QIcon::fromTheme("zoom-out"), tr("&Zoom out"), this, SLOT(clickedFrameZoomOut()));
|
||||
frameMenu->addAction(QIcon::fromTheme("zoom-original"), tr("Reset"), this, SLOT(clickedFrameZoomReset()));
|
||||
frameMenu->addSeparator();
|
||||
frameMenu->addAction(QIcon::fromTheme("text-html"), tr("Show so&urce of frame"), this, SLOT(showClickedFrameSource()));
|
||||
|
||||
menu->addMenu(frameMenu);
|
||||
}
|
||||
|
||||
menu->addSeparator();
|
||||
menu->addAction(QIcon::fromTheme("bookmark-new"), tr("Book&mark page"), this, SLOT(bookmarkLink()));
|
||||
menu->addAction(QIcon::fromTheme("document-save"), tr("&Save page as..."), this, SLOT(savePageAs()));
|
||||
menu->addAction(QIcon::fromTheme("edit-copy"), tr("&Copy page link"), this, SLOT(copyLinkToClipboard()))->setData(url());
|
||||
menu->addAction(QIcon::fromTheme("mail-message-new"), tr("Send page link..."), this, SLOT(sendPageByMail()));
|
||||
menu->addAction(QIcon::fromTheme("document-print"), tr("&Print page"), this, SLOT(printPage()));
|
||||
menu->addSeparator();
|
||||
menu->addAction(QIcon::fromTheme("edit-select-all"), tr("Select &all"), this, SLOT(editSelectAll()));
|
||||
menu->addSeparator();
|
||||
|
||||
if (url().scheme() == QLatin1String("http") || url().scheme() == QLatin1String("https")) {
|
||||
const QUrl w3url = QUrl::fromEncoded("http://validator.w3.org/check?uri=" + QUrl::toPercentEncoding(url().toEncoded()));
|
||||
menu->addAction(QIcon(":icons/sites/w3.png"), tr("Validate page"), this, SLOT(openUrlInSelectedTab()))->setData(w3url);
|
||||
|
||||
QByteArray langCode = mApp->currentLanguage().left(2).toUtf8();
|
||||
const QUrl gturl = QUrl::fromEncoded("http://translate.google.com/translate?sl=auto&tl=" + langCode + "&u=" + QUrl::toPercentEncoding(url().toEncoded()));
|
||||
menu->addAction(QIcon(":icons/sites/translate.png"), tr("Translate page"), this, SLOT(openUrlInSelectedTab()))->setData(gturl);
|
||||
}
|
||||
|
||||
menu->addSeparator();
|
||||
menu->addAction(QIcon::fromTheme("text-html"), tr("Show so&urce code"), this, SLOT(showSource()));
|
||||
menu->addAction(QIcon::fromTheme("dialog-information"), tr("Show info ab&out site"), this, SLOT(showSiteInfo()));
|
||||
}
|
||||
|
||||
void WebView::createLinkContextMenu(QMenu* menu, const QWebHitTestResult &hitTest)
|
||||
|
|
|
@ -129,7 +129,6 @@ protected slots:
|
|||
void searchSelectedText();
|
||||
void searchSelectedTextInBackgroundTab();
|
||||
void bookmarkLink();
|
||||
void showSourceOfSelection();
|
||||
void openUrlInSelectedTab();
|
||||
void openUrlInBackgroundTab();
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user