quassel.git
5 years agotypes: Add STL-compliant Hash functor for Qt types
Manuel Nickschas [Mon, 15 Oct 2018 19:22:04 +0000 (21:22 +0200)]
types: Add STL-compliant Hash functor for Qt types

In order to use Qt types with std::unordered_set (and map), a
compatible hash function needs to be provided. Provide a generic
Hash<T> functor that just uses the qHash() function for the given
type.

This can be used as follows:
    std::unordered_set<QString, Hash<QString>> set;

5 years agotests: Add unit test for basic SignalProxy functionality
Manuel Nickschas [Thu, 4 Oct 2018 20:16:50 +0000 (22:16 +0200)]
tests: Add unit test for basic SignalProxy functionality

Add unit test cases for attached signals as well as syncable objects.
These test cases don't check for error behavior (yet); they mostly
are intended for ensuring that the upcoming refactoring of the
SignalProxy does not affect the format on the wire. As such, the test
cases mostly focus on the protocol messages sent by invoking
SignalProxy and SyncableObject functionality.

5 years agotest: Add a spy type that waits for one or more signals
Manuel Nickschas [Thu, 4 Oct 2018 19:10:13 +0000 (21:10 +0200)]
test: Add a spy type that waits for one or more signals

Introducing SignalSpy that allows to wait for one or more signals
to be emitted in test cases. Unlike QSignalSpy, it is not bound to
a particular signal on construction; instead, one has to explicitly
connect one or more signal(s) before calling wait().

5 years agotest: Add a way to mock peers for SignalProxy-related test cases
Manuel Nickschas [Thu, 4 Oct 2018 17:03:02 +0000 (19:03 +0200)]
test: Add a way to mock peers for SignalProxy-related test cases

Introduce a new mock class MockedPeer that allows for setting
expectations for dispatched Quassel protocol messages. Also provide
matchers to express such expectations in a straightforward way.

MockedPeer for now only supports SignalProxy messages; support for
authentication messages can be added later if needed. Note that
expectations can be set on the level of protocol messages, but things
like a testing a particular serialization, the use of network sockets,
or other lower-level implementation details are not supported, nor is
MockedPeer intended for such use cases (we'd expect specific tests for
specific peer types).

5 years agotest: Add GTest printers for commonly used Qt types
Manuel Nickschas [Thu, 4 Oct 2018 16:59:59 +0000 (18:59 +0200)]
test: Add GTest printers for commonly used Qt types

Because GTest by default prints out unknown types as hexdump or other
badly readably formats, provide PrintTo functions for Qt types we use
in tests. That way, GTest will use those instead of falling back to
its own default.

Reuse Qt's own QDebug stream support to avoid having to reimplement
printing functionality for all the types. This makes it very easy
to see e.g. the contents of a QVariantMap or other complex types.

5 years agotest: Add InvocationSpy and ValueSpy helper classes
Manuel Nickschas [Thu, 4 Oct 2018 16:40:23 +0000 (18:40 +0200)]
test: Add InvocationSpy and ValueSpy helper classes

For test cases testing asynchronous operations that require a running
event loop, it is convenient to have a way to wait until something
happens. Qt provides QSignalSpy to wait for a specific signal while
spinning the event loop. This is not always convenient to use, though.

Provide InvocationSpy and ValueSpy (based on QSignalSpy) that provide
an explicit way of notifying them, without having to connect a signal
first. Unlike QSignalSpy, those classes also time out when not notified
within a given time span.

Put those classes in a new library Quassel::Test::Util, which will
gain more testing-related utils over time.

5 years agotest: Introduce Quassel::Test::Global library
Manuel Nickschas [Sun, 30 Sep 2018 20:11:56 +0000 (22:11 +0200)]
test: Introduce Quassel::Test::Global library

