Merge branch 'Murmele:master' into latest

This commit is contained in:
gh-devnull 2023-11-15 02:20:35 +00:00 committed by GitHub
commit 6b77e6ee4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 15395 additions and 9011 deletions

View File

@ -137,8 +137,11 @@ jobs:
os: ubuntu-latest
ninja_platform: linux
qt_platform: linux
qt_arch: gcc_64
openssl_arch: linux-x86_64
cmake_flags: "-DGENERATE_APPDATA=ON"
ld_library_arch: linux-x86-64
cmake_flags: "-DGENERATE_APPDATA=ON -DCMAKE_INSTALL_PREFIX=/usr -DUSE_SYSTEM_QT=ON -DENABLE_UPDATE_OVER_GUI=OFF"
pack: 0
cmake_env: {}
- name: macos
@ -278,7 +281,7 @@ jobs:
run: |
mkdir -p build/release
cd build/release
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DGITTYUP_CI_TESTS=ON ${{ env.CMAKE_FLAGS }} ${{ matrix.env.cmake_flags }} ../..
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DUPDATE_TRANSLATIONS=ON -DGITTYUP_CI_TESTS=ON ${{ env.CMAKE_FLAGS }} ${{ matrix.env.cmake_flags }} ../..
- name: Build Information
run: |
@ -315,9 +318,14 @@ jobs:
if: matrix.env.pack && !matrix.qt.check_only
uses: actions/upload-artifact@v3
with:
path: build/release/VERSION.txt
path: build/release/Version.txt
name: Gittyup-VERSION
- name: Check Version file
run: |
cd build/release
cat ./Version.txt
- name: Test
if: matrix.env.ninja_platform != 'win' && matrix.env.ninja_platform != 'mac'
uses: GabrielBB/xvfb-action@v1
@ -331,6 +339,44 @@ jobs:
cd build/release
ninja check_no_win32_offscreen
- name: Build Appimage
if: matrix.env.ninja_platform == 'linux' && !matrix.qt.check_only
run: |
cd build/release
sudo apt -y install appstream
sudo apt -y install libfuse2
sudo apt -y install libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-shape0
sudo apt -y install libxcb-shm0 libxcb-sync1 libxcb-util1 libxcb-xinerama0 libxcb-xinput0 libxcb-xkb1 libxcb-xrm0 libxcb-xv0 libxcb-xvmc0 libxcb1
mkdir -p AppDir
DESTDIR=AppDir ninja install
export QTDIR=$RUNNER_WORKSPACE/Qt/${{ matrix.qt.version }}/${{ matrix.env.qt_arch }}
rm -rf ./AppDir/usr/include/
strip ./AppDir/usr/bin/cmark ./AppDir/usr/bin/gittyup ./AppDir/usr/bin/indexer ./AppDir/usr/bin/relauncher
wget -c https://github.com/$(wget -q https://github.com/probonopd/go-appimage/releases/expanded_assets/continuous -O - | grep "appimagetool-.*-x86_64.AppImage" | head -n 1 | cut -d '"' -f 2)
chmod +x appimagetool-*.AppImage
QTDIR=$QTDIR ./appimagetool-*.AppImage -s deploy ./AppDir/usr/share/applications/*.desktop --appimage-extract-and-run # Bundle EVERYTHING
# Modify the AppDir: move ld-linux into the same directory as the payload application
# and change AppRun accordingly; so that, e.g., Qt qApp->applicationDirPath() works
mv ./AppDir/lib64/ld-${{ matrix.env.ld_library_arch }}.so.2 ./AppDir/usr/bin/
sed -i -e 's@^LD_LINUX.*@LD_LINUX=$(find "$HERE/usr/bin" -name "ld-*.so.*" | head -n 1)@g' ./AppDir/AppRun
rm ./AppDir/usr/share/metainfo/gittyup.appdata.xml
VERSION=$(cat ./Version.txt)
VERSION="$VERSION" ./appimagetool-*.AppImage ./AppDir # turn AppDir into AppImage
#ls -lh Gittyup-*
- name: Publish Appimage
if: matrix.env.ninja_platform == 'linux' && !matrix.qt.check_only
uses: actions/upload-artifact@v3
with:
path: build/release/*.AppImage
name: Gittyup Appimage
publish:
# https://github.com/marvinpinto/actions/issues/177
needs: [flatpak, build]
@ -361,7 +407,7 @@ jobs:
# version is exported from cmake to file
- name: Retrieve version
run: |
echo "::set-output name=VERSION::$(cat artifacts/Gittyup-VERSION/VERSION.txt)"
echo "::set-output name=VERSION::$(cat artifacts/Gittyup-VERSION/Version.txt)"
id: version
- name: Update GitHub release (latest tag)
@ -392,6 +438,7 @@ jobs:
**/artifacts/Gittyup macos/Gittyup*.dmg
**/artifacts/Gittyup Flatpak/com.github.Murmele.Gittyup.yml
**/Gittyup-x86_64/*.flatpak
**/artifacts/Gittyup Appimage/*
# needed otherwise the docs folder is not available
- name: Checkout repository

View File

@ -6,7 +6,7 @@ cd "`dirname "$0"`"
# Variable that will hold the name of the clang-format command
FMT=""
FOLDERS=("./src" "./test")
FOLDERS=("./src" "./test" "./l10n")
# We specifically require clang-format v13. Some distros include the version
# number in the name, others don't. Prefer the specifically-named version.

View File

@ -31,7 +31,7 @@ Report bugs in Gittyup by opening an issue in the
Remember to search for existing issues before creating a new one.
If you still need help, check out our Matrix channel
[Gittyup:martix.org](https://matrix.to/#/#Gittyup:matrix.org).
[Gittyup:matrix.org](https://matrix.to/#/#Gittyup:matrix.org).
Multi language support
======================

View File

@ -14,10 +14,18 @@ set(LANGUAGES
set(SRC_DIR ${CMAKE_SOURCE_DIR}/src)
file(GLOB_RECURSE SOURCE_FILES ${SRC_DIR}/*.h ${SRC_DIR}/*.cpp ${SRC_DIR}/*.mm)
set(SYSTEM_LANG_KEY "System")
set(SUPPORTED_LANGUAGES "{\"${SYSTEM_LANG_KEY}\", \"${SYSTEM_LANG_KEY}\"},")
foreach(LANGUAGE ${LANGUAGES})
set(TS_FILES ${TS_FILES} gittyup_${LANGUAGE}.ts)
set(SUPPORTED_LANGUAGES
"${SUPPORTED_LANGUAGES} {\"${LANGUAGE}\", \"${LANGUAGE}\"},")
endforeach()
set(LANGUAGE_SOURCE_FILE "${CMAKE_CURRENT_BINARY_DIR}/languages.cpp")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/languages.cpp.inc"
${LANGUAGE_SOURCE_FILE} @ONLY)
if(UPDATE_TRANSLATIONS)
# FIXME: Clean removes the .ts files.
qt5_create_translation(QM_FILES ${SOURCE_FILES} ${TS_FILES})
@ -28,6 +36,10 @@ endif()
add_custom_target(translations DEPENDS ${QM_FILES})
add_dependencies(gittyup translations)
add_library(translation ${LANGUAGE_SOURCE_FILE})
target_include_directories(translation PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
target_link_libraries(translation Qt5::Core)
# install language files
foreach(LANGUAGE ${LANGUAGES})

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

9
l10n/languages.cpp.inc Normal file
View File

@ -0,0 +1,9 @@
#include "languages.h"
#include <QList>
#include <QString>
namespace Languages {
const QString system = QStringLiteral("@SYSTEM_LANG_KEY@");
const QMap<const char*, const char*> languages = { @SUPPORTED_LANGUAGES@ };
}

11
l10n/languages.h Normal file
View File

@ -0,0 +1,11 @@
#ifndef LANGUAGES_H
#define LANGUAGES_H
#include <QMap>
namespace Languages {
extern const QString system;
extern const QMap<const char *, const char *> languages;
} // namespace Languages
#endif // LANGUAGES_H

View File

@ -16,6 +16,7 @@
#include "ui/RepoView.h"
#include "ui/TabWidget.h"
#include "update/Updater.h"
#include "languages.h"
#include "util/Debug.h"
#include <QCloseEvent>
#include <QCommandLineParser>
@ -172,6 +173,12 @@ Application::Application(int &argc, char **argv, bool haltOnParseError)
.toBool()) &&
(!parser.isSet("no-translation"))) {
// Load translation files.
const auto &language =
Settings::instance()->value(Setting::Id::Language).toString();
if (language != Languages::system)
QLocale::setDefault(QLocale(language));
QLocale locale;
QDir l10n = Settings::l10nDir();
QString name = QString(GITTYUP_NAME).toLower();

View File

@ -67,7 +67,14 @@ target_compile_definitions(
PRIVATE QT_TRANSLATIONS_DIR="${QT_TRANSLATIONS_DIR}"
BUILD_DESCRIPTION="${BUILD_DESCRIPTION}")
target_link_libraries(app conf git ui update Qt5::Widgets)
target_link_libraries(
app
translation
conf
git
ui
update
Qt5::Widgets)
set_target_properties(app PROPERTIES AUTOMOC ON)

View File

@ -1,7 +1,7 @@
add_library(conf ConfFile.cpp Settings.cpp Setting.cpp RecentRepositories.cpp
RecentRepository.cpp)
target_link_libraries(conf lua Qt5::Core util)
target_link_libraries(conf lua Qt5::Core util translation)
# SRC_ definitions point to the source directly
target_compile_definitions(
@ -9,7 +9,7 @@ target_compile_definitions(
PRIVATE CONF_DIR="${RESOURCES_DIR}"
SRC_CONF_DIR="${CMAKE_SOURCE_DIR}/conf"
L10N_DIR="${L10N_INSTALL_DIR}"
SRC_L10N_DIR="${CMAKE_SOURCE_DIR}/l10n"
SRC_L10N_DIR="${CMAKE_BINARY_DIR}/l10n"
SCINTILLUA_LEXERS_DIR="${SCINTILLUA_LEXERS_DIR}"
SRC_SCINTILLUA_LEXERS_DIR="${SRC_SCINTILLUA_LEXERS_DIR}")
set_target_properties(conf PROPERTIES AUTOMOC ON)

View File

@ -26,6 +26,7 @@ void Setting::initialize(QMap<Id, QString> &keys) {
keys[Id::TerminalName] = "terminal/name";
keys[Id::TerminalPath] = "terminal/path";
keys[Id::DontTranslate] = "translation/disable";
keys[Id::Language] = "translation/language";
keys[Id::AllowSingleInstanceOnly] = "singleInstance";
keys[Id::CheckForUpdatesAutomatically] = "update/check";
keys[Id::InstallUpdatesAutomatically] = "update/download";

View File

@ -63,6 +63,7 @@ public:
ShowCommitsId,
ShowChangedFilesAsList,
ShowChangedFilesInSingleView,
Language,
};
Q_ENUM(Id)

View File

@ -11,6 +11,7 @@
#include "ConfFile.h"
#include "Debug.h"
#include "qtsupport.h"
#include "languages.h"
#include <QCoreApplication>
#include <QDir>
#include <QSettings>
@ -26,6 +27,8 @@ namespace {
const QString kIgnoreWsKey("diff/whitespace/ignore");
const QString kLastPathKey("lastpath");
const QString kTranslation("translation");
const QString kTranslationLanguage("language");
// Look up variant at key relative to root.
QVariant lookup(const QVariantMap &root, const QString &key) {
@ -51,6 +54,10 @@ Settings::Settings(QObject *parent) : QObject(parent) {
foreach (const QFileInfo &file, confDir().entryInfoList(QStringList("*.lua")))
mDefaults[file.baseName()] = ConfFile(file.absoluteFilePath()).parse();
mDefaults[kLastPathKey] = QDir::homePath();
QVariantMap map;
map[kTranslationLanguage] = QVariant(Languages::system);
mDefaults[kTranslation] = map;
mDefaults[kTranslation].toMap()[kTranslationLanguage] = Languages::system;
mCurrentMap = mDefaults;
}

View File

@ -25,6 +25,7 @@
#include "ui/MainWindow.h"
#include "ui/MenuBar.h"
#include "ui/RepoView.h"
#include "languages.h"
#include "update/Updater.h"
#include <QAction>
#include <QApplication>
@ -105,6 +106,13 @@ public:
new QCheckBox(tr("Update submodules after pull and clone"), this);
mAutoPrune = new QCheckBox(tr("Prune when fetching"), this);
mNoTranslation = new QCheckBox(tr("No translation"), this);
mLanguages = new QComboBox(this);
QMapIterator<const char *, const char *> i(Languages::languages);
while (i.hasNext()) {
i.next();
mLanguages->addItem(tr(i.key()), QVariant(i.value()));
}
mStoreCredentials =
new QCheckBox(tr("Store credentials in secure storage"), this);
@ -123,6 +131,7 @@ public:
form->addRow(QString(), mPullUpdate);
form->addRow(QString(), mAutoPrune);
form->addRow(tr("Language:"), mNoTranslation);
form->addRow(tr("Language:"), mLanguages);
form->addRow(tr("Credentials:"), mStoreCredentials);
form->addRow(tr("Credential store type:"), mAvailableStores);
form->addRow(QString(), privacy);
@ -184,6 +193,12 @@ public:
Settings::instance()->setValue(Setting::Id::DontTranslate, checked);
});
connect(mLanguages, QOverload<int>::of(&QComboBox::currentIndexChanged),
[this]() {
const auto &language = mLanguages->currentData().toString();
Settings::instance()->setValue(Setting::Id::Language, language);
});
connect(mStoreCredentials, &QCheckBox::toggled, [this](bool checked) {
git::Config config = git::Config::global();
mAvailableStores->setEnabled(checked);
@ -234,6 +249,14 @@ public:
mNoTranslation->setChecked(
settings->value(Setting::Id::DontTranslate).toBool());
const auto &l = settings->value(Setting::Id::Language).toString();
for (int i = 0; i < mLanguages->count(); i++) {
if (mLanguages->itemData(i).toString() == l) {
mLanguages->setCurrentIndex(i);
break;
}
}
auto currentHelper = config.value<QString>("credential.helper");
auto checked = CredentialHelper::isHelperValid(currentHelper);
mStoreCredentials->setChecked(checked);
@ -259,6 +282,7 @@ private:
QCheckBox *mPullUpdate;
QCheckBox *mAutoPrune;
QCheckBox *mNoTranslation;
QComboBox *mLanguages;
QCheckBox *mStoreCredentials;
QComboBox *mAvailableStores;
QCheckBox *mSingleInstance;

View File

@ -258,7 +258,27 @@ CommitEditor::CommitEditor(const git::Repository &repo, QWidget *parent)
mTemplate = new TemplateButton(this);
mTemplate->setText(tr("T"));
connect(mTemplate, &TemplateButton::templateChanged, this,
QOverload<const QString &>::of(&CommitEditor::applyTemplate));
[this](const QString &t) {
QStringList files;
if (mDiff.isValid()) {
int count = mDiff.count();
git::Index index = mDiff.index();
for (int i = 0; i < count; ++i) {
QString name = mDiff.name(i);
switch (index.isStaged(name)) {
case git::Index::PartiallyStaged:
case git::Index::Staged:
files.append(QFileInfo(name).fileName());
break;
case git::Index::Conflicted:
case git::Index::Disabled:
case git::Index::Unstaged:
break;
}
}
}
applyTemplate(t, files);
});
QLabel *label = new QLabel(tr("<b>Commit Message:</b>"), this);
@ -585,11 +605,11 @@ QString CommitEditor::createFileList(const QStringList &list, int maxFiles) {
return msg;
}
void CommitEditor::setMessage(const QStringList &list) {
void CommitEditor::setMessage(const QStringList &files) {
if (mTemplate->templates().count() > 0) {
applyTemplate(mTemplate->templates().first().value, list);
applyTemplate(mTemplate->templates().first().value, files);
} else {
QString msg = createFileList(list, 3);
QString msg = createFileList(files, 3);
if (!msg.isEmpty())
msg = QStringLiteral("Update ") + msg;
setMessage(msg);
@ -710,7 +730,7 @@ void CommitEditor::updateButtons(bool yieldFocus) {
return;
}
QStringList list;
QStringList files;
int staged = 0;
int partial = 0;
int conflicted = 0;
@ -724,12 +744,12 @@ void CommitEditor::updateButtons(bool yieldFocus) {
break;
case git::Index::PartiallyStaged:
list.append(QFileInfo(name).fileName());
files.append(QFileInfo(name).fileName());
++partial;
break;
case git::Index::Staged:
list.append(QFileInfo(name).fileName());
files.append(QFileInfo(name).fileName());
++staged;
break;
@ -743,7 +763,7 @@ void CommitEditor::updateButtons(bool yieldFocus) {
QSignalBlocker blocker(mMessage);
(void)blocker;
setMessage(list);
setMessage(files);
if (yieldFocus && !mMessage->toPlainText().isEmpty())
mMessage->setFocus();
}

View File

@ -35,7 +35,7 @@ public:
void unstage();
bool isUnstageEnabled() const;
static QString createFileList(const QStringList &list, int maxFiles);
void setMessage(const QStringList &list);
void setMessage(const QStringList &files);
void setMessage(const QString &message);
QString message() const;
void setDiff(const git::Diff &diff);

View File

@ -68,6 +68,8 @@ TemplateDialog::TemplateDialog(QList<TemplateButton::Template> &templates,
hBox->addItem(spacer);
hBox->addWidget(mRemove);
QVBoxLayout *vBox2 = new QVBoxLayout();
vBox2->addWidget(
new QLabel(tr("First template will be applied automatically"), this));
vBox2->addWidget(mTemplateList);
vBox2->addLayout(hBox);