mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-12-04 15:39:34 +01:00
make stackedWidget index using enum
This commit is contained in:
@@ -393,8 +393,8 @@ void MainWindow::openDatabase(const QString& fileName, const QString& pw, const
|
|||||||
void MainWindow::setMenuActionState(DatabaseWidget::Mode mode)
|
void MainWindow::setMenuActionState(DatabaseWidget::Mode mode)
|
||||||
{
|
{
|
||||||
int currentIndex = m_ui->stackedWidget->currentIndex();
|
int currentIndex = m_ui->stackedWidget->currentIndex();
|
||||||
bool inDatabaseTabWidget = (currentIndex == 0);
|
bool inDatabaseTabWidget = (currentIndex == DatabaseTabScreen);
|
||||||
bool inWelcomeWidget = (currentIndex == 2);
|
bool inWelcomeWidget = (currentIndex == WelcomeScreen);
|
||||||
|
|
||||||
if (inDatabaseTabWidget && m_ui->tabWidget->currentIndex() != -1) {
|
if (inDatabaseTabWidget && m_ui->tabWidget->currentIndex() != -1) {
|
||||||
DatabaseWidget* dbWidget = m_ui->tabWidget->currentDatabaseWidget();
|
DatabaseWidget* dbWidget = m_ui->tabWidget->currentDatabaseWidget();
|
||||||
@@ -508,7 +508,7 @@ void MainWindow::setMenuActionState(DatabaseWidget::Mode mode)
|
|||||||
|
|
||||||
m_ui->actionLockDatabases->setEnabled(m_ui->tabWidget->hasLockableDatabases());
|
m_ui->actionLockDatabases->setEnabled(m_ui->tabWidget->hasLockableDatabases());
|
||||||
|
|
||||||
if ((3 == currentIndex) != m_ui->actionPasswordGenerator->isChecked()) {
|
if ((currentIndex == PasswordGeneratorScreen) != m_ui->actionPasswordGenerator->isChecked()) {
|
||||||
bool blocked = m_ui->actionPasswordGenerator->blockSignals(true);
|
bool blocked = m_ui->actionPasswordGenerator->blockSignals(true);
|
||||||
m_ui->actionPasswordGenerator->toggle();
|
m_ui->actionPasswordGenerator->toggle();
|
||||||
m_ui->actionPasswordGenerator->blockSignals(blocked);
|
m_ui->actionPasswordGenerator->blockSignals(blocked);
|
||||||
@@ -520,7 +520,7 @@ void MainWindow::updateWindowTitle()
|
|||||||
QString customWindowTitlePart;
|
QString customWindowTitlePart;
|
||||||
int stackedWidgetIndex = m_ui->stackedWidget->currentIndex();
|
int stackedWidgetIndex = m_ui->stackedWidget->currentIndex();
|
||||||
int tabWidgetIndex = m_ui->tabWidget->currentIndex();
|
int tabWidgetIndex = m_ui->tabWidget->currentIndex();
|
||||||
if (stackedWidgetIndex == 0 && tabWidgetIndex != -1) {
|
if (stackedWidgetIndex == DatabaseTabScreen && tabWidgetIndex != -1) {
|
||||||
customWindowTitlePart = m_ui->tabWidget->tabText(tabWidgetIndex);
|
customWindowTitlePart = m_ui->tabWidget->tabText(tabWidgetIndex);
|
||||||
if (m_ui->tabWidget->readOnly(tabWidgetIndex)) {
|
if (m_ui->tabWidget->readOnly(tabWidgetIndex)) {
|
||||||
customWindowTitlePart.append(QString(" [%1]").arg(tr("read-only")));
|
customWindowTitlePart.append(QString(" [%1]").arg(tr("read-only")));
|
||||||
@@ -556,17 +556,17 @@ void MainWindow::showAboutDialog()
|
|||||||
void MainWindow::switchToDatabases()
|
void MainWindow::switchToDatabases()
|
||||||
{
|
{
|
||||||
if (m_ui->tabWidget->currentIndex() == -1) {
|
if (m_ui->tabWidget->currentIndex() == -1) {
|
||||||
m_ui->stackedWidget->setCurrentIndex(2);
|
m_ui->stackedWidget->setCurrentIndex(WelcomeScreen);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_ui->stackedWidget->setCurrentIndex(0);
|
m_ui->stackedWidget->setCurrentIndex(DatabaseTabScreen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::switchToSettings()
|
void MainWindow::switchToSettings()
|
||||||
{
|
{
|
||||||
m_ui->settingsWidget->loadSettings();
|
m_ui->settingsWidget->loadSettings();
|
||||||
m_ui->stackedWidget->setCurrentIndex(1);
|
m_ui->stackedWidget->setCurrentIndex(SettingsScreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::switchToPasswordGen(bool enabled)
|
void MainWindow::switchToPasswordGen(bool enabled)
|
||||||
@@ -575,7 +575,7 @@ void MainWindow::switchToPasswordGen(bool enabled)
|
|||||||
m_ui->passwordGeneratorWidget->loadSettings();
|
m_ui->passwordGeneratorWidget->loadSettings();
|
||||||
m_ui->passwordGeneratorWidget->regeneratePassword();
|
m_ui->passwordGeneratorWidget->regeneratePassword();
|
||||||
m_ui->passwordGeneratorWidget->setStandaloneMode(true);
|
m_ui->passwordGeneratorWidget->setStandaloneMode(true);
|
||||||
m_ui->stackedWidget->setCurrentIndex(3);
|
m_ui->stackedWidget->setCurrentIndex(PasswordGeneratorScreen);
|
||||||
} else {
|
} else {
|
||||||
m_ui->passwordGeneratorWidget->saveSettings();
|
m_ui->passwordGeneratorWidget->saveSettings();
|
||||||
switchToDatabases();
|
switchToDatabases();
|
||||||
@@ -624,11 +624,11 @@ void MainWindow::databaseStatusChanged(DatabaseWidget *)
|
|||||||
|
|
||||||
void MainWindow::databaseTabChanged(int tabIndex)
|
void MainWindow::databaseTabChanged(int tabIndex)
|
||||||
{
|
{
|
||||||
if (tabIndex != -1 && m_ui->stackedWidget->currentIndex() == 2) {
|
if (tabIndex != -1 && m_ui->stackedWidget->currentIndex() == WelcomeScreen) {
|
||||||
m_ui->stackedWidget->setCurrentIndex(0);
|
m_ui->stackedWidget->setCurrentIndex(DatabaseTabScreen);
|
||||||
}
|
}
|
||||||
else if (tabIndex == -1 && m_ui->stackedWidget->currentIndex() == 0) {
|
else if (tabIndex == -1 && m_ui->stackedWidget->currentIndex() == DatabaseTabScreen) {
|
||||||
m_ui->stackedWidget->setCurrentIndex(2);
|
m_ui->stackedWidget->setCurrentIndex(WelcomeScreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_actionMultiplexer.setCurrentObject(m_ui->tabWidget->currentDatabaseWidget());
|
m_actionMultiplexer.setCurrentObject(m_ui->tabWidget->currentDatabaseWidget());
|
||||||
@@ -919,7 +919,7 @@ void MainWindow::hideGlobalMessage()
|
|||||||
|
|
||||||
void MainWindow::hideTabMessage()
|
void MainWindow::hideTabMessage()
|
||||||
{
|
{
|
||||||
if (m_ui->stackedWidget->currentIndex() == 0) {
|
if (m_ui->stackedWidget->currentIndex() == DatabaseTabScreen) {
|
||||||
m_ui->tabWidget->currentDatabaseWidget()->hideMessage();
|
m_ui->tabWidget->currentDatabaseWidget()->hideMessage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,13 @@ class MainWindow : public QMainWindow
|
|||||||
public:
|
public:
|
||||||
MainWindow();
|
MainWindow();
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
|
enum StackedWidgetIndex
|
||||||
|
{
|
||||||
|
DatabaseTabScreen = 0,
|
||||||
|
SettingsScreen = 1,
|
||||||
|
WelcomeScreen = 2,
|
||||||
|
PasswordGeneratorScreen = 3
|
||||||
|
};
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void openDatabase(const QString& fileName, const QString& pw = QString(),
|
void openDatabase(const QString& fileName, const QString& pw = QString(),
|
||||||
|
|||||||
Reference in New Issue
Block a user