Move things that are needed in every test case into a new library,
rather than requiring the Test::Main one (which is not going to be
linked to other test tooling which we'll introduce).

5 years agomodernize: Remove custom Quassel-specific log macros
Manuel Nickschas [Sun, 14 Oct 2018 22:49:57 +0000 (00:49 +0200)]
modernize: Remove custom Quassel-specific log macros

The quInfo(), quWarning(), quError() macros were introduced a long
time ago to provide custom log message handling, such as logging to
file or syslog. Such features have been directly supported for the
standard Qt log macros for a while now, using a global message handler.
The only reason for Quassel's custom macros to still exist was the
lack of an info log level prior to Qt 5.5.

As we can now rely on Qt 5.5 to be available, replace the custom
macros by Qt ones, and remove LogMessage which is no longer needed.

5 years agomodernize: Remove Uncrustify config and script
Manuel Nickschas [Mon, 24 Sep 2018 22:42:00 +0000 (00:42 +0200)]
modernize: Remove Uncrustify config and script

Since we can now use clang-format for formatting the code, and
provide a .clang-format ruleset in the repository, we can remove
the ancient Uncrustify configuration and script.

5 years agomodernize: Reformat ALL the source... again!
Manuel Nickschas [Mon, 24 Sep 2018 22:13:14 +0000 (00:13 +0200)]
modernize: Reformat ALL the source... again!

It's been more than six years since we last used an autoformatter
on the codebase. Tooling has progressed, so has the language and
of course our personal preferences.

Use clang-format this time to reformat the whole codebase, following
the rules laid out in .clang-format (which one can use for configuring
an IDE, too, if it supports autoformatting). Overall, the new style
is not too different from what we used before, with one significant
change:

We now attach pointer/reference indicators (*&) to the type rather
than the name, i.e. we left-align. While this is a major deviation
from the Qt style which we use for almost everything else, it aligns
more closely with many other projects, as well as the C++
documentation and STL. It also makes more sense semantically,
because */& are really part of the type.

Other changes include (but are not limited to):

- Use only one blank line between function definitions
- Categorize includes from generic/system to local, sorting each
  category alphabetically. The generic-to-local sort order seems to
  be more common than the other way round, so we use that.
- In .cpp files, the corresponding header is always included first.
  This is a general recommendation, because it makes it harder to
  accidentally introduce a reliance on transitive includes in headers.
- Consistently break initializers in ctors before the comma, so the
  commas are left-aligned together with the colon.
- Use two spaces between code and trailing comments.

Note that sometimes even clang-format gets things wrong. In a few
places, formatting was manually fixed; however, reviewing a diff of
almost 80k lines is a rather boring task, so we didn't thoroughly
go through all the changes. Wrong formatting can always be fixed
in follow-up commits, anyway.

Note also that we don't intend to re-run clang-format on a regular
basis, nor do we want to religiously follow a hardcoded set of rules
for new code in the future. Where it makes sense, the rules may be
bent in favor of better readability or more pleasing code.

5 years agocmake: Add build-time dependency to Boost 1.56
Manuel Nickschas [Mon, 24 Sep 2018 19:55:42 +0000 (21:55 +0200)]
cmake: Add build-time dependency to Boost 1.56

We'll be using some Boost features in the future, so prepare the
build system to reflect that dependency.

5 years agotravis: Reduce ccache size
Manuel Nickschas [Mon, 24 Sep 2018 19:26:35 +0000 (21:26 +0200)]
travis: Reduce ccache size

Reduce the ccache size in order to not waste too much time packing/
extracting the cache. Since we're only building one project, 1G should
be plenty.

5 years agotests: Enable tests in Travis
Manuel Nickschas [Mon, 24 Sep 2018 19:04:30 +0000 (21:04 +0200)]
tests: Enable tests in Travis

Build Quassel with -DBUILD_TESTING=ON and run the tests as part of
the CI build.

5 years agotests: Convert ExpressionMatchTests into a GTest-based test case
Manuel Nickschas [Mon, 24 Sep 2018 18:42:51 +0000 (20:42 +0200)]
tests: Convert ExpressionMatchTests into a GTest-based test case

As first contender for the newly introduced test framework, use
the recently added ExpressionMatchTests class. Convert to use
GTest, and move into the new home for Quassel unit tests (the
tests/<module>/ directory).

With this, "make test" (or "ninja test") actually does something
if Quassel is configured with -DBUILD_TESTING=ON.

5 years agotest: Add build system support and a main function for unit tests
Manuel Nickschas [Mon, 24 Sep 2018 18:36:21 +0000 (20:36 +0200)]
test: Add build system support and a main function for unit tests

Add a new CMake option BUILD_TESTING (defaults to OFF) that, if
enabled, will build unit tests and related requirements.

Add a new library Quassel::Test::Main that provides a main function
for test cases.

Add a new CMake macro quassel_add_test for making the adding of test
cases convenient by hiding most of the boilerplate.

Test cases should #include "testglobal.h", so they automatically have
access to GTest/GMock macros as well as the imported main function.

5 years agotest: Bundle GTest/GMock 1.8.1 sources and provide a find script
Manuel Nickschas [Mon, 24 Sep 2018 18:30:25 +0000 (20:30 +0200)]
test: Bundle GTest/GMock 1.8.1 sources and provide a find script

GTest/GMock is a unit testing framework that we want to use for
writing unit tests for Quassel in the future. Since Google
recommends building the test libraries with the same flags and
settings as the code under test, we should build them as part of
Quassel's build process rather than relying on system-provided
libraries.

Because most distros don't seem to package the GTest/GMock sources,
bundle them with Quassel. The upstream sources are unmodified,
although the set of files shipped is trimmed down significantly
in order to not needlessly blow up the repo size.

Provide FindGTest.cmake, which builds the libraries from the
bundled sources.

5 years agomodernize: Require member function pointers for Settings::notify()
Manuel Nickschas [Wed, 19 Sep 2018 22:54:21 +0000 (00:54 +0200)]
modernize: Require member function pointers for Settings::notify()

Require member function pointers for Settings::notify() and
Settings::initAndNotify(). This brings us one step closer to being
SLOT-free.

5 years agomodernize: Remove old-style slot usage in NetworkModelController
Manuel Nickschas [Wed, 19 Sep 2018 19:05:08 +0000 (21:05 +0200)]
modernize: Remove old-style slot usage in NetworkModelController

Use member function pointers in NetworkModelController and related
classes, instead of old-style slots and invokeMethod().

5 years agomodernize: Don't use apparent connect-by-name slots in MainWin
Manuel Nickschas [Tue, 18 Sep 2018 21:48:08 +0000 (23:48 +0200)]
modernize: Don't use apparent connect-by-name slots in MainWin

Rename slots named "on_*" to follow our naming conventions, and avoid
association with the very old and very discouraged connect-by-name
feature in Qt (also known as "auto-connection slots"). MainWin doesn't
even use this feature, so we should not confuse casual readers.

5 years agomodernize: Migrate action-related things to PMF connects
Manuel Nickschas [Tue, 18 Sep 2018 21:37:02 +0000 (23:37 +0200)]
modernize: Migrate action-related things to PMF connects

In our quest to get rid of the deprecated use of slots, refactor
Action and ActionCollection to require pointer-to-member-function
connects. Ensure nobody accidentally still uses SLOT through a static
assertion.

Add a convenience function to ActionCollection for adding lists of
actions. While we're at it, also rework ActionCollection's optional
KDE Frameworks support to simplify things.

Adapt the rest of the code accordingly.

5 years agouisupport: Provide helpers for dealing with widget changes
Manuel Nickschas [Mon, 17 Sep 2018 21:42:37 +0000 (23:42 +0200)]
uisupport: Provide helpers for dealing with widget changes

In many places, we want to connect to a widget's changed signal,
i.e. a signal that is emitted whenever the widget changes. This
requires a great deal of boilerplate especially in settingspages,
since the signal to listen to varies between widget types.

Provide helpers that automate most of this by matching the given
widget against a static list of supported widgets' changed signals,
and connecting automatically. A sprinkle of template magic makes
it very easy to support a bunch of different widget types in a generic
way.

Make use of this feature to get rid of the remaining old-style
connects in SettingsPage. Also migrate a couple of specific
settingspages as proof-of-concept and API validation; others
can follow over time.

5 years agocommon: Provide helper for getting member function traits
Manuel Nickschas [Mon, 17 Sep 2018 21:39:37 +0000 (23:39 +0200)]
common: Provide helper for getting member function traits

Add a new header funchelpers.h that contains helpers for dealing
with member function traits. MemberFunction<Callable> provides
the class, return and argument types of the given Callable, as well
as a compatible std::function type.

5 years agomodernize: Replace most remaining old-style connects by PMF ones
Manuel Nickschas [Wed, 12 Sep 2018 17:45:13 +0000 (19:45 +0200)]
modernize: Replace most remaining old-style connects by PMF ones

Manually replace old-style connects (using the SIGNAL/SLOT macros)
by the much more efficient and typesafe pointer-to-member-function-
based ones.

This fixes the cases where clazy could not auto-migrate to the new
syntax for a variety of reasons. In most of the cases, we need to
remove overloads or explicitly select the desired one, because the
plain syntax cannot deal with overloads. Another issue is trying
to connect to signals in a baseclass that are only declared in a
derived class (which works with the old-style runtime connection
handling, but obviously no longer with the compile-time version).

Also do some selected cleanups in places.

5 years agocommon: Provide helper for resolving overloaded function pointers
Manuel Nickschas [Mon, 10 Sep 2018 20:12:44 +0000 (22:12 +0200)]
common: Provide helper for resolving overloaded function pointers

The pointer-to-member-function connect syntax cannot directly deal
with overloaded method signatures. Provide a helper to avoid ugly
static_cast incantations:

  #include "util.h"
  connect(this, selectOverload<int, QString>(&MyClass::mySignal), other, &Other::mySlot);

This helper can be used for both signals and slots.

5 years agoqtui: Fix initialization order after switching to PMF connects
Manuel Nickschas [Thu, 13 Sep 2018 21:35:29 +0000 (23:35 +0200)]
qtui: Fix initialization order after switching to PMF connects

Seems like switching to PMF connections has changed the order signals
are processed in, resulting in the UI being initialized after the
session manager asks for saving the UI state (for whatever reason).

Make this less fragile (and avoid a crash when using KDE) by
connecting to the session manager only after initializing the UI, and
replace the initUi() slot by a lambda while we're at it.

5 years agoclazy: Convert many old-style connects into function pointer based
Manuel Nickschas [Mon, 10 Sep 2018 16:38:20 +0000 (18:38 +0200)]
clazy: Convert many old-style connects into function pointer based

Since Qt5, signal/slot connections can be expressed using function
pointers rather than the SIGNAL/SLOT macros. This is a) much more
efficient, and b) provides a compile-time check for the sender
and receiver being compatible.

