Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
psemiletov committed Sep 26, 2019
1 parent adc6e38 commit 70831fc
Show file tree
Hide file tree
Showing 11 changed files with 100 additions and 87 deletions.
2 changes: 1 addition & 1 deletion fman.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class CFMan: public QTreeView
Qt::SortOrder sort_order;

QStandardItemModel *mymodel;
QList <QFileInfo> list;
// QList <QFileInfo> files_list;

CFMan (QWidget *parent = 0);

Expand Down
11 changes: 3 additions & 8 deletions logmemo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
#include <QTextBlock>
#include <QTextCursor>

//#if QT_VERSION >= 0x05
#if QT_VERSION_MAJOR >= 5
#if QT_VERSION >= 0x050000
#include <QRegularExpression>
#include <QRegularExpressionMatch>
#endif
Expand All @@ -46,9 +45,7 @@ CLogMemo::CLogMemo (QWidget *parent): QPlainTextEdit (parent)
Qt::TextSelectableByKeyboard);
}

//#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#if QT_VERSION_MAJOR >= 5

#if QT_VERSION >= 0x050000
void CLogMemo::log_terminal (const QString &text)
{
if (no_jump)
Expand Down Expand Up @@ -87,9 +84,7 @@ void CLogMemo::log_terminal (const QString &text)
void CLogMemo::log (const QString &text)
{

//#if QT_VERSION >= 0x05
#if QT_VERSION_MAJOR >= 5

#if QT_VERSION >= 0x050000
if (terminal_output)
{
log_terminal (text);
Expand Down
4 changes: 1 addition & 3 deletions logmemo.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ class CLogMemo: public QPlainTextEdit

Q_INVOKABLE void log (const QString &text);

//#if QT_VERSION >= 0x05
#if QT_VERSION_MAJOR >= 5

#if QT_VERSION >= 0x050000
void log_terminal (const QString &text);
#endif

Expand Down
3 changes: 1 addition & 2 deletions myjoystick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void CJoystick::read_joystick_depr()
event->value = js.x;
}

QApplication::postEvent (receiver, reinterpret_cast<QEvent*>(event));
QApplication::postEvent (receiver, reinterpret_cast<QEvent*>(event));
}


Expand All @@ -89,7 +89,6 @@ void CJoystick::read_joystick()
process_event (e);
}


if (errno != EAGAIN)
{
qDebug() << "Joystick read error";
Expand Down
12 changes: 6 additions & 6 deletions rvln.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6321,12 +6321,12 @@ void rvln::fman_delete()
update_dyn_menus();
fman->refresh();

if (i < fman->list.count())
{
QModelIndex index = fman->index_from_idx (i);
fman->selectionModel()->setCurrentIndex (index, QItemSelectionModel::Select | QItemSelectionModel::Rows);
fman->scrollTo (index, QAbstractItemView::PositionAtCenter);
}
QModelIndex index = fman->index_from_idx (i);
if (! index.isValid())
index = fman->index_from_idx (0);

fman->selectionModel()->setCurrentIndex (index, QItemSelectionModel::Select | QItemSelectionModel::Rows);
fman->scrollTo (index, QAbstractItemView::PositionAtCenter);
}


Expand Down
7 changes: 4 additions & 3 deletions single_application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

#include "single_application.h"

CSingleApplication::CSingleApplication(int &argc, char *argv[], const QString uniqueKey) : QApplication(argc, argv), _uniqueKey(uniqueKey)
CSingleApplication::CSingleApplication(int &argc, char *argv[], const QString uniqueKey): QApplication(argc, argv), _uniqueKey (uniqueKey)
{

#ifndef Q_OS_OS2
Expand Down Expand Up @@ -44,7 +44,7 @@ CSingleApplication::CSingleApplication(int &argc, char *argv[], const QString un
#endif
}

// public slots.
// public slots

void CSingleApplication::receiveMessage()
{
Expand All @@ -66,7 +66,7 @@ void CSingleApplication::receiveMessage()
delete localSocket;
}

// public functions.
// public functions

bool CSingleApplication::isRunning()
{
Expand Down Expand Up @@ -102,3 +102,4 @@ bool CSingleApplication::sendMessage(const QString &message)
localSocket.disconnectFromServer();
return true;
}

38 changes: 21 additions & 17 deletions single_application.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,35 @@

class CSingleApplication : public QApplication
{
Q_OBJECT
public:
CSingleApplication (int &argc, char *argv[], const QString uniqueKey);
Q_OBJECT

private:

#ifndef Q_OS_OS2
QSharedMemory sharedMemory;
#endif

bool _isRunning;
QString _uniqueKey;

bool isRunning();
bool sendMessage(const QString &message);
QLocalServer *localServer;
static const int timeout = 1000;

static int cursorFlashTime() {return 0;};
public:

CSingleApplication (int &argc, char *argv[], const QString uniqueKey);
bool isRunning();
bool sendMessage(const QString &message);
static int cursorFlashTime() {return 0;};

public slots:
void receiveMessage();

signals:
void messageAvailable(QString message);
void receiveMessage();

private:
bool _isRunning;
QString _uniqueKey;
signals:

#ifndef Q_OS_OS2
QSharedMemory sharedMemory;
#endif
QLocalServer *localServer;
void messageAvailable(QString message);

static const int timeout = 1000;
};

#endif // SINGLE_APP_H
Expand Down
23 changes: 12 additions & 11 deletions single_application_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ CSingleApplicationShared::CSingleApplicationShared (int &argc, char *argv[], con
{
#ifndef Q_OS_OS2

qDebug() << "CSingleApplicationShared::CSingleApplicationShared";
// qDebug() << "CSingleApplicationShared::CSingleApplicationShared";

sharedMemory.setKey(uniqueKey);

Expand All @@ -30,13 +30,13 @@ CSingleApplicationShared::CSingleApplicationShared (int &argc, char *argv[], con
*(char*)sharedMemory.data() = '\0';
sharedMemory.unlock();

bAlreadyExists = false;
bAlreadyExists = false;

// start checking for messages of other instances.
QTimer *timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(checkForMessage()));
timer->start(200);
}
// start checking for messages of other instances.
QTimer *timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(checkForMessage()));
timer->start(200);
}

