...
 
Commits (15)
moc_*.cxx
qrc_*.cxx
cmake_install.cmake
cmake_uninstall.cmake
Makefile
CMakeFiles
CMakeCache.txt
CPackConfig.cmake
CPackSourceConfig.cmake
lib*.so
lib*.so.*
ui_*.h
*.qm
lxqt-appswitcher/lxqt-appswitcher
lxqt-desktop/lxqt-desktop
lxqt-panel/panel/lxqt-panel
*~
*.autosave
*-swp
CMakeLists.txt.user*
/build
nbproject/
[main]
host = https://www.transifex.com
[lxde-qt.liblxqt]
file_filter = translations/liblxqt_<lang>.ts
source_file = translations/source.ts
source_lang = en
type = QT
#[flacon.About_Translators]
#source_file = translations/src.translators.info
#source_lang = en
#file_filter = translations/translators_<lang>.info
#type = MOZILLAPROPERTIES
#!/bin/sh
tx pull --all --force
#!/bin/sh
LUPDATE_OPTIONS="-noobsolete"
LUPDATE_OPTIONS="${LUPDATE_OPTIONS} -locations none "
TS_FILE="../translations/source.ts"
LUPDATE=$(which lupdate-qt4 2>/dev/null)
[ -z "${LUPDATE}" ] && LUPDATE=$(which lupdate 2>/dev/null)
if [ -z "${LUPDATE}" ]; then
echo "The lupdate program not found."
exit 1;
fi
${LUPDATE} ${LUPDATE_OPTIONS} .. -ts ${TS_FILE}
#!/bin/sh
./updateSrc.sh && tx push --source
Upstream Authors:
LXQt team: http://lxqt.org
LXQt team: https://lxqt.org
Razor team: http://razor-qt.org
Copyright:
Copyright (c) 2010-2012 Razor team
Copyright (c) 2012-2014 LXQt team
Copyright (c) 2012-2018 LXQt team
License: GPL-2 and LGPL-2.1+
The full text of the licenses can be found in the 'COPYING' file.
License: LGPL-2.1+ and BSD-3-clause
The full text of the LGPL-2.1+ licenses can be found in the 'COPYING' file.
The full text of the BSD-3-clause license can be found in the headers of
the files under this license.
This diff is collapsed.
This diff is collapsed.
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
......@@ -23,8 +22,7 @@ specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations
below.
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
......@@ -89,9 +87,9 @@ libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it
becomes a de-facto standard. To achieve this, non-free programs must
be allowed to use the library. A more frequent case is that a free
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
......@@ -138,8 +136,8 @@ included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control
compilation and installation of the library.
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
......@@ -305,10 +303,10 @@ of these things:
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at least
three years, to give the same user the materials specified in
Subsection 6a, above, for a charge no more than the cost of
performing this distribution.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
......@@ -386,10 +384,9 @@ all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply, and the section as a whole is intended to apply in other
circumstances.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
......@@ -407,11 +404,11 @@ be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License
may add an explicit geographical distribution limitation excluding those
countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
......
# liblxqt
## Overview
`liblxqt` represents the core library of LXQt providing essential functionality
needed by nearly all of its components.
## Installation
### Sources
Its runtime dependencies are libxss, KWindowSystem, qtbase, qtx11extras and
[libqtxdg](https://github.com/lxqt/libqtxdg).
Additional build dependencies are CMake and optionally Git to pull latest VCS
checkouts. The localization files were outsourced to repository
[lxqt-l10n](https://github.com/lxqt/lxqt-l10n) so the corresponding dependencies
are needed, too. Please refer to this repository's `README.md` for further
information.
Code configuration is handled by CMake. CMake variable `CMAKE_INSTALL_PREFIX`
will normally have to be set to `/usr`, depending on the way library paths are
dealt with on 64bit systems variables like `CMAKE_INSTALL_LIBDIR` may have to be
set as well.
To build run `make`, to install `make install` which accepts variable `DESTDIR`
as usual.
### Binary packages
The library is provided by all major Linux distributions like Arch Linux, Debian,
Fedora and openSUSE. Just use your package manager to search for string `liblxqt`.
### Translation (Weblate)
<a href="https://weblate.lxqt.org/projects/lxqt/liblxqt/">
<img src="https://weblate.lxqt.org/widgets/lxqt/-/liblxqt/multi-auto.svg" alt="Translation status" />
</a>
/* BEGIN_COMMON_COPYRIGHT_HEADER
* (c)LGPL2+
*
* LXQt - The Lightweight Desktop Environment
* http://lxqt.org
*
* Copyright: 2010-2011 Razor team
* Authors:
* Petr Vanek <petr@scribus.info>
*
* This program or library is free software; you can redistribute it
* and/or modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* END_COMMON_COPYRIGHT_HEADER */
#include "lxqtaboutdialog.h"
#include "ui_lxqtaboutdialog.h"
#include "lxqtaboutdialog_p.h"
#include "lxqttranslator.h"
#include "technicalinfo.h"
#include "translatorsinfo/translatorsinfo.h"
#include <QDebug>
#include <QDate>
#include <QClipboard>
using namespace LxQt;
AboutDialogPrivate::AboutDialogPrivate()
{
Translator::translateLibrary("liblxqt");
setupUi(this);
QString css="<style TYPE='text/css'> "
"body { font-family: sans-serif;} "
".name { font-size: 16pt; } "
"a { white-space: nowrap ;} "
"h2 { font-size: 10pt;} "
"li { line-height: 120%;} "
".techInfoKey { white-space: nowrap ; margin: 0 20px 0 16px; } "
"</style>"
;
iconLabel->setFixedSize(48, 48);
iconLabel->setScaledContents(true);
iconLabel->setPixmap(QPixmap(QString(LXQT_SHARE_DIR) + "/graphics/lxqt_logo.png"));
nameLabel->setText(css + titleText());
aboutBrowser->setHtml(css + aboutText());
aboutBrowser->viewport()->setAutoFillBackground(false);
autorsBrowser->setHtml(css + authorsText());
autorsBrowser->viewport()->setAutoFillBackground(false);
thanksBrowser->setHtml(css + thanksText());
thanksBrowser->viewport()->setAutoFillBackground(false);
translationsBrowser->setHtml(css + translationsText());
translationsBrowser->viewport()->setAutoFillBackground(false);
TechnicalInfo info;
techBrowser->setHtml(info.html());
techBrowser->viewport()->setAutoFillBackground(false);
connect(techCopyToClipboardButton, SIGNAL(clicked()), this, SLOT(copyToCliboardTechInfo()));
this->setAttribute(Qt::WA_DeleteOnClose);
show();
}
QString AboutDialogPrivate::titleText() const
{
return QString("<div class=name>%1</div><div class=ver>%2</div>").arg("LXQt",
tr("Version: %1").arg(LXQT_VERSION));
}
QString AboutDialogPrivate::aboutText() const
{
return QString(
"<p>%1</p>"
"<p>%2</p>"
"<p>%3</p>"
"<p>%4</p>"
"<p>%5</p>")
.arg(
tr("Advanced, easy-to-use, and fast desktop environment based on Qt technologies.",
"About dialog, 'About' tab text"),
tr("LXQt would not have been possible without the <a %1>Razor-qt</a> project and its many contributors.",
"About dialog, 'About' tab text").arg("href=\"http://razor-qt.org\""),
tr("Copyright: %1-%2 %3", "About dialog, 'About' tab text")
.arg("2010", QDate::currentDate().toString("yyyy"), "LXQt team"),
tr("Homepage: %1", "About dialog, 'About' tab text")
.arg("<a href=\"http://lxqt.org\">http://lxqt.org</a>"),
tr("License: %1", "About dialog, 'About' tab text")
.arg("<a href=\"http://www.gnu.org/licenses/lgpl-2.1.html\">GNU Lesser General Public License version 2.1 or later</a>"
" and partly under the "
"<a href=\"http://www.gnu.org/licenses/gpl-2.0.html\">GNU General Public License version 2</a>")
);
}
QString AboutDialogPrivate::authorsText() const
{
return QString("<p>%1</p><p>%2</p>").arg(
tr("LXQt is developed by the <a %1>LXQt Team and contributors</a>.", "About dialog, 'Authors' tab text")
.arg(" href=\"https://github.com/lxde/lxde-qt\""),
tr("If you are interested in working with our development team, <a %1>join us</a>.", "About dialog, 'Authors' tab text")
.arg("href=\"http://lxqt.org\"")
);
}
QString AboutDialogPrivate::thanksText() const
{
return QString(
"%1"
"<ul>"
"<li>Alexey Nosov (for the A-MeGo theme)</li>"
"<li>Alexander Zakher (the Razor-qt name)</li>"
"<li>Andy Fitzsimon (logo/icon)</li>"
"<li>Eugene Pivnev (QtDesktop)</li>"
"<li>Paul Gnther (desktop backgrounds)</li>"
"<li>Manuel Meier (for ideas)</li>"
"<li>KDE &lt;<a href=\"http://kde.org/\">http://kde.org/</a>&gt;</li>"
).arg(tr("Special thanks to:", "About dialog, 'Thanks' tab text"));
}
QString AboutDialogPrivate::translationsText() const
{
TranslatorsInfo translatorsInfo;
return QString("%1<p><ul>%2</ul>").arg(
tr("LXQt is translated into many languages thanks to the work of the translation teams all over the world.", "About dialog, 'Translations' tab text"),
translatorsInfo.asHtml()
);
}
AboutDialog::AboutDialog()
{
d_ptr = new AboutDialogPrivate();
}
void AboutDialogPrivate::copyToCliboardTechInfo()
{
TechnicalInfo info;
QClipboard *clipboard = QApplication::clipboard();
clipboard->setText(info.text());
}
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>about</class>
<widget class="QDialog" name="about">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>633</width>
<height>416</height>
</rect>
</property>
<property name="windowTitle">
<string> About LXQt</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>21</number>
</property>
<property name="bottomMargin">
<number>16</number>
</property>
<item>
<widget class="QLabel" name="iconLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="sizeIncrement">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="text">
<string notr="true"/>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="nameLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string notr="true">&lt;h1&gt;LXQt&lt;/h1&gt;&lt;p&gt;Version: %1&lt;/p&gt;</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
<string comment="About dialog, Tab title ">About</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QTextBrowser" name="aboutBrowser">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_3">
<attribute name="title">
<string comment="About dialog, Tab title">Authors</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QTextBrowser" name="autorsBrowser">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_4">
<attribute name="title">
<string comment="About dialog, Tab title">Thanks</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QTextBrowser" name="thanksBrowser">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="translationsTab">
<attribute name="title">
<string comment="About dialog, Tab title">Translations</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QTextBrowser" name="translationsBrowser">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string comment="About dialog, Tab title">Technical Info</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QTextBrowser" name="techBrowser">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="techCopyToClipboardButton">
<property name="text">
<string>Copy to clipboard</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Close</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>about</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>303</x>
<y>273</y>
</hint>
<hint type="destinationlabel">
<x>437</x>
<y>290</y>
</hint>
</hints>
</connection>
</connections>
</ui>
/* BEGIN_COMMON_COPYRIGHT_HEADER
* (c)LGPL2+
*
* LXQt - a lightweight, Qt based, desktop toolset
* http://razor-qt.org
*
* Copyright: 2010-2011 Razor team
* Authors:
* Petr Vanek <petr@scribus.info>
*
* This program or library is free software; you can redistribute it
* and/or modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* END_COMMON_COPYRIGHT_HEADER */
#ifndef LXQT_ABOUTDIALOG_P_H
#define LXQT_ABOUTDIALOG_P_H
#include "ui_lxqtaboutdialog.h"
#include <QDialog>
namespace LxQt
{
/**
* @brief prepares the data to show and fills the form, then shows.
*/
class AboutDialogPrivate: public QDialog, public Ui_about
{
Q_OBJECT
public:
AboutDialogPrivate();
QString titleText() const;
QString aboutText() const;
QString authorsText() const;
QString thanksText() const;
QString translationsText() const;
public slots:
void copyToCliboardTechInfo();
};
} // namespace LxQt
#endif // LXQT_ABOUTDIALOG_P_H
/* BEGIN_COMMON_COPYRIGHT_HEADER
* (c)LGPL2+
*
* LXQt - a lightweight, Qt based, desktop toolset
* http://razor-qt.org
*
* Copyright: 2012 Razor team
* Authors:
* Alexander Sokoloff <sokoloff.a@gmail.com>
*
* This program or library is free software; you can redistribute it
* and/or modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* END_COMMON_COPYRIGHT_HEADER */
#include "technicalinfo.h"
#include "lxqttranslator.h"
#include <XdgDirs>
using namespace LxQt;
class LxQt::TechInfoTable
{
public:
TechInfoTable(const QString &title);
void add(const QString &name, const QVariant &value);
QString html() const;
QString text(int nameFieldWidth) const;
int maxNameLength() const;
private:
QString mTitle;
QList<QPair<QString,QString> > mRows;
};
TechInfoTable::TechInfoTable(const QString &title)
{
mTitle = title;
}
void TechInfoTable::add(const QString &name, const QVariant &value)
{
QPair<QString,QString> row;
row.first = name;
row.second = value.toString();
mRows.append(row);
}
QString TechInfoTable::html() const
{
QString res;
res = "<style TYPE='text/css'> "
".techInfoKey { white-space: nowrap ; margin: 0 20px 0 16px; } "
"</style>";
res += QString("<b>%1</b>").arg(mTitle);
res += "<table width='100%'>";
QPair<QString,QString> row;
foreach(row, mRows)
{
res += QString("<tr>"
"<td class=techInfoTd width='1%'>"
"<div class=techInfoKey>%1</div>"
"</td>"
"<td>%2</td>"
"</tr>").arg(row.first, row.second);
}
res += "</table>";
return res;
}
QString TechInfoTable::text(int nameFieldWidth) const
{
QString res;
res += QString("%1\n").arg(mTitle);
QPair<QString,QString> row;
foreach(row, mRows)
{
res += QString(" %1 %2\n")
.arg(row.first + ":", -nameFieldWidth)
.arg(row.second);
}
return res;
}
int TechInfoTable::maxNameLength() const
{
int res = 0;
QPair<QString,QString> row;
foreach (row, mRows)
res = qMax(res, row.first.length());
return res;
}
QString TechnicalInfo::html() const
{
QString res;
foreach (TechInfoTable* item, mItems)
{
res += item->html();
res += "<br><br>";
}
return res;
}
QString TechnicalInfo::text() const
{
int nameWidth = 0;
foreach (TechInfoTable* item, mItems)
nameWidth = qMax(nameWidth, item->maxNameLength());
QString res;
foreach (TechInfoTable* item, mItems)
{
res += item->text(nameWidth + 2);
res += "\n\n";
}
return res;
}
TechInfoTable *TechnicalInfo::newTable(const QString &title)
{
TechInfoTable *table = new TechInfoTable(title);
mItems.append(table);
return table;
}
TechnicalInfo::~TechnicalInfo()
{
qDeleteAll(mItems);
}
TechnicalInfo::TechnicalInfo()
{
TechInfoTable *table;
// ******************************************
table = newTable("LXQt Desktop Toolbox - Technical Info<p>");
#ifdef DEBUG
QString buildType("Debug");
#else
QString buildType("Release");
#endif
table->add("Version", LXQT_VERSION);
table->add("Qt", qVersion());
table->add("Build type", buildType);
table->add("System Configuration", LXQT_ETC_XDG_DIR);
table->add("Share Directory", LXQT_SHARE_DIR);
table->add("Translations", Translator::translationSearchPaths().join("<br>\n"));
// ******************************************
table = newTable("User Directories");
XdgDirs xdgDirs;
table->add("Xdg Data Home", xdgDirs.dataHome(false));
table->add("Xdg Config Home", xdgDirs.configHome(false));
table->add("Xdg Data Dirs", xdgDirs.dataDirs().join(":"));
table->add("Xdg Cache Home", xdgDirs.cacheHome(false));
table->add("Xdg Runtime Home", xdgDirs.runtimeDir());
table->add("Xdg Autostart Dirs", xdgDirs.autostartDirs().join("<br>\n"));
table->add("Xdg Autostart Home", xdgDirs.autostartHome(false));
}
/* BEGIN_COMMON_COPYRIGHT_HEADER
* (c)LGPL2+
*
* LXQt - a lightweight, Qt based, desktop toolset
* http://razor-qt.org
*
* Copyright: 2010-2011 Razor team
* Authors:
* Alexander Sokoloff <sokoloff.a@gmail.com>
*
* This program or library is free software; you can redistribute it
* and/or modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* END_COMMON_COPYRIGHT_HEADER */
#include "lxqtaddplugindialog.h"
#include "ui_lxqtaddplugindialog.h"
#include "lxqthtmldelegate.h"
#include <QDebug>
#include <QLineEdit>
#include <XdgIcon>
#include <QListWidgetItem>
#include <QIcon>
#include "lxqttranslator.h"
using namespace LxQt;
#define SEARCH_ROLE Qt::UserRole
#define INDEX_ROLE SEARCH_ROLE+1
/************************************************
************************************************/
bool pluginDescriptionLessThan(const PluginInfo &p1, const PluginInfo &p2)
{
int cmp = QString::compare(p1.name(), p2.name());
if (cmp != 0)
return cmp < 0;
return p1.comment() < p2.comment();
}
/************************************************
************************************************/
AddPluginDialog::AddPluginDialog(const QStringList& desktopFilesDirs,
const QString &serviceType,
const QString &nameFilter,
QWidget *parent):
QDialog(parent),
ui(new Ui::AddPluginDialog),
mTimerId(0)
{
Translator::translateLibrary("liblxqt");
ui->setupUi(this);
mPlugins = PluginInfo::search(desktopFilesDirs, serviceType, nameFilter);
qSort(mPlugins.begin(), mPlugins.end(), pluginDescriptionLessThan);
ui->pluginList->setItemDelegate(new HtmlDelegate(QSize(32, 32), ui->pluginList));
init();
connect(ui->pluginList, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(emitPluginSelected()));
connect(ui->pluginList, SIGNAL(itemSelectionChanged()), this, SLOT(toggleAddButtonState()));
connect(ui->searchEdit, SIGNAL(textEdited(QString)), this, SLOT(searchEditTexChanged(QString)));
connect(ui->addButton, SIGNAL(clicked(bool)), this, SLOT(emitPluginSelected()));
}
void AddPluginDialog::setPluginsInUse(const QStringList pluginsInUseIDs)
{
Q_FOREACH (QString id, pluginsInUseIDs)
{
if (!mPluginsInUseAmount.contains(id))
mPluginsInUseAmount[id] = 0;
mPluginsInUseAmount[id]++;
}
init();
}
void AddPluginDialog::init()
{
QListWidget* pluginList = ui->pluginList;
pluginList->clear();
QIcon fallIco = XdgIcon::fromTheme("preferences-plugin");
int pluginCount = mPlugins.length();
for (int i = 0; i < pluginCount; ++i)
{
const PluginInfo &plugin = mPlugins.at(i);
QString countStr;
int amount = mPluginsInUseAmount[plugin.id()];
if (amount)
countStr = tr("(%1 active)").arg(amount);
QListWidgetItem* item = new QListWidgetItem(ui->pluginList);
item->setText(QString("<b>%1 %2</b><br>\n%3\n").arg(plugin.name(), countStr, plugin.comment()));
item->setIcon(plugin.icon(fallIco));
item->setData(INDEX_ROLE, i);
item->setData(SEARCH_ROLE, QString("%1 %2 %3 %4").arg(
plugin.name(),
plugin.comment(),
plugin.value("Name").toString(),
plugin.value("Comment").toString()
)
);
}
if (pluginCount > 0)
ui->pluginList->setCurrentRow(0);
}
/************************************************
************************************************/
void AddPluginDialog::pluginAdded(const QString &id)
{
if (!mPluginsInUseAmount.contains(id))
mPluginsInUseAmount[id] = 0;
mPluginsInUseAmount[id]++;
init();
}
/************************************************
************************************************/
void AddPluginDialog::pluginRemoved(const QString &id)
{
mPluginsInUseAmount[id]--;
init();
}
/************************************************
************************************************/
AddPluginDialog::~AddPluginDialog()
{
delete ui;
}
/************************************************
************************************************/
void AddPluginDialog::searchEditTexChanged(const QString& text)
{
if (mTimerId)
killTimer(mTimerId);
mTimerId = startTimer(SEARCH_DELAY);
}
/************************************************
************************************************/
void AddPluginDialog::timerEvent(QTimerEvent* event)
{
if (event->timerId() == mTimerId)
{
killTimer(mTimerId);
QListWidget* pluginList = ui->pluginList;
QString s = ui->searchEdit->text();
for (int i=0; i < pluginList->count(); ++i)
{
QListWidgetItem* item = pluginList->item(i);
item->setHidden(! item->data(SEARCH_ROLE).toString().contains(s, Qt::CaseInsensitive));
}
}
}
/************************************************
************************************************/
void AddPluginDialog::emitPluginSelected()
{
QListWidget* pluginList = ui->pluginList;
if (pluginList->currentItem() && pluginList->currentItem()->isSelected())
{
PluginInfo plugin = mPlugins.at(pluginList->currentItem()->data(INDEX_ROLE).toInt());
emit pluginSelected(plugin);
}
}
/************************************************
************************************************/
void AddPluginDialog::toggleAddButtonState()
{
ui->addButton->setEnabled(ui->pluginList->currentItem() && ui->pluginList->currentItem()->isSelected());
}
/* BEGIN_COMMON_COPYRIGHT_HEADER
* (c)LGPL2+
*
* LXQt - a lightweight, Qt based, desktop toolset
* http://razor-qt.org
*
* Copyright: 2010-2011 Razor team
* Authors:
* Alexander Sokoloff <sokoloff.a@gmail.com>
*
* This program or library is free software; you can redistribute it
* and/or modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* END_COMMON_COPYRIGHT_HEADER */
#ifndef LXQTADDPLUGINDIALOG_H
#define LXQTADDPLUGINDIALOG_H
#include <QDialog>
#include <lxqtplugininfo.h>
#include "lxqtglobals.h"
#define SEARCH_DELAY 125
namespace Ui {
class AddPluginDialog;
}
namespace LxQt
{
/*! The AddPluginDialog class provides a dialog that allow users to add plugins.
*/
class LXQT_API AddPluginDialog : public QDialog
{
Q_OBJECT
public:
/*! Constructs a dialog with the given parent that initially displays
PluginInfo objects for the matched files in the directories
@param desktopFilesDirs - list of the scanned directories names.
@param serviceType - type of the plugin, for example "LxQtPanel/Plugin".
@param nameFilter - wildcard filter that understands * and ? wildcards. */
AddPluginDialog(const QStringList& desktopFilesDirs,
const QString& serviceType,
const QString& nameFilter="*",
QWidget *parent = 0);
~AddPluginDialog();
void setPluginsInUse(const QStringList pluginsInUseIDs);
signals:
void pluginSelected(const LxQt::PluginInfo &plugin);
protected:
void timerEvent(QTimerEvent* event);
private:
void init();
Ui::AddPluginDialog *ui;
PluginInfoList mPlugins;
int mTimerId;
// store the amount of instances of the plugins using their ids
QHash<QString, int> mPluginsInUseAmount;
public slots:
void pluginAdded(const QString &id);
void pluginRemoved(const QString &id);
private slots:
void emitPluginSelected();
void searchEditTexChanged(const QString& text);
void toggleAddButtonState();
};
} // namecpase LxQt
#endif // LXQTADDPLUGINDIALOG_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AddPluginDialog</class>
<widget class="QDialog" name="AddPluginDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>359</height>
</rect>
</property>
<property name="windowTitle">
<string/>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="searchLabel">
<property name="text">
<string>Search:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="searchEdit"/>
</item>
</layout>
</item>
<item>
<widget class="QListWidget" name="pluginList">
<property name="sizeAdjustPolicy">
<enum>QAbstractScrollArea::AdjustToContentsOnFirstShow</enum>
</property>
<property name="showDropIndicator" stdset="0">
<bool>true</bool>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<property name="movement">
<enum>QListView::Static</enum>
</property>
<property name="flow">
<enum>QListView::TopToBottom</enum>
</property>
<property name="resizeMode">
<enum>QListView::Adjust</enum>
</property>
<property name="spacing">
<number>0</number>
</property>
<property name="modelColumn">
<number>0</number>
</property>
<property name="uniformItemSizes">
<bool>false</bool>
</property>
<property name="selectionRectVisible">
<bool>true</bool>
</property>
<property name="currentRow">
<number>-1</number>
</property>
<property name="sortingEnabled">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="addButton">
<property name="text">
<string>Add Widget</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="closeButton">
<property name="text">
<string>Close</string>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
<property name="default">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<tabstops>
<tabstop>pluginList</tabstop>
<tabstop>addButton</tabstop>
<tabstop>closeButton</tabstop>
<tabstop>searchEdit</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
<sender>closeButton</sender>
<signal>clicked()</signal>
<receiver>AddPluginDialog</receiver>
<slot>close()</slot>
<hints>
<hint type="sourcelabel">
<x>380</x>
<y>279</y>
</hint>
<hint type="destinationlabel">
<x>118</x>
<y>270</y>
</hint>
</hints>
</connection>
</connections>
</ui>
# XDG standards expects system-wide configuration files in the /etc/xdg/lxqt location.
# Unfortunately QSettings we are using internally can be overriden in the Qt compilation
# time to use different path for system-wide configs. (for example configure ... -sysconfdir /etc/settings ...)
# This path can be found calling Qt4's qmake:
# qmake -query QT_INSTALL_CONFIGURATION
#
if(NOT DEFINED LXQT_ETC_XDG_DIR)
get_target_property(QT_QMAKE_EXECUTABLE ${Qt5Core_QMAKE_EXECUTABLE} IMPORTED_LOCATION)
message(STATUS "${QT_QMAKE_EXECUTABLE}")
if(NOT QT_QMAKE_EXECUTABLE)
message(FATAL_ERROR "LXQT_ETC_XDG_DIR: qmake executable not found (included before qt was configured?)")
endif()
execute_process(COMMAND ${QT_QMAKE_EXECUTABLE} -query QT_INSTALL_CONFIGURATION
OUTPUT_VARIABLE LXQT_ETC_XDG_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE)
message(STATUS "LXQT_ETC_XDG_DIR autodetected as '${LXQT_ETC_XDG_DIR}'")
message(STATUS "You can set it manually with -DLXQT_ETC_XDG_DIR=<value>")
message(STATUS "")
endif ()
#
# Write a pkg-config pc file for given "name" with "decription"
# Arguments:
# name: a library name (withoud "lib" prefix and "so" suffixes
# desc: a desription string
#
macro (create_pkgconfig_file name desc)
set(_pkgfname "${CMAKE_CURRENT_BINARY_DIR}/${name}.pc")
#message(STATUS "${name}: writing pkgconfig file ${_pkgfname}")
file(WRITE "${_pkgfname}"
"# file generated by lxde-qt cmake build\n"
"prefix=${CMAKE_INSTALL_PREFIX}\n"
"libdir=\${prefix}/lib${LIB_SUFFIX}\n"
"includedir=\${prefix}/include\n"
"\n"
"Name: ${name}\n"
"Description: ${desc}\n"
"Version: ${LXQT_VERSION}\n"
"Libs: -L\${libdir} -l${name}\n"
"Cflags: -I\${includedir}\n"
"\n"
)
# FreeBSD loves to install files to different locations
# http://www.freebsd.org/doc/handbook/dirstructure.html
if(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
install(FILES ${_pkgfname} DESTINATION libdata/pkgconfig)
else()
install(FILES ${_pkgfname} DESTINATION lib${LIB_SUFFIX}/pkgconfig)
endif()
endmacro()
# Creates portable headers; e.g.:
# Creates XdgAction from xdgaction.h
# XdgAction contents:
# #include "xdgaction.h"
#
# Use:
# set(PUBLIC_CLASSES MyClass YourClass)
# create_portable_headers(PORTABLE_HEADERS ${PUBLIC_CLASSES})
# PORTABLE_HEADER is an return value that contains the full name of the
# generated headers.
function(create_portable_headers outfiles outDir)
set(options)
set(oneValueArgs)
set(multiValueArgs)
cmake_parse_arguments(_CREATE_PORTABLE_HEADERS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
set(class_list ${_CREATE_PORTABLE_HEADERS_UNPARSED_ARGUMENTS})
foreach(f ${class_list})
string(TOLOWER "${f}.h" _filename)
file(WRITE ${outDir}/${f}
"#include \"lxqt${_filename}\"\n")
list(APPEND ${outfiles} ${outDir}/${f})
endforeach()
set(${outfiles} ${${outfiles}} PARENT_SCOPE)
endfunction()
function(check_portable_headers)
cmake_parse_arguments(__ARGS "" "" "H_FILES;LINKS" ${ARGN})
foreach(f ${__ARGS_LINKS})
file(READ ${f} content)
set(found False)
foreach(line ${content})
string(REGEX MATCH "#include \"(.*)\"" v ${line})
set(hFile ${CMAKE_MATCH_1})
string(REGEX MATCH "[;/]${hFile};" v ";${__ARGS_H_FILES};")
if(NOT v)
set(found True)
endif()
endforeach()
if(found)
message(FATAL_ERROR "Incorrect portable header: '${f}'")
endif()
endforeach()
endfunction()
# - Find the lxqt include and library dirs and define a some macros
#
# The module defines the following variables
#
# LXQT_FOUND - Set to TRUE if all of the above has been found
#
# LXQT_INCLUDE_DIR - The lxqt include directory
#
# LXQT_INCLUDE_DIRS - The lxqt and the Qt include directory, for use with INCLUDE_DIRECTORIES()
#
# LXQT_LIBRARY_DIRS - The lxqt and the Qt library directories
#
# LXQT_LIBRARIES - The libraries needed to use lxqt
#
# LXQT_SHARE_DIR - This allows to install and read the configs from non-standard locations
#
# LXQT_TRANSLATIONS_DIR - The default translations directory
#
# LXQT_ETC_XDG_DIR - XDG standards expects system-wide configuration files in the
# /etc/xdg/lxqt location. Unfortunately QSettings we are using internally
# can be overriden in the Qt compilation time to use different path for
# system-wide configs. (for example configure ... -sysconfdir /etc/settings ...)
# This path can be found calling Qt4's qmake:
# qmake -query QT_INSTALL_CONFIGURATION
#
# LXQT_USE_FILE - The variable LXQT_USE_FILE is set which is the path to a CMake file that
# can be included to compile lxqt applications and libraries. It sets up
# the compilation environment for include directories and populates a
# LXQT_LIBRARIES variable.
#
# When using the components argument, LXQT_USE_* variables are automatically set
# for the LXQT_USE_FILE to pick up. If one wishes to manually set them, the
# available ones to set include:
# LXQT_USE_MOUNT
# LXQT_USE_GLOBAL_KEY_CLIENT
#
# Typical usage could be something like:
# set(LXQT_USE_MOUNT 1)
# find_package(LXQT REQUIRED)
# include(${LXQT_USE_FILE})
#
# lxqt_translate_ts(QM_FILES
# SOURCES
# ${H_FILES}
# ${CPP_FILES}
# ${UI_FILES}
# )
# lxqt_translate_desktop(DESKTOP_FILES
# SOURCES
# ${DESKTOP_FILES_IN}
# )
#
# add_executable(myexe main.cpp)
# target_link_libraries(myexe $LXQT_LIBRARIES})
# - Finds the lxqt package
if(LXQT_FIND_REQUIRED)
set(REQUIRED_OPT "REQUIRED")
@PACKAGE_INIT@
if (CMAKE_VERSION VERSION_LESS 3.0.2)
message(FATAL_ERROR \"@PROJECT_NAME@ requires at least CMake version 3.0.2\")
endif()
set(LXQT_LIBRARY_DIRS @CMAKE_INSTALL_PREFIX@/@LIB_INSTALL_DIR@)
set(LXQT_LIBRARIES ${LXQT_LIBRARY} )
set(LXQT_INCLUDE_DIRS ${LXQT_INCLUDE_DIR} @CMAKE_INSTALL_PREFIX@/include)
set(LXQT_USE_FILE ${CMAKE_CURRENT_LIST_DIR}/lxqt_use.cmake)
set(LXQT_CMAKE_MODULES_DIR @CFG_LXQT_CMAKE_MODULES_DIR@)
set(LXQT_FOUND 1)
include(CMakeFindDependencyMacro)
find_dependency(Qt5Widgets @QT_MINIMUM_VERSION@)
find_dependency(Qt5DBus @QT_MINIMUM_VERSION@)
find_dependency(Qt5X11Extras @QT_MINIMUM_VERSION@)
find_dependency(Qt5LinguistTools @QT_MINIMUM_VERSION@)
find_dependency(Qt5Xdg @QTXDG_MINIMUM_VERSION@)
find_dependency(KF5WindowSystem)
find_dependency(lxqt-build-tools @LXQTBT_MINIMUM_VERSION@)
include(LXQtConfigVars)
if(LXQT_FIND_QUIETLY)
set(QUIET_OPT "QUIET")
endif()
find_package(LxQt5 ${REQUIRED_OPT} ${QUIET_OPT})
# - Set version informations
set(LXQT_MAJOR_VERSION "@LXQT_MAJOR_VERSION@")
set(LXQT_MINOR_VERSION "@LXQT_MINOR_VERSION@")
set(LXQT_PATCH_VERSION "@LXQT_PATCH_VERSION@")
set(LXQT_VERSION "@LXQT_VERSION@")