Let clazy auto-fix old-style connects where it can. However, a lot of
occurrences remain where we'll need manual intervention for one
reason or another.

5 years agomodernize: Use ranged-for loops in some obvious cases
Manuel Nickschas [Sun, 9 Sep 2018 22:11:38 +0000 (00:11 +0200)]
modernize: Use ranged-for loops in some obvious cases

Some old-style loops can be automatically converted by clang-tidy
to use ranged-for.

5 years agomodernize: Use 'while(true)' instead of 'while(1)'
Manuel Nickschas [Sun, 9 Sep 2018 22:04:49 +0000 (00:04 +0200)]
modernize: Use 'while(true)' instead of 'while(1)'

5 years agomodernize: Use std::make_unique
Manuel Nickschas [Sun, 9 Sep 2018 22:04:11 +0000 (00:04 +0200)]
modernize: Use std::make_unique

5 years agomodernize: Use C++ versions of system headers
Manuel Nickschas [Sun, 9 Sep 2018 22:02:03 +0000 (00:02 +0200)]
modernize: Use C++ versions of system headers

System headers ending on .h are deprecated; use the c* version
instead.

5 years agomodernize: Use raw string literals instead of escaped strings
Manuel Nickschas [Sun, 9 Sep 2018 21:37:56 +0000 (23:37 +0200)]
modernize: Use raw string literals instead of escaped strings

Replace escaped strings with raw string literals in places where
it makes sense, and doesn't confuse lupdate.

5 years agomodernize: Use braced-init list when returning types
Manuel Nickschas [Sun, 9 Sep 2018 21:20:09 +0000 (23:20 +0200)]
modernize: Use braced-init list when returning types

5 years agomodernize: Use auto where the type is clear from context
Manuel Nickschas [Sun, 9 Sep 2018 20:44:18 +0000 (22:44 +0200)]
modernize: Use auto where the type is clear from context

Apply clang-tidy's modernize-use-auto fix, which uses auto where
the type would otherwise be duplicated in the line (e.g. when casting
a type, or creating an instance with 'new').

