add close current tab action
This commit is contained in:
		
							parent
							
								
									cf48e1c5ed
								
							
						
					
					
						commit
						4a0b4d8c97
					
				
					 6 changed files with 23 additions and 1 deletions
				
			
		|  | @ -26,7 +26,7 @@ | |||
|   <url type="donation">https://github.com/sponsors/martinrotter</url> | ||||
|   <content_rating type="oars-1.1" /> | ||||
|   <releases> | ||||
|     <release version="4.0.4" date="2021-11-05"/> | ||||
|     <release version="4.0.4" date="2021-11-09"/> | ||||
|   </releases> | ||||
|   <content_rating type="oars-1.0"> | ||||
|     <content_attribute id="violence-cartoon">none</content_attribute> | ||||
|  |  | |||
|  | @ -84,6 +84,7 @@ FormMain::FormMain(QWidget* parent, Qt::WindowFlags f) | |||
|   createConnections(); | ||||
|   updateMessageButtonsAvailability(); | ||||
|   updateFeedButtonsAvailability(); | ||||
|   updateTabsButtonsAvailability(tabWidget()->currentIndex()); | ||||
| 
 | ||||
|   // Setup some appearance of the window.
 | ||||
|   setupIcons(); | ||||
|  | @ -198,6 +199,7 @@ QList<QAction*> FormMain::allActions() const { | |||
|   actions << m_ui->m_actionTabNewWebBrowser; | ||||
| #endif | ||||
| 
 | ||||
|   actions << m_ui->m_actionTabsCloseCurrent; | ||||
|   actions << m_ui->m_actionTabsCloseAll; | ||||
|   actions << m_ui->m_actionTabsCloseAllExceptCurrent; | ||||
| 
 | ||||
|  | @ -392,6 +394,11 @@ void FormMain::updateAccountsMenu() { | |||
|   m_ui->m_menuAccounts->addAction(m_ui->m_actionServiceDelete); | ||||
| } | ||||
| 
 | ||||
| void FormMain::updateTabsButtonsAvailability(int index) { | ||||
|   m_ui->m_actionTabsCloseCurrent->setEnabled(tabWidget()->tabBar()->tabType(index) == TabBar::TabType::Closable || | ||||
|                                              tabWidget()->tabBar()->tabType(index) == TabBar::TabType::DownloadManager); | ||||
| } | ||||
| 
 | ||||
| void FormMain::onFeedUpdatesFinished(const FeedDownloadResults& results) { | ||||
|   Q_UNUSED(results) | ||||
| 
 | ||||
|  | @ -568,6 +575,7 @@ void FormMain::setupIcons() { | |||
|   // Tabs & web browser.
 | ||||
|   m_ui->m_actionTabNewWebBrowser->setIcon(icon_theme_factory->fromTheme(QSL("tab-new"))); | ||||
|   m_ui->m_actionTabsCloseAll->setIcon(icon_theme_factory->fromTheme(QSL("window-close"))); | ||||
|   m_ui->m_actionTabsCloseCurrent->setIcon(icon_theme_factory->fromTheme(QSL("window-close"))); | ||||
|   m_ui->m_actionTabsCloseAllExceptCurrent->setIcon(icon_theme_factory->fromTheme(QSL("window-close"))); | ||||
|   m_ui->m_actionTabsNext->setIcon(icon_theme_factory->fromTheme(QSL("go-next"))); | ||||
|   m_ui->m_actionTabsPrevious->setIcon(icon_theme_factory->fromTheme(QSL("go-previous"))); | ||||
|  | @ -715,6 +723,7 @@ void FormMain::createConnections() { | |||
|   connect(m_ui->m_actionTabsPrevious, &QAction::triggered, m_ui->m_tabWidget, &TabWidget::gotoPreviousTab); | ||||
|   connect(m_ui->m_actionTabsCloseAllExceptCurrent, &QAction::triggered, m_ui->m_tabWidget, &TabWidget::closeAllTabsExceptCurrent); | ||||
|   connect(m_ui->m_actionTabsCloseAll, &QAction::triggered, m_ui->m_tabWidget, &TabWidget::closeAllTabs); | ||||
|   connect(m_ui->m_actionTabsCloseCurrent, &QAction::triggered, m_ui->m_tabWidget, &TabWidget::closeCurrentTab); | ||||
|   connect(m_ui->m_actionTabNewWebBrowser, &QAction::triggered, m_ui->m_tabWidget, &TabWidget::addEmptyBrowser); | ||||
|   connect(tabWidget()->feedMessageViewer()->feedsView(), &FeedsView::itemSelected, this, &FormMain::updateFeedButtonsAvailability); | ||||
|   connect(qApp->feedUpdateLock(), &Mutex::locked, this, &FormMain::updateFeedButtonsAvailability); | ||||
|  | @ -723,6 +732,7 @@ void FormMain::createConnections() { | |||
|           this, &FormMain::updateMessageButtonsAvailability); | ||||
|   connect(tabWidget()->feedMessageViewer()->messagesView(), &MessagesView::currentMessageChanged, | ||||
|           this, &FormMain::updateMessageButtonsAvailability); | ||||
|   connect(tabWidget(), &TabWidget::currentChanged, this, &FormMain::updateTabsButtonsAvailability); | ||||
|   connect(qApp->feedReader(), &FeedReader::feedUpdatesStarted, this, &FormMain::onFeedUpdatesStarted); | ||||
|   connect(qApp->feedReader(), &FeedReader::feedUpdatesProgress, this, &FormMain::onFeedUpdatesProgress); | ||||
|   connect(qApp->feedReader(), &FeedReader::feedUpdatesFinished, this, &FormMain::onFeedUpdatesFinished); | ||||
|  |  | |||
|  | @ -49,6 +49,7 @@ class RSSGUARD_DLLSPEC FormMain : public QMainWindow { | |||
|     void updateRecycleBinMenu(); | ||||
|     void updateAccountsMenu(); | ||||
| 
 | ||||
|     void updateTabsButtonsAvailability(int index); | ||||
|     void updateMessageButtonsAvailability(); | ||||
|     void updateFeedButtonsAvailability(); | ||||
| 
 | ||||
|  |  | |||
|  | @ -177,6 +177,7 @@ | |||
|     </property> | ||||
|     <addaction name="m_actionTabNewWebBrowser"/> | ||||
|     <addaction name="separator"/> | ||||
|     <addaction name="m_actionTabsCloseCurrent"/> | ||||
|     <addaction name="m_actionTabsCloseAll"/> | ||||
|     <addaction name="m_actionTabsCloseAllExceptCurrent"/> | ||||
|     <addaction name="separator"/> | ||||
|  | @ -835,6 +836,11 @@ | |||
|     <string>Expand/collapse selected item &recursively</string> | ||||
|    </property> | ||||
|   </action> | ||||
|   <action name="m_actionTabsCloseCurrent"> | ||||
|    <property name="text"> | ||||
|     <string>Close &current tab</string> | ||||
|    </property> | ||||
|   </action> | ||||
|  </widget> | ||||
|  <customwidgets> | ||||
|   <customwidget> | ||||
|  |  | |||
|  | @ -183,6 +183,10 @@ void TabWidget::closeAllTabs() { | |||
|   } | ||||
| } | ||||
| 
 | ||||
| void TabWidget::closeCurrentTab() { | ||||
|   closeTab(currentIndex()); | ||||
| } | ||||
| 
 | ||||
| int TabWidget::addNewspaperView(RootItem* root, const QList<Message>& messages) { | ||||
|   int msg_height = height() - tabBar()->height() - 50; | ||||
|   NewspaperPreviewer* prev = new NewspaperPreviewer(msg_height, root, messages, this); | ||||
|  |  | |||
|  | @ -63,6 +63,7 @@ class TabWidget : public QTabWidget { | |||
|     bool closeTab(int index); | ||||
|     void closeAllTabsExceptCurrent(); | ||||
|     void closeAllTabs(); | ||||
|     void closeCurrentTab(); | ||||
| 
 | ||||
|     // Displays download manager.
 | ||||
|     void showDownloadManager(); | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue