Skip to content

Commit

Permalink
Move libpsi from submodules to main tree
Browse files Browse the repository at this point in the history
  • Loading branch information
Ri0n committed Mar 17, 2024
1 parent bba5f73 commit 48604b6
Show file tree
Hide file tree
Showing 93 changed files with 15,769 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks

exclude: '^3rdparty|COPYING|.gitmodules'
exclude: '^3rdparty|COPYING|.gitmodules|src/libpsi/tools/zip/minizip'
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
Expand Down
29 changes: 29 additions & 0 deletions src/libpsi/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks

exclude: '^3rdparty|tools/zip/minizip|COPYING'
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-added-large-files
- id: check-merge-conflict
- repo: https://github.com/doublify/pre-commit-clang-format
# for clang-tidy we can take github.com/pocc/pre-commit-hooks
rev: f4c4ac5948aff384af2b439bfabb2bdd65d2b3ac
hooks:
- id: clang-format
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.1.7
hooks:
- id: forbid-crlf
- id: remove-crlf
- id: forbid-tabs
- id: remove-tabs
- repo: https://github.com/openstack-dev/bashate
rev: 2.0.0
hooks:
- id: bashate
args: ['--ignore', 'E006']
295 changes: 295 additions & 0 deletions src/libpsi/COPYING

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/libpsi/README
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
libpsi is internal library for Psi and Psi+ projects
24 changes: 24 additions & 0 deletions src/libpsi/dialogs/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
unset(HEADERS)
unset(FORMS)
unset(SOURCES)
unset(UI_FORMS)
unset(EXTRA_LDFLAGS)

include_directories(libpsi/dialogs)

list(APPEND HEADERS
grepshortcutkeydialog.h
)

list(APPEND SOURCES
grepshortcutkeydialog.cpp
)

list(APPEND FORMS
grepshortcutkeydialog.ui
)

qt_wrap_ui(UI_FORMS ${FORMS})
add_library(libpsi_dialogs STATIC ${HEADERS} ${SOURCES} ${UI_FORMS})
target_link_libraries(libpsi_dialogs ${QT_LIBRARIES})
target_include_directories(libpsi_dialogs PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
108 changes: 108 additions & 0 deletions src/libpsi/dialogs/grepshortcutkeydialog.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/*
* grepshortcutkeydialog.cpp - a dialog which greps a KeySequence and
* emits a signal with this KeySequence as Parameter
* Copyright (C) 2006 Cestonaro Thilo
*
* 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 2
* 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 <https://www.gnu.org/licenses/>.
*
*/

#include "grepshortcutkeydialog.h"

GrepShortcutKeyDialog::GrepShortcutKeyDialog() : QDialog(), gotKey(false)
{
setAttribute(Qt::WA_DeleteOnClose);
ui_.setupUi(this);
setWindowTitle(tr("Press shortcut"));
displayPressedKeys(QKeySequence());
}

/**
* Grabs the keyboard and proceeds with the default show() call.
*/
void GrepShortcutKeyDialog::show()
{
QDialog::show();
grabKeyboard();
setFocus();
}

/**
* Releases the grabbed keyboard and proceeds with the default close() call.
*/
void GrepShortcutKeyDialog::closeEvent(QCloseEvent *event)
{
releaseKeyboard();
event->accept();
}

void GrepShortcutKeyDialog::displayPressedKeys(const QKeySequence &keys)
{
QString str = keys.toString(QKeySequence::NativeText);
if (str.isEmpty())
str = tr("Set Keys");
ui_.shortcutPreview->setText(str);
}

QKeySequence GrepShortcutKeyDialog::getKeySequence(QKeyEvent *event) const
{
return QKeySequence((isValid(event->key()) ? event->key() : 0) | (event->modifiers() & ~Qt::KeypadModifier));
}

void GrepShortcutKeyDialog::keyPressEvent(QKeyEvent *event)
{
displayPressedKeys(getKeySequence(event));

if (!isValid(event->key()) || gotKey)
return;

gotKey = true;
emit newShortcutKey(getKeySequence(event));
close();
}

void GrepShortcutKeyDialog::keyReleaseEvent(QKeyEvent *event) { displayPressedKeys(getKeySequence(event)); }

/**
* Returns true if \param key could be used in a shortcut.
*/
bool GrepShortcutKeyDialog::isValid(int key) const
{
switch (key) {
case 0:
case Qt::Key_unknown:
return false;
}

return !isModifier(key);
}

/**
* Returns true if \param key is modifier.
*/
bool GrepShortcutKeyDialog::isModifier(int key) const
{
switch (key) {
case Qt::Key_Shift:
case Qt::Key_Control:
case Qt::Key_Meta:
case Qt::Key_Alt:
case Qt::Key_AltGr:
case Qt::Key_Super_L:
case Qt::Key_Super_R:
case Qt::Key_Menu:
return true;
}
return false;
}
57 changes: 57 additions & 0 deletions src/libpsi/dialogs/grepshortcutkeydialog.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* grepshortcutkeydialog.h - a dialog which greps a KeySequence and
* emits a signal with this KeySequence as Parameter
* Copyright (C) 2006 Cestonaro Thilo
*
* 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 2
* 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 <https://www.gnu.org/licenses/>.
*
*/

#ifndef GREPSHORTCUTKEYDIALOG_H
#define GREPSHORTCUTKEYDIALOG_H

#include "ui_grepshortcutkeydialog.h"

#include <QDialog>
#include <QKeyEvent>
#include <QKeySequence>

class GrepShortcutKeyDialog : public QDialog {
Q_OBJECT
public:
GrepShortcutKeyDialog();

// reimplemented
void show();

protected:
// reimplemented
void keyPressEvent(QKeyEvent *event);
void keyReleaseEvent(QKeyEvent *event);
void closeEvent(QCloseEvent *event);

signals:
void newShortcutKey(const QKeySequence &key);

private:
Ui::GrepShortcutKeyDialog ui_;
bool gotKey;

void displayPressedKeys(const QKeySequence &keys);
QKeySequence getKeySequence(QKeyEvent *event) const;
bool isValid(int key) const;
bool isModifier(int key) const;
};

#endif // GREPSHORTCUTKEYDIALOG_H
77 changes: 77 additions & 0 deletions src/libpsi/dialogs/grepshortcutkeydialog.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<ui version="4.0" >
<class>GrepShortcutKeyDialog</class>
<widget class="QWidget" name="GrepShortcutKeyDialog" >
<property name="windowModality" >
<enum>Qt::ApplicationModal</enum>
</property>
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>255</width>
<height>50</height>
</rect>
</property>
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>0</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="contextMenuPolicy" >
<enum>Qt::NoContextMenu</enum>
</property>
<layout class="QHBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QLineEdit" name="shortcutPreview" >
<property name="focusPolicy" >
<enum>Qt::NoFocus</enum>
</property>
<property name="alignment" >
<set>Qt::AlignHCenter</set>
</property>
<property name="readOnly" >
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton" >
<property name="focusPolicy" >
<enum>Qt::NoFocus</enum>
</property>
<property name="text" >
<string>Cancel</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>pushButton</sender>
<signal>clicked()</signal>
<receiver>GrepShortcutKeyDialog</receiver>
<slot>close()</slot>
<hints>
<hint type="sourcelabel" >
<x>207</x>
<y>83</y>
</hint>
<hint type="destinationlabel" >
<x>100</x>
<y>23</y>
</hint>
</hints>
</connection>
</connections>
</ui>
Loading

0 comments on commit 48604b6

Please sign in to comment.