5 years agomodernize: Use '= default' instead of empty ctor/dtor bodies
Manuel Nickschas [Thu, 6 Sep 2018 23:08:09 +0000 (01:08 +0200)]
modernize: Use '= default' instead of empty ctor/dtor bodies

Also remove lots of unnecessary, empty ctors and dtors.

5 years agomodernize: Prefer default member init over ctor init
Manuel Nickschas [Thu, 6 Sep 2018 20:43:39 +0000 (22:43 +0200)]
modernize: Prefer default member init over ctor init

Where appropriate, initialize class members in the header rather
than in the constructor.

5 years agomodernize: Pass arguments by value and move in constructors
Manuel Nickschas [Thu, 6 Sep 2018 19:01:22 +0000 (21:01 +0200)]
modernize: Pass arguments by value and move in constructors

If a method (or constructor) wants to store an argument in a local
variable or attribute, one should prefer passing it in by value
and moving it into the final location, rather than taking a
const reference and copying it over. In the best case, this saves
one copy, if the method is called with an rvalue.

This pattern is most frequent in constructors initializing class
members, so let clang-tidy fix this for argument types that have
move constructors.

5 years agomodernize: Use 'using' instead of 'typedef'
Manuel Nickschas [Thu, 6 Sep 2018 17:47:17 +0000 (19:47 +0200)]
modernize: Use 'using' instead of 'typedef'

5 years agomodernize: Use override instead of virtual
Manuel Nickschas [Wed, 5 Sep 2018 22:36:28 +0000 (00:36 +0200)]
modernize: Use override instead of virtual

Let clang-tidy fix all occurrences where override should be used
instead of virtual. Also, let it annotate member functions where
virtual was missing in the first place.

5 years agomodernize: Use nullptr
Manuel Nickschas [Wed, 5 Sep 2018 22:09:45 +0000 (00:09 +0200)]
modernize: Use nullptr

Let clang-tidy fix all occurrences where nullptr should be used
instead of 0.

5 years agoclang-tidy: Mark several settingspage methods as final
Manuel Nickschas [Tue, 4 Sep 2018 22:56:14 +0000 (00:56 +0200)]
clang-tidy: Mark several settingspage methods as final

To avoid warnings about calling virtual methods during construction,
mark affected methods as final. It's legitimate to call things like
load() from their ctors as long as nobody inherits from them.

5 years agoclang-tidy: Don't call virtual methods from CoreAccountModel's ctor
Manuel Nickschas [Tue, 4 Sep 2018 22:36:11 +0000 (00:36 +0200)]
clang-tidy: Don't call virtual methods from CoreAccountModel's ctor

5 years agocmake: Build shared libraries (DLLs) on Windows
Manuel Nickschas [Sun, 2 Sep 2018 21:29:43 +0000 (23:29 +0200)]
cmake: Build shared libraries (DLLs) on Windows

Since symbols are now properly marked for export, we can finally
enable the building of DLLs on Windows.

5 years agocmake: Make symbols hidden by default on GCC/Clang
Manuel Nickschas [Sun, 2 Sep 2018 21:26:24 +0000 (23:26 +0200)]
cmake: Make symbols hidden by default on GCC/Clang

With symbols now being explicitly marked as exported where needed,
there is no need to globally export all symbols anymore.
Tell CMake to set the appropriate compiler flags
(i.e. -fvisibility=hidden) for GCC and Clang so, they only export
requested symbols.

5 years agosrc: Mark symbols to be exported where needed
Manuel Nickschas [Sun, 2 Sep 2018 21:34:36 +0000 (23:34 +0200)]
src: Mark symbols to be exported where needed

Generate export headers for the Quassel modules, and mark all
relevant classes and function to be exported so that shared libraries
can be linked against without globally exporting all symbols.
This is a hard requirement for Windows DLLs, and more efficient on
other platforms, too.

For now, this was done incrementally until everything linked properly.
In the future, we may consider explicitly defining the public
interfaces for each module, and trying to minimize the linker
interface e.g. by PIMPLing.

5 years agocmake: Support generation of export headers
Manuel Nickschas [Sun, 2 Sep 2018 21:06:18 +0000 (23:06 +0200)]
cmake: Support generation of export headers

For using shared libraries without globally exporting all symbols,
one has to explicitly mark classes and free functions to be exported.
This is more efficient on platforms like Linux (enabling the use
of -fvisibility=hidden on GCC/Clang), and a hard requirement for
using DLLs on Windows (which don't support global export at all).

Extend the quassel_add_module() macro with an optional EXPORT
argument, which, if provided, uses CMake's built-in support for
generating an export header that provides macros for exporting
symbols. The same macro will also import the marked symbols when
building against a library.

While we're at it, also fix the install rule to use the proper
install locations for RUNTIME/LIBRARY/ARCHIVE target types.

5 years agosigproxy: Don't expose the thread_local '_current' attribute
Manuel Nickschas [Sun, 2 Sep 2018 21:23:06 +0000 (23:23 +0200)]
sigproxy: Don't expose the thread_local '_current' attribute

Windows does not allow exporting thread_local attributes in the
DLL interface. Since it's not good practice anyway to expose such
an implementation detail in the public header, make the accessor
non-inline and move the attribute into a private anonymous namespace,
removing it from the public interface.

5 years agouisupport: Let ClickableList inherit from std::vector instead of QList
Manuel Nickschas [Sun, 2 Sep 2018 21:18:40 +0000 (23:18 +0200)]
uisupport: Let ClickableList inherit from std::vector instead of QList

Apparently, a class inheriting from a QList specialization cannot
be properly exported, while this works fine when inheriting from
std::vector instead. Since we now prefer std containers over Qt's
anyway, changing the baseclass is a Good Thing™ either way, so
just do it.

5 years agoqtui: Add debug dialog for showing the resource file tree
Manuel Nickschas [Wed, 29 Aug 2018 18:38:31 +0000 (20:38 +0200)]
qtui: Add debug dialog for showing the resource file tree

Add a dialog in the debug menu that shows the compiled-in
resource files. This is useful for checking that resource generation
and loading works properly.

5 years agocommon: Simplify SyncableObject macros and usage
Manuel Nickschas [Thu, 23 Aug 2018 21:40:36 +0000 (23:40 +0200)]
common: Simplify SyncableObject macros and usage

Since the C++11 standard defines "__func__", and modern versions
of MSVC support this, we can remove the workaround for MSVC from
the SyncableObject macros. It is no longer necessary to derive
the function name from MSVC's __FUNCTION__ (which contains the
enclosing class name), and thus the _classNameOffset__ function
declared by the SYNCABLE_OBJECT macro is no longer needed.

