adopt comment style to doxygen

This commit is contained in:
frickler24
2016-02-20 23:14:26 +01:00
committed by Lutz Eichler
parent 2cffe41c4b
commit c747a69967
6 changed files with 124 additions and 57 deletions
-1
View File
@@ -241,7 +241,6 @@
</layout>
<zorder>label</zorder>
<zorder>line</zorder>
<zorder>verticalSpacer</zorder>
<zorder>label_2</zorder>
<zorder>line_2</zorder>
<zorder>widget</zorder>
-2
View File
@@ -10,8 +10,6 @@
namespace Ui {
class KbWidget;
class KbBindWidget;
class RebindWidget;
}
class KbWidget : public QWidget
+4 -5
View File
@@ -434,7 +434,7 @@ void KeyAction::keyEvent(KbBind* bind, bool down){
//////////
/// \brief KeyAction::macroDisplay
/// Just for debugging
/// Just for debugging.
///
void KeyAction::macroDisplay() {
qDebug() << "isMacro returns" << (isMacro() ? "true" : "false");
@@ -490,13 +490,12 @@ void KeyAction::adjustDisplay(){
}
//////////
/// \brief KeyAction::macroAction
/// \param macroDef
/// \return QString holding G-Key macro definition
///
/// \brief KeyAction::macroAction is called when applying changes on a macro definition.
/// macroAction ist called while being in the macro pane
/// and clicking Apply with something in the Macro Text Box.
/// Tag that input with "$macro:" for further recognition.
/// \param macroDef holds the String containing parts 2-4 of a complete macro definition.
/// \return QString holding the complete G-Key macro definition (parts 1-4)
///
QString KeyAction::macroAction(QString macroDef) {
return QString ("$macro:%1").arg(macroDef);
+27 -30
View File
@@ -31,26 +31,12 @@ public:
// Name to send to driver (empty string for unbind)
QString driverName() const;
//////////
/// Three inline functions for macros.
/// This helps QSting mengling with the macro-action string:
/// That string consists of 4 elements:
/// 1. "$macro:"
/// 2. Macro Key Definition (coming from pteMacroBox)
/// This sequence will program the keyboard,
/// is hardly readable and is delimited by ":"
/// 3. Readable Macro String
/// This is displayed in pteMacroText
/// 4. Readable Macro Comment
/// This is displayed in pteMacroComment
//////////
//////////
/// \brief macroFullLine
/// \return QString
/// If a macro definition exists for the given key,
/// returns the string except the leading "$"
/// If a macro command and a macro definition exists for the given key,
/// returns the complete string except the leading "$"
/// (the $ may confuse some caller).
/// \return QString
/// All 4 parts are returned in one QString.
/// If no definition exists, return ""
///
@@ -59,10 +45,12 @@ public:
}
//////////
/// \brief isValidMacro
/// \return bool
/// true, iff the macro definition
/// contains exactly all three elements.
/// \brief isValidMacro checks whether a keyAction contains a valid macro.
/// This is easy done: If the macro action starts with $macro:
/// and has four elements, delimited by ":", we may assume,
/// thats a structural correct macro action.
/// \return bool is true, iff the macro definition
/// contains all four elements.
///
inline bool isValidMacro() const {
if (isMacro()) {
@@ -75,9 +63,8 @@ public:
}
//////////
/// \brief macroLine
/// \return QStringList
/// Macro Key Definition,
/// \brief macroLine returns all interresting content for a macro definition.
/// \return QStringList returns the Macro Key Definition,
/// Readble Macro String and
/// Readable Macro Comment as QStringList.
///
@@ -90,18 +77,28 @@ public:
}
//////////
/// \brief macroContent
/// \return QString
/// Return the macro key definition only
/// (the second part of the macro definition)
/// \brief macroContent returns the macro key definition only
/// (the second part of the macro action).
/// \return QString macroContent
///
inline QString macroContent() const {
return isValidMacro() ? _value.split(":")[1] : "";
}
//////////
/// \brief macroDisplay
/// Debug output for invalid macro Definitions
/// \brief Debug output for invalid macro Definitions
///
/// General Info on KeyAction::_value for macros:
/// That string consists of 4 elements:
/// 1. Macro command "$macro:"
/// 2. Macro Key Definition (coming from pteMacroBox)
/// This sequence will program the keyboard,
/// is hardly readable and is delimited by ":"
/// 3. Readable Macro String
/// This is displayed in pteMacroText
/// 4. Readable Macro Comment
/// This is displayed in pteMacroComment
///
///
void macroDisplay();
+18 -15
View File
@@ -2,17 +2,18 @@
#include <qdebug.h>
#include "macroreader.h"
//////////
/// \class MacroReader
///
MacroReader::MacroReader() {
qDebug() << "Calling MacroReader without params is not allowed.";
}
MacroReader::MacroReader(int macroNumber, QString macroPath, QPlainTextEdit* macBox, QPlainTextEdit* macText) {
macText->setFocus(); // we want to see the keys as they appear in the macroText Widget
startWorkInAThread(macroNumber, macroPath, macBox, macText);
}
MacroReader::~MacroReader() {
}
MacroReader::~MacroReader() {}
void MacroReader::startWorkInAThread(int macroNumber, QString macroPath, QPlainTextEdit* macBox, QPlainTextEdit* macText) {
macroReaderThread = new MacroReaderThread(macroNumber, macroPath, macBox, macText);
@@ -20,19 +21,13 @@ void MacroReader::startWorkInAThread(int macroNumber, QString macroPath, QPlainT
macroReaderThread->start();
}
//////////////////////
/// \brief MacroReaderThread::readMacro
/// \param line as QString
///
/// That method ist called wia signal from the worker thread,
/// which reads the keyboard input.
/// Just display the key code in the macroBox Widget
/// without he trailing \n
//////////
/// \class MacroReaderThread
///
void MacroReaderThread::readMacro(QString line) {
// we want to see the keys as they appear in the macroText Widget
// Because it is possible to change the Focus via keyboard,
// we must set the focus on each call.
/// \detail We want to see the keys as they appear in the macroText Widget
/// Because it is possible to change the Focus via keyboard,
/// we must set the focus on each call.
macroText->setFocus();
QTextCursor c = macroText->textCursor();
c.setPosition(macroText->toPlainText().length());
@@ -40,6 +35,14 @@ void MacroReaderThread::readMacro(QString line) {
macroBox->appendPlainText(line.left(line.size()-1));
}
//////////
/// \brief MacroReaderThread::run is the standard main function for a thread.
/// Tries to open a file <macroPath><macroNumber> several times
/// (in this case, it should be possible the first time. The code was recycled from kb.cpp)
///
/// While the file is open, read lines an signal them via metaObject() to the main thread.
/// When the file is closed by the sender, close it as reader and terminate.
///
void MacroReaderThread::run() {
qDebug() << "MacroReader::run() started with" << macroNumber << "and" << macroPath << "and" << macroBox << "and" << macroText;
+75 -4
View File
@@ -7,17 +7,53 @@
#include <QThread>
#include <QPlainTextEdit>
// Class for managing G-key macros
//////////
/// \brief The MacroReaderThread class is responsible for reading Macro Key Values.
/// It is created as a separate thread (worker thread) for reading macro commands from an fresh opened notify channel.
/// Standard notify channel for macro definitions is number 2.
///
/// While the worker Thread gets input from the keyboard,
/// the lines are sent via signalling (metaobject) to run a member function in the context of the Qt UI manager.
/// (BTW: in this case it is not interesting, but you may have a lot of parallel running worker threads.
/// Just create more than one object from MacroReaderThread).
///
/// When the notify channel is closed (that's normally done by pressing "Stop"-Button in the UI),
/// the worker thread closes the channelFile and leaves.
/// \sa MacroReaderThread(), ~MacroReaderThread(), readMaco(), run()
///
class MacroReaderThread : public QThread
{
Q_OBJECT
//////////
/// \brief macroNumber
/// Filenames of nofity channels have the structure <input-device-path>/ckb1/notify<number>
/// First part is hold in macroPath, the number is hold in macroNumber.
/// macroNumber may range from 0 to 9.
int macroNumber;
//////////
/// \brief macroPath holds the path for the notify channel
/// \see macroNumber
QString macroPath;
//////////
/// \brief macroBox will receive the Macro Key Values sent from the keyboard while defining a new macro.
QPlainTextEdit* macroBox;
//////////
/// \brief macroText is the other textpane used in the UI while typing new macros.
/// That variable is used for setting the focus to that textpane and to set the cursor at EOT.
QPlainTextEdit* macroText;
public:
//////////
/// \brief MacroReaderThread saves the four params to local vars with similar varNames.
/// \param macNum
/// \param macPath
/// \param macBox
/// \param macText
///
MacroReaderThread(int macNum, QString macPath, QPlainTextEdit* macBox, QPlainTextEdit* macText) {
macroNumber = macNum;
macroPath = macPath;
@@ -25,23 +61,58 @@ public:
macroText = macText;
}
// Notification reader, launches as a separate thread and reads from file.
// (QFile doesn't have readyRead() so there's no other way to do this asynchronously)
//////////
/// \brief run is the notification reader main loop.
void run Q_DECL_OVERRIDE ();
private slots:
//////////
/// \brief readMacro is called for each line received by the worker thread.
/// The method ist called via signal (metaobject) from the worker thread,
/// which reads the keyboard input.
/// Just display the key code in the macroBox Widget without he trailing newline
/// and reposition the cursor in the macro pane.
///
/// This is used, because the worker thread shouldn't get access to the UI elements
/// (and normally has none, because the pointers macroBox and macroText remain on the stack).
/// That mechanism guarantees, that the UI does not freeze if it happens something magic to the reading function.
///
/// \param line holds the line just got from keyboard
void readMacro(QString line);
};
//////////
/// \brief The MacroReader class creates a worker thread object.
/// It does a connect do delayed deletion of thread local variables in the case the worker thread terminates.
///
class MacroReader : public QThread
{
Q_OBJECT
public:
//////////
/// \brief MacroReader Calling MacroReader without params is not allowed.
///
MacroReader();
//////////
/// \brief MacroReader This is the only allowed constructor.
/// It only calls startWorkInAThread() with the four params.
/// \param macroNumber
/// \param macroPath
/// \param macBox
/// \param macText
///
MacroReader(int macroNumber, QString macroPath, QPlainTextEdit* macBox, QPlainTextEdit* macText);
~MacroReader();
//////////
/// \brief startWorkInAThread This member function creates the new thread object and starts it with the four params.
/// \param macroNumber
/// \param macroPath
/// \param macBox
/// \param macText
///
void startWorkInAThread(int macroNumber, QString macroPath, QPlainTextEdit* macBox, QPlainTextEdit* macText);
signals: