1
0
mirror of https://github.com/KDE/latte-dock.git synced 2024-12-24 05:33:50 +03:00

organize new>layout templates action menu

This commit is contained in:
Michail Vourlakos 2021-02-16 16:46:52 +02:00
parent 5b9ec2ee06
commit da3fbca477
3 changed files with 18 additions and 4 deletions

View File

@ -36,6 +36,7 @@
#include "../../layouts/importer.h"
#include "../../layouts/manager.h"
#include "../../templates/templatesmanager.h"
#include "../../tools/commontools.h"
//! Qt
#include <QDBusInterface>
@ -250,11 +251,14 @@ void TabLayouts::initLayoutTemplatesSubMenu()
}
/*Add Layout Templates for New Action*/
Data::LayoutsTable templates = m_corona->templatesManager()->systemLayoutTemplates();
Data::LayoutsTable templates = m_corona->templatesManager()->layoutTemplates();
bool customtemplateseparatoradded{false};
for (int i=0; i<templates.rowCount(); ++i) {
if (i==2) {
if (!customtemplateseparatoradded && !templates[i].isSystemTemplate()) {
m_layoutTemplatesSubMenu->addSeparator();
customtemplateseparatoradded = true;
}
QAction *newlayout = m_layoutTemplatesSubMenu->addAction(templates[i].name);
@ -265,6 +269,16 @@ void TabLayouts::initLayoutTemplatesSubMenu()
newLayout(templatename);
});
}
if (templates.rowCount() > 0) {
QAction *openTemplatesDirectory = m_layoutTemplatesSubMenu->addAction(i18n("Templates..."));
openTemplatesDirectory->setToolTip(i18n("Open templates directory"));
openTemplatesDirectory->setIcon(QIcon::fromTheme("edit"));
connect(openTemplatesDirectory, &QAction::triggered, this, [&]() {
KIO::highlightInFileManager({QString(Latte::configPath() + "/latte/templates/Dock.layout.latte")});
});
}
}
Latte::Corona *TabLayouts::corona() const

View File

@ -131,7 +131,7 @@ Data::Layout Manager::layoutTemplateForName(const QString &layoutName)
return Data::Layout();
}
Data::LayoutsTable Manager::systemLayoutTemplates()
Data::LayoutsTable Manager::layoutTemplates()
{
Data::LayoutsTable templates;

View File

@ -65,7 +65,7 @@ public:
Data::Layout layoutTemplateForName(const QString &layoutName);
Data::LayoutsTable systemLayoutTemplates();
Data::LayoutsTable layoutTemplates();
Data::GenericTable<Data::Generic> viewTemplates();
//! creates a new layout with layoutName based on specific layout template and returns the new layout path