diff options
| author | Tannin <devnull@localhost> | 2014-02-04 19:55:27 +0100 |
|---|---|---|
| committer | Tannin <devnull@localhost> | 2014-02-04 19:55:27 +0100 |
| commit | 76fbe6effef7c2e787c1801741d4eb0a156128ce (patch) | |
| tree | ef671b8073e1208a00b5b50f0afa493375daaede /src/modinfodialog.cpp | |
| parent | 38ee6ccf0a822bf20d548bbb89dbe3059ee336bb (diff) | |
- tabs in the mod info dialog can now be moved around by the user
Diffstat (limited to 'src/modinfodialog.cpp')
| -rw-r--r-- | src/modinfodialog.cpp | 62 |
1 files changed, 58 insertions, 4 deletions
diff --git a/src/modinfodialog.cpp b/src/modinfodialog.cpp index 3657d48a..117b2726 100644 --- a/src/modinfodialog.cpp +++ b/src/modinfodialog.cpp @@ -69,7 +69,6 @@ ModInfoDialog::ModInfoDialog(ModInfo::Ptr modInfo, const DirectoryEntry *directo ui->setupUi(this); this->setWindowTitle(modInfo->name()); this->setWindowModality(Qt::WindowModal); - m_UTF8Codec = QTextCodec::codecForName("utf-8"); QListWidget *textFileList = findChild<QListWidget*>("textFileList"); @@ -143,7 +142,6 @@ ModInfoDialog::ModInfoDialog(ModInfo::Ptr modInfo, const DirectoryEntry *directo QTabWidget *tabWidget = findChild<QTabWidget*>("tabWidget"); tabWidget->setTabEnabled(TAB_TEXTFILES, textFileList->count() != 0); - //tabWidget->setTabEnabled(TAB_INIFILES, (iniFileList->count() != 0) || (iniTweaksList->count() != 0)); tabWidget->setTabEnabled(TAB_IMAGES, thumbnailArea->count() != 0); tabWidget->setTabEnabled(TAB_ESPS, (inactiveESPList->count() != 0) || (activeESPList->count() != 0)); tabWidget->setTabEnabled(TAB_CONFLICTS, m_Origin != NULL); @@ -168,6 +166,63 @@ ModInfoDialog::~ModInfoDialog() } +int ModInfoDialog::tabIndex(const QString &tabId) +{ + for (int i = 0; i < ui->tabWidget->count(); ++i) { + if (ui->tabWidget->widget(i)->objectName() == tabId) { + return i; + } + } + return -1; +} + + +void ModInfoDialog::restoreTabState(const QByteArray &state) +{ + QDataStream stream(state); + int count = 0; + stream >> count; + + QStringList tabIds; + + // first, only determine the new mapping + for (int newPos = 0; newPos < count; ++newPos) { + QString tabId; + stream >> tabId; + tabIds.append(tabId); + int oldPos = tabIndex(tabId); + if (oldPos != -1) { + m_RealTabPos[newPos] = oldPos; + } else { + m_RealTabPos[newPos] = newPos; + } + } + // then actually move the tabs + QTabBar *tabBar = ui->tabWidget->findChild<QTabBar*>("qt_tabwidget_tabbar"); // magic name = bad + ui->tabWidget->blockSignals(true); + for (int newPos = 0; newPos < count; ++newPos) { + QString tabId = tabIds.at(newPos); + int oldPos = tabIndex(tabId); + tabBar->moveTab(oldPos, newPos); + } + ui->tabWidget->blockSignals(false); +} + + +QByteArray ModInfoDialog::saveTabState() const +{ + QByteArray result; + QDataStream stream(&result, QIODevice::WriteOnly); + stream << ui->tabWidget->count(); + for (int i = 0; i < ui->tabWidget->count(); ++i) { + stream << ui->tabWidget->widget(i)->objectName(); + + } + + return result; +} + + void ModInfoDialog::refreshLists() { int numNonConflicting = 0; @@ -331,7 +386,6 @@ void ModInfoDialog::openTab(int tab) } } - void ModInfoDialog::thumbnailClicked(const QString &fileName) { QLabel *imageLabel = findChild<QLabel*>("imageLabel"); @@ -784,7 +838,7 @@ void ModInfoDialog::activateNexusTab() void ModInfoDialog::on_tabWidget_currentChanged(int index) { - if (index == TAB_NEXUS) { + if (m_RealTabPos[index] == TAB_NEXUS) { activateNexusTab(); } } |
