Skip to content

Commit 0f0b795

Browse files
committed
initial code
1 parent 47ce5df commit 0f0b795

File tree

13 files changed

+934
-1
lines changed

13 files changed

+934
-1
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
build
2+
tools
3+
*.exe
4+
*.pro.*

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "hotkey"]
2+
path = hotkey
3+
url = https://github.com/Skycoder42/QHotkey

COPYING

Lines changed: 674 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,30 @@
1-
# nsclip
1+
# nsClip
2+
3+
Simple application that removes whitespace from clipboard.
4+
5+
## Workflow
6+
7+
* Copy some text (``Ctrl+C``)
8+
* Remove whitespace (``Alt+Win+C``)
9+
* Paste text (``Ctrl+V``)
10+
11+
## How does it work?
12+
13+
The application runs in the background and when activated (``Alt+Win+C``) will strip whitespace from the current clipboard text.
14+
15+
### Input
16+
17+
```
18+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla est purus, ultrices in porttitor
19+
in, accumsan non quam. Nam consectetur porttitor rhoncus. Curabitur eu est et leo feugiat
20+
auctor vel quis lorem. Ut et ligula dolor, sit amet consequat lorem. Aliquam porta eros sed
21+
velit imperdiet egestas. Maecenas tempus eros ut diam ullamcorper id dictum libero
22+
tempor. Donec quis augue quis magna condimentum lobortis. Quisque imperdiet ipsum vel
23+
magna viverra rutrum. Cras viverra molestie urna, vitae vestibulum turpis varius id.
24+
```
25+
26+
### Output
27+
28+
```
29+
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.
30+
```

hotkey

Submodule hotkey added at 34777f2

main.cpp

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
#
3+
# nsClip - https://github.com/nettstudio/nsclip
4+
#
5+
# Copyright (c) 2022 NettStudio AS <https://nettstudio.no>.
6+
# All rights reserved.
7+
#
8+
# This program is free software; you can redistribute it and/or modify
9+
# it under the terms of the GNU General Public License as published by
10+
# the Free Software Foundation; either version 3 of the License, or
11+
# (at your option) any later version.
12+
#
13+
# This program is distributed in the hope that it will be useful,
14+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
# GNU General Public License for more details.
17+
#
18+
# You should have received a copy of the GNU General Public License
19+
# along with this program. If not, see <http://www.gnu.org/licenses/>
20+
#
21+
*/
22+
23+
#include "nsclip.h"
24+
25+
#include <QObject>
26+
#include <QGuiApplication>
27+
28+
int main(int argc, char *argv[])
29+
{
30+
QGuiApplication a(argc, argv);
31+
QGuiApplication::setApplicationDisplayName("nsClip");
32+
QGuiApplication::setApplicationName("nsClip");
33+
QGuiApplication::setOrganizationName("NettStudio AS");
34+
QGuiApplication::setOrganizationDomain("nettstudio.no");
35+
36+
nsClip clip;
37+
38+
return a.exec();
39+
}

nsclip.bat

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
@echo off
2+
3+
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" x64 %*
4+
5+
set CWD=%cd%
6+
set TOOLS=%CWD%\tools
7+
set QT_MAJOR=5
8+
set QT_MINOR=12
9+
set QT_PATCH=12
10+
set QT_VERSION=%QT_MAJOR%.%QT_MINOR%.%QT_PATCH%
11+
set QT_DIR=%TOOLS%\qt
12+
13+
set PATH=%QT_DIR%\bin;%ProgramFiles%\7-Zip;%PATH%
14+
15+
set QTBASE=qtbase-everywhere-src-%QT_VERSION%
16+
set QTTOOLS=qttools-everywhere-src-%QT_VERSION%
17+
set QT_URL=https://mirrors.dotsrc.org/qtproject/archive/qt/%QT_MAJOR%.%QT_MINOR%/%QT_VERSION%/submodules
18+
set QTBASE_URL=%QT_URL%/%QTBASE%.zip
19+
set QTTOOLS_URL=%QT_URL%/%QTTOOLS%.zip
20+
21+
@RD /S /Q build
22+
mkdir build
23+
mkdir "%TOOLS%"
24+
25+
if not exist "%QT_DIR%\bin\qmake.exe" (
26+
if not exist "%TOOLS%\%QTBASE%.zip" (
27+
curl --url %QTBASE_URL% -o "%TOOLS%\%QTBASE%.zip"
28+
)
29+
cd "%CWD%\build"
30+
7z x "%TOOLS%\%QTBASE%.zip"
31+
cd "%QTBASE%"
32+
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
33+
nmake
34+
nmake install
35+
)
36+
37+
cd "%CWD%\build"
38+
qmake.exe CONFIG+=release ..
39+
nmake