Repurpose the macro to define the syncMetaObject() member function
instead, and remove the no-longer needed INIT_SYNCABLE_OBJECT
macro.
The syncMetaObject() function is used by the signal proxy for
accessing the metaObject() of the base class in case there are
client- or core-specific specializations of a syncable object;
i.e. if you have Foo directly inheriting from SyncableObject,
and ClientFoo derived from Foo, the function must only be
declared in Foo, otherwise syncing won't work.

Thus, the SYNCABLE_OBJECT macro declares the function as final,
so it can't be accidentally overridden.

While we're at it, replace include guards with #pragma once in
files we touched.

5 years agoqa: Remove lots of superfluous semicolons
Manuel Nickschas [Wed, 22 Aug 2018 19:15:11 +0000 (21:15 +0200)]
qa: Remove lots of superfluous semicolons

Since we have now enabled -Wpedantic, the compiler warns us about
superfluous semicolons, of which we apparently have a lot.
Remove them.

5 years agocmake: Reorder slightly for consistency
Manuel Nickschas [Wed, 29 Aug 2018 16:17:26 +0000 (18:17 +0200)]
cmake: Reorder slightly for consistency

Other modules link the main dependencies before caring about
options, so do the same for the core module.

5 years agocmake: Link resources statically, and init locally
Manuel Nickschas [Wed, 29 Aug 2018 16:15:47 +0000 (18:15 +0200)]
cmake: Link resources statically, and init locally

Link resource libraries statically in order to avoid problems with
symbol exporting. Move resource initialization from main() into the
respective libraries.

5 years agocmake: Add support for static libs to quassel_add_module
Manuel Nickschas [Wed, 29 Aug 2018 16:10:56 +0000 (18:10 +0200)]
cmake: Add support for static libs to quassel_add_module

We'll need this for building resource libraries, which we can't
easily export symbols from (and which also are not used more than
once).

5 years agocmake: Build shared libraries
Manuel Nickschas [Wed, 22 Aug 2018 21:47:22 +0000 (23:47 +0200)]
cmake: Build shared libraries

The days of static builds are finally over. Build dynamic libraries
for all Quassel modules.

Let CMake handle the RPATH in a way that doesn't cause inconvenience;
always set an RPATH in the build tree so the correct libraries
are loaded, and also set an RPATH for installed binaries unless
they go into a system location.

Also define output directories for all build artifacts.

5 years agocmake: Modernize compile settings; require C++14
Manuel Nickschas [Wed, 22 Aug 2018 18:15:50 +0000 (20:15 +0200)]
cmake: Modernize compile settings; require C++14

Clean up QuasselCompileSettings.cmake, treat GNU and Clang the same.
Use add_compile_options() instead of CMAKE_CXX_FLAGS. Curate the list
of compiler flags, and add sensible linker flags, too.

Check explicitly for required compiler features using CMake's
target_compile_features(), rather than hard-coding compiler versions.
The set of required features basically implies that we now require
a C++14 compiler (even though the new stuff isn't used in the code
yet).

5 years agocmake: Build Windows icon resource again
Manuel Nickschas [Tue, 21 Aug 2018 22:29:17 +0000 (00:29 +0200)]
cmake: Build Windows icon resource again

Building the Windows resource got lost while refactoring the build
system, so bring it back.

5 years agocmake: Modernize translation generation
Manuel Nickschas [Tue, 21 Aug 2018 21:31:45 +0000 (23:31 +0200)]
cmake: Modernize translation generation

Refactor and modernize the CMake support for translation generation.
Properly use targets, custom commands and dependencies to ensure that
files are only regenerated when needed, and avoid useless rebuilds.

Avoid individual invocations of lupdate and lrelease, which both
support processing multiple files at once.

Make use of the newly added quassel_add_resource function instead of
building the .qrc file explicitly.

Fix LINGUAS support, which was previously not working as intended.

5 years agocmake: Autogenerate most of the .qrc resource files
Manuel Nickschas [Wed, 15 Aug 2018 23:35:09 +0000 (01:35 +0200)]
cmake: Autogenerate most of the .qrc resource files

With the CMake support from the previous commit, resource files
can now be autogenerated. Do this for almost all resources;
the hicolor one is special because it uses aliases, and the i18n
one requires more work that is going to be added in a follow-up
commit.

Combine several of the previous resources (e.g. different icon sets)
to reduce complexity. This wasn't possible previously due to the
various configuration-specific combinations, but can now be done
dynamically by extending the glob patterns accordingly.

5 years agocmake: Add support for generating .qrc files
Manuel Nickschas [Wed, 15 Aug 2018 23:25:43 +0000 (01:25 +0200)]
cmake: Add support for generating .qrc files

