Skip to content

Commit

Permalink
Merge pull request #25 from Bollos00/dev
Browse files Browse the repository at this point in the history
Upgrade to version 1.6.2
  • Loading branch information
Bollos00 authored Jun 15, 2021
2 parents ee80d21 + 1d58f69 commit 7777e51
Show file tree
Hide file tree
Showing 11 changed files with 391 additions and 167 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
message(STATUS "Using CMake version ${CMAKE_VERSION}")
cmake_minimum_required(VERSION 3.1.0)
project(libremines
VERSION "1.6.1"
VERSION "1.6.2"
DESCRIPTION "A Qt based Minesweeper game"
HOMEPAGE_URL "https://github.com/Bollos00/LibreMines"
LANGUAGES "CXX"
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@ All kinds of contributions are welcome on this project. You can help:
* Sharing the game in order to attract more users;
* Adapting the software for other Operational Systems;
* Packaging the software for other distributions;
* Increasing the playability and adding new features by making changes on the source code.
* Increasing the playability and adding new features by making changes on the source code;
* Reporting new [issues](https://github.com/Bollos00/LibreMines/issues) or solving existing ones;
* Adding or improve the [translations](https://github.com/Bollos00/LibreMines/blob/master/etc/translations/README.md).

# Third party Repositories used in this software
* [BreezeStyleSheets](https://github.com/Alexhuszagh/BreezeStyleSheets)
Expand Down
46 changes: 46 additions & 0 deletions etc/translations/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Requirements

In order to help translating LibreMines, it is necessary to have the [Qt Linguistic Tool](https://doc.qt.io/qt-5/qtlinguist-index.html) installed.

On Arch Linux and its derivatives, it can be done by installing rhe package `qt5-tools` (or `qt6-tools` for Qt6):
```sh
sudo pacman -S qt5-tools
```

On Ubuntu systems, it can be done with:
```sh
sudo apt install qttools5-dev
```

# Updating and creating translation files

In order to update translation files (TS format), on the main directory, run:
```sh
lupdate src -ts etc/translations/libremines_es.ts etc/translations/libremines_pt_BR.ts
```

It will update the files `etc/translations/libremines_es.ts` (Spanish) and `etc/translations/libremines_pt_BR.ts` (Brazilian Portuguese) using the source directory `src`.

To generate a TS file for a new language, just append it to the end of the command above. For example, to generate a TS file for French, run:
```sh
lupdate src -ts etc/translations/libremines_es.ts etc/translations/libremines_pt_BR.ts etc/translations/libremines_fr.ts
```

The command above will generate the file `etc/translations/libremines_fr.ts`.

# Translating the software

You can use Qt Linguistic tool to translate the software. To do so, open Qt Linguistic and open the TS file you want to translate.

# Generating QM files from the TS files

Qt uses files of type QM to translate the application. While TS files are more human readable and easier to edit, QM files are non-human readable and faster to process. To generate the QM files, simply pass the option `UPDATE_TRANSLATIONS="YES"` on the cmake part on the [build process](https://github.com/Bollos00/LibreMines#building):

```sh
git clone https://github.com/Bollos00/LibreMines.git
cd LibreMines
mkdir build && cd build
cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DUPDATE_TRANSLATIONS="YES" ..
make

```
195 changes: 118 additions & 77 deletions etc/translations/libremines_es.ts

Large diffs are not rendered by default.

Binary file modified etc/translations/libremines_pt_BR.qm
Binary file not shown.
196 changes: 119 additions & 77 deletions etc/translations/libremines_pt_BR.ts

Large diffs are not rendered by default.

61 changes: 52 additions & 9 deletions src/libreminesgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,23 @@ bool LibreMinesGui::eventFilter(QObject* object, QEvent* event)
{
Qt::Key key = (Qt::Key)((QKeyEvent*)event)->key();

switch(key)
if(key == Qt::Key_Control)
{
controller.ctrlPressed = true;
return true;
}
if(controller.active)
{
case Qt::Key_Control:
controller.ctrlPressed = true;
if(key == controller.keyLeft ||
key == controller.keyUp ||
key == controller.keyDown ||
key == controller.keyRight ||
key == controller.keyCenterCell ||
key == controller.keyFlagCell ||
key == controller.keyReleaseCell)
{
return true;

default:
break;
}
}

}break;
Expand Down Expand Up @@ -180,11 +189,26 @@ bool LibreMinesGui::eventFilter(QObject* object, QEvent* event)
qApp->setOverrideCursor(QCursor(Qt::BlankCursor));
qApp->overrideCursor()->setPos(90*qApp->primaryScreen()->geometry().width()/100,
90*qApp->primaryScreen()->geometry().height()/100);

this->setFocus();

return true;
}
}
else
{
if(key == controller.keyLeft ||
key == controller.keyUp ||
key == controller.keyDown ||
key == controller.keyRight ||
key == controller.keyCenterCell ||
key == controller.keyFlagCell ||
key == controller.keyReleaseCell)
{
this->setFocus();
}


if(key == controller.keyLeft)
{
vKeyboardControllerMoveLeft();
Expand Down Expand Up @@ -359,7 +383,12 @@ void LibreMinesGui::vNewGame(const uchar _X,
this, &LibreMinesGui::SLOT_onCellLabelClicked);
}

qApp->processEvents();
if(preferences->optionMinefieldGenerationAnimation() == LibreMines::AnimationOn ||
(preferences->optionMinefieldGenerationAnimation() == LibreMines::AnimationLimited &&
i == _X - 1))
{
qApp->processEvents();
}
}
}

Expand Down Expand Up @@ -495,6 +524,7 @@ void LibreMinesGui::vCreateGUI(const int width, const int height)
actionToggleFullScreen = new QAction(this);
actionAbout = new QAction(this);
actionAboutQt = new QAction(this);
actionGitHubHomePage = new QAction(this);

QMenuBar* menuBarGlobal = new QMenuBar(this);

Expand All @@ -510,7 +540,7 @@ void LibreMinesGui::vCreateGUI(const int width, const int height)
menuBarGlobal->addAction(menuHelp->menuAction());

menuOptions->addActions({actionPreferences, actionHighScores, actionToggleFullScreen});
menuHelp->addActions({actionAbout, actionAboutQt});
menuHelp->addActions({actionAbout, actionAboutQt, actionGitHubHomePage});

menuOptions->setTitle(tr("Options"));
menuHelp->setTitle(tr("Help"));
Expand All @@ -522,6 +552,7 @@ void LibreMinesGui::vCreateGUI(const int width, const int height)

actionAbout->setText(tr("About..."));
actionAboutQt->setText(tr("About Qt..."));
actionGitHubHomePage->setText(tr("GitHub Homepage..."));
// Actions and Menu Bar


Expand Down Expand Up @@ -662,6 +693,9 @@ void LibreMinesGui::vCreateGUI(const int width, const int height)
connect(actionAboutQt, &QAction::triggered,
[this](){ QMessageBox::aboutQt(this, "LibreMines"); });

connect(actionGitHubHomePage, &QAction::triggered,
[](){ QDesktopServices::openUrl(QUrl("https://github.com/Bollos00/LibreMines")); });

connect(cbCustomizedMinesInPercentage, &QCheckBox::stateChanged,
[this](const int state)
{
Expand Down Expand Up @@ -2147,6 +2181,14 @@ void LibreMinesGui::vLastSessionLoadConfigurationFile()

preferences->setOptionProgressBar(terms.at(1));
}
else if(terms.at(0).compare("MinefieldGenerationAnimation", Qt::CaseInsensitive) == 0)
{
if(terms.size() != 2)
continue;

preferences->setOptionMinefieldGenerationAnimation(terms.at(1));
}

}
}

Expand Down Expand Up @@ -2206,7 +2248,8 @@ void LibreMinesGui::vLastSessionSaveConfigurationFile()
<< "MinimumCellLength" << ' ' << preferences->optionMinimumCellLength() << '\n'
<< "MaximumCellLength" << ' ' << preferences->optionMaximumCellLength() << '\n'
<< "FacesReaction" << ' ' << preferences->optionFacesReaction() << '\n'
<< "ProgressBar" << ' ' << (preferences->optionProgressBar() ? "On" : "Off") << '\n';
<< "ProgressBar" << ' ' << (preferences->optionProgressBar() ? "On" : "Off") << '\n'
<< "MinefieldGenerationAnimation" << ' ' << preferences->optionMinefieldGenerationAnimationString() << '\n';
}

{
Expand Down
1 change: 1 addition & 0 deletions src/libreminesgui.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ private Q_SLOTS:
QMenu* menuHelp;
QAction* actionAbout;
QAction* actionAboutQt;
QAction* actionGitHubHomePage;

QScopedPointer<QPixmap> pmZero; /**< TODO: describe */
QScopedPointer<QPixmap> pmOne; /**< TODO: describe */
Expand Down
23 changes: 23 additions & 0 deletions src/libreminespreferencesdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ LibreMinesPreferencesDialog::LibreMinesPreferencesDialog(QWidget *parent) :

ui->comboBoxLanguage->addItems({"English", "Português do Brasil"});

ui->comboBoxMinefieldGenerationAnimation->addItems({tr("On"), tr("Limited"), tr("Off")});


// Space character is not allowed. This will remove every space character of the line edit
// ui->lineEditUsername->setValidator(new QRegExpValidator(QRegExp("^(?i)[a-z][a-z0-9]*$")));
Expand Down Expand Up @@ -162,6 +164,16 @@ QString LibreMinesPreferencesDialog::optionsLanguage() const
return "";
}

uchar LibreMinesPreferencesDialog::optionMinefieldGenerationAnimation() const
{
return ui->comboBoxMinefieldGenerationAnimation->currentIndex();
}

QString LibreMinesPreferencesDialog::optionMinefieldGenerationAnimationString() const
{
return ui->comboBoxMinefieldGenerationAnimation->currentText();
}

void LibreMinesPreferencesDialog::setOptionFirstCellClean(const QString &option)
{
ui->cbFirstCellClean->setChecked(option.compare("On", Qt::CaseInsensitive) == 0);
Expand Down Expand Up @@ -243,6 +255,17 @@ void LibreMinesPreferencesDialog::setOptionLanguage(const QString &option)
QTimer::singleShot(10, [this](){ updateLanguageDialog = true; });
}

void LibreMinesPreferencesDialog::setOptionMinefieldGenerationAnimation(const uchar option)
{
if(ui->comboBoxMinefieldGenerationAnimation->count() > option)
ui->comboBoxMinefieldGenerationAnimation->setCurrentIndex(option);
}

void LibreMinesPreferencesDialog::setOptionMinefieldGenerationAnimation(const QString &option)
{
ui->comboBoxMinefieldGenerationAnimation->setCurrentText(option);
}

QList<int> LibreMinesPreferencesDialog::optionKeyboardControllerKeys() const
{
return
Expand Down
11 changes: 11 additions & 0 deletions src/libreminespreferencesdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ enum WhenCtrlIsPressedOptions : uchar
Jump5Cells = 2,
Jump10Cells = 3
};

enum MinefieldGenerationAnimation : uchar
{
AnimationOn = 0,
AnimationLimited = 1,
AnimationOff = 2
};
}

