1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Merge pull request #3162

Diadlo (4):
      refactor(chatmessage): Delete duplicate enum MarkdownType
      refactor(videoframe, camerasource, corevideosource): Change calls deprecated functions
      fix(main): Added check sodium_init result
      refactor(systemtrayicon, genericchatform): Replace C-style cast to static_cast

Polshakov Dmitry (5):
      perf(camerasource): Passed parameter by reference
      fix(genericchatitemwidget, micfeedbackwidget): Added members init in the constructor
      style(ipc, widgets, genericcharitemlayout): Small style changes
      perf(contentdialog): Delete redundant conditions
      style(constructors): Constructors are explicit now
This commit is contained in:
sudden6 2016-04-20 22:26:53 +02:00
commit edc35ba9df
No known key found for this signature in database
GPG Key ID: 279509B499E032B9
42 changed files with 95 additions and 82 deletions

View File

@ -57,7 +57,7 @@ ChatMessage::Ptr ChatMessage::createChatMessage(const QString &sender, const QSt
text = detectQuotes(detectAnchors(text), type); text = detectQuotes(detectAnchors(text), type);
//markdown //markdown
if (Settings::getInstance().getMarkdownPreference() != MarkdownType::NONE) if (Settings::getInstance().getMarkdownPreference() != NONE)
text = detectMarkdown(text); text = detectMarkdown(text);
switch(type) switch(type)
@ -209,7 +209,7 @@ QString ChatMessage::detectMarkdown(const QString &str)
{ {
int mul = 0; // Determines how many characters to strip from markdown text int mul = 0; // Determines how many characters to strip from markdown text
// Set mul depending on markdownPreference // Set mul depending on markdownPreference
if (Settings::getInstance().getMarkdownPreference() == MarkdownType::WITHOUT_CHARS) if (Settings::getInstance().getMarkdownPreference() == WITHOUT_CHARS)
mul = 2; mul = 2;
// Match captured string to corresponding md format // Match captured string to corresponding md format

View File

@ -45,13 +45,6 @@ public:
ALERT, ALERT,
}; };
enum MarkdownType
{
NONE,
WITH_CHARS,
WITHOUT_CHARS,
};
ChatMessage(); ChatMessage();
static ChatMessage::Ptr createChatMessage(const QString& sender, const QString& rawMessage, MessageType type, bool isMe, const QDateTime& date = QDateTime()); static ChatMessage::Ptr createChatMessage(const QString& sender, const QString& rawMessage, MessageType type, bool isMe, const QDateTime& date = QDateTime());

View File

@ -31,7 +31,7 @@ class NotificationIcon : public QObject, public ChatLineContent
{ {
Q_OBJECT Q_OBJECT
public: public:
NotificationIcon(QSize size); explicit NotificationIcon(QSize size);
virtual QRectF boundingRect() const override; virtual QRectF boundingRect() const override;
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override; virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;

View File

@ -45,7 +45,7 @@ class CoreAV : public QObject
Q_OBJECT Q_OBJECT
public: public:
CoreAV(Tox* tox); explicit CoreAV(Tox* tox);
~CoreAV(); ~CoreAV();
const ToxAV* getToxAv() const; const ToxAV* getToxAv() const;

View File

@ -18,7 +18,7 @@ struct ToxCall
{ {
protected: protected:
ToxCall() = default; ToxCall() = default;
ToxCall(uint32_t CallId); explicit ToxCall(uint32_t CallId);
~ToxCall(); ~ToxCall();
public: public:
ToxCall(const ToxCall& other) = delete; ToxCall(const ToxCall& other) = delete;

View File

@ -281,8 +281,10 @@ void IPC::processEvents()
evt->processed = time(0); evt->processed = time(0);
} }
else else
{
evt->processed = time(0); evt->processed = time(0);
} }
}
} }
@ -293,5 +295,5 @@ void IPC::processEvents()
IPC::IPCMemory *IPC::global() IPC::IPCMemory *IPC::global()
{ {
return (IPCMemory*)globalMemory.data(); return static_cast<IPCMemory*>(globalMemory.data());
} }

View File

