Skip to content

Commit

Permalink
get rid of tray icon, raise window if already running
Browse files Browse the repository at this point in the history
  • Loading branch information
Sunshine committed Jan 23, 2022
1 parent 85afd46 commit cdb6d5f
Show file tree
Hide file tree
Showing 19 changed files with 379 additions and 397 deletions.
10 changes: 5 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
doer
build/

# C++ objects and libs

*.slo
*.lo
*.o
Expand All @@ -13,23 +12,25 @@ doer
*.dylib

# Qt-es

/.qmake.cache
/.qmake.stash
*.pro.user
*.pro.user.*
*.qbs.user
*.qbs.user.*
.objs/
.mocs/
*.moc
moc_*.cpp
moc_*.h
.qrcs/
qrc_*.cpp
.uis/
ui_*.h
Makefile*
*build-*

# QtCreator

*.autosave

# QtCtreator Qml
Expand All @@ -38,4 +39,3 @@ Makefile*

# QtCtreator CMake
CMakeLists.txt.user

10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# Doer

This notepad application is so lightweight it saves and reads text to and from just one file.
With almost no user interface it works great as a place to keep your notes in.
With almost no user interface, it works great as a place to keep your notes in.

It was built to replace a giant collection of small paper notes scattered all over my workspace and home.
Comes in handy as a to-do list. Can also help you keep those pretty Japanese smileys at hand.

![screenshot](https://cloud.githubusercontent.com/assets/1392048/24592087/2bcfb58e-17de-11e7-8c22-27a804c2f0f0.png)
![Doer](screenshots/sc1.png)


## Customize

Placing a file named `doer.qss` into `~/.config/doer/` will serve as a custom stylesheet for the program.
Use [default.qss](res/styles/default.qss) as a reference.
Use [doer.qss](res/stylesheets/doer.qss) as a reference.


## Control
Expand All @@ -24,8 +24,8 @@ Use [default.qss](res/styles/default.qss) as a reference.

## Build

qmake -qt5
make clean && make -j 4
qmake
make -j


## Install
Expand Down
80 changes: 43 additions & 37 deletions doer.pro
Original file line number Diff line number Diff line change
@@ -1,70 +1,76 @@
include($${PWD}/modules/modules.pri)

PROG_NAME = doer

VERSION_MAJOR = 1
VERSION_MINOR = 0
VERSION_MINOR = 2
VERSION_PATCH = 0

DEFINES += "VERSION_MAJOR=$$VERSION_MAJOR"\
"VERSION_MINOR=$$VERSION_MINOR"\
"VERSION_PATCH=$$VERSION_PATCH"
VERSION = $${VERSION_MAJOR}.$${VERSION_MINOR}.$${VERSION_PATCH}

QT += core gui widgets
CONFIG += c++11
TEMPLATE = app

VERSION = $${VERSION_MAJOR}.$${VERSION_MINOR}.$${VERSION_PATCH}
DESTDIR = build

QT += core gui widgets
CONFIG += c++11
TEMPLATE = app
INC_DIR = inc
SRC_DIR = src
RES_DIR = res
FORMS_DIR = ui

SRC_DIR = src
INC_DIR = inc
FORMS_DIR = ui
OBJECTS_DIR = .objs
MOC_DIR = .mocs
UI_DIR = .uis
RCC_DIR = .qrcs

OBJECTS_DIR = .objs
MOC_DIR = .mocs
UI_DIR = .uis
RCC_DIR = .qrcs
INCLUDEPATH += $${INC_DIR}

DESTDIR = bin
TARGET = doer
HEADERS += $${INC_DIR}/mainwindow.hpp

INCLUDEPATH += $${INC_DIR}
SOURCES += $${SRC_DIR}/main.cpp \
$${SRC_DIR}/mainwindow.cpp

SOURCES += src/main.cpp \
src/mainwindow.cpp \
src/traymenu.cpp \
src/runguard.cpp
FORMS += $${FORMS_DIR}/mainwindow.ui

HEADERS += inc/mainwindow.h \
inc/traymenu.h \
inc/runguard.h
RESOURCES = $${RES_DIR}/resources.qrc

FORMS += ui/mainwindow.ui
OTHER_FILES += $${RES_DIR}/images/background.png \
$${RES_DIR}/images/$${PROG_NAME}.svg \
$${RES_DIR}/stylesheets/doer.qss

RESOURCES = res/resources.qrc
QMAKE_CLEAN += -r $${DESTDIR}/$${PROG_NAME}

OTHER_FILES += dist/$${TARGET}.desktop \
res/images/background.png \
res/images/$${TARGET}.svg \
res/images/tray.png \
res/styles/default.qss
DEFINES += PROG_NAME=\\\"$${PROG_NAME}\\\"

QMAKE_CLEAN += -r $${DESTDIR}/$${TARGET}
DEFINES += "VERSION_MAJOR=$$VERSION_MAJOR" \
"VERSION_MINOR=$$VERSION_MINOR" \
"VERSION_PATCH=$$VERSION_PATCH" \

DEFINES += VERSION=\\\"$${VERSION}\\\"

# CONFIG += debug

unix:!mac {
isEmpty(PREFIX) {
PREFIX = /usr
}
BINDIR = $${PREFIX}/bin
DATADIR =$${PREFIX}/share
BINDIR = $${PREFIX}/bin
DATADIR = $${PREFIX}/share

OTHER_FILES += dist/$${PROG_NAME}.desktop

target.path = $${BINDIR}

INSTALLS += target

desktop.path = $${DATADIR}/applications
eval(desktop.files += dist/$${TARGET}.desktop)
eval(desktop.files += dist/$${PROG_NAME}.desktop)

INSTALLS += desktop

icon.path = $${DATADIR}/icons/hicolor/scalable/apps
eval(icon.files += res/images/$${TARGET}.svg)
eval(icon.files += $${RES_DIR}/images/$${PROG_NAME}.svg)

INSTALLS += icon
}
52 changes: 0 additions & 52 deletions inc/mainwindow.h

This file was deleted.

48 changes: 48 additions & 0 deletions inc/mainwindow.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#pragma once

#include <QAction>
#include <QMainWindow>
#include <QSettings>

#include "singleinstance.hpp"

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
Q_OBJECT

public:
explicit MainWindow(QWidget *parent = Q_NULLPTR);
~MainWindow();

bool isAlreadyRunning(void);

public slots:
void exitFullScreen(void);
void quitApplication(void);
void toggleFullScreen(void);

protected:
void closeEvent(QCloseEvent *event) override;
void moveEvent(QMoveEvent *event) override;
void resizeEvent(QResizeEvent *event) override;

bool ready = false;

private slots:
void on_textArea_cursorPositionChanged(void);
void on_textArea_textChanged(void);

private:
QSettings *settings;
Ui::MainWindow *ui;
QByteArray windowGeometry;
SingleInstance *singleInstance;

void applyStyle(void);
void bindShortcuts(void);
void loadSettings(void);
};
28 changes: 0 additions & 28 deletions inc/runguard.h

