summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTannin <devnull@localhost>2014-02-04 19:55:27 +0100
committerTannin <devnull@localhost>2014-02-04 19:55:27 +0100
commit76fbe6effef7c2e787c1801741d4eb0a156128ce (patch)
treeef671b8073e1208a00b5b50f0afa493375daaede /src
parent38ee6ccf0a822bf20d548bbb89dbe3059ee336bb (diff)
- tabs in the mod info dialog can now be moved around by the user
Diffstat (limited to 'src')
-rw-r--r--src/mainwindow.cpp3
-rw-r--r--src/modinfodialog.cpp62
-rw-r--r--src/modinfodialog.h8
-rw-r--r--src/modinfodialog.ui11
4 files changed, 76 insertions, 8 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 90eb6bce..b6a744aa 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -3160,7 +3160,10 @@ void MainWindow::displayModInformation(ModInfo::Ptr modInfo, unsigned int index,
connect(&dialog, SIGNAL(endorseMod(ModInfo::Ptr)), this, SLOT(endorseMod(ModInfo::Ptr)));
dialog.openTab(tab);
+ dialog.restoreTabState(m_Settings.directInterface().value("mod_info_tabs").toByteArray());
dialog.exec();
+ m_Settings.directInterface().setValue("mod_info_tabs", dialog.saveTabState());
+
modInfo->saveMeta();
emit modInfoDisplayed();
m_ModList.modInfoChanged(modInfo);
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();
}
}
diff --git a/src/modinfodialog.h b/src/modinfodialog.h
index b33b743e..edfe59cf 100644
--- a/src/modinfodialog.h
+++ b/src/modinfodialog.h
@@ -100,6 +100,10 @@ public:
**/
void openTab(int tab);
+ void restoreTabState(const QByteArray &state);
+
+ QByteArray saveTabState() const;
+
signals:
void thumbnailClickedSignal(const QString &filename);
@@ -142,6 +146,8 @@ private:
void addCheckedCategories(QTreeWidgetItem *tree);
void refreshPrimaryCategoriesBox();
+ int tabIndex(const QString &tabId);
+
private slots:
void hideConflictFile();
@@ -221,6 +227,8 @@ private:
MOShared::FilesOrigin *m_Origin;
QTextCodec *m_UTF8Codec;
+ std::map<int, int> m_RealTabPos;
+
};
#endif // MODINFODIALOG_H
diff --git a/src/modinfodialog.ui b/src/modinfodialog.ui
index 7b95e011..1d357f70 100644
--- a/src/modinfodialog.ui
+++ b/src/modinfodialog.ui
@@ -22,6 +22,9 @@
<property name="currentIndex">
<number>0</number>
</property>
+ <property name="movable">
+ <bool>true</bool>
+ </property>
<widget class="QWidget" name="tabText">
<attribute name="title">
<string>Textfiles</string>
@@ -209,7 +212,7 @@
<rect>
<x>0</x>
<y>0</y>
- <width>668</width>
+ <width>676</width>
<height>126</height>
</rect>
</property>
@@ -546,7 +549,7 @@ Most mods do not have optional esps, so chances are good you are looking at an e
</item>
</layout>
</widget>
- <widget class="QWidget" name="tabNexus_2">
+ <widget class="QWidget" name="tabNexus">
<attribute name="icon">
<iconset resource="resources.qrc">
<normaloff>:/MO/gui/resources/internet-web-browser.png</normaloff>:/MO/gui/resources/internet-web-browser.png</iconset>
@@ -666,8 +669,8 @@ p, li { white-space: pre-wrap; }
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
-&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:7.8pt; font-weight:400; font-style:normal;&quot;&gt;
-&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
+&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="textInteractionFlags">
<set>Qt::TextBrowserInteraction</set>