mirror of
https://github.com/KDE/latte-dock.git
synced 2025-01-01 01:17:51 +03:00
add new menu options and edit layout file action
This commit is contained in:
parent
79f392723e
commit
714b41ec2f
@ -154,14 +154,31 @@ SettingsDialog::SettingsDialog(QWidget *parent, Latte::Corona *corona)
|
||||
QMenu *fileMenu = new QMenu(i18n("File"), menuBar);
|
||||
menuBar->addMenu(fileMenu);
|
||||
|
||||
QMenu *layoutMenu = new QMenu(i18n("Layout"), menuBar);
|
||||
//rightAlignedMenuBar->addMenu(helpMenu);
|
||||
menuBar->addMenu(layoutMenu);
|
||||
|
||||
QMenu *helpMenu = new QMenu(i18n("Help"), menuBar);
|
||||
//rightAlignedMenuBar->addMenu(helpMenu);
|
||||
menuBar->addMenu(helpMenu);
|
||||
|
||||
QAction *quitAction = fileMenu->addAction(i18n("Quit Latte"));
|
||||
QAction *screensAction = fileMenu->addAction(i18n("Sc&reens..."));
|
||||
screensAction->setIcon(QIcon::fromTheme("view-list-details"));
|
||||
screensAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_R));
|
||||
|
||||
QAction *quitAction = fileMenu->addAction(i18n("&Quit Latte"));
|
||||
quitAction->setIcon(QIcon::fromTheme("application-exit"));
|
||||
quitAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q));
|
||||
|
||||
m_editLayoutAction = layoutMenu->addAction(i18nc("edit layout","&Edit..."));
|
||||
m_editLayoutAction->setIcon(QIcon::fromTheme("document-edit"));
|
||||
m_editLayoutAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_E));
|
||||
m_editLayoutAction->setToolTip("You can edit layout file when layout is not active or locked");
|
||||
|
||||
QAction *infoLayoutAction = layoutMenu->addAction(i18nc("layout information","&Information..."));
|
||||
infoLayoutAction->setIcon(QIcon::fromTheme("view-list-details"));
|
||||
infoLayoutAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_I));
|
||||
|
||||
QAction *aboutAction = helpMenu->addAction(i18n("About Latte"));
|
||||
aboutAction->setIcon(QIcon::fromTheme("latte-dock"));
|
||||
|
||||
@ -227,6 +244,14 @@ SettingsDialog::SettingsDialog(QWidget *parent, Latte::Corona *corona)
|
||||
m_corona->closeApplication();
|
||||
});
|
||||
|
||||
connect(m_editLayoutAction, &QAction::triggered, this, [&]() {
|
||||
QString file = idForRow(ui->layoutsView->currentIndex().row());
|
||||
|
||||
if (!file.isEmpty()) {
|
||||
QProcess::startDetached("kwrite " + file);
|
||||
}
|
||||
});
|
||||
|
||||
//! update all layouts view when runningActivities changed. This way we update immediately
|
||||
//! the running Activities in Activities checkboxes which are shown as bold
|
||||
connect(m_corona->activitiesConsumer(), &KActivities::Consumer::runningActivitiesChanged,
|
||||
@ -1365,6 +1390,7 @@ void SettingsDialog::updatePerLayoutButtonsState()
|
||||
QString originalName = m_layouts.contains(id) ? m_layouts[id]->name() : "";
|
||||
bool lockedInModel = m_model->data(m_model->index(currentRow, NAMECOLUMN), Qt::UserRole).toBool();
|
||||
bool sharedInModel = !m_model->data(m_model->index(currentRow, SHAREDCOLUMN), Qt::UserRole).toStringList().isEmpty();
|
||||
bool editable = !isActive(originalName) && !lockedInModel;
|
||||
|
||||
//! Switch Button
|
||||
if (id.startsWith("/tmp/") || originalName != nameInModel) {
|
||||
@ -1413,6 +1439,12 @@ void SettingsDialog::updatePerLayoutButtonsState()
|
||||
} else {
|
||||
ui->sharedButton->setChecked(false);
|
||||
}
|
||||
|
||||
if (editable) {
|
||||
m_editLayoutAction->setEnabled(true);
|
||||
} else {
|
||||
m_editLayoutAction->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
void SettingsDialog::updateSharedLayoutsStates()
|
||||
|
@ -144,6 +144,8 @@ private:
|
||||
|
||||
Latte::Corona *m_corona{nullptr};
|
||||
|
||||
QAction *m_editLayoutAction{nullptr};
|
||||
|
||||
QStandardItemModel *m_model{nullptr};
|
||||
Ui::SettingsDialog *ui;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user