Most .qrc files we use just map the (partial) contents of a
directory, so that can be autogenerated. Provide CMake functions
that support this endeavour to remove the need of regenerating
resource files if directory contents changes.

Since RCC is stupid, some hacks are required to make this work,
so we can't use either autorcc nor qt5_add_resource(); we must
invoke RCC manually. Clever use of targets and custom commands
as well as external CMake script invocation ensures that the .qrc
files are always up to date even if files change, while avoiding
useless rebuilds (as is currently still the case for i18n).

5 years agocmake: Fix source-specific compile definitions
Manuel Nickschas [Mon, 13 Aug 2018 21:50:24 +0000 (23:50 +0200)]
cmake: Fix source-specific compile definitions

set_source_files_properties() overwrites previously specified
properties and does not have a way to append, which is bad when
e.g. conditionally adding multiple compile definitions to a file.
In this particular case, for main.cpp -DHAVE_UMASK would overwrite
-DEMBED_DATA, and thus resources would not be loaded.

Use set_property(SOURCE... APPEND PROPERTY...) instead.

5 years agocmake: Modernize cmake support for LDAP
Manuel Nickschas [Wed, 8 Aug 2018 20:22:39 +0000 (22:22 +0200)]
cmake: Modernize cmake support for LDAP

Use a more modern, property-based find script for the LDAP libraries
and get rid of the deprecated use of LDAP_LIBRARIES and similar
variables in favor of a namespaced Ldap::Ldap target.
Set package properties for better diagnostic output at configure time.

5 years agocmake: Reorganize package finding
Manuel Nickschas [Mon, 6 Aug 2018 21:35:00 +0000 (23:35 +0200)]
cmake: Reorganize package finding

Use COMPONENTS to find required Qt5 modules in one go.
Don't look for QtWebKit if we already have QtWebEngine.
Look for Sonnet explicitly even when using KDE Frameworks, because
we're using its config widget and shouldn't rely on transitivity
here.
Only look for LDAP when building the core (or mono client).
Add QUIET everywhere to avoid spammy CMake warnings for optional
packages.
Add some diagnostic output indicating the versions of Qt and KF5.

5 years agocmake: Remove some compiler flags that are no longer needed
Manuel Nickschas [Mon, 6 Aug 2018 21:27:10 +0000 (23:27 +0200)]
cmake: Remove some compiler flags that are no longer needed

With the move to a property-based build system, we no longer need
special handling of -fPIC for Qt.

Also remove some things related to old KDE and CMake.

5 years agocmake: Set -DHAVE_UMASK only where it's needed
Manuel Nickschas [Mon, 6 Aug 2018 21:19:52 +0000 (23:19 +0200)]
cmake: Set -DHAVE_UMASK only where it's needed

Avoid setting this define globally when it's only used in two
files.

5 years agocmake: Remove boilerplate from HAVE_SSL check
Manuel Nickschas [Thu, 2 Aug 2018 23:32:35 +0000 (01:32 +0200)]
cmake: Remove boilerplate from HAVE_SSL check

Instead of setting flags and includes manually (potentially
polluting global variables), just link the test program to
Qt5::Core directly and rely on property propagation.

5 years agocmake: Modernize use of Qt Linguist Tools
Manuel Nickschas [Thu, 2 Aug 2018 23:11:08 +0000 (01:11 +0200)]
cmake: Modernize use of Qt Linguist Tools

All Qt versions we support provide an alias target for the linguist
tools. Thus, remove the fallback for older Qt versions.

Use the LOCATION property of the tools' target instead of relying
on the corresponding QT_L*_EXECUTABLE variables.

5 years agocmake: Modernize build system
Manuel Nickschas [Thu, 2 Aug 2018 21:16:22 +0000 (23:16 +0200)]
cmake: Modernize build system

Move to the modern, property-based way of using CMake. This
simplifies a lot of things:
 - No need to manually specify interface include dirs and libraries
   of dependencies
 - No need to carry around variables
 - Clear separation of local and global dependencies and definitions
 - No need for hacks to make the triple-executable thing work

Provide convenience functions to set up library and executable
targets. This will make it very easy in the future to split up
some modules, as well as move towards using shared libraries.

Use the modern, property-based way of using Qt, too. This removes
the need for the deprecated qt5_use_modules() macro, and a bunch
of manual things we had to do to get the compile flags right
for the different Quassel executables.
Also make use of CMake's AUTOUIC and AUTORCC to avoid a bunch of
boilerplate for dealing with .ui files and Qt resources.

Move the .ui files from their subdirectory into the qtui directory,
since the separation doesn't really make too much sense. We'd rather
want to split the QtUi module into smaller parts/libraries.

Remove a bunch of unnecessary stuff from the CMake files.

5 years agocmake: Remove custom build types
Manuel Nickschas [Wed, 1 Aug 2018 20:12:09 +0000 (22:12 +0200)]
cmake: Remove custom build types

The non-standard build types DebugFull and Profile (which we took
from KDE4) are not supported by e.g. Qt, so remove them.

Improve build type handling; show the supported values in CMake GUIs
and provide a sensible default if none is given (Release unless
a .git directory is present, in which case Debug is default).

5 years agocmake: Remove support for building static binaries
Manuel Nickschas [Tue, 31 Jul 2018 21:14:16 +0000 (23:14 +0200)]
cmake: Remove support for building static binaries

Building and running static binaries has become increasingly
difficult on modern systems, in particular when involving
complex libraries like Qt due to their reliance on plugins and
other dynamically loaded resources. It is also a security risk,
as upgrades to system libraries won't apply to the static binary.

