Skip to content

Commit

Permalink
initial code
Browse files Browse the repository at this point in the history
  • Loading branch information
rodlie committed Sep 9, 2022
1 parent 47ce5df commit 0f0b795
Show file tree
Hide file tree
Showing 13 changed files with 934 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
build
tools
*.exe
*.pro.*
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "hotkey"]
path = hotkey
url = https://github.com/Skycoder42/QHotkey
674 changes: 674 additions & 0 deletions COPYING

Large diffs are not rendered by default.

31 changes: 30 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,30 @@
# nsclip
# nsClip

Simple application that removes whitespace from clipboard.

## Workflow

* Copy some text (``Ctrl+C``)
* Remove whitespace (``Alt+Win+C``)
* Paste text (``Ctrl+V``)

## How does it work?

The application runs in the background and when activated (``Alt+Win+C``) will strip whitespace from the current clipboard text.

### Input

```
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla est purus, ultrices in porttitor
in, accumsan non quam. Nam consectetur porttitor rhoncus. Curabitur eu est et leo feugiat
auctor vel quis lorem. Ut et ligula dolor, sit amet consequat lorem. Aliquam porta eros sed
velit imperdiet egestas. Maecenas tempus eros ut diam ullamcorper id dictum libero
tempor. Donec quis augue quis magna condimentum lobortis. Quisque imperdiet ipsum vel
magna viverra rutrum. Cras viverra molestie urna, vitae vestibulum turpis varius id.
```

### Output

```
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla est purus, ultrices in porttitor in, accumsan non quam. Nam consectetur porttitor rhoncus. Curabitur eu est et leo feugiat auctor vel quis lorem. Ut et ligula dolor, sit amet consequat lorem. Aliquam porta eros sed velit imperdiet egestas. Maecenas tempus eros ut diam ullamcorper id dictum libero tempor. Donec quis augue quis magna condimentum lobortis. Quisque imperdiet ipsum vel magna viverra rutrum. Cras viverra molestie urna, vitae vestibulum turpis varius id.
```
1 change: 1 addition & 0 deletions hotkey
Submodule hotkey added at 34777f
39 changes: 39 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
#
# nsClip - https://github.com/nettstudio/nsclip
#
# Copyright (c) 2022 NettStudio AS <https://nettstudio.no>.
# All rights reserved.
#
# 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/>
#
*/

#include "nsclip.h"

#include <QObject>
#include <QGuiApplication>

int main(int argc, char *argv[])
{
QGuiApplication a(argc, argv);
QGuiApplication::setApplicationDisplayName("nsClip");
QGuiApplication::setApplicationName("nsClip");
QGuiApplication::setOrganizationName("NettStudio AS");
QGuiApplication::setOrganizationDomain("nettstudio.no");

nsClip clip;

return a.exec();
}
39 changes: 39 additions & 0 deletions nsclip.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
@echo off

call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" x64 %*

set CWD=%cd%
set TOOLS=%CWD%\tools
set QT_MAJOR=5
set QT_MINOR=12
set QT_PATCH=12
set QT_VERSION=%QT_MAJOR%.%QT_MINOR%.%QT_PATCH%
set QT_DIR=%TOOLS%\qt

set PATH=%QT_DIR%\bin;%ProgramFiles%\7-Zip;%PATH%

set QTBASE=qtbase-everywhere-src-%QT_VERSION%
set QTTOOLS=qttools-everywhere-src-%QT_VERSION%
set QT_URL=https://mirrors.dotsrc.org/qtproject/archive/qt/%QT_MAJOR%.%QT_MINOR%/%QT_VERSION%/submodules
set QTBASE_URL=%QT_URL%/%QTBASE%.zip
set QTTOOLS_URL=%QT_URL%/%QTTOOLS%.zip

@RD /S /Q build
mkdir build
mkdir "%TOOLS%"

