|
@@ -63,6 +63,9 @@ void StackedWidget::setCurrentWidget(QWidget *widget, bool popOut)
|
|
|
|
|
|
void StackedWidget::setCurrentIndex(int index, bool popOut)
|
|
|
{
|
|
|
+ if (index < 0 || index >= view()->count()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
setCurrentWidget(m_view->widget(index), popOut);
|
|
|
}
|
|
|
|
|
@@ -71,6 +74,17 @@ PopUpAniStackedWidget *StackedWidget::view() const
|
|
|
return m_view;
|
|
|
}
|
|
|
|
|
|
+int StackedWidget::index(const QString routeKey)
|
|
|
+{
|
|
|
+ for (int i = 0; i < view()->count(); i++) {
|
|
|
+ QWidget *w = view()->widget(i);
|
|
|
+ if (w->objectName() == routeKey) {
|
|
|
+ return i;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return -1;
|
|
|
+}
|
|
|
+
|
|
|
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
|
|
|
{
|
|
|
m_titleBar = new CustomTitleBar(this);
|
|
@@ -89,7 +103,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
|
|
|
|
|
|
initLoginPage();
|
|
|
|
|
|
- setMinimumSize(QSize(1000, 800));
|
|
|
+ setMinimumSize(QSize(1200, 800));
|
|
|
}
|
|
|
|
|
|
MainWindow::~MainWindow() { }
|
|
@@ -130,6 +144,7 @@ void MainWindow::initMainPage()
|
|
|
m_widgetLayout->setContentsMargins(0, 32, 0, 0);
|
|
|
|
|
|
initNavigation();
|
|
|
+ m_naviInterface->panel->expand();
|
|
|
|
|
|
connect(m_naviInterface, &NavigationInterface::displayModeChanged, m_titleBar, &StandardTitleBar::raise);
|
|
|
connect(m_userView, &UserView::signalLogout, this, &MainWindow::slotLogout);
|
|
@@ -192,17 +207,6 @@ void MainWindow::resizeEvent(QResizeEvent *event)
|
|
|
m_titleBar->resize(width() - titleBarIndent(), m_titleBar->height());
|
|
|
}
|
|
|
|
|
|
-int MainWindow::routeIndex(const QString routeKey) const
|
|
|
-{
|
|
|
- for (int i = 0; i < m_stackWidget->view()->count(); i++) {
|
|
|
- QWidget *w = m_stackWidget->view()->widget(i);
|
|
|
- if (w->objectName() == routeKey) {
|
|
|
- return i;
|
|
|
- }
|
|
|
- }
|
|
|
- return -1;
|
|
|
-}
|
|
|
-
|
|
|
void MainWindow::slotLogin()
|
|
|
{
|
|
|
initMainPage();
|
|
@@ -231,24 +235,24 @@ void MainWindow::slotCancelLogin()
|
|
|
|
|
|
void MainWindow::slotNaviItemClicked()
|
|
|
{
|
|
|
- for (int i = 0; i < m_stackWidget->view()->count(); i++) {
|
|
|
- QWidget *w = m_stackWidget->view()->widget(i);
|
|
|
- if (w->objectName() == sender()->property("routeKey")) {
|
|
|
- m_stackWidget->setCurrentWidget(w, false);
|
|
|
- }
|
|
|
- }
|
|
|
+ int index = m_stackWidget->index(sender()->property("routeKey").toString());
|
|
|
+ m_stackWidget->setCurrentIndex(index);
|
|
|
}
|
|
|
|
|
|
void MainWindow::slotOpenProject(ProjectInfo *proj)
|
|
|
{
|
|
|
QString n = QString("project_%1").arg(proj->id);
|
|
|
-
|
|
|
- CMindView *m = new CMindView(m_mainWidget);
|
|
|
- m->setObjectName(n);
|
|
|
- m_stackWidget->addWidget(m);
|
|
|
-
|
|
|
- QString t = QString("打开项目-%1").arg(proj->projectName);
|
|
|
- m_naviInterface->addItem(m->objectName(), NEWFLICON(QFDIcon, Project), t, this, SLOT(slotNaviItemClicked()), true,
|
|
|
- NavigationItemPosition::SCROLL);
|
|
|
- m_stackWidget->setCurrentWidget(m);
|
|
|
+ int index = m_stackWidget->index(n);
|
|
|
+ if (index >= 0) {
|
|
|
+ m_stackWidget->setCurrentIndex(index);
|
|
|
+ } else {
|
|
|
+ CMindView *m = new CMindView(m_mainWidget);
|
|
|
+ m->setObjectName(n);
|
|
|
+ m_stackWidget->addWidget(m);
|
|
|
+
|
|
|
+ QString t = QString("打开项目-%1").arg(proj->projectName);
|
|
|
+ m_naviInterface->addItem(m->objectName(), NEWFLICON(QFDIcon, Project), t, this, SLOT(slotNaviItemClicked()),
|
|
|
+ true, NavigationItemPosition::SCROLL);
|
|
|
+ m_stackWidget->setCurrentWidget(m);
|
|
|
+ }
|
|
|
}
|