Having a static quasselcore binary was quite useful when it was
hard to get Qt on an X11-less box, but these days all major distros
support modular Qt, and can provide Quasselcore packages that
don't require graphical dependencies. Consequently, we no longer
intend to offer static binaries.

Thus, remove the corresponding hacks from the build system.

5 years agocmake: Use official CMake config for QCA
Manuel Nickschas [Tue, 31 Jul 2018 20:18:05 +0000 (22:18 +0200)]
cmake: Use official CMake config for QCA

QCA has been shipping with a CMake config for a while, so use this
rather than providing a custom find module. Remove the custom
modules, as well as FindLibraryWithDebug.cmake which was only used
by them.

Move KeyEvent from common into core, since it's only used there.

5 years agocmake: Use official FindBacktrace rather than custom FindExecInfo
Manuel Nickschas [Tue, 31 Jul 2018 19:16:32 +0000 (21:16 +0200)]
cmake: Use official FindBacktrace rather than custom FindExecInfo

Newer versions of CMake ship their own FindBacktrace.cmake module,
which replaces the FindExecInfo.cmake module so far shipped by
Quassel. The official module is also a bit more thorough in terms
of cross-platform support.

To avoid duplication, remove Quassel's custom find module and use
the official one instead.

5 years agocmake: Bump minimum required CMake version to 3.5
Manuel Nickschas [Wed, 25 Jul 2018 22:47:13 +0000 (00:47 +0200)]
cmake: Bump minimum required CMake version to 3.5

This is the version shipped with Ubuntu 16.04 "Xenial", so
use this as a minimum requirement.

5 years agocmake: Only require a C++ compiler
Manuel Nickschas [Wed, 25 Jul 2018 20:49:27 +0000 (22:49 +0200)]
cmake: Only require a C++ compiler

With miniz gone, the only reason to still specify both C and CXX
as project languages is the use of the check_include_file cmake
macro.

Turns out there's a C++ version of that one, too; so use it.

5 years agocmake: Make zlib a required dependency, remove bundled miniz
Manuel Nickschas [Wed, 25 Jul 2018 21:59:57 +0000 (23:59 +0200)]
cmake: Make zlib a required dependency, remove bundled miniz

These days, zlib should be easily available on all platforms we
support, so make it a required dependency. This allows for removing
the bundled drop-in replacement miniz.

5 years agocommon: Rework command line option handling
Manuel Nickschas [Mon, 30 Jul 2018 22:15:52 +0000 (00:15 +0200)]
common: Rework command line option handling

Since we can now rely on Qt5's QCommandLineParser, there is
no longer a need for an abstraction for command line parsing.
Use QCommandLineParser directly, and remove the now obsolete
AbstractCliParser and its various implementations.

Move command line parsing into Quassel::init(), which allows for
using translated strings. Make user-visible strings translateable.

Remove the long-deprecated --datadir option for now (may come
back if we decide to allow for specifying the database location
independently of config files).

5 years agocommon: Initialize translations in Quassel::init()
Manuel Nickschas [Thu, 26 Jul 2018 20:58:40 +0000 (22:58 +0200)]
common: Initialize translations in Quassel::init()

In order to have localized strings during initialization, e.g. for
command line options, the translation catalogue must be loaded
early.

Since at this point the UI configuration is not available yet,
the system locale is used. QtUi will reload translations afterwards
later if a language different from the system locale is configured
for the UI.

5 years agoqt4-b-gone: Initialize data dir paths on demand
Manuel Nickschas [Thu, 26 Jul 2018 20:07:24 +0000 (22:07 +0200)]
qt4-b-gone: Initialize data dir paths on demand

Since special handling for KDE4 data locations was removed, it is
no longer required to set the paths from the outside. Simply
initialize the paths on first use.

5 years agoqt4-b-gone: Reorganize the initialization sequence
Manuel Nickschas [Thu, 26 Jul 2018 19:21:40 +0000 (21:21 +0200)]
qt4-b-gone: Reorganize the initialization sequence

KDE4 required special handling during initialization, because command
line arguments needed to be parsed before instantiating the
application object. Since this is no longer required, the sequence
can now be simplified.

To prepare for enabling early translations (also for the CLI parser),
instantiate the application first, then explicitly initialize the
Quassel instance in main() (which will later both load translations,
and handle CLI options). Only then also initialize the application
itself.

Since initialization errors are handled by exceptions anyway, get rid
of the return values for the various init() methods, too.

5 years agoqt4-b-gone: Remove bundled sha512 implementation
Manuel Nickschas [Tue, 17 Jul 2018 23:00:58 +0000 (01:00 +0200)]
qt4-b-gone: Remove bundled sha512 implementation

Qt5 supports SHA512 natively, so we no longer need to ship an
external implementation.

5 years agoqt4-b-gone: Remove all code supporting Qt < 5.5 and KDE4
Manuel Nickschas [Tue, 17 Jul 2018 22:42:45 +0000 (00:42 +0200)]
qt4-b-gone: Remove all code supporting Qt < 5.5 and KDE4

Remove compatibility code for Qt versions we no longer support.

5 years agoqt4-b-gone: Remove support for Phonon
Manuel Nickschas [Tue, 17 Jul 2018 20:11:01 +0000 (22:11 +0200)]
qt4-b-gone: Remove support for Phonon

Phonon is superseded by QtMultimedia, which offers everything we need
for playing audio notifications.

5 years agoqt4-b-gone: Remove support for libindicate
Manuel Nickschas [Tue, 17 Jul 2018 20:07:03 +0000 (22:07 +0200)]
qt4-b-gone: Remove support for libindicate

