Skip to content

Commit

Permalink
wayland support
Browse files Browse the repository at this point in the history
  • Loading branch information
arcan1s committed May 17, 2023
1 parent 84de975 commit dea9d48
Show file tree
Hide file tree
Showing 89 changed files with 423 additions and 646 deletions.
4 changes: 2 additions & 2 deletions sources/.clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ BreakBeforeBinaryOperators: All
BreakBeforeBraces: Linux
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: true
ColumnLimit: 100
ColumnLimit: 120
CommentPragmas: '^ IWYU pragma:'
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
Expand Down Expand Up @@ -58,7 +58,7 @@ SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
Standard: Latest
TabWidth: 8
UseTab: Never
...
Expand Down
23 changes: 6 additions & 17 deletions sources/awdebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,15 @@ QString AWDebug::getAboutText(const QString &_type)
} else if (_type == "description") {
text = i18n("A set of minimalistic plasmoid widgets");
} else if (_type == "links") {
text = i18n("Links:") + "<ul>"
+ QString("<li><a href=\"%1\">%2</a></li>").arg(HOMEPAGE).arg(i18n("Homepage"))
text = i18n("Links:") + "<ul>" + QString("<li><a href=\"%1\">%2</a></li>").arg(HOMEPAGE).arg(i18n("Homepage"))
+ QString("<li><a href=\"%1\">%2</a></li>").arg(REPOSITORY).arg(i18n("Repository"))
+ QString("<li><a href=\"%1\">%2</a></li>").arg(BUGTRACKER).arg(i18n("Bugtracker"))
+ QString("<li><a href=\"%1\">%2</a></li>")
.arg(TRANSLATION)
.arg(i18n("Translation issue"))
+ QString("<li><a href=\"%1\">%2</a></li>")
.arg(AUR_PACKAGES)
.arg(i18n("AUR packages"))
+ QString("<li><a href=\"%1\">%2</a></li>")
.arg(OPENSUSE_PACKAGES)
.arg(i18n("openSUSE packages"))
+ QString("<li><a href=\"%1\">%2</a></li>").arg(TRANSLATION).arg(i18n("Translation issue"))
+ QString("<li><a href=\"%1\">%2</a></li>").arg(AUR_PACKAGES).arg(i18n("AUR packages"))
+ QString("<li><a href=\"%1\">%2</a></li>").arg(OPENSUSE_PACKAGES).arg(i18n("openSUSE packages"))
+ "</ul>";
} else if (_type == "copy") {
text = QString("<small>&copy; %1 <a href=\"mailto:%2\">%3</a><br>")
.arg(DATE)
.arg(EMAIL)
.arg(AUTHOR)
text = QString("<small>&copy; %1 <a href=\"mailto:%2\">%3</a><br>").arg(DATE).arg(EMAIL).arg(AUTHOR)
+ i18nc("This software is licensed under %1", LICENSE) + "</small>";
} else if (_type == "translators") {
QStringList translatorList = QString(TRANSLATORS).split(',');
Expand Down Expand Up @@ -114,8 +104,7 @@ QStringList AWDebug::getBuildData()
metadata.append(QString(" CMAKE_CXX_FLAGS: %1").arg(CMAKE_CXX_FLAGS));
metadata.append(QString(" CMAKE_CXX_FLAGS_DEBUG: %1").arg(CMAKE_CXX_FLAGS_DEBUG));
metadata.append(QString(" CMAKE_CXX_FLAGS_RELEASE: %1").arg(CMAKE_CXX_FLAGS_RELEASE));
metadata.append(
QString(" CMAKE_CXX_FLAGS_OPTIMIZATION: %1").arg(CMAKE_CXX_FLAGS_OPTIMIZATION));
metadata.append(QString(" CMAKE_CXX_FLAGS_OPTIMIZATION: %1").arg(CMAKE_CXX_FLAGS_OPTIMIZATION));
metadata.append(QString(" CMAKE_DEFINITIONS: %1").arg(CMAKE_DEFINITIONS));
metadata.append(QString(" CMAKE_INSTALL_PREFIX: %1").arg(CMAKE_INSTALL_PREFIX));
metadata.append(QString(" CMAKE_MODULE_LINKER_FLAGS: %1").arg(CMAKE_MODULE_LINKER_FLAGS));
Expand Down
3 changes: 1 addition & 2 deletions sources/awesome-widget/plugin/awabstractpairconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ void AWAbstractPairConfig::updateUi()
void AWAbstractPairConfig::addSelector(const QStringList &_keys, const QStringList &_values,
const QPair<QString, QString> &_current)
{
qCDebug(LOG_AW) << "Add selector with keys" << _keys << "values" << _values
<< "and current ones" << _current;
qCDebug(LOG_AW) << "Add selector with keys" << _keys << "values" << _values << "and current ones" << _current;

auto *selector = new AWAbstractSelector(ui->scrollAreaWidgetContents, m_editable);
selector->init(_keys, _values, _current);
Expand Down
6 changes: 2 additions & 4 deletions sources/awesome-widget/plugin/awabstractpairconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ class AWAbstractPairConfig : public QDialog
Q_OBJECT

public:
explicit AWAbstractPairConfig(QWidget *_parent = nullptr, bool _hasEdit = false,
QStringList _keys = QStringList());
explicit AWAbstractPairConfig(QWidget *_parent = nullptr, bool _hasEdit = false, QStringList _keys = QStringList());
~AWAbstractPairConfig() override;
template <class T> void initHelper()
{
Expand All @@ -62,8 +61,7 @@ private slots:
bool m_hasEdit = false;
QStringList m_keys;
// methods
void addSelector(const QStringList &_keys, const QStringList &_values,
const QPair<QString, QString> &_current);
void addSelector(const QStringList &_keys, const QStringList &_values, const QPair<QString, QString> &_current);
void clearSelectors();
void execDialog();
[[nodiscard]] QPair<QStringList, QStringList> initKeys() const;
Expand Down
14 changes: 4 additions & 10 deletions sources/awesome-widget/plugin/awabstractpairhelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ void AWAbstractPairHelper::initItems()
{
m_pairs.clear();

QStringList configs
= QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, m_filePath);
QStringList configs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, m_filePath);

for (auto &fileName : configs) {
QSettings settings(fileName, QSettings::IniFormat);
Expand All @@ -80,8 +79,7 @@ void AWAbstractPairHelper::initItems()
QStringList keys = settings.childKeys();
for (auto &key : keys) {
QString value = settings.value(key).toString();
qCInfo(LOG_AW) << "Found key" << key << "for value" << value << "in"
<< settings.fileName();
qCInfo(LOG_AW) << "Found key" << key << "for value" << value << "in" << settings.fileName();
if (value.isEmpty()) {
qCInfo(LOG_AW) << "Skip empty value for" << key;
continue;
Expand All @@ -98,9 +96,7 @@ bool AWAbstractPairHelper::writeItems(const QHash<QString, QString> &_configurat
qCDebug(LOG_AW) << "Write configuration" << _configuration;

QString fileName
= QString("%1/%2")
.arg(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation))
.arg(m_filePath);
= QString("%1/%2").arg(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)).arg(m_filePath);
QSettings settings(fileName, QSettings::IniFormat);
qCInfo(LOG_AW) << "Configuration file" << fileName;

Expand All @@ -120,9 +116,7 @@ bool AWAbstractPairHelper::removeUnusedKeys(const QStringList &_keys) const
qCDebug(LOG_AW) << "Remove keys" << _keys;

QString fileName
= QString("%1/%2")
.arg(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation))
.arg(m_filePath);
= QString("%1/%2").arg(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)).arg(m_filePath);
QSettings settings(fileName, QSettings::IniFormat);
qCInfo(LOG_AW) << "Configuration file" << fileName;

Expand Down
4 changes: 2 additions & 2 deletions sources/awesome-widget/plugin/awabstractselector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ void AWAbstractSelector::init(const QStringList &_keys, const QStringList &_valu
qCWarning(LOG_AW) << "Invalid current value" << _current << "not found in default ones";
return;
}
qCDebug(LOG_AW) << "Init selector with keys" << _keys << "and values" << _values
<< "and current ones are" << _current;
qCDebug(LOG_AW) << "Init selector with keys" << _keys << "and values" << _values << "and current ones are"
<< _current;

// set data
ui->comboBox_key->clear();
Expand Down
6 changes: 2 additions & 4 deletions sources/awesome-widget/plugin/awabstractselector.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,10 @@ class AWAbstractSelector : public QWidget
Q_OBJECT

public:
explicit AWAbstractSelector(QWidget *_parent = nullptr,
const QPair<bool, bool> &_editable = {false, false});
explicit AWAbstractSelector(QWidget *_parent = nullptr, const QPair<bool, bool> &_editable = {false, false});
~AWAbstractSelector() override;
[[nodiscard]] QPair<QString, QString> current() const;
void init(const QStringList &_keys, const QStringList &_values,
const QPair<QString, QString> &_current);
void init(const QStringList &_keys, const QStringList &_values, const QPair<QString, QString> &_current);

signals:
void selectionChanged();
Expand Down
4 changes: 2 additions & 2 deletions sources/awesome-widget/plugin/awactions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ QVariantMap AWActions::getFont(const QVariantMap &_defaultFont)

QVariantMap fontMap;
int ret = 0;
CFont defaultCFont = CFont(_defaultFont["family"].toString(), _defaultFont["size"].toInt(), 400,
false, _defaultFont["color"].toString());
CFont defaultCFont = CFont(_defaultFont["family"].toString(), _defaultFont["size"].toInt(), 400, false,
_defaultFont["color"].toString());
CFont font = CFontDialog::getFont(i18n("Select font"), defaultCFont, false, false, &ret);

fontMap["applied"] = ret;
Expand Down
13 changes: 5 additions & 8 deletions sources/awesome-widget/plugin/awbugreporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,12 @@ AWBugReporter::~AWBugReporter()
void AWBugReporter::doConnect()
{
// additional method for testing needs
connect(this, SIGNAL(replyReceived(const int, const QString &)), this,
SLOT(showInformation(int, const QString &)));
connect(this, SIGNAL(replyReceived(const int, const QString &)), this, SLOT(showInformation(int, const QString &)));
}


QString AWBugReporter::generateText(const QString &_description, const QString &_reproduce,
const QString &_expected, const QString &_logs)
QString AWBugReporter::generateText(const QString &_description, const QString &_reproduce, const QString &_expected,
const QString &_logs)
{
// do not log _logs here, it may have quite large size
qCDebug(LOG_AW) << "Generate text with description" << _description << "steps" << _reproduce
Expand All @@ -73,8 +72,7 @@ void AWBugReporter::sendBugReport(const QString &_title, const QString &_body)
qCDebug(LOG_AW) << "Send bug report with title" << _title << "and body" << _body;

auto *manager = new QNetworkAccessManager(nullptr);
connect(manager, SIGNAL(finished(QNetworkReply *)), this,
SLOT(issueReplyRecieved(QNetworkReply *)));
connect(manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(issueReplyRecieved(QNetworkReply *)));

QNetworkRequest request = QNetworkRequest(QUrl(BUGTRACKER_API));
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
Expand All @@ -95,8 +93,7 @@ void AWBugReporter::sendBugReport(const QString &_title, const QString &_body)
void AWBugReporter::issueReplyRecieved(QNetworkReply *_reply)
{
if (_reply->error() != QNetworkReply::NoError) {
qCWarning(LOG_AW) << "An error occurs" << _reply->error() << "with message"
<< _reply->errorString();
qCWarning(LOG_AW) << "An error occurs" << _reply->error() << "with message" << _reply->errorString();
return emit(replyReceived(0, ""));
}

Expand Down
51 changes: 19 additions & 32 deletions sources/awesome-widget/plugin/awconfighelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ AWConfigHelper::AWConfigHelper(QObject *_parent)
{
qCDebug(LOG_AW) << __PRETTY_FUNCTION__;

m_baseDir = QString("%1/awesomewidgets")
.arg(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation));
m_baseDir = QString("%1/awesomewidgets").arg(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation));
}


Expand All @@ -45,9 +44,8 @@ AWConfigHelper::~AWConfigHelper()
QString AWConfigHelper::configurationDirectory()
{
// get readable directory
QString localDir
= QString("%1/awesomewidgets/configs")
.arg(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation));
QString localDir = QString("%1/awesomewidgets/configs")
.arg(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation));

// create directory and copy files from default settings
QDir localDirectory;
Expand All @@ -63,8 +61,7 @@ QString AWConfigHelper::configurationDirectory()
bool AWConfigHelper::dropCache()
{
QString fileName
= QString("%1/awesomewidgets.ndx")
.arg(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation));
= QString("%1/awesomewidgets.ndx").arg(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation));

