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

docs(widget): Change comment style

This commit is contained in:
Diadlo 2016-07-27 01:20:39 +03:00
parent 52ff1c2aa8
commit 1552bfb114
No known key found for this signature in database
GPG Key ID: 5AF9F2E29107C727
28 changed files with 262 additions and 90 deletions

View File

@ -89,9 +89,8 @@ void AboutUser::onSelectDirClicked()
}
/**
* @brief AboutUser::onAcceptedClicked When users clicks the bottom OK button,
* save all settings
*/
@brief Called when user clicks the bottom OK button, save all settings
*/
void AboutUser::onAcceptedClicked()
{
ToxId toxId = ToxId(ui->publicKey->text());

View File

@ -41,6 +41,11 @@
#include <QWindow>
#include <QScrollArea>
/**
@var QString AddFriendForm::lastUsername
@brief Cached username so we can retranslate the invite message
*/
AddFriendForm::AddFriendForm()
{
tabWidget = new QTabWidget();

View File

@ -85,7 +85,7 @@ private:
QTextEdit message;
QVBoxLayout layout, headLayout;
QWidget *head, *main;
QString lastUsername; // Cached username so we can retranslate the invite message
QString lastUsername;
QTabWidget* tabWidget;
QVBoxLayout* requestsLayout;
QList<QPushButton*> acceptButtons;

View File

@ -26,10 +26,13 @@
#include <QMenu>
#include "src/core/corestructs.h"
#include "src/chatlog/chatmessage.h"
#include "../../core/toxid.h"
#include "src/core/toxid.h"
// Spacing in px inserted when the author of the last message changes
#define AUTHOR_CHANGE_SPACING 5 // why the hell is this a thing? surely the different font is enough?
/**
Spacing in px inserted when the author of the last message changes
@note Why the hell is this a thing? surely the different font is enough?
*/
#define AUTHOR_CHANGE_SPACING 5
class QLabel;
class QVBoxLayout;

View File

@ -37,6 +37,14 @@
#include <QDragEnterEvent>
#include <QtAlgorithms>
/**
@var QList<QLabel*> GroupChatForm::peerLabels
@brief Maps peernumbers to the QLabels in namesListLayout.
@var QMap<int, QTimer*> GroupChatForm::peerAudioTimers
@brief Timeout = peer stopped sending audio.
*/
GroupChatForm::GroupChatForm(Group* chatGroup)
: group(chatGroup), inCall{false}
{

View File

@ -61,8 +61,8 @@ private:
private:
Group* group;
QList<QLabel*> peerLabels; // maps peernumbers to the QLabels in namesListLayout
QMap<int, QTimer*> peerAudioTimers; // timeout = peer stopped sending audio
QList<QLabel*> peerLabels;
QMap<int, QTimer*> peerAudioTimers;
FlowLayout* namesListLayout;
QLabel *nusersLabel;
TabCompleter* tabber;

View File

@ -20,15 +20,21 @@
along with qTox. If not, see <http://www.gnu.org/licenses/>.
*/
/* This file was taken from the Quassel IRC client source (src/uisupport), and
was greatly simplified for use in qTox. */
/**
@file tabcompleter.h
@file tabcompleter.cpp
These files were taken from the Quassel IRC client source (src/uisupport), and
was greatly simplified for use in qTox.
*/
#include "tabcompleter.h"
#include <QRegExp>
#include <QKeyEvent>
#include "src/core/core.h"
#include "src/group.h"
#include "src/widget/tool/chattextedit.h"
#include <QRegExp>
#include <QKeyEvent>
const QString TabCompleter::nickSuffix = QString(": ");

View File

@ -20,18 +20,13 @@
along with qTox. If not, see <http://www.gnu.org/licenses/>.
*/
/* This file was taken from the Quassel IRC client source (src/uisupport), and
was greatly simplified for use in qTox. */
#ifndef TABCOMPLETER_H
#define TABCOMPLETER_H
#include <QString>
#include <QMap>
#include <QObject> // I'm really confused why I need this
class ChatTextEdit;
class Group;
#include "src/group.h"
#include "src/widget/tool/chattextedit.h"
class TabCompleter : public QObject
{

View File

@ -31,6 +31,17 @@
#include <QPushButton>
#include <QThread>
/**
@class GUI
@brief Abstracts the GUI from the target backend (DesktopGUI, ...)
All the functions exposed here are thread-safe.
Prefer calling this class to calling a GUI backend directly.
@fn void GUI::resized()
@brief Emitted when the GUI is resized on supported platforms.
*/
GUI::GUI(QObject *parent) :
QObject(parent)
{
@ -39,6 +50,9 @@ GUI::GUI(QObject *parent) :
connect(Nexus::getDesktopGUI(), &Widget::resized, this, &GUI::resized);
}
/**
@brief Returns the singleton instance.
*/
GUI& GUI::getInstance()
{
static GUI gui;
@ -47,6 +61,9 @@ GUI& GUI::getInstance()
// Implementation of the public clean interface
/**
@brief Clear the GUI's contact list.
*/
void GUI::clearContacts()
{
if (QThread::currentThread() == qApp->thread())
@ -55,6 +72,11 @@ void GUI::clearContacts()
QMetaObject::invokeMethod(&getInstance(), "_clearContacts", Qt::BlockingQueuedConnection);
}
/**
@brief Will enable or disable the GUI.
@note A disabled GUI can't be interacted with by the user.
@param state Enable/disable GUI.
*/
void GUI::setEnabled(bool state)
{
if (QThread::currentThread() == qApp->thread())
@ -68,6 +90,12 @@ void GUI::setEnabled(bool state)
}
}
/**
@brief Change the title of the main window.
@param title Titile to set.
This is usually always visible to the user.
*/
void GUI::setWindowTitle(const QString& title)
{
if (QThread::currentThread() == qApp->thread())
@ -81,6 +109,9 @@ void GUI::setWindowTitle(const QString& title)
}
}
/**
@brief Reloads the application theme and redraw the window.
*/
void GUI::reloadTheme()
{
if (QThread::currentThread() == qApp->thread())
@ -93,6 +124,9 @@ void GUI::reloadTheme()
}
}
/**
@brief Optionally switches to a view of the qTox update being downloaded.
*/
void GUI::showUpdateDownloadProgress()
{
if (QThread::currentThread() == qApp->thread())
@ -105,6 +139,11 @@ void GUI::showUpdateDownloadProgress()
}
}
/**
@brief Show some text to the user.
@param title Title of information window.
@param msg Text in information window.
*/
void GUI::showInfo(const QString& title, const QString& msg)
{
if (QThread::currentThread() == qApp->thread())
@ -118,6 +157,11 @@ void GUI::showInfo(const QString& title, const QString& msg)
}
}
/**
@brief Show a warning to the user
@param title Title of warning window.
@param msg Text in warning window.
*/
void GUI::showWarning(const QString& title, const QString& msg)
{
if (QThread::currentThread() == qApp->thread())
@ -131,6 +175,11 @@ void GUI::showWarning(const QString& title, const QString& msg)
}
}
/**
@brief Show an error to the user.
@param title Title of error window.
@param msg Text in error window.
*/
void GUI::showError(const QString& title, const QString& msg)
{
if (QThread::currentThread() == qApp->thread())
@ -149,6 +198,15 @@ void GUI::showError(const QString& title, const QString& msg)
}
}
/**
@brief Asks the user a question with Ok/Cansel or Yes/No buttons.
@param title Title of question window.
@param msg Text in question window.
@param defaultAns If is true, default was positive answer. Negative otherwise.
@param warning If is true, we will use a special warning style.
@param yesno Show "Yes" and "No" buttons.
@return True if the answer is positive, false otherwise.
*/
bool GUI::askQuestion(const QString& title, const QString& msg,
bool defaultAns, bool warning,
bool yesno)
@ -169,6 +227,18 @@ bool GUI::askQuestion(const QString& title, const QString& msg,
}
}
/**
@brief Asks the user a question.
The text for the displayed buttons can be specified.
@param title Title of question window.
@param msg Text in question window.
@param button1 Text of positive button.
@param button2 Text of negative button.
@param defaultAns If is true, default was positive answer. Negative otherwise.
@param warning If is true, we will use a special warning style.
@return True if the answer is positive, false otherwise.
*/
bool GUI::askQuestion(const QString& title, const QString& msg,
const QString& button1, const QString& button2,
bool defaultAns, bool warning)
@ -188,6 +258,21 @@ bool GUI::askQuestion(const QString& title, const QString& msg,
}
}
/**
@brief Asks the user to input text and returns the answer.
The interface is equivalent to QInputDialog::getItem()
@param parent Is the dialog's parent widget
@param title Is the text which is displayed in the title bar of the dialog.
@param label Is the text which is shown to the user (it should say what should be entered).
@param items Is the string list which is inserted into the combobox.
@param current Is the number of the item which should be the current item.
@param editable If is true the user can enter their own text, otherwise the user may only select one of the existing items.
@param ok If is nonnull will be set to true if the user pressed OK and to false if the user pressed Cancel.
@param flags The dialog will uses to widget flags.
@param hints Is the input method hints that will be used if the combobox is editable and an input method is active.
@return This function returns the text of the current item, or if editable is true, the current text of the combobox.
*/
QString GUI::itemInputDialog(QWidget * parent, const QString & title,
const QString & label, const QStringList & items,
int current, bool editable, bool * ok,
@ -211,6 +296,12 @@ QString GUI::itemInputDialog(QWidget * parent, const QString & title,
}
}
/**
@brief Asks the user to answer a password.
@param cancel Is the text on the cancel button.
@param body Is descriptive text that will be shown to the user.
@return Entered password.
*/
QString GUI::passwordDialog(const QString& cancel, const QString& body)
{
if (QThread::currentThread() == qApp->thread())
@ -369,6 +460,10 @@ QString GUI::_passwordDialog(const QString& cancel, const QString& body)
// Other
/**
@brief Get the main widget.
@return The main QWidget* of the application
*/
QWidget* GUI::getMainWidget()
{
QWidget* maingui{nullptr};

View File

@ -25,69 +25,44 @@
class QWidget;
/// Abstracts the GUI from the target backend (DesktopGUI, ...)
/// All the functions exposed here are thread-safe
/// Prefer calling this class to calling a GUI backend directly
class GUI : public QObject
{
Q_OBJECT
public:
static GUI& getInstance();
/// Returns the main QWidget* of the application
static QWidget* getMainWidget();
/// Clear the GUI's contact list
static void clearContacts();
/// Will enable or disable the GUI.
/// A disabled GUI can't be interacted with by the user
static void setEnabled(bool state);
/// Change the title of the main window
/// This is usually always visible to the user
static void setWindowTitle(const QString& title);
/// Reloads the application theme and redraw the window
static void reloadTheme();
/// Optionally switches to a view of the qTox update being downloaded
static void showUpdateDownloadProgress();
/// Show some text to the user, for example in a message box
static void showInfo(const QString& title, const QString& msg);
/// Show a warning to the user, for example in a message box
static void showWarning(const QString& title, const QString& msg);
/// Show an error to the user, for example in a message box
static void showError(const QString& title, const QString& msg);
/// Asks the user a question, for example in a message box.
/// If warning is true, we will use a special warning style.
/// Returns the answer.
static bool askQuestion(const QString& title, const QString& msg,
bool defaultAns = false, bool warning = true,
bool yesno = true);
/// Asks the user a question, for example in a message box.
/// The text for the displayed buttons can be specified.
/// If warning is true, we will use a special warning style.
/// Returns the answer.
static bool askQuestion(const QString& title, const QString& msg,
const QString& button1, const QString& button2,
bool defaultAns = false, bool warning = true);
/// Asks the user to input text and returns the answer.
/// The interface is equivalent to QInputDialog::getItem()
static QString itemInputDialog(QWidget * parent, const QString & title,
const QString & label, const QStringList & items,
int current = 0, bool editable = true, bool * ok = 0,
Qt::WindowFlags flags = 0,
Qt::InputMethodHints hints = Qt::ImhNone);
/// Asks the user to answer a password
/// cancel is the text on the cancel button and body
/// is descriptive text that will be shown to the user
static QString passwordDialog(const QString& cancel, const QString& body);
signals:
/// Emitted when the GUI is resized on supported platforms
/// Guaranteed to work on desktop platforms
void resized();
private:
explicit GUI(QObject *parent = 0);
// Private implementation, those must be called from the GUI thread
private slots:
// Private implementation, those must be called from the GUI thread
void _clearContacts();
void _setEnabled(bool state);
void _setWindowTitle(const QString& title);

View File

@ -71,6 +71,9 @@ LoginScreen::~LoginScreen()
delete ui;
}
/**
@brief Resets the UI, clears all fields.
*/
void LoginScreen::reset()
{
ui->newUsername->clear();

View File

@ -36,7 +36,7 @@ class LoginScreen : public QWidget
public:
explicit LoginScreen(QWidget *parent = 0);
~LoginScreen();
void reset(); ///< Resets the UI, clears all fields
void reset();
bool event(QEvent* event) final override;

View File

@ -20,8 +20,14 @@
#include "maskablepixmapwidget.h"
#include <QPainter>
/**
@var QPixmap* MaskablePixmapWidget::renderTarget
@brief pointer to dynamically call the constructor.
*/
MaskablePixmapWidget::MaskablePixmapWidget(QWidget *parent, QSize size, QString maskName)
: QWidget(parent)
, renderTarget(nullptr)
, maskName(maskName)
, clickable(false)
{

View File

@ -42,8 +42,8 @@ protected:
virtual void mousePressEvent(QMouseEvent *) final override;
private:
QPixmap pixmap, mask, unscaled; // a lot of memory...
QPixmap* renderTarget = nullptr; // pointer to dynamically call the constructor
QPixmap pixmap, mask, unscaled;
QPixmap* renderTarget;
QSize size;
QString maskName;
bool clickable;

View File

@ -67,16 +67,16 @@ void NotificationScrollArea::trackWidget(GenericChatroomWidget* widget)
}
/**
* @brief Delete notification bar to visible elements on scroll area
*/
@brief Delete notification bar from visible elements on scroll area
*/
void NotificationScrollArea::updateVisualTracking() {
updateTracking(nullptr);
}
/**
* @brief Delete notification bar from visible elements and widget on scroll area
* @param widget Chatroom widget to remove from tracked widgets
*/
@brief Delete notification bar from visible elements and widget on scroll area
@param widget Chatroom widget to remove from tracked widgets
*/
void NotificationScrollArea::updateTracking(GenericChatroomWidget *widget)
{
QHash<GenericChatroomWidget*, Visibility>::iterator i = trackedWidgets.begin();

View File

@ -31,6 +31,11 @@
#include <sys/errno.h>
#endif
/**
@file qrwidget.cpp
@link https://stackoverflow.com/questions/21400254/how-to-draw-a-qr-code-with-qt-in-native-c-c
*/
QRWidget::QRWidget(QWidget *parent) : QWidget(parent), data("0")
//Note: The encoding fails with empty string so I just default to something else.
//Use the setQRData() call to change this.
@ -58,10 +63,10 @@ QImage* QRWidget::getImage()
}
/**
* @brief QRWidget::saveImage
* @param path Full path to the file with extension.
* @return indicate if saving was successful.
*/
@brief QRWidget::saveImage
@param path Full path to the file with extension.
@return indicate if saving was successful.
*/
bool QRWidget::saveImage(QString path)
{
return image->save(path, 0, 75); //0 - image format same as file extension, 75-quality, png file is ~6.3kb

View File

@ -21,8 +21,6 @@
#ifndef QRWIDGET_H
#define QRWIDGET_H
// https://stackoverflow.com/questions/21400254/how-to-draw-a-qr-code-with-qt-in-native-c-c
#include <QWidget>
class QRWidget : public QWidget

View File

@ -31,6 +31,31 @@
#include <QSvgRenderer>
#include <QPainter>
/**
@enum Style::Font
@var ExtraBig
@brief [SystemDefault + 2]px, bold
@var Big
@brief [SystemDefault]px
@var BigBold
@brief [SystemDefault]px, bold
@var Medium
@brief [SystemDefault - 1]px
@var MediumBold
@brief [SystemDefault - 1]px, bold
@var Small
@brief [SystemDefault - 2]px
@var SmallLight
@brief [SystemDefault - 2]px, light
*/
// helper functions
QFont appFont(int pixelSize, int weight)
{
@ -181,6 +206,12 @@ void Style::setThemeColor(int color)
setThemeColor(themeColorColors[color]);
}
/**
@brief Set theme color.
@param color Color to set.
Pass an invalid QColor to reset to defaults.
*/
void Style::setThemeColor(const QColor &color)
{
if (!color.isValid())
@ -205,6 +236,9 @@ void Style::setThemeColor(const QColor &color)
dict["@themeLight"] = getColor(ThemeLight).name();
}
/**
@brief Reloads some CCS
*/
void Style::applyTheme()
{
GUI::reloadTheme();

View File

@ -49,13 +49,13 @@ public:
enum Font
{
ExtraBig, // [SystemDefault + 2]px, bold
Big, // [SystemDefault ]px
BigBold, // [SystemDefault ]px, bold
Medium, // [SystemDefault - 1]px
MediumBold, // [SystemDefault - 1]px, bold
Small, // [SystemDefault - 2]px
SmallLight // [SystemDefault - 2]px, light
ExtraBig,
Big,
BigBold,
Medium,
MediumBold,
Small,
SmallLight
};
static QStringList getThemeColorNames();
@ -65,8 +65,8 @@ public:
static QString resolve(QString qss, const QFont& baseFont = QFont());
static void repolish(QWidget* w);
static void setThemeColor(int color);
static void setThemeColor(const QColor &color); ///< Pass an invalid QColor to reset to defaults
static void applyTheme(); ///< Reloads some CCS
static void setThemeColor(const QColor &color);
static void applyTheme();
static QPixmap scaleSvgImage(const QString& path, uint32_t width, uint32_t height);
static QList<QColor> themeColorColors;

View File

@ -31,6 +31,26 @@
#include <QRect>
#include <QPalette>
/**
@class CallConfirmWidget
@brief This is a widget with dialog buttons to accept/reject a call
It tracks the position of another widget called the anchor
and looks like a bubble at the bottom of that widget.
@var const QWidget* CallConfirmWidget::anchor
@brief The widget we're going to be tracking
@var const Friend& CallConfirmWidget::f
@brief The friend on whose chat form we should appear
@var const int CallConfirmWidget::roundedFactor
@brief By how much are the corners of the main rect rounded
@var const qreal CallConfirmWidget::rectRatio
@brief Used to correct the rounding factors on non-square rects
*/
CallConfirmWidget::CallConfirmWidget(const QWidget *Anchor, const Friend& f) :
QWidget(), anchor(Anchor), f(f),
rectW{120}, rectH{85},
@ -75,6 +95,9 @@ CallConfirmWidget::CallConfirmWidget(const QWidget *Anchor, const Friend& f) :
reposition();
}
/**
@brief Recalculate our positions to track the anchor
*/
void CallConfirmWidget::reposition()
{
if (parentWidget())

View File

@ -30,9 +30,6 @@ class QPaintEvent;
class QShowEvent;
class Friend;
/// This is a widget with dialog buttons to accept/reject a call
/// It tracks the position of another widget called the anchor
/// and looks like a bubble at the bottom of that widget.
class CallConfirmWidget final : public QWidget
{
Q_OBJECT
@ -44,7 +41,7 @@ signals:
void rejected();
public slots:
void reposition(); ///< Recalculate our positions to track the anchor
void reposition();
protected:
virtual void paintEvent(QPaintEvent* event) final override;
@ -53,8 +50,8 @@ protected:
virtual bool eventFilter(QObject *, QEvent* event) final override;
private:
const QWidget* anchor; ///< The widget we're going to be tracking
const Friend& f; ///< The friend on whose chat form we should appear
const QWidget* anchor;
const Friend& f;
QRect mainRect;
QPolygon spikePoly;
@ -62,8 +59,8 @@ private:
const int rectW, rectH;
const int spikeW, spikeH;
const int roundedFactor; ///< By how much are the corners of the main rect rounded
const qreal rectRatio; ///< Used to correct the rounding factors on non-square rects
const int roundedFactor;
const qreal rectRatio;
};
#endif // CALLCONFIRMWIDGET_H

View File

@ -151,6 +151,10 @@ void CroppingLabel::showTextEdit()
textEdit->setFocusPolicy(Qt::ClickFocus);
}
/**
@brief Get original full text.
@return The un-cropped text.
*/
QString CroppingLabel::fullText()
{
return origText;

View File

@ -35,7 +35,7 @@ public:
void setEdlideMode(Qt::TextElideMode elide);
void setText(const QString& text);
QString fullText(); ///< Returns the un-cropped text
QString fullText();
public slots:

View File

@ -192,10 +192,9 @@ void ScreenshotGrabber::chooseHelperTooltipText(QRect rect)
}
/**
* @internal
*
* Align the tooltip centred at top of screen with the mouse cursor.
*/
@internal
@brief Align the tooltip centered at top of screen with the mouse cursor.
*/
void ScreenshotGrabber::adjustTooltipPosition()
{
QRect recGL = QGuiApplication::primaryScreen()->virtualGeometry();

View File

@ -33,6 +33,9 @@ QTranslator* Translator::translator{nullptr};
QVector<Translator::Callback> Translator::callbacks;
QMutex Translator::lock;
/**
@brief Loads the translations according to the settings or locale.
*/
void Translator::translate()
{
QMutexLocker locker{&lock};
@ -76,12 +79,21 @@ void Translator::translate()
pair.second();
}
/**
@brief Register a function to be called when the UI needs to be retranslated.
@param f Function, wich will called.
@param owner Widget to retanslate.
*/
void Translator::registerHandler(std::function<void()> f, void *owner)
{
QMutexLocker locker{&lock};
callbacks.push_back({owner, f});
}
/**
@brief Unregisters all handlers of an owner.
@param owner Owner to unregister.
*/
void Translator::unregister(void *owner)
{
QMutexLocker locker{&lock};

View File

@ -31,11 +31,8 @@ class QTranslator;
class Translator
{
public:
/// Loads the translations according to the settings or locale
static void translate();
/// Register a function to be called when the UI needs to be retranslated
static void registerHandler(std::function<void()>, void* owner);
/// Unregisters all handlers of an owner
static void unregister(void* owner);
private:

View File

@ -537,6 +537,9 @@ Widget::~Widget()
instance = nullptr;
}
/**
@brief Returns the singleton instance.
*/
Widget* Widget::getInstance()
{
if (!instance)
@ -545,6 +548,9 @@ Widget* Widget::getInstance()
return instance;
}
/**
@brief Switches to the About settings page.
*/
void Widget::showUpdateDownloadProgress()
{
settingsWidget->showAbout();
@ -1704,6 +1710,9 @@ void Widget::onEmptyGroupCreated(int groupId)
group->getGroupWidget()->editName();
}
/**
@brief Used to reset the blinking icon.
*/
void Widget::resetIcon() {
eventIcon = false;
eventFlag = false;

View File

@ -67,7 +67,7 @@ public:
QString getUsername();
Camera* getCamera();
static Widget* getInstance();
void showUpdateDownloadProgress(); ///< Switches to the About settings page
void showUpdateDownloadProgress();
void addFriendDialog(Friend* frnd, ContentDialog* dialog);
void addGroupDialog(Group* group, ContentDialog* dialog);
bool newFriendMessageAlert(int friendId, bool sound=true);
@ -106,7 +106,6 @@ public:
void searchItem(GenericChatItemWidget* chatItem, GenericChatItemWidget::ItemType type);
bool groupsVisible() const;
// Used to reset the blinking icon
void resetIcon();
public slots: