mirror of
https://github.com/KDE/latte-dock.git
synced 2024-12-23 01:33:50 +03:00
expose view templates through dock settings
--the user can now add views based on view templates found in the system through Dock Settings, New Dock actions
This commit is contained in:
parent
390ea0596c
commit
09654e75b3
@ -907,6 +907,11 @@ void Corona::aboutApplication()
|
||||
aboutDialog->show();
|
||||
}
|
||||
|
||||
void Corona::loadDefaultLayout()
|
||||
{
|
||||
//disabled
|
||||
}
|
||||
|
||||
int Corona::screenForContainment(const Plasma::Containment *containment) const
|
||||
{
|
||||
//FIXME: indexOf is not a proper way to support multi-screen
|
||||
@ -1030,61 +1035,6 @@ void Corona::alternativesVisibilityChanged(bool visible)
|
||||
}
|
||||
}
|
||||
|
||||
void Corona::addViewForLayout(QString layoutName)
|
||||
{
|
||||
qDebug() << "loading default layout";
|
||||
//! Setting mutable for create a containment
|
||||
setImmutability(Plasma::Types::Mutable);
|
||||
QVariantList args;
|
||||
auto defaultContainment = createContainmentDelayed("org.kde.latte.containment", args);
|
||||
defaultContainment->setContainmentType(Plasma::Types::PanelContainment);
|
||||
defaultContainment->init();
|
||||
|
||||
if (!defaultContainment || !defaultContainment->kPackage().isValid()) {
|
||||
qWarning() << "the requested containment plugin can not be located or loaded";
|
||||
return;
|
||||
}
|
||||
|
||||
auto config = defaultContainment->config();
|
||||
defaultContainment->restore(config);
|
||||
|
||||
using Plasma::Types;
|
||||
QList<Types::Location> edges{Types::BottomEdge, Types::LeftEdge,
|
||||
Types::TopEdge, Types::RightEdge};
|
||||
|
||||
Layout::GenericLayout *currentLayout = m_layoutsManager->synchronizer()->layout(layoutName);
|
||||
|
||||
if (currentLayout) {
|
||||
edges = currentLayout->freeEdges(defaultContainment->screen());
|
||||
}
|
||||
|
||||
if ((edges.count() > 0)) {
|
||||
defaultContainment->setLocation(edges.at(0));
|
||||
} else {
|
||||
defaultContainment->setLocation(Plasma::Types::BottomEdge);
|
||||
}
|
||||
|
||||
if (m_layoutsManager->memoryUsage() == MemoryUsage::MultipleLayouts) {
|
||||
config.writeEntry("layoutId", layoutName);
|
||||
}
|
||||
|
||||
defaultContainment->updateConstraints(Plasma::Types::StartupCompletedConstraint);
|
||||
|
||||
defaultContainment->save(config);
|
||||
requestConfigSync();
|
||||
|
||||
defaultContainment->flushPendingConstraintsEvents();
|
||||
emit containmentAdded(defaultContainment);
|
||||
emit containmentCreated(defaultContainment);
|
||||
|
||||
defaultContainment->createApplet(QStringLiteral("org.kde.latte.plasmoid"));
|
||||
}
|
||||
|
||||
void Corona::loadDefaultLayout()
|
||||
{
|
||||
// addViewForLayout(m_layoutsManager->currentLayoutsNames());
|
||||
}
|
||||
|
||||
QStringList Corona::containmentsIds()
|
||||
{
|
||||
QStringList ids;
|
||||
|
@ -163,7 +163,6 @@ public:
|
||||
|
||||
public slots:
|
||||
void aboutApplication();
|
||||
void addViewForLayout(QString layoutName);
|
||||
void activateLauncherMenu();
|
||||
void loadDefaultLayout() override;
|
||||
void setBackgroundFromBroadcast(QString activity, QString screenName, QString filename);
|
||||
|
@ -768,16 +768,6 @@ void GenericLayout::renameLayout(QString newName)
|
||||
}
|
||||
}
|
||||
|
||||
void GenericLayout::addNewView()
|
||||
{
|
||||
if (!m_corona) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_corona->addViewForLayout(name());
|
||||
emit viewEdgeChanged();
|
||||
}
|
||||
|
||||
void GenericLayout::addView(Plasma::Containment *containment, bool forceOnPrimary, int explicitScreen, Layout::ViewsMap *occupied)
|
||||
{
|
||||
qDebug() << "Layout :::: " << m_layoutName << " ::: addView was called... m_containments :: " << m_containments.size();
|
||||
@ -1685,6 +1675,24 @@ void GenericLayout::copyView(Plasma::Containment *containment)
|
||||
emit viewEdgeChanged();
|
||||
}
|
||||
|
||||
void GenericLayout::newView(const QString &templateFile)
|
||||
{
|
||||
//! Don't create LatteView when the containment is created because we must update its screen settings first
|
||||
setBlockAutomaticLatteViewCreation(true);
|
||||
|
||||
Layouts::ViewDelayedCreationData result = Layouts::Storage::self()->newView(this, templateFile);
|
||||
if (result.containment) {
|
||||
addView(result.containment, result.forceOnPrimary, result.explicitScreen);
|
||||
|
||||
if (result.reactToScreenChange) {
|
||||
result.containment->reactToScreenChange();
|
||||
}
|
||||
}
|
||||
|
||||
setBlockAutomaticLatteViewCreation(false);
|
||||
emit viewEdgeChanged();
|
||||
}
|
||||
|
||||
void GenericLayout::importToCorona()
|
||||
{
|
||||
Layouts::Storage::self()->importToCorona(this);
|
||||
|
@ -146,7 +146,7 @@ public:
|
||||
QList<int> viewsScreens();
|
||||
|
||||
public slots:
|
||||
Q_INVOKABLE void addNewView();
|
||||
Q_INVOKABLE void newView(const QString &templateFile);
|
||||
Q_INVOKABLE int viewsWithTasks() const;
|
||||
virtual Q_INVOKABLE QList<int> qmlFreeEdges(int screen) const; //change <Plasma::Types::Location> to <int> types
|
||||
|
||||
|
@ -544,19 +544,23 @@ ViewDelayedCreationData Storage::newView(const Layout::GenericLayout *destinatio
|
||||
Plasma::Containment *newContainment = (importedViews.size() == 1 ? importedViews[0] : nullptr);
|
||||
|
||||
if (!newContainment || !newContainment->kPackage().isValid()) {
|
||||
qWarning() << "the requested containment plugin can not be located or loaded";
|
||||
qWarning() << "the requested containment plugin can not be located or loaded from:" << templateFile;
|
||||
return ViewDelayedCreationData();
|
||||
}
|
||||
|
||||
auto config = newContainment->config();
|
||||
int primaryScrId = destination->corona()->screenPool()->primaryScreenId();
|
||||
|
||||
QList<Plasma::Types::Location> edges = destination->freeEdges(newContainment->screen());
|
||||
QList<Plasma::Types::Location> edges = destination->freeEdges(primaryScrId);
|
||||
qDebug() << "org.kde.latte current template edge : " << newContainment->location() << " free edges :: " << edges;
|
||||
|
||||
if (edges.count() > 0) {
|
||||
newContainment->setLocation(edges.at(0));
|
||||
} else {
|
||||
newContainment->setLocation(Plasma::Types::BottomEdge);
|
||||
//! if selected template screen edge is not free
|
||||
if (!edges.contains(newContainment->location())) {
|
||||
if (edges.count() > 0) {
|
||||
newContainment->setLocation(edges.at(0));
|
||||
} else {
|
||||
newContainment->setLocation(Plasma::Types::BottomEdge);
|
||||
}
|
||||
}
|
||||
|
||||
config.writeEntry("onPrimary", true);
|
||||
|
@ -530,7 +530,7 @@ Loader {
|
||||
var item = actionsModel.get(index);
|
||||
|
||||
if (item.actionId === "new:") {
|
||||
|
||||
latteView.layout.newView(item.templateId);
|
||||
} else if (item.actionId === "copy:") {
|
||||
latteView.copyView();
|
||||
} else if (item.actionId === "move:") {
|
||||
@ -552,7 +552,7 @@ Loader {
|
||||
|
||||
Connections{
|
||||
target: actionsComboBtn.button
|
||||
onClicked: latteView.layout.addNewView();
|
||||
onClicked: latteView.layout.newView(layoutsManager.viewTemplateIds()[0])
|
||||
}
|
||||
|
||||
Connections{
|
||||
|
@ -7,7 +7,7 @@ formfactor=2
|
||||
immutability=1
|
||||
isPreferredForShortcuts=false
|
||||
lastScreen=-1
|
||||
location=4
|
||||
location=3
|
||||
onPrimary=true
|
||||
plugin=org.kde.latte.containment
|
||||
raiseOnActivityChange=false
|
||||
|
Loading…
Reference in New Issue
Block a user