class LibreMinesPreferencesDialog : public QDialog
Expand All @@ -58,6 +65,8 @@ class LibreMinesPreferencesDialog : public QDialog
int optionMinimumCellLength()const;
int optionMaximumCellLength()const;
QString optionsLanguage()const;
uchar optionMinefieldGenerationAnimation()const;
QString optionMinefieldGenerationAnimationString()const;

void setOptionFirstCellClean(const QString& option);
void setOptionCleanNeighborCellsWhenClickedOnShowedCell(const QString& option);
Expand All @@ -70,6 +79,8 @@ class LibreMinesPreferencesDialog : public QDialog
void setOptionMinimumCellLength(const int option);
void setOptionMaximumCellLength(const int option);
void setOptionLanguage(const QString& option);
void setOptionMinefieldGenerationAnimation(const uchar option);
void setOptionMinefieldGenerationAnimation(const QString& option);

QList<int> optionKeyboardControllerKeys()const;
QString optionKeyboardControllerKeysString()const;
Expand Down
19 changes: 17 additions & 2 deletions src/libreminespreferencesdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>687</width>
<height>562</height>
<width>680</width>
<height>522</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -84,6 +84,21 @@ clicked on showed cell</string>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_16">
<item>
<widget class="QLabel" name="labelMinefieldGenerationAnimation">
<property name="text">
<string>Minefield Generation
Animation</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBoxMinefieldGenerationAnimation"/>
</item>
</layout>
</item>
</layout>
</widget>
</item>
Expand Down

0 comments on commit 7777e51

Please sign in to comment.