Skip to content

Commit

Permalink
Merge pull request #1 from CM0use/2.0.0
Browse files Browse the repository at this point in the history
GenPassword v.2.0.0
  • Loading branch information
CM0use authored Nov 12, 2023
2 parents c06e188 + a46346a commit 94742a4
Show file tree
Hide file tree
Showing 86 changed files with 1,867 additions and 2,703 deletions.
Binary file removed installer/config/appIcon.png
Binary file not shown.
9 changes: 1 addition & 8 deletions installer/config/config.xml
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<Installer>
<Name>GenPassword</Name>
<Version>1.0.0</Version>
<Version>2.0.0</Version>
<Title>GenPassword Installer</Title>
<Publisher>CM0use</Publisher>
<ProductUrl>https://github.com/CM0use/GenPassword</ProductUrl>
<InstallerWindowIcon>appIcon.png</InstallerWindowIcon>
<StartMenuDir>GenPassword</StartMenuDir>
<TargetDir>@HomeDir@/GenPassword</TargetDir>
<ProductImages>
<ProductImage>
<Image>appIcon.png</Image>
<Url>https://github.com/CM0use/GenPassword</Url>
</ProductImage>
</ProductImages>
</Installer>
24 changes: 4 additions & 20 deletions installer/packages/com.CM0use.GenPassword/meta/installscript.qs
Original file line number Diff line number Diff line change
@@ -1,21 +1,5 @@
/**
** This file is part of the GenPassword project.
** Copyright 2023 CM0use [email protected]
** URL: https://github.com/CM0use/GenPassword
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
**/
// GenPassword
// Copyright (c) 2023 CM0use

