Skip to content

Commit

Permalink
[gtk,kde] Convert some static classes to namespaces.
Browse files Browse the repository at this point in the history
[gtk] Converted MessageSound.

[gtk3] Converted CairoImageConv.

[kde] Converted MessageSound.

No code size changes, but static classes are annoying.
  • Loading branch information
GerbilSoft committed Nov 1, 2023
1 parent f9d95ed commit e159940
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 54 deletions.
6 changes: 5 additions & 1 deletion src/gtk/MessageSound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
# error Neither GSound nor LibCanberra GTK are available
#endif

namespace MessageSound {

#ifdef HAVE_GSOUND
/**
* GSound playback callback.
Expand All @@ -47,7 +49,7 @@ static void _gsound_play_callback(GObject *source_object, GAsyncResult *res, gpo
* @param message Message for logging.
* @param parent Parent window.
*/
void MessageSound::play(GtkMessageType notificationType, const char *message, GtkWidget *parent)
void play(GtkMessageType notificationType, const char *message, GtkWidget *parent)
{
// Check if event sounds are enabled.
GtkSettings *const settings = gtk_settings_get_default();
Expand Down Expand Up @@ -138,3 +140,5 @@ void MessageSound::play(GtkMessageType notificationType, const char *message, Gt
}
#endif
}

} //namespace MessageSound
27 changes: 10 additions & 17 deletions src/gtk/MessageSound.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,14 @@
#include <gtk/gtk.h>
#include "common.h"

class MessageSound
{
public:
// Static class
MessageSound() = delete;
~MessageSound() = delete;
private:
RP_DISABLE_COPY(MessageSound);
namespace MessageSound {

public:
/**
* Play a message sound effect.
* @param notificationType Notification type.
* @param message Message for logging.
* @param parent Parent window.
*/
static void play(GtkMessageType notificationType, const char *message = nullptr, GtkWidget *parent = nullptr);
};
/**
* Play a message sound effect.
* @param notificationType Notification type.
* @param message Message for logging.
* @param parent Parent window.
*/
void play(GtkMessageType notificationType, const char *message = nullptr, GtkWidget *parent = nullptr);

} //namespace MessageSound
6 changes: 5 additions & 1 deletion src/gtk/gtk3/CairoImageConv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ using std::array;
#include "librptexture/ImageSizeCalc.hpp"
using namespace LibRpTexture;

namespace CairoImageConv {

/**
* Convert an rp_image to cairo_surface_t.
* @param img [in] rp_image.
* @param premultiply [in] If true, premultiply. Needed for display; NOT needed for PNG.
* @return GdkPixbuf, or nullptr on error.
*/
cairo_surface_t *CairoImageConv::rp_image_to_cairo_surface_t(const rp_image *img, bool premultiply)
cairo_surface_t *rp_image_to_cairo_surface_t(const rp_image *img, bool premultiply)
{
assert(img != nullptr);
if (unlikely(!img || !img->isValid()))
Expand Down Expand Up @@ -158,3 +160,5 @@ cairo_surface_t *CairoImageConv::rp_image_to_cairo_surface_t(const rp_image *img

return surface;
}

} //namespace CairoImageConv
27 changes: 10 additions & 17 deletions src/gtk/gtk3/CairoImageConv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,14 @@ namespace LibRpTexture {
}
#include <cairo.h>

class CairoImageConv
{
public:
// Static class
CairoImageConv() = delete;
~CairoImageConv() = delete;
private:
RP_DISABLE_COPY(CairoImageConv)
namespace CairoImageConv {

public:
/**
* Convert an rp_image to cairo_surface_t.
* @param img [in] rp_image.
* @param premultiply [in] If true, premultiply. Needed for display; NOT needed for PNG.
* @return cairo_surface_t, or nullptr on error.
*/
static cairo_surface_t *rp_image_to_cairo_surface_t(const LibRpTexture::rp_image *img, bool premultiply = true);
};
/**
* Convert an rp_image to cairo_surface_t.
* @param img [in] rp_image.
* @param premultiply [in] If true, premultiply. Needed for display; NOT needed for PNG.
* @return cairo_surface_t, or nullptr on error.
*/
cairo_surface_t *rp_image_to_cairo_surface_t(const LibRpTexture::rp_image *img, bool premultiply = true);

} //namespace CairoImageConv
6 changes: 5 additions & 1 deletion src/kde/MessageSound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@
# include <knotification.h>
#endif

namespace MessageSound {

/**
* Play a message sound effect.
* @param notificationType Notification type.
* @param message Message for logging.
* @param parent Parent window.
*/
void MessageSound::play(QMessageBox::Icon notificationType, const QString &message, QWidget *parent)
void play(QMessageBox::Icon notificationType, const QString &message, QWidget *parent)
{
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
QPluginLoader lib(QStringLiteral("kf5/FrameworkIntegrationPlugin"));
Expand Down Expand Up @@ -58,3 +60,5 @@ void MessageSound::play(QMessageBox::Icon notificationType, const QString &messa
KNotification::event(messageType, message, QPixmap(), parent);
#endif
}

} //namespace MessageSound
27 changes: 10 additions & 17 deletions src/kde/MessageSound.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,14 @@

#include <QMessageBox>

class MessageSound
{
public:
// Static class
MessageSound() = delete;
~MessageSound() = delete;
private:
Q_DISABLE_COPY(MessageSound);
namespace MessageSound {

public:
/**
* Play a message sound effect.
* @param notificationType Notification type.
* @param message Message for logging.
* @param parent Parent window.
*/
static void play(QMessageBox::Icon notificationType, const QString &message = QString(), QWidget *parent = nullptr);
};
/**
* Play a message sound effect.
* @param notificationType Notification type.
* @param message Message for logging.
* @param parent Parent window.
*/
void play(QMessageBox::Icon notificationType, const QString &message = QString(), QWidget *parent = nullptr);

} //namespace MessageSound

0 comments on commit e159940

Please sign in to comment.