Commit graph

29 commits

Author SHA1 Message Date
Vadim Peretokin
b6738dd8c2
infrastructure: Apply clang-format to all CPP files (#8804)
#### Brief overview of PR changes/additions
Ran clang-format on all 134 CPP files in src/ using the project's
.clang-format config

#### Motivation for adding to Mudlet
Ensures consistent code formatting across the codebase.

#### Other info (issues closed, discussion etc)
None

**Test case:** Build the project and verify it compiles successfully.
2026-01-19 18:10:44 +01:00
Vadim Peretokin
9aab5cfc2a
Improve: Modernize color trigger dialog button handling (#8693)
#### Brief overview of PR changes/additions

Replaces the deprecated `QSignalMapper` class with modern lambda
functions in the Color Trigger dialog.

#### Motivation for adding to Mudlet

`QSignalMapper` has been deprecated since Qt 5.10 and the codebase had a
TODO comment requesting this modernization.

#### Other info (issues closed, discussion etc)

**Testing instructions:**
1. Open the Trigger Editor
2. Create a new trigger and set its type to "color trigger" 
3. Click the foreground or background color button to open the Color
Trigger dialog
4. Verify all 16 basic color buttons (Black through Light White) work
correctly when clicked
5. Confirm the dialog closes and the selected color is applied to the
trigger

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-27 11:24:43 +01:00
Zooka
7f05b267f5
improve: remove qt5 checks (#7736)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
     the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Attempt to remove all obsolete qt5 checks.

#### Motivation for adding to Mudlet
Migrate to qt6.

#### Other info (issues closed, discussion etc)

---------

Co-authored-by: Vadim Peretokin <vadi2@users.noreply.github.com>
2025-02-24 06:59:51 +01:00
Stephen Lyons
208adb4b8c
Fix: correct QSignalMapper usage for Qt6 (#7420)
#### Brief overview of PR changes/additions
Revise some signal names to handled changes made in Qt 5.15 and demanded
(because old named signals have been removed) in Qt 6, for
`QSignalMapper`.

#### Motivation for adding to Mudlet
Prevent error messages and problems with a signal-slot connection not
working for user-actions added to the 2D mapper context menu and the
fore-/back-ground colour selection buttons in colour triggers.

#### Other info (issues closed, discussion etc)
`QSignalMapper` has been depreciated in Qt6 as the functionality it
proved can now be done in C++ lamda functions - however making such
changes requires a firm understanding of how each of them works and in
the meantime it is less complex to just use the functor form of the
`connect(...)` - to replace the obsolete `const char[]` form and to use
the newer names that are supported from Qt version **5.15.0**.

I pointed out this issue in our Discord "#mudlet-development" channel at
[2024/08/03 21:16
UTC](https://canary.discord.com/channels/283581582550237184/283582439002210305/1280637687552020510).

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
2024-09-12 12:39:47 +01:00
Stephen Lyons
00f35a6ebf
Fix: invalid grey QColor generated for grey-scale part of color triggers (#6995)
#### Motivation for adding to Mudlet
There is supposed to be a label that demonstrates the grey value
selected when the "More colors" button is clicked for a color trigger
item and the 24 position slider is adjusted. This color is also supposed
to be replaced in the foreground or background colour set for the color
trigger and is recorded as part of the details for a color trigger.

#### Brief overview of PR changes/additions
However, a defect in #5328 seems to have been based on the
"slider-value" being passed to `(void)
dlgColorTrigger::slot_grayColorChanged(int)` being in the range 232 to
255 rather than the 0 to 23 that it is. The result is that the QColor
generated from that grey scale part of the ANSI 256 color range is wrong
(invalid). This at least means that the grey color chosen does not show
up in the editor - it also may mean that such color triggers may be
defective and not work as expected.

#### Other info (issues closed, discussion etc)
The previous PR that introduced this bug is over 2 years old - I guess
it was not something that rates more than a **low** priority - but it is
a one-liner to fix! 😀

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
2023-10-21 22:48:02 +02:00
TachyonicBytes
e0bab9363b
Infrastructure: update tr() annotation style (#6862)
#### Brief overview of PR changes/additions
Update the tr() annotation style, as discussed in #5522 
#### Motivation for adding to Mudlet
Makes the code cleaner and also keeps Mudlet in tune with the latest
standards.
#### Other info (issues closed, discussion etc)
/claim #5522

---------

Co-authored-by: TachyonicBytes <support@tachyonicbytes.com>
Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2023-05-29 21:03:34 +02:00
Vadim Peretokin
ff3ae8de4c
Infrastructure: mark read-only variables as const (#6843)
<!-- Keep the title short & concise so anyone non-technical can
understand it,
     the title appears in PTB changelogs -->
#### Brief overview of PR changes/additions
Mark read-only variables as const - that is, not intended to change
after they've been declared
#### Motivation for adding to Mudlet
So we don't change them by accident later on, and also to clearly state
intentions for the variables
#### Other info (issues closed, discussion etc)
This is also recommended by the [C++ Core
Guidelines](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#es25-declare-an-object-const-or-constexpr-unless-you-want-to-modify-its-value-later-on)
2023-05-14 15:06:15 +02:00
Kebap
e832e70f29
Infrastructure: rename pF -> pParentWidget & fix some whitespace layouts (#6379)
#### Brief overview of PR changes/additions
make variable name more readable 

#### Motivation for adding to Mudlet
Improve readability

#### Other info (issues closed, discussion etc)
Fix #6375

Co-authored-by: Stephen Lyons <slysven@virginmedia.com>
2022-11-14 10:14:16 +01:00
Stephen Lyons
0671a62dd0
Infrastructure: replace qsl(...) used for Tooltips (#5694)
Specifically when it is used to put HTML like tags around the text so that it
triggers the "rich-text" detector in the Qt libraries so that the tips gets
better formatting than being a single (long) line of plain text.

Whilst working on this PR I also spotted and fixed:
* A couple of raw strings in the `VarUnit` class that should have been
translated (or replaced with a `QString()`) - this required adding the
`Q_DECLARE_TR_FUNCTIONS(`className`)` macro to that class as it is not
derived from the `QObject` class which we normally use to provide the
`QObject::tr(`...`)` method.
* The tooltip for the "Save item" button in the editor contained a
unmatched `<p>`...`</p>` tag pair as well as a useless (as it is ignored
there) `\n` {Line Feed}.
* The tooltip for the "Save profile" button in the editor contained a
unmatched `<p>`...`</p>` tag pair.
* I had previously defined the `QT_NO_CAST_FROM_ASCII` and
`QT_NO_CAST_TO_ASCII` macros in the `dlgRoomExits` class but they are
no longer considered useful for us so I have removed those Qt macros.
* The `utils::richText(`...`)` wraper has exactly the same code effect as
the `(const QString) singleParagraph` helper function in the `dlgRoomExits`
class - so it has been replaced by that.

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
Co-authored-by: Vadim Peretokin <vperetokin@gmail.com>
2021-12-26 15:22:05 +00:00
Vadim Peretokin
39a91d3bdf
Infrastructure: Add short qsl macro to stand in for 'QStringLiteral' (#5640) 2021-12-07 06:21:39 +01:00
Vadim Peretokin
b9cb18ca89
Fix 160 typos in C++ code (#5387) 2021-08-22 08:01:05 +02:00
Tomas Seniunas
63a50ea611
Adjusted the 256 color conversion to match other clients (#5328) 2021-08-08 09:42:38 +02:00
Kebap
b42921b6ee
Improve some texts for translations (#5186)
* Remove path/filename from translations

* "Remove packages" as plural

* untangle texts, settle "format version"

* Split more texts

* get rid of double "this"
2021-04-19 08:07:25 +02:00
atari2600tim
b3822ad279
Typo fixes (#5070)
* Update dlgTriggerEditor.cpp

* Update TRoomDB.cpp

* Update TRoomDB.cpp

* Update dlgProfilePreferences.cpp

* Update dlgAboutDialog.cpp

* Update TTextEdit.cpp

* Update dlgColorTrigger.cpp

* Update profile_preferences.ui

* Update TTextEdit.cpp

* Update timers_main_area.ui

* Update triggers_main_area.ui

* Update dlgProfilePreferences.cpp

* Update dlgProfilePreferences.cpp

* Update scripts_main_area.ui
2021-03-29 16:34:23 +02:00
Vadim Peretokin
bdca23acb4
React when the button has been pressed and released (#4486)
Instead of just pressed and not released yet, which is incorrect
2020-12-16 19:40:59 +01:00
Stephen Lyons
160d30a9e2
Refactor: clean up TBuffer text format aspects (#1840)
This is the edited summary of a squash and merge of 14 commits:

Adds support for SGR Reverse (swap foreground and background colours)
"7"/"27" for On/Off and SGR Overline "53"/"55" for On/Off

Remove unused cruft:
* (void) TTextEdit::drawFrame(QPainter&, const QRect&)
* (void) TTextEdit::updateLastLine
* const QChar cLF & cSPACE in TBuffer (as it happens they are completely
  unused and redundant as the enum QChar::SpecialCharacter provides
  QChar::LineFeed and QChar::Space to provide the same constants)
* (QTime) TBuffer::mTime
* (void) TConsole::echoUserWindow(const QString&)
* (QPoint) TBuffer::insert(QPoint&, const QString&, int, int, int,
                           int, int, int, bool, bool, bool, bool)
* (void) TConsole::printDebug(...) functionally the same as one type of
  (void) TConsole::print(...) just with a different order of arguments.

Convert #define constants TCHAR_BOLD etc. into a QFLag/enum
TChar::AttributeFlags which is declared and capable of QFlag OR operations.

Refactor a number of methods that take lots of bools and ints as individual
formatting options and colour components to take single
TChar::AttributeFlags and one or two QColors instead.

Remove a large number of (int) colour value component values as member
variables in TBuffer as they are not needed.

Convert highly repetitive intermediate methods to setBold, setItalics etc.
to take a (combinations allowed) TChar::Attribute flag value instead.

Convert 2x3 int as colour components (r,g,b) in TColorTable defined in
TTrigger class to a pair of QColors.

Remove unused QString argument from:
* (void) mudlet::setLink(...)
* (void) TConsole::setLink(...)

Remove unused QColor argument from:
* (inline void) TTextEdit::drawCharacters(...)

Refactor arguments in:
*(QString) TBuffer::bufferToHtml(QPoint P1, QPoint P2,
                              bool allowedTimestamps, int spacePadding = 0)
to:
 (QString) TBuffer::bufferToHtml(const bool showTimeStamp = false,
                              const int row = -1, const int endColumn = -1,
                          const int startColumn = 0,  int spacePadding = 0)

Convert to const references some method arguments.

Add TBuffer::set[BF]gColor(...) overloads that take a QColor argument.
Add selection state methods select()/deselect()/isSelected() const methods
to TChar class to hide/separate the selection process from the formatting
effect. (TChar::Reverse tracks the ANSI SGR reverse colour attribute and
its effect is EX-ORed with the (bool) TChar::mIsSelected flag).

Add a new tempAnsiColorTrigger lua function that, unlike tempColorTrigger
uses the correct ANSIcolors in the range 0-15 - although the original also
handles the 256 colour range in the 16-255 correctly those first 16 values
are miss-mapped and it is not possible to change them without breakage.

Adds 256-color support to Editor GUI for color triggers - and allows
choosing the default (unmodified) fore or background colors to match one
(the previous did not) and also allows one of the fore or background color
to be ignored so only the other is considered. The ignored color case is
saved in the profile data and can exported but MAY not work in previous
Mudlet versions which cannot handle the value used! It is also reported as
an error to have a color trigger with both fore and background ignored in
both the lua functions and in the GUI.

Also:
Fixed a code structure issue in TLuaInterpreter::debug() which would not
work correctly if there was more than one value on the lua stack to print
out.

This will close issues #477 and #703.

Converted some `QObject::connect` calls to the new Qt5 compile time
version.

Removed an unused `TTrigger*` argument from
`dlgColorTrigger::setupBasicButtons(...)`.

Removed an unused flag:
* `(bool) TConsole::mSaveLayoutRequested

Also spotted some dead code from abandoned attempt to support blinking,
some reordering that a new version of Qt spotted as needed in the TBuffer
and TChar constructor initialisation lists, and a operator precedence item
that could be clarified with an addition pair of `(`...`)`s.

A previous error in the prior PR that this one is attempting to replace
had a problem in HTML generation that I reproduced here and which needed
the same fix (a missing escaped `"` mark).

An upgraded Qt Creator pointed out to me some initiliser list issues in
`TBuffer` and `TConsole`; and some C-style casts in some font settings in
the latter class.

Remove a debugging output line that is not useful now and will be spammy.

Modernise a triplet of QObject::connect(...) calls that will otherwise
clash harder when merged into development after "upgrade-to-qt5-connect"
PR has also been merged into the main branch.

Also:
* add some explanation/help text to the dlgColorTrigger dialog.
* revise the text explaining the formula (232 + grey scale value 0..23)
used for colours from the 24 grey-scale part of the 256 colour range.
* add some tool-tips to parts of the dlgColorTrigger dialog.
* add a generic static method to the mudlet class to provide a consistent
and re-usable "HTML" wrapper around text - which will be particularly
useful for tool-tip generation.

Revise: change colour trigger UI to hide colours 16-255 by default

This follows a suggestion from a peer in the review process.

Update: add Wiki documentation link comment

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
2019-01-28 23:23:53 +00:00
Vadim Peretokin
cb0935b426
Optimised imports in Mudlet. (#1703) 2018-05-31 07:13:32 +02:00
Vadim Peretokin
ba6e4af346
Fixed up a few clazy warnings (#1641)
Biggest ones were:

1. https://github.com/KDE/clazy/blob/master/src/checks/level2/README-qstring-allocations.md
1. https://github.com/KDE/clazy/blob/master/src/checks/level2/README-old-style-connect.md
2018-05-14 18:30:48 +02:00
Ahmed Charles
a28a1734b3 Subset of clang-format changes. (#965) 2017-04-27 03:55:38 -07:00
Ahmed Charles
d0dc31dfc3 Run clang-format on headers. 2017-04-14 03:45:58 -07:00
Ahmed Charles
9b4f547e46 Revert "Formatting: applied anti-ClangFormat guards around pre/post_guard.h includes"
This reverts commit 272970e62f.
2017-04-14 03:45:58 -07:00
Stephen Lyons
272970e62f
Formatting: applied anti-ClangFormat guards around pre/post_guard.h includes
clang-format has an option to sort header #include lines in source code
files - however the `#include "pre_guard.h"` and `#include "post_guard.h"`
includes are position sensitive - they must wrap around Qt's own classes'
includes in our files and they must not be tidied-up/rearranged.

This commit adds the necessary comments that commands clang tools to not
touch these lines.

We had previously done this on the XMLimport class as a test case but
during recent major branch merging operations one of these comments was
lost from the XMLimport.cpp file!

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
2017-04-13 14:00:23 +01:00
Stephen Lyons
7bf8b9379a bugfix: typos in dlgColorTrigger messes up cyan and lWhite triggers
Found these the hard way - in use - and it meant that one could not specify
a colour trigger to fire on cyan or light white (grey ?) - one of which was
just the colour I needed for a Mud that I had returned to after it had come
back after being off-line for more than six months - I'd always wondered
why I could never get my WoTMUD (now at game.wotmud.org:2224) room name
trigger to work...!

Using gitk blame it transpires that this bug dates to 03/11/2009 and
predates Mudlet version 1.0.1 !

Signed-off-by: Stephen Lyons <slysven@virginmedia.com>
2015-01-06 15:22:00 +00:00
Ahmed Charles
3989340fcd Rearrange includes to improve compile times.
This also allows for memory leak checking on MSVC by having include
surrounding Qt headers, which break if you have a macro define new
to be something which tracks line information.
2014-08-17 14:46:54 -07:00
heiko
6597b6f268 color triggers pattern|tempColorTriggers|isAnsiColor|Manual upgrade 2009-11-04 00:33:42 +01:00
heiko
f2b1920748 Fix: connect to already loaded profiles is save now 2009-07-11 17:25:26 +02:00
heiko
8321f42e4c mac analysis patch 2009-07-04 02:23:21 +02:00
heiko
5c52d88f65 Color Triggers Final | MAC OSX patch: make Trigger Editor
moveable/resizable on Macs
2009-05-23 21:29:08 +02:00
heiko
aa80f8d0c7 Feature: timestamps with milliseconds support | added credits for Ben
Carlson for the MAC OSX installer
2009-05-22 19:32:47 +02:00