@ -150,7 +150,11 @@ int main(int argc, char *argv[])
IPC& ipc = IPC::getInstance(); IPC& ipc = IPC::getInstance();
#endif #endif
sodium_init(); // For the auto-updater if (sodium_init() < 0) // For the auto-updater
{
qCritical() << "Can't init libsodium";
return EXIT_FAILURE;
}
#ifdef LOG_TO_FILE #ifdef LOG_TO_FILE
QString logFileDir = Settings::getInstance().getAppCacheDirPath(); QString logFileDir = Settings::getInstance().getAppCacheDirPath();

View File

@ -69,7 +69,7 @@ public:
QList<HistMessage> exportMessages(); QList<HistMessage> exportMessages();
private: private:
HistoryKeeper(GenericDdInterface *db_); explicit HistoryKeeper(GenericDdInterface *db_);
HistoryKeeper(HistoryKeeper &hk) = delete; HistoryKeeper(HistoryKeeper &hk) = delete;
HistoryKeeper& operator=(const HistoryKeeper&) = delete; HistoryKeeper& operator=(const HistoryKeeper&) = delete;
QString unWrapMessage(const QString &str); QString unWrapMessage(const QString &str);

View File

@ -34,7 +34,7 @@ class OfflineMsgEngine : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
OfflineMsgEngine(Friend *); explicit OfflineMsgEngine(Friend *);
virtual ~OfflineMsgEngine(); virtual ~OfflineMsgEngine();
static QMutex globalMutex; static QMutex globalMutex;

View File