return QFile(fileName).remove();
}
Expand All @@ -88,8 +85,8 @@ bool AWConfigHelper::exportConfiguration(QObject *_nativeConfig, const QString &

// extensions
for (auto &item : m_dirs) {
QStringList items = QDir(QString("%1/%2").arg(m_baseDir).arg(item))
.entryList(QStringList() << "*.desktop", QDir::Files);
QStringList items
= QDir(QString("%1/%2").arg(m_baseDir).arg(item)).entryList(QStringList() << "*.desktop", QDir::Files);
settings.beginGroup(item);
for (auto &it : items)
copyExtensions(it, item, settings, false);
Expand All @@ -99,11 +96,9 @@ bool AWConfigHelper::exportConfiguration(QObject *_nativeConfig, const QString &
// additional files
settings.beginGroup("json");
// script filters
readFile(settings, "filters",
QString("%1/scripts/awesomewidgets-extscripts-filters.json").arg(m_baseDir));
readFile(settings, "filters", QString("%1/scripts/awesomewidgets-extscripts-filters.json").arg(m_baseDir));
// weather icon settings
readFile(settings, "weathers",
QString("%1/weather/awesomewidgets-extweather-ids.json").arg(m_baseDir));
readFile(settings, "weathers", QString("%1/weather/awesomewidgets-extweather-ids.json").arg(m_baseDir));
settings.endGroup();

settings.beginGroup("ini");
Expand All @@ -120,10 +115,8 @@ bool AWConfigHelper::exportConfiguration(QObject *_nativeConfig, const QString &
}


QVariantMap AWConfigHelper::importConfiguration(const QString &_fileName,
const bool _importPlasmoid,
const bool _importExtensions,
const bool _importAdds) const
QVariantMap AWConfigHelper::importConfiguration(const QString &_fileName, const bool _importPlasmoid,
const bool _importExtensions, const bool _importAdds) const
{
qCDebug(LOG_AW) << "Selected filename" << _fileName;

Expand All @@ -144,11 +137,9 @@ QVariantMap AWConfigHelper::importConfiguration(const QString &_fileName,
if (_importAdds) {
settings.beginGroup("json");
// script filters
writeFile(settings, "filters",
QString("%1/scripts/awesomewidgets-extscripts-filters.json").arg(m_baseDir));
writeFile(settings, "filters", QString("%1/scripts/awesomewidgets-extscripts-filters.json").arg(m_baseDir));
// weather icon settings
writeFile(settings, "weathers",
QString("%1/weather/awesomewidgets-extweather-ids.json").arg(m_baseDir));
writeFile(settings, "weathers", QString("%1/weather/awesomewidgets-extweather-ids.json").arg(m_baseDir));
settings.endGroup();

settings.beginGroup("ini");
Expand All @@ -173,8 +164,7 @@ QVariantMap AWConfigHelper::importConfiguration(const QString &_fileName,

QVariantMap AWConfigHelper::readDataEngineConfiguration()
{
QString fileName = QStandardPaths::locate(QStandardPaths::ConfigLocation,
"plasma-dataengine-extsysmon.conf");
QString fileName = QStandardPaths::locate(QStandardPaths::ConfigLocation, "plasma-dataengine-extsysmon.conf");
qCInfo(LOG_AW) << "Configuration file" << fileName;
QSettings settings(fileName, QSettings::IniFormat);
QVariantMap configuration;
Expand Down Expand Up @@ -228,31 +218,28 @@ void AWConfigHelper::copyConfigs(const QString &_localDir)
{
qCDebug(LOG_AW) << "Local directory" << _localDir;

QStringList dirs
= QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, "awesomewidgets/configs",
QStandardPaths::LocateDirectory);
QStringList dirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, "awesomewidgets/configs",
QStandardPaths::LocateDirectory);
for (auto &dir : dirs) {
if (dir == _localDir)
continue;
QStringList files = QDir(dir).entryList(QDir::Files);
for (auto &source : files) {
QString destination = QString("%1/%2").arg(_localDir).arg(source);
bool status = QFile::copy(QString("%1/%2").arg(dir).arg(source), destination);
qCInfo(LOG_AW) << "File" << source << "has been copied to" << destination
<< "with status" << status;
qCInfo(LOG_AW) << "File" << source << "has been copied to" << destination << "with status" << status;
}
}
}


void AWConfigHelper::copyExtensions(const QString &_item, const QString &_type,
QSettings &_settings, const bool _inverse) const
void AWConfigHelper::copyExtensions(const QString &_item, const QString &_type, QSettings &_settings,
const bool _inverse) const
{
qCDebug(LOG_AW) << "Extension" << _item << "has type" << _type << "inverse copying" << _inverse;

_settings.beginGroup(_item);
QSettings itemSettings(QString("%1/%2/%3").arg(m_baseDir).arg(_type).arg(_item),
QSettings::IniFormat);
QSettings itemSettings(QString("%1/%2/%3").arg(m_baseDir).arg(_type).arg(_item), QSettings::IniFormat);
itemSettings.beginGroup("Desktop Entry");
if (_inverse)
copySettings(_settings, itemSettings);
Expand Down
9 changes: 3 additions & 6 deletions sources/awesome-widget/plugin/awconfighelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,16 @@ class AWConfigHelper : public QObject
Q_INVOKABLE [[nodiscard]] static QString configurationDirectory();
Q_INVOKABLE static bool dropCache();
Q_INVOKABLE bool exportConfiguration(QObject *_nativeConfig, const QString &_fileName) const;
Q_INVOKABLE [[nodiscard]] QVariantMap importConfiguration(const QString &_fileName,
bool _importPlasmoid,
bool _importExtensions,
bool _importAdds) const;
Q_INVOKABLE [[nodiscard]] QVariantMap importConfiguration(const QString &_fileName, bool _importPlasmoid,
bool _importExtensions, bool _importAdds) const;
// dataengine
Q_INVOKABLE static QVariantMap readDataEngineConfiguration();
Q_INVOKABLE static bool writeDataEngineConfiguration(const QVariantMap &_configuration);

private:
// methods
static void copyConfigs(const QString &_localDir);
void copyExtensions(const QString &_item, const QString &_type, QSettings &_settings,
bool _inverse) const;
void copyExtensions(const QString &_item, const QString &_type, QSettings &_settings, bool _inverse) const;
static void copySettings(QSettings &_from, QSettings &_to);
static void readFile(QSettings &_settings, const QString &_key, const QString &_fileName);
static void writeFile(QSettings &_settings, const QString &_key, const QString &_fileName);
Expand Down
3 changes: 1 addition & 2 deletions sources/awesome-widget/plugin/awcustomkeysconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ class AWCustomKeysConfig : public AWAbstractPairConfig
Q_OBJECT

public:
explicit AWCustomKeysConfig(QWidget *_parent = nullptr,
const QStringList &_keys = QStringList());
explicit AWCustomKeysConfig(QWidget *_parent = nullptr, const QStringList &_keys = QStringList());
~AWCustomKeysConfig() override;
};

Expand Down
Loading

0 comments on commit dea9d48

Please sign in to comment.