// it exits, so we can attach it?!
else
Expand All @@ -49,7 +49,7 @@ CSingleApplicationShared::CSingleApplicationShared (int &argc, char *argv[], con
}


// public slots.
// public slots

void CSingleApplicationShared::checkForMessage()
{
Expand All @@ -72,10 +72,10 @@ void CSingleApplicationShared::checkForMessage()
arguments << QString::fromUtf8 (byteArray.constData());
}

*(char*)sharedMemory.data() = '\0';
sharedMemory.unlock();
*(char*)sharedMemory.data() = '\0';
sharedMemory.unlock();

if (arguments.size()) emit messageAvailable (arguments);
if (arguments.size()) emit messageAvailable (arguments);
#endif
}

Expand Down Expand Up @@ -108,5 +108,6 @@ bool CSingleApplicationShared::sendMessage (const QString &message)
sharedMemory.unlock();

#endif

return true;
}
63 changes: 35 additions & 28 deletions single_application_shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,44 +19,51 @@

class CSingleApplicationShared: public QApplication
{
Q_OBJECT
Q_OBJECT


private:

#ifndef Q_OS_OS2
QSharedMemory sharedMemory;
#endif

bool bAlreadyExists;

public:
CSingleApplicationShared (int &argc, char *argv[], const QString uniqueKey);
~CSingleApplicationShared() {qDebug() << "~CSingleApplicationShared";};

static int cursorFlashTime()
{
return 0;
}

CSingleApplicationShared (int &argc, char *argv[], const QString uniqueKey);
~CSingleApplicationShared() {qDebug() << "~CSingleApplicationShared";};

static int cursorFlashTime()
{
return 0;
}

bool alreadyExists() const
{
return bAlreadyExists;
}
bool alreadyExists() const
{
return bAlreadyExists;
}

bool isMasterApp() const
{
return !alreadyExists();
}
bool isMasterApp() const
{
return ! alreadyExists();
}

bool sendMessage(const QString &message);
bool sendMessage (const QString &message);


public slots:
void checkForMessage();


void checkForMessage();

signals:
void messageAvailable(const QStringList& messages);
void signal_commit_data();

void messageAvailable(const QStringList& messages);
void signal_commit_data();

private:
bool bAlreadyExists;

#ifndef Q_OS_OS2
QSharedMemory sharedMemory;
#endif
};


#endif // SINGLE_APP_SHARED_H

22 changes: 15 additions & 7 deletions utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ QString change_file_ext (const QString &s, const QString &ext)
if (i == -1)
return (s + "." + ext);


QString r (s);
r.truncate (++i);

Expand Down Expand Up @@ -182,8 +181,10 @@ bool char_is_bad (const QChar &c)

void qstring_list_print (const QStringList &l)
{
foreach (QString s, l)
qDebug() << s;
// foreach (QString s, l)
// qDebug() << s;
for (int i = 0; i < l.size(); i++)
qDebug() << l[i];
}


Expand Down Expand Up @@ -220,17 +221,24 @@ QString qstring_load_value (const QString &fileName, const QString &key, const Q
return hash_get_val (h, key, def);
}


/*
QString hash_keyval_to_string (const QHash <QString, QString> &h)
{
QStringList l;
foreach (QString s, h.keys())
l.prepend (s.append ("=").append (h.value (s)));
// foreach (QString s, h.keys())
// l.prepend (s.append ("=").append (h.value (s)));
QList< QString> keys = h.keys();
QList <QString>::iterator i;
for (i = keys.begin(); i != keys.end(); ++i)
l.prepend (*i + "=" + h.value (*i));
return l.join ("\n").trimmed();
}

*/

QHash <QString, QString> hash_load (const QString &fname)
{
Expand Down
2 changes: 1 addition & 1 deletion utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void strlist_swap (QStringList &l, int a, int b);

QString hash_get_val (QHash<QString, QString> &h, const QString &key, const QString &def_val);
QString qstring_load_value (const QString &fileName, const QString &key, const QString &def);
QString hash_keyval_to_string (const QHash<QString, QString> &h);
//QString hash_keyval_to_string (const QHash<QString, QString> &h);

QHash<QString, QString> hash_load (const QString &fname);
QHash<QString, QString> hash_load_keyval (const QString &fname);
Expand Down

0 comments on commit 70831fc

Please sign in to comment.