@ -65,12 +65,12 @@ void CameraSource::open()
open(CameraDevice::getDefaultDeviceName()); open(CameraDevice::getDefaultDeviceName());
} }
void CameraSource::open(const QString deviceName) void CameraSource::open(const QString& deviceName)
{ {
open(deviceName, VideoMode{0,0,0,0}); open(deviceName, VideoMode{0,0,0,0});
} }
void CameraSource::open(const QString DeviceName, VideoMode Mode) void CameraSource::open(const QString& DeviceName, VideoMode Mode)
{ {
streamBlocker = true; streamBlocker = true;
QMutexLocker l{&biglock}; QMutexLocker l{&biglock};
@ -337,7 +337,7 @@ void CameraSource::stream()
} }
// Free the packet that was allocated by av_read_frame // Free the packet that was allocated by av_read_frame
av_free_packet(&packet); av_packet_unref(&packet);
}; };
forever { forever {

View File

@ -52,8 +52,8 @@ public:
/// Opens the source for the camera device in argument, in the settings, or the system default /// Opens the source for the camera device in argument, in the settings, or the system default
/// If a device is already open, the source will seamlessly switch to the new device /// If a device is already open, the source will seamlessly switch to the new device
void open(); void open();
void open(const QString deviceName); void open(const QString& deviceName);
void open(const QString deviceName, VideoMode mode); void open(const QString& deviceName, VideoMode mode);
void close(); ///< Equivalent to opening the source with the video device "none". Stops streaming. void close(); ///< Equivalent to opening the source with the video device "none". Stops streaming.
bool isOpen(); bool isOpen();

View File

@ -20,6 +20,7 @@
extern "C" { extern "C" {
#include <libavcodec/avcodec.h> #include <libavcodec/avcodec.h>
#include <libavutil/imgutils.h>
} }
#include "corevideosource.h" #include "corevideosource.h"
#include "videoframe.h" #include "videoframe.h"
@ -53,7 +54,8 @@ void CoreVideoSource::pushFrame(const vpx_image_t* vpxframe)
avframe->height = height; avframe->height = height;
avframe->format = AV_PIX_FMT_YUV420P; avframe->format = AV_PIX_FMT_YUV420P;
buf = (uint8_t*)av_malloc(avpicture_get_size(AV_PIX_FMT_YUV420P, width, height)); int imgBufferSize = av_image_get_buffer_size(AV_PIX_FMT_YUV420P, width, height, 1);
buf = (uint8_t*)av_malloc(imgBufferSize);
if (!buf) if (!buf)
{ {
av_frame_free(&avframe); av_frame_free(&avframe);
@ -61,7 +63,9 @@ void CoreVideoSource::pushFrame(const vpx_image_t* vpxframe)
} }
avframe->opaque = buf; avframe->opaque = buf;
avpicture_fill((AVPicture*)avframe, buf, AV_PIX_FMT_YUV420P, width, height); uint8_t** data = avframe->data;
int* linesize = avframe->linesize;
av_image_fill_arrays(data, linesize, buf, AV_PIX_FMT_YUV420P, width, height, 1);
dstStride=avframe->linesize[0], srcStride=vpxframe->stride[0], minStride=std::min(dstStride, srcStride); dstStride=avframe->linesize[0], srcStride=vpxframe->stride[0], minStride=std::min(dstStride, srcStride);
for (int i=0; i<height; i++) for (int i=0; i<height; i++)

View File

@ -30,7 +30,7 @@ class GenericNetCamView : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
GenericNetCamView(QWidget* parent); explicit GenericNetCamView(QWidget* parent);
signals: signals:
void showMessageClicked(); void showMessageClicked();

View File

@ -24,6 +24,7 @@
#include <vpx/vpx_image.h> #include <vpx/vpx_image.h>
extern "C" { extern "C" {
#include <libavcodec/avcodec.h> #include <libavcodec/avcodec.h>
#include <libavutil/imgutils.h>
#include <libswscale/swscale.h> #include <libswscale/swscale.h>
} }
#include "videoframe.h" #include "videoframe.h"
@ -154,7 +155,8 @@ bool VideoFrame::convertToRGB24(QSize size)
return false; return false;
} }
uint8_t* buf = (uint8_t*)av_malloc(avpicture_get_size(AV_PIX_FMT_RGB24, size.width(), size.height())); int imgBufferSize = av_image_get_buffer_size(AV_PIX_FMT_RGB24, size.width(), size.height(), 1);
uint8_t* buf = (uint8_t*)av_malloc(imgBufferSize);
if (!buf) if (!buf)
{ {
qCritical() << "av_malloc failed"; qCritical() << "av_malloc failed";
@ -163,7 +165,9 @@ bool VideoFrame::convertToRGB24(QSize size)
} }
frameRGB24->opaque = buf; frameRGB24->opaque = buf;
avpicture_fill((AVPicture*)frameRGB24, buf, AV_PIX_FMT_RGB24, size.width(), size.height()); uint8_t** data = frameRGB24->data;
int* linesize = frameRGB24->linesize;
av_image_fill_arrays(data, linesize, buf, AV_PIX_FMT_RGB24, size.width(), size.height(), 1);
frameRGB24->width = size.width(); frameRGB24->width = size.width();
frameRGB24->height = size.height(); frameRGB24->height = size.height();
@ -211,7 +215,8 @@ bool VideoFrame::convertToYUV420()
return false; return false;
} }
uint8_t* buf = (uint8_t*)av_malloc(avpicture_get_size(AV_PIX_FMT_RGB24, width, height)); int imgBufferSize = av_image_get_buffer_size(AV_PIX_FMT_RGB24, width, height, 1);
uint8_t* buf = (uint8_t*)av_malloc(imgBufferSize);
if (!buf) if (!buf)
{ {
qCritical() << "av_malloc failed"; qCritical() << "av_malloc failed";
@ -220,7 +225,9 @@ bool VideoFrame::convertToYUV420()
} }
frameYUV420->opaque = buf; frameYUV420->opaque = buf;
avpicture_fill((AVPicture*)frameYUV420, buf, AV_PIX_FMT_YUV420P, width, height); uint8_t** data = frameYUV420->data;
int* linesize = frameYUV420->linesize;
av_image_fill_arrays(data, linesize, buf, AV_PIX_FMT_YUV420P, width, height, 1);
SwsContext *swsCtx = sws_getContext(width, height, (AVPixelFormat)pixFmt, SwsContext *swsCtx = sws_getContext(width, height, (AVPixelFormat)pixFmt,
width, height, AV_PIX_FMT_YUV420P, width, height, AV_PIX_FMT_YUV420P,

View File

@ -37,7 +37,7 @@ struct vpx_image;
class VideoFrame class VideoFrame
{ {
public: public:
VideoFrame(AVFrame* frame); explicit VideoFrame(AVFrame* frame);
VideoFrame(AVFrame* frame, std::function<void()> freelistCallback); VideoFrame(AVFrame* frame, std::function<void()> freelistCallback);
VideoFrame(AVFrame* frame, int w, int h, int fmt, std::function<void()> freelistCallback); VideoFrame(AVFrame* frame, int w, int h, int fmt, std::function<void()> freelistCallback);
~VideoFrame(); ~VideoFrame();

View File

@ -28,7 +28,7 @@
#include <QApplication> #include <QApplication>
void emitChatroomWidget(QLayout* layout, int index) void CategoryWidget::emitChatroomWidget(QLayout* layout, int index)
{ {
GenericChatroomWidget* chatWidget = dynamic_cast<GenericChatroomWidget*>(layout->itemAt(index)->widget()); GenericChatroomWidget* chatWidget = dynamic_cast<GenericChatroomWidget*>(layout->itemAt(index)->widget());
if (chatWidget != nullptr) if (chatWidget != nullptr)
@ -83,11 +83,12 @@ void CategoryWidget::setExpanded(bool isExpanded, bool save)
setMouseTracking(true); setMouseTracking(true);
listWidget->setVisible(isExpanded); listWidget->setVisible(isExpanded);
QString pixmapPath;
if (isExpanded) if (isExpanded)
statusPic.setPixmap(QPixmap(":/ui/chatArea/scrollBarDownArrow.svg")); pixmapPath = ":/ui/chatArea/scrollBarDownArrow.svg";
else else
statusPic.setPixmap(QPixmap(":/ui/chatArea/scrollBarRightArrow.svg")); pixmapPath = ":/ui/chatArea/scrollBarRightArrow.svg";
statusPic.setPixmap(QPixmap(pixmapPath));
// The listWidget will recieve a enterEvent for some reason if now visible. // The listWidget will recieve a enterEvent for some reason if now visible.
// Using the following, we prevent that. // Using the following, we prevent that.
QApplication::processEvents(QEventLoop::ExcludeSocketNotifiers); QApplication::processEvents(QEventLoop::ExcludeSocketNotifiers);
@ -199,8 +200,9 @@ bool CategoryWidget::cycleContacts(FriendWidget* activeChatroomWidget, bool forw
QLayout* currentLayout = nullptr; QLayout* currentLayout = nullptr;
FriendWidget* friendWidget = dynamic_cast<FriendWidget*>(activeChatroomWidget); FriendWidget* friendWidget = dynamic_cast<FriendWidget*>(activeChatroomWidget);
if (friendWidget != nullptr) if (friendWidget == nullptr)
{ return false;
currentLayout = listLayout->getLayoutOnline(); currentLayout = listLayout->getLayoutOnline();
index = listLayout->indexOfFriendWidget(friendWidget, true); index = listLayout->indexOfFriendWidget(friendWidget, true);
if (index == -1) if (index == -1)
@ -208,9 +210,6 @@ bool CategoryWidget::cycleContacts(FriendWidget* activeChatroomWidget, bool forw
currentLayout = listLayout->getLayoutOffline(); currentLayout = listLayout->getLayoutOffline();
index = listLayout->indexOfFriendWidget(friendWidget, false); index = listLayout->indexOfFriendWidget(friendWidget, false);
} }
}
else
return false;
index += forward ? 1 : -1; index += forward ? 1 : -1;
for (;;) for (;;)

View File

@ -33,7 +33,7 @@ class CategoryWidget : public GenericChatItemWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
CategoryWidget(QWidget* parent = 0); explicit CategoryWidget(QWidget* parent = 0);
bool isExpanded() const; bool isExpanded() const;
void setExpanded(bool isExpanded, bool save = true); void setExpanded(bool isExpanded, bool save = true);
@ -60,6 +60,7 @@ protected:
QLayout* friendOnlineLayout() const; QLayout* friendOnlineLayout() const;
QLayout* friendOfflineLayout() const; QLayout* friendOfflineLayout() const;
void moveFriendWidgets(FriendListWidget* friendList); void moveFriendWidgets(FriendListWidget* friendList);
void emitChatroomWidget(QLayout *layout, int index);
private: private:
virtual void onSetName() {} virtual void onSetName() {}

View File

@ -518,7 +518,7 @@ void ContentDialog::dragEnterEvent(QDragEnterEvent *event)
auto iter = friendList.find(friendId); auto iter = friendList.find(friendId);
// If friend is already in a dialog then you can't drop friend where it already is. // If friend is already in a dialog then you can't drop friend where it already is.
if (iter == friendList.end() || (iter != friendList.end() && std::get<0>(iter.value()) != this)) if (iter == friendList.end() || std::get<0>(iter.value()) != this)
event->acceptProposedAction(); event->acceptProposedAction();
} }
else if (event->mimeData()->hasFormat("group")) else if (event->mimeData()->hasFormat("group"))
@ -526,7 +526,7 @@ void ContentDialog::dragEnterEvent(QDragEnterEvent *event)
int groupId = event->mimeData()->data("group").toInt(); int groupId = event->mimeData()->data("group").toInt();
auto iter = groupList.find(groupId); auto iter = groupList.find(groupId);
if (iter == groupList.end() || (iter != groupList.end() && std::get<0>(iter.value()) != this)) if (iter == groupList.end() || std::get<0>(iter.value()) != this)
event->acceptProposedAction(); event->acceptProposedAction();
} }
} }

