mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-12-29 01:06:27 -05:00
Synchronize DatabaseWidget splitter sizes.
This commit is contained in:
parent
05de45dadb
commit
d874f58a39
@ -75,6 +75,7 @@ set(keepassx_SOURCES
|
||||
gui/DatabaseSettingsWidget.cpp
|
||||
gui/DatabaseTabWidget.cpp
|
||||
gui/DatabaseWidget.cpp
|
||||
gui/DatabaseWidgetStateSync.cpp
|
||||
gui/DialogyWidget.cpp
|
||||
gui/DragTabBar.cpp
|
||||
gui/EditWidget.cpp
|
||||
@ -156,6 +157,7 @@ set(keepassx_MOC
|
||||
gui/DatabaseSettingsWidget.h
|
||||
gui/DatabaseTabWidget.h
|
||||
gui/DatabaseWidget.h
|
||||
gui/DatabaseWidgetStateSync.h
|
||||
gui/DialogyWidget.h
|
||||
gui/DragTabBar.h
|
||||
gui/EditWidget.h
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "core/Metadata.h"
|
||||
#include "core/qsavefile.h"
|
||||
#include "gui/DatabaseWidget.h"
|
||||
#include "gui/DatabaseWidgetStateSync.h"
|
||||
#include "gui/DragTabBar.h"
|
||||
#include "gui/FileDialog.h"
|
||||
#include "gui/MessageBox.h"
|
||||
@ -46,12 +47,15 @@ const int DatabaseTabWidget::LastDatabasesCount = 5;
|
||||
|
||||
DatabaseTabWidget::DatabaseTabWidget(QWidget* parent)
|
||||
: QTabWidget(parent)
|
||||
, m_dbWidgetSateSync(new DatabaseWidgetStateSync(this))
|
||||
{
|
||||
DragTabBar* tabBar = new DragTabBar(this);
|
||||
tabBar->setDrawBase(false);
|
||||
setTabBar(tabBar);
|
||||
|
||||
connect(this, SIGNAL(tabCloseRequested(int)), SLOT(closeDatabase(int)));
|
||||
connect(this, SIGNAL(currentChanged(int)), SLOT(emitActivateDatabaseChanged()));
|
||||
connect(this, SIGNAL(activateDatabaseChanged(DatabaseWidget*)), m_dbWidgetSateSync, SLOT(setActive(DatabaseWidget*)));
|
||||
connect(autoType(), SIGNAL(globalShortcutTriggered()), SLOT(performGlobalAutoType()));
|
||||
}
|
||||
|
||||
@ -584,6 +588,11 @@ void DatabaseTabWidget::changeDatabase(Database* newDb)
|
||||
connectDatabase(newDb, oldDb);
|
||||
}
|
||||
|
||||
void DatabaseTabWidget::emitActivateDatabaseChanged()
|
||||
{
|
||||
Q_EMIT activateDatabaseChanged(currentDatabaseWidget());
|
||||
}
|
||||
|
||||
void DatabaseTabWidget::connectDatabase(Database* newDb, Database* oldDb)
|
||||
{
|
||||
if (oldDb) {
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "gui/DatabaseWidget.h"
|
||||
|
||||
class DatabaseWidget;
|
||||
class DatabaseWidgetStateSync;
|
||||
class DatabaseOpenWidget;
|
||||
class QFile;
|
||||
|
||||
@ -75,6 +76,7 @@ public Q_SLOTS:
|
||||
Q_SIGNALS:
|
||||
void tabNameChanged();
|
||||
void databaseWithFileClosed(QString filePath);
|
||||
void activateDatabaseChanged(DatabaseWidget* dbWidget);
|
||||
|
||||
private Q_SLOTS:
|
||||
void updateTabName(Database* db);
|
||||
@ -83,6 +85,7 @@ private Q_SLOTS:
|
||||
void modified();
|
||||
void toggleTabbar();
|
||||
void changeDatabase(Database* newDb);
|
||||
void emitActivateDatabaseChanged();
|
||||
|
||||
private:
|
||||
void saveDatabase(Database* db);
|
||||
@ -99,6 +102,7 @@ private:
|
||||
|
||||
KeePass2Writer m_writer;
|
||||
QHash<Database*, DatabaseManagerStruct> m_dbList;
|
||||
DatabaseWidgetStateSync* m_dbWidgetSateSync;
|
||||
};
|
||||
|
||||
#endif // KEEPASSX_DATABASETABWIDGET_H
|
||||
|
@ -61,12 +61,12 @@ DatabaseWidget::DatabaseWidget(Database* db, QWidget* parent)
|
||||
|
||||
m_mainWidget = new QWidget(this);
|
||||
QLayout* layout = new QHBoxLayout(m_mainWidget);
|
||||
QSplitter* splitter = new QSplitter(m_mainWidget);
|
||||
m_splitter = new QSplitter(m_mainWidget);
|
||||
|
||||
QWidget* rightHandSideWidget = new QWidget(splitter);
|
||||
QWidget* rightHandSideWidget = new QWidget(m_splitter);
|
||||
m_searchWidget->setParent(rightHandSideWidget);
|
||||
|
||||
m_groupView = new GroupView(db, splitter);
|
||||
m_groupView = new GroupView(db, m_splitter);
|
||||
m_groupView->setObjectName("groupView");
|
||||
m_groupView->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(m_groupView, SIGNAL(customContextMenuRequested(QPoint)),
|
||||
@ -106,10 +106,10 @@ DatabaseWidget::DatabaseWidget(Database* db, QWidget* parent)
|
||||
setTabOrder(m_entryView, m_groupView);
|
||||
setTabOrder(m_groupView, m_searchWidget);
|
||||
|
||||
splitter->addWidget(m_groupView);
|
||||
splitter->addWidget(rightHandSideWidget);
|
||||
m_splitter->addWidget(m_groupView);
|
||||
m_splitter->addWidget(rightHandSideWidget);
|
||||
|
||||
layout->addWidget(splitter);
|
||||
layout->addWidget(m_splitter);
|
||||
m_mainWidget->setLayout(layout);
|
||||
|
||||
m_editEntryWidget = new EditEntryWidget();
|
||||
@ -141,6 +141,7 @@ DatabaseWidget::DatabaseWidget(Database* db, QWidget* parent)
|
||||
addWidget(m_keepass1OpenWidget);
|
||||
addWidget(m_unlockDatabaseWidget);
|
||||
|
||||
connect(m_splitter, SIGNAL(splitterMoved(int,int)), SIGNAL(splitterSizesChanged()));
|
||||
connect(m_groupView, SIGNAL(groupChanged(Group*)), this, SLOT(clearLastGroup(Group*)));
|
||||
connect(m_groupView, SIGNAL(groupChanged(Group*)), SIGNAL(groupChanged()));
|
||||
connect(m_groupView, SIGNAL(groupChanged(Group*)), m_entryView, SLOT(setGroup(Group*)));
|
||||
@ -200,6 +201,15 @@ bool DatabaseWidget::isInEditMode() const
|
||||
}
|
||||
}
|
||||
|
||||
QList<int> DatabaseWidget::splitterSizes() const
|
||||
{
|
||||
return m_splitter->sizes();
|
||||
}
|
||||
|
||||
void DatabaseWidget::setSplitterSizes(const QList<int>& sizes)
|
||||
{
|
||||
m_splitter->setSizes(sizes);
|
||||
}
|
||||
|
||||
void DatabaseWidget::emitCurrentModeChanged()
|
||||
{
|
||||
|
@ -38,6 +38,7 @@ class GroupView;
|
||||
class KeePass1OpenWidget;
|
||||
class QFile;
|
||||
class QMenu;
|
||||
class QSplitter;
|
||||
class UnlockDatabaseWidget;
|
||||
|
||||
namespace Ui {
|
||||
@ -75,6 +76,8 @@ public:
|
||||
QStringList customEntryAttributes() const;
|
||||
bool isGroupSelected()const ;
|
||||
bool isInEditMode() const;
|
||||
QList<int> splitterSizes() const;
|
||||
void setSplitterSizes(const QList<int>& sizes);
|
||||
|
||||
Q_SIGNALS:
|
||||
void closeRequest();
|
||||
@ -85,6 +88,9 @@ Q_SIGNALS:
|
||||
void groupContextMenuRequested(const QPoint& globalPos);
|
||||
void entryContextMenuRequested(const QPoint& globalPos);
|
||||
void unlockedDatabase();
|
||||
void listModeActivated();
|
||||
void searchModeActivated();
|
||||
void splitterSizesChanged();
|
||||
|
||||
public Q_SLOTS:
|
||||
void createEntry();
|
||||
@ -147,6 +153,7 @@ private:
|
||||
DatabaseOpenWidget* m_databaseOpenWidget;
|
||||
KeePass1OpenWidget* m_keepass1OpenWidget;
|
||||
UnlockDatabaseWidget* m_unlockDatabaseWidget;
|
||||
QSplitter* m_splitter;
|
||||
GroupView* m_groupView;
|
||||
EntryView* m_entryView;
|
||||
Group* m_newGroup;
|
||||
|
72
src/gui/DatabaseWidgetStateSync.cpp
Normal file
72
src/gui/DatabaseWidgetStateSync.cpp
Normal file
@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Felix Geyer <debfx@fobos.de>
|
||||
* Copyright (C) 2014 Florian Geyer <blueice@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/>.
|
||||
*/
|
||||
|
||||
#include "DatabaseWidgetStateSync.h"
|
||||
|
||||
#include "core/Config.h"
|
||||
|
||||
DatabaseWidgetStateSync::DatabaseWidgetStateSync(QObject* parent)
|
||||
: QObject(parent)
|
||||
, m_activeDbWidget(Q_NULLPTR)
|
||||
{
|
||||
QVariantList variantList = config()->get("GUI/SplitterState").toList();
|
||||
Q_FOREACH (const QVariant& var, variantList) {
|
||||
bool ok;
|
||||
int size = var.toInt(&ok);
|
||||
if (ok) {
|
||||
m_splitterSizes.append(size);
|
||||
}
|
||||
else {
|
||||
m_splitterSizes.clear();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DatabaseWidgetStateSync::~DatabaseWidgetStateSync()
|
||||
{
|
||||
QVariantList variantList;
|
||||
Q_FOREACH (int size, m_splitterSizes) {
|
||||
variantList.append(size);
|
||||
}
|
||||
|
||||
config()->set("GUI/SplitterState", variantList);
|
||||
}
|
||||
|
||||
void DatabaseWidgetStateSync::setActive(DatabaseWidget* dbWidget)
|
||||
{
|
||||
if (m_activeDbWidget) {
|
||||
disconnect(m_activeDbWidget, 0, this, 0);
|
||||
}
|
||||
|
||||
m_activeDbWidget = dbWidget;
|
||||
|
||||
if (m_activeDbWidget) {
|
||||
if (!m_splitterSizes.isEmpty()) {
|
||||
m_activeDbWidget->setSplitterSizes(m_splitterSizes);
|
||||
}
|
||||
|
||||
connect(m_activeDbWidget, SIGNAL(splitterSizesChanged()),
|
||||
SLOT(updateSplitterSizes()));
|
||||
}
|
||||
}
|
||||
|
||||
void DatabaseWidgetStateSync::updateSplitterSizes()
|
||||
{
|
||||
m_splitterSizes = m_activeDbWidget->splitterSizes();
|
||||
}
|
44
src/gui/DatabaseWidgetStateSync.h
Normal file
44
src/gui/DatabaseWidgetStateSync.h
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Felix Geyer <debfx@fobos.de>
|
||||
* Copyright (C) 2014 Florian Geyer <blueice@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_HEADERVIEWSYNC_H
|
||||
#define KEEPASSX_HEADERVIEWSYNC_H
|
||||
|
||||
#include "gui/DatabaseWidget.h"
|
||||
|
||||
class DatabaseWidgetStateSync : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DatabaseWidgetStateSync(QObject* parent = Q_NULLPTR);
|
||||
~DatabaseWidgetStateSync();
|
||||
|
||||
public Q_SLOTS:
|
||||
void setActive(DatabaseWidget* dbWidget);
|
||||
|
||||
private Q_SLOTS:
|
||||
void updateSplitterSizes();
|
||||
|
||||
private:
|
||||
DatabaseWidget* m_activeDbWidget;
|
||||
|
||||
QList<int> m_splitterSizes;
|
||||
};
|
||||
|
||||
#endif // KEEPASSX_HEADERVIEWSYNC_H
|
Loading…
Reference in New Issue
Block a user