Skip to content

Commit

Permalink
Optimize multiple tab
Browse files Browse the repository at this point in the history
  • Loading branch information
BlackINT3 committed Jul 24, 2020
1 parent 0fab7ac commit 8c81fd1
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/OpenArk/common/config/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,12 @@ void OpenArkConfig::GetMainTabAllMap(QVector<QVector<int>> &idxs)
str = GetValue(section + "maintab_map").toString();
if (str.isEmpty()) {
for (int i = 0; i < TAB_MAX; i++) {
str.append("0");
str.append("20000");
if (i == TAB_MAX - 1) break;
str.append(":");
}
}
for (int seq = 0; seq < maintab_map_.size(); seq++) {
for (int seq = 0; seq < TAB_MAX; seq++) {
QVector<int> idx;
maintab_map_ = str.split(":").toVector();
int cnt = maintab_map_[seq].mid(0, 1).toInt();
Expand Down
6 changes: 5 additions & 1 deletion src/OpenArk/kernel/kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,12 @@ class Kernel : public QWidget {
~Kernel();

public:
Q_INVOKABLE QTabWidget *GetActiveTabWidget() { return ui.tabWidget; };
Q_INVOKABLE int GetActiveTab() { return ui.tabWidget->currentIndex(); };
Q_INVOKABLE void SetActiveTab(int idx) { ui.tabWidget->setCurrentIndex(idx); };
Q_INVOKABLE void SetActiveTab(QVector<int> idx) {
ui.tabWidget->setCurrentIndex(idx[0]);
qobject_cast<QTabWidget *>(ui.tabWidget->currentWidget())->setCurrentIndex(idx[1]);
};

protected:
bool eventFilter(QObject *obj, QEvent *e);
Expand Down
26 changes: 22 additions & 4 deletions src/OpenArk/openark/openark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ OpenArk::OpenArk(QWidget *parent) :

for (int tab = 0; tab < TAB_MAX; tab++) {
switch (main_idx) {
case TAB_KERNEL: kernel->SetActiveTab(level2_idx); break;
case TAB_KERNEL: kernel->SetActiveTab(idxs[main_idx]); break;
case TAB_CODERKIT: coderkit->SetActiveTab(level2_idx); break;
case TAB_SCANNER: scanner->SetActiveTab(level2_idx); break;
case TAB_UTILITIES: utilities->SetActiveTab(level2_idx); break;
Expand Down Expand Up @@ -520,11 +520,29 @@ void OpenArk::onTabChanged(int idx)
case TAB_REVERSE:
auto obj = ui.tabWidget->currentWidget();
if (obj->objectName().contains("tab")) break;

QVector<int> tabs;

qint32 l2;
qRegisterMetaType<qint32>("qint32");
QMetaObject::invokeMethod(obj,
"GetActiveTab", Qt::DirectConnection, Q_RETURN_ARG(qint32, l2));
OpenArkConfig::Instance()->SetPrefLevel2Tab(l2);
QMetaObject::invokeMethod(obj, "GetActiveTab", Qt::DirectConnection, Q_RETURN_ARG(qint32, l2));
tabs.push_back(l2);

QTabWidget *tab222;
//qRegisterMetaType<QTabWidget*>("QTabWidget*");
qRegisterMetaType<QTabWidget*>();
QMetaObject::invokeMethod(obj, "GetActiveTabWidget", Qt::DirectConnection, Q_RETURN_ARG(QTabWidget*, tab222));

QString xx = tab222->metaObject()->className();
if (xx == "QTabWidget") {
auto obj3 = qobject_cast<QTabWidget*>(obj)->currentWidget();
qint32 l3;
qRegisterMetaType<qint32>("qint32");
QMetaObject::invokeMethod(obj3, "currentIndex", Qt::DirectConnection, Q_RETURN_ARG(qint32, l2));
tabs.push_back(l3);
//OpenArkConfig::Instance()->SetPrefLevel2Tab(l2);
}
OpenArkConfig::Instance()->SetMainTabMap(idx, tabs);
break;
}

Expand Down

0 comments on commit 8c81fd1

Please sign in to comment.