Commit 1da83f1e authored by Kurt Hindenburg's avatar Kurt Hindenburg

uncrustify using kf5 config

parent de68973d
This diff is collapsed.
......@@ -33,8 +33,7 @@ class KConfig;
class QPixmap;
class QPainter;
namespace Konsole
{
namespace Konsole {
/**
* This class holds the wallpaper pixmap associated with a color scheme.
* The wallpaper object is shared between multiple TerminalDisplay.
......@@ -44,13 +43,13 @@ class ColorSchemeWallpaper : public QSharedData
public:
typedef QExplicitlySharedDataPointer<ColorSchemeWallpaper> Ptr;
explicit ColorSchemeWallpaper(const QString& path);
explicit ColorSchemeWallpaper(const QString &path);
~ColorSchemeWallpaper();
void load();
/** Returns true if wallpaper available and drawn */
bool draw(QPainter& painter, const QRect& rect, qreal opacity=1.0);
bool draw(QPainter &painter, const QRect &rect, qreal opacity = 1.0);
bool isNull() const;
......@@ -58,7 +57,7 @@ public:
private:
QString _path;
QPixmap* _picture;
QPixmap *_picture;
};
/**
......@@ -75,26 +74,26 @@ public:
* for Konsole.
*/
ColorScheme();
ColorScheme(const ColorScheme& other);
ColorScheme(const ColorScheme &other);
~ColorScheme();
/** Sets the descriptive name of the color scheme. */
void setDescription(const QString& description);
void setDescription(const QString &description);
/** Returns the descriptive name of the color scheme. */
QString description() const;
/** Sets the name of the color scheme */
void setName(const QString& name);
void setName(const QString &name);
/** Returns the name of the color scheme */
QString name() const;
/** Reads the color scheme from the specified configuration source */
void read(const KConfig& config);
void read(const KConfig &config);
/** Writes the color scheme to the specified configuration source */
void write(KConfig& config) const;
void write(KConfig &config) const;
/** Sets a single entry within the color palette. */
void setColorTableEntry(int index , const ColorEntry& entry);
void setColorTableEntry(int index, const ColorEntry &entry);
/**
* Copies the color entries which form the palette for this color scheme
......@@ -105,14 +104,14 @@ public:
* @param randomSeed Color schemes may allow certain colors in their
* palette to be randomized. The seed is used to pick the random color.
*/
void getColorTable(ColorEntry* table, uint randomSeed = 0) const;
void getColorTable(ColorEntry *table, uint randomSeed = 0) const;
/**
* Retrieves a single color entry from the table.
*
* See getColorTable()
*/
ColorEntry colorEntry(int index , uint randomSeed = 0) const;
ColorEntry colorEntry(int index, uint randomSeed = 0) const;
/**
* Convenience method. Returns the
......@@ -151,7 +150,7 @@ public:
*/
qreal opacity() const;
void setWallpaper(const QString& path);
void setWallpaper(const QString &path);
ColorSchemeWallpaper::Ptr wallpaper() const;
......@@ -176,42 +175,47 @@ private:
class RandomizationRange
{
public:
RandomizationRange() : hue(0) , saturation(0) , value(0) {}
RandomizationRange() : hue(0),
saturation(0),
value(0)
{
}
bool isNull() const {
return (hue == 0 && saturation == 0 && value == 0);
bool isNull() const
{
return hue == 0 && saturation == 0 && value == 0;
}
quint16 hue;
quint8 saturation;
quint8 value;
quint8 saturation;
quint8 value;
};
// returns the active color table. if none has been set specifically,
// this is the default color table.
const ColorEntry* colorTable() const;
const ColorEntry *colorTable() const;
// reads a single color entry from a KConfig source
// and sets the palette entry at 'index' to the entry read.
void readColorEntry(const KConfig& config , int index);
void readColorEntry(const KConfig &config, int index);
// writes a single color entry to a KConfig source
void writeColorEntry(KConfig& config , int index) const;
void writeColorEntry(KConfig &config, int index) const;
// sets the amount of randomization allowed for a particular color
// in the palette. creates the randomization table if
// it does not already exist
void setRandomizationRange(int index , quint16 hue , quint8 saturation , quint8 value);
void setRandomizationRange(int index, quint16 hue, quint8 saturation, quint8 value);
QString _description;
QString _name;
// pointer to custom color table, or 0 if the default color table is
// being used
ColorEntry* _table;
ColorEntry *_table;
// pointer to randomization table, or 0 if no colors in the color
// scheme support randomization
RandomizationRange* _randomTable;
RandomizationRange *_randomTable;
qreal _opacity;
......@@ -219,11 +223,11 @@ private:
static const quint16 MAX_HUE = 340;
static const char* const colorNames[TABLE_COLORS];
static const char* const translatedColorNames[TABLE_COLORS];
static const char * const colorNames[TABLE_COLORS];
static const char * const translatedColorNames[TABLE_COLORS];
};
}
Q_DECLARE_METATYPE(const Konsole::ColorScheme*)
Q_DECLARE_METATYPE(const Konsole::ColorScheme *)
#endif //COLORSCHEME_H
This diff is collapsed.
......@@ -31,13 +31,11 @@
class QTableWidgetItem;
namespace Ui
{
namespace Ui {
class ColorSchemeEditor;
}
namespace Konsole
{
namespace Konsole {
class ColorScheme;
/**
......@@ -58,40 +56,40 @@ class KONSOLEPRIVATE_EXPORT ColorSchemeEditor : public QDialog
public:
/** Constructs a new color scheme editor with the specified parent. */
explicit ColorSchemeEditor(QWidget* parent = 0);
explicit ColorSchemeEditor(QWidget *parent = 0);
~ColorSchemeEditor() Q_DECL_OVERRIDE;
/** Initializes the dialog with the properties of the specified color scheme. */
void setup(const ColorScheme* scheme, bool isNewScheme);
void setup(const ColorScheme *scheme, bool isNewScheme);
/** Returns the modified color scheme. */
ColorScheme& colorScheme() const;
ColorScheme &colorScheme() const;
bool isNewScheme() const;
Q_SIGNALS:
/** Emitted when the colors in the color scheme change. */
void colorsChanged(ColorScheme* scheme);
void colorsChanged(ColorScheme *scheme);
/** Used to send back colorscheme changes into the profile edited */
void colorSchemeSaveRequested(const ColorScheme& scheme,bool isNewScheme);
void colorSchemeSaveRequested(const ColorScheme &scheme, bool isNewScheme);
public Q_SLOTS:
/** Sets the text displayed in the description edit field. */
void setDescription(const QString& description);
void setDescription(const QString &description);
private Q_SLOTS:
void setTransparencyPercentLabel(int percent);
void setRandomizedBackgroundColor(bool randomized);
void editColorItem(QTableWidgetItem* item);
void wallpaperPathChanged(const QString& path);
void editColorItem(QTableWidgetItem *item);
void wallpaperPathChanged(const QString &path);
void selectWallpaper();
/** Triggered by apply/ok buttons */
void saveColorScheme();
private:
void setupColorTable(const ColorScheme* table);
void setupColorTable(const ColorScheme *table);
bool _isNewScheme;
Ui::ColorSchemeEditor* _ui;
ColorScheme* _colors;
Ui::ColorSchemeEditor *_ui;
ColorScheme *_colors;
};
}
......
......@@ -35,9 +35,9 @@
using namespace Konsole;
ColorSchemeManager::ColorSchemeManager()
: _colorSchemes(QHash<QString, const ColorScheme*>())
, _haveLoadedAll(false)
ColorSchemeManager::ColorSchemeManager() :
_colorSchemes(QHash<QString, const ColorScheme *>()),
_haveLoadedAll(false)
{
}
......@@ -59,20 +59,22 @@ void ColorSchemeManager::loadAllColorSchemes()
int failed = 0;
QStringList nativeColorSchemes = listColorSchemes();
foreach(const QString& colorScheme, nativeColorSchemes) {
if (loadColorScheme(colorScheme))
foreach (const QString &colorScheme, nativeColorSchemes) {
if (loadColorScheme(colorScheme)) {
success++;
else
} else {
failed++;
}
}
if (failed > 0)
if (failed > 0) {
qCDebug(KonsoleDebug) << "failed to load " << failed << " color schemes.";
}
_haveLoadedAll = true;
}
QList<const ColorScheme*> ColorSchemeManager::allColorSchemes()
QList<const ColorScheme *> ColorSchemeManager::allColorSchemes()
{
if (!_haveLoadedAll) {
loadAllColorSchemes();
......@@ -81,20 +83,22 @@ QList<const ColorScheme*> ColorSchemeManager::allColorSchemes()
return _colorSchemes.values();
}
bool ColorSchemeManager::loadColorScheme(const QString& filePath)
bool ColorSchemeManager::loadColorScheme(const QString &filePath)
{
if (!filePath.endsWith(QLatin1String(".colorscheme")) || !QFile::exists(filePath))
if (!filePath.endsWith(QLatin1String(".colorscheme")) || !QFile::exists(filePath)) {
return false;
}
QFileInfo info(filePath);
KConfig config(filePath , KConfig::NoGlobals);
KConfig config(filePath, KConfig::NoGlobals);
auto scheme = new ColorScheme();
scheme->setName(info.baseName());
scheme->read(config);
if (scheme->name().isEmpty()) {
qCDebug(KonsoleDebug) << "Color scheme in" << filePath << "does not have a valid name and was not loaded.";
qCDebug(KonsoleDebug) << "Color scheme in" << filePath
<< "does not have a valid name and was not loaded.";
delete scheme;
return false;
}
......@@ -114,26 +118,26 @@ bool ColorSchemeManager::loadColorScheme(const QString& filePath)
QStringList ColorSchemeManager::listColorSchemes()
{
QStringList colorschemes;
const QStringList dirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("konsole"), QStandardPaths::LocateDirectory);
const QStringList dirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("konsole"),
QStandardPaths::LocateDirectory);
colorschemes.reserve(dirs.size());
Q_FOREACH (const QString& dir, dirs) {
Q_FOREACH (const QString &dir, dirs) {
const QStringList fileNames = QDir(dir).entryList(QStringList() << QStringLiteral("*.colorscheme"));
Q_FOREACH (const QString& file, fileNames) {
Q_FOREACH (const QString &file, fileNames) {
colorschemes.append(dir + QLatin1Char('/') + file);
}
}
return colorschemes;
}
const ColorScheme ColorSchemeManager::_defaultColorScheme;
const ColorScheme* ColorSchemeManager::defaultColorScheme() const
const ColorScheme *ColorSchemeManager::defaultColorScheme() const
{
return &_defaultColorScheme;
}
void ColorSchemeManager::addColorScheme(ColorScheme* scheme)
void ColorSchemeManager::addColorScheme(ColorScheme *scheme)
{
// remove existing colorscheme with the same name
if (_colorSchemes.contains(scheme->name())) {
......@@ -145,15 +149,16 @@ void ColorSchemeManager::addColorScheme(ColorScheme* scheme)
// save changes to disk
const QString dir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + QStringLiteral("/konsole/");
const QString dir = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)
+ QStringLiteral("/konsole/");
QDir().mkpath(dir);
const QString path = dir + scheme->name() + QStringLiteral(".colorscheme");
KConfig config(path , KConfig::NoGlobals);
KConfig config(path, KConfig::NoGlobals);
scheme->write(config);
}
bool ColorSchemeManager::deleteColorScheme(const QString& name)
bool ColorSchemeManager::deleteColorScheme(const QString &name)
{
Q_ASSERT(_colorSchemes.contains(name));
......@@ -169,10 +174,11 @@ bool ColorSchemeManager::deleteColorScheme(const QString& name)
}
}
const ColorScheme* ColorSchemeManager::findColorScheme(const QString& name)
const ColorScheme *ColorSchemeManager::findColorScheme(const QString &name)
{
if (name.isEmpty())
if (name.isEmpty()) {
return defaultColorScheme();
}
// A fix to prevent infinite loops if users puts / in ColorScheme name
// Konsole will create a sub-folder in that case (bko 315086)
......@@ -197,7 +203,7 @@ const ColorScheme* ColorSchemeManager::findColorScheme(const QString& name)
}
}
QString ColorSchemeManager::findColorSchemePath(const QString& name) const
QString ColorSchemeManager::findColorSchemePath(const QString &name) const
{
QString path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("konsole/") + name + QStringLiteral(".colorscheme"));
......@@ -207,4 +213,3 @@ QString ColorSchemeManager::findColorSchemePath(const QString& name) const
return QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("konsole/") + name + QStringLiteral(".schema"));
}
......@@ -29,8 +29,7 @@
// Konsole
#include "ColorScheme.h"
namespace Konsole
{
namespace Konsole {
/**
* Manages the color schemes available for use by terminal displays.
* See ColorScheme
......@@ -54,7 +53,7 @@ public:
/**
* Returns the default color scheme for Konsole
*/
const ColorScheme* defaultColorScheme() const;
const ColorScheme *defaultColorScheme() const;
/**
* Returns the color scheme with the given name or 0 if no
......@@ -64,18 +63,18 @@ public:
* The first time that a color scheme with a particular name is
* requested, the configuration information is loaded from disk.
*/
const ColorScheme* findColorScheme(const QString& name);
const ColorScheme *findColorScheme(const QString &name);
/**
* Adds a new color scheme to the manager. If @p scheme has the same name as
* an existing color scheme, it replaces the existing scheme.
*/
void addColorScheme(ColorScheme* scheme);
void addColorScheme(ColorScheme *scheme);
/**
* Deletes a color scheme. Returns true on successful deletion or false otherwise.
*/
bool deleteColorScheme(const QString& name);
bool deleteColorScheme(const QString &name);
/**
* Returns a list of the all the available color schemes.
......@@ -84,22 +83,22 @@ public:
*
* Subsequent calls will be inexpensive.
*/
QList<const ColorScheme*> allColorSchemes();
QList<const ColorScheme *> allColorSchemes();
/** Returns the global color scheme manager instance. */
static ColorSchemeManager* instance();
static ColorSchemeManager *instance();
private:
// loads a color scheme from a KDE 4+ .colorscheme file
bool loadColorScheme(const QString& path);
bool loadColorScheme(const QString &path);
// returns a list of paths of color schemes in the KDE 4+ .colorscheme file format
QStringList listColorSchemes();
// loads all of the color schemes
void loadAllColorSchemes();
// finds the path of a color scheme
QString findColorSchemePath(const QString& name) const;
QString findColorSchemePath(const QString &name) const;
QHash<QString, const ColorScheme*> _colorSchemes;
QHash<QString, const ColorScheme *> _colorSchemes;
bool _haveLoadedAll;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment