Description: Add a desktop shortcut for the Lubuntu Manual Forwarded: eventually Author: Simon Quigley Last-Update: 2022-06-16 --- --- a/pcmanfm/desktop-preferences.ui +++ b/pcmanfm/desktop-preferences.ui @@ -6,8 +6,8 @@ 0 0 - 534 - 434 + 609 + 720 @@ -485,27 +485,17 @@ are left clicked, even when it is not th false - - - - Wallpaper image folder: + + + + Wallpaper folder - - + + - Browse - - - - - - - hour(s) - - - 24 + Randomize the slide show @@ -522,6 +512,20 @@ are left clicked, even when it is not th + + + + Wallpaper image folder: + + + + + + + Browse + + + @@ -545,46 +549,42 @@ are left clicked, even when it is not th - - + + Qt::Horizontal + + QSizePolicy::Minimum + - 10 + 5 5 - - - - Wallpaper folder - - - - - + + Qt::Horizontal - - QSizePolicy::Minimum - - 5 + 10 5 - - - - Randomize the slide show + + + + hour(s) + + + 24 @@ -663,6 +663,17 @@ are left clicked, even when it is not th .. + + + + + Lubuntu Manual + + + + .. + + --- a/pcmanfm/desktoppreferencesdialog.cpp +++ b/pcmanfm/desktoppreferencesdialog.cpp @@ -120,6 +120,7 @@ DesktopPreferencesDialog::DesktopPrefere ui.trashBox->setChecked(ds.contains(QLatin1String("Trash"))); ui.computerBox->setChecked(ds.contains(QLatin1String("Computer"))); ui.networkBox->setChecked(ds.contains(QLatin1String("Network"))); + ui.lubuntuManualBox->setChecked(ds.contains(QLatin1String("Lubuntu Manual"))); connect(ui.buttonBox->button(QDialogButtonBox::Apply), &QPushButton::clicked, this, &DesktopPreferencesDialog::onApplyClicked); @@ -208,6 +209,9 @@ void DesktopPreferencesDialog::applySett if(ui.networkBox->isChecked()) { ds << QLatin1String("Network"); } + if(ui.lubuntuManualBox->isChecked()) { + ds << QLatin1String("Lubuntu Manual"); + } settings.setDesktopShortcuts(ds); settings.setDesktopCellMargins(QSize(ui.hMargin->value(), ui.vMargin->value())); --- a/pcmanfm/desktopwindow.cpp +++ b/pcmanfm/desktopwindow.cpp @@ -277,6 +277,16 @@ void DesktopWindow::updateShortcutsFromS paths.push_back(Fm::FilePath::fromLocalPath(network.toStdString().c_str())); } } + // Lubuntu Manual + if(ds.contains(QLatin1String("Lubuntu Manual"))) { + createLubuntuManualShortcut(); + } + else if(!firstCall) { + QString network = XdgDir::readDesktopDir() + QLatin1String("/lubuntu-manual.desktop"); + if(QFile::exists(network)) { + paths.push_back(Fm::FilePath::fromLocalPath(network.toStdString().c_str())); + } + } // WARNING: QFile::remove() is not compatible with libfm-qt and should not be used. if(!paths.empty()) { @@ -362,6 +372,20 @@ void DesktopWindow::createNetworkShortcu g_key_file_free(kf); } +void DesktopWindow::createLubuntuManualShortcut() { + GKeyFile* kf = g_key_file_new(); + g_key_file_set_string(kf, "Desktop Entry", "Type", "Application"); + g_key_file_set_string(kf, "Desktop Entry", "Exec", "firefox manual.lubuntu.me"); + g_key_file_set_string(kf, "Desktop Entry", "Icon", "help-browser"); + const QString name = tr("Lubuntu Manual"); + g_key_file_set_string(kf, "Desktop Entry", "Name", name.toStdString().c_str()); + + auto path = Fm::FilePath::fromLocalPath(XdgDir::readDesktopDir().toStdString().c_str()).localPath(); + auto trash_can = Fm::CStrPtr{g_build_filename(path.get(), "lubuntu-manual.desktop", nullptr)}; + g_key_file_save_to_file(kf, trash_can.get(), nullptr); + g_key_file_free(kf); +} + void DesktopWindow::createTrash() { if(trashMonitor_) { return; @@ -987,7 +1011,8 @@ void DesktopWindow::onFileClicked(int ty if((fileName == QLatin1String("trash-can.desktop") && ds.contains(QLatin1String("Trash"))) || (fileName == QLatin1String("user-home.desktop") && ds.contains(QLatin1String("Home"))) || (fileName == QLatin1String("computer.desktop") && ds.contains(QLatin1String("Computer"))) - || (fileName == QLatin1String("network.desktop") && ds.contains(QLatin1String("Network")))) { + || (fileName == QLatin1String("network.desktop") && ds.contains(QLatin1String("Network"))) + || (fileName == QLatin1String("lubuntu-manual.desktop") && ds.contains(QLatin1String("Lubuntu Manual")))) { QMenu* menu = new QMenu(this); // "Open" action for all QAction* action = menu->addAction(tr("Open")); @@ -1297,7 +1322,8 @@ void DesktopWindow::trustOurDesktopShort const char* execStr = isHome ? homeExec.get() : fileName == QLatin1String("trash-can.desktop") && ds.contains(QLatin1String("Trash")) ? "pcmanfm-qt trash:///" : fileName == QLatin1String("computer.desktop") && ds.contains(QLatin1String("Computer")) ? "pcmanfm-qt computer:///" : - fileName == QLatin1String("network.desktop") && ds.contains(QLatin1String("Network")) ? "pcmanfm-qt network:///" : nullptr; + fileName == QLatin1String("network.desktop") && ds.contains(QLatin1String("Network")) ? "pcmanfm-qt network:///" : + fileName == QLatin1String("lubuntu-manual.desktop") && ds.contains(QLatin1String("Lubuntu Manual")) ? "firefox manual.lubuntu.me" : nullptr ; if(execStr) { GKeyFile* kf = g_key_file_new(); if(g_key_file_load_from_file(kf, file->path().toString().get(), G_KEY_FILE_NONE, nullptr)) { --- a/pcmanfm/desktopwindow.h +++ b/pcmanfm/desktopwindow.h @@ -158,6 +158,7 @@ private: void createHomeShortcut(); void createComputerShortcut(); void createNetworkShortcut(); + void createLubuntuManualShortcut(); void createTrash(); static void onTrashChanged(GFileMonitor* monitor, GFile* gf, GFile* other, GFileMonitorEvent evt, DesktopWindow* pThis);