nsclip.cpp

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
#
3+
# nsClip - https://github.com/nettstudio/nsclip
4+
#
5+
# Copyright (c) 2022 NettStudio AS <https://nettstudio.no>.
6+
# All rights reserved.
7+
#
8+
# This program is free software; you can redistribute it and/or modify
9+
# it under the terms of the GNU General Public License as published by
10+
# the Free Software Foundation; either version 3 of the License, or
11+
# (at your option) any later version.
12+
#
13+
# This program is distributed in the hope that it will be useful,
14+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
# GNU General Public License for more details.
17+
#
18+
# You should have received a copy of the GNU General Public License
19+
# along with this program. If not, see <http://www.gnu.org/licenses/>
20+
#
21+
*/
22+
23+
#include "nsclip.h"
24+
25+
#include <QGuiApplication>
26+
#include <QClipboard>
27+
#include <QHotkey>
28+
#include <QDebug>
29+
30+
nsClip::nsClip(QObject *parent)
31+
: QObject{parent}
32+
, _tray(nullptr)
33+
{
34+
_tray = new QSystemTrayIcon(this);
35+
_tray->setIcon( QIcon(":/nsclip.png") );
36+
_tray->setToolTip("nsClip");
37+
_tray->show();
38+
39+
QHotkey *hotkey1 = new QHotkey(QKeySequence("Alt+Meta+C"),
40+
true,
41+
this);
42+
QObject::connect(hotkey1,
43+
&QHotkey::activated,
44+
this,
45+
&nsClip::handleSimplifyClipboard);
46+
}
47+
48+
void nsClip::handleSimplifyClipboard()
49+
{
50+
QString text = QGuiApplication::clipboard()->text();
51+
if ( text.isEmpty() ) { return; }
52+
53+
qDebug() << "IN" << text;
54+
qDebug() << "OUT" << text.simplified();
55+
56+
QGuiApplication::clipboard()->setText( text.simplified() );
57+
}

nsclip.h

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
#
3+
# nsClip - https://github.com/nettstudio/nsclip
4+
#
5+
# Copyright (c) 2022 NettStudio AS <https://nettstudio.no>.
6+
# All rights reserved.
7+
#
8+
# This program is free software; you can redistribute it and/or modify
9+
# it under the terms of the GNU General Public License as published by
10+
# the Free Software Foundation; either version 3 of the License, or
11+
# (at your option) any later version.
12+
#
13+
# This program is distributed in the hope that it will be useful,
14+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
# GNU General Public License for more details.
17+
#
18+
# You should have received a copy of the GNU General Public License
19+
# along with this program. If not, see <http://www.gnu.org/licenses/>
20+
#
21+
*/
22+
23+
#ifndef NSCLIP_H
24+
#define NSCLIP_H
25+
26+
#include <QObject>
27+
#include <QSystemTrayIcon>
28+
29+
class nsClip : public QObject
30+
{
31+
Q_OBJECT
32+
33+
public:
34+
explicit nsClip(QObject *parent = nullptr);
35+
36+
private:
37+
QSystemTrayIcon *_tray;
38+
39+
private slots:
40+
void handleSimplifyClipboard();
41+
};
42+
43+
#endif // NSCLIP_H

nsclip.ico

261 KB
Binary file not shown.

0 commit comments

Comments
 (0)