keepassxc/src/gui/MainWindow.h

117 lines
3.7 KiB
C++
Raw Normal View History

2010-09-19 16:59:32 +02:00
/*
* Copyright (C) 2010 Felix Geyer <debfx@fobos.de>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 or (at your option)
* version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef KEEPASSX_MAINWINDOW_H
#define KEEPASSX_MAINWINDOW_H
#include <QActionGroup>
#include <QMainWindow>
#include <QSystemTrayIcon>
2010-09-19 16:59:32 +02:00
#include "core/SignalMultiplexer.h"
#include "gui/DatabaseWidget.h"
#include "gui/Application.h"
namespace Ui {
class MainWindow;
}
2010-09-19 16:59:32 +02:00
class InactivityTimer;
class MainWindow : public QMainWindow
2010-09-19 16:59:32 +02:00
{
Q_OBJECT
public:
MainWindow();
~MainWindow();
public Q_SLOTS:
void openDatabase(const QString& fileName, const QString& pw = QString(),
const QString& keyFile = QString());
void appExit();
void displayGlobalMessage(const QString& text, MessageWidget::MessageType type, bool showClosebutton = true);
void displayTabMessage(const QString& text, MessageWidget::MessageType type, bool showClosebutton = true);
void hideGlobalMessage();
void showYubiKeyPopup();
void hideYubiKeyPopup();
2011-11-13 14:55:20 +01:00
protected:
2015-07-24 18:28:12 +02:00
void closeEvent(QCloseEvent* event) override;
void changeEvent(QEvent* event) override;
private Q_SLOTS:
void setMenuActionState(DatabaseWidget::Mode mode = DatabaseWidget::None);
void updateWindowTitle();
2012-05-02 15:37:21 +02:00
void showAboutDialog();
void switchToDatabases();
void switchToSettings();
void switchToPasswordGen(bool enabled);
2017-02-11 19:04:37 +01:00
void switchToNewDatabase();
void switchToOpenDatabase();
void switchToDatabaseFile(QString file);
void switchToKeePass1Database();
void closePasswordGen();
2016-10-08 18:55:05 +02:00
void databaseStatusChanged(DatabaseWidget *dbWidget);
void databaseTabChanged(int tabIndex);
void openRecentDatabase(QAction* action);
void clearLastDatabases();
void updateLastDatabasesMenu();
void updateCopyAttributesMenu();
void showEntryContextMenu(const QPoint& globalPos);
void showGroupContextMenu(const QPoint& globalPos);
void saveToolbarState(bool value);
2013-04-27 11:20:13 +02:00
void rememberOpenDatabases(const QString& filePath);
void applySettingsChanges();
void trayIconTriggered(QSystemTrayIcon::ActivationReason reason);
void hideWindow();
void toggleWindow();
void lockDatabasesAfterInactivity();
void repairDatabase();
void hideTabMessage();
2011-11-13 14:55:20 +01:00
private:
2012-05-15 18:16:04 +02:00
static void setShortcut(QAction* action, QKeySequence::StandardKey standard, int fallback = 0);
2012-05-14 19:10:42 +02:00
static const QString BaseWindowTitle;
2014-03-22 12:21:49 +01:00
void saveWindowInformation();
bool saveLastDatabases();
void updateTrayIcon();
bool isTrayIconEnabled() const;
2014-03-22 12:21:49 +01:00
2012-04-23 19:44:43 +02:00
const QScopedPointer<Ui::MainWindow> m_ui;
SignalMultiplexer m_actionMultiplexer;
QAction* m_clearHistoryAction;
QAction* m_searchWidgetAction;
QActionGroup* m_lastDatabasesActions;
QActionGroup* m_copyAdditionalAttributeActions;
2013-04-27 11:20:13 +02:00
QStringList m_openDatabases;
InactivityTimer* m_inactivityTimer;
int m_countDefaultAttributes;
QSystemTrayIcon* m_trayIcon;
Q_DISABLE_COPY(MainWindow)
bool appExitCalled;
2010-09-19 16:59:32 +02:00
};
2017-02-24 19:47:03 +01:00
#define KEEPASSXC_MAIN_WINDOW (qobject_cast<Application*>(qApp) ? \
qobject_cast<MainWindow*>(qobject_cast<Application*>(qApp)->mainWindow()) : nullptr)
2010-09-19 16:59:32 +02:00
#endif // KEEPASSX_MAINWINDOW_H