├── AUTHORS ├── CHANGELOG ├── CMakeLists.txt ├── COPYING ├── README.md ├── cmake └── lxqt-config.cmake.in ├── configdialog ├── lxqtconfigdialog.cpp ├── lxqtconfigdialog.h ├── lxqtconfigdialog.ui ├── lxqtconfigdialog_p.h ├── lxqtconfigdialogcmdlineoptions.cpp ├── lxqtconfigdialogcmdlineoptions.h ├── lxqtpageselectwidget.cpp └── lxqtpageselectwidget.h ├── dbus ├── org.freedesktop.Notifications.xml └── org.lxqt.SingleApplication.xml ├── liblxqt.doxygen ├── lxqtapplication.cpp ├── lxqtapplication.h ├── lxqtautostartentry.cpp ├── lxqtautostartentry.h ├── lxqtbacklight.cpp ├── lxqtbacklight.h ├── lxqtbacklight ├── linux_backend │ ├── driver │ │ ├── CMakeLists.txt │ │ ├── libbacklight_backend.c │ │ ├── libbacklight_backend.h │ │ └── lxqtbacklight_backend.c │ ├── linuxbackend.cpp │ └── linuxbackend.h ├── virtual_backend.cpp └── virtual_backend.h ├── lxqtglobals.h ├── lxqtgridlayout.cpp ├── lxqtgridlayout.h ├── lxqthtmldelegate.cpp ├── lxqthtmldelegate.h ├── lxqtnotification.cpp ├── lxqtnotification.h ├── lxqtnotification_p.h ├── lxqtplugininfo.cpp ├── lxqtplugininfo.h ├── lxqtpower ├── lxqtpower.cpp ├── lxqtpower.h ├── lxqtpowerproviders.cpp └── lxqtpowerproviders.h ├── lxqtpowermanager.cpp ├── lxqtpowermanager.h ├── lxqtprogramfinder.cpp ├── lxqtprogramfinder.h ├── lxqtrotatedwidget.cpp ├── lxqtrotatedwidget.h ├── lxqtscreensaver.cpp ├── lxqtscreensaver.h ├── lxqtsettings.cpp ├── lxqtsettings.h ├── lxqtsingleapplication.cpp ├── lxqtsingleapplication.h ├── lxqttranslator.cpp ├── lxqttranslator.h ├── polkit └── org.lxqt.backlight.pkexec.policy.in ├── resources └── power.conf └── translations ├── CMakeLists.txt ├── liblxqt.ts ├── liblxqt_ar.ts ├── liblxqt_arn.ts ├── liblxqt_ast.ts ├── liblxqt_bg.ts ├── liblxqt_ca.ts ├── liblxqt_cs.ts ├── liblxqt_cy.ts ├── liblxqt_da.ts ├── liblxqt_de.ts ├── liblxqt_el.ts ├── liblxqt_en_GB.ts ├── liblxqt_eo.ts ├── liblxqt_es.ts ├── liblxqt_es_VE.ts ├── liblxqt_et.ts ├── liblxqt_eu.ts ├── liblxqt_fi.ts ├── liblxqt_fr.ts ├── liblxqt_gl.ts ├── liblxqt_he.ts ├── liblxqt_hi.ts ├── liblxqt_hr.ts ├── liblxqt_hu.ts ├── liblxqt_ia.ts ├── liblxqt_id.ts ├── liblxqt_is.ts ├── liblxqt_it.ts ├── liblxqt_ja.ts ├── liblxqt_ka.ts ├── liblxqt_kab.ts ├── liblxqt_kk.ts ├── liblxqt_ko.ts ├── liblxqt_lg.ts ├── liblxqt_lt.ts ├── liblxqt_lv.ts ├── liblxqt_nb_NO.ts ├── liblxqt_nl.ts ├── liblxqt_oc.ts ├── liblxqt_pa.ts ├── liblxqt_pl.ts ├── liblxqt_pt.ts ├── liblxqt_pt_BR.ts ├── liblxqt_ro_RO.ts ├── liblxqt_ru.ts ├── liblxqt_si.ts ├── liblxqt_sk_SK.ts ├── liblxqt_sl.ts ├── liblxqt_sr@latin.ts ├── liblxqt_sr_RS.ts ├── liblxqt_th_TH.ts ├── liblxqt_tr.ts ├── liblxqt_uk.ts ├── liblxqt_zh_CN.ts └── liblxqt_zh_TW.ts /AUTHORS: -------------------------------------------------------------------------------- 1 | Upstream Authors: 2 | LXQt team: https://lxqt-project.org 3 | Razor team: http://razor-qt.org 4 | 5 | Copyright: 6 | Copyright (c) 2010-2012 Razor team 7 | Copyright (c) 2012-2018 LXQt team 8 | 9 | License: LGPL-2.1+ 10 | The full text of the LGPL-2.1+ licenses can be found in the 'COPYING' file. 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # liblxqt 2 | 3 | ## Overview 4 | 5 | `liblxqt` represents the core library of LXQt providing essential functionality 6 | needed by nearly all of its components. 7 | 8 | ## Installation 9 | 10 | ### Sources 11 | 12 | Its runtime dependencies are libxss, KWindowSystem, qtbase, and 13 | [libqtxdg](https://github.com/lxqt/libqtxdg). 14 | Additional build dependencies are CMake, [lxqt-build-tools](https://github.com/lxqt/lxqt-build-tools) and optionally Git to pull latest VCS 15 | checkouts. 16 | 17 | Code configuration is handled by CMake. CMake variable `CMAKE_INSTALL_PREFIX` 18 | will normally have to be set to `/usr`, depending on the way library paths are 19 | dealt with on 64bit systems variables like `CMAKE_INSTALL_LIBDIR` may have to be 20 | set as well. 21 | 22 | To build run `make`, to install `make install` which accepts variable `DESTDIR` 23 | as usual. 24 | 25 | ### Binary packages 26 | 27 | The library is provided by all major Linux distributions like Arch Linux, Debian, 28 | Fedora and openSUSE. Just use your package manager to search for string `liblxqt`. 29 | 30 | 31 | ### Translation 32 | 33 | Translations can be done in [LXQt-Weblate](https://translate.lxqt-project.org/projects/lxqt-desktop/liblxqt/) 34 | 35 | 36 | Translation status 38 | -------------------------------------------------------------------------------- /cmake/lxqt-config.cmake.in: -------------------------------------------------------------------------------- 1 | # - Finds the lxqt package 2 | 3 | @PACKAGE_INIT@ 4 | 5 | if (CMAKE_VERSION VERSION_LESS 3.0.2) 6 | message(FATAL_ERROR \"@PROJECT_NAME@ requires at least CMake version 3.0.2\") 7 | endif() 8 | 9 | include(CMakeFindDependencyMacro) 10 | 11 | find_dependency(Qt6Widgets @QT_MINIMUM_VERSION@) 12 | find_dependency(Qt6DBus @QT_MINIMUM_VERSION@) 13 | find_dependency(Qt6LinguistTools @QT_MINIMUM_VERSION@) 14 | find_dependency(Qt6Xdg @QTXDG_MINIMUM_VERSION@) 15 | find_dependency(KF6WindowSystem) 16 | find_dependency(lxqt2-build-tools @LXQTBT_MINIMUM_VERSION@) 17 | include(LXQtConfigVars) 18 | 19 | 20 | # - Set version informations 21 | set(LXQT_MAJOR_VERSION "@LXQT_MAJOR_VERSION@") 22 | set(LXQT_MINOR_VERSION "@LXQT_MINOR_VERSION@") 23 | set(LXQT_PATCH_VERSION "@LXQT_PATCH_VERSION@") 24 | set(LXQT_VERSION "@LXQT_VERSION@") 25 | 26 | add_definitions("-DLXQT_MAJOR_VERSION=\"${LXQT_MAJOR_VERSION}\"") 27 | add_definitions("-DLXQT_MINOR_VERSION=\"${LXQT_MINOR_VERSION}\"") 28 | add_definitions("-DLXQT_PATCH_VERSION=\"${LXQT_PATCH_VERSION}\"") 29 | add_definitions("-DLXQT_VERSION=\"${LXQT_VERSION}\"") 30 | 31 | if (NOT TARGET @LXQT_LIBRARY_NAME@) 32 | if (POLICY CMP0024) 33 | cmake_policy(SET CMP0024 NEW) 34 | endif() 35 | include("${CMAKE_CURRENT_LIST_DIR}/lxqt-targets.cmake") 36 | endif() 37 | -------------------------------------------------------------------------------- /configdialog/lxqtconfigdialog.cpp: -------------------------------------------------------------------------------- 1 | /* BEGIN_COMMON_COPYRIGHT_HEADER 2 | * (c)LGPL2+ 3 | * 4 | * LXQt - a lightweight, Qt based, desktop toolset 5 | * https://lxqt.org 6 | * 7 | * Copyright (C) 2012 Alec Moskvin 8 | * 9 | * This library is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU Lesser General Public 11 | * License as published by the Free Software Foundation; either 12 | * version 2.1 of the License, or (at your option) any later version. 13 | 14 | * This library is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | * Lesser General Public License for more details. 18 | 19 | * You should have received a copy of the GNU Lesser General Public 20 | * License along with this library; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 22 | * 23 | * END_COMMON_COPYRIGHT_HEADER */ 24 | 25 | #include "lxqtconfigdialog.h" 26 | #include "lxqtconfigdialog_p.h" 27 | #include "ui_lxqtconfigdialog.h" 28 | 29 | #include 30 | #include 31 | 32 | #include "lxqtsettings.h" 33 | 34 | using namespace LXQt; 35 | 36 | ConfigDialogPrivate::ConfigDialogPrivate(ConfigDialog *q, Settings *settings) 37 | : q_ptr(q), 38 | mCache(new SettingsCache(settings)), 39 | ui(new Ui::ConfigDialog) 40 | { 41 | init(); 42 | } 43 | 44 | ConfigDialogPrivate::~ConfigDialogPrivate() 45 | { 46 | delete ui; 47 | delete mCache; 48 | } 49 | 50 | void ConfigDialogPrivate::init() 51 | { 52 | Q_Q(ConfigDialog); 53 | ui->setupUi(q); 54 | 55 | QObject::connect(ui->buttons, &QDialogButtonBox::clicked, q, 56 | [this](QAbstractButton* button) { dialogButtonsAction(button); } 57 | ); 58 | 59 | ui->moduleList->setVisible(false); 60 | const QList buttons = ui->buttons->findChildren(); 61 | for(QPushButton* button : buttons) 62 | button->setAutoDefault(false); 63 | } 64 | 65 | void ConfigDialogPrivate::dialogButtonsAction(QAbstractButton* button) 66 | { 67 | Q_Q(ConfigDialog); 68 | QDialogButtonBox::StandardButton standardButton = ui->buttons->standardButton(button); 69 | Q_EMIT q->clicked(standardButton); 70 | if (standardButton == QDialogButtonBox::Reset) 71 | { 72 | mCache->loadToSettings(); 73 | Q_EMIT q->reset(); 74 | } 75 | else if(standardButton == QDialogButtonBox::Close) 76 | { 77 | q->close(); 78 | } 79 | } 80 | 81 | void ConfigDialogPrivate::updateIcons() 82 | { 83 | Q_Q(ConfigDialog); 84 | for (int ix = 0; ix < mIcons.size(); ix++) 85 | ui->moduleList->item(ix)->setIcon(XdgIcon::fromTheme(mIcons.at(ix))); 86 | q->update(); 87 | } 88 | 89 | ConfigDialog::ConfigDialog(const QString& title, Settings* settings, QWidget* parent) : 90 | QDialog(parent), 91 | mSettings(settings), 92 | d_ptr(new ConfigDialogPrivate(this, settings)) 93 | { 94 | setWindowTitle(title); 95 | } 96 | 97 | void ConfigDialog::setButtons(QDialogButtonBox::StandardButtons buttons) 98 | { 99 | Q_D(ConfigDialog); 100 | d->ui->buttons->setStandardButtons(buttons); 101 | const QList b = d->ui->buttons->findChildren(); 102 | for(QPushButton* button : b) 103 | button->setAutoDefault(false); 104 | } 105 | 106 | void ConfigDialog::enableButton(QDialogButtonBox::StandardButton which, bool enable) 107 | { 108 | Q_D(ConfigDialog); 109 | if (QPushButton* pb = d->ui->buttons->button(which)) 110 | pb->setEnabled(enable); 111 | } 112 | 113 | void ConfigDialog::addPage(QWidget* page, const QString& name, const QString& iconName) 114 | { 115 | addPage(page, name, QStringList() << iconName); 116 | } 117 | 118 | void ConfigDialog::addPage(QWidget* page, const QString& name, const QStringList& iconNames) 119 | { 120 | Q_D(ConfigDialog); 121 | Q_ASSERT(page); 122 | if (!page) 123 | { 124 | return; 125 | } 126 | 127 | /* We set the layout margin to 0. In the default configuration, one page 128 | * only, it aligns buttons with the page. In multi-page it saves a little 129 | * bit of space, without clutter. 130 | */ 131 | if (page->layout()) 132 | { 133 | page->layout()->setContentsMargins(QMargins()); 134 | } 135 | 136 | QStringList icons = QStringList(iconNames) << QL1SV("application-x-executable"); 137 | new QListWidgetItem(XdgIcon::fromTheme(icons), name, d->ui->moduleList); 138 | d->mIcons.append(icons); 139 | d->ui->stackedWidget->addWidget(page); 140 | d->mPages[name] = page; 141 | if(d->ui->stackedWidget->count() > 1) 142 | { 143 | d->ui->moduleList->setVisible(true); 144 | d->ui->moduleList->setCurrentRow(0); 145 | d->mMaxSize = QSize(qMax(page->geometry().width() + d->ui->moduleList->geometry().width(), 146 | d->mMaxSize.width()), 147 | qMax(page->geometry().height() + d->ui->buttons->geometry().height(), 148 | d->mMaxSize.height())); 149 | } 150 | else 151 | { 152 | d->mMaxSize = page->geometry().size(); 153 | } 154 | resize(d->mMaxSize); 155 | } 156 | 157 | void ConfigDialog::showPage(QWidget* page) 158 | { 159 | Q_D(ConfigDialog); 160 | int index = d->ui->stackedWidget->indexOf(page); 161 | if (index < 0) 162 | return; 163 | 164 | d->ui->stackedWidget->setCurrentIndex(index); 165 | d->ui->moduleList->setCurrentRow(index); 166 | } 167 | 168 | void ConfigDialog::showPage(const QString &name) 169 | { 170 | Q_D(ConfigDialog); 171 | if (d->mPages.contains(name)) 172 | showPage(d->mPages.value(name)); 173 | else 174 | qWarning("ConfigDialog::showPage: Invalid page name (%s)", name.toLocal8Bit().constData()); 175 | } 176 | 177 | bool ConfigDialog::event(QEvent * event) 178 | { 179 | Q_D(ConfigDialog); 180 | if (QEvent::ThemeChange == event->type()) 181 | d->updateIcons(); 182 | return QDialog::event(event); 183 | } 184 | 185 | void ConfigDialog::closeEvent(QCloseEvent* event) 186 | { 187 | Q_UNUSED(event) 188 | Q_EMIT save(); 189 | mSettings->sync(); 190 | } 191 | 192 | ConfigDialog::~ConfigDialog() = default; 193 | -------------------------------------------------------------------------------- /configdialog/lxqtconfigdialog.h: -------------------------------------------------------------------------------- 1 | /* BEGIN_COMMON_COPYRIGHT_HEADER 2 | * (c)LGPL2+ 3 | * 4 | * LXQt - a lightweight, Qt based, desktop toolset 5 | * https://lxqt.org 6 | * 7 | * Copyright (C) 2012 Alec Moskvin 8 | * 9 | * This library is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU Lesser General Public 11 | * License as published by the Free Software Foundation; either 12 | * version 2.1 of the License, or (at your option) any later version. 13 | 14 | * This library is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | * Lesser General Public License for more details. 18 | 19 | * You should have received a copy of the GNU Lesser General Public 20 | * License along with this library; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 22 | * 23 | * END_COMMON_COPYRIGHT_HEADER */ 24 | 25 | #ifndef LXQTCONFIGDIALOG_H 26 | #define LXQTCONFIGDIALOG_H 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include "lxqtglobals.h" 33 | 34 | namespace Ui { 35 | class ConfigDialog; 36 | } 37 | 38 | namespace LXQt 39 | { 40 | class Settings; 41 | class ConfigDialogPrivate; 42 | 43 | class LXQT_API ConfigDialog : public QDialog 44 | { 45 | Q_OBJECT 46 | Q_DECLARE_PRIVATE(ConfigDialog) 47 | 48 | public: 49 | explicit ConfigDialog(const QString& title, Settings* settings, QWidget* parent = nullptr); 50 | 51 | ~ConfigDialog() override; 52 | 53 | /*! 54 | * Sets buttons in button bar 55 | */ 56 | void setButtons(QDialogButtonBox::StandardButtons buttons); 57 | 58 | /*! 59 | * Enable/disable a standard button if it exists 60 | */ 61 | void enableButton(QDialogButtonBox::StandardButton which, bool enable); 62 | 63 | /*! 64 | * Add a page to the configure dialog 65 | */ 66 | void addPage(QWidget* page, const QString& name, const QString& iconName = QL1SV("application-x-executable")); 67 | 68 | /*! 69 | * Add a page to the configure dialog, attempting several alternative icons to find one in the theme 70 | */ 71 | void addPage(QWidget* page, const QString& name, const QStringList& iconNames); 72 | 73 | /*! 74 | * Show page containing the widget in parameter 75 | */ 76 | void showPage(QWidget *page); 77 | 78 | /*! 79 | * \brief Shows the given page 80 | * \param name The page to be shown. 81 | */ 82 | void showPage(const QString &name); 83 | 84 | Q_SIGNALS: 85 | /*! 86 | * This signal is emitted when the user pressed the "Reset" button. 87 | * Settings should be re-read and the widgets should be set accordingly. 88 | */ 89 | void reset(); 90 | 91 | /*! 92 | * This is emitted whenever the window is closed and settings need to be saved. 93 | * It is only necessary if additional actions need to be performed - Settings are handled automatically. 94 | */ 95 | void save(); 96 | 97 | /*! 98 | * This is emitted when some button in the buttonbar is clicked. 99 | */ 100 | void clicked(QDialogButtonBox::StandardButton); 101 | 102 | protected: 103 | Settings* mSettings; 104 | bool event(QEvent * event) override; 105 | void closeEvent(QCloseEvent* event) override; 106 | 107 | private: 108 | Q_DISABLE_COPY(ConfigDialog) 109 | QScopedPointer const d_ptr; 110 | }; 111 | 112 | } // namespace LXQt 113 | #endif // LXQTCONFIGDIALOG_H 114 | -------------------------------------------------------------------------------- /configdialog/lxqtconfigdialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | ConfigDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 272 10 | 231 11 | 12 | 13 | 14 | Dialog 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | Qt::ScrollBarAlwaysOff 23 | 24 | 25 | QAbstractScrollArea::AdjustToContents 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -1 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | Qt::Horizontal 46 | 47 | 48 | QDialogButtonBox::Close|QDialogButtonBox::Reset 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | LXQt::PageSelectWidget 57 | QListWidget 58 |
configdialog/lxqtpageselectwidget.h
59 |
60 |
61 | 62 | moduleList 63 | buttons 64 | 65 | 66 | 67 | 68 | moduleList 69 | currentRowChanged(int) 70 | stackedWidget 71 | setCurrentIndex(int) 72 | 73 | 74 | 150 75 | 123 76 | 77 | 78 | 344 79 | 117 80 | 81 | 82 | 83 | 84 |
85 | -------------------------------------------------------------------------------- /configdialog/lxqtconfigdialog_p.h: -------------------------------------------------------------------------------- 1 | /* 2 | * LXQt - a lightweight, Qt based, desktop toolset 3 | * https://lxqt.org 4 | * 5 | * Copyright (C) 2012 Alec Moskvin 6 | * Copyright (C) 2018 Luís Pereira 7 | * 8 | * This library is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Lesser General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2.1 of the License, or (at your option) any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this library; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, 21 | * Boston, MA 02110-1301 USA 22 | */ 23 | 24 | #ifndef LXQTCONFIGDIALOG_P_H 25 | #define LXQTCONFIGDIALOG_P_H 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | class QWidget; 33 | class QAbstractButton; 34 | 35 | namespace Ui { 36 | class ConfigDialog; 37 | } 38 | 39 | namespace LXQt 40 | { 41 | 42 | class ConfigDialog; 43 | class Settings; 44 | class SettingsCache; 45 | 46 | class Q_DECL_HIDDEN ConfigDialogPrivate 47 | { 48 | Q_DECLARE_PUBLIC(ConfigDialog) 49 | ConfigDialog* const q_ptr; 50 | 51 | public: 52 | ConfigDialogPrivate(ConfigDialog *q, Settings* settings); 53 | ~ConfigDialogPrivate(); 54 | 55 | void init(); 56 | void dialogButtonsAction(QAbstractButton* button); 57 | void updateIcons(); 58 | 59 | SettingsCache* mCache; 60 | QList mIcons; 61 | QSize mMaxSize; 62 | Ui::ConfigDialog* ui; 63 | QHash mPages; 64 | }; 65 | 66 | } // namespace LXQt 67 | 68 | #endif // LXQTCONFIGDIALOG_P_H 69 | -------------------------------------------------------------------------------- /configdialog/lxqtconfigdialogcmdlineoptions.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * LXQt - a lightweight, Qt based, desktop toolset 3 | * https://lxqt.org 4 | * 5 | * Copyright (C) 2018 Luís Pereira 6 | * 7 | * This program or library is free software; you can redistribute it 8 | * and/or modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | 17 | * You should have received a copy of the GNU Lesser General 18 | * Public License along with this library; if not, write to the 19 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 20 | * Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #include "lxqtconfigdialogcmdlineoptions.h" 24 | 25 | #include 26 | 27 | namespace LXQt { 28 | 29 | class Q_DECL_HIDDEN ConfigDialogCmdLineOptionsPrivate { 30 | public: 31 | QString mPage; 32 | }; 33 | 34 | ConfigDialogCmdLineOptions::ConfigDialogCmdLineOptions() 35 | : d(new ConfigDialogCmdLineOptionsPrivate) 36 | { 37 | } 38 | 39 | ConfigDialogCmdLineOptions::~ConfigDialogCmdLineOptions() = default; 40 | 41 | bool ConfigDialogCmdLineOptions::setCommandLine(QCommandLineParser *parser) 42 | { 43 | Q_ASSERT(parser); 44 | if (!parser) 45 | return false; 46 | 47 | return parser->addOption(QCommandLineOption{QStringList{QL1SV("s"), QL1SV("show-page")}, QCoreApplication::tr("Choose the page to be shown."), QL1SV("name")}); 48 | } 49 | 50 | void ConfigDialogCmdLineOptions::process(QCommandLineParser &parser) 51 | { 52 | if (parser.isSet(QL1SV("show-page"))) { 53 | d->mPage = parser.value(QL1SV("show-page")); 54 | } 55 | } 56 | 57 | QString ConfigDialogCmdLineOptions::page() const 58 | { 59 | return d->mPage; 60 | } 61 | 62 | } // LXQt namespace 63 | -------------------------------------------------------------------------------- /configdialog/lxqtconfigdialogcmdlineoptions.h: -------------------------------------------------------------------------------- 1 | /* 2 | * LXQt - a lightweight, Qt based, desktop toolset 3 | * https://lxqt.org 4 | * 5 | * Copyright (C) 2018 Luís Pereira 6 | * 7 | * This program or library is free software; you can redistribute it 8 | * and/or modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | 17 | * You should have received a copy of the GNU Lesser General 18 | * Public License along with this library; if not, write to the 19 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 20 | * Boston, MA 02110-1301 USA 21 | */ 22 | 23 | #ifndef LXQTCONFIGDIALOGCMDLINEOPTIONS_H 24 | #define LXQTCONFIGDIALOGCMDLINEOPTIONS_H 25 | 26 | #include "lxqtglobals.h" 27 | 28 | #include 29 | #include 30 | 31 | class QCommandLineParser; 32 | 33 | namespace LXQt { 34 | 35 | class ConfigDialogCmdLineOptionsPrivate; 36 | 37 | class LXQT_API ConfigDialogCmdLineOptions 38 | { 39 | public: 40 | ConfigDialogCmdLineOptions(); 41 | ~ConfigDialogCmdLineOptions(); 42 | 43 | bool setCommandLine(QCommandLineParser *parser); 44 | void process(QCommandLineParser &parser); 45 | 46 | QString page() const; 47 | 48 | private: 49 | Q_DISABLE_COPY(ConfigDialogCmdLineOptions) 50 | QScopedPointer const d; 51 | }; 52 | 53 | } // LXQt namespace 54 | 55 | #endif // LXQTCONFIGDIALOGCMDLINEOPTIONS_H 56 | -------------------------------------------------------------------------------- /configdialog/lxqtpageselectwidget.cpp: -------------------------------------------------------------------------------- 1 | /* BEGIN_COMMON_COPYRIGHT_HEADER 2 | * (c)LGPL2+ 3 | * 4 | * LXQt - a lightweight, Qt based, desktop toolset 5 | * https://lxqt.org 6 | * 7 | * Copyright: 2010-2011 Razor team 8 | * Authors: 9 | * Alexander Sokoloff 10 | * 11 | * This program or library is free software; you can redistribute it 12 | * and/or modify it under the terms of the GNU Lesser General Public 13 | * License as published by the Free Software Foundation; either 14 | * version 2.1 of the License, or (at your option) any later version. 15 | * 16 | * This library is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | * Lesser General Public License for more details. 20 | 21 | * You should have received a copy of the GNU Lesser General 22 | * Public License along with this library; if not, write to the 23 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 24 | * Boston, MA 02110-1301 USA 25 | * 26 | * END_COMMON_COPYRIGHT_HEADER */ 27 | 28 | 29 | #include "lxqtpageselectwidget.h" 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | using namespace LXQt; 37 | 38 | class PageSelectWidgetItemDelegate: public QStyledItemDelegate 39 | { 40 | public: 41 | explicit PageSelectWidgetItemDelegate(PageSelectWidget *parent = nullptr); 42 | QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override; 43 | 44 | private: 45 | PageSelectWidget* mView; 46 | }; 47 | 48 | 49 | /************************************************ 50 | 51 | ************************************************/ 52 | PageSelectWidgetItemDelegate::PageSelectWidgetItemDelegate(PageSelectWidget *parent): 53 | QStyledItemDelegate(parent), 54 | mView(parent) 55 | { 56 | } 57 | 58 | 59 | /************************************************ 60 | 61 | ************************************************/ 62 | QSize PageSelectWidgetItemDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const 63 | { 64 | QVariant value = index.data(Qt::SizeHintRole); 65 | if (value.isValid()) 66 | return qvariant_cast(value); 67 | 68 | //all items should have unified width 69 | 70 | QStyleOptionViewItem opt = option; 71 | initStyleOption(&opt, index); 72 | const QWidget *widget = option.widget; 73 | QStyle *style = widget ? widget->style() : QApplication::style(); 74 | QSize size = style->sizeFromContents(QStyle::CT_ItemViewItem, &opt, QSize(), widget); 75 | //NOTE: this margin logic follows code in QCommonStylePrivate::viewItemLayout() 76 | const int margin = style->pixelMetric(QStyle::PM_FocusFrameHMargin, &option, option.widget) + 1; 77 | 78 | // Find the extra vertical gap by subtracting the height of the text when wrapped within 79 | // the default size from the height of the text when wrapped within our max. width. 80 | const QRect R1 = mView->fontMetrics().boundingRect(QRect(0, 0, size.width() - 2 * margin, 0), 81 | Qt::AlignLeft | Qt::TextWordWrap, opt.text); 82 | const QRect R2 = mView->fontMetrics().boundingRect(QRect(0, 0, mView->getWrappedTextWidth(), 0), 83 | Qt::AlignLeft | Qt::TextWordWrap, opt.text); 84 | // compensate for the vertical gap 85 | size.rheight() -= qAbs(R1.height() - R2.height()); 86 | 87 | //considering the icon size too 88 | size.setWidth(qMax(mView->maxTextWidth(), option.decorationSize.width())); 89 | // adding the margin is good but not necessary because it is already added 90 | size.rwidth() += 2 * margin; 91 | size.rheight() += margin; // only at the bottom 92 | 93 | return size; 94 | } 95 | 96 | 97 | 98 | /************************************************ 99 | 100 | ************************************************/ 101 | PageSelectWidget::PageSelectWidget(QWidget *parent) : 102 | QListWidget(parent) 103 | , mMaxTextWidth(0) 104 | { 105 | mWrappedTextWidth = fontMetrics().averageCharWidth() * 13; // max. 13 characters 106 | 107 | setSelectionRectVisible(false); 108 | setViewMode(IconMode); 109 | setSpacing(2); 110 | setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding); 111 | setWordWrap(true); 112 | setDragEnabled(NoDragDrop); 113 | setEditTriggers(NoEditTriggers); 114 | setTextElideMode(Qt::ElideNone); 115 | setContentsMargins(0, 0, 0, 0); 116 | 117 | setItemDelegate(new PageSelectWidgetItemDelegate(this)); 118 | connect(model(), &QAbstractItemModel::rowsInserted, this, &PageSelectWidget::updateMaxTextWidth); 119 | connect(model(), &QAbstractItemModel::rowsRemoved, this, &PageSelectWidget::updateMaxTextWidth); 120 | connect(model(), &QAbstractItemModel::dataChanged, this, &PageSelectWidget::updateMaxTextWidth); 121 | } 122 | 123 | 124 | /************************************************ 125 | 126 | ************************************************/ 127 | PageSelectWidget::~PageSelectWidget() = default; 128 | 129 | /************************************************ 130 | 131 | ************************************************/ 132 | int PageSelectWidget::maxTextWidth() const 133 | { 134 | return mMaxTextWidth; 135 | } 136 | 137 | /************************************************ 138 | 139 | ************************************************/ 140 | QSize PageSelectWidget::viewportSizeHint() const 141 | { 142 | const int spacing2 = spacing() * 2; 143 | QSize size{sizeHintForColumn(0) + spacing2, (sizeHintForRow(0) + spacing2) * count()}; 144 | auto vScrollbar = verticalScrollBar(); 145 | if (vScrollbar 146 | && vScrollbar->isVisible() 147 | && !vScrollbar->style()->styleHint(QStyle::SH_ScrollBar_Transient, nullptr, vScrollbar)) 148 | { 149 | size.rwidth() += verticalScrollBar()->sizeHint().width(); 150 | } 151 | return size; 152 | } 153 | 154 | /************************************************ 155 | 156 | ************************************************/ 157 | QSize PageSelectWidget::sizeHint() const 158 | { 159 | const int f = 2 * frameWidth(); 160 | return viewportSizeHint() + QSize(f, f); 161 | } 162 | 163 | /************************************************ 164 | 165 | ************************************************/ 166 | QSize PageSelectWidget::minimumSizeHint() const 167 | { 168 | return QSize{0, 0}; 169 | } 170 | 171 | /************************************************ 172 | 173 | ************************************************/ 174 | void PageSelectWidget::updateMaxTextWidth() 175 | { 176 | for(int i = count() - 1; 0 <= i; --i) 177 | { 178 | const QRect r = fontMetrics().boundingRect(QRect(0, 0, mWrappedTextWidth, 0), 179 | Qt::AlignLeft | Qt::TextWordWrap, item(i)->text()); 180 | mMaxTextWidth = qMax(mMaxTextWidth, r.width()); 181 | } 182 | } 183 | 184 | /************************************************ 185 | 186 | ************************************************/ 187 | bool PageSelectWidget::event(QEvent * event) 188 | { 189 | if (QEvent::StyleChange == event->type()) 190 | updateMaxTextWidth(); 191 | 192 | return QListWidget::event(event); 193 | } 194 | -------------------------------------------------------------------------------- /configdialog/lxqtpageselectwidget.h: -------------------------------------------------------------------------------- 1 | /* BEGIN_COMMON_COPYRIGHT_HEADER 2 | * (c)LGPL2+ 3 | * 4 | * LXQt - a lightweight, Qt based, desktop toolset 5 | * https://lxqt.org 6 | * 7 | * Copyright: 2010-2011 Razor team 8 | * Authors: 9 | * Alexander Sokoloff 10 | * 11 | * This program or library is free software; you can redistribute it 12 | * and/or modify it under the terms of the GNU Lesser General Public 13 | * License as published by the Free Software Foundation; either 14 | * version 2.1 of the License, or (at your option) any later version. 15 | * 16 | * This library is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | * Lesser General Public License for more details. 20 | 21 | * You should have received a copy of the GNU Lesser General 22 | * Public License along with this library; if not, write to the 23 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 24 | * Boston, MA 02110-1301 USA 25 | * 26 | * END_COMMON_COPYRIGHT_HEADER */ 27 | 28 | 29 | #ifndef LXQTPAGESELECTWIDGET_H 30 | #define LXQTPAGESELECTWIDGET_H 31 | 32 | #include "lxqtglobals.h" 33 | #include 34 | 35 | namespace LXQt 36 | { 37 | 38 | class LXQT_API PageSelectWidget : public QListWidget 39 | { 40 | Q_OBJECT 41 | public: 42 | explicit PageSelectWidget(QWidget *parent = nullptr); 43 | ~PageSelectWidget() override; 44 | int maxTextWidth() const; 45 | bool event(QEvent * event) override; 46 | 47 | int getWrappedTextWidth() const { 48 | return mWrappedTextWidth; 49 | } 50 | 51 | protected: 52 | QSize viewportSizeHint() const override; 53 | QSize sizeHint() const override; 54 | QSize minimumSizeHint() const override; 55 | 56 | protected Q_SLOTS: 57 | void updateMaxTextWidth(); 58 | 59 | private: 60 | int mMaxTextWidth; 61 | int mWrappedTextWidth; 62 | }; 63 | 64 | } // namespace LXQt 65 | #endif // PAGESELECTWIDGET_H 66 | -------------------------------------------------------------------------------- /dbus/org.freedesktop.Notifications.xml: -------------------------------------------------------------------------------- 1 | 3 | 8 | 9 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /dbus/org.lxqt.SingleApplication.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /liblxqt.doxygen: -------------------------------------------------------------------------------- 1 | /*! \mainpage A minimal shared library for LXQt DE. 2 | 3 | liblxqt containing shared classes for LXQt developed by LXQt team and contributors. 4 | */ 5 | -------------------------------------------------------------------------------- /lxqtapplication.cpp: -------------------------------------------------------------------------------- 1 | /* BEGIN_COMMON_COPYRIGHT_HEADER 2 | * (c)LGPL2+ 3 | * 4 | * LXQt - a lightweight, Qt based, desktop toolset 5 | * https://lxqt.org 6 | * 7 | * Copyright: 2012-2013 Razor team 8 | * Authors: 9 | * Petr Vanek 10 | * 11 | * This program or library is free software; you can redistribute it 12 | * and/or modify it under the terms of the GNU Lesser General Public 13 | * License as published by the Free Software Foundation; either 14 | * version 2.1 of the License, or (at your option) any later version. 15 | * 16 | * This library is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | * Lesser General Public License for more details. 20 | 21 | * You should have received a copy of the GNU Lesser General 22 | * Public License along with this library; if not, write to the 23 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 24 | * Boston, MA 02110-1301 USA 25 | * 26 | * END_COMMON_COPYRIGHT_HEADER */ 27 | 28 | #include 29 | 30 | #include "lxqtapplication.h" 31 | #include "lxqtsettings.h" 32 | 33 | #include 34 | 35 | using namespace LXQt; 36 | 37 | #define COLOR_DEBUG "\033[32;2m" 38 | #define COLOR_WARN "\033[33;2m" 39 | #define COLOR_CRITICAL "\033[31;1m" 40 | #define COLOR_FATAL "\033[33;1m" 41 | #define COLOR_RESET "\033[0m" 42 | 43 | #define QAPP_NAME qApp ? qApp->objectName().toUtf8().constData() : "" 44 | 45 | #include 46 | #include 47 | #include 48 | #include 49 | #include 50 | #include 51 | #include 52 | #include 53 | #include 54 | 55 | Application::Application(int &argc, char** argv) 56 | : QApplication(argc, argv) 57 | { 58 | setWindowIcon(QIcon(QFile::decodeName(LXQT_GRAPHICS_DIR) + QL1SV("/lxqt_logo.png"))); 59 | connect(Settings::globalSettings(), &GlobalSettings::lxqtThemeChanged, this, &Application::updateTheme); 60 | updateTheme(); 61 | } 62 | 63 | Application::Application(int &argc, char** argv, bool handleQuitSignals) 64 | : Application(argc, argv) 65 | { 66 | if (handleQuitSignals) 67 | { 68 | QList signo_list = {SIGINT, SIGTERM, SIGHUP}; 69 | connect(this, &Application::unixSignal, [this, signo_list] (int signo) 70 | { 71 | if (signo_list.contains(signo)) 72 | quit(); 73 | }); 74 | listenToUnixSignals(signo_list); 75 | } 76 | } 77 | 78 | void Application::updateTheme() 79 | { 80 | const QString styleSheetKey = QFileInfo(applicationFilePath()).fileName(); 81 | setStyleSheet(lxqtTheme.qss(styleSheetKey)); 82 | Q_EMIT themeChanged(); 83 | } 84 | 85 | namespace 86 | { 87 | class SignalHandler 88 | { 89 | public: 90 | static void signalHandler(int signo) 91 | { 92 | const int ret = write(instance->mSignalSock[0], &signo, sizeof (int)); 93 | if (sizeof (int) != ret) 94 | qCritical("unable to write into socketpair: %s", strerror(errno)); 95 | } 96 | 97 | public: 98 | template 99 | SignalHandler(Application * app, Lambda signalEmitter) 100 | : mSignalSock{-1, -1} 101 | { 102 | if (0 != socketpair(AF_UNIX, SOCK_STREAM, 0, mSignalSock)) 103 | { 104 | qCritical("unable to create socketpair for correct signal handling: %s", strerror(errno)); 105 | return; 106 | } 107 | 108 | mNotifier.reset(new QSocketNotifier(mSignalSock[1], QSocketNotifier::Read)); 109 | QObject::connect(mNotifier.data(), &QSocketNotifier::activated, app, [this, signalEmitter] { 110 | int signo = 0; 111 | int ret = read(mSignalSock[1], &signo, sizeof (int)); 112 | if (sizeof (int) != ret) 113 | qCritical("unable to read signal from socketpair, %s", strerror(errno)); 114 | signalEmitter(signo); 115 | }); 116 | } 117 | 118 | ~SignalHandler() 119 | { 120 | close(mSignalSock[0]); 121 | close(mSignalSock[1]); 122 | } 123 | 124 | void listenToSignals(QList const & signoList) 125 | { 126 | struct sigaction sa; 127 | sa.sa_handler = signalHandler; 128 | sigemptyset(&sa.sa_mask); 129 | sa.sa_flags = 0; 130 | for (auto const & signo : signoList) 131 | sigaction(signo, &sa, nullptr); 132 | } 133 | 134 | public: 135 | static QScopedPointer instance; 136 | 137 | private: 138 | int mSignalSock[2]; 139 | QScopedPointer mNotifier; 140 | }; 141 | 142 | QScopedPointer SignalHandler::instance; 143 | } 144 | 145 | void Application::listenToUnixSignals(QList const & signoList) 146 | { 147 | static QScopedPointer signal_notifier; 148 | 149 | if (SignalHandler::instance.isNull()) 150 | SignalHandler::instance.reset(new SignalHandler{this, [this] (int signo) { Q_EMIT unixSignal(signo); }}); 151 | SignalHandler::instance->listenToSignals(signoList); 152 | } 153 | -------------------------------------------------------------------------------- /lxqtapplication.h: -------------------------------------------------------------------------------- 1 | /* BEGIN_COMMON_COPYRIGHT_HEADER 2 | * (c)LGPL2+ 3 | * 4 | * LXQt - a lightweight, Qt based, desktop toolset 5 | * https://lxqt.org 6 | * 7 | * Copyright: 2012-2013 Razor team 8 | * Authors: 9 | * Petr Vanek 10 | * 11 | * This program or library is free software; you can redistribute it 12 | * and/or modify it under the terms of the GNU Lesser General Public 13 | * License as published by the Free Software Foundation; either 14 | * version 2.1 of the License, or (at your option) any later version. 15 | * 16 | * This library is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | * Lesser General Public License for more details. 20 | 21 | * You should have received a copy of the GNU Lesser General 22 | * Public License along with this library; if not, write to the 23 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 24 | * Boston, MA 02110-1301 USA 25 | * 26 | * END_COMMON_COPYRIGHT_HEADER */ 27 | 28 | #ifndef LXQTAPPLICATION_H 29 | #define LXQTAPPLICATION_H 30 | 31 | #include 32 | #include 33 | #include "lxqtglobals.h" 34 | 35 | namespace LXQt 36 | { 37 | 38 | /*! \brief LXQt wrapper around QApplication. 39 | * It loads various LXQt related stuff by default (window icon, icon theme...) 40 | * 41 | * \note This wrapper is intended to be used only inside LXQt project. Using it 42 | * in external application will automatically require linking to various 43 | * LXQt libraries. 44 | * 45 | */ 46 | class LXQT_API Application : public QApplication 47 | { 48 | Q_OBJECT 49 | 50 | public: 51 | /*! Construct a LXQt application object. 52 | * \param argc standard argc as in QApplication 53 | * \param argv standard argv as in QApplication 54 | */ 55 | Application(int &argc, char **argv); 56 | /*! Construct a LXQt application object. 57 | * \param argc standard argc as in QApplication 58 | * \param argv standard argv as in QApplication 59 | * \param handleQuitSignals flag if signals SIGINT, SIGTERM, SIGHUP should be handled internally (\sa quit() application) 60 | */ 61 | Application(int &argc, char **argv, bool handleQuitSignals); 62 | ~Application() override {} 63 | /*! Install UNIX signal handler for signals defined in \param signalList 64 | * Upon receiving of any of this signals the \sa unixSignal signal is emitted 65 | */ 66 | void listenToUnixSignals(QList const & signolList); 67 | 68 | private Q_SLOTS: 69 | void updateTheme(); 70 | 71 | Q_SIGNALS: 72 | void themeChanged(); 73 | /*! Signal is emitted upon receival of registered unix signal 74 | * \param signo the received unix signal number 75 | */ 76 | void unixSignal(int signo); 77 | }; 78 | 79 | #if defined(lxqtApp) 80 | #undef lxqtApp 81 | #endif 82 | #define lxqtApp (static_cast(qApp)) 83 | 84 | } // namespace LXQt 85 | #endif // LXQTAPPLICATION_H 86 | -------------------------------------------------------------------------------- /lxqtautostartentry.cpp: -------------------------------------------------------------------------------- 1 | /* BEGIN_COMMON_COPYRIGHT_HEADER 2 | * (c)LGPL2+ 3 | * 4 | * LXQt - a lightweight, Qt based, desktop toolset 5 | * https://lxqt.org 6 | * 7 | * Copyright (C) 2012 Alec Moskvin 8 | * 9 | * This library is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU Lesser General Public 11 | * License as published by the Free Software Foundation; either 12 | * version 2.1 of the License, or (at your option) any later version. 13 | 14 | * This library is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | * Lesser General Public License for more details. 18 | 19 | * You should have received a copy of the GNU Lesser General Public 20 | * License along with this library; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 22 | * 23 | * END_COMMON_COPYRIGHT_HEADER */ 24 | 25 | #include "lxqtautostartentry.h" 26 | #include 27 | 28 | #include 29 | #include 30 | 31 | using namespace LXQt; 32 | 33 | AutostartEntry::AutostartEntry() : 34 | mLocalState(StateNone), mSystem(false) 35 | { 36 | } 37 | 38 | AutostartEntry::AutostartEntry(const QString& name): 39 | mLocalState(StateNone), mSystem(false) 40 | { 41 | const QStringList& dirs = XdgDirs::autostartDirs(); 42 | for (const QString& dir : dirs) 43 | { 44 | const QString path = QString::fromLatin1("%1/%2").arg(dir, name); 45 | if (QFile(path).exists()) 46 | { 47 | mSystemFile.load(path); 48 | mSystem = true; 49 | break; 50 | } 51 | } 52 | 53 | const QString path = QString::fromLatin1("%1/%2").arg(XdgDirs::autostartHome(), name); 54 | if (QFile(path).exists()) 55 | { 56 | mLocalFile.load(path); 57 | mLocalState = StateExists; 58 | } 59 | } 60 | 61 | void AutostartEntry::setFile(const XdgDesktopFile& file) 62 | { 63 | const bool local = isLocal(); 64 | if (mSystem && local && file == mSystemFile) 65 | { 66 | removeLocal(); 67 | } 68 | else 69 | { 70 | if (local) 71 | mLocalState = StateModified; 72 | else 73 | mLocalState = StateTransient; 74 | mLocalFile = file; 75 | } 76 | } 77 | 78 | bool AutostartEntry::removeLocal() 79 | { 80 | if (!isLocal()) 81 | return false; 82 | 83 | if (mLocalState == StateTransient) 84 | mLocalState = StateNone; 85 | else 86 | mLocalState = StateDeleted; 87 | 88 | return !mSystem; 89 | } 90 | 91 | const XdgDesktopFile& AutostartEntry::file() const 92 | { 93 | return isLocal() ? mLocalFile : mSystemFile; 94 | } 95 | 96 | QString AutostartEntry::name() const 97 | { 98 | return QFileInfo(file().fileName()).fileName(); 99 | } 100 | 101 | void AutostartEntry::setEnabled(bool enable) 102 | { 103 | // Disabling is done only for LXQt, for respecting other DEs, 104 | // while enabling of global entries can only be done for all DEs. 105 | XdgDesktopFile f = file(); 106 | if (enable) 107 | { 108 | f.removeEntry(QL1SV("Hidden")); 109 | f.removeEntry(QL1SV("X-LXQt-Autostart-disabled")); 110 | } 111 | else 112 | f.setValue(QL1SV("X-LXQt-Autostart-disabled"), true); 113 | 114 | setFile(f); 115 | } 116 | 117 | bool AutostartEntry::isEnabled() const 118 | { 119 | return !isEmpty() 120 | && !file().value(QL1SV("Hidden"), false).toBool() 121 | && !file().value(QL1SV("X-LXQt-Autostart-disabled"), false).toBool(); 122 | } 123 | 124 | bool AutostartEntry::commit() 125 | { 126 | if (mLocalState == StateDeleted) 127 | { 128 | mLocalState = StateNone; 129 | return QFile::remove(mLocalFile.fileName()); 130 | } 131 | else if (mLocalState == StateModified || mLocalState == StateTransient) 132 | { 133 | mLocalState = StateExists; 134 | return mLocalFile.save(XdgAutoStart::localPath(mLocalFile)); 135 | } 136 | return true; 137 | } 138 | -------------------------------------------------------------------------------- /lxqtautostartentry.h: -------------------------------------------------------------------------------- 1 | /* BEGIN_COMMON_COPYRIGHT_HEADER 2 | * (c)LGPL2+ 3 | * 4 | * LXQt - a lightweight, Qt based, desktop toolset 5 | * https://lxqt.org 6 | * 7 | * Copyright (C) 2012 Alec Moskvin 8 | * 9 | * This library is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU Lesser General Public 11 | * License as published by the Free Software Foundation; either 12 | * version 2.1 of the License, or (at your option) any later version. 13 | 14 | * This library is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | * Lesser General Public License for more details. 18 | 19 | * You should have received a copy of the GNU Lesser General Public 20 | * License along with this library; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 22 | * 23 | * END_COMMON_COPYRIGHT_HEADER */ 24 | 25 | #ifndef LXQTAUTOSTARTENTRY_H 26 | #define LXQTAUTOSTARTENTRY_H 27 | 28 | #include "lxqtglobals.h" 29 | #include 30 | 31 | namespace LXQt 32 | { 33 | 34 | /*! \brief The AutostartEntry class provides an interface for staging configuration of individual 35 | autostart items. All changes are made in memory until commit() is called. 36 | 37 | - "system" file refers to a read-only file in /etc/xdg/autostart (or a directory in $XDG_CONFIG_DIRS) 38 | - "local" file refers to the file in user's ~/.config/autostart (or in $XDG_CONFIG_HOME/autostart) 39 | 40 | When a "local" file has the same name as the "system" file, the local one overrides it. This class 41 | tries to ensure that the "local" file is deleted if it's identical to the "system" file. 42 | */ 43 | class LXQT_API AutostartEntry 44 | { 45 | public: 46 | /*! Constructs an AutostartEntry object for a specific entry. 47 | * \param name The name of the autostart desktop file (e.g. "lxqt-panel.desktop") 48 | */ 49 | AutostartEntry(const QString& name); 50 | 51 | //! \brief Default constructor 52 | AutostartEntry(); 53 | 54 | //! Destructor 55 | virtual ~AutostartEntry() { } 56 | 57 | //! Returns the "active" desktop file 58 | const XdgDesktopFile& file() const; 59 | 60 | //! Returns the name of the autostart entry (e.g. "lxqt-panel.desktop") 61 | QString name() const; 62 | 63 | /*! Sets to the specified desktop file. Use this to make modifications. 64 | * \param file The desktop file 65 | */ 66 | void setFile(const XdgDesktopFile& file); 67 | 68 | /*! Sets whether the item auto-starts 69 | * \param enable When false, sets the "Hidden" key which will prevent the item from starting 70 | */ 71 | void setEnabled(bool enable); 72 | 73 | //! Returns true if the item will auto-start 74 | bool isEnabled() const; 75 | 76 | /*! Returns true if the entry does not exist, and the object carries no useful information 77 | * and can be ignored/deleted. 78 | */ 79 | bool isEmpty() const { return !mSystem && mLocalState == StateNone; } 80 | 81 | /*! Write any changes to disk 82 | * \return true on success 83 | */ 84 | bool commit(); 85 | 86 | protected: 87 | //! Returns true if the user's "local" version exists 88 | bool isLocal() const { return mLocalState != StateNone && mLocalState != StateDeleted; } 89 | 90 | /*! Removes the user's "local" version of the file, reverting to system defaults 91 | * \return true if there is no "system" version left (i.e. the entry was entirely deleted) 92 | */ 93 | bool removeLocal(); 94 | 95 | //! \brief a read-only file in /etc/xdg/autostart (or a directory in $XDG_CONFIG_DIRS) 96 | XdgDesktopFile mSystemFile; 97 | 98 | //! \brief the file in user's ~/.config/autostart (or in $XDG_CONFIG_HOME/autostart) 99 | XdgDesktopFile mLocalFile; 100 | 101 | //! State of the "local" file 102 | enum ItemState 103 | { 104 | StateNone, //! does not exist at all 105 | StateDeleted, //! needs to be deleted from disk 106 | StateTransient, //! does not yet exist on disk 107 | StateModified, //! exists on disk and is modified 108 | StateExists //! exists on disk and unmodified 109 | } mLocalState; 110 | bool mSystem; //! true if the "system" file exists 111 | }; 112 | 113 | } // namespace LXQt 114 | #endif // LXQTAUTOSTARTENTRY_H 115 | -------------------------------------------------------------------------------- /lxqtbacklight.cpp: -------------------------------------------------------------------------------- 1 | /* BEGIN_COMMON_COPYRIGHT_HEADER 2 | * (c)LGPL2+ 3 | * 4 | * LXQt - a lightweight, Qt based, desktop toolset 5 | * https://lxqt.org 6 | * 7 | * Copyright: 2016 - LXQt team 8 | * Authors: 9 | * P.L. Lucas 10 | * 11 | * This program or library is free software; you can redistribute it 12 | * and/or modify it under the terms of the GNU Lesser General Public 13 | * License as published by the Free Software Foundation; either 14 | * version 2.1 of the License, or (at your option) any later version. 15 | * 16 | * This library is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | * Lesser General Public License for more details. 20 | 21 | * You should have received a copy of the GNU Lesser General 22 | * Public License along with this library; if not, write to the 23 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 24 | * Boston, MA 02110-1301 USA 25 | * 26 | * END_COMMON_COPYRIGHT_HEADER */ 27 | 28 | #include "lxqtbacklight.h" 29 | #include "lxqtbacklight/virtual_backend.h" 30 | #ifdef USE_BACKLIGHT_LINUX_BACKEND 31 | #include "lxqtbacklight/linux_backend/linuxbackend.h" 32 | #endif 33 | 34 | namespace LXQt { 35 | 36 | Backlight::Backlight(QObject *parent):QObject(parent) 37 | { 38 | #ifdef USE_BACKLIGHT_LINUX_BACKEND 39 | m_backend = (VirtualBackEnd *) new LinuxBackend(this); 40 | #else 41 | m_backend = new VirtualBackEnd(this); 42 | #endif 43 | connect(m_backend, &VirtualBackEnd::backlightChanged, this, &Backlight::backlightChangedSlot); 44 | } 45 | 46 | Backlight::~Backlight() 47 | { 48 | delete m_backend; 49 | } 50 | 51 | int Backlight::getBacklight() 52 | { 53 | return m_backend->getBacklight(); 54 | } 55 | 56 | int Backlight::getMaxBacklight() 57 | { 58 | return m_backend->getMaxBacklight(); 59 | } 60 | 61 | bool Backlight::isBacklightAvailable() 62 | { 63 | return m_backend->isBacklightAvailable(); 64 | } 65 | 66 | bool Backlight::isBacklightOff() 67 | { 68 | return m_backend->isBacklightOff(); 69 | } 70 | 71 | void Backlight::setBacklight(int value) 72 | { 73 | m_backend->setBacklight(value); 74 | } 75 | 76 | void Backlight::backlightChangedSlot(int value) 77 | { 78 | Q_EMIT backlightChanged(value); 79 | } 80 | 81 | } // namespace LXQt 82 | -------------------------------------------------------------------------------- /lxqtbacklight.h: -------------------------------------------------------------------------------- 1 | /* BEGIN_COMMON_COPYRIGHT_HEADER 2 | * (c)LGPL2+ 3 | * 4 | * LXQt - a lightweight, Qt based, desktop toolset 5 | * https://lxqt.org 6 | * 7 | * Copyright: 2016 - LXQt team 8 | * Authors: 9 | * P.L. Lucas 10 | * 11 | * This program or library is free software; you can redistribute it 12 | * and/or modify it under the terms of the GNU Lesser General Public 13 | * License as published by the Free Software Foundation; either 14 | * version 2.1 of the License, or (at your option) any later version. 15 | * 16 | * This library is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | * Lesser General Public License for more details. 20 | 21 | * You should have received a copy of the GNU Lesser General 22 | * Public License along with this library; if not, write to the 23 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 24 | * Boston, MA 02110-1301 USA 25 | * 26 | * END_COMMON_COPYRIGHT_HEADER */ 27 | 28 | #ifndef __Backlight_H__ 29 | #define __Backlight_H__ 30 | 31 | #include 32 | #include "lxqtglobals.h" 33 | 34 | namespace LXQt 35 | { 36 | class VirtualBackEnd; 37 | 38 | class LXQT_API Backlight : public QObject 39 | { 40 | Q_OBJECT 41 | 42 | public: 43 | Backlight(QObject *parent = nullptr); 44 | ~Backlight() override; 45 | 46 | bool isBacklightAvailable(); 47 | bool isBacklightOff(); 48 | /**Sets backlight level. 49 | * @param value backlight level. Negative values turn off backlight. 50 | */ 51 | void setBacklight(int value); 52 | int getBacklight(); 53 | int getMaxBacklight(); 54 | 55 | Q_SIGNALS: 56 | void backlightChanged(int value); 57 | 58 | private Q_SLOTS: 59 | void backlightChangedSlot(int value); 60 | 61 | private: 62 | VirtualBackEnd *m_backend; 63 | }; 64 | 65 | } // namespace LXQt 66 | 67 | #endif // __Backlight_H__ 68 | -------------------------------------------------------------------------------- /lxqtbacklight/linux_backend/driver/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(lxqt-backlight_backend) 2 | 3 | set(C_FILES 4 | lxqtbacklight_backend.c 5 | ) 6 | 7 | include_directories( 8 | ${CMAKE_CURRENT_SOURCE_DIR} 9 | ${CMAKE_CURRENT_BINARY_DIR} 10 | ) 11 | 12 | add_executable(${PROJECT_NAME} 13 | ${C_FILES} 14 | ) 15 | 16 | install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin) 17 | -------------------------------------------------------------------------------- /lxqtbacklight/linux_backend/driver/libbacklight_backend.h: -------------------------------------------------------------------------------- 1 | /* BEGIN_COMMON_COPYRIGHT_HEADER 2 | * (c)LGPL2+ 3 | * 4 | * LXQt - a lightweight, Qt based, desktop toolset 5 | * https://lxqt.org 6 | * 7 | * Copyright: 2016 - LXQt team 8 | * Authors: 9 | * P.L. Lucas 10 | * 11 | * This program or library is free software; you can redistribute it 12 | * and/or modify it under the terms of the GNU Lesser General Public 13 | * License as published by the Free Software Foundation; either 14 | * version 2.1 of the License, or (at your option) any later version. 15 | * 16 | * This library is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | * Lesser General Public License for more details. 20 | 21 | * You should have received a copy of the GNU Lesser General 22 | * Public License along with this library; if not, write to the 23 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 24 | * Boston, MA 02110-1301 USA 25 | * 26 | * END_COMMON_COPYRIGHT_HEADER */ 27 | 28 | #ifndef __LXQTBACKLIGHT_BACKEND_H__ 29 | #define __LXQTBACKLIGHT_BACKEND_H__ 30 | 31 | #ifdef __cplusplus 32 | extern "C" { 33 | #endif 34 | 35 | #include 36 | 37 | /**Returns actual value of backlight. 38 | * -1 will be returned if backlight can not be changed. 39 | */ 40 | int lxqt_backlight_backend_get(); 41 | 42 | /**Returns maximum value of backlight. 43 | * -1 will be returned if backlight can not be changed. 44 | */ 45 | int lxqt_backlight_backend_get_max(); 46 | 47 | /**Returns a FILE pointer to stream which can be used to write values 48 | * of backlight. 49 | * int max_backlight = lxqt_backlight_backend_get_max(); 50 | * if(max_backlight<0) 51 | * return; // Backlight can not be controlled. 52 | * FILE *fout = lxqt_backlight_backend_write_stream(); 53 | * fprintf(fout, "%d\n", 3); 54 | * fflush(fout); 55 | * // ... Do something ... 56 | * fprintf(fout, "%d\n", 7); 57 | * fclose(fout); 58 | * Under Qt you can use QTextStream class: 59 | * FILE *fout = lxqt_backlight_backend_write_stream(); 60 | * QTextStream backlightStream(fout); 61 | * backlightStream << 3 << endl; 62 | */ 63 | FILE *lxqt_backlight_backend_get_write_stream(); 64 | 65 | /**Returns if backlight power is turned off. 66 | * @ return 0 backlight off, bigger then 0 backlight on. 67 | */ 68 | int lxqt_backlight_is_backlight_off(); 69 | 70 | /**Returns the driver. Backlight values are read from /sys/class/backlight/driver/. 71 | * Example: 72 | * char *driver = lxqt_backlight_backend_get_driver(); 73 | * printf("%s\n", driver); 74 | * free(driver); 75 | */ 76 | char *lxqt_backlight_backend_get_driver(); 77 | 78 | #ifdef __cplusplus 79 | } 80 | #endif 81 | 82 | 83 | #endif 84 | -------------------------------------------------------------------------------- /lxqtbacklight/linux_backend/driver/lxqtbacklight_backend.c: -------------------------------------------------------------------------------- 1 | /* BEGIN_COMMON_COPYRIGHT_HEADER 2 | * (c)LGPL2+ 3 | * 4 | * LXQt - a lightweight, Qt based, desktop toolset 5 | * https://lxqt.org 6 | * 7 | * Copyright: 2016 - LXQt team 8 | * Authors: 9 | * P.L. Lucas 10 | * 11 | * This program or library is free software; you can redistribute it 12 | * and/or modify it under the terms of the GNU Lesser General Public 13 | * License as published by the Free Software Foundation; either 14 | * version 2.1 of the License, or (at your option) any later version. 15 | * 16 | * This library is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | * Lesser General Public License for more details. 20 | 21 | * You should have received a copy of the GNU Lesser General 22 | * Public License along with this library; if not, write to the 23 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 24 | * Boston, MA 02110-1301 USA 25 | * 26 | * END_COMMON_COPYRIGHT_HEADER */ 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | #include "libbacklight_backend.h" 37 | #include "libbacklight_backend.c" 38 | 39 | #define True 1 40 | #define False 0 41 | 42 | /**bl_power turn off or turn on backlight. 43 | * @param driver is the driver to use 44 | * @param value 0 turns on backlight, 4 turns off backlight 45 | */ 46 | static void set_bl_power(const char *driver, int value) 47 | { 48 | FILE *out = open_driver_file("bl_power", driver, "w"); 49 | if( out != NULL ) { 50 | fprintf(out, "%d", value); 51 | fclose(out); 52 | } 53 | } 54 | 55 | 56 | static void set_backlight(const char *driver, int value) 57 | { 58 | if(value>0) { 59 | FILE *out = open_driver_file("brightness", driver, "w"); 60 | if( out != NULL ) { 61 | fprintf(out, "%d", value); 62 | fclose(out); 63 | } 64 | if(read_bl_power(driver) > 0) 65 | set_bl_power(driver, 0); 66 | } else { 67 | set_bl_power(driver, 4); 68 | } 69 | } 70 | 71 | static char *get_driver() 72 | { 73 | return lxqt_backlight_backend_get_driver(); 74 | } 75 | 76 | 77 | static void show_blacklight() 78 | { 79 | char *driver = get_driver(); 80 | if( driver == NULL ) { 81 | return; 82 | } 83 | int max_value = read_max_backlight(driver); 84 | int actual = read_backlight(driver); 85 | printf("%s %d %d\n", driver, max_value, actual); 86 | free(driver); 87 | } 88 | 89 | static void change_blacklight(int value, int percent_ok) 90 | { 91 | char *driver = get_driver(); 92 | if( driver == NULL ) { 93 | return; 94 | } 95 | int max_value = read_max_backlight(driver); 96 | if(percent_ok) { 97 | value = (float)(max_value*value)/100.0; 98 | if( value == 0 ) { 99 | // avoid switching off backlight but support zero as lowest value 100 | value = 1; 101 | } 102 | } 103 | if(value<=max_value && value>0) { 104 | set_backlight(driver, value); 105 | } 106 | free(driver); 107 | } 108 | 109 | static void increases_blacklight() 110 | { 111 | char *driver = get_driver(); 112 | if( driver == NULL ) { 113 | return; 114 | } 115 | int max_value = read_max_backlight(driver); 116 | int actual = read_backlight(driver); 117 | int incr = max_value/10; 118 | if( incr == 0 ) 119 | incr = 1; 120 | int value = actual + incr; 121 | if( value > max_value) 122 | value = max_value; 123 | if(value0) { 124 | set_backlight(driver, value); 125 | } 126 | free(driver); 127 | } 128 | 129 | static void decreases_blacklight() 130 | { 131 | char *driver = get_driver(); 132 | if( driver == NULL ) { 133 | return; 134 | } 135 | int max_value = read_max_backlight(driver); 136 | int actual = read_backlight(driver); 137 | int decr = max_value/10; 138 | if( decr == 0 ) 139 | decr = 1; 140 | int value = actual - decr; 141 | if( value <= 0 ) 142 | value = 1; 143 | if(value 0 && value <= max_value) { 160 | set_backlight(driver, value); 161 | } 162 | } 163 | free(driver); 164 | } 165 | 166 | static void help(char *argv0) 167 | { 168 | printf("%s [backlight-level [ %% ]] [--help]\n" 169 | "--help Shows this message.\n" 170 | "--show Shows actual brightness level.\n" 171 | "--inc Increases actual brightness level.\n" 172 | "--dec Decreases actual brightness level.\n" 173 | "--stdin Read backlight value from stdin\n" 174 | "backlight-level Sets backlight\n" 175 | "backlight-level %% Sets backlight from 1%% to 100%%\n" 176 | "This tool changes screen backlight.\n" 177 | "Example:\n" 178 | "%s 10 %% Sets backlight level until 10%%.\n" 179 | , argv0, argv0 180 | ); 181 | } 182 | 183 | 184 | int main(int argc, char *argv[]) 185 | { 186 | int value = -1, value_percent_ok = False; 187 | int n; 188 | for(n=1; n 10 | * 11 | * This program or library is free software; you can redistribute it 12 | * and/or modify it under the terms of the GNU Lesser General Public 13 | * License as published by the Free Software Foundation; either 14 | * version 2.1 of the License, or (at your option) any later version. 15 | * 16 | * This library is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | * Lesser General Public License for more details. 20 | 21 | * You should have received a copy of the GNU Lesser General 22 | * Public License along with this library; if not, write to the 23 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 24 | * Boston, MA 02110-1301 USA 25 | * 26 | * END_COMMON_COPYRIGHT_HEADER */ 27 | 28 | #include "driver/libbacklight_backend.h" 29 | 30 | #ifdef __cplusplus 31 | extern "C" { 32 | #endif 33 | #include "driver/libbacklight_backend.c" 34 | #ifdef __cplusplus 35 | } 36 | #endif 37 | 38 | #include "linuxbackend.h" 39 | #include 40 | #include 41 | 42 | namespace LXQt { 43 | 44 | LinuxBackend::LinuxBackend(QObject *parent):VirtualBackEnd(parent) 45 | { 46 | maxBacklight = lxqt_backlight_backend_get_max(); 47 | backlightStream = NULL; 48 | if( isBacklightAvailable() ) { 49 | char *driver = lxqt_backlight_backend_get_driver(); 50 | fileSystemWatcher = new QFileSystemWatcher(this); 51 | fileSystemWatcher->addPath(QString::fromLatin1("/sys/class/backlight/%1/actual_brightness").arg(QL1SV(driver))); 52 | fileSystemWatcher->addPath(QString::fromLatin1("/sys/class/backlight/%1/brightness").arg(QL1SV(driver))); 53 | fileSystemWatcher->addPath(QString::fromLatin1("/sys/class/backlight/%1/bl_power").arg(QL1SV(driver))); 54 | free(driver); 55 | actualBacklight = lxqt_backlight_backend_get(); 56 | connect(fileSystemWatcher, &QFileSystemWatcher::fileChanged, 57 | this, &LinuxBackend::fileSystemChanged); 58 | } 59 | } 60 | 61 | LinuxBackend::~LinuxBackend() 62 | { 63 | closeBacklightStream(); 64 | } 65 | 66 | int LinuxBackend::getBacklight() 67 | { 68 | actualBacklight = lxqt_backlight_backend_get(); 69 | return actualBacklight; 70 | } 71 | 72 | int LinuxBackend::getMaxBacklight() 73 | { 74 | return maxBacklight; 75 | } 76 | 77 | bool LinuxBackend::isBacklightAvailable() 78 | { 79 | return maxBacklight > 0; 80 | } 81 | 82 | bool LinuxBackend::isBacklightOff() 83 | { 84 | return lxqt_backlight_is_backlight_off() > 0; 85 | } 86 | 87 | void LinuxBackend::setBacklight(int value) 88 | { 89 | if( ! isBacklightAvailable() ) 90 | return; 91 | if( backlightStream == NULL ) { 92 | backlightStream = lxqt_backlight_backend_get_write_stream(); 93 | if( backlightStream != NULL ) { 94 | // Close stream after 60 seconds 95 | QTimer::singleShot(60000, this, SLOT(closeBacklightStream())); 96 | } 97 | } 98 | if( backlightStream != NULL ) { 99 | // normalize the value (to work around an issue in QSlider) 100 | value = qBound(0, value, maxBacklight); 101 | fprintf(backlightStream, "%d\n", value); 102 | fflush(backlightStream); 103 | } 104 | } 105 | 106 | void LinuxBackend::closeBacklightStream() 107 | { 108 | if( backlightStream != NULL ) { 109 | fclose(backlightStream); 110 | backlightStream = NULL; 111 | } 112 | } 113 | 114 | void LinuxBackend::fileSystemChanged(const QString & /*path*/) 115 | { 116 | int value = actualBacklight; 117 | if( value != getBacklight() ) { 118 | Q_EMIT backlightChanged(actualBacklight); 119 | } 120 | } 121 | 122 | } // namespace LXQt 123 | -------------------------------------------------------------------------------- /lxqtbacklight/linux_backend/linuxbackend.h: -------------------------------------------------------------------------------- 1 | /* BEGIN_COMMON_COPYRIGHT_HEADER 2 | * (c)LGPL2+ 3 | * 4 | * LXQt - a lightweight, Qt based, desktop toolset 5 | * https://lxqt.org 6 | * 7 | * Copyright: 2016 - LXQt team 8 | * Authors: 9 | * P.L. Lucas 10 | * 11 | * This program or library is free software; you can redistribute it 12 | * and/or modify it under the terms of the GNU Lesser General Public 13 | * License as published by the Free Software Foundation; either 14 | * version 2.1 of the License, or (at your option) any later version. 15 | * 16 | * This library is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | * Lesser General Public License for more details. 20 | 21 | * You should have received a copy of the GNU Lesser General 22 | * Public License along with this library; if not, write to the 23 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 24 | * Boston, MA 02110-1301 USA 25 | * 26 | * END_COMMON_COPYRIGHT_HEADER */ 27 | 28 | #ifndef __LinuxBackend_H__ 29 | #define __LinuxBackend_H__ 30 | 31 | #include "../virtual_backend.h" 32 | #include 33 | #include 34 | 35 | namespace LXQt 36 | { 37 | 38 | class LinuxBackend:public VirtualBackEnd 39 | { 40 | Q_OBJECT 41 | 42 | public: 43 | LinuxBackend(QObject *parent = nullptr); 44 | ~LinuxBackend() override; 45 | 46 | bool isBacklightAvailable() override; 47 | bool isBacklightOff() override; 48 | void setBacklight(int value) override; 49 | int getBacklight() override; 50 | int getMaxBacklight() override; 51 | 52 | private Q_SLOTS: 53 | void closeBacklightStream(); 54 | void fileSystemChanged(const QString & path); 55 | 56 | private: 57 | int maxBacklight; 58 | int actualBacklight; 59 | QFileSystemWatcher *fileSystemWatcher; 60 | FILE *backlightStream; 61 | }; 62 | 63 | } // namespace LXQt 64 | 65 | #endif // __LinuxBackend_H__ 66 | -------------------------------------------------------------------------------- /lxqtbacklight/virtual_backend.cpp: -------------------------------------------------------------------------------- 1 | /* BEGIN_COMMON_COPYRIGHT_HEADER 2 | * (c)LGPL2+ 3 | * 4 | * LXQt - a lightweight, Qt based, desktop toolset 5 | * https://lxqt.org 6 | * 7 | * Copyright: 2016 - LXQt team 8 | * Authors: 9 | * P.L. Lucas 10 | * 11 | * This program or library is free software; you can redistribute it 12 | * and/or modify it under the terms of the GNU Lesser General Public 13 | * License as published by the Free Software Foundation; either 14 | * version 2.1 of the License, or (at your option) any later version. 15 | * 16 | * This library is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | * Lesser General Public License for more details. 20 | 21 | * You should have received a copy of the GNU Lesser General 22 | * Public License along with this library; if not, write to the 23 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 24 | * Boston, MA 02110-1301 USA 25 | * 26 | * END_COMMON_COPYRIGHT_HEADER */ 27 | 28 | #include "virtual_backend.h" 29 | 30 | namespace LXQt { 31 | 32 | VirtualBackEnd::VirtualBackEnd(QObject *parent):QObject(parent) 33 | { 34 | } 35 | 36 | bool VirtualBackEnd::isBacklightAvailable() 37 | { 38 | return false; 39 | } 40 | 41 | bool VirtualBackEnd::isBacklightOff() 42 | { 43 | return false; 44 | } 45 | 46 | void VirtualBackEnd::setBacklight(int /*value*/) 47 | { 48 | } 49 | 50 | int VirtualBackEnd::getBacklight() 51 | { 52 | return -1; 53 | } 54 | 55 | int VirtualBackEnd::getMaxBacklight() 56 | { 57 | return -1; 58 | } 59 | 60 | } // namespace LXQt 61 | -------------------------------------------------------------------------------- /lxqtbacklight/virtual_backend.h: -------------------------------------------------------------------------------- 1 | /* BEGIN_COMMON_COPYRIGHT_HEADER 2 | * (c)LGPL2+ 3 | * 4 | * LXQt - a lightweight, Qt based, desktop toolset 5 | * https://lxqt.org 6 | * 7 | * Copyright: 2016 - LXQt team 8 | * Authors: 9 | * P.L. Lucas 10 | * 11 | * This program or library is free software; you can redistribute it 12 | * and/or modify it under the terms of the GNU Lesser General Public 13 | * License as published by the Free Software Foundation; either 14 | * version 2.1 of the License, or (at your option) any later version. 15 | * 16 | * This library is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | * Lesser General Public License for more details. 20 | 21 | * You should have received a copy of the GNU Lesser General 22 | * Public License along with this library; if not, write to the 23 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 24 | * Boston, MA 02110-1301 USA 25 | * 26 | * END_COMMON_COPYRIGHT_HEADER */ 27 | 28 | #ifndef __VirtualBackend_H__ 29 | #define __VirtualBackend_H__ 30 | 31 | #include 32 | #include "lxqtglobals.h" 33 | 34 | namespace LXQt 35 | { 36 | 37 | class LXQT_API VirtualBackEnd:public QObject 38 | { 39 | Q_OBJECT 40 | 41 | public: 42 | VirtualBackEnd(QObject *parent = nullptr); 43 | 44 | virtual bool isBacklightAvailable(); 45 | virtual bool isBacklightOff(); 46 | virtual void setBacklight(int value); 47 | virtual int getBacklight(); 48 | virtual int getMaxBacklight(); 49 | 50 | Q_SIGNALS: 51 | void backlightChanged(int value); 52 | }; 53 | 54 | } // namespace LXQt 55 | 56 | #endif // __VirtualBackend_H__ 57 | -------------------------------------------------------------------------------- /lxqtglobals.h: -------------------------------------------------------------------------------- 1 | /* BEGIN_COMMON_COPYRIGHT_HEADER 2 | * (c)LGPL2+ 3 | * 4 | * LXQt - a lightweight, Qt based, desktop toolset 5 | * https://lxqt.org 6 | * 7 | * Copyright: 2013 - LXQt team 8 | * Authors: 9 | * Hong Jen Yee (PCMan) 10 | * 11 | * This program or library is free software; you can redistribute it 12 | * and/or modify it under the terms of the GNU Lesser General Public 13 | * License as published by the Free Software Foundation; either 14 | * version 2.1 of the License, or (at your option) any later version. 15 | * 16 | * This library is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | * Lesser General Public License for more details. 20 | 21 | * You should have received a copy of the GNU Lesser General 22 | * Public License along with this library; if not, write to the 23 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 24 | * Boston, MA 02110-1301 USA 25 | * 26 | * END_COMMON_COPYRIGHT_HEADER */ 27 | 28 | #ifndef _LXQT_GLOBALS_H_ 29 | #define _LXQT_GLOBALS_H_ 30 | 31 | #include 32 | 33 | #ifdef COMPILE_LIBLXQT 34 | #define LXQT_API Q_DECL_EXPORT 35 | #else 36 | #define LXQT_API Q_DECL_IMPORT 37 | #endif 38 | 39 | #ifndef QL1S 40 | #define QL1S(x) QLatin1StringView(x) 41 | #endif 42 | 43 | #ifndef QL1SV 44 | #define QL1SV(x) QLatin1StringView(x) 45 | #endif 46 | 47 | #ifndef QL1C 48 | #define QL1C(x) QLatin1Char(x) 49 | #endif 50 | 51 | #ifndef QSL 52 | #define QSL(x) QStringLiteral(x) 53 | #endif 54 | 55 | #ifndef QBAL 56 | #define QBAL(x) QByteArrayLiteral(x) 57 | #endif 58 | 59 | #endif // _LXQT_GLOBALS_H_ 60 | -------------------------------------------------------------------------------- /lxqthtmldelegate.cpp: -------------------------------------------------------------------------------- 1 | /* BEGIN_COMMON_COPYRIGHT_HEADER 2 | * (c)LGPL2+ 3 | * 4 | * LXQt - a lightweight, Qt based, desktop toolset 5 | * https://lxqt.org 6 | * 7 | * Copyright: 2010-2011 Razor team 8 | * Authors: 9 | * Alexander Sokoloff 10 | * Paulo Lieuthier 11 | * 12 | * This program or library is free software; you can redistribute it 13 | * and/or modify it under the terms of the GNU Lesser General Public 14 | * License as published by the Free Software Foundation; either 15 | * version 2.1 of the License, or (at your option) any later version. 16 | * 17 | * This library is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | * Lesser General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU Lesser General 23 | * Public License along with this library; if not, write to the 24 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 25 | * Boston, MA 02110-1301 USA 26 | * 27 | * END_COMMON_COPYRIGHT_HEADER */ 28 | 29 | #include "lxqthtmldelegate.h" 30 | #include 31 | #include 32 | #include 33 | 34 | using namespace LXQt; 35 | 36 | 37 | HtmlDelegate::HtmlDelegate(const QSize iconSize, QObject* parent) : 38 | QStyledItemDelegate(parent), 39 | mIconSize(iconSize) 40 | { 41 | } 42 | 43 | HtmlDelegate::~HtmlDelegate() = default; 44 | 45 | /************************************************ 46 | 47 | ************************************************/ 48 | void HtmlDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const 49 | { 50 | if (!index.isValid()) 51 | return; 52 | 53 | QStyleOptionViewItem options = option; 54 | initStyleOption(&options, index); 55 | const bool is_right_to_left = Qt::RightToLeft == options.direction; 56 | 57 | painter->save(); 58 | 59 | QTextDocument doc; 60 | doc.setHtml(options.text); 61 | QIcon icon = options.icon; 62 | 63 | // icon size 64 | const QSize iconSize = icon.actualSize(mIconSize); 65 | // center the icon vertically 66 | QRect iconRect = QRect(8, qMax(options.rect.height() - iconSize.height(), 0) / 2, 67 | iconSize.width(), iconSize.height()); 68 | if (is_right_to_left) 69 | { 70 | iconRect.moveLeft(options.rect.left() + options.rect.right() - iconRect.x() - iconRect.width() + 1); 71 | } 72 | 73 | // set doc size 74 | // NOTE: Qt has a bug, because of which HTML tags are included in QTextDocument::setTextWidth() 75 | // when the text is set by QTextDocument::setHtml(). 76 | // As a result, the text height may be a little greater than needed. 77 | doc.setTextWidth(options.rect.width() - iconRect.width() - 8 - 8); // 8-px icon-text spacing 78 | 79 | // draw the item's panel 80 | const QWidget* widget = option.widget; 81 | QStyle* style = widget ? widget->style() : QApplication::style(); 82 | style->drawPrimitive(QStyle::PE_PanelItemViewItem, &options, painter, widget); 83 | 84 | // paint icon 85 | painter->translate(options.rect.left(), options.rect.top()); 86 | icon.paint(painter, iconRect); 87 | 88 | // center the text vertically 89 | painter->translate(0, qMax(static_cast(options.rect.height()) - doc.size().height(), 0.0) / 2.0); 90 | 91 | if (!is_right_to_left) 92 | { 93 | // shift text right to make icon visible 94 | painter->translate((iconRect.right() + 1) + 8, 0); 95 | } 96 | const QRect clip(0, 0, options.rect.width() - iconRect.width() - 8, options.rect.height()); 97 | painter->setClipRect(clip); 98 | 99 | // set text colors 100 | QAbstractTextDocumentLayout::PaintContext ctx; 101 | QPalette::ColorGroup colorGroup = (option.state & QStyle::State_Active) ? QPalette::Active : QPalette::Inactive; 102 | if (option.state & QStyle::State_Selected) // selected items 103 | ctx.palette.setColor(QPalette::Text, option.palette.color(colorGroup, QPalette::HighlightedText)); 104 | else // ordinary items and those with an alternate base color (there is no alternate text color) 105 | ctx.palette.setColor(QPalette::Text, option.palette.color(colorGroup, QPalette::Text)); 106 | 107 | ctx.clip = clip; 108 | doc.documentLayout()->draw(painter, ctx); 109 | 110 | painter->restore(); 111 | } 112 | 113 | 114 | /************************************************ 115 | 116 | ************************************************/ 117 | QSize HtmlDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const 118 | { 119 | QStyleOptionViewItem options = option; 120 | initStyleOption(&options, index); 121 | 122 | const QSize iconSize = options.icon.actualSize(mIconSize); 123 | // 8-px left, top and bottom margins for the icon 124 | const QRect iconRect = QRect(8, 8, iconSize.width(), iconSize.height()); 125 | const int w = options.rect.width(); 126 | 127 | QTextDocument doc; 128 | doc.setHtml(options.text); 129 | 130 | if (w > 0) 131 | doc.setTextWidth(static_cast(w - (iconRect.right() + 1) - 8)); // 8-px icon-text spacing 132 | else 133 | doc.adjustSize(); 134 | return {w > 0 ? w : iconRect.width() + 8 + qRound(doc.size().width()) + 8, 135 | qMax(qRound(doc.size().height() + 8), // 4-px top/bottom text spacing 136 | iconSize.height() + 16)}; 137 | } 138 | -------------------------------------------------------------------------------- /lxqthtmldelegate.h: -------------------------------------------------------------------------------- 1 | /* BEGIN_COMMON_COPYRIGHT_HEADER 2 | * (c)LGPL2+ 3 | * 4 | * LXQt - a lightweight, Qt based, desktop toolset 5 | * https://lxqt.org 6 | * 7 | * Copyright: 2010-2011 Razor team 8 | * Authors: 9 | * Alexander Sokoloff 10 | * Paulo Lieuthier 11 | * 12 | * This program or library is free software; you can redistribute it 13 | * and/or modify it under the terms of the GNU Lesser General Public 14 | * License as published by the Free Software Foundation; either 15 | * version 2.1 of the License, or (at your option) any later version. 16 | * 17 | * This library is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | * Lesser General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU Lesser General 23 | * Public License along with this library; if not, write to the 24 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 25 | * Boston, MA 02110-1301 USA 26 | * 27 | * END_COMMON_COPYRIGHT_HEADER */ 28 | 29 | #ifndef LXQTHTMLDELEGATE_H 30 | #define LXQTHTMLDELEGATE_H 31 | 32 | #include 33 | #include 34 | #include "lxqtglobals.h" 35 | 36 | namespace LXQt 37 | { 38 | 39 | class LXQT_API HtmlDelegate : public QStyledItemDelegate 40 | { 41 | Q_OBJECT 42 | 43 | public: 44 | explicit HtmlDelegate(const QSize iconSize, QObject* parent = nullptr); 45 | ~HtmlDelegate() override; 46 | 47 | void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override; 48 | 49 | QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const override; 50 | 51 | private: 52 | QSize mIconSize; 53 | }; 54 | 55 | } 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /lxqtnotification.h: -------------------------------------------------------------------------------- 1 | /* BEGIN_COMMON_COPYRIGHT_HEADER 2 | * (c)LGPL2+ 3 | * 4 | * LXQt - a lightweight, Qt based, desktop toolset 5 | * https://lxqt.org 6 | * 7 | * Copyright (C) 2012 Alec Moskvin 8 | * 9 | * This library is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU Lesser General Public 11 | * License as published by the Free Software Foundation; either 12 | * version 2.1 of the License, or (at your option) any later version. 13 | 14 | * This library is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | * Lesser General Public License for more details. 18 | 19 | * You should have received a copy of the GNU Lesser General Public 20 | * License along with this library; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 22 | * 23 | * END_COMMON_COPYRIGHT_HEADER */ 24 | 25 | #ifndef LXQTNOTIFICATION_H 26 | #define LXQTNOTIFICATION_H 27 | 28 | #include 29 | #include 30 | #include "lxqtglobals.h" 31 | 32 | namespace LXQt 33 | { 34 | 35 | class NotificationPrivate; 36 | 37 | /** 38 | * \brief Libnotify-style desktop notifications 39 | * 40 | * Spec: http://developer.gnome.org/notification-spec 41 | */ 42 | class LXQT_API Notification : public QObject 43 | { 44 | Q_OBJECT 45 | public: 46 | /*! 47 | * \brief Notification is an object that represents a single notification. 48 | * \param summary Summary text briefly describing the notification (required by the spec) 49 | */ 50 | Notification(const QString& summary = QString(), QObject* parent = nullptr); 51 | ~Notification() override; 52 | 53 | enum CloseReason 54 | { 55 | //! The notification expired. 56 | Expired = 1, 57 | //! The notification was dismissed by the user. 58 | Dismissed = 2, 59 | //! The notification was closed by a call to close(). 60 | ForceClosed = 3, 61 | //! Undefined/reserved reasons. 62 | Unknown = 4 63 | }; 64 | 65 | enum Urgency 66 | { 67 | UrgencyLow = 0, 68 | UrgencyNormal = 1, 69 | UrgencyCritical = 2 70 | }; 71 | 72 | struct ServerInfo 73 | { 74 | //! The product name of the server. 75 | QString name; 76 | //! The vendor name. For example, "lxqt.org" 77 | QString vendor; 78 | //! The server's version number. 79 | QString version; 80 | //! The specification version the server is compliant with. 81 | QString specVersion; 82 | }; 83 | 84 | /*! 85 | * \brief Set the summary text briefly describing the notification 86 | */ 87 | void setSummary(const QString& summary); 88 | 89 | /*! 90 | * \brief Set the detailed body text 91 | */ 92 | void setBody(const QString& body); 93 | 94 | /*! 95 | * \brief Set an icon to display 96 | * \param iconName Name of the icon 97 | */ 98 | void setIcon(const QString& iconName); 99 | 100 | /*! 101 | * \brief Set action buttons for the notification. Whenever an action is 102 | * activated, the actionActivated() signal is emitted with the list 103 | * index of the activated action. 104 | * \param actions List of action button titles 105 | * \param defaultAction Index of the default action which gets activated 106 | * when the notification body is clicked 107 | * \sa actionActivated() 108 | */ 109 | void setActions(const QStringList& actions, int defaultAction = -1); 110 | 111 | /*! 112 | * \brief Set the timeout for the notification 113 | * \param timeout Milliseconds for timeout, or zero to never time out. 114 | */ 115 | void setTimeout(int timeout); 116 | 117 | /*! 118 | * \brief Set notification hint. 119 | * \note For description of Hints, see http://developer.gnome.org/notification-spec/#hints 120 | * \note For D-Bus-to-Qt mappings, see https://qt-project.org/doc/qdbustypesystem.html 121 | * \param hint Hint name 122 | * \param value The hint data 123 | */ 124 | void setHint(const QString& hint, const QVariant& value); 125 | 126 | /*! 127 | * \brief Set the "urgency" hint 128 | * \param urgency 129 | */ 130 | void setUrgencyHint(Urgency urgency); 131 | 132 | /*! 133 | * \brief Remove all hints that were set 134 | * \sa setHint() 135 | */ 136 | void clearHints(); 137 | 138 | /*! 139 | * \brief returns a list of optional capabilities supported by the server. 140 | * For the list, see http://developer.gnome.org/notification-spec/#commands 141 | */ 142 | QStringList getCapabilities(); 143 | 144 | /*! 145 | * \brief Returns information about the notifications server 146 | * \note This call may block for up to 25s (default dbus timeout) if the notification server 147 | * is not running and the info wasn't previously queried. 148 | * \sa queryServerInfo() 149 | */ 150 | const ServerInfo serverInfo(); 151 | 152 | /*! 153 | * \brief Performs an asynchronous query of the notifications server information. 154 | * Use serverInfoReady signal to get notified (no pun intended) when the 155 | * info will be received. 156 | * \sa serverInfo() 157 | * \sa serverInfoReady() 158 | */ 159 | void queryServerInfo(); 160 | 161 | /*! 162 | * \brief Convenience function to create and display a notification for the most common 163 | * cases. For anything more complex, create a Notification object, set the 164 | * desired properties and call update(). (That's what this does internally.) 165 | * \sa Notification() 166 | */ 167 | static void notify(const QString& summary, 168 | const QString& body = QString(), 169 | const QString& iconName = QString() 170 | ); 171 | 172 | public Q_SLOTS: 173 | /*! 174 | * \brief Display the notification or update it if it's already visible 175 | */ 176 | void update(); 177 | 178 | /*! 179 | * \brief Causes a notification to be forcefully closed and removed from the user's view. 180 | * It can be used, for example, in the event that what the notification pertains to 181 | * is no longer relevant, or to cancel a notification with no expiration time. 182 | */ 183 | void close(); 184 | 185 | Q_SIGNALS: 186 | /*! 187 | * \brief Emitted when the notification is closed 188 | * \param reason How notification was closed 189 | */ 190 | void notificationClosed(LXQt::Notification::CloseReason reason); 191 | 192 | /*! 193 | * \brief Emitted when an action button is activated. 194 | * \param actionNumber Index of the actions array for the activated button. 195 | * \sa setActions() 196 | */ 197 | void actionActivated(int actionNumber); 198 | 199 | /*! 200 | * \brief Emitted when queried server info is received 201 | * \sa queryServerInfo() 202 | */ 203 | void serverInfoReady(); 204 | 205 | private: 206 | Q_DECLARE_PRIVATE(Notification) 207 | NotificationPrivate* const d_ptr; 208 | }; 209 | 210 | } // namespace LXQt 211 | #endif // LXQTNOTIFICATION_H 212 | -------------------------------------------------------------------------------- /lxqtnotification_p.h: -------------------------------------------------------------------------------- 1 | /* BEGIN_COMMON_COPYRIGHT_HEADER 2 | * (c)LGPL2+ 3 | * 4 | * LXQt - a lightweight, Qt based, desktop toolset 5 | * https://lxqt.org 6 | * 7 | * Copyright (C) 2012 Alec Moskvin 8 | * 9 | * This library is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU Lesser General Public 11 | * License as published by the Free Software Foundation; either 12 | * version 2.1 of the License, or (at your option) any later version. 13 | 14 | * This library is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | * Lesser General Public License for more details. 18 | 19 | * You should have received a copy of the GNU Lesser General Public 20 | * License along with this library; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 22 | * 23 | * END_COMMON_COPYRIGHT_HEADER */ 24 | 25 | #ifndef LXQTNOTIFICATION_P_H 26 | #define LXQTNOTIFICATION_P_H 27 | 28 | #include "lxqtnotification.h" 29 | #include "notifications_interface.h" 30 | 31 | namespace LXQt 32 | { 33 | 34 | class NotificationPrivate : public QObject 35 | { 36 | Q_OBJECT 37 | public: 38 | NotificationPrivate(const QString& summary, Notification* parent); 39 | ~NotificationPrivate() override; 40 | 41 | void update(); 42 | void close(); 43 | void setActions(QStringList actions, int defaultAction); 44 | const Notification::ServerInfo serverInfo(); 45 | void queryServerInfo(bool async=1); 46 | 47 | public Q_SLOTS: 48 | void handleAction(uint id, const QString& key); 49 | void notificationClosed(uint, uint); 50 | 51 | private: 52 | OrgFreedesktopNotificationsInterface* mInterface; 53 | uint mId; 54 | 55 | QString mSummary; 56 | QString mBody; 57 | QString mIconName; 58 | QStringList mActions; 59 | QVariantMap mHints; 60 | int mDefaultAction; 61 | int mTimeout; 62 | 63 | static Notification::ServerInfo sServerInfo; 64 | static bool sIsServerInfoQuried; 65 | 66 | Notification* const q_ptr; 67 | Q_DECLARE_PUBLIC(Notification) 68 | }; 69 | 70 | } // namespace LXQt 71 | #endif // LXQTNOTIFICATION_P_H 72 | -------------------------------------------------------------------------------- /lxqtplugininfo.cpp: -------------------------------------------------------------------------------- 1 | /* BEGIN_COMMON_COPYRIGHT_HEADER 2 | * (c)LGPL2+ 3 | * 4 | * LXQt - a lightweight, Qt based, desktop toolset 5 | * https://lxqt.org 6 | * 7 | * Copyright: 2010-2011 Razor team 8 | * Authors: 9 | * Alexander Sokoloff 10 | * 11 | * This program or library is free software; you can redistribute it 12 | * and/or modify it under the terms of the GNU Lesser General Public 13 | * License as published by the Free Software Foundation; either 14 | * version 2.1 of the License, or (at your option) any later version. 15 | * 16 | * This library is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | * Lesser General Public License for more details. 20 | 21 | * You should have received a copy of the GNU Lesser General 22 | * Public License along with this library; if not, write to the 23 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 24 | * Boston, MA 02110-1301 USA 25 | * 26 | * END_COMMON_COPYRIGHT_HEADER */ 27 | 28 | 29 | #include "lxqtplugininfo.h" 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | 39 | using namespace LXQt; 40 | 41 | /************************************************ 42 | 43 | ************************************************/ 44 | PluginInfo::PluginInfo(): 45 | XdgDesktopFile() 46 | { 47 | 48 | } 49 | 50 | 51 | /************************************************ 52 | 53 | ************************************************/ 54 | bool PluginInfo::load(const QString& fileName) 55 | { 56 | XdgDesktopFile::load(fileName); 57 | mId = QFileInfo(fileName).completeBaseName(); 58 | return isValid(); 59 | } 60 | 61 | 62 | /************************************************ 63 | 64 | ************************************************/ 65 | bool PluginInfo::isValid() const 66 | { 67 | return XdgDesktopFile::isValid(); 68 | } 69 | 70 | 71 | /************************************************ 72 | 73 | ************************************************/ 74 | QLibrary* PluginInfo::loadLibrary(const QString& libDir) const 75 | { 76 | const QFileInfo fi = QFileInfo(fileName()); 77 | const QString path = fi.canonicalPath(); 78 | const QString baseName = value(QL1SV("X-LXQt-Library"), fi.completeBaseName()).toString(); 79 | 80 | const QString soPath = QDir(libDir).filePath(QString::fromLatin1("lib%2.so").arg(baseName)); 81 | QLibrary* library = new QLibrary(soPath); 82 | 83 | if (!library->load()) 84 | { 85 | qWarning() << QString::fromLatin1("Can't load plugin lib \"%1\"").arg(soPath) << library->errorString(); 86 | delete library; 87 | return nullptr; 88 | } 89 | 90 | const QString locale = QLocale::system().name(); 91 | QTranslator* translator = new QTranslator(library); 92 | 93 | if(!translator->load(QString::fromLatin1("%1/%2/%2_%3.qm").arg(path, baseName, locale))) 94 | { 95 | qWarning() << QString::fromLatin1("Can't load translator: ").arg(translator->filePath()); 96 | } 97 | qApp->installTranslator(translator); 98 | 99 | return library; 100 | } 101 | 102 | 103 | /************************************************ 104 | 105 | ************************************************/ 106 | PluginInfoList PluginInfo::search(const QStringList& desktopFilesDirs, const QString& serviceType, const QString& nameFilter) 107 | { 108 | QList res; 109 | QSet processed; 110 | 111 | for (const QString &desktopFilesDir : desktopFilesDirs) 112 | { 113 | const QDir dir(desktopFilesDir); 114 | const QFileInfoList files = dir.entryInfoList(QStringList(nameFilter), QDir::Files | QDir::Readable); 115 | for (const QFileInfo &file : files) 116 | { 117 | if (processed.contains(file.fileName())) 118 | continue; 119 | 120 | processed << file.fileName(); 121 | 122 | PluginInfo item; 123 | item.load(file.canonicalFilePath()); 124 | 125 | if (item.isValid() && item.serviceType() == serviceType) 126 | res.append(item); 127 | } 128 | } 129 | return res; 130 | } 131 | 132 | 133 | /************************************************ 134 | 135 | ************************************************/ 136 | PluginInfoList PluginInfo::search(const QString& desktopFilesDir, const QString& serviceType, const QString& nameFilter) 137 | { 138 | return search(QStringList(desktopFilesDir), serviceType, nameFilter); 139 | } 140 | 141 | 142 | /************************************************ 143 | 144 | ************************************************/ 145 | LXQT_API QDebug operator<<(QDebug dbg, const LXQt::PluginInfo &pluginInfo) 146 | { 147 | dbg.nospace() << QString::fromLatin1("%1").arg(pluginInfo.id()); 148 | return dbg.space(); 149 | } 150 | 151 | 152 | /************************************************ 153 | 154 | ************************************************/ 155 | LXQT_API QDebug operator<<(QDebug dbg, const PluginInfoList& list) 156 | { 157 | dbg.nospace() << QL1C('('); 158 | for (int i=0; i 10 | * 11 | * This program or library is free software; you can redistribute it 12 | * and/or modify it under the terms of the GNU Lesser General Public 13 | * License as published by the Free Software Foundation; either 14 | * version 2.1 of the License, or (at your option) any later version. 15 | * 16 | * This library is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | * Lesser General Public License for more details. 20 | 21 | * You should have received a copy of the GNU Lesser General 22 | * Public License along with this library; if not, write to the 23 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 24 | * Boston, MA 02110-1301 USA 25 | * 26 | * END_COMMON_COPYRIGHT_HEADER */ 27 | 28 | 29 | #ifndef LXQTPLUGININFO_H 30 | #define LXQTPLUGININFO_H 31 | 32 | #include 33 | #include 34 | 35 | #include 36 | #include 37 | #include 38 | #include "lxqtglobals.h" 39 | 40 | #include 41 | 42 | class QLibrary; 43 | 44 | namespace LXQt 45 | { 46 | 47 | /*! 48 | Every plugin needs a .desktop file that describes it. The basename of this file must 49 | be same as the basename of the plugin library. 50 | 51 | lxqtpanel_clock2.desktop file 52 | 53 | [Desktop Entry] 54 | Type=Service 55 | ServiceTypes=LXQtPanel/Plugin 56 | Name=Clock 57 | Comment=Clock and calendar 58 | 59 | PluginInfo class gives the interface for reading the values from the plugin .desktop file. 60 | This is a pure virtual class, you must implement libraryDir(), translationDir(), and instance() methods. 61 | */ 62 | class LXQT_API PluginInfo: public XdgDesktopFile 63 | { 64 | public: 65 | /// Constructs a PluginInfo object for accessing the info stored in the .desktop file. 66 | explicit PluginInfo(); 67 | 68 | //! Reimplemented from XdgDesktopFile. 69 | bool load(const QString& fileName) override; 70 | 71 | 72 | //! Reimplemented from XdgDesktopFile. 73 | //PluginInfo& operator=(const PluginInfo& other); 74 | 75 | 76 | //! Returns identification string of this plugin, identified plugin type. Now id is part of the filename. 77 | QString id() const { return mId; } 78 | 79 | //! This function is provided for convenience. It's equivalent to calling value("ServiceTypes").toString(). 80 | QString serviceType() const { return value(QL1SV("ServiceTypes")).toString(); } 81 | 82 | //! Reimplemented from XdgDesktopFile. 83 | virtual bool isValid() const; 84 | 85 | /*! Loads the library and returns QLibrary object if the library was loaded successfully; otherwise returns 0. 86 | @parm libDir directory where placed the plugin .so file. */ 87 | QLibrary* loadLibrary(const QString& libDir) const; 88 | 89 | 90 | /*! Returns a list of PluginInfo objects for the matched files in the directories. 91 | @param desktopFilesDirs - scanned directories names. 92 | @param serviceType - type of the plugin, for example "LXQtPanel/Plugin". 93 | @param nameFilter - wildcard filter that understands * and ? wildcards. 94 | 95 | If the same filename is located under multiple directories only the first file should be used. 96 | */ 97 | static QList search(const QStringList& desktopFilesDirs, const QString& serviceType, const QString& nameFilter = QL1SV("*")); 98 | 99 | /// This function is provided for convenience. It's equivalent to new calling search(QString(desktopFilesDir), serviceType, nameFilter) 100 | static QList search(const QString& desktopFilesDir, const QString& serviceType, const QString& nameFilter = QL1SV("*")); 101 | 102 | private: 103 | QString mId; 104 | }; 105 | 106 | typedef QList PluginInfoList; 107 | 108 | } // namespace LXQt 109 | 110 | LXQT_API QDebug operator<<(QDebug dbg, const LXQt::PluginInfo& pi); 111 | LXQT_API QDebug operator<<(QDebug dbg, const LXQt::PluginInfoList& list); 112 | 113 | inline QDebug operator<<(QDebug dbg, const LXQt::PluginInfo * const pluginInfo) 114 | { 115 | return operator<<(std::move(dbg), *pluginInfo); 116 | } 117 | 118 | inline QDebug operator<<(QDebug dbg, const LXQt::PluginInfoList* const pluginInfoList) 119 | { 120 | return operator<<(std::move(dbg), *pluginInfoList); 121 | } 122 | 123 | #endif // LXQTPLUGININFO_H 124 | -------------------------------------------------------------------------------- /lxqtpower/lxqtpower.cpp: -------------------------------------------------------------------------------- 1 | /* BEGIN_COMMON_COPYRIGHT_HEADER 2 | * (c)LGPL2+ 3 | * 4 | * LXQt - a lightweight, Qt based, desktop toolset 5 | * https://lxqt.org 6 | * 7 | * Copyright: 2010-2011 Razor team 8 | * Authors: 9 | * Alexander Sokoloff 10 | * 11 | * This program or library is free software; you can redistribute it 12 | * and/or modify it under the terms of the GNU Lesser General Public 13 | * License as published by the Free Software Foundation; either 14 | * version 2.1 of the License, or (at your option) any later version. 15 | * 16 | * This library is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | * Lesser General Public License for more details. 20 | 21 | * You should have received a copy of the GNU Lesser General 22 | * Public License along with this library; if not, write to the 23 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 24 | * Boston, MA 02110-1301 USA 25 | * 26 | * END_COMMON_COPYRIGHT_HEADER */ 27 | 28 | 29 | #include "lxqtpower.h" 30 | #include "lxqtpowerproviders.h" 31 | #include 32 | #include 33 | 34 | using namespace LXQt; 35 | 36 | Power::Power(bool useLxqtSessionProvider, QObject * parent /*= nullptr*/) : 37 | QObject(parent) 38 | { 39 | mProviders.append(new CustomProvider(this)); 40 | if (useLxqtSessionProvider) 41 | mProviders.append(new LXQtProvider(this)); 42 | mProviders.append(new SystemdProvider(this)); 43 | mProviders.append(new UPowerProvider(this)); 44 | mProviders.append(new ConsoleKitProvider(this)); 45 | mProviders.append(new LxSessionProvider(this)); 46 | } 47 | 48 | Power::Power(QObject * parent /*= nullptr*/) 49 | : Power(true, parent) 50 | { 51 | } 52 | 53 | 54 | Power::~Power() = default; 55 | 56 | 57 | bool Power::canAction(Power::Action action) const 58 | { 59 | for(const PowerProvider* provider : std::as_const(mProviders)) 60 | { 61 | if (provider->canAction(action)) 62 | return true; 63 | } 64 | 65 | return false; 66 | } 67 | 68 | 69 | bool Power::doAction(Power::Action action) 70 | { 71 | for(PowerProvider* provider : std::as_const(mProviders)) 72 | { 73 | if (provider->canAction(action) && 74 | provider->doAction(action) 75 | ) 76 | { 77 | return true; 78 | } 79 | } 80 | return false; 81 | } 82 | 83 | 84 | bool Power::canLogout() const { return canAction(PowerLogout); } 85 | bool Power::canHibernate() const { return canAction(PowerHibernate); } 86 | bool Power::canReboot() const { return canAction(PowerReboot); } 87 | bool Power::canShutdown() const { return canAction(PowerShutdown); } 88 | bool Power::canSuspend() const { return canAction(PowerSuspend); } 89 | bool Power::canMonitorOff() const { return canAction(PowerMonitorOff); } 90 | bool Power::canShowLeaveDialog() const { return canAction(PowerShowLeaveDialog); } 91 | 92 | bool Power::logout() { return doAction(PowerLogout); } 93 | bool Power::hibernate() { return doAction(PowerHibernate); } 94 | bool Power::reboot() { return doAction(PowerReboot); } 95 | bool Power::shutdown() { return doAction(PowerShutdown); } 96 | bool Power::suspend() { return doAction(PowerSuspend); } 97 | bool Power::monitorOff() { return doAction(PowerMonitorOff); } 98 | bool Power::showLeaveDialog() { return doAction(PowerShowLeaveDialog); } 99 | -------------------------------------------------------------------------------- /lxqtpower/lxqtpower.h: -------------------------------------------------------------------------------- 1 | /* BEGIN_COMMON_COPYRIGHT_HEADER 2 | * (c)LGPL2+ 3 | * 4 | * LXQt - a lightweight, Qt based, desktop toolset 5 | * https://lxqt.org 6 | * 7 | * Copyright: 2010-2011 Razor team 8 | * Authors: 9 | * Alexander Sokoloff 10 | * 11 | * This program or library is free software; you can redistribute it 12 | * and/or modify it under the terms of the GNU Lesser General Public 13 | * License as published by the Free Software Foundation; either 14 | * version 2.1 of the License, or (at your option) any later version. 15 | * 16 | * This library is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | * Lesser General Public License for more details. 20 | 21 | * You should have received a copy of the GNU Lesser General 22 | * Public License along with this library; if not, write to the 23 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 24 | * Boston, MA 02110-1301 USA 25 | * 26 | * END_COMMON_COPYRIGHT_HEADER */ 27 | 28 | 29 | #ifndef LXQTPOWER_H 30 | #define LXQTPOWER_H 31 | 32 | #include 33 | #include 34 | #include "lxqtglobals.h" 35 | 36 | namespace LXQt 37 | { 38 | 39 | 40 | class PowerProvider; 41 | 42 | /*! Power class provides an interface to control system-wide power and session management. 43 | It allows logout from the user session, hibernate, reboot, shutdown and suspend computer. 44 | This is a wrapper class. All the real work is done in the PowerWorker classes. 45 | */ 46 | class LXQT_API Power : public QObject 47 | { 48 | Q_OBJECT 49 | public: 50 | /// Power can perform next actions: 51 | enum Action{ 52 | PowerLogout, /// Close the current user session. 53 | PowerHibernate, /// Hibernate the comupter 54 | PowerReboot, /// Reboot the computer 55 | PowerShutdown, /// Shutdown the computer 56 | PowerSuspend, /// Suspend the computer 57 | PowerMonitorOff, /// Turn off the monitor(s) 58 | PowerShowLeaveDialog /// Show the lxqt-leave dialog 59 | }; 60 | 61 | /*! 62 | * Constructs the Power object. 63 | * \param useLxqtSessionProvider indicates if the DBus methods 64 | * provided by lxqt-session should be considered. This is useful to 65 | * avoid recursion if the lxqt-session wants to provide some of the 66 | * methods by itself with internal use of this object. 67 | */ 68 | explicit Power(bool useLxqtSessionProvider, QObject *parent = nullptr); 69 | /// Constructs a Power with using the lxqt-session provider. 70 | explicit Power(QObject *parent = nullptr); 71 | 72 | /// Destroys the object. 73 | ~Power() override; 74 | 75 | /// Returns true if the Power can perform action. 76 | bool canAction(Action action) const; 77 | 78 | //! This function is provided for convenience. It's equivalent to calling canAction(PowerLogout). 79 | bool canLogout() const; 80 | 81 | //! This function is provided for convenience. It's equivalent to calling canAction(PowerHibernate). 82 | bool canHibernate() const; 83 | 84 | //! This function is provided for convenience. It's equivalent to calling canAction(PowerReboot). 85 | bool canReboot() const; 86 | 87 | //! This function is provided for convenience. It's equivalent to calling canAction(PowerShutdown). 88 | bool canShutdown() const; 89 | 90 | //! This function is provided for convenience. It's equivalent to calling canAction(PowerSuspend). 91 | bool canSuspend() const; 92 | 93 | //! This function is provided for convenience. It's equivalent to calling canAction(PowerMonitorOff). 94 | bool canMonitorOff() const; 95 | 96 | //! This function is provided for convenience. It's equivalent to calling canAction(PowerShowLeaveDialog). 97 | bool canShowLeaveDialog() const; 98 | 99 | public Q_SLOTS: 100 | /// Performs the requested action. 101 | bool doAction(Action action); 102 | 103 | //! This function is provided for convenience. It's equivalent to calling doAction(PowerLogout). 104 | bool logout(); 105 | 106 | //! This function is provided for convenience. It's equivalent to calling doAction(PowerHibernate). 107 | bool hibernate(); 108 | 109 | //! This function is provided for convenience. It's equivalent to calling doAction(PowerReboot). 110 | bool reboot(); 111 | 112 | //! This function is provided for convenience. It's equivalent to calling doAction(PowerShutdown). 113 | bool shutdown(); 114 | 115 | //! This function is provided for convenience. It's equivalent to calling doAction(PowerSuspend). 116 | bool suspend(); 117 | 118 | //! This function is provided for convenience. It's equivalent to calling doAction(PowerMonitorOff). 119 | bool monitorOff(); 120 | 121 | //! This function is provided for convenience. It's equivalent to calling doAction(PowerShowLeaveDialog). 122 | bool showLeaveDialog(); 123 | 124 | private: 125 | QList mProviders; 126 | }; 127 | 128 | } // namespace LXQt 129 | #endif // LXQTPOWER_H 130 | -------------------------------------------------------------------------------- /lxqtpower/lxqtpowerproviders.h: -------------------------------------------------------------------------------- 1 | /* BEGIN_COMMON_COPYRIGHT_HEADER 2 | * (c)LGPL2+ 3 | * 4 | * LXQt - a lightweight, Qt based, desktop toolset 5 | * https://lxqt.org 6 | * 7 | * Copyright: 2010-2011 Razor team 8 | * Authors: 9 | * Alexander Sokoloff 10 | * 11 | * This program or library is free software; you can redistribute it 12 | * and/or modify it under the terms of the GNU Lesser General Public 13 | * License as published by the Free Software Foundation; either 14 | * version 2.1 of the License, or (at your option) any later version. 15 | * 16 | * This library is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | * Lesser General Public License for more details. 20 | 21 | * You should have received a copy of the GNU Lesser General 22 | * Public License along with this library; if not, write to the 23 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 24 | * Boston, MA 02110-1301 USA 25 | * 26 | * END_COMMON_COPYRIGHT_HEADER */ 27 | 28 | 29 | #ifndef LXQTPOWER_PROVIDERS_H 30 | #define LXQTPOWER_PROVIDERS_H 31 | 32 | #include 33 | #include 34 | #include "lxqtpower.h" 35 | #include // for PID_T 36 | 37 | namespace LXQt 38 | { 39 | 40 | 41 | class PowerProvider: public QObject 42 | { 43 | Q_OBJECT 44 | public: 45 | 46 | enum DbusErrorCheck { 47 | CheckDBUS, 48 | DontCheckDBUS 49 | }; 50 | 51 | explicit PowerProvider(QObject *parent = nullptr); 52 | ~PowerProvider() override; 53 | 54 | /*! Returns true if the Power can perform action. 55 | This is a pure virtual function, and must be reimplemented in subclasses. */ 56 | virtual bool canAction(Power::Action action) const = 0 ; 57 | 58 | public Q_SLOTS: 59 | /*! Performs the requested action. 60 | This is a pure virtual function, and must be reimplemented in subclasses. */ 61 | virtual bool doAction(Power::Action action) = 0; 62 | }; 63 | 64 | 65 | class UPowerProvider: public PowerProvider 66 | { 67 | Q_OBJECT 68 | public: 69 | UPowerProvider(QObject *parent = nullptr); 70 | ~UPowerProvider() override; 71 | bool canAction(Power::Action action) const override; 72 | 73 | public Q_SLOTS: 74 | bool doAction(Power::Action action) override; 75 | }; 76 | 77 | 78 | class ConsoleKitProvider: public PowerProvider 79 | { 80 | Q_OBJECT 81 | public: 82 | ConsoleKitProvider(QObject *parent = nullptr); 83 | ~ConsoleKitProvider() override; 84 | bool canAction(Power::Action action) const override; 85 | 86 | public Q_SLOTS: 87 | bool doAction(Power::Action action) override; 88 | }; 89 | 90 | 91 | class SystemdProvider: public PowerProvider 92 | { 93 | Q_OBJECT 94 | public: 95 | SystemdProvider(QObject *parent = nullptr); 96 | ~SystemdProvider() override; 97 | bool canAction(Power::Action action) const override; 98 | 99 | public Q_SLOTS: 100 | bool doAction(Power::Action action) override; 101 | }; 102 | 103 | 104 | class LXQtProvider: public PowerProvider 105 | { 106 | Q_OBJECT 107 | public: 108 | LXQtProvider(QObject *parent = nullptr); 109 | ~LXQtProvider() override; 110 | bool canAction(Power::Action action) const override; 111 | 112 | public Q_SLOTS: 113 | bool doAction(Power::Action action) override; 114 | }; 115 | 116 | class LxSessionProvider: public PowerProvider 117 | { 118 | Q_OBJECT 119 | public: 120 | LxSessionProvider(QObject *parent = nullptr); 121 | ~LxSessionProvider() override; 122 | bool canAction(Power::Action action) const override; 123 | 124 | public Q_SLOTS: 125 | bool doAction(Power::Action action) override; 126 | private: 127 | qint64 pid; 128 | }; 129 | 130 | class HalProvider: public PowerProvider 131 | { 132 | Q_OBJECT 133 | public: 134 | HalProvider(QObject *parent = nullptr); 135 | ~HalProvider() override; 136 | bool canAction(Power::Action action) const override; 137 | 138 | public Q_SLOTS: 139 | bool doAction(Power::Action action) override; 140 | }; 141 | 142 | 143 | class CustomProvider: public PowerProvider 144 | { 145 | Q_OBJECT 146 | public: 147 | CustomProvider(QObject *parent = nullptr); 148 | ~CustomProvider() override; 149 | bool canAction(Power::Action action) const override; 150 | 151 | public Q_SLOTS: 152 | bool doAction(Power::Action action) override; 153 | 154 | private: 155 | Settings mSettings; 156 | }; 157 | 158 | } // namespace LXQt 159 | #endif // LXQTPOWER_PROVIDERS_H 160 | -------------------------------------------------------------------------------- /lxqtpowermanager.cpp: -------------------------------------------------------------------------------- 1 | /* BEGIN_COMMON_COPYRIGHT_HEADER 2 | * (c)LGPL2+ 3 | * 4 | * LXQt - a lightweight, Qt based, desktop toolset 5 | * https://lxqt.org 6 | * 7 | * Copyright: 2010-2011 Razor team 8 | * Authors: 9 | * Petr Vanek 10 | * 11 | * This program or library is free software; you can redistribute it 12 | * and/or modify it under the terms of the GNU Lesser General Public 13 | * License as published by the Free Software Foundation; either 14 | * version 2.1 of the License, or (at your option) any later version. 15 | * 16 | * This library is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | * Lesser General Public License for more details. 20 | 21 | * You should have received a copy of the GNU Lesser General 22 | * Public License along with this library; if not, write to the 23 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 24 | * Boston, MA 02110-1301 USA 25 | * 26 | * END_COMMON_COPYRIGHT_HEADER */ 27 | 28 | #include "lxqtpowermanager.h" 29 | #include "lxqtpower/lxqtpower.h" 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include "lxqttranslator.h" 37 | #include "lxqtglobals.h" 38 | #include "lxqtsettings.h" 39 | #include 40 | 41 | namespace LXQt { 42 | 43 | class LXQT_API MessageBox: public QMessageBox 44 | { 45 | Q_DECLARE_TR_FUNCTIONS(LXQt::MessageBox) 46 | 47 | public: 48 | explicit MessageBox(QWidget *parent = nullptr): QMessageBox(parent) {} 49 | 50 | static QWidget *parentWidget() 51 | { 52 | const QWidgetList widgets = QApplication::topLevelWidgets(); 53 | 54 | if (widgets.count()) 55 | return widgets.at(0); 56 | else 57 | return nullptr; 58 | } 59 | 60 | static bool question(const QString& title, const QString& text) 61 | { 62 | MessageBox msgBox(parentWidget()); 63 | msgBox.setWindowTitle(title); 64 | msgBox.setText(text); 65 | msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); 66 | msgBox.setDefaultButton(QMessageBox::Yes); 67 | 68 | return (msgBox.exec() == QMessageBox::Yes); 69 | } 70 | 71 | 72 | static void warning(const QString& title, const QString& text) 73 | { 74 | Q_UNUSED(title) 75 | Q_UNUSED(text) 76 | QMessageBox::warning(parentWidget(), tr("LXQt Power Manager Error"), tr("Hibernate failed.")); 77 | } 78 | }; 79 | 80 | PowerManager::PowerManager(QObject * parent, bool skipWarning) 81 | : QObject(parent), 82 | m_skipWarning(skipWarning) 83 | { 84 | m_power = new Power(this); 85 | // connect(m_power, SIGNAL(suspendFail()), this, SLOT(suspendFailed())); 86 | // connect(m_power, SIGNAL(hibernateFail()), this, SLOT(hibernateFailed())); 87 | // connect(m_power, SIGNAL(monitoring(const QString &)), 88 | // this, SLOT(monitoring(const QString&))); 89 | 90 | QString sessionConfig(QFile::decodeName(qgetenv("LXQT_SESSION_CONFIG"))); 91 | Settings settings(sessionConfig.isEmpty() ? QL1SV("session") : sessionConfig); 92 | m_skipWarning = settings.value(QL1SV("leave_confirmation")).toBool() ? false : true; 93 | } 94 | 95 | PowerManager::~PowerManager() 96 | { 97 | // delete m_power; 98 | } 99 | 100 | QList PowerManager::availableActions() 101 | { 102 | QList ret; 103 | QAction * act; 104 | 105 | // TODO/FIXME: icons 106 | if (m_power->canHibernate()) 107 | { 108 | act = new QAction(XdgIcon::fromTheme(QL1SV("system-suspend-hibernate")), tr("Hibernate"), this); 109 | connect(act, &QAction::triggered, this, &PowerManager::hibernate); 110 | ret.append(act); 111 | } 112 | 113 | if (m_power->canSuspend()) 114 | { 115 | act = new QAction(XdgIcon::fromTheme(QL1SV("system-suspend")), tr("Suspend"), this); 116 | connect(act, &QAction::triggered, this, &PowerManager::suspend); 117 | ret.append(act); 118 | } 119 | 120 | if (m_power->canReboot()) 121 | { 122 | act = new QAction(XdgIcon::fromTheme(QL1SV("system-reboot")), tr("Reboot"), this); 123 | connect(act, &QAction::triggered, this, &PowerManager::reboot); 124 | ret.append(act); 125 | } 126 | 127 | if (m_power->canShutdown()) 128 | { 129 | act = new QAction(XdgIcon::fromTheme(QL1SV("system-shutdown")), tr("Shutdown"), this); 130 | connect(act, &QAction::triggered, this, &PowerManager::shutdown); 131 | ret.append(act); 132 | } 133 | 134 | if (m_power->canLogout()) 135 | { 136 | act = new QAction(XdgIcon::fromTheme(QL1SV("system-log-out")), tr("Logout"), this); 137 | connect(act, &QAction::triggered, this, &PowerManager::logout); 138 | ret.append(act); 139 | } 140 | 141 | return ret; 142 | } 143 | 144 | 145 | void PowerManager::suspend() 146 | { 147 | if (m_skipWarning || 148 | MessageBox::question(tr("LXQt Session Suspend"), 149 | tr("Do you want to really suspend your computer?

