Sat, 14 Jun 2014 09:48:55 +0300
- added close buttons to tabs
src/mainWindow.cc | file | annotate | diff | comparison | revisions | |
src/mainWindow.h | file | annotate | diff | comparison | revisions |
--- a/src/mainWindow.cc Sat Jun 14 09:34:57 2014 +0300 +++ b/src/mainWindow.cc Sat Jun 14 09:48:55 2014 +0300 @@ -75,6 +75,7 @@ m_updatingTabs = false; m_renderer = new GLRenderer (this); m_tabs = new QTabBar; + m_tabs->setTabsClosable (true); ui->verticalLayout->insertWidget (0, m_tabs); // Stuff the renderer into its frame @@ -84,6 +85,7 @@ connect (ui->objectList, SIGNAL (itemSelectionChanged()), this, SLOT (slot_selectionChanged())); connect (ui->objectList, SIGNAL (itemDoubleClicked (QListWidgetItem*)), this, SLOT (slot_editObject (QListWidgetItem*))); connect (m_tabs, SIGNAL (currentChanged(int)), this, SLOT (changeCurrentFile())); + connect (m_tabs, SIGNAL (tabCloseRequested (int)), this, SLOT (closeTab (int))); if (getActivePrimitiveScanner() != null) connect (getActivePrimitiveScanner(), SIGNAL (workDone()), this, SLOT (updatePrimitives())); @@ -923,6 +925,7 @@ // If the document.has unsaved changes, draw a little icon next to it to mark that. m_tabs->setTabIcon (doc->tabIndex(), doc->hasUnsavedChanges() ? getIcon ("file-save") : QIcon()); + m_tabs->setTabData (doc->tabIndex(), doc->name()); m_updatingTabs = oldUpdatingTabs; } @@ -996,6 +999,18 @@ // ============================================================================= // +void MainWindow::closeTab (int tabindex) +{ + LDDocumentPtr doc = findDocument (m_tabs->tabData (tabindex).toString()); + + if (doc == null) + return; + + doc->dismiss(); +} + +// ============================================================================= +// QImage imageFromScreencap (uchar* data, int w, int h) { // GL and Qt formats have R and B swapped. Also, GL flips Y - correct it as well.