This file was deleted.

17 changes: 0 additions & 17 deletions inc/traymenu.h

This file was deleted.

1 change: 1 addition & 0 deletions modules/modules.pri
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include($${PWD}/singleinstance/singleinstance.pri)
27 changes: 27 additions & 0 deletions modules/singleinstance/inc/singleinstance.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#pragma once

#include <QSharedMemory>
#include <QSystemSemaphore>
#include <QWidget>

class SingleInstance : public QObject
{
Q_OBJECT

public:
explicit SingleInstance(QWidget *parent = Q_NULLPTR, QString *progName = new QString());
~SingleInstance();

bool isAlreadyRunning(const bool raiseExisting = false);
static void raiseWindow(QWidget *window);

private:
struct SharedData
{
bool needToRaiseExistingWindow = false;
};

QSharedMemory *shMem;
QString shmemName;
QString smphorName;
};
16 changes: 16 additions & 0 deletions modules/singleinstance/singleinstance.pri
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
!win:!mac {
LIBS += -lX11 -lXfixes -lXinerama -lXext -lXcomposite
}

QT += core
CONFIG += c++11
TEMPLATE = lib

INC_DIR = inc
SRC_DIR = src

INCLUDEPATH += $${PWD}/$${INC_DIR}

HEADERS += $${PWD}/inc/singleinstance.hpp

SOURCES += $${PWD}/src/singleinstance.cpp
Loading

0 comments on commit cdb6d5f

Please sign in to comment.