mirror of
https://github.com/KDE/latte-dock.git
synced 2025-08-30 09:49:25 +03:00
viewsdialog:concrete implementation for move
--these are the last pieces of code in order for moving active views between different active layouts to work properly
This commit is contained in:
@ -143,11 +143,11 @@ View::operator QString() const
|
|||||||
result +=" : ";
|
result +=" : ";
|
||||||
result += isActive ? "Active" : "Inactive";
|
result += isActive ? "Active" : "Inactive";
|
||||||
result +=" : ";
|
result +=" : ";
|
||||||
if (isMoveOrigin) {
|
if (m_state==OriginFromLayout && isMoveOrigin) {
|
||||||
result += " ↑ ";
|
result += " ↑ ";
|
||||||
} else if (isMoveDestination) {
|
} else if (m_state==OriginFromLayout && isMoveDestination) {
|
||||||
result += " ↓ ";
|
result += " ↓ ";
|
||||||
} else if (isMoveOrigin && isMoveDestination) {
|
} else if (m_state==OriginFromLayout && isMoveOrigin && isMoveDestination) {
|
||||||
result += " ↑↓ ";
|
result += " ↑↓ ";
|
||||||
} else {
|
} else {
|
||||||
result += " - ";
|
result += " - ";
|
||||||
|
@ -63,7 +63,7 @@ public:
|
|||||||
|
|
||||||
//! View sub-states
|
//! View sub-states
|
||||||
bool isMoveOrigin{false};
|
bool isMoveOrigin{false};
|
||||||
bool isMoveDestination{true};
|
bool isMoveDestination{false};
|
||||||
|
|
||||||
bool isValid() const;
|
bool isValid() const;
|
||||||
bool isCreated() const;
|
bool isCreated() const;
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
#include "delegates/singletextdelegate.h"
|
#include "delegates/singletextdelegate.h"
|
||||||
#include "../generic/generictools.h"
|
#include "../generic/generictools.h"
|
||||||
#include "../settingsdialog/templateskeeper.h"
|
#include "../settingsdialog/templateskeeper.h"
|
||||||
|
#include "../../layout/genericlayout.h"
|
||||||
#include "../../layout/centrallayout.h"
|
#include "../../layout/centrallayout.h"
|
||||||
#include "../../layouts/manager.h"
|
#include "../../layouts/manager.h"
|
||||||
#include "../../layouts/synchronizer.h"
|
#include "../../layouts/synchronizer.h"
|
||||||
@ -358,6 +359,21 @@ void Views::onCurrentLayoutChanged()
|
|||||||
{
|
{
|
||||||
Data::Layout layout = m_handler->currentData();
|
Data::Layout layout = m_handler->currentData();
|
||||||
m_model->setOriginalData(layout.views);
|
m_model->setOriginalData(layout.views);
|
||||||
|
|
||||||
|
//! track viewscountchanged signal for current active layout scenario
|
||||||
|
for (const auto &var : m_currentLayoutConnections) {
|
||||||
|
QObject::disconnect(var);
|
||||||
|
}
|
||||||
|
|
||||||
|
Data::Layout originlayoutdata = m_handler->layoutsController()->originalData(layout.id);
|
||||||
|
auto currentlayout = m_handler->layoutsController()->isLayoutOriginal(layout.id) ?
|
||||||
|
m_handler->corona()->layoutsManager()->synchronizer()->centralLayout(originlayoutdata.name) : nullptr;
|
||||||
|
|
||||||
|
if (currentlayout && currentlayout->isActive()) {
|
||||||
|
m_currentLayoutConnections << connect(currentlayout, &Layout::GenericLayout::viewsCountChanged, this, [&, currentlayout](){
|
||||||
|
m_model->updateActiveStatesBasedOn(currentlayout);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Views::onSelectionsChanged()
|
void Views::onSelectionsChanged()
|
||||||
@ -407,9 +423,40 @@ CentralLayout *Views::originLayout(const Data::View &view)
|
|||||||
return originactive;
|
return originactive;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Views::updateDoubledMoveDestinationRows() {
|
||||||
|
//! only one isMoveDestination should exist for each unique move isMoveOrigin case
|
||||||
|
//! all the rest that have been created through Cut/Paste or Duplicate options should become
|
||||||
|
//! simple OriginFromViewTemplate cases
|
||||||
|
|
||||||
|
for (int i=0; i<m_model->rowCount(); ++i) {
|
||||||
|
Data::View baseview = m_model->at(i);
|
||||||
|
|
||||||
|
if (!baseview.isMoveDestination || baseview.state()!=Data::View::OriginFromLayout) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int j=i+1; j<m_model->rowCount(); ++j) {
|
||||||
|
Data::View subsequentview = m_model->at(j);
|
||||||
|
|
||||||
|
if (subsequentview.isMoveDestination
|
||||||
|
&& subsequentview.state() == Data::View::OriginFromLayout
|
||||||
|
&& subsequentview.originFile() == baseview.originFile()
|
||||||
|
&& subsequentview.originLayout() == baseview.originLayout()
|
||||||
|
&& subsequentview.originView() == baseview.originView()) {
|
||||||
|
//! this is a subsequent view that needs to be updated properly
|
||||||
|
subsequentview.isMoveDestination = false;
|
||||||
|
subsequentview.isMoveOrigin = false;
|
||||||
|
subsequentview.setState(Data::View::OriginFromViewTemplate, subsequentview.originFile(), QString(), QString());
|
||||||
|
m_model->updateCurrentView(subsequentview.id, subsequentview);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Views::save()
|
void Views::save()
|
||||||
{
|
{
|
||||||
//! when this function is called we consider that removal has already been approved
|
//! when this function is called we consider that removal has already been approved
|
||||||
|
updateDoubledMoveDestinationRows();
|
||||||
|
|
||||||
Latte::Data::Layout originallayout = m_handler->originalData();
|
Latte::Data::Layout originallayout = m_handler->originalData();
|
||||||
Latte::Data::Layout currentlayout = m_handler->currentData();
|
Latte::Data::Layout currentlayout = m_handler->currentData();
|
||||||
@ -426,6 +473,9 @@ void Views::save()
|
|||||||
QHash<QString, Data::View> cuttedpastedviews;
|
QHash<QString, Data::View> cuttedpastedviews;
|
||||||
QHash<QString, Data::View> cuttedpastedactiveviews;
|
QHash<QString, Data::View> cuttedpastedactiveviews;
|
||||||
|
|
||||||
|
m_debugSaveCall++;
|
||||||
|
qDebug() << "org.kde.latte ViewsDialog::save() call: " << m_debugSaveCall << "-------- ";
|
||||||
|
|
||||||
//! add new views that are accepted
|
//! add new views that are accepted
|
||||||
for(int i=0; i<newViews.rowCount(); ++i){
|
for(int i=0; i<newViews.rowCount(); ++i){
|
||||||
if (newViews[i].isMoveDestination) {
|
if (newViews[i].isMoveDestination) {
|
||||||
@ -456,7 +506,7 @@ void Views::save()
|
|||||||
//! update altered views
|
//! update altered views
|
||||||
for (int i=0; i<alteredViews.rowCount(); ++i) {
|
for (int i=0; i<alteredViews.rowCount(); ++i) {
|
||||||
if (alteredViews[i].state() == Data::View::IsCreated && !alteredViews[i].isMoveOrigin) {
|
if (alteredViews[i].state() == Data::View::IsCreated && !alteredViews[i].isMoveOrigin) {
|
||||||
qDebug() << "org.kde.latte updating altered view :: " << alteredViews[i];
|
qDebug() << "org.kde.latte ViewsDialog::save() updating altered view :: " << alteredViews[i];
|
||||||
central->updateView(alteredViews[i]);
|
central->updateView(alteredViews[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -465,6 +515,7 @@ void Views::save()
|
|||||||
Latte::Data::ViewsTable removedViews = originalViews.subtracted(currentViews);
|
Latte::Data::ViewsTable removedViews = originalViews.subtracted(currentViews);
|
||||||
|
|
||||||
for (int i=0; i<removedViews.rowCount(); ++i) {
|
for (int i=0; i<removedViews.rowCount(); ++i) {
|
||||||
|
qDebug() << "org.kde.latte ViewsDialog::save() real removing view :: " << removedViews[i];
|
||||||
central->removeView(removedViews[i]);
|
central->removeView(removedViews[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -479,6 +530,8 @@ void Views::save()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qDebug() << "org.kde.latte ViewsDialog::save() removing cut-pasted view :: " << cuttedpastedviews[vid];
|
||||||
|
|
||||||
//! Be Careful: Remove deprecated views from Cut->Paste Action
|
//! Be Careful: Remove deprecated views from Cut->Paste Action
|
||||||
QString origincurrentid = cuttedpastedviews[vid].originLayout();
|
QString origincurrentid = cuttedpastedviews[vid].originLayout();
|
||||||
Data::Layout originlayout = m_handler->layoutsController()->originalData(origincurrentid);
|
Data::Layout originlayout = m_handler->layoutsController()->originalData(origincurrentid);
|
||||||
@ -507,6 +560,8 @@ void Views::save()
|
|||||||
QString tempviewid = pastedactiveview.id;
|
QString tempviewid = pastedactiveview.id;
|
||||||
pastedactiveview.id = QString::number(originviewid);
|
pastedactiveview.id = QString::number(originviewid);
|
||||||
|
|
||||||
|
qDebug() << "org.kde.latte ViewsDialog::save() move to another layout cutted-pasted active view :: " << pastedactiveview;
|
||||||
|
|
||||||
if (view) {
|
if (view) {
|
||||||
//! onscreen_view->onscreen_view
|
//! onscreen_view->onscreen_view
|
||||||
//! onscreen_view->offscreen_view
|
//! onscreen_view->offscreen_view
|
||||||
@ -619,3 +674,4 @@ void Views::saveConfig()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,6 +32,8 @@
|
|||||||
#include <QAbstractItemModel>
|
#include <QAbstractItemModel>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include <QItemSelection>
|
#include <QItemSelection>
|
||||||
|
#include <QList>
|
||||||
|
#include <QMetaObject>
|
||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
#include <QTableView>
|
#include <QTableView>
|
||||||
|
|
||||||
@ -114,11 +116,18 @@ private slots:
|
|||||||
void onCurrentLayoutChanged();
|
void onCurrentLayoutChanged();
|
||||||
void onSelectionsChanged();
|
void onSelectionsChanged();
|
||||||
|
|
||||||
|
void updateDoubledMoveDestinationRows();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Settings::Handler::ViewsHandler *m_handler{nullptr};
|
Settings::Handler::ViewsHandler *m_handler{nullptr};
|
||||||
|
|
||||||
Settings::View::ViewsTableView *m_view{nullptr};
|
Settings::View::ViewsTableView *m_view{nullptr};
|
||||||
|
|
||||||
|
int m_debugSaveCall{0};
|
||||||
|
|
||||||
|
//! current active layout signals/slots
|
||||||
|
QList<QMetaObject::Connection> m_currentLayoutConnections;
|
||||||
|
|
||||||
//! layoutsView ui settings
|
//! layoutsView ui settings
|
||||||
int m_viewSortColumn{Model::Views::SCREENCOLUMN};
|
int m_viewSortColumn{Model::Views::SCREENCOLUMN};
|
||||||
Qt::SortOrder m_viewSortOrder;
|
Qt::SortOrder m_viewSortOrder;
|
||||||
|
Reference in New Issue
Block a user