View File

@ -27,7 +27,7 @@ class ContentLayout : public QVBoxLayout
{ {
public: public:
ContentLayout(); ContentLayout();
ContentLayout(QWidget* parent); explicit ContentLayout(QWidget* parent);
~ContentLayout(); ~ContentLayout();
void clear(); void clear();

View File

@ -40,7 +40,7 @@ class ChatForm : public GenericChatForm
{ {
Q_OBJECT Q_OBJECT
public: public:
ChatForm(Friend* chatFriend); explicit ChatForm(Friend* chatFriend);
~ChatForm(); ~ChatForm();
void setStatusMessage(QString newMessage); void setStatusMessage(QString newMessage);
void loadHistory(QDateTime since, bool processUndelivered = false); void loadHistory(QDateTime since, bool processUndelivered = false);

View File

@ -303,7 +303,7 @@ bool GenericChatForm::event(QEvent* e)
void GenericChatForm::onChatContextMenuRequested(QPoint pos) void GenericChatForm::onChatContextMenuRequested(QPoint pos)
{ {
QWidget* sender = (QWidget*)QObject::sender(); QWidget* sender = static_cast<QWidget*>(QObject::sender());
pos = sender->mapToGlobal(pos); pos = sender->mapToGlobal(pos);
menu.exec(pos); menu.exec(pos);

View File

@ -52,7 +52,7 @@ class GenericChatForm : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
GenericChatForm(QWidget *parent = 0); explicit GenericChatForm(QWidget *parent = 0);
~GenericChatForm(); ~GenericChatForm();
void setName(const QString &newName); void setName(const QString &newName);

View File

@ -33,7 +33,7 @@ class GroupChatForm : public GenericChatForm
{ {
Q_OBJECT Q_OBJECT
public: public:
GroupChatForm(Group* chatGroup); explicit GroupChatForm(Group* chatGroup);
~GroupChatForm(); ~GroupChatForm();
void onUserListChanged(); void onUserListChanged();

View File

@ -52,7 +52,7 @@ class ProfileForm : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
ProfileForm(QWidget *parent = nullptr); explicit ProfileForm(QWidget *parent = nullptr);
~ProfileForm(); ~ProfileForm();
virtual void show() final{} virtual void show() final{}
void show(ContentLayout* contentLayout); void show(ContentLayout* contentLayout);

View File

@ -32,7 +32,7 @@ class GeneralForm : public GenericForm
{ {
Q_OBJECT Q_OBJECT
public: public:
GeneralForm(SettingsWidget *parent); explicit GeneralForm(SettingsWidget *parent);
~GeneralForm(); ~GeneralForm();
virtual QString getFormName() final override {return tr("General");} virtual QString getFormName() final override {return tr("General");}

View File

@ -24,7 +24,7 @@ class GenericForm : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
GenericForm(const QPixmap &icon) : formIcon(icon) {;} explicit GenericForm(const QPixmap &icon) : formIcon(icon) {;}
virtual ~GenericForm() {} virtual ~GenericForm() {}
virtual QString getFormName() = 0; virtual QString getFormName() = 0;

View File

@ -38,7 +38,7 @@ class SettingsWidget : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
SettingsWidget(QWidget* parent = nullptr); explicit SettingsWidget(QWidget* parent = nullptr);
~SettingsWidget(); ~SettingsWidget();
bool isShown() const; bool isShown() const;

View File

@ -37,7 +37,7 @@ class TabCompleter : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit TabCompleter(ChatTextEdit* msgEdit, Group* group); TabCompleter(ChatTextEdit* msgEdit, Group* group);
public slots: public slots:
void complete(); void complete();

View File

@ -99,10 +99,10 @@ QLayout* GenericChatItemLayout::getLayout() const
int GenericChatItemLayout::indexOfClosestSortedWidget(GenericChatItemWidget* widget) const int GenericChatItemLayout::indexOfClosestSortedWidget(GenericChatItemWidget* widget) const
{ {
// Binary search: Deferred test of equality. // Binary search: Deferred test of equality.
int min = 0, max = layout->count(), mid; int min = 0, max = layout->count();
while (min < max) while (min < max)
{ {
mid = (max - min) / 2 + min; int mid = (max - min) / 2 + min;
GenericChatItemWidget* atMid = dynamic_cast<GenericChatItemWidget*>(layout->itemAt(mid)->widget()); GenericChatItemWidget* atMid = dynamic_cast<GenericChatItemWidget*>(layout->itemAt(mid)->widget());
assert(atMid != nullptr); assert(atMid != nullptr);

View File

@ -24,7 +24,7 @@
#include <QVariant> #include <QVariant>
GenericChatItemWidget::GenericChatItemWidget(QWidget *parent) GenericChatItemWidget::GenericChatItemWidget(QWidget *parent)
: QFrame(parent) : QFrame(parent), compact(false)
{ {
setProperty("compact", Settings::getInstance().getCompactLayout()); setProperty("compact", Settings::getInstance().getCompactLayout());

View File

@ -36,7 +36,7 @@ public:
FriendOnlineItem FriendOnlineItem
}; };
GenericChatItemWidget(QWidget *parent = 0); explicit GenericChatItemWidget(QWidget *parent = 0);
bool isCompact() const; bool isCompact() const;
void setCompact(bool compact); void setCompact(bool compact);

View File

@ -29,10 +29,13 @@ GenericChatroomWidget::GenericChatroomWidget(QWidget *parent)
: GenericChatItemWidget(parent), active{false} : GenericChatItemWidget(parent), active{false}
{ {
// avatar // avatar
QSize size;
if (isCompact()) if (isCompact())
avatar = new MaskablePixmapWidget(this, QSize(20,20), ":/img/avatar_mask.svg"); size = QSize(20,20);
else else
avatar = new MaskablePixmapWidget(this, QSize(40,40), ":/img/avatar_mask.svg"); size = QSize(40,40);
avatar = new MaskablePixmapWidget(this, size, ":/img/avatar_mask.svg");
// status text // status text
statusMessageLabel = new CroppingLabel(this); statusMessageLabel = new CroppingLabel(this);

View File

@ -34,7 +34,7 @@ class GenericChatroomWidget : public GenericChatItemWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
GenericChatroomWidget(QWidget *parent = 0); explicit GenericChatroomWidget(QWidget *parent = 0);
virtual void setAsActiveChatroom() = 0; virtual void setAsActiveChatroom() = 0;
virtual void setAsInactiveChatroom() = 0; virtual void setAsInactiveChatroom() = 0;

View File

@ -29,7 +29,7 @@ class NotificationEdgeWidget;
class NotificationScrollArea final : public AdjustingScrollArea class NotificationScrollArea final : public AdjustingScrollArea
{ {
public: public:
NotificationScrollArea(QWidget* parent = 0); explicit NotificationScrollArea(QWidget* parent = 0);
public slots: public slots:
void trackWidget(GenericChatroomWidget* widget); void trackWidget(GenericChatroomWidget* widget);

View File

@ -76,14 +76,14 @@ SystemTrayIcon::SystemTrayIcon()
void (*callbackTrigger)(GtkStatusIcon*, gpointer) = void (*callbackTrigger)(GtkStatusIcon*, gpointer) =
[](GtkStatusIcon*, gpointer data) [](GtkStatusIcon*, gpointer data)
{ {
((SystemTrayIcon*)data)->activated(QSystemTrayIcon::Trigger); static_cast<SystemTrayIcon*>(data)->activated(QSystemTrayIcon::Trigger);
}; };
g_signal_connect(gtkIcon, "activate", G_CALLBACK(callbackTrigger), this); g_signal_connect(gtkIcon, "activate", G_CALLBACK(callbackTrigger), this);
void (*callbackButtonClick)(GtkStatusIcon*, GdkEvent*, gpointer) = void (*callbackButtonClick)(GtkStatusIcon*, GdkEvent*, gpointer) =
[](GtkStatusIcon*, GdkEvent* event, gpointer data) [](GtkStatusIcon*, GdkEvent* event, gpointer data)
{ {
if (event->button.button == 2) if (event->button.button == 2)
((SystemTrayIcon*)data)->activated(QSystemTrayIcon::MiddleClick); static_cast<SystemTrayIcon*>(data)->activated(QSystemTrayIcon::MiddleClick);
}; };
g_signal_connect(gtkIcon, "button-release-event", G_CALLBACK(callbackButtonClick), this); g_signal_connect(gtkIcon, "button-release-event", G_CALLBACK(callbackButtonClick), this);
} }
@ -124,13 +124,13 @@ void SystemTrayIcon::setContextMenu(QMenu* menu)
void (*callbackClick)(StatusNotifier*, gint, gint, gpointer) = void (*callbackClick)(StatusNotifier*, gint, gint, gpointer) =
[](StatusNotifier*, gint, gint, gpointer data) [](StatusNotifier*, gint, gint, gpointer data)
{ {
((SystemTrayIcon*)data)->activated(QSystemTrayIcon::Trigger); static_cast<SystemTrayIcon*>(data)->activated(QSystemTrayIcon::Trigger);
}; };
g_signal_connect(statusNotifier, "activate", G_CALLBACK(callbackClick), this); g_signal_connect(statusNotifier, "activate", G_CALLBACK(callbackClick), this);
void (*callbackMiddleClick)(StatusNotifier*, gint, gint, gpointer) = void (*callbackMiddleClick)(StatusNotifier*, gint, gint, gpointer) =
[](StatusNotifier*, gint, gint, gpointer data) [](StatusNotifier*, gint, gint, gpointer data)
{ {
((SystemTrayIcon*)data)->activated(QSystemTrayIcon::MiddleClick); static_cast<SystemTrayIcon*>(data)->activated(QSystemTrayIcon::MiddleClick);
}; };
g_signal_connect(statusNotifier, "secondary_activate", G_CALLBACK(callbackMiddleClick), this); g_signal_connect(statusNotifier, "secondary_activate", G_CALLBACK(callbackMiddleClick), this);
@ -175,8 +175,8 @@ void SystemTrayIcon::setContextMenu(QMenu* menu)
void (*callbackMenu)(StatusNotifier*, gint, gint, gpointer) = void (*callbackMenu)(StatusNotifier*, gint, gint, gpointer) =
[](StatusNotifier*, gint, gint, gpointer data) [](StatusNotifier*, gint, gint, gpointer data)
{ {
gtk_widget_show_all(((SystemTrayIcon*)data)->snMenu); gtk_widget_show_all(static_cast<SystemTrayIcon*>(data)->snMenu);
gtk_menu_popup(GTK_MENU(((SystemTrayIcon*)data)->snMenu), 0, 0, 0, 0, 3, gtk_get_current_event_time()); gtk_menu_popup(GTK_MENU(static_cast<SystemTrayIcon*>(data)->snMenu), 0, 0, 0, 0, 3, gtk_get_current_event_time());
}; };
g_signal_connect(statusNotifier, "context-menu", G_CALLBACK(callbackMenu), this); g_signal_connect(statusNotifier, "context-menu", G_CALLBACK(callbackMenu), this);
} }
@ -225,8 +225,8 @@ void SystemTrayIcon::setContextMenu(QMenu* menu)
void (*callbackMenu)(GtkMenu*, gint, gint, gpointer) = void (*callbackMenu)(GtkMenu*, gint, gint, gpointer) =
[](GtkMenu*, gint, gint, gpointer data) [](GtkMenu*, gint, gint, gpointer data)
{ {
gtk_widget_show_all(((SystemTrayIcon*)data)->gtkMenu); gtk_widget_show_all(static_cast<SystemTrayIcon*>(data)->gtkMenu);
gtk_menu_popup(GTK_MENU(((SystemTrayIcon*)data)->gtkMenu), 0, 0, 0, 0, 3, gtk_get_current_event_time()); gtk_menu_popup(GTK_MENU(static_cast<SystemTrayIcon*>(data)->gtkMenu), 0, 0, 0, 0, 3, gtk_get_current_event_time());
}; };
g_signal_connect(gtkIcon, "popup-menu", G_CALLBACK(callbackMenu), this); g_signal_connect(gtkIcon, "popup-menu", G_CALLBACK(callbackMenu), this);
} }
@ -253,7 +253,7 @@ void SystemTrayIcon::setContextMenu(QMenu* menu)
gtk_menu_shell_append(GTK_MENU_SHELL(unityMenu), item); gtk_menu_shell_append(GTK_MENU_SHELL(unityMenu), item);
void (*callback)(GtkMenu*, gpointer data) = [](GtkMenu*, gpointer a) void (*callback)(GtkMenu*, gpointer data) = [](GtkMenu*, gpointer a)
{ {
((QAction*)a)->activate(QAction::Trigger); static_cast<QAction*>(a)->activate(QAction::Trigger);
}; };
g_signal_connect(item, "activate", G_CALLBACK(callback), a); g_signal_connect(item, "activate", G_CALLBACK(callback), a);
gtk_widget_show(item); gtk_widget_show(item);
@ -266,7 +266,7 @@ void SystemTrayIcon::setContextMenu(QMenu* menu)
void (*callback)(DbusmenuMenuitem *, gpointer) = void (*callback)(DbusmenuMenuitem *, gpointer) =
[](DbusmenuMenuitem *, gpointer data) [](DbusmenuMenuitem *, gpointer data)
{ {
((SystemTrayIcon*)data)->activated(QSystemTrayIcon::Unknown); static_cast<SystemTrayIcon*>(data)->activated(QSystemTrayIcon::Unknown);
}; };
g_signal_connect(rootMenuItem, "about-to-show", G_CALLBACK(callback), this); g_signal_connect(rootMenuItem, "about-to-show", G_CALLBACK(callback), this);
} }

View File

@ -34,7 +34,7 @@ CroppingLabel::CroppingLabel(QWidget* parent)
class LineEdit : public QLineEdit class LineEdit : public QLineEdit
{ {
public: public:
LineEdit(QWidget* parent = 0) : explicit LineEdit(QWidget* parent = 0) :
QLineEdit(parent) QLineEdit(parent)
{} {}

View File

@ -23,7 +23,7 @@
#include <QLinearGradient> #include <QLinearGradient>
MicFeedbackWidget::MicFeedbackWidget(QWidget *parent) MicFeedbackWidget::MicFeedbackWidget(QWidget *parent)
: QWidget(parent) : QWidget(parent), mMeterListener(nullptr)
{ {
setFixedHeight(20); setFixedHeight(20);
} }

View File

@ -25,7 +25,7 @@
class MovableWidget : public QWidget class MovableWidget : public QWidget
{ {
public: public:
MovableWidget(QWidget* parent); explicit MovableWidget(QWidget* parent);
void resetBoundary(QRect newBoundary); void resetBoundary(QRect newBoundary);
void setBoundary(QRect newBoundary); void setBoundary(QRect newBoundary);
float getRatio() const; float getRatio() const;

View File

@ -26,7 +26,7 @@ class ScreenGrabberChooserRectItem final : public QObject, public QGraphicsItemG
{ {
Q_OBJECT Q_OBJECT
public: public:
ScreenGrabberChooserRectItem(QGraphicsScene* scene); explicit ScreenGrabberChooserRectItem(QGraphicsScene* scene);
~ScreenGrabberChooserRectItem(); ~ScreenGrabberChooserRectItem();
virtual QRectF boundingRect() const final override; virtual QRectF boundingRect() const final override;

View File

@ -28,7 +28,7 @@ class ScreenGrabberOverlayItem final : public QObject, public QGraphicsRectItem
{ {
Q_OBJECT Q_OBJECT
public: public:
ScreenGrabberOverlayItem(ScreenshotGrabber* grabber); explicit ScreenGrabberOverlayItem(ScreenshotGrabber* grabber);
~ScreenGrabberOverlayItem(); ~ScreenGrabberOverlayItem();
void setChosenRect(QRect rect); void setChosenRect(QRect rect);

View File

@ -39,7 +39,7 @@ class ScreenshotGrabber : public QObject
Q_OBJECT Q_OBJECT
public: public:
ScreenshotGrabber(QObject* parent); explicit ScreenshotGrabber(QObject* parent);
~ScreenshotGrabber() override; ~ScreenshotGrabber() override;
bool eventFilter(QObject* object, QEvent* event) override; bool eventFilter(QObject* object, QEvent* event) override;

View File

@ -1404,7 +1404,7 @@ ContentLayout* Widget::createContentDialog(DialogType type)
class Dialog : public ActivateDialog class Dialog : public ActivateDialog
{ {
public: public:
Dialog(DialogType type) explicit Dialog(DialogType type)
: ActivateDialog() : ActivateDialog()
, type(type) , type(type)
{ {