function Component()
{
Expand Down Expand Up @@ -44,8 +28,8 @@ Component.prototype.createOperations = function()
"iconPath=@TargetDir@/GenPassword.exe");
} else if (installer.value("os") === "x11") {
component.addOperation("InstallIcons", "@TargetDir@/icons");
var app_desktop = "Version=1.0.0\nName=GenPassword\nComment=A random and customizable password generator\nComment[zh_CN]=随机和可定制的密码生成器\nComment[hi]=एक यादृच्छिक और अनुकूलन योग्य पासवर्ड जनरेटर\nComment[es]=Un generador de contraseñas aleatorio y personalizable\nComment[pt_BR]=Um gerador de senhas aleatórias e personalizáveis\nExec=@TargetDir@/GenPassword\nTerminal=false\nType=Application\nIcon=GenPasswordIcon\nCategories=Utility;Security",
uninstall_desktop = "Version=1.0.0\nName=Uninstall\nExec=@TargetDir@/maintenancetool\nTerminal=false\nKeyword=GenPassword\nType=Application\nIcon=GenPasswordIcon\nCategories=Utility;Security";
var app_desktop = "Version=2.0.0\nName=GenPassword\nComment=A random and customizable password generator\nComment[es]=Un generador de contraseñas aleatorio y personalizable\nExec=@TargetDir@/GenPassword\nTerminal=false\nType=Application\nIcon=GenPasswordIcon\nCategories=Utility;Security",
uninstall_desktop = "Version=2.0.0\nName=Uninstall\nExec=@TargetDir@/maintenancetool\nTerminal=false\nKeyword=GenPassword\nType=Application\nIcon=GenPasswordIcon\nCategories=Utility;Security";

component.addOperation("CreateDesktopEntry",
"GenPassword.desktop",
Expand Down
4 changes: 2 additions & 2 deletions installer/packages/com.CM0use.GenPassword/meta/package.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<Package>
<DisplayName>GenPassword</DisplayName>
<ReleaseDate>2023-09-16</ReleaseDate>
<Version>1.0.0</Version>
<ReleaseDate>2023-11-10</ReleaseDate>
<Version>2.0.0</Version>
<Default>true</Default>
<Description>A random and customizable password generator.</Description>
<Licenses>
Expand Down
44 changes: 17 additions & 27 deletions src/GenPassword.pro
Original file line number Diff line number Diff line change
@@ -1,44 +1,34 @@
#
# ** This file is part of the GenPassword project.
# ** Copyright 2023 CM0use [email protected]
# ** URL: https://github.com/CM0use/GenPassword
# **
# ** This program is free software: you can redistribute it and/or modify
# ** it under the terms of the GNU General Public License as published by
# ** the Free Software Foundation, either version 3 of the License, or
# ** (at your option) any later version.
# **
# ** This program is distributed in the hope that it will be useful,
# ** but WITHOUT ANY WARRANTY; without even the implied warranty of
# ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# ** GNU General Public License for more details.
# **
# ** You should have received a copy of the GNU General Public License
# ** along with this program. If not, see <http://www.gnu.org/licenses/>.
#

QT += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

CONFIG += c++20
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
CONFIG += c++17
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000
VERSION = 2.0.0
QMAKE_TARGET_PRODUCT = GenPassword
QMAKE_TARGET_DESCRIPTION = "A free generator password"
QMAKE_TARGET_COPYRIGHT = CM0use

win32: RC_ICONS = icons/appIcon.ico

SOURCES += \
framelesswindow.cpp \
main.cpp \
passwordgeneratorapp.cpp
passwordgenerator.cpp \
switchbutton.cpp \
window.cpp

HEADERS += \
passwordgeneratorapp.h
framelesswindow.h \
icons.h \
passwordgenerator.h \
switchbutton.h \
window.h

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target

win32: RC_ICONS = icon/appIcon.ico
macx: ICON = icon/appIcon.icns

RESOURCES += \
i18n.qrc \
icons.qrc \
Expand Down
88 changes: 88 additions & 0 deletions src/framelesswindow.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
// GenPassword
// Copyright (c) 2023 CM0use

#include "framelesswindow.h"

#include <QStyle>
#include <QHoverEvent>
#include <QWindow>

FramelessWindow::FramelessWindow(QWidget *const parent)
: QMainWindow{ parent, Qt::FramelessWindowHint },
m_titleBar{ nullptr }
{ }

bool FramelessWindow::event(QEvent *const event)
{
if (windowFlags() & Qt::FramelessWindowHint) {
static Qt::Edges edges{ Qt::Edges() };
const int margin{ style()->pixelMetric(QStyle::PM_LayoutTopMargin) };
switch (event->type()) {
case QEvent::MouseButtonPress:
updateCursor(edges);
if ((m_titleBar != nullptr) && m_titleBar->underMouse())
windowHandle()->startSystemMove();
else if (edges)
windowHandle()->startSystemResize(edges);
break;
case QEvent::MouseButtonRelease:
edges = Qt::Edges();
updateCursor(edges);
setFocus();
break;
case QEvent::HoverMove: {
edges = Qt::Edges();
QPoint p{ static_cast<QHoverEvent *>(event)->position().toPoint() };

if (p.x() < margin)
edges |= Qt::LeftEdge;
if (p.x() > (width() - margin))
edges |= Qt::RightEdge;
if (p.y() < margin)
edges |= Qt::TopEdge;
if (p.y() > (height() - margin))
edges |= Qt::BottomEdge;
updateCursor(edges);
break;
}
default:
break;
}
}
return QMainWindow::event(event);
}

void FramelessWindow::setTitleBar(QWidget *const widget)
{
m_titleBar = widget;
}

QWidget* FramelessWindow::getTitleBar() const
{
return m_titleBar;
}

void FramelessWindow::updateCursor(const Qt::Edges &edges)
{
switch (edges) {
case 0:
setCursor(Qt::ArrowCursor);
break;
case Qt::LeftEdge:
case Qt::RightEdge:
setCursor(Qt::SizeHorCursor);
break;
case Qt::TopEdge:
case Qt::BottomEdge:
setCursor(Qt::SizeVerCursor);
break;
case Qt::LeftEdge | Qt::TopEdge:
case Qt::RightEdge | Qt::BottomEdge:
setCursor(Qt::SizeFDiagCursor);
break;
case Qt::RightEdge | Qt::TopEdge:
case Qt::LeftEdge | Qt::BottomEdge:
setCursor(Qt::SizeBDiagCursor);
break;
}
}
26 changes: 26 additions & 0 deletions src/framelesswindow.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// GenPassword
// Copyright (c) 2023 CM0use

#ifndef FRAMELESSWINDOW_H
#define FRAMELESSWINDOW_H

#include <QMainWindow>

class FramelessWindow: public QMainWindow
{
public:
explicit FramelessWindow(QWidget *const parent = nullptr);
virtual ~FramelessWindow() = default;

protected:
virtual bool event(QEvent *const event) override;

void setTitleBar(QWidget *const widget);
QWidget* getTitleBar() const;

private:
void updateCursor(const Qt::Edges &edges);
QWidget *m_titleBar;
};

#endif
8 changes: 2 additions & 6 deletions src/i18n.qrc
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
<RCC>
<qresource prefix="/i18n">
<file>languages/en.qm</file>
<file>languages/es.qm</file>
<file>languages/hi.qm</file>
<file>languages/pt-BR.qm</file>
<file>languages/zh-CN.qm</file>
<qresource prefix="/">
<file>i18n/es.qm</file>
</qresource>
</RCC>
Binary file added src/i18n/es.qm
Binary file not shown.
Loading

0 comments on commit 94742a4

Please sign in to comment.