|
|
|
@ -34,9 +34,11 @@
|
|
|
|
|
//! KDE
|
|
|
|
|
#include <KWindowSystem>
|
|
|
|
|
#include <KLocalizedString>
|
|
|
|
|
#include <KActivities/Controller>
|
|
|
|
|
#include <PlasmaActivities/Controller>
|
|
|
|
|
#include <KIO/OpenFileManagerWindowJob>
|
|
|
|
|
#include <KNewStuff3/KNS3/DownloadDialog>
|
|
|
|
|
|
|
|
|
|
//! KNewStuff
|
|
|
|
|
#include <KNSWidgets/Dialog>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace Latte {
|
|
|
|
@ -86,16 +88,16 @@ void TabLayouts::initUi()
|
|
|
|
|
connect(this, &Settings::Handler::TabLayouts::dataChanged, this, &TabLayouts::updatePerLayoutButtonsState);
|
|
|
|
|
connect(m_corona->activitiesConsumer(), &KActivities::Consumer::runningActivitiesChanged, this, &TabLayouts::updatePerLayoutButtonsState);
|
|
|
|
|
|
|
|
|
|
connect(m_inMemoryButtons, static_cast<void(QButtonGroup::*)(int, bool)>(&QButtonGroup::buttonToggled),
|
|
|
|
|
[ = ](int id, bool checked) {
|
|
|
|
|
connect(m_inMemoryButtons, &QButtonGroup::buttonToggled,
|
|
|
|
|
[ this ](int id, bool checked) {
|
|
|
|
|
|
|
|
|
|
if (checked) {
|
|
|
|
|
m_layoutsController->setInMultipleMode(id == MemoryUsage::MultipleLayouts);
|
|
|
|
|
this->m_layoutsController->setInMultipleMode(id == MemoryUsage::MultipleLayouts);
|
|
|
|
|
|
|
|
|
|
if (id == MemoryUsage::MultipleLayouts) {
|
|
|
|
|
m_layoutsController->sortByColumn(Model::Layouts::ACTIVITYCOLUMN, Qt::AscendingOrder);
|
|
|
|
|
this->m_layoutsController->sortByColumn(Model::Layouts::ACTIVITYCOLUMN, Qt::AscendingOrder);
|
|
|
|
|
} else {
|
|
|
|
|
m_layoutsController->sortByColumn(Model::Layouts::NAMECOLUMN, Qt::AscendingOrder);
|
|
|
|
|
this->m_layoutsController->sortByColumn(Model::Layouts::NAMECOLUMN, Qt::AscendingOrder);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
@ -116,14 +118,14 @@ void TabLayouts::initLayoutMenu()
|
|
|
|
|
m_switchLayoutAction = m_layoutMenu->addAction(i18nc("switch layout","Switch"));
|
|
|
|
|
m_switchLayoutAction->setToolTip(i18n("Switch to selected layout"));
|
|
|
|
|
m_switchLayoutAction->setIcon(QIcon::fromTheme("user-identity"));
|
|
|
|
|
m_switchLayoutAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Tab));
|
|
|
|
|
m_switchLayoutAction->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_Tab));
|
|
|
|
|
connectActionWithButton(m_ui->switchButton, m_switchLayoutAction);
|
|
|
|
|
connect(m_switchLayoutAction, &QAction::triggered, this, &TabLayouts::switchLayout);
|
|
|
|
|
|
|
|
|
|
m_activitiesManagerAction = m_layoutMenu->addAction(i18n("&Activities"));
|
|
|
|
|
m_activitiesManagerAction->setToolTip(i18n("Show Plasma Activities manager"));
|
|
|
|
|
m_activitiesManagerAction->setIcon(QIcon::fromTheme("activities"));
|
|
|
|
|
m_activitiesManagerAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_A));
|
|
|
|
|
m_activitiesManagerAction->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_A));
|
|
|
|
|
connectActionWithButton(m_ui->activitiesButton, m_activitiesManagerAction);
|
|
|
|
|
connect(m_activitiesManagerAction, &QAction::triggered, this, &TabLayouts::toggleActivitiesManager);
|
|
|
|
|
|
|
|
|
@ -132,7 +134,7 @@ void TabLayouts::initLayoutMenu()
|
|
|
|
|
m_newLayoutAction = m_layoutMenu->addAction(i18nc("new layout", "&New"));
|
|
|
|
|
m_newLayoutAction->setToolTip(i18n("New layout"));
|
|
|
|
|
m_newLayoutAction->setIcon(QIcon::fromTheme("add"));
|
|
|
|
|
m_newLayoutAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_N));
|
|
|
|
|
m_newLayoutAction->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_N));
|
|
|
|
|
connectActionWithButton(m_ui->newButton, m_newLayoutAction);
|
|
|
|
|
connect(m_newLayoutAction, &QAction::triggered, m_ui->newButton, &QPushButton::showMenu);
|
|
|
|
|
|
|
|
|
@ -145,7 +147,7 @@ void TabLayouts::initLayoutMenu()
|
|
|
|
|
m_duplicateLayoutAction = m_layoutMenu->addAction(i18nc("duplicate layout", "&Duplicate"));
|
|
|
|
|
m_duplicateLayoutAction->setToolTip(i18n("Duplicate selected layout"));
|
|
|
|
|
m_duplicateLayoutAction->setIcon(QIcon::fromTheme("edit-copy"));
|
|
|
|
|
m_duplicateLayoutAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_D));
|
|
|
|
|
m_duplicateLayoutAction->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_D));
|
|
|
|
|
connectActionWithButton(m_ui->duplicateButton, m_duplicateLayoutAction);
|
|
|
|
|
connect(m_duplicateLayoutAction, &QAction::triggered, this, &TabLayouts::duplicateLayout);
|
|
|
|
|
|
|
|
|
@ -162,7 +164,7 @@ void TabLayouts::initLayoutMenu()
|
|
|
|
|
m_enabledLayoutAction = m_layoutMenu->addAction(i18n("Ena&bled"));
|
|
|
|
|
m_enabledLayoutAction->setToolTip(i18n("Assign in activities in order to be activated through Plasma Activities"));
|
|
|
|
|
m_enabledLayoutAction->setIcon(QIcon::fromTheme("edit-link"));
|
|
|
|
|
m_enabledLayoutAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B));
|
|
|
|
|
m_enabledLayoutAction->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_B));
|
|
|
|
|
m_enabledLayoutAction->setCheckable(true);
|
|
|
|
|
connectActionWithButton(m_ui->enabledButton, m_enabledLayoutAction);
|
|
|
|
|
connect(m_enabledLayoutAction, &QAction::triggered, this, &TabLayouts::toggleEnabledLayout);
|
|
|
|
@ -170,7 +172,7 @@ void TabLayouts::initLayoutMenu()
|
|
|
|
|
m_readOnlyLayoutAction = m_layoutMenu->addAction(i18nc("read only layout", "&Read Only"));
|
|
|
|
|
m_readOnlyLayoutAction->setToolTip(i18n("Make selected layout read-only"));
|
|
|
|
|
m_readOnlyLayoutAction->setIcon(QIcon::fromTheme("object-locked"));
|
|
|
|
|
m_readOnlyLayoutAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_R));
|
|
|
|
|
m_readOnlyLayoutAction->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_R));
|
|
|
|
|
m_readOnlyLayoutAction->setCheckable(true);
|
|
|
|
|
connectActionWithButton(m_ui->readOnlyButton, m_readOnlyLayoutAction);
|
|
|
|
|
connect(m_readOnlyLayoutAction, &QAction::triggered, this, &TabLayouts::lockLayout);
|
|
|
|
@ -178,14 +180,14 @@ void TabLayouts::initLayoutMenu()
|
|
|
|
|
m_viewsAction = m_layoutMenu->addAction(i18nc("layout docks / panels", "Docks, &Panels..."));
|
|
|
|
|
m_viewsAction->setToolTip(i18n("Show selected layouts docks and panels"));
|
|
|
|
|
m_viewsAction->setIcon(QIcon::fromTheme("window"));
|
|
|
|
|
m_viewsAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_P));
|
|
|
|
|
m_viewsAction->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_P));
|
|
|
|
|
connectActionWithButton(m_ui->viewsBtn, m_viewsAction);
|
|
|
|
|
connect(m_viewsAction, &QAction::triggered, this, &TabLayouts::showViewsDialog);
|
|
|
|
|
|
|
|
|
|
m_detailsAction = m_layoutMenu->addAction(i18nc("layout details", "De&tails..."));
|
|
|
|
|
m_detailsAction->setToolTip(i18n("Show selected layout details"));
|
|
|
|
|
m_detailsAction->setIcon(QIcon::fromTheme("view-list-details"));
|
|
|
|
|
m_detailsAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_T));
|
|
|
|
|
m_detailsAction->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_T));
|
|
|
|
|
connectActionWithButton(m_ui->detailsButton, m_detailsAction);
|
|
|
|
|
connect(m_detailsAction, &QAction::triggered, this, &TabLayouts::showDetailsDialog);
|
|
|
|
|
|
|
|
|
@ -196,7 +198,7 @@ void TabLayouts::initLayoutMenu()
|
|
|
|
|
m_importLayoutAction = m_layoutMenu->addAction(i18nc("import layout", "&Import"));
|
|
|
|
|
m_importLayoutAction->setToolTip(i18n("Import layout from various resources"));
|
|
|
|
|
m_importLayoutAction->setIcon(QIcon::fromTheme("document-import"));
|
|
|
|
|
m_importLayoutAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_I));
|
|
|
|
|
m_importLayoutAction->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_I));
|
|
|
|
|
connectActionWithButton(m_ui->importButton, m_importLayoutAction);
|
|
|
|
|
connect(m_importLayoutAction, &QAction::triggered, m_ui->importButton, &QPushButton::showMenu);
|
|
|
|
|
|
|
|
|
@ -208,7 +210,7 @@ void TabLayouts::initLayoutMenu()
|
|
|
|
|
m_exportLayoutAction = m_layoutMenu->addAction(i18nc("export layout", "&Export"));
|
|
|
|
|
m_exportLayoutAction->setToolTip(i18n("Export selected layout at your system"));
|
|
|
|
|
m_exportLayoutAction->setIcon(QIcon::fromTheme("document-export"));
|
|
|
|
|
m_exportLayoutAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_E));
|
|
|
|
|
m_exportLayoutAction->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_E));
|
|
|
|
|
connectActionWithButton(m_ui->exportButton, m_exportLayoutAction);
|
|
|
|
|
connect(m_exportLayoutAction, &QAction::triggered, m_ui->exportButton, &QPushButton::showMenu);
|
|
|
|
|
|
|
|
|
@ -228,12 +230,12 @@ void TabLayouts::initImportLayoutSubMenu()
|
|
|
|
|
|
|
|
|
|
QAction *importLayoutAction = m_layoutImportSubMenu->addAction(i18nc("import layout", "&Import From Local File..."));
|
|
|
|
|
importLayoutAction->setIcon(QIcon::fromTheme("document-import"));
|
|
|
|
|
importLayoutAction->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_I));
|
|
|
|
|
importLayoutAction->setShortcut(QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_I));
|
|
|
|
|
connect(importLayoutAction, &QAction::triggered, this, &TabLayouts::importLayout);
|
|
|
|
|
|
|
|
|
|
QAction *downloadLayoutAction = m_layoutImportSubMenu->addAction(i18nc("download layout", "Import From K&DE Online Store..."));
|
|
|
|
|
downloadLayoutAction->setIcon(QIcon::fromTheme("get-hot-new-stuff"));
|
|
|
|
|
downloadLayoutAction->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_D));
|
|
|
|
|
downloadLayoutAction->setShortcut(QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_D));
|
|
|
|
|
connect(downloadLayoutAction, &QAction::triggered, this, &TabLayouts::downloadLayout);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -248,12 +250,12 @@ void TabLayouts::initExportLayoutSubMenu()
|
|
|
|
|
|
|
|
|
|
QAction *exportForBackup = m_layoutExportSubMenu->addAction(i18nc("export for backup","&Export For Backup..."));
|
|
|
|
|
exportForBackup->setIcon(QIcon::fromTheme("document-export"));
|
|
|
|
|
exportForBackup->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_E));
|
|
|
|
|
exportForBackup->setShortcut(QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_E));
|
|
|
|
|
connect(exportForBackup, &QAction::triggered, this, &TabLayouts::exportLayoutForBackup);
|
|
|
|
|
|
|
|
|
|
QAction *exportAsTemplate = m_layoutExportSubMenu->addAction(i18nc("export as template","Export As &Template..."));
|
|
|
|
|
exportAsTemplate->setIcon(QIcon::fromTheme("document-export"));
|
|
|
|
|
exportAsTemplate->setShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_T));
|
|
|
|
|
exportAsTemplate->setShortcut(QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_T));
|
|
|
|
|
connect(exportAsTemplate, &QAction::triggered, this, &TabLayouts::exportLayoutAsTemplate);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -466,12 +468,14 @@ void TabLayouts::downloadLayout()
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
KNS3::DownloadDialog dialog(QStringLiteral("latte-layouts.knsrc"), m_parentDialog);
|
|
|
|
|
KNSWidgets::Dialog dialog(QStringLiteral("latte-layouts.knsrc"), m_parentDialog);
|
|
|
|
|
dialog.resize(m_parentDialog->downloadWindowSize());
|
|
|
|
|
dialog.exec();
|
|
|
|
|
|
|
|
|
|
if (!dialog.changedEntries().isEmpty() && !dialog.installedEntries().isEmpty()) {
|
|
|
|
|
for (const auto &entry : dialog.installedEntries()) {
|
|
|
|
|
if (!dialog.changedEntries().isEmpty() /* && !dialog.installedEntries().isEmpty() */) {
|
|
|
|
|
//for (const auto &entry : dialog.installedEntries()) {
|
|
|
|
|
// FIXME: Check if this actually works lol
|
|
|
|
|
for (const KNSCore::Entry &entry : dialog.changedEntries()) {
|
|
|
|
|
for (const auto &entryFile : entry.installedFiles()) {
|
|
|
|
|
Latte::Layouts::Importer::LatteFileVersion version = Latte::Layouts::Importer::fileVersion(entryFile);
|
|
|
|
|
|
|
|
|
@ -817,7 +821,7 @@ void TabLayouts::onCurrentPageChanged()
|
|
|
|
|
|
|
|
|
|
void TabLayouts::onDragEnterEvent(QDragEnterEvent *event)
|
|
|
|
|
{
|
|
|
|
|
if (!isHoveringLayoutsTable(event->pos())) {
|
|
|
|
|
if (!isHoveringLayoutsTable(event->position().toPoint())) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -827,12 +831,13 @@ void TabLayouts::onDragEnterEvent(QDragEnterEvent *event)
|
|
|
|
|
|
|
|
|
|
void TabLayouts::onDragLeaveEvent(QDragLeaveEvent *event)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(event);
|
|
|
|
|
m_ui->layoutsView->dragLeft();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TabLayouts::onDragMoveEvent(QDragMoveEvent *event)
|
|
|
|
|
{
|
|
|
|
|
if (!isHoveringLayoutsTable(event->pos())) {
|
|
|
|
|
if (!isHoveringLayoutsTable(event->position().toPoint())) {
|
|
|
|
|
event->ignore();
|
|
|
|
|
m_ui->layoutsView->dragLeft();
|
|
|
|
|
return;
|
|
|
|
@ -843,7 +848,7 @@ void TabLayouts::onDragMoveEvent(QDragMoveEvent *event)
|
|
|
|
|
|
|
|
|
|
void TabLayouts::onDropEvent(QDropEvent *event)
|
|
|
|
|
{
|
|
|
|
|
if (!isHoveringLayoutsTable(event->pos())) {
|
|
|
|
|
if (!isHoveringLayoutsTable(event->position().toPoint())) {
|
|
|
|
|
event->ignore();
|
|
|
|
|
m_ui->layoutsView->dragLeft();
|
|
|
|
|
return;
|
|
|
|
|