if not exist "%QT_DIR%\bin\qmake.exe" (
if not exist "%TOOLS%\%QTBASE%.zip" (
curl --url %QTBASE_URL% -o "%TOOLS%\%QTBASE%.zip"
)
cd "%CWD%\build"
7z x "%TOOLS%\%QTBASE%.zip"
cd "%QTBASE%"
configure.bat -static -release -prefix "%QT_DIR%" -platform win32-msvc2019 -opensource -confirm-license -nomake examples -nomake tests -static-runtime -opengl desktop -optimize-size -no-pch -no-glib -no-dbus -no-sse4.2 -no-avx -no-avx2 -no-avx512 -strip -no-openssl -no-gif -no-ico
nmake
nmake install
)

cd "%CWD%\build"
qmake.exe CONFIG+=release ..
nmake
57 changes: 57 additions & 0 deletions nsclip.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
#
# nsClip - https://github.com/nettstudio/nsclip
#
# Copyright (c) 2022 NettStudio AS <https://nettstudio.no>.
# All rights reserved.
#
# 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/>
#
*/

#include "nsclip.h"

#include <QGuiApplication>
#include <QClipboard>
#include <QHotkey>
#include <QDebug>

nsClip::nsClip(QObject *parent)
: QObject{parent}
, _tray(nullptr)
{
_tray = new QSystemTrayIcon(this);
_tray->setIcon( QIcon(":/nsclip.png") );
_tray->setToolTip("nsClip");
_tray->show();

QHotkey *hotkey1 = new QHotkey(QKeySequence("Alt+Meta+C"),
true,
this);
QObject::connect(hotkey1,
&QHotkey::activated,
this,
&nsClip::handleSimplifyClipboard);
}

void nsClip::handleSimplifyClipboard()
{
QString text = QGuiApplication::clipboard()->text();
if ( text.isEmpty() ) { return; }

qDebug() << "IN" << text;
qDebug() << "OUT" << text.simplified();

QGuiApplication::clipboard()->setText( text.simplified() );
}
43 changes: 43 additions & 0 deletions nsclip.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
#
# nsClip - https://github.com/nettstudio/nsclip
#
# Copyright (c) 2022 NettStudio AS <https://nettstudio.no>.
# All rights reserved.
#
# 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/>
#
*/

#ifndef NSCLIP_H
#define NSCLIP_H

#include <QObject>
#include <QSystemTrayIcon>

class nsClip : public QObject
{
Q_OBJECT

public:
explicit nsClip(QObject *parent = nullptr);

private:
QSystemTrayIcon *_tray;

private slots:
void handleSimplifyClipboard();
};

#endif // NSCLIP_H
Binary file added nsclip.ico
Binary file not shown.
Binary file added nsclip.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 39 additions & 0 deletions nsclip.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#
# nsClip - https://github.com/nettstudio/nsclip
#
# Copyright (c) 2022 NettStudio AS <https://nettstudio.no>.
# All rights reserved.
#
# 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/>
#

VERSION= 2022.9.9
TEMPLATE = app

QT += core gui widgets
CONFIG += c++11
SOURCES += main.cpp nsclip.cpp
HEADERS += nsclip.h
RESOURCES += nsclip.qrc

CONFIG(release, debug|release): DEFINES += QT_NO_DEBUG_OUTPUT QT_NO_WARNING_OUTPUT

QMAKE_TARGET_PRODUCT = "nsClip"
QMAKE_TARGET_DESCRIPTION = "nsClip"
QMAKE_TARGET_COPYRIGHT = "NettStudio AS"
QMAKE_TARGET_COMPANY = "NettStudio AS"

win32: RC_ICONS += nsclip.ico

include(hotkey/qhotkey.pri)
5 changes: 5 additions & 0 deletions nsclip.qrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/">
<file>nsclip.png</file>
</qresource>
</RCC>

0 comments on commit 0f0b795

Please sign in to comment.