Commit 039f7d90 authored by Alexander Lohnau's avatar Alexander Lohnau 💬

Run clang-format

If you want git blame to ignore formatting revisions run:
git config blame.ignoreRevsFile .git-blame-ignore-revs
parent 977fa81a
......@@ -20,7 +20,6 @@ public:
{
return QColor::isValidColor(colorString);
}
};
static QObject *utils_singletontype_provider(QQmlEngine *, QJSEngine *)
......@@ -28,7 +27,7 @@ static QObject *utils_singletontype_provider(QQmlEngine *, QJSEngine *)
return new Utils();
}
void ColorPickerPlugin::registerTypes(const char* uri)
void ColorPickerPlugin::registerTypes(const char *uri)
{
Q_ASSERT(QLatin1String(uri) == QLatin1String("org.kde.plasma.private.colorpicker"));
qmlRegisterType<GrabWidget>(uri, 2, 0, "GrabWidget");
......
......@@ -17,7 +17,6 @@ class ColorPickerPlugin : public QQmlExtensionPlugin
public:
void registerTypes(const char *uri) override;
};
#endif // COLORPICKERPLUGIN_H
......@@ -6,15 +6,15 @@
#include "grabwidget.h"
#include <QDebug>
#include <QApplication>
#include <QClipboard>
#include <QDBusConnection>
#include <QDBusMessage>
#include <QDBusMetaType>
#include <QDBusPendingCall>
#include <QDBusPendingCallWatcher>
#include <QDBusPendingReply>
#include <QApplication>
#include <QClipboard>
#include <QDebug>
#include <QDesktopWidget>
#include <QEvent>
#include <QMouseEvent>
......@@ -25,7 +25,7 @@
Q_DECLARE_METATYPE(QColor)
QDBusArgument &operator<< (QDBusArgument &argument, const QColor &color)
QDBusArgument &operator<<(QDBusArgument &argument, const QColor &color)
{
argument.beginStructure();
argument << color.rgba();
......@@ -92,8 +92,7 @@ bool X11Grabber::eventFilter(QObject *watched, QEvent *event)
if (me->button() == Qt::LeftButton) {
const QPoint pos = me->globalPos();
const QDesktopWidget *desktop = QApplication::desktop();
const QPixmap pixmap = QGuiApplication::screens().at(desktop->screenNumber())->grabWindow(desktop->winId(),
pos.x(), pos.y(), 1, 1);
const QPixmap pixmap = QGuiApplication::screens().at(desktop->screenNumber())->grabWindow(desktop->winId(), pos.x(), pos.y(), 1, 1);
if (!pixmap.isNull()) {
QImage i = pixmap.toImage();
QColor color(i.pixel(0, 0));
......@@ -121,15 +120,13 @@ void KWinWaylandGrabber::pick()
QStringLiteral("pick"));
auto call = QDBusConnection::sessionBus().asyncCall(msg);
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(call, this);
connect(watcher, &QDBusPendingCallWatcher::finished, this,
[this] (QDBusPendingCallWatcher *watcher) {
watcher->deleteLater();
QDBusPendingReply<QColor> reply = *watcher;
if (!reply.isError()) {
setColor(reply.value());
}
connect(watcher, &QDBusPendingCallWatcher::finished, this, [this](QDBusPendingCallWatcher *watcher) {
watcher->deleteLater();
QDBusPendingReply<QColor> reply = *watcher;
if (!reply.isError()) {
setColor(reply.value());
}
);
});
}
GrabWidget::GrabWidget(QObject *parent)
......
......@@ -7,8 +7,8 @@
#ifndef GRABWIDGET_H
#define GRABWIDGET_H
#include <QObject>
#include <QColor>
#include <QObject>
class QWidget;
......@@ -20,7 +20,8 @@ public:
virtual void pick() = 0;
QColor color() const {
QColor color() const
{
return m_color;
}
......@@ -81,7 +82,6 @@ Q_SIGNALS:
private:
Grabber *m_grabber = nullptr;
};
#endif // GRABWIDGET_H
......@@ -9,12 +9,9 @@
ActiveComicModel::ActiveComicModel(QObject *parent)
: QStandardItemModel(0, 1, parent)
{
connect(this, &ActiveComicModel::modelReset,
this, &ActiveComicModel::countChanged);
connect(this, &ActiveComicModel::rowsInserted,
this, &ActiveComicModel::countChanged);
connect(this, &ActiveComicModel::rowsRemoved,
this, &ActiveComicModel::countChanged);
connect(this, &ActiveComicModel::modelReset, this, &ActiveComicModel::countChanged);
connect(this, &ActiveComicModel::rowsInserted, this, &ActiveComicModel::countChanged);
connect(this, &ActiveComicModel::rowsRemoved, this, &ActiveComicModel::countChanged);
}
QHash<int, QByteArray> ActiveComicModel::roleNames() const
......@@ -28,7 +25,7 @@ QHash<int, QByteArray> ActiveComicModel::roleNames() const
return roleNames;
}
void ActiveComicModel::addComic(const QString& key, const QString& title, const QIcon& icon, bool highlight)
void ActiveComicModel::addComic(const QString &key, const QString &title, const QIcon &icon, bool highlight)
{
QList<QStandardItem *> newRow;
QStandardItem *item = new QStandardItem(title);
......
......@@ -16,10 +16,10 @@ class ActiveComicModel : public QStandardItemModel
public:
enum Roles {
ComicKeyRole = Qt::UserRole+1,
ComicTitleRole = Qt::UserRole+2,
ComicIconRole = Qt::UserRole+3,
ComicHighlightRole = Qt::UserRole+4,
ComicKeyRole = Qt::UserRole + 1,
ComicTitleRole = Qt::UserRole + 2,
ComicIconRole = Qt::UserRole + 3,
ComicHighlightRole = Qt::UserRole + 4,
};
explicit ActiveComicModel(QObject *parent = nullptr);
......@@ -28,7 +28,10 @@ public:
void addComic(const QString &key, const QString &title, const QIcon &icon, bool highlight = true);
int count() { return rowCount(QModelIndex()); }
int count()
{
return rowCount(QModelIndex());
}
Q_INVOKABLE QVariantHash get(int i) const;
......
......@@ -8,43 +8,43 @@
#include <QTimer>
CheckNewStrips::CheckNewStrips( const QStringList &identifiers, Plasma::DataEngine *engine, int minutes, QObject *parent)
: QObject( parent ),
mMinutes( minutes ),
mIndex( 0 ),
mEngine( engine ),
mIdentifiers( identifiers )
CheckNewStrips::CheckNewStrips(const QStringList &identifiers, Plasma::DataEngine *engine, int minutes, QObject *parent)
: QObject(parent)
, mMinutes(minutes)
, mIndex(0)
, mEngine(engine)
, mIdentifiers(identifiers)
{
QTimer *timer = new QTimer( this );
timer->setInterval( minutes * 60 * 1000 );
connect( timer, &QTimer::timeout, this, &CheckNewStrips::start );
QTimer *timer = new QTimer(this);
timer->setInterval(minutes * 60 * 1000);
connect(timer, &QTimer::timeout, this, &CheckNewStrips::start);
timer->start();
//start at once, that way the user does not have to wait for minutes to get the initial result
// start at once, that way the user does not have to wait for minutes to get the initial result
start();
}
void CheckNewStrips::dataUpdated( const QString &source, const Plasma::DataEngine::Data &data )
void CheckNewStrips::dataUpdated(const QString &source, const Plasma::DataEngine::Data &data)
{
QString lastIdentifierSuffix;
if (!data[QStringLiteral("Error")].toBool()) {
lastIdentifierSuffix = data[QStringLiteral("Identifier")].toString();
lastIdentifierSuffix.remove( source );
lastIdentifierSuffix.remove(source);
}
mEngine->disconnectSource( source, this );
mEngine->disconnectSource(source, this);
if ( !lastIdentifierSuffix.isEmpty() ) {
if (!lastIdentifierSuffix.isEmpty()) {
QString temp = source;
temp.remove(QLatin1Char(':'));
emit lastStrip( mIndex, temp, lastIdentifierSuffix );
emit lastStrip(mIndex, temp, lastIdentifierSuffix);
}
++mIndex;
if ( mIndex < mIdentifiers.count() ) {
if (mIndex < mIdentifiers.count()) {
const QString newSource = mIdentifiers[mIndex] + QLatin1Char(':');
mEngine->connectSource( newSource, this );
mEngine->connectSource(newSource, this);
} else {
mIndex = 0;
}
......@@ -52,13 +52,13 @@ void CheckNewStrips::dataUpdated( const QString &source, const Plasma::DataEngin
void CheckNewStrips::start()
{
//already running, do nothing
if ( mIndex ) {
// already running, do nothing
if (mIndex) {
return;
}
if ( mIndex < mIdentifiers.count() ) {
if (mIndex < mIdentifiers.count()) {
const QString newSource = mIdentifiers[mIndex] + QLatin1Char(':');
mEngine->connectSource( newSource, this );
mEngine->connectSource(newSource, this);
}
}
......@@ -17,29 +17,29 @@ class CheckNewStrips : public QObject
{
Q_OBJECT
public:
CheckNewStrips( const QStringList &identifiers, Plasma::DataEngine *engine, int minutes, QObject *parent = nullptr );
Q_SIGNALS:
/**
* @param index of the identifier in identifiers
* @param identifier of the comic
* @param suffix of the last comic strip
* @see CheckNewStrips
*/
void lastStrip( int index, const QString &identifier, const QString &suffix );
public Q_SLOTS:
void dataUpdated( const QString &name, const Plasma::DataEngine::Data &data );
private Q_SLOTS:
void start();
private:
int mMinutes;
int mIndex;
Plasma::DataEngine *mEngine;
const QStringList mIdentifiers;
public:
CheckNewStrips(const QStringList &identifiers, Plasma::DataEngine *engine, int minutes, QObject *parent = nullptr);
Q_SIGNALS:
/**
* @param index of the identifier in identifiers
* @param identifier of the comic
* @param suffix of the last comic strip
* @see CheckNewStrips
*/
void lastStrip(int index, const QString &identifier, const QString &suffix);
public Q_SLOTS:
void dataUpdated(const QString &name, const Plasma::DataEngine::Data &data);
private Q_SLOTS:
void start();
private:
int mMinutes;
int mIndex;
Plasma::DataEngine *mEngine;
const QStringList mIdentifiers;
};
#endif
This diff is collapsed.
......@@ -16,9 +16,9 @@
#include <QDate>
#include <QUrl>
#include <Plasma/Applet>
#include <Plasma/DataEngine>
#include <Plasma/DataEngineConsumer>
#include <Plasma/Applet>
#include "activecomicmodel.h"
......@@ -51,54 +51,54 @@ class ComicApplet : public Plasma::Applet, public Plasma::DataEngineConsumer
Q_PROPERTY(int providerUpdateInterval READ providerUpdateInterval WRITE setProviderUpdateInterval NOTIFY providerUpdateIntervalChanged)
Q_PROPERTY(int maxComicLimit READ maxComicLimit WRITE setMaxComicLimit NOTIFY maxComicLimitChanged)
public:
ComicApplet( QObject *parent, const QVariantList &args );
~ComicApplet() override;
public:
ComicApplet(QObject *parent, const QVariantList &args);
~ComicApplet() override;
void init() override;
QList<QAction*> contextualActions() override;
void init() override;
QList<QAction *> contextualActions() override;
//For QML
QObject *comicsModel() const;
QObject *availableComicsModel() const;
QVariantMap comicData() const;
// For QML
QObject *comicsModel() const;
QObject *availableComicsModel() const;
QVariantMap comicData() const;
QStringList tabIdentifiers() const;
void setTabIdentifiers(const QStringList &tabs);
QStringList tabIdentifiers() const;
void setTabIdentifiers(const QStringList &tabs);
bool showComicUrl() const;
void setShowComicUrl(bool show);
bool showComicUrl() const;
void setShowComicUrl(bool show);
bool showComicAuthor() const;
void setShowComicAuthor(bool show);
bool showComicAuthor() const;
void setShowComicAuthor(bool show);
bool showComicTitle() const;
void setShowComicTitle(bool show);
bool showComicTitle() const;
void setShowComicTitle(bool show);
bool showComicIdentifier() const;
void setShowComicIdentifier(bool show);
bool showComicIdentifier() const;
void setShowComicIdentifier(bool show);
bool showErrorPicture() const;
void setShowErrorPicture(bool show);
bool showErrorPicture() const;
void setShowErrorPicture(bool show);
bool arrowsOnHover() const;
void setArrowsOnHover(bool show);
bool arrowsOnHover() const;
void setArrowsOnHover(bool show);
bool middleClick() const;
void setMiddleClick(bool show);
bool middleClick() const;
void setMiddleClick(bool show);
bool showActualSize() const;
void setShowActualSize(bool show);
bool showActualSize() const;
void setShowActualSize(bool show);
int checkNewComicStripsInterval() const;
void setCheckNewComicStripsInterval(int interval);
int checkNewComicStripsInterval() const;
void setCheckNewComicStripsInterval(int interval);
int providerUpdateInterval() const;
void setProviderUpdateInterval(int interval);
int providerUpdateInterval() const;
void setProviderUpdateInterval(int interval);
void setMaxComicLimit(int limit);
int maxComicLimit() const;
//End for QML
void setMaxComicLimit(int limit);
int maxComicLimit() const;
// End for QML
Q_SIGNALS:
void comicModelChanged();
......@@ -118,90 +118,103 @@ Q_SIGNALS:
void providerUpdateIntervalChanged();
void maxComicLimitChanged();
public Q_SLOTS:
void dataUpdated( const QString &name, const Plasma::DataEngine::Data &data );
private Q_SLOTS:
void slotTabChanged( const QString &newIdentifier );
void slotNextDay();
void slotPreviousDay();
void slotFirstDay();
void slotCurrentDay();
void slotFoundLastStrip( int index, const QString &identifier, const QString &suffix );
void slotGoJump();
void slotSaveComicAs();
void slotScaleToContent();
void slotShop();
void slotStorePosition();
void checkDayChanged();
void createComicBook();
void slotArchive( int archiveType, const QUrl &dest, const QString &fromIdentifier, const QString &toIdentifier );
void slotArchiveFinished( KJob *job );
public Q_SLOTS:
void configChanged() override;
void saveConfig();
Q_INVOKABLE void updateComic(const QString &identifierSuffix = QString());
Q_INVOKABLE void goJump() { slotGoJump();}
Q_INVOKABLE void shop() { slotShop();}
Q_INVOKABLE void tabChanged(const QString &newIdentifier) { slotTabChanged(newIdentifier);}
Q_INVOKABLE void loadProviders();
Q_INVOKABLE void positionFullView(QWindow *window);
private:
void changeComic( bool differentComic );
void updateUsedComics();
void updateContextMenu();
void updateView();
void refreshComicData();
void setTabHighlighted(const QString &id, bool highlight);
bool isTabHighlighted(const QString &id) const;
private:
static const int CACHE_LIMIT;
ComicModel *mModel;
QSortFilterProxyModel *mProxy;
ActiveComicModel *mActiveComicModel;
QVariantMap mComicData;
QDate mCurrentDay;
QString mIdentifierError;
QString mOldSource;
ConfigWidget *mConfigWidget;
bool mDifferentComic;
bool mShowComicUrl;
bool mShowComicAuthor;
bool mShowComicTitle;
bool mShowComicIdentifier;
bool mShowErrorPicture;
bool mArrowsOnHover;
bool mMiddleClick;
int mCheckNewComicStripsInterval;
int mMaxComicLimit;
CheckNewStrips *mCheckNewStrips;
QTimer *mDateChangedTimer;
QList<QAction*> mActions;
QAction *mActionGoFirst;
QAction *mActionGoLast;
QAction *mActionGoJump;
QAction *mActionScaleContent;
QAction *mActionShop;
QAction *mActionStorePosition;
QAction *mActionNextNewStripTab;
QAction *mActionSaveComicAs;
QAction *mActionCreateComicBook;
QSizeF mMaxSize;
QSizeF mLastSize;
QSizeF mIdealSize;
Plasma::DataEngine *mEngine;
//Tabs
bool mTabAdded;
QStringList mTabIdentifier;
ComicData mCurrent;
SavingDir *mSavingDir;
public Q_SLOTS:
void dataUpdated(const QString &name, const Plasma::DataEngine::Data &data);
private Q_SLOTS:
void slotTabChanged(const QString &newIdentifier);
void slotNextDay();
void slotPreviousDay();
void slotFirstDay();
void slotCurrentDay();
void slotFoundLastStrip(int index, const QString &identifier, const QString &suffix);
void slotGoJump();
void slotSaveComicAs();
void slotScaleToContent();
void slotShop();
void slotStorePosition();
void checkDayChanged();
void createComicBook();
void slotArchive(int archiveType, const QUrl &dest, const QString &fromIdentifier, const QString &toIdentifier);
void slotArchiveFinished(KJob *job);
public Q_SLOTS:
void configChanged() override;
void saveConfig();
Q_INVOKABLE void updateComic(const QString &identifierSuffix = QString());
Q_INVOKABLE void goJump()
{
slotGoJump();
}
Q_INVOKABLE void shop()
{
slotShop();
}
Q_INVOKABLE void tabChanged(const QString &newIdentifier)
{
slotTabChanged(newIdentifier);
}
Q_INVOKABLE void loadProviders();
Q_INVOKABLE void positionFullView(QWindow *window);
private:
void changeComic(bool differentComic);
void updateUsedComics();
void updateContextMenu();
void updateView();
void refreshComicData();
void setTabHighlighted(const QString &id, bool highlight);
bool isTabHighlighted(const QString &id) const;
private:
static const int CACHE_LIMIT;
ComicModel *mModel;
QSortFilterProxyModel *mProxy;
ActiveComicModel *mActiveComicModel;
QVariantMap mComicData;
QDate mCurrentDay;
QString mIdentifierError;
QString mOldSource;
ConfigWidget *mConfigWidget;
bool mDifferentComic;
bool mShowComicUrl;
bool mShowComicAuthor;
bool mShowComicTitle;
bool mShowComicIdentifier;
bool mShowErrorPicture;
bool mArrowsOnHover;
bool mMiddleClick;
int mCheckNewComicStripsInterval;
int mMaxComicLimit;
CheckNewStrips *mCheckNewStrips;
QTimer *mDateChangedTimer;
QList<QAction *> mActions;
QAction *mActionGoFirst;
QAction *mActionGoLast;
QAction *mActionGoJump;
QAction *mActionScaleContent;
QAction *mActionShop;
QAction *mActionStorePosition;
QAction *mActionNextNewStripTab;
QAction *mActionSaveComicAs;
QAction *mActionCreateComicBook;
QSizeF mMaxSize;
QSizeF mLastSize;
QSizeF mIdealSize;
Plasma::DataEngine *mEngine;
// Tabs
bool mTabAdded;
QStringList mTabIdentifier;
ComicData mCurrent;
SavingDir *mSavingDir;