Skip to content

Commit

Permalink
PR (#2)
Browse files Browse the repository at this point in the history
* Save window size

* Also save window position

* Use provided settings database

* Create watch

watch file to be used by uscan(1)

* Create cool-retro-term.1

a manpage

* Update 3270 terminal font

* Updated install of needed packages for Ubuntu 16.10

* Removed duplicated packages from Ubuntu 16.10

* add comment listing bugs in --help option output

* add --version, aka -v, command line option

* typo

* version 1.0

* Create .travis.yml

* Update .travis.yml

* Install libgl-dev

* Install libgl1-mesa-dev

* Upload to transfer.sh

* Use linuxdeployqt-3-x86_64.AppImage

* -qmldir=./app/qml/ -qmldir=./qmltermwidget/

* linuxdeployqt-3-x86_64.AppImage

* Debug why some qml imports do not get deployed

* Update .travis.yml

* find /opt/qt58/ | grep QtGraphicalEffects

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* Update .travis.yml

* update change log for a first upload (sponsoring)

how it should be for a first official Debian package

* Try to reduce workarounds fpr

* Use linuxdeployqt-continuous-x86_64.AppImage for now

* update copyright years

* See if we still need 2 runs

* Update .travis.yml

* fix typos

* Gentoo overlay source change note

* fixed markdown headings

* Update README.md

added Ubuntu 17.04 dependencies

* Create snapcraft.yaml

* Updated 3278 font and associated files

* Update submodule to include fix for High Sierra.

* Bump version to 1.0.1.

* Gentoo package version bump announced

* Updated OS X → macOS

* Add some GIFs?

* Make screenshot sizes in appdata XML match actual image sizes

* Improve manpage: add description and missing options, improve formatting

* cool-retro-term made it to Fedora official repos

* Instrucitons for ubuntu 17.10. Fixes Swordfish90#396

* Update readme

Periods, amirite?

* Change apt-get to apt, and added stretch.

* Add a -T option that sets window title.

`cool-retro-term -T myretrosession` sets window name to 'myretrosession'

This is useful especially for people who rely on wmctrl to change windows, now I
can do `wmctrl -a myretrocession` to focus on cool-retro-term.

-T was chosen since it matches classic xterm(1) and other terminal emulators

* add Debian Stretch to dependency instructions

I've confirmed that the same instructions for Jessie also work for Stretch

* Added Debian Stretch dependencies

In addition to what Debian Jessie needs, Stretch also needs qml-module-qt-labs-settings and qml-module-qt-labs-folderlistmodel
These packages are not needed to build cool-retro-term, but they are needed to run it.

* Add Knight TV font.  As used by the MIT AI Lab.

* Add a Knight TV profile.

* Ubuntu 17.10 PPA

* Increase baseScaling font for knight profile to improve consistency.

* Add a description of the -T option to the man page

* Fix alphabetically incorrect ordering of options in man page

* Preparing for PR.

* fix alt(meta), ctrl for emacs on macos

* update submodule

* Update snapcraft.yaml

* merging stuff

* Delete snapcraft.yaml

* Update snapcraft.yaml

* Update snapcraft.yaml

* Update snapcraft.yaml

* Update snapcraft.yaml

* Update snapcraft.yaml

* Update with v2.0.0 - new glyphs, better hinting

* Update README.md

* Track unstable qmltermwidget branch.

* Initial support for system monospace fonts.

* Slight improvements to burnin and rgb shift effects.

* Fix wrong bottom texture clamping.

* Slight improvements to brunin look.

* Update and replace fonts.

* Fix some alignment related warnings.

* RGB Shift effect now looks much better.

* Improve bloom effect. This is more pronounced in very bright areas.

* Add subpixels rasterization and improve existing ones.

* Further improve rgbShift effect. Now can be enabled without chroma color.

* Slightly change rgb shift values.

* Fix wrong gamma colors when using chroma.

* Important burn-in optimization. It is much lighter on resources.

* Unload burnin effect when not in use.

* Fix masking issue with new burn in.

* Make jitter stronger on the x axis.

* Fix screen brightness consistency in some scenarios.

* Fix small issue with burnin masking.

* Fix division by zero when no effects were selected.

* Change mask value to use greyscale color instead of max channel.

* Revert "Add subpixels rasterization and improve existing ones."

Use something similar to what we had before, avoiding heavy texture
fetches."

This reverts commit 293b05f.

* Update snapcraft.yaml

* Update snapcraft.yaml

* Reduce default font size.

* Make font sizes more consistent.

* Increase maximum amount of bloom allowed.

* Update snapcraft.yaml

* Update snapcraft.yaml

* Scanlines no longer affect background. Less artifacts at low fontSize values.

* Update terminus font.

* Handle db upgrades and prepare work for old profiles deprecation.

* Update snapcraft.yaml

* Revert "Handle db upgrades and prepare work for old profiles deprecation."

This reverts commit 6fb8ceb.

* Handle database and profile upgrade for new versions.

* Fix a couple of issues with burnIn.

* Update snapcraft.yaml

* Avoid border artifacts on burn in effect.

* Hide by default menubar on linux.

* Limit screen curvature effect.

* Fixed fontColor conversion applied two times.

* Update README.md

Make it easier for the eye to pick up the instructions for the various Linux distros.  Presently, the eye skips over them and all you see are the Ubuntu things.  Also adjusted the help text a little.

* Update defualt profiles.

* Custom command should be a setting not a profile.

* Bump version code.

* Update qmltermwidget submodule.

* Change version and description of snap package.

* First implementation of imageless frame.

* Add inner screen shadow. Various overall frame improvements.

* Remove useless frame settings.

* First wrong framebuffer implementation.

* Use window scaling parameter for framebuffer size.

* Split effects into static (cached) and dynamic computed at every frame.

* Reduce default fps to 20. It looks good with new burnin and saves some gpu.

* Rearrange settings window.

* Tweak some shader constants.

* Change default curvature values.

* Unload frame when not needed.

* Move frame to separate framebuffer. This fixes some glitches in terminal
frame.

* Allow screen margin customization.

* Improve settings layout.

* Force integer values for new margins.

* Let's reenable smoothing in burnin to see which artifact is actually better.

* Remove comment.

* Change the way margin is used. This slightly improves quality.

* Change burnin masking function to max. Should preseve darker colors.

* Reduce horizontal sync maximum strength.

* Revert "Change burnin masking function to max. Should preseve darker colors."

This reverts commit 3cee186.

* Reduce horizontal sync possible minimum value.

* Update README.md

* new ebuild available for 1.1.0

* Fixes issue Swordfish90#491.

* Fix Swordfish90#336

* Upload to GitHub Releases

Need to set a GITHUB_TOKEN environment variable in https://travis-ci.org/Swordfish90/cool-retro-term/settings

* usr/share/metainfo

As per https://www.freedesktop.org/software/appstream/docs/chap-Quickstart.html#sect-Quickstart-DesktopApps, usr/share/metainfo should be used

* correct version number output with --version

* Settings optin for old burinin version. It seems to be working better on osx.

* Improve highdpi support.

* Use threaded renderer by default in linux. This improves performances.

* Use a single version name.

* Fix font slider misbehaving.

* Bump version number.

* Update snapcraft file.

* Update snap package to use core18.

* Fix snap package launcher and expose in path qml directory.

* Print system font log only when verbose is enabled.

* Update README.md

* Remove snapcraft plugs. Not used for classic confinement.

* Adds installation instruction for Solus

* Add FreeBSD installation instructions

* Fix typo in README.md

* Add two missing qt dependencies to snapcraft.yaml

* new ebuild available for 1.1.1

* Update README.md

added installation method via Hombrew

* Update qmltermwidget submodule with CTRL+SPACE fix.

* Update qmltermwidget submodule

* Add support for blinking cursor

* Disable blinking cursor by default

* Update Readme - Trizen for Arch - Yaourt is deprecated.

yaourt is deprecated.  Use trizen instead.  The command line arguments are identical to yaourt, for easy migration.

* Add installation instructions using Homebrew

I was not aware there was a [Homebrew cask](https://github.com/Homebrew/homebrew-cask/blob/master/Casks/cool-retro-term.rb) for this
project, which simplifies installation on macOS. This commit adds
documentation for installing the app via Homebrew.

* now packaged in the official repository

* Update Readme.md to include directions to settings

Several users of OS's without titlebars or window decor have expressed confusion at how one change's their theme (in this case, via the context menu). Mentioning how to access the menu in the Readme will make the settings more accessible and prevent any future confusion. It might be more appropriate to create a "Use" heading exploring features such as Performance settings, but for the sake of brevity, I've just inserted a mention at the end of the description, before more OS-specific install instructions.

* Adding snap install method

Adding snap install method which is supported in most of the distros and is easy!

* git ignore app/moc_predefs.h

* squelch ugly quotes on 1st line of cool-retro-term --usage

* send cool-retro-term --help and --version to stdout

* allow --help/-h/--version/-v options without graphics

* Bump qmltermwidget submodule.

Co-authored-by: Alex Spataru <alex_spataru@outlook.com>
Co-authored-by: Alex <alex@aiei.ch>
Co-authored-by: Filippo Scognamiglio <flscogna@gmail.com>
Co-authored-by: Ricardo Banffy <rbanffy@gmail.com>
Co-authored-by: Jan Schäfer <j@nschaefer.net>
Co-authored-by: Barak A. Pearlmutter <barak+git@pearlmutter.net>
Co-authored-by: probonopd <probonopd@users.noreply.github.com>
Co-authored-by: Tamás Gérczei <tamas@gerczei.eu>
Co-authored-by: Matthias Balke <matthias.balke@googlemail.com>
Co-authored-by: Stewart C. Russell <scruss@scruss.com>
Co-authored-by: kz6fittycent <jimmy.tigert@gmail.com>
Co-authored-by: Filippo Scognamiglio <filippo.scognamiglio@funambol.com>
Co-authored-by: Lee Reilly <lee@github.com>
Co-authored-by: suve <veg@svgames.pl>
Co-authored-by: Miro Hrončok <miro@hroncok.cz>
Co-authored-by: Lars Falk-Petersen <lars.falk-petersen@copyleft.no>
Co-authored-by: maiki <maiki@interi.org>
Co-authored-by: mason1920 <mkukosky@outlook.com>
Co-authored-by: Christiano Haesbaert <haesbaert@haesbaert.org>
Co-authored-by: Alex Von Hoene <avh.on1@gmail.com>
Co-authored-by: Lars Brinkhoff <lars@nocrew.org>
Co-authored-by: Tom Chiverton <tomchiverton@users.noreply.github.com>
Co-authored-by: spuch <picospuch@gmail.com>
Co-authored-by: mason1920 <42262007+mason1920@users.noreply.github.com>
Co-authored-by: Darryl T. Agostinelli <dagostinelli@users.noreply.github.com>
Co-authored-by: Sascha Paunovic <azarus@posteo.net>
Co-authored-by: mclang <Jani.Long@gmail.com>
Co-authored-by: Mateusz Piotrowski <0mp@FreeBSD.org>
Co-authored-by: timm0e <11885527+timm0e@users.noreply.github.com>
Co-authored-by: Haradric <nikita.braslavskiy@gmail.com>
Co-authored-by: Kristian <ga53jey@mytum.de>
Co-authored-by: Jay Kuri <jayk@ionzero.com>
Co-authored-by: ayazhafiz <ayaz.hafiz.1@gmail.com>
Co-authored-by: AutumnalAntlers <45282916+AutumnalAntlers@users.noreply.github.com>
Co-authored-by: Amir Fo <pwwiur@yahoo.com>
  • Loading branch information
1 parent 69d35a7 commit 4b98521
Show file tree
Hide file tree
Showing 84 changed files with 2,925 additions and 1,639 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*.pro.user.*
*.moc
moc_*.cpp
moc_*.h
qrc_*.cpp
ui_*.h
Makefile*
Expand Down
1 change: 1 addition & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[submodule "qmltermwidget"]
path = qmltermwidget
url = https://github.com/Swordfish90/qmltermwidget
branch = unstable
37 changes: 37 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
sudo: required
dist: trusty
language: c++

install:
- sudo add-apt-repository -y ppa:beineri/opt-qt58-trusty
- sudo apt-get update -qq
- sudo apt-get -y install build-essential qt58declarative qt58graphicaleffects qt58quickcontrols libgl1-mesa-dev
- source /opt/qt*/bin/qt*-env.sh

script:
- qmake CONFIG+=release PREFIX=/usr
- make -j$(nproc)
- mkdir -p appdir/usr/share/metainfo appdir/usr/bin
- cp packaging/appdata/cool-retro-term.appdata.xml appdir/usr/share/metainfo/
- cp cool-retro-term appdir/usr/bin/
- cp ./cool-retro-term.desktop appdir/
- cp ./app/icons/128x128/cool-retro-term.png appdir/
- cp -r ./app/qml appdir/usr/
- cp -r ./qmltermwidget/QMLTermWidget appdir/usr/qml/ # Workaround for https://github.com/probonopd/linuxdeployqt/issues/78
- wget -c https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage
- chmod a+x linuxdeployqt-*.AppImage
- unset QTDIR; unset QT_PLUGIN_PATH ; unset LD_LIBRARY_PATH
- export VERSION=$(git rev-parse --short HEAD) # linuxdeployqt uses this for naming the file
- ./linuxdeployqt-*.AppImage appdir/usr/bin/cool-retro-term -qmldir=./app/qml/ -qmldir=./qmltermwidget/ # -verbose=3 2>&1 | grep "path:" -C 3
- ./linuxdeployqt-*.AppImage appdir/usr/bin/cool-retro-term -qmldir=./app/qml/ -qmldir=./qmltermwidget/ -verbose=2 -appimage

after_success:
- find appdir -executable -type f -exec ldd {} \; | grep " => /usr" | cut -d " " -f 2-3 | sort | uniq
- # curl --upload-file Cool*.AppImage https://transfer.sh/Cool_Retro_Term-git.$(git rev-parse --short HEAD)-x86_64.AppImage
- wget -c https://github.com/probonopd/uploadtool/raw/master/upload.sh
- bash upload.sh Cool*.AppImage*

branches:
except:
- # Do not build tags that we create when we upload to GitHub Releases
- /^(?i:continuous)/
116 changes: 87 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,51 +1,79 @@
#cool-retro-term
# cool-retro-term

##Description
|> Default Amber|C:\ IBM DOS|$ Default Green|
|---|---|---|
|![Default Amber Cool Retro Term](https://user-images.githubusercontent.com/121322/32070717-16708784-ba42-11e7-8572-a8fcc10d7f7d.gif)|![IBM DOS](https://user-images.githubusercontent.com/121322/32070716-16567e5c-ba42-11e7-9e64-ba96dfe9b64d.gif)|![Default Green Cool Retro Term](https://user-images.githubusercontent.com/121322/32070715-163a1c94-ba42-11e7-80bb-41fbf10fc634.gif)|

## Description
cool-retro-term is a terminal emulator which mimics the look and feel of the old cathode tube screens.
It has been designed to be eye-candy, customizable, and reasonably lightweight.

It uses the QML port of qtermwidget (Konsole) developed by me: https://github.com/Swordfish90/qmltermwidget .

This terminal emulator works under Linux and OSX and requires Qt 5.2 or higher.
This terminal emulator works under Linux and macOS and requires Qt 5.2 or higher.

Settings such as colors, fonts, and effects can be accessed via context menu.

## Screenshots
![Image](<https://i.imgur.com/TNumkDn.png>)
![Image](<https://i.imgur.com/hfjWOM4.png>)
![Image](<https://i.imgur.com/GYRDPzJ.jpg>)

## Install
Walk the easy way and install cool-retro-term using one of these convenient packages:

Just grab the latest AppImage from the release page and make it executable and run it:

##Screenshots
![Image](<http://i.imgur.com/I6wq1cC.png>)
![Image](<http://i.imgur.com/12EqlpL.png>)
![Image](<http://i.imgur.com/Lx0acQz.jpg>)
wget https://github.com/Swordfish90/cool-retro-term/releases/download/1.1.1/Cool-Retro-Term-1.1.1-x86_64.AppImage
chmod a+x Cool-Retro-Term-1.1.1-x86_64.AppImage
./Cool-Retro-Term-1.1.1-x86_64.AppImage

##Get cool-retro-term
You can either build cool-retro-term yourself (see below) or walk the easy way and install one of these packages:
**Fedora** has the `cool-retro-term` in the official repositories. All you have to do is `sudo dnf install cool-retro-term`.

Users of Fedora and openSUSE can grab a package from [Open Build Service](http://software.opensuse.org/package/cool-retro-term).
Users of **openSUSE** can grab a package from [Open Build Service](http://software.opensuse.org/package/cool-retro-term).

Arch users can install this [package](https://aur.archlinux.org/packages/cool-retro-term-git/) directly via the [AUR](https://aur.archlinux.org):
**Arch** users can install this [package](https://aur.archlinux.org/packages/cool-retro-term-git/) directly via the [AUR](https://aur.archlinux.org):

yaourt -S aur/cool-retro-term-git
trizen -S aur/cool-retro-term-git

or use:

pacman -S cool-retro-term

to install precompiled from community repository.

Gentoo users can now install the first release "1.0" from a 3rd-party repository preferably via layman:
Users of **Ubuntu 14.04 LTS (Trusty) up to 15.10 (Wily)** can use [this PPA](https://launchpad.net/~bugs-launchpad-net-falkensweb).

**Ubuntu 17.10** can use [this PPA](https://launchpad.net/%7Evantuz/+archive/ubuntu/cool-retro-term)

**Solus** users can install using `eopg`:
```
eopkg it cool-retro-term
```

**macOS** users can grab the latest dmg from the [release page](https://github.com/Swordfish90/cool-retro-term/releases) or install via Homebrew:
```
brew cask install cool-retro-term
```

USE="subversion git" emerge app-portage/layman
wget https://www.gerczei.eu/files/gerczei.xml -O /etc/layman/overlays/gerczei.xml
layman -f -a qt -a gerczei # those who've added the repo already should sync instead via 'layman -s gerczei'
ACCEPT_KEYWORDS="~*" emerge =x11-terms/cool-retro-term-1.0.0-r1::gerczei
**FreeBSD** users can install cool-retro-term with `pkg`:

The live ebuild (version 9999-r1) tracking the bleeding-edge WIP codebase also remains available.
pkg install cool-retro-term

## Build instructions (FreeBSD)

A word of warning: USE flags and keywords are to be added to portage's configuration files and every emerge operation should be executed with '-p' (short option for --pretend) appended to the command line first as per best practice!
Grab a copy of [the FreeBSD Ports Collection](https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/ports-using.html), modify [`/usr/ports/x11/cool-retro-term/Makefile`](https://svnweb.freebsd.org/ports/head/x11/cool-retro-term/Makefile?view=markup) as you like, and then run `make install` to build and install the emulator:

Ubuntu users of 14.04 LTS (Trusty) up to 15.10 (Wily) can use [this PPA](https://launchpad.net/~bugs-launchpad-net-falkensweb)
```
cd /usr/ports/x11/cool-retro-term
make install
```

OSX users can grab the latest dmg from the release page: https://github.com/Swordfish90/cool-retro-term/releases
## Build instructions (Linux)

##Build instructions (Linux)
Build cool-retro-term yourself, you know, the retro way.

##Dependencies
## Dependencies
Make sure to install these first.

---
Expand All @@ -56,9 +84,33 @@ Make sure to install these first.

---

**Debian Jessie**
**Ubuntu 16.10**

sudo apt-get install build-essential qmlscene qt5-qmake qt5-default qtdeclarative5-dev qml-module-qtquick-controls qml-module-qtgraphicaleffects qml-module-qtquick-dialogs qml-module-qtquick-localstorage qml-module-qtquick-window2
sudo apt-get install build-essential qmlscene qt5-qmake qt5-default qtdeclarative5-dev qml-module-qtquick-controls qtdeclarative5-qtquick2-plugin libqt5qml-graphicaleffects qml-module-qtquick-dialogs qtdeclarative5-localstorage-plugin qtdeclarative5-window-plugin

---

**Ubuntu 17.04**

sudo apt install build-essential libqt5qml-graphicaleffects qml-module-qt-labs-folderlistmodel qml-module-qt-labs-settings qml-module-qtquick-controls qml-module-qtquick-dialogs qmlscene qt5-default qt5-qmake qtdeclarative5-dev qtdeclarative5-localstorage-plugin qtdeclarative5-qtquick2-plugin qtdeclarative5-window-plugin

---

**Ubuntu 17.10**

sudo apt-get install build-essential qml-module-qtgraphicaleffects qml-module-qt-labs-folderlistmodel qml-module-qt-labs-settings qml-module-qtquick-controls qml-module-qtquick-dialogs qmlscene qt5-default qt5-qmake qtdeclarative5-dev qtdeclarative5-localstorage-plugin qtdeclarative5-qtquick2-plugin qtdeclarative5-window-plugin

---

**snapcraft (most of distros)**

sudo snap install cool-retro-term --classic

---

**Debian Jessie and above**

sudo apt install build-essential qmlscene qt5-qmake qt5-default qtdeclarative5-dev qml-module-qtquick-controls qml-module-qtgraphicaleffects qml-module-qtquick-dialogs qml-module-qtquick-localstorage qml-module-qtquick-window2 qml-module-qt-labs-settings qml-module-qt-labs-folderlistmodel

---

Expand Down Expand Up @@ -98,7 +150,7 @@ Install Qt directly from here http://qt-project.org/downloads . Once done export
export PATH=/opt/Qt5.3.1/5.3/gcc_64/bin/:$PATH
---

###Compile
### Compile
Once you installed all dependencies (Qt is installed and in your path) you need to compile and run the application:

```bash
Expand All @@ -115,7 +167,7 @@ qmake && make
./cool-retro-term
```

##Build instructions (OSX)
## Build instructions (macOS)

1. Install [Xcode](https://developer.apple.com/xcode/) and agree to the licence agreement
2. Enter the following commands into the terminal:
Expand Down Expand Up @@ -147,7 +199,13 @@ cp -r qmltermwidget/QMLTermWidget cool-retro-term.app/Contents/PlugIns
open cool-retro-term.app
```

##Donations
I made this project in my spare time because I love what I'm doing. If you are enjoying it and you want to buy me a beer click [here](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=flscogna%40gmail%2ecom&lc=IT&item_name=Filippo%20Scognamiglio&currency_code=EUR&bn=PP%2dDonationsBF%3abtn_donate_LG%2egif%3aNonHosted) .
**Homebrew**

```sh
brew cask install cool-retro-term
```

## Donations
I made this project in my spare time because I love what I'm doing. If you are enjoying it and you want to buy me a beer click [here](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=flscogna%40gmail%2ecom&lc=IT&item_name=Filippo%20Scognamiglio&currency_code=EUR&bn=PP%2dDonationsBF%3abtn_donate_LG%2egif%3aNonHosted).

You can also add "bounties" on your favourite issues. More information on the [Bountysource](https://www.bountysource.com/teams/crt/issues) page.
6 changes: 4 additions & 2 deletions app/app.pro
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ TARGET = cool-retro-term
DESTDIR = $$OUT_PWD/../

HEADERS += \
fileio.h
fileio.h \
monospacefontmanager.h

SOURCES = main.cpp \
fileio.cpp
fileio.cpp \
monospacefontmanager.cpp

macx:ICON = icons/crt.icns

Expand Down
54 changes: 42 additions & 12 deletions app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
#include <QDebug>
#include <stdlib.h>

#include <QFontDatabase>

#include <fileio.h>
#include <monospacefontmanager.h>

QString getNamedArgument(QStringList args, QString name, QString defaultName)
{
Expand All @@ -30,14 +33,45 @@ int main(int argc, char *argv[])
// This disables QT appmenu under Ubuntu, which is not working with QML apps.
setenv("QT_QPA_PLATFORMTHEME", "", 1);

#if defined (Q_OS_LINUX)
setenv("QSG_RENDER_LOOP", "threaded", 0);
#endif

#if defined(Q_OS_MAC)
// This allows UTF-8 characters usage in OSX.
setenv("LC_CTYPE", "UTF-8", 1);
#endif

if (argc>1 && (!strcmp(argv[1],"-h") || !strcmp(argv[1],"--help"))) {
QTextStream cout(stdout, QIODevice::WriteOnly);
cout << "Usage: " << argv[0] << " [--default-settings] [--workdir <dir>] [--program <prog>] [-p|--profile <prof>] [--fullscreen] [-h|--help]" << endl;
cout << " --default-settings Run cool-retro-term with the default settings" << endl;
cout << " --workdir <dir> Change working directory to 'dir'" << endl;
cout << " -e <cmd> Command to execute. This option will catch all following arguments, so use it as the last option." << endl;
cout << " -T <title> Set window title to 'title'." << endl;
cout << " --fullscreen Run cool-retro-term in fullscreen." << endl;
cout << " -p|--profile <prof> Run cool-retro-term with the given profile." << endl;
cout << " -h|--help Print this help." << endl;
cout << " --verbose Print additional information such as profiles and settings." << endl;
return 0;
}

QString appVersion("1.1.1");

if (argc>1 && (!strcmp(argv[1],"-v") || !strcmp(argv[1],"--version"))) {
QTextStream cout(stdout, QIODevice::WriteOnly);
cout << "cool-retro-term " << appVersion << endl;
return 0;
}

QApplication app(argc, argv);
// set application attributes
// Has no effects, see https://bugreports.qt.io/browse/QTBUG-51293
// app.setAttribute(Qt::AA_MacDontSwapCtrlAndMeta, true);

QQmlApplicationEngine engine;
FileIO fileIO;
MonospaceFontManager monospaceFontManager;

#if !defined(Q_OS_MAC)
app.setWindowIcon(QIcon::fromTheme("cool-retro-term", QIcon(":../icons/32x32/cool-retro-term.png")));
Expand All @@ -47,17 +81,6 @@ int main(int argc, char *argv[])

// Manage command line arguments from the cpp side
QStringList args = app.arguments();
if (args.contains("-h") || args.contains("--help")) {
qDebug() << "Usage: " + args.at(0) + " [--default-settings] [--workdir <dir>] [--program <prog>] [-p|--profile <prof>] [--fullscreen] [-h|--help]";
qDebug() << " --default-settings Run cool-retro-term with the default settings";
qDebug() << " --workdir <dir> Change working directory to 'dir'";
qDebug() << " -e <cmd> Command to execute. This option will catch all following arguments, so use it as the last option.";
qDebug() << " --fullscreen Run cool-retro-term in fullscreen.";
qDebug() << " -p|--profile <prof> Run cool-retro-term with the given profile.";
qDebug() << " -h|--help Print this help.";
qDebug() << " --verbose Print additional information such as profiles and settings.";
return 0;
}

// Manage default command
QStringList cmdList;
Expand All @@ -66,11 +89,13 @@ int main(int argc, char *argv[])
}
QVariant command(cmdList.empty() ? QVariant() : cmdList[0]);
QVariant commandArgs(cmdList.size() <= 1 ? QVariant() : QVariant(cmdList.mid(1)));
engine.rootContext()->setContextProperty("appVersion", appVersion);
engine.rootContext()->setContextProperty("defaultCmd", command);
engine.rootContext()->setContextProperty("defaultCmdArgs", commandArgs);

engine.rootContext()->setContextProperty("workdir", getNamedArgument(args, "--workdir", "$HOME"));
engine.rootContext()->setContextProperty("fileIO", &fileIO);
engine.rootContext()->setContextProperty("monospaceSystemFonts", monospaceFontManager.retrieveMonospaceFonts());

engine.rootContext()->setContextProperty("devicePixelRatio", app.devicePixelRatio());

Expand All @@ -81,7 +106,12 @@ int main(int argc, char *argv[])
importPathList.prepend(QCoreApplication::applicationDirPath() + "/../../../qmltermwidget");
engine.setImportPathList(importPathList);

engine.load(QUrl("qrc:/main.qml"));
engine.load(QUrl(QStringLiteral ("qrc:/main.qml")));

if (engine.rootObjects().isEmpty()) {
qDebug() << "Cannot load QML interface";
return EXIT_FAILURE;
}

// Quit the application when the engine closes.
QObject::connect((QObject*) &engine, SIGNAL(quit()), (QObject*) &app, SLOT(quit()));
Expand Down
25 changes: 25 additions & 0 deletions app/monospacefontmanager.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include "monospacefontmanager.h"

#include <QDebug>

MonospaceFontManager::MonospaceFontManager(QObject *parent) : QObject(parent)
{

}

QStringList MonospaceFontManager::retrieveMonospaceFonts() {
QStringList result;

QFontDatabase fontDatabase;
QStringList fontFamilies = fontDatabase.families();

for (int i = 0; i < fontFamilies.size(); i++) {
QString fontFamily = fontFamilies[i];
QFont font(fontFamily);
if (fontDatabase.isFixedPitch(font.family())) {
result.append(fontFamily);
}
}

return result;
}
15 changes: 15 additions & 0 deletions app/monospacefontmanager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#ifndef MONOSPACEFONTMANAGER_H
#define MONOSPACEFONTMANAGER_H

#include <QObject>
#include <QFontDatabase>

class MonospaceFontManager : public QObject
{
Q_OBJECT
public:
explicit MonospaceFontManager(QObject *parent = nullptr);
Q_INVOKABLE QStringList retrieveMonospaceFonts();
};

#endif // MONOSPACEFONTMANAGER_H
Loading

0 comments on commit 4b98521

Please sign in to comment.