Suspends the computer into a low power state. System state is not preserved if the power is lost."))) 150 | { 151 | m_power->suspend(); 152 | } 153 | } 154 | 155 | void PowerManager::hibernate() 156 | { 157 | if (m_skipWarning || 158 | MessageBox::question(tr("LXQt Session Hibernate"), 159 | tr("Do you want to really hibernate your computer?

Hibernates the computer into a low power state. System state is preserved if the power is lost."))) 160 | { 161 | m_power->hibernate(); 162 | } 163 | } 164 | 165 | void PowerManager::reboot() 166 | { 167 | if (m_skipWarning || 168 | MessageBox::question(tr("LXQt Session Reboot"), 169 | tr("Do you want to really restart your computer? All unsaved work will be lost..."))) 170 | { 171 | m_power->reboot(); 172 | } 173 | } 174 | 175 | void PowerManager::shutdown() 176 | { 177 | if (m_skipWarning || 178 | MessageBox::question(tr("LXQt Session Shutdown"), 179 | tr("Do you want to really switch off your computer? All unsaved work will be lost..."))) 180 | { 181 | m_power->shutdown(); 182 | } 183 | } 184 | 185 | void PowerManager::logout() 186 | { 187 | if (m_skipWarning || 188 | MessageBox::question(tr("LXQt Session Logout"), 189 | tr("Do you want to really logout? All unsaved work will be lost..."))) 190 | { 191 | m_power->logout(); 192 | } 193 | } 194 | 195 | void PowerManager::hibernateFailed() 196 | { 197 | MessageBox::warning(tr("LXQt Power Manager Error"), tr("Hibernate failed.")); 198 | } 199 | 200 | void PowerManager::suspendFailed() 201 | { 202 | MessageBox::warning(tr("LXQt Power Manager Error"), tr("Suspend failed.")); 203 | } 204 | 205 | } // namespace LXQt 206 | -------------------------------------------------------------------------------- /lxqtpowermanager.h: -------------------------------------------------------------------------------- 1 | /* BEGIN_COMMON_COPYRIGHT_HEADER 2 | * (c)LGPL2+ 3 | * 4 | * LXQt - a lightweight, Qt based, desktop toolset 5 | * https://lxqt.org 6 | * 7 | * Copyright: 2010-2011 Razor team 8 | * Authors: 9 | * Petr Vanek 10 | * 11 | * This program or library is free software; you can redistribute it 12 | * and/or modify it under the terms of the GNU Lesser General Public 13 | * License as published by the Free Software Foundation; either 14 | * version 2.1 of the License, or (at your option) any later version. 15 | * 16 | * This library is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | * Lesser General Public License for more details. 20 | 21 | * You should have received a copy of the GNU Lesser General 22 | * Public License along with this library; if not, write to the 23 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 24 | * Boston, MA 02110-1301 USA 25 | * 26 | * END_COMMON_COPYRIGHT_HEADER */ 27 | 28 | #ifndef LXQTPOWERMANAGER_H 29 | #define LXQTPOWERMANAGER_H 30 | 31 | #include 32 | #include 33 | #include "lxqtglobals.h" 34 | 35 | namespace LXQt 36 | { 37 | class Power; 38 | 39 | /*! QAction centric menu aware wrapper around lxqtpower 40 | */ 41 | class LXQT_API PowerManager : public QObject 42 | { 43 | Q_OBJECT 44 | 45 | public: 46 | PowerManager(QObject * parent, bool skipWarning = false); 47 | ~PowerManager() override; 48 | QList availableActions(); 49 | 50 | public Q_SLOTS: 51 | // power management 52 | void suspend(); 53 | void hibernate(); 54 | void reboot(); 55 | void shutdown(); 56 | // lxqt session 57 | void logout(); 58 | 59 | public: 60 | bool skipWarning() const { return m_skipWarning; } 61 | 62 | private: 63 | LXQt::Power * m_power; 64 | bool m_skipWarning; 65 | 66 | private Q_SLOTS: 67 | void hibernateFailed(); 68 | void suspendFailed(); 69 | }; 70 | 71 | } // namespace LXQt 72 | 73 | #endif // LXQTPOWERMANAGER_H 74 | -------------------------------------------------------------------------------- /lxqtprogramfinder.cpp: -------------------------------------------------------------------------------- 1 | /* BEGIN_COMMON_COPYRIGHT_HEADER 2 | * (c)LGPL2+ 3 | * 4 | * LXQt - a lightweight, Qt based, desktop toolset 5 | * https://lxqt.org 6 | * 7 | * Copyright (C) 2013 Alec Moskvin 8 | * 9 | * This library is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU Lesser General Public 11 | * License as published by the Free Software Foundation; either 12 | * version 2.1 of the License, or (at your option) any later version. 13 | 14 | * This library is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | * Lesser General Public License for more details. 18 | 19 | * You should have received a copy of the GNU Lesser General Public 20 | * License along with this library; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 22 | * 23 | * END_COMMON_COPYRIGHT_HEADER */ 24 | 25 | #include "lxqtprogramfinder.h" 26 | #include 27 | #include 28 | #include 29 | 30 | using namespace LXQt; 31 | 32 | LXQT_API bool ProgramFinder::programExists(const QString& command) 33 | { 34 | const QString program = programName(command); 35 | if (program[0] == QL1C('/')) 36 | { 37 | QFileInfo fi(program); 38 | return fi.isExecutable() && fi.isFile(); 39 | } 40 | 41 | const QString path = QFile::decodeName(qgetenv("PATH")); 42 | const QStringList dirs = path.split(QL1C(':'), Qt::SkipEmptyParts); 43 | for (const QString& dirName : dirs) 44 | { 45 | const QFileInfo fi(QDir(dirName), program); 46 | if (fi.isExecutable() && fi.isFile()) 47 | return true; 48 | } 49 | return false; 50 | } 51 | 52 | LXQT_API QStringList ProgramFinder::findPrograms(const QStringList& commands) 53 | { 54 | QStringList availPrograms; 55 | for (const QString& program : commands) 56 | if (programExists(program)) 57 | availPrograms.append(program); 58 | return availPrograms; 59 | } 60 | 61 | LXQT_API QString ProgramFinder::programName(const QString& command) 62 | { 63 | wordexp_t we; 64 | if (wordexp(command.toLocal8Bit().constData(), &we, WRDE_NOCMD) == 0) 65 | if (we.we_wordc > 0) 66 | return QString::fromLocal8Bit(we.we_wordv[0]); 67 | return QString(); 68 | } 69 | -------------------------------------------------------------------------------- /lxqtprogramfinder.h: -------------------------------------------------------------------------------- 1 | /* BEGIN_COMMON_COPYRIGHT_HEADER 2 | * (c)LGPL2+ 3 | * 4 | * LXQt - a lightweight, Qt based, desktop toolset 5 | * https://lxqt.org 6 | * 7 | * Copyright (C) 2013 Alec Moskvin 8 | * 9 | * This library is free software; you can redistribute it and/or 10 | * modify it under the terms of the GNU Lesser General Public 11 | * License as published by the Free Software Foundation; either 12 | * version 2.1 of the License, or (at your option) any later version. 13 | 14 | * This library is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | * Lesser General Public License for more details. 18 | 19 | * You should have received a copy of the GNU Lesser General Public 20 | * License along with this library; if not, write to the Free Software 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 22 | * 23 | * END_COMMON_COPYRIGHT_HEADER */ 24 | 25 | #ifndef LXQTPROGRAMFINDER_H 26 | #define LXQTPROGRAMFINDER_H 27 | 28 | #include 29 | #include "lxqtglobals.h" 30 | 31 | namespace LXQt 32 | { 33 | 34 | namespace ProgramFinder 35 | { 36 | /*! 37 | * \brief programExists Checks if the program needed to execute the given 38 | * command is installed 39 | * \param command 40 | * \return True if the program exists 41 | */ 42 | LXQT_API bool programExists(const QString& command); 43 | 44 | /*! 45 | * \brief findPrograms Filters a list of commands (with arguments) based on 46 | * which programs are installed 47 | * \param commands Commands to check 48 | * \return List of commands which are installed 49 | */ 50 | LXQT_API QStringList findPrograms(const QStringList& commands); 51 | 52 | /*! 53 | * \brief programName Returns the program name given a command 54 | * \param command 55 | * \return 56 | */ 57 | LXQT_API QString programName(const QString& command); 58 | } 59 | 60 | } // namespace LXQt 61 | #endif // LXQTPROGRAMFINDER_H 62 | -------------------------------------------------------------------------------- /lxqtrotatedwidget.h: -------------------------------------------------------------------------------- 1 | /* BEGIN_COMMON_COPYRIGHT_HEADER 2 | * (c)LGPL2+ 3 | * 4 | * LXQt - a lightweight, Qt based, desktop toolset 5 | * https://lxqt.org 6 | * 7 | * Copyright: 2010-2013 Razor team 8 | * Authors: 9 | * Kuzma Shapran 10 | * 11 | * This program or library is free software; you can redistribute it 12 | * and/or modify it under the terms of the GNU Lesser General Public 13 | * License as published by the Free Software Foundation; either 14 | * version 2.1 of the License, or (at your option) any later version. 15 | * 16 | * This library is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | * Lesser General Public License for more details. 20 | 21 | * You should have received a copy of the GNU Lesser General 22 | * Public License along with this library; if not, write to the 23 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 24 | * Boston, MA 02110-1301 USA 25 | * 26 | * END_COMMON_COPYRIGHT_HEADER */ 27 | 28 | #ifndef LXQTROTATED_WIDGET_H 29 | #define LXQTROTATED_WIDGET_H 30 | 31 | #include 32 | #include "lxqtglobals.h" 33 | 34 | namespace LXQt 35 | { 36 | 37 | class LXQT_API RotatedWidget: public QWidget 38 | { 39 | Q_OBJECT 40 | 41 | Q_PROPERTY(Qt::Corner origin READ origin WRITE setOrigin) 42 | 43 | Q_PROPERTY(bool transferMousePressEvent READ transferMousePressEvent WRITE setTransferMousePressEvent) 44 | Q_PROPERTY(bool transferMouseReleaseEvent READ transferMouseReleaseEvent WRITE setTransferMouseReleaseEvent) 45 | Q_PROPERTY(bool transferMouseDoubleClickEvent READ transferMouseDoubleClickEvent WRITE setTransferMouseDoubleClickEvent) 46 | Q_PROPERTY(bool transferMouseMoveEvent READ transferMouseMoveEvent WRITE setTransferMouseMoveEvent) 47 | #ifndef QT_NO_WHEELEVENT 48 | Q_PROPERTY(bool transferWheelEvent READ transferWheelEvent WRITE setTransferWheelEvent) 49 | #endif 50 | 51 | Q_PROPERTY(bool transferEnterEvent READ transferEnterEvent WRITE setTransferEnterEvent) 52 | Q_PROPERTY(bool transferLeaveEvent READ transferLeaveEvent WRITE setTransferLeaveEvent) 53 | 54 | public: 55 | explicit RotatedWidget(QWidget &content, QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags()); 56 | 57 | Qt::Corner origin() const; 58 | void setOrigin(Qt::Corner); 59 | 60 | QWidget * content() const; 61 | 62 | void adjustContentSize(); 63 | 64 | QSize minimumSizeHint() const override; 65 | QSize sizeHint() const override; 66 | 67 | QSize adjustedSize(QSize) const; 68 | QPointF adjustedPoint(QPointF) const; 69 | 70 | 71 | bool transferMousePressEvent() const { return mTransferMousePressEvent; } 72 | void setTransferMousePressEvent(bool value) { mTransferMousePressEvent = value; } 73 | 74 | bool transferMouseReleaseEvent() const { return mTransferMouseReleaseEvent; } 75 | void setTransferMouseReleaseEvent(bool value) { mTransferMouseReleaseEvent = value; } 76 | 77 | bool transferMouseDoubleClickEvent() const { return mTransferMouseDoubleClickEvent; } 78 | void setTransferMouseDoubleClickEvent(bool value) { mTransferMouseDoubleClickEvent = value; } 79 | 80 | bool transferMouseMoveEvent() const { return mTransferMouseMoveEvent; } 81 | void setTransferMouseMoveEvent(bool value) { mTransferMouseMoveEvent = value; } 82 | 83 | #ifndef QT_NO_WHEELEVENT 84 | bool transferWheelEvent() const { return mTransferWheelEvent; } 85 | void setTransferWheelEvent(bool value) { mTransferWheelEvent = value; } 86 | #endif 87 | 88 | bool transferEnterEvent() const { return mTransferEnterEvent; } 89 | void setTransferEnterEvent(bool value) { mTransferEnterEvent = value; } 90 | 91 | bool transferLeaveEvent() const { return mTransferLeaveEvent; } 92 | void setTransferLeaveEvent(bool value) { mTransferLeaveEvent = value; } 93 | 94 | protected: 95 | void paintEvent(QPaintEvent *) override; 96 | 97 | // Transition event handlers 98 | void mousePressEvent(QMouseEvent *) override; 99 | void mouseReleaseEvent(QMouseEvent *) override; 100 | void mouseDoubleClickEvent(QMouseEvent *) override; 101 | void mouseMoveEvent(QMouseEvent *) override; 102 | #ifndef QT_NO_WHEELEVENT 103 | void wheelEvent(QWheelEvent *) override; 104 | #endif 105 | void enterEvent(QEnterEvent *) override; 106 | void leaveEvent(QEvent *) override; 107 | 108 | void resizeEvent(QResizeEvent *) override; 109 | 110 | private: 111 | QWidget *mContent; 112 | Qt::Corner mOrigin; 113 | 114 | bool mTransferMousePressEvent; 115 | bool mTransferMouseReleaseEvent; 116 | bool mTransferMouseDoubleClickEvent; 117 | bool mTransferMouseMoveEvent; 118 | #ifndef QT_NO_WHEELEVENT 119 | bool mTransferWheelEvent; 120 | #endif 121 | bool mTransferEnterEvent; 122 | bool mTransferLeaveEvent; 123 | }; 124 | 125 | } // namespace LXQt 126 | #endif // LXQTROTATEDWIDGET_H 127 | -------------------------------------------------------------------------------- /lxqtscreensaver.h: -------------------------------------------------------------------------------- 1 | /* BEGIN_COMMON_COPYRIGHT_HEADER 2 | * (c)LGPL2+ 3 | * 4 | * LXQt - a lightweight, Qt based, desktop toolset 5 | * https://lxqt.org 6 | * 7 | * Copyright: 2010-2011 Razor team 8 | * Authors: 9 | * Petr Vanek 10 | * 11 | * Copyright (c) 2016 Luís Pereira 12 | * 13 | * This program or library is free software; you can redistribute it 14 | * and/or modify it under the terms of the GNU Lesser General Public 15 | * License as published by the Free Software Foundation; either 16 | * version 2.1 of the License, or (at your option) any later version. 17 | * 18 | * This library is distributed in the hope that it will be useful, 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21 | * Lesser General Public License for more details. 22 | 23 | * You should have received a copy of the GNU Lesser General 24 | * Public License along with this library; if not, write to the 25 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 26 | * Boston, MA 02110-1301 USA 27 | * 28 | * END_COMMON_COPYRIGHT_HEADER */ 29 | 30 | #ifndef SCREENSAVER_H 31 | #define SCREENSAVER_H 32 | 33 | #include "lxqtglobals.h" 34 | #include 35 | #include 36 | 37 | namespace LXQt 38 | { 39 | 40 | class ScreenSaverPrivate; 41 | 42 | class LXQT_API ScreenSaver : public QObject 43 | { 44 | Q_OBJECT 45 | Q_DECLARE_PRIVATE(ScreenSaver) 46 | Q_DISABLE_COPY(ScreenSaver) 47 | 48 | public: 49 | ScreenSaver(QObject * parent=nullptr); 50 | ~ScreenSaver() override; 51 | 52 | QList availableActions(); 53 | 54 | Q_SIGNALS: 55 | void activated(); 56 | void done(); 57 | public Q_SLOTS: 58 | void lockScreen(); 59 | 60 | private: 61 | ScreenSaverPrivate* const d_ptr; 62 | }; 63 | 64 | } // namespace LXQt 65 | #endif 66 | 67 | -------------------------------------------------------------------------------- /lxqtsettings.h: -------------------------------------------------------------------------------- 1 | /* BEGIN_COMMON_COPYRIGHT_HEADER 2 | * (c)LGPL2+ 3 | * 4 | * LXQt - a lightweight, Qt based, desktop toolset 5 | * https://lxqt.org 6 | * 7 | * Copyright: 2010-2011 Razor team 8 | * Authors: 9 | * Alexander Sokoloff 10 | * 11 | * This program or library is free software; you can redistribute it 12 | * and/or modify it under the terms of the GNU Lesser General Public 13 | * License as published by the Free Software Foundation; either 14 | * version 2.1 of the License, or (at your option) any later version. 15 | * 16 | * This library is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | * Lesser General Public License for more details. 20 | 21 | * You should have received a copy of the GNU Lesser General 22 | * Public License along with this library; if not, write to the 23 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 24 | * Boston, MA 02110-1301 USA 25 | * 26 | * END_COMMON_COPYRIGHT_HEADER */ 27 | 28 | 29 | #ifndef LXQTSETTINGS_H 30 | #define LXQTSETTINGS_H 31 | 32 | #include 33 | #include 34 | #include 35 | #include "lxqtglobals.h" 36 | 37 | class QEvent; 38 | 39 | namespace LXQt 40 | { 41 | 42 | class SettingsPrivate; 43 | class GlobalSettings; 44 | 45 | /*! \brief User settings handling */ 46 | class LXQT_API Settings : public QSettings 47 | { 48 | Q_OBJECT 49 | public: 50 | 51 | /*! \brief Constructs a Settings object for accessing settings of the module called module, and with parent parent. 52 | Settings can be accessed using the standard interface provided by QSettings, but it also provides some convenience functions and signals. 53 | 54 | \param module a base name of the config file. It's a name without 55 | the extension. For example: if you want to open settings for 56 | panel create it as Settings("panel"). 57 | The function will create all parent directories necessary to create 58 | the file. 59 | \param parent It's no need to delete this class manually if it's set. 60 | */ 61 | explicit Settings(const QString& module, QObject* parent = nullptr); 62 | //explicit Settings(QObject* parent=0); 63 | explicit Settings(const QSettings* parentSettings, const QString& subGroup, QObject* parent=nullptr); 64 | explicit Settings(const QSettings& parentSettings, const QString& subGroup, QObject* parent=nullptr); 65 | Settings(const QString &fileName, QSettings::Format format, QObject *parent = nullptr); 66 | ~Settings() override; 67 | 68 | static const GlobalSettings *globalSettings(); 69 | 70 | 71 | /*! Returns the localized value for key. In the desktop file keys may be postfixed by [LOCALE]. If the 72 | localized value doesn't exist, returns non lokalized value. If non localized value doesn't exist, returns defaultValue. 73 | LOCALE must be of the form lang_COUNTRY.ENCODING@MODIFIER, where _COUNTRY, .ENCODING, and @MODIFIER may be omitted. 74 | 75 | If no default value is specified, a default QVariant is returned. */ 76 | QVariant localizedValue(const QString& key, const QVariant& defaultValue = QVariant()) const; 77 | 78 | /*! Sets the value of setting key to value. If a localized version of the key already exists, the previous value is 79 | overwritten. Otherwise, it overwrites the the un-localized version. */ 80 | void setLocalizedValue(const QString &key, const QVariant &value); 81 | 82 | Q_SIGNALS: 83 | /*! /brief signal for backward compatibility (emitted whenever settingsChangedFromExternal() or settingsChangedByApp() is emitted) 84 | */ 85 | void settingsChanged(); 86 | /*! /brief signal emitted when the settings file is changed by external application 87 | */ 88 | void settingsChangedFromExternal(); 89 | /*! /brief signal emitted when any setting is changed by this object 90 | */ 91 | void settingsChangedByApp(); 92 | 93 | protected: 94 | bool event(QEvent *event) override; 95 | 96 | protected Q_SLOTS: 97 | /*! Called when the config file is changed */ 98 | virtual void fileChanged(); 99 | 100 | private Q_SLOTS: 101 | void _fileChanged(const QString& path); 102 | 103 | private: 104 | void addWatchedFile(QString const & path); 105 | 106 | private: 107 | Q_DISABLE_COPY(Settings) 108 | 109 | SettingsPrivate* const d_ptr; 110 | Q_DECLARE_PRIVATE(Settings) 111 | }; 112 | 113 | 114 | class LXQtThemeData; 115 | 116 | /*! \brief QSS theme handling */ 117 | class LXQT_API LXQtTheme 118 | { 119 | public: 120 | /// Constructs a null theme. 121 | LXQtTheme(); 122 | 123 | /*! Constructs an theme from the dir with the given path. If path not absolute 124 | (i.e. the theme name only) the relevant dir must be found relative to the 125 | $XDG_DATA_HOME + $XDG_DATA_DIRS directories. */ 126 | LXQtTheme(const QString &path); 127 | 128 | /// Constructs a copy of other. This is very fast. 129 | LXQtTheme(const LXQtTheme &other); 130 | 131 | LXQtTheme& operator=(const LXQtTheme &other); 132 | ~LXQtTheme(); 133 | 134 | /// Returns the name of the theme. 135 | QString name() const; 136 | 137 | QString path() const; 138 | 139 | QString previewImage() const; 140 | 141 | /// Returns true if this theme is valid; otherwise returns false. 142 | bool isValid() const; 143 | 144 | /*! \brief Returns StyleSheet text (not file name, but real text) of the module called module. 145 | Paths in url() C/QSS functions are parsed to be real values for the theme, 146 | relative to full path 147 | */ 148 | QString qss(const QString& module) const; 149 | 150 | /*! \brief A full path to image used as a wallpaper 151 | \param screen is an ID of the screen like in Qt. -1 means default (any) screen. 152 | Any other value greater than -1 is the exact screen (in dualhead). 153 | In themes the index starts from 1 (ix 1 means 1st screen). 154 | \retval QString a file name (including path). 155 | */ 156 | QString desktopBackground(int screen=-1) const; 157 | 158 | /// Returns the current lxqt theme. 159 | static const LXQtTheme ¤tTheme(); 160 | 161 | /// Returns the all themes found in the system. 162 | static QList allThemes(); 163 | 164 | private: 165 | static LXQtTheme* mInstance; 166 | QSharedDataPointer d; 167 | }; 168 | 169 | /*! 170 | A global pointer referring to the unique LXQtTheme object. 171 | It is equivalent to the pointer returned by the LXQtTheme::instance() function. 172 | Only one theme object can be created. !*/ 173 | 174 | #define lxqtTheme LXQtTheme::currentTheme() 175 | 176 | 177 | class LXQT_API SettingsCache 178 | { 179 | public: 180 | explicit SettingsCache(QSettings &settings); 181 | explicit SettingsCache(QSettings *settings); 182 | virtual ~SettingsCache() {} 183 | 184 | void loadFromSettings(); 185 | void loadToSettings(); 186 | 187 | private: 188 | QSettings &mSettings; 189 | QHash mCache; 190 | }; 191 | 192 | class GlobalSettingsPrivate; 193 | 194 | class LXQT_API GlobalSettings : public Settings 195 | { 196 | Q_OBJECT 197 | public: 198 | GlobalSettings(); 199 | ~GlobalSettings() override; 200 | 201 | Q_SIGNALS: 202 | /// Signal emitted when the icon theme has changed. 203 | void iconThemeChanged(); 204 | 205 | /// Signal emitted when the lxqt theme has changed. 206 | void lxqtThemeChanged(); 207 | 208 | protected Q_SLOTS: 209 | void fileChanged() override; 210 | 211 | private: 212 | GlobalSettingsPrivate* const d_ptr; 213 | Q_DECLARE_PRIVATE(GlobalSettings) 214 | }; 215 | 216 | } // namespace LXQt 217 | #endif // LXQTSETTINGS_H 218 | -------------------------------------------------------------------------------- /lxqtsingleapplication.cpp: -------------------------------------------------------------------------------- 1 | /* BEGIN_COMMON_COPYRIGHT_HEADER 2 | * (c)LGPL2+ 3 | * 4 | * LXQt - a lightweight, Qt based, desktop toolset 5 | * https://lxqt.org 6 | * 7 | * Copyright: 2014 LXQt team 8 | * Authors: 9 | * Luís Pereira 10 | * 11 | * This program or library is free software; you can redistribute it 12 | * and/or modify it under the terms of the GNU Lesser General Public 13 | * License as published by the Free Software Foundation; either 14 | * version 2.1 of the License, or (at your option) any later version. 15 | * 16 | * This library is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | * Lesser General Public License for more details. 20 | 21 | * You should have received a copy of the GNU Lesser General 22 | * Public License along with this library; if not, write to the 23 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 24 | * Boston, MA 02110-1301 USA 25 | * 26 | * END_COMMON_COPYRIGHT_HEADER */ 27 | 28 | #include "lxqtsingleapplication.h" 29 | #include "singleapplicationadaptor.h" 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | using namespace LXQt; 39 | 40 | SingleApplication::SingleApplication(int &argc, char **argv, StartOptions options) 41 | : Application(argc, argv, true), 42 | mActivationWindow(nullptr) 43 | { 44 | QString service = 45 | QString::fromLatin1("org.lxqt.%1").arg(QApplication::applicationName()); 46 | 47 | QDBusConnection bus = QDBusConnection::sessionBus(); 48 | 49 | if (!bus.isConnected()) { 50 | QLatin1StringView errorMessage("Can't connect to the D-Bus session bus\n" 51 | "Make sure the D-Bus daemon is running"); 52 | 53 | /* ExitOnDBusFailure is the default. Any value other than 54 | NoExitOnDBusFailure will be taken as ExitOnDBusFailure (the default). 55 | */ 56 | if (options == NoExitOnDBusFailure) { 57 | qDebug() << Q_FUNC_INFO << errorMessage; 58 | return; 59 | } else { 60 | qCritical() << Q_FUNC_INFO << errorMessage; 61 | QTimer::singleShot(0, this, [] { SingleApplication::exit(1); }); 62 | } 63 | } 64 | 65 | bool registered = (bus.registerService(service) == 66 | QDBusConnectionInterface::ServiceRegistered); 67 | if (registered) { // We are the primary instance 68 | SingleApplicationAdaptor *mAdaptor = new SingleApplicationAdaptor(this); 69 | QLatin1StringView objectPath("/"); 70 | bus.registerObject(objectPath, mAdaptor, 71 | QDBusConnection::ExportAllSlots); 72 | } else { // We are the second outstance 73 | QDBusMessage msg = QDBusMessage::createMethodCall(service, 74 | QStringLiteral("/"), 75 | QStringLiteral("org.lxqt.SingleApplication"), 76 | QStringLiteral("activateWindow")); 77 | QDBusConnection::sessionBus().send(msg); 78 | 79 | QTimer::singleShot(0, this, [] { SingleApplication::exit(0); }); 80 | } 81 | } 82 | 83 | SingleApplication::~SingleApplication() = default; 84 | 85 | void SingleApplication::setActivationWindow(QWidget *w) 86 | { 87 | mActivationWindow = w; 88 | } 89 | 90 | QWidget *SingleApplication::activationWindow() const 91 | { 92 | return mActivationWindow; 93 | } 94 | 95 | void SingleApplication::activateWindow() 96 | { 97 | if (mActivationWindow) { 98 | mActivationWindow->show(); 99 | WId window = mActivationWindow->effectiveWinId(); 100 | KWindowInfo info(window, NET::WMDesktop); 101 | int windowDesktop = info.desktop(); 102 | 103 | if (windowDesktop != KX11Extras::currentDesktop()) 104 | KX11Extras::setCurrentDesktop(windowDesktop); 105 | 106 | if (QWindow *w = mActivationWindow->windowHandle()) 107 | KWindowSystem::activateWindow(w); 108 | else 109 | qDebug() << Q_FUNC_INFO << "Got null windowHandle"; 110 | } else { 111 | qDebug() << Q_FUNC_INFO << "activationWindow not set or null"; 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /lxqtsingleapplication.h: -------------------------------------------------------------------------------- 1 | /* BEGIN_COMMON_COPYRIGHT_HEADER 2 | * (c)LGPL2+ 3 | * 4 | * LXQt - a lightweight, Qt based, desktop toolset 5 | * https://lxqt.org 6 | * 7 | * Copyright: 2014 LXQt team 8 | * Authors: 9 | * Luís Pereira 10 | * 11 | * This program or library is free software; you can redistribute it 12 | * and/or modify it under the terms of the GNU Lesser General Public 13 | * License as published by the Free Software Foundation; either 14 | * version 2.1 of the License, or (at your option) any later version. 15 | * 16 | * This library is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | * Lesser General Public License for more details. 20 | 21 | * You should have received a copy of the GNU Lesser General 22 | * Public License along with this library; if not, write to the 23 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 24 | * Boston, MA 02110-1301 USA 25 | * 26 | * END_COMMON_COPYRIGHT_HEADER */ 27 | 28 | #ifndef LXQTSINGLEAPPLICATION_H 29 | #define LXQTSINGLEAPPLICATION_H 30 | 31 | #include "lxqtapplication.h" 32 | 33 | class QWidget; 34 | 35 | namespace LXQt { 36 | 37 | /*! \class SingleApplication 38 | * \brief The SingleApplication class provides an single instance Application. 39 | * 40 | * This class allows the user to create applications where only one instance 41 | * is allowed to be running at an given time. If the user tries to launch 42 | * another instance, the already running instance will be activated instead. 43 | * 44 | * The user has to set the activation window with setActivationWindow. If it 45 | * doesn't the second instance will quietly exit without activating the first 46 | * instance window. In any case only one instance is allowed. 47 | * 48 | * These classes depend on D-Bus and KF5::WindowSystem 49 | * 50 | * \code 51 | * 52 | * // Original code 53 | * int main(int argc, char **argv) 54 | * { 55 | * LXQt::Application app(argc, argv); 56 | * 57 | * MainWidget w; 58 | * w.show(); 59 | * 60 | * return app.exec(); 61 | * } 62 | * 63 | * // Using the library 64 | * int main(int argc, char **argv) 65 | * { 66 | * LXQt::SingleApplication app(argc, argv); 67 | * 68 | * MainWidget w; 69 | * app.setActivationWindow(&w); 70 | * w.show(); 71 | * 72 | * return app.exec(); 73 | * } 74 | * \endcode 75 | * \sa SingleApplication 76 | */ 77 | 78 | class LXQT_API SingleApplication : public Application { 79 | Q_OBJECT 80 | 81 | public: 82 | /*! 83 | * \brief Options to control the D-Bus failure related application behaviour 84 | * 85 | * By default (ExitOnDBusFailure) if an instance can't connect to the D-Bus 86 | * session bus, that instance calls ::exit(1). Not even the first instance 87 | * will run. Connecting to the D-Bus session bus is an condition to 88 | * guarantee that only one instance will run. 89 | * 90 | * If an user wants to allow an application to run without D-Bus, it must 91 | * use the NoExitOnDBusFailure option. 92 | * 93 | * ExitOnDBusFailure is the default. 94 | */ 95 | enum StartOptions { 96 | /** Exit if the connection to the D-Bus session bus fails. 97 | * It's the default 98 | */ 99 | ExitOnDBusFailure, 100 | /** Don't exit if the connection to the D-Bus session bus fails.*/ 101 | NoExitOnDBusFailure 102 | }; 103 | Q_ENUM(StartOptions) 104 | 105 | /*! 106 | * \brief Construct a LXQt SingleApplication object. 107 | * \param argc standard argc as in QApplication 108 | * \param argv standard argv as in QApplication 109 | * \param options Control the on D-Bus failure application behaviour 110 | * 111 | * \sa StartOptions. 112 | */ 113 | SingleApplication(int &argc, char **argv, StartOptions options = ExitOnDBusFailure); 114 | ~SingleApplication() override; 115 | 116 | /*! 117 | * \brief Sets the activation window. 118 | * \param w activation window. 119 | * 120 | * Sets the activation window of this application to w. The activation 121 | * window is the widget that will be activated by \a activateWindow(). 122 | * 123 | * \sa activationWindow() \sa activateWindow(); 124 | */ 125 | void setActivationWindow(QWidget *w); 126 | 127 | /*! 128 | * \brief Gets the current activation window. 129 | * \return The current activation window. 130 | * 131 | * \sa setActivationWindow(); 132 | */ 133 | QWidget *activationWindow() const; 134 | 135 | public Q_SLOTS: 136 | /*! 137 | * \brief Activates this application activation window. 138 | * 139 | * Changes to the desktop where this applications is. It then de-minimizes, 140 | * raises and activates the application's activation window. 141 | * If no activation window has been set, this function does nothing. 142 | * 143 | * \sa setActivationWindow(); 144 | */ 145 | void activateWindow(); 146 | 147 | private: 148 | QWidget *mActivationWindow; 149 | }; 150 | 151 | #if defined(lxqtSingleApp) 152 | #undef lxqtSingleApp 153 | #endif 154 | #define lxqtSingleApp (static_cast(qApp)) 155 | 156 | } // namespace LXQt 157 | 158 | #endif // LXQTSINGLEAPPLICATION_H 159 | -------------------------------------------------------------------------------- /lxqttranslator.cpp: -------------------------------------------------------------------------------- 1 | /* BEGIN_COMMON_COPYRIGHT_HEADER 2 | * (c)LGPL2+ 3 | * 4 | * LXQt - a lightweight, Qt based, desktop toolset 5 | * https://lxqt.org 6 | * 7 | * Copyright: 2013 LXQt team 8 | * Authors: 9 | * Alexander Sokoloff 10 | Luís Pereira 11 | * 12 | * This program or library is free software; you can redistribute it 13 | * and/or modify it under the terms of the GNU Lesser General Public 14 | * License as published by the Free Software Foundation; either 15 | * version 2.1 of the License, or (at your option) any later version. 16 | * 17 | * This library is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | * Lesser General Public License for more details. 21 | 22 | * You should have received a copy of the GNU Lesser General 23 | * Public License along with this library; if not, write to the 24 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 25 | * Boston, MA 02110-1301 USA 26 | * 27 | * END_COMMON_COPYRIGHT_HEADER */ 28 | 29 | #include "lxqttranslator.h" 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | 39 | #include 40 | 41 | using namespace LXQt; 42 | 43 | bool translate(const QString &name, const QString &owner = QString()); 44 | /************************************************ 45 | 46 | ************************************************/ 47 | QStringList *getSearchPaths() 48 | { 49 | static QStringList *searchPath = nullptr; 50 | 51 | if (searchPath == nullptr) 52 | { 53 | searchPath = new QStringList(); 54 | *searchPath << XdgDirs::dataDirs(QL1C('/') + QL1SV(LXQT_RELATIVE_SHARE_TRANSLATIONS_DIR)); 55 | *searchPath << QL1SV(LXQT_SHARE_TRANSLATIONS_DIR); 56 | searchPath->removeDuplicates(); 57 | } 58 | 59 | return searchPath; 60 | } 61 | 62 | 63 | /************************************************ 64 | 65 | ************************************************/ 66 | QStringList LXQt::Translator::translationSearchPaths() 67 | { 68 | return *(getSearchPaths()); 69 | } 70 | 71 | 72 | /************************************************ 73 | 74 | ************************************************/ 75 | void Translator::setTranslationSearchPaths(const QStringList &paths) 76 | { 77 | QStringList *p = getSearchPaths(); 78 | p->clear(); 79 | *p << paths; 80 | } 81 | 82 | 83 | /************************************************ 84 | 85 | ************************************************/ 86 | bool translate(const QString &name, const QString &owner) 87 | { 88 | const QString locale = QLocale::system().name(); 89 | QTranslator *appTranslator = new QTranslator(qApp); 90 | 91 | QStringList *paths = getSearchPaths(); 92 | for(const QString &path : std::as_const(*paths)) 93 | { 94 | QStringList subPaths; 95 | 96 | if (!owner.isEmpty()) 97 | { 98 | subPaths << path + QL1C('/') + owner + QL1C('/') + name; 99 | } 100 | else 101 | { 102 | subPaths << path + QL1C('/') + name; 103 | subPaths << path; 104 | } 105 | 106 | for(const QString &p : std::as_const(subPaths)) 107 | { 108 | if (appTranslator->load(name + QL1C('_') + locale, p)) 109 | { 110 | QCoreApplication::installTranslator(appTranslator); 111 | return true; 112 | } 113 | else if (locale == QL1SV("C") || 114 | locale.startsWith(QL1SV("en"))) 115 | { 116 | // English is the default. Even if there isn't an translation 117 | // file, we return true. It's translated anyway. 118 | delete appTranslator; 119 | return true; 120 | } 121 | } 122 | } 123 | 124 | // If we got here, no translation was loaded. appTranslator has no use. 125 | delete appTranslator; 126 | return false; 127 | } 128 | 129 | 130 | /************************************************ 131 | 132 | ************************************************/ 133 | bool Translator::translateApplication(const QString &applicationName) 134 | { 135 | const QString locale = QLocale::system().name(); 136 | QTranslator *qtTranslator = new QTranslator(qApp); 137 | 138 | if (qtTranslator->load(QL1SV("qt_") + locale, QLibraryInfo::path(QLibraryInfo::TranslationsPath))) 139 | { 140 | qApp->installTranslator(qtTranslator); 141 | } 142 | else 143 | { 144 | delete qtTranslator; 145 | } 146 | 147 | if (!applicationName.isEmpty()) 148 | return translate(applicationName); 149 | else 150 | return translate(QFileInfo(QCoreApplication::applicationFilePath()).baseName()); 151 | } 152 | 153 | 154 | /************************************************ 155 | 156 | ************************************************/ 157 | bool Translator::translateLibrary(const QString &libraryName) 158 | { 159 | static QSet loadedLibs; 160 | 161 | if (loadedLibs.contains(libraryName)) 162 | return true; 163 | 164 | loadedLibs.insert(libraryName); 165 | 166 | return translate(libraryName); 167 | } 168 | 169 | bool Translator::translatePlugin(const QString &pluginName, const QString& type) 170 | { 171 | static QSet loadedPlugins; 172 | 173 | const QString fullName = type % QL1C('/') % pluginName; 174 | if (loadedPlugins.contains(fullName)) 175 | return true; 176 | 177 | loadedPlugins.insert(pluginName); 178 | return translate(pluginName, type); 179 | } 180 | 181 | static void loadSelfTranslation() 182 | { 183 | Translator::translateLibrary(QStringLiteral("liblxqt")); 184 | } 185 | 186 | Q_COREAPP_STARTUP_FUNCTION(loadSelfTranslation) 187 | -------------------------------------------------------------------------------- /lxqttranslator.h: -------------------------------------------------------------------------------- 1 | /* BEGIN_COMMON_COPYRIGHT_HEADER 2 | * (c)LGPL2+ 3 | * 4 | * LXQt - a lightweight, Qt based, desktop toolset 5 | * https://lxqt.org 6 | * 7 | * Copyright: 2013 LXQt team 8 | * Authors: 9 | * Alexander Sokoloff 10 | Luís Pereira 11 | * 12 | * This program or library is free software; you can redistribute it 13 | * and/or modify it under the terms of the GNU Lesser General Public 14 | * License as published by the Free Software Foundation; either 15 | * version 2.1 of the License, or (at your option) any later version. 16 | * 17 | * This library is distributed in the hope that it will be useful, 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 20 | * Lesser General Public License for more details. 21 | 22 | * You should have received a copy of the GNU Lesser General 23 | * Public License along with this library; if not, write to the 24 | * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 25 | * Boston, MA 02110-1301 USA 26 | * 27 | * END_COMMON_COPYRIGHT_HEADER */ 28 | 29 | #ifndef LXQTTRANSLATOR_H 30 | #define LXQTTRANSLATOR_H 31 | 32 | #include 33 | #include "lxqtglobals.h" 34 | 35 | namespace LXQt 36 | { 37 | /** 38 | The Translator class provides internationalization support for application and librarioes. 39 | **/ 40 | class LXQT_API Translator 41 | { 42 | public: 43 | /** 44 | Returns a list of paths that the application will search translations files. 45 | **/ 46 | static QStringList translationSearchPaths(); 47 | 48 | /** 49 | Sets the list of directories to search translations. All existing paths 50 | will be deleted and the path list will consist of the paths given in paths. 51 | **/ 52 | static void setTranslationSearchPaths(const QStringList &paths); 53 | 54 | /** 55 | Loads translations for application. If applicationName is not specified, 56 | then basename of QCoreApplication::applicationFilePath() is used. 57 | Returns true if the translation is successfully loaded; otherwise returns false. 58 | **/ 59 | static bool translateApplication(const QString &applicationName = QString()); 60 | 61 | /** 62 | Loads translations for application. If applicationName is not specified, 63 | then basename of QCoreApplication::applicationFilePath() is used. 64 | Returns true if the translation is successfully loaded; otherwise returns false. 65 | **/ 66 | static bool translateLibrary(const QString &libraryName = QString()); 67 | 68 | static bool translatePlugin(const QString &pluginName, const QString& type); 69 | }; 70 | 71 | } // namespace LXQt 72 | #endif // LXQTTRANSLATOR_H 73 | -------------------------------------------------------------------------------- /polkit/org.lxqt.backlight.pkexec.policy.in: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | Authentication is required to Change Brightness 7 | battery 8 | 9 | no 10 | no 11 | yes 12 | 13 | ${CMAKE_INSTALL_PREFIX}/bin/lxqt-backlight_backend 14 | 15 | 16 | -------------------------------------------------------------------------------- /resources/power.conf: -------------------------------------------------------------------------------- 1 | [General] 2 | monitorOffCommand=xset dpms force off 3 | showLeaveDialogCommand=lxqt-leave 4 | -------------------------------------------------------------------------------- /translations/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(liblxqt) 2 | 3 | build_component("." "") 4 | -------------------------------------------------------------------------------- /translations/liblxqt.ts: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ConfigDialog 6 | 7 | 8 | Dialog 9 | 10 | 11 | 12 | 13 | LXQt::MessageBox 14 | 15 | 16 | LXQt Power Manager Error 17 | 18 | 19 | 20 | 21 | Hibernate failed. 22 | 23 | 24 | 25 | 26 | LXQt::NotificationPrivate 27 | 28 | 29 | Notifications Fallback 30 | 31 | 32 | 33 | 34 | LXQt::PowerManager 35 | 36 | 37 | Hibernate 38 | 39 | 40 | 41 | 42 | Suspend 43 | 44 | 45 | 46 | 47 | Reboot 48 | 49 | 50 | 51 | 52 | Shutdown 53 | 54 | 55 | 56 | 57 | Logout 58 | 59 | 60 | 61 | 62 | LXQt Session Suspend 63 | 64 | 65 | 66 | 67 | Do you want to really suspend your computer?<p>Suspends the computer into a low power state. System state is not preserved if the power is lost. 68 | 69 | 70 | 71 | 72 | LXQt Session Hibernate 73 | 74 | 75 | 76 | 77 | Do you want to really hibernate your computer?<p>Hibernates the computer into a low power state. System state is preserved if the power is lost. 78 | 79 | 80 | 81 | 82 | LXQt Session Reboot 83 | 84 | 85 | 86 | 87 | Do you want to really restart your computer? All unsaved work will be lost... 88 | 89 | 90 | 91 | 92 | LXQt Session Shutdown 93 | 94 | 95 | 96 | 97 | Do you want to really switch off your computer? All unsaved work will be lost... 98 | 99 | 100 | 101 | 102 | LXQt Session Logout 103 | 104 | 105 | 106 | 107 | Do you want to really logout? All unsaved work will be lost... 108 | 109 | 110 | 111 | 112 | 113 | LXQt Power Manager Error 114 | 115 | 116 | 117 | 118 | Hibernate failed. 119 | 120 | 121 | 122 | 123 | Suspend failed. 124 | 125 | 126 | 127 | 128 | LXQt::ScreenSaver 129 | 130 | 131 | Failed to run "%1". Ensure you have a locker/screensaver compatible with xdg-screensaver installed and running. 132 | 133 | 134 | 135 | 136 | Failed to run "%1". Ensure the specified locker/screensaver is installed and running. 137 | 138 | 139 | 140 | 141 | Lock Screen 142 | 143 | 144 | 145 | 146 | Screen Saver Error 147 | 148 | 149 | 150 | 151 | QCoreApplication 152 | 153 | 154 | Choose the page to be shown. 155 | 156 | 157 | 158 | 159 | QObject 160 | 161 | 162 | 163 | Power Manager Error 164 | 165 | 166 | 167 | 168 | 169 | QDBusInterface is invalid 170 | 171 | 172 | 173 | 174 | 175 | Power Manager Error (D-BUS call) 176 | 177 | 178 | 179 | 180 | -------------------------------------------------------------------------------- /translations/liblxqt_arn.ts: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ConfigDialog 6 | 7 | 8 | Dialog 9 | 10 | 11 | 12 | 13 | LXQt::MessageBox 14 | 15 | 16 | LXQt Power Manager Error 17 | 18 | 19 | 20 | 21 | Hibernate failed. 22 | 23 | 24 | 25 | 26 | LXQt::NotificationPrivate 27 | 28 | 29 | Notifications Fallback 30 | 31 | 32 | 33 | 34 | LXQt::PowerManager 35 | 36 | 37 | Hibernate 38 | 39 | 40 | 41 | 42 | Suspend 43 | 44 | 45 | 46 | 47 | Reboot 48 | 49 | 50 | 51 | 52 | Shutdown 53 | 54 | 55 | 56 | 57 | Logout 58 | 59 | 60 | 61 | 62 | LXQt Session Suspend 63 | 64 | 65 | 66 | 67 | Do you want to really suspend your computer?<p>Suspends the computer into a low power state. System state is not preserved if the power is lost. 68 | 69 | 70 | 71 | 72 | LXQt Session Hibernate 73 | 74 | 75 | 76 | 77 | Do you want to really hibernate your computer?<p>Hibernates the computer into a low power state. System state is preserved if the power is lost. 78 | 79 | 80 | 81 | 82 | LXQt Session Reboot 83 | 84 | 85 | 86 | 87 | Do you want to really restart your computer? All unsaved work will be lost... 88 | 89 | 90 | 91 | 92 | LXQt Session Shutdown 93 | 94 | 95 | 96 | 97 | Do you want to really switch off your computer? All unsaved work will be lost... 98 | 99 | 100 | 101 | 102 | LXQt Session Logout 103 | 104 | 105 | 106 | 107 | Do you want to really logout? All unsaved work will be lost... 108 | 109 | 110 | 111 | 112 | 113 | LXQt Power Manager Error 114 | 115 | 116 | 117 | 118 | Hibernate failed. 119 | 120 | 121 | 122 | 123 | Suspend failed. 124 | 125 | 126 | 127 | 128 | LXQt::ScreenSaver 129 | 130 | 131 | Failed to run "%1". Ensure you have a locker/screensaver compatible with xdg-screensaver installed and running. 132 | 133 | 134 | 135 | 136 | Failed to run "%1". Ensure the specified locker/screensaver is installed and running. 137 | 138 | 139 | 140 | 141 | Lock Screen 142 | 143 | 144 | 145 | 146 | Screen Saver Error 147 | 148 | 149 | 150 | 151 | QCoreApplication 152 | 153 | 154 | Choose the page to be shown. 155 | 156 | 157 | 158 | 159 | QObject 160 | 161 | 162 | 163 | Power Manager Error 164 | 165 | 166 | 167 | 168 | 169 | QDBusInterface is invalid 170 | 171 | 172 | 173 | 174 | 175 | Power Manager Error (D-BUS call) 176 | 177 | 178 | 179 | 180 | -------------------------------------------------------------------------------- /translations/liblxqt_cy.ts: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ConfigDialog 6 | 7 | 8 | Dialog 9 | 10 | 11 | 12 | 13 | LXQt::MessageBox 14 | 15 | 16 | LXQt Power Manager Error 17 | 18 | 19 | 20 | 21 | Hibernate failed. 22 | 23 | 24 | 25 | 26 | LXQt::NotificationPrivate 27 | 28 | 29 | Notifications Fallback 30 | 31 | 32 | 33 | 34 | LXQt::PowerManager 35 | 36 | 37 | Hibernate 38 | 39 | 40 | 41 | 42 | Suspend 43 | 44 | 45 | 46 | 47 | Reboot 48 | 49 | 50 | 51 | 52 | Shutdown 53 | 54 | 55 | 56 | 57 | Logout 58 | 59 | 60 | 61 | 62 | LXQt Session Suspend 63 | 64 | 65 | 66 | 67 | Do you want to really suspend your computer?<p>Suspends the computer into a low power state. System state is not preserved if the power is lost. 68 | 69 | 70 | 71 | 72 | LXQt Session Hibernate 73 | 74 | 75 | 76 | 77 | Do you want to really hibernate your computer?<p>Hibernates the computer into a low power state. System state is preserved if the power is lost. 78 | 79 | 80 | 81 | 82 | LXQt Session Reboot 83 | 84 | 85 | 86 | 87 | Do you want to really restart your computer? All unsaved work will be lost... 88 | 89 | 90 | 91 | 92 | LXQt Session Shutdown 93 | 94 | 95 | 96 | 97 | Do you want to really switch off your computer? All unsaved work will be lost... 98 | 99 | 100 | 101 | 102 | LXQt Session Logout 103 | 104 | 105 | 106 | 107 | Do you want to really logout? All unsaved work will be lost... 108 | 109 | 110 | 111 | 112 | 113 | LXQt Power Manager Error 114 | 115 | 116 | 117 | 118 | Hibernate failed. 119 | 120 | 121 | 122 | 123 | Suspend failed. 124 | 125 | 126 | 127 | 128 | LXQt::ScreenSaver 129 | 130 | 131 | Failed to run "%1". Ensure you have a locker/screensaver compatible with xdg-screensaver installed and running. 132 | 133 | 134 | 135 | 136 | Failed to run "%1". Ensure the specified locker/screensaver is installed and running. 137 | 138 | 139 | 140 | 141 | Lock Screen 142 | 143 | 144 | 145 | 146 | Screen Saver Error 147 | 148 | 149 | 150 | 151 | QCoreApplication 152 | 153 | 154 | Choose the page to be shown. 155 | 156 | 157 | 158 | 159 | QObject 160 | 161 | 162 | 163 | Power Manager Error 164 | 165 | 166 | 167 | 168 | 169 | QDBusInterface is invalid 170 | 171 | 172 | 173 | 174 | 175 | Power Manager Error (D-BUS call) 176 | 177 | 178 | 179 | 180 | -------------------------------------------------------------------------------- /translations/liblxqt_en_GB.ts: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ConfigDialog 6 | 7 | 8 | Dialog 9 | 10 | 11 | 12 | 13 | LXQt::MessageBox 14 | 15 | 16 | LXQt Power Manager Error 17 | 18 | 19 | 20 | 21 | Hibernate failed. 22 | 23 | 24 | 25 | 26 | LXQt::NotificationPrivate 27 | 28 | 29 | Notifications Fallback 30 | 31 | 32 | 33 | 34 | LXQt::PowerManager 35 | 36 | 37 | Hibernate 38 | 39 | 40 | 41 | 42 | Suspend 43 | 44 | 45 | 46 | 47 | Reboot 48 | 49 | 50 | 51 | 52 | Shutdown 53 | 54 | 55 | 56 | 57 | Logout 58 | 59 | 60 | 61 | 62 | LXQt Session Suspend 63 | 64 | 65 | 66 | 67 | Do you want to really suspend your computer?<p>Suspends the computer into a low power state. System state is not preserved if the power is lost. 68 | 69 | 70 | 71 | 72 | LXQt Session Hibernate 73 | 74 | 75 | 76 | 77 | Do you want to really hibernate your computer?<p>Hibernates the computer into a low power state. System state is preserved if the power is lost. 78 | 79 | 80 | 81 | 82 | LXQt Session Reboot 83 | 84 | 85 | 86 | 87 | Do you want to really restart your computer? All unsaved work will be lost... 88 | 89 | 90 | 91 | 92 | LXQt Session Shutdown 93 | 94 | 95 | 96 | 97 | Do you want to really switch off your computer? All unsaved work will be lost... 98 | 99 | 100 | 101 | 102 | LXQt Session Logout 103 | 104 | 105 | 106 | 107 | Do you want to really logout? All unsaved work will be lost... 108 | 109 | 110 | 111 | 112 | 113 | LXQt Power Manager Error 114 | 115 | 116 | 117 | 118 | Hibernate failed. 119 | 120 | 121 | 122 | 123 | Suspend failed. 124 | 125 | 126 | 127 | 128 | LXQt::ScreenSaver 129 | 130 | 131 | Failed to run "%1". Ensure you have a locker/screensaver compatible with xdg-screensaver installed and running. 132 | Failed to run "%1". Ensure you have a locker/screensaver compatible with xdg-screensaver installed and running. 133 | 134 | 135 | 136 | Failed to run "%1". Ensure the specified locker/screensaver is installed and running. 137 | Failed to run "%1". Ensure the specified locker/screensaver is installed and running. 138 | 139 | 140 | 141 | Lock Screen 142 | 143 | 144 | 145 | 146 | Screen Saver Error 147 | 148 | 149 | 150 | 151 | QCoreApplication 152 | 153 | 154 | Choose the page to be shown. 155 | 156 | 157 | 158 | 159 | QObject 160 | 161 | 162 | 163 | Power Manager Error 164 | 165 | 166 | 167 | 168 | 169 | QDBusInterface is invalid 170 | 171 | 172 | 173 | 174 | 175 | Power Manager Error (D-BUS call) 176 | 177 | 178 | 179 | 180 | -------------------------------------------------------------------------------- /translations/liblxqt_kab.ts: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ConfigDialog 6 | 7 | 8 | Dialog 9 | 10 | 11 | 12 | 13 | LXQt::MessageBox 14 | 15 | 16 | LXQt Power Manager Error 17 | 18 | 19 | 20 | 21 | Hibernate failed. 22 | 23 | 24 | 25 | 26 | LXQt::NotificationPrivate 27 | 28 | 29 | Notifications Fallback 30 | 31 | 32 | 33 | 34 | LXQt::PowerManager 35 | 36 | 37 | Hibernate 38 | 39 | 40 | 41 | 42 | Suspend 43 | 44 | 45 | 46 | 47 | Reboot 48 | Ales asenker 49 | 50 | 51 | 52 | Shutdown 53 | Sexsi 54 | 55 | 56 | 57 | Logout 58 | Senser tuqqna 59 | 60 | 61 | 62 | LXQt Session Suspend 63 | 64 | 65 | 66 | 67 | Do you want to really suspend your computer?<p>Suspends the computer into a low power state. System state is not preserved if the power is lost. 68 | 69 | 70 | 71 | 72 | LXQt Session Hibernate 73 | 74 | 75 | 76 | 77 | Do you want to really hibernate your computer?<p>Hibernates the computer into a low power state. System state is preserved if the power is lost. 78 | 79 | 80 | 81 | 82 | LXQt Session Reboot 83 | 84 | 85 | 86 | 87 | Do you want to really restart your computer? All unsaved work will be lost... 88 | 89 | 90 | 91 | 92 | LXQt Session Shutdown 93 | 94 | 95 | 96 | 97 | Do you want to really switch off your computer? All unsaved work will be lost... 98 | 99 | 100 | 101 | 102 | LXQt Session Logout 103 | 104 | 105 | 106 | 107 | Do you want to really logout? All unsaved work will be lost... 108 | 109 | 110 | 111 | 112 | 113 | LXQt Power Manager Error 114 | 115 | 116 | 117 | 118 | Hibernate failed. 119 | 120 | 121 | 122 | 123 | Suspend failed. 124 | 125 | 126 | 127 | 128 | LXQt::ScreenSaver 129 | 130 | 131 | Failed to run "%1". Ensure you have a locker/screensaver compatible with xdg-screensaver installed and running. 132 | 133 | 134 | 135 | 136 | Failed to run "%1". Ensure the specified locker/screensaver is installed and running. 137 | 138 | 139 | 140 | 141 | Lock Screen 142 | 143 | 144 | 145 | 146 | Screen Saver Error 147 | 148 | 149 | 150 | 151 | QCoreApplication 152 | 153 | 154 | Choose the page to be shown. 155 | 156 | 157 | 158 | 159 | QObject 160 | 161 | 162 | 163 | Power Manager Error 164 | 165 | 166 | 167 | 168 | 169 | QDBusInterface is invalid 170 | 171 | 172 | 173 | 174 | 175 | Power Manager Error (D-BUS call) 176 | 177 | 178 | 179 | 180 | -------------------------------------------------------------------------------- /translations/liblxqt_kk.ts: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ConfigDialog 6 | 7 | 8 | Dialog 9 | Сұхбат 10 | 11 | 12 | 13 | LXQt::MessageBox 14 | 15 | 16 | LXQt Power Manager Error 17 | 18 | 19 | 20 | 21 | Hibernate failed. 22 | 23 | 24 | 25 | 26 | LXQt::NotificationPrivate 27 | 28 | 29 | Notifications Fallback 30 | 31 | 32 | 33 | 34 | LXQt::PowerManager 35 | 36 | 37 | Hibernate 38 | 39 | 40 | 41 | 42 | Suspend 43 | 44 | 45 | 46 | 47 | Reboot 48 | 49 | 50 | 51 | 52 | Shutdown 53 | 54 | 55 | 56 | 57 | Logout 58 | 59 | 60 | 61 | 62 | LXQt Session Suspend 63 | 64 | 65 | 66 | 67 | Do you want to really suspend your computer?<p>Suspends the computer into a low power state. System state is not preserved if the power is lost. 68 | 69 | 70 | 71 | 72 | LXQt Session Hibernate 73 | 74 | 75 | 76 | 77 | Do you want to really hibernate your computer?<p>Hibernates the computer into a low power state. System state is preserved if the power is lost. 78 | 79 | 80 | 81 | 82 | LXQt Session Reboot 83 | 84 | 85 | 86 | 87 | Do you want to really restart your computer? All unsaved work will be lost... 88 | 89 | 90 | 91 | 92 | LXQt Session Shutdown 93 | 94 | 95 | 96 | 97 | Do you want to really switch off your computer? All unsaved work will be lost... 98 | 99 | 100 | 101 | 102 | LXQt Session Logout 103 | 104 | 105 | 106 | 107 | Do you want to really logout? All unsaved work will be lost... 108 | 109 | 110 | 111 | 112 | 113 | LXQt Power Manager Error 114 | 115 | 116 | 117 | 118 | Hibernate failed. 119 | 120 | 121 | 122 | 123 | Suspend failed. 124 | 125 | 126 | 127 | 128 | LXQt::ScreenSaver 129 | 130 | 131 | Failed to run "%1". Ensure you have a locker/screensaver compatible with xdg-screensaver installed and running. 132 | 133 | 134 | 135 | 136 | Failed to run "%1". Ensure the specified locker/screensaver is installed and running. 137 | 138 | 139 | 140 | 141 | Lock Screen 142 | 143 | 144 | 145 | 146 | Screen Saver Error 147 | 148 | 149 | 150 | 151 | QCoreApplication 152 | 153 | 154 | Choose the page to be shown. 155 | 156 | 157 | 158 | 159 | QObject 160 | 161 | 162 | 163 | Power Manager Error 164 | 165 | 166 | 167 | 168 | 169 | QDBusInterface is invalid 170 | 171 | 172 | 173 | 174 | 175 | Power Manager Error (D-BUS call) 176 | 177 | 178 | 179 | 180 | -------------------------------------------------------------------------------- /translations/liblxqt_zh_CN.ts: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ConfigDialog 6 | 7 | 8 | Dialog 9 | 对话框 10 | 11 | 12 | 13 | LXQt::MessageBox 14 | 15 | 16 | LXQt Power Manager Error 17 | LXQt 电源管理器错误 18 | 19 | 20 | 21 | Hibernate failed. 22 | 休眠失败。 23 | 24 | 25 | 26 | LXQt::NotificationPrivate 27 | 28 | 29 | Notifications Fallback 30 | 缺省消息通知 31 | 32 | 33 | 34 | LXQt::PowerManager 35 | 36 | 37 | Hibernate 38 | 休眠 39 | 40 | 41 | 42 | Suspend 43 | 挂起 44 | 45 | 46 | 47 | Reboot 48 | 重启 49 | 50 | 51 | 52 | Shutdown 53 | 关机 54 | 55 | 56 | 57 | Logout 58 | 注销 59 | 60 | 61 | 62 | LXQt Session Suspend 63 | 挂起LXQt会话 64 | 65 | 66 | 67 | Do you want to really suspend your computer?<p>Suspends the computer into a low power state. System state is not preserved if the power is lost. 68 | 你真的要挂起你的计算机吗?<p>挂起的计算机将进入低功耗状态。 电源丢失后系统状态不会被保存。 69 | 70 | 71 | 72 | LXQt Session Hibernate 73 | 休眠LXQt会话 74 | 75 | 76 | 77 | Do you want to really hibernate your computer?<p>Hibernates the computer into a low power state. System state is preserved if the power is lost. 78 | 你真的要将你的计算机休眠吗?<p>休眠的计算机将进入低功耗状态。 电源丢失后系统状态不会被保存。 79 | 80 | 81 | 82 | LXQt Session Reboot 83 | 重启LXQt会话 84 | 85 | 86 | 87 | Do you want to really restart your computer? All unsaved work will be lost... 88 | 你真的想要重启你的计算机吗? 所有未保存的任务都将丢失…… 89 | 90 | 91 | 92 | LXQt Session Shutdown 93 | 关闭电源 94 | 95 | 96 | 97 | Do you want to really switch off your computer? All unsaved work will be lost... 98 | 你真的想要关闭你的计算机吗? 所有未保存的任务都将丢失…… 99 | 100 | 101 | 102 | LXQt Session Logout 103 | 注销LXQt会话 104 | 105 | 106 | 107 | Do you want to really logout? All unsaved work will be lost... 108 | 你真的想要注销你的计算机吗? 所有未保存的任务都将丢失…… 109 | 110 | 111 | 112 | 113 | LXQt Power Manager Error 114 | LXQt 电源管理器错误 115 | 116 | 117 | 118 | Hibernate failed. 119 | 休眠失败。 120 | 121 | 122 | 123 | Suspend failed. 124 | 挂起失败。 125 | 126 | 127 | 128 | LXQt::ScreenSaver 129 | 130 | 131 | Failed to run "%1". Ensure you have a locker/screensaver compatible with xdg-screensaver installed and running. 132 | 运行"%1"失败。确保你已经安装并运行着一个与 xdg-screensaver 适配的屏保或锁屏。 133 | 134 | 135 | 136 | Failed to run "%1". Ensure the specified locker/screensaver is installed and running. 137 | 运行 "%1"失败。请确保指定的锁屏或屏保已经安装并正在运行。 138 | 139 | 140 | 141 | Lock Screen 142 | 锁屏 143 | 144 | 145 | 146 | Screen Saver Error 147 | 屏幕保护程序错误 148 | 149 | 150 | 151 | QCoreApplication 152 | 153 | 154 | Choose the page to be shown. 155 | 选择要显示的页。 156 | 157 | 158 | 159 | QObject 160 | 161 | 162 | 163 | Power Manager Error 164 | 电源管理错误 165 | 166 | 167 | 168 | 169 | QDBusInterface is invalid 170 | QDBusInterface 不正确 171 | 172 | 173 | 174 | 175 | Power Manager Error (D-BUS call) 176 | 电源管理错误 (D-BUS 调用) 177 | 178 | 179 | 180 | -------------------------------------------------------------------------------- /translations/liblxqt_zh_TW.ts: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ConfigDialog 6 | 7 | 8 | Dialog 9 | 對話框 10 | 11 | 12 | 13 | LXQt::MessageBox 14 | 15 | 16 | LXQt Power Manager Error 17 | LXQt電源管理員錯誤 18 | 19 | 20 | 21 | Hibernate failed. 22 | 休眠失敗。 23 | 24 | 25 | 26 | LXQt::NotificationPrivate 27 | 28 | 29 | Notifications Fallback 30 | 後援通知 31 | 32 | 33 | 34 | LXQt::PowerManager 35 | 36 | 37 | Hibernate 38 | 休眠 39 | 40 | 41 | 42 | Suspend 43 | 暫停 44 | 45 | 46 | 47 | Reboot 48 | 重新啟動 49 | 50 | 51 | 52 | Shutdown 53 | 關機 54 | 55 | 56 | 57 | Logout 58 | 登出 59 | 60 | 61 | 62 | LXQt Session Suspend 63 | LXQt 工作階段暫停 64 | 65 | 66 | 67 | Do you want to really suspend your computer?<p>Suspends the computer into a low power state. System state is not preserved if the power is lost. 68 | 確定要讓電腦進入暫停嗎?<p>暫停電腦將進入低功耗狀態。如果電源切斷,系統狀態不會被保存。 69 | 70 | 71 | 72 | LXQt Session Hibernate 73 | LXQt 工作階段休眠 74 | 75 | 76 | 77 | Do you want to really hibernate your computer?<p>Hibernates the computer into a low power state. System state is preserved if the power is lost. 78 | 確定要讓電腦進入休眠嗎?<p>休眠電腦即進入低功耗狀態。如果電源切斷,系統狀態將會被保存。 79 | 80 | 81 | 82 | LXQt Session Reboot 83 | LXQt 工作階段重新啟動 84 | 85 | 86 | 87 | Do you want to really restart your computer? All unsaved work will be lost... 88 | 確定要重新啟動您的電腦嗎?全部尚未儲存工作將會遺失…… 89 | 90 | 91 | 92 | LXQt Session Shutdown 93 | 關閉電源 94 | 95 | 96 | 97 | Do you want to really switch off your computer? All unsaved work will be lost... 98 | 確定要關閉您的電腦嗎?全部尚未儲存工作將會遺失…… 99 | 100 | 101 | 102 | LXQt Session Logout 103 | LXQt 工作階段登出 104 | 105 | 106 | 107 | Do you want to really logout? All unsaved work will be lost... 108 | 確定要登出嗎?全部尚未儲存工作將會遺失…… 109 | 110 | 111 | 112 | 113 | LXQt Power Manager Error 114 | LXQt 電源管理器錯誤 115 | 116 | 117 | 118 | Hibernate failed. 119 | 休眠失敗。 120 | 121 | 122 | 123 | Suspend failed. 124 | 暫停失敗。 125 | 126 | 127 | 128 | LXQt::ScreenSaver 129 | 130 | 131 | Failed to run "%1". Ensure you have a locker/screensaver compatible with xdg-screensaver installed and running. 132 | 無法執行 "%1"。要確定與 xdg-screensaver 相容的鎖定程式/螢幕保護程式已經安裝並在執行中。 133 | 134 | 135 | 136 | Failed to run "%1". Ensure the specified locker/screensaver is installed and running. 137 | 執行失敗 "%1"。確定指定的鎖定程式/螢幕保護程式已有安裝並在執行中。 138 | 139 | 140 | 141 | Lock Screen 142 | 螢幕鎖定 143 | 144 | 145 | 146 | Screen Saver Error 147 | 螢幕保護程式錯誤 148 | 149 | 150 | 151 | QCoreApplication 152 | 153 | 154 | Choose the page to be shown. 155 | 選擇要顯示的頁面。 156 | 157 | 158 | 159 | QObject 160 | 161 | 162 | 163 | Power Manager Error 164 | 電源管理器錯誤 165 | 166 | 167 | 168 | 169 | QDBusInterface is invalid 170 | QDBusInterface 無效 171 | 172 | 173 | 174 | 175 | Power Manager Error (D-BUS call) 176 | 電源管理器錯誤 (D-Bus 呼叫) 177 | 178 | 179 | 180 | --------------------------------------------------------------------------------