mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-13 10:32:11 +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,7 +996,13 @@ void WebView::createPageContextMenu(QMenu* menu, const QPoint &pos)
|
|||
action->setIcon(IconProvider::standardIcon(QStyle::SP_ArrowForward));
|
||||
action->setEnabled(history()->canGoForward());
|
||||
|
||||
if (url() != QUrl("qupzilla:speeddial")) {
|
||||
// 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);
|
||||
|
@ -1061,13 +1052,6 @@ void WebView::createPageContextMenu(QMenu* menu, const QPoint &pos)
|
|||
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 {
|
||||
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()));
|
||||
}
|
||||
}
|
||||
|
||||
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