libindicate-qt only exists for the dead Qt4, so remove support
for it.

5 years agocmake: Bump minimum required version of Qt to 5.5.0
Manuel Nickschas [Tue, 17 Jul 2018 21:23:27 +0000 (23:23 +0200)]
cmake: Bump minimum required version of Qt to 5.5.0

This version of Qt is provided in Ubuntu "Xenial" 16.04, which is our
new baseline for distro support.

5 years agocmake: Remove build system support for Qt4/KDE4
Manuel Nickschas [Mon, 16 Jul 2018 22:11:57 +0000 (00:11 +0200)]
cmake: Remove build system support for Qt4/KDE4

In our quest to modernize the codebase, remove support for the
long-dead Qt4 libraries (and consequently, also for integration
into KDE4) from the build system.

5 years agotravis: Add bionic as target distro
Manuel Nickschas [Mon, 18 Jun 2018 17:50:49 +0000 (19:50 +0200)]
travis: Add bionic as target distro

This allows us to test building Quassel against a recent release
of Ubuntu, as well.

5 years agotravis: Add jobs for building against KDE Frameworks
Manuel Nickschas [Mon, 18 Jun 2018 17:27:15 +0000 (19:27 +0200)]
travis: Add jobs for building against KDE Frameworks

Define CMake options in a more generic way, and use this to define
builds against KDE Frameworks.

5 years agotravis: Use docker-based builds, new baseline
Manuel Nickschas [Sun, 17 Jun 2018 17:52:12 +0000 (19:52 +0200)]
travis: Use docker-based builds, new baseline

Perform Linux builds in docker images, which allows us to freely
define the build environment rather than relying on the Travis host
system.

Use Ubuntu 16.04 "Xenial" as the new baseline for Quassel, allowing
us to make use of a more modern toolchain.

Reorganize and modernize travis.yml in general.

5 years agoPost-release version bump 0.14-pre
Manuel Nickschas [Sat, 17 Nov 2018 19:49:54 +0000 (20:49 +0100)]
Post-release version bump

5 years agoBump version for release 0.13.0
Manuel Nickschas [Thu, 15 Nov 2018 23:46:16 +0000 (00:46 +0100)]
Bump version for release

5 years agoUpdate ChangeLog
Manuel Nickschas [Thu, 15 Nov 2018 23:44:51 +0000 (00:44 +0100)]
Update ChangeLog

5 years agoMinor cleanup of BufferView
Manuel Nickschas [Fri, 16 Nov 2018 19:04:01 +0000 (20:04 +0100)]
Minor cleanup of BufferView

Fix some nitpicks.

5 years agoAllow selecting the search result when searching for buffers
Martin T. H. Sandsmark [Mon, 29 Oct 2018 11:52:17 +0000 (12:52 +0100)]
Allow selecting the search result when searching for buffers

If multiple buffers are displayed when filtering by name, allow
selecting one of the using the up/down keys. This makes it possible
to jump to a buffer other than the topmost.

5 years agocommon: Fix syncing of BufferViewManager
Manuel Nickschas [Wed, 7 Nov 2018 20:01:39 +0000 (21:01 +0100)]
common: Fix syncing of BufferViewManager

Two syncable methods where accidentally demoted from being slots,
so adding/removing buffer views would not be synced anymore.

Fix this by making those methods slots again.

5 years agoqtui: Make the debug log a proper dialog
Manuel Nickschas [Tue, 6 Nov 2018 22:46:33 +0000 (23:46 +0100)]
qtui: Make the debug log a proper dialog

For some reason unbeknownst and shrouded in ancient mystery, the
debug log was displayed in a naked widget, which caused it to not
be rendered in a window when using not-so-smart window managers
(such as Windows™).

Make the debug log a proper dialog, and also fix the close button
not being part of a platform-agnostic QDialogButtonBox, while we're
at it.

5 years agocore: Avoid Clang warning for inconsistent override
Manuel Nickschas [Thu, 1 Nov 2018 09:09:35 +0000 (10:09 +0100)]
core: Avoid Clang warning for inconsistent override

5 years agoircuser: Fix setting of away message time by pre-0.13 cores
Manuel Nickschas [Tue, 30 Oct 2018 16:26:43 +0000 (17:26 +0100)]
ircuser: Fix setting of away message time by pre-0.13 cores

IrcUser::setLastAwayMessage() is called by pre-0.13 cores (newer
cores call setLastAwayMessageTime() instead). Fix wrong use of
QDateTime::from[M]SecsSinceEpoch(), which is a static method returning
a new QDateTime instance rather than a modifying setter.

Also fix signatures passing primitive types as const refs.

5 years agoqtui: Disable web preview by default
Manuel Nickschas [Tue, 30 Oct 2018 19:07:44 +0000 (20:07 +0100)]
qtui: Disable web preview by default

Upon popular request, disable the web preview by default. This
feature tends to surprise unwitting new users that just happen
to hover over a questionable link, and the preview's functionality
is limited anyway with today's complex websites.

The web preview can still be enabled explicitly in chatview settings.
Existing configurations are unaffected by this change.

5 years agoFix the order of the Davids
David ‘Bombe’ Roden [Mon, 22 Oct 2018 14:04:16 +0000 (16:04 +0200)]
Fix the order of the Davids

5 years agoBump version for release 0.13-rc2 build/0.13-rc2
Manuel Nickschas [Mon, 15 Oct 2018 17:51:51 +0000 (19:51 +0200)]
Bump version for release

5 years agoUpdate ChangeLog
Manuel Nickschas [Mon, 15 Oct 2018 17:51:00 +0000 (19:51 +0200)]
Update ChangeLog