Switch to DatabaseTabWidget when the current tab changed and the welcome widget is shown.

This commit is contained in:
Felix Geyer 2012-05-28 18:49:16 +02:00
parent a8ab3a5ca1
commit f145cb69de
2 changed files with 10 additions and 3 deletions

View File

@ -76,13 +76,13 @@ MainWindow::MainWindow()
SLOT(updateWindowTitle())); SLOT(updateWindowTitle()));
connect(m_ui->tabWidget, SIGNAL(currentChanged(int)), connect(m_ui->tabWidget, SIGNAL(currentChanged(int)),
SLOT(updateWindowTitle())); SLOT(updateWindowTitle()));
connect(m_ui->tabWidget, SIGNAL(currentChanged(int)),
SLOT(databaseTabChanged(int)));
connect(m_ui->stackedWidget, SIGNAL(currentChanged(int)), SLOT(setMenuActionState())); connect(m_ui->stackedWidget, SIGNAL(currentChanged(int)), SLOT(setMenuActionState()));
connect(m_ui->settingsWidget, SIGNAL(editFinished(bool)), SLOT(switchToDatabases())); connect(m_ui->settingsWidget, SIGNAL(editFinished(bool)), SLOT(switchToDatabases()));
connect(m_ui->actionDatabaseNew, SIGNAL(triggered()), SLOT(switchToDatabases()));
connect(m_ui->actionDatabaseNew, SIGNAL(triggered()), m_ui->tabWidget, connect(m_ui->actionDatabaseNew, SIGNAL(triggered()), m_ui->tabWidget,
SLOT(newDatabase())); SLOT(newDatabase()));
connect(m_ui->actionDatabaseOpen, SIGNAL(triggered()), SLOT(switchToDatabases()));
connect(m_ui->actionDatabaseOpen, SIGNAL(triggered()), m_ui->tabWidget, connect(m_ui->actionDatabaseOpen, SIGNAL(triggered()), m_ui->tabWidget,
SLOT(openDatabase())); SLOT(openDatabase()));
connect(m_ui->actionDatabaseSave, SIGNAL(triggered()), m_ui->tabWidget, connect(m_ui->actionDatabaseSave, SIGNAL(triggered()), m_ui->tabWidget,
@ -95,7 +95,6 @@ MainWindow::MainWindow()
SLOT(changeMasterKey())); SLOT(changeMasterKey()));
connect(m_ui->actionChangeDatabaseSettings, SIGNAL(triggered()), m_ui->tabWidget, connect(m_ui->actionChangeDatabaseSettings, SIGNAL(triggered()), m_ui->tabWidget,
SLOT(changeDatabaseSettings())); SLOT(changeDatabaseSettings()));
connect(m_ui->actionImportKeePass1, SIGNAL(triggered()), SLOT(switchToDatabases()));
connect(m_ui->actionImportKeePass1, SIGNAL(triggered()), m_ui->tabWidget, connect(m_ui->actionImportKeePass1, SIGNAL(triggered()), m_ui->tabWidget,
SLOT(importKeePass1Database())); SLOT(importKeePass1Database()));
connect(m_ui->actionQuit, SIGNAL(triggered()), SLOT(close())); connect(m_ui->actionQuit, SIGNAL(triggered()), SLOT(close()));
@ -247,6 +246,13 @@ void MainWindow::switchToSettings()
m_ui->stackedWidget->setCurrentIndex(1); m_ui->stackedWidget->setCurrentIndex(1);
} }
void MainWindow::databaseTabChanged(int tabIndex)
{
if (tabIndex != -1 && m_ui->stackedWidget->currentIndex() == 2) {
switchToDatabases();
}
}
void MainWindow::closeEvent(QCloseEvent* event) { void MainWindow::closeEvent(QCloseEvent* event) {
if (!m_ui->tabWidget->closeAllDatabases()) { if (!m_ui->tabWidget->closeAllDatabases()) {
event->ignore(); event->ignore();

View File

@ -47,6 +47,7 @@ private Q_SLOTS:
void showAboutDialog(); void showAboutDialog();
void switchToDatabases(); void switchToDatabases();
void switchToSettings(); void switchToSettings();
void databaseTabChanged(int tabIndex);
private: private:
static void setShortcut(QAction* action, QKeySequence::StandardKey standard, int fallback = 0); static void setShortcut(QAction* action, QKeySequence::StandardKey standard, int fallback = 0);