# HG changeset patch # User Santeri Piippo # Date 1402728535 -10800 # Node ID 88d4973cfe1a41db408b364f7692944fb14f0196 # Parent 4bd154b5d0bd7fe45dd8326f511e6f9a895b7415 - added close buttons to tabs diff -r 4bd154b5d0bd -r 88d4973cfe1a src/mainWindow.cc --- 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. diff -r 4bd154b5d0bd -r 88d4973cfe1a src/mainWindow.h --- a/src/mainWindow.h Sat Jun 14 09:34:57 2014 +0300 +++ b/src/mainWindow.h Sat Jun 14 09:48:55 2014 +0300 @@ -189,6 +189,7 @@ public slots: void updatePrimitives(); void changeCurrentFile(); + void closeTab (int tabindex); void slot_action(); void slot_actionNew(); void slot_actionNewFile();