mirror of
https://github.com/martinrotter/rssguard.git
synced 2025-01-01 02:48:05 +01:00
Functional menu for web browser.
This commit is contained in:
parent
dbbedc7b74
commit
075aaf34d8
@ -176,6 +176,10 @@ void FormMain::createConnections() {
|
|||||||
this, SLOT(loadWebBrowserMenu(int)));
|
this, SLOT(loadWebBrowserMenu(int)));
|
||||||
connect(m_ui->m_actionCloseCurrentTab, SIGNAL(triggered()),
|
connect(m_ui->m_actionCloseCurrentTab, SIGNAL(triggered()),
|
||||||
m_ui->m_tabWidget, SLOT(closeCurrentTab()));
|
m_ui->m_tabWidget, SLOT(closeCurrentTab()));
|
||||||
|
connect(m_ui->m_actionAddBrowser, SIGNAL(triggered()),
|
||||||
|
m_ui->m_tabWidget, SLOT(addEmptyBrowser()));
|
||||||
|
connect(m_ui->m_actionCloseAllTabs, SIGNAL(triggered()),
|
||||||
|
m_ui->m_tabWidget, SLOT(closeAllTabsExceptCurrent()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FormMain::loadWebBrowserMenu(int index) {
|
void FormMain::loadWebBrowserMenu(int index) {
|
||||||
|
@ -76,14 +76,50 @@ void TabWidget::setupIcons() {
|
|||||||
m_cornerButton->setIcon(IconThemeFactory::getInstance()->fromTheme("list-add"));
|
m_cornerButton->setIcon(IconThemeFactory::getInstance()->fromTheme("list-add"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabWidget::closeTab(int index) {
|
bool TabWidget::closeTab(int index) {
|
||||||
if (tabBar()->tabType(index) == TabBar::Closable) {
|
if (tabBar()->tabType(index) == TabBar::Closable) {
|
||||||
removeTab(index);
|
removeTab(index);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabWidget::closeCurrentTab() {
|
bool TabWidget::closeCurrentTab() {
|
||||||
closeTab(currentIndex());
|
return closeTab(currentIndex());
|
||||||
|
}
|
||||||
|
|
||||||
|
void TabWidget::closeAllTabsExceptCurrent() {
|
||||||
|
// Close tabs after active tab.
|
||||||
|
int index_of_active = currentIndex();
|
||||||
|
int total_count = count();
|
||||||
|
int iterative_index = 0;
|
||||||
|
|
||||||
|
while (total_count-- > 0) {
|
||||||
|
if (iterative_index < index_of_active) {
|
||||||
|
// Deleting tab on the left from the active one.
|
||||||
|
if (closeTab(iterative_index)) {
|
||||||
|
// We successfully deleted that LEFT tab.
|
||||||
|
index_of_active--;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// We reached "non-closable" tab, go forward.
|
||||||
|
iterative_index++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (iterative_index > index_of_active) {
|
||||||
|
// Deleting tab on the right from the active one.
|
||||||
|
if (!closeTab(iterative_index)) {
|
||||||
|
// We reached "non-closable" tab, go forward.
|
||||||
|
iterative_index++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// We iterate through active tab now, no deleting;
|
||||||
|
iterative_index++;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabWidget::removeTab(int index) {
|
void TabWidget::removeTab(int index) {
|
||||||
|
@ -59,8 +59,11 @@ class TabWidget : public QTabWidget {
|
|||||||
void changeIcon(int index, const QIcon &new_icon);
|
void changeIcon(int index, const QIcon &new_icon);
|
||||||
|
|
||||||
// Closes tab with given index and deletes contained widget.
|
// Closes tab with given index and deletes contained widget.
|
||||||
void closeTab(int index);
|
bool closeTab(int index);
|
||||||
void closeCurrentTab();
|
bool closeCurrentTab();
|
||||||
|
|
||||||
|
// Closes all "closable" tabs except the active tab.
|
||||||
|
void closeAllTabsExceptCurrent();
|
||||||
|
|
||||||
// Adds new WebBrowser tab to global TabWidget.
|
// Adds new WebBrowser tab to global TabWidget.
|
||||||
int addEmptyBrowser();
|
int addEmptyBrowser();
|
||||||
|
Loading…
Reference in New Issue
Block a user