Skip to content

Commit 00e967a

Browse files
committed
Merge branch '0.6.0'
2 parents 111de08 + d5a9cdc commit 00e967a

File tree

8 files changed

+52
-33
lines changed

8 files changed

+52
-33
lines changed

redis-desktop-manager/forms/connection.ui

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
</rect>
9999
</property>
100100
<property name="currentIndex">
101-
<number>0</number>
101+
<number>1</number>
102102
</property>
103103
<widget class="QWidget" name="mainTab">
104104
<attribute name="title">
@@ -122,8 +122,11 @@
122122
</property>
123123
<item row="2" column="2">
124124
<widget class="QSpinBox" name="portSpinBox">
125+
<property name="minimum">
126+
<number>1</number>
127+
</property>
125128
<property name="maximum">
126-
<number>100000</number>
129+
<number>65535</number>
127130
</property>
128131
<property name="value">
129132
<number>6379</number>
@@ -249,7 +252,7 @@
249252
<number>1</number>
250253
</property>
251254
<property name="maximum">
252-
<number>10000</number>
255+
<number>65535</number>
253256
</property>
254257
<property name="value">
255258
<number>22</number>
Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
11
#pragma once
22

33
#include <QObject>
4+
#include "RedisConnectionConfig.h"
45

5-
class RedisConnectionConfig;
66
class RedisConnectionAbstract;
7-
class consoleTab;
87

98
class ConsoleConnectionWrapper : public QObject
109
{
1110
Q_OBJECT
1211

1312
public:
14-
ConsoleConnectionWrapper(RedisConnectionConfig &, consoleTab &);
13+
ConsoleConnectionWrapper(RedisConnectionConfig &);
1514

1615
public slots:
16+
void init();
1717
void executeCommand(QString);
1818

19+
signals:
20+
void changePrompt(QString);
21+
void addOutput(QString);
22+
1923
private:
2024
RedisConnectionAbstract * connection;
21-
consoleTab & consoleView;
25+
RedisConnectionConfig config;
2226
bool connectionValid;
2327
};
2428

redis-desktop-manager/include/widgets/consoleTab.h

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
#pragma once
22

3-
/**
4-
Based on Console Qt widget from RedisConsole
5-
https://github.com/ptrofimov/RedisConsole
6-
author Petr Trofimov ([email protected])
7-
**/
83

94
#include <QPlainTextEdit>
5+
#include <QThread>
106

117
class RedisConnectionConfig;
128
class ConsoleConnectionWrapper;
@@ -18,10 +14,12 @@ class consoleTab: public QPlainTextEdit
1814
public:
1915
consoleTab(RedisConnectionConfig&);
2016
~consoleTab(void);
21-
void output(QString);
22-
void setPrompt(QString);
2317
void scrollDown();
2418

19+
public slots:
20+
void output(QString);
21+
void setPrompt(QString);
22+
2523
protected:
2624
void keyPressEvent(QKeyEvent *);
2725
void mousePressEvent(QMouseEvent *);
@@ -33,7 +31,7 @@ class consoleTab: public QPlainTextEdit
3331
QStringList *history;
3432
int historyPos;
3533
ConsoleConnectionWrapper * connection;
36-
//QThread connectionThread;
34+
QThread connectionThread;
3735

3836
void onEnter();
3937
void insertPrompt(bool insertNewBlock = true);

redis-desktop-manager/source/demo.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,9 @@ void MainWin::OnConnectionTreeClick(const QModelIndex & index)
151151
connections->updateFilter();
152152
loadingInProgress = false;
153153

154-
if (!connected) {
155-
QMessageBox::warning(this, "Can't connect to server", "Can't connect to server. Check connection settings");
154+
if (!connected) {
155+
QMessageBox::warning(this, "Can't connect to server",
156+
QString("Check connection settings \nError: %1").arg(server->getConnection()->getLastError()));
156157
}
157158
}
158159
break;

redis-desktop-manager/source/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ int main(int argc, char *argv[])
66
QApplication a(argc, argv);
77

88
QApplication::setApplicationName("Redis Desktop Manager");
9-
QApplication::setApplicationVersion("0.5.1");
9+
QApplication::setApplicationVersion("0.5.2");
1010
QApplication::setOrganizationDomain("redisdesktop.com");
1111

1212
MainWin w;

redis-desktop-manager/source/redis/ConsoleConnectionWrapper.cpp

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,40 +6,45 @@
66
#include "consoleTab.h"
77
#include "Response.h"
88

9-
ConsoleConnectionWrapper::ConsoleConnectionWrapper(RedisConnectionConfig &config, consoleTab &view)
10-
: consoleView(view) , connectionValid(false)
9+
ConsoleConnectionWrapper::ConsoleConnectionWrapper(RedisConnectionConfig &config)
10+
: config(config), connectionValid(false)
11+
{
12+
}
13+
14+
void ConsoleConnectionWrapper::init()
1115
{
1216
if (config.isNull())
1317
{
14-
consoleView.output("Invalid config. Can't create connection.");
18+
emit addOutput("Invalid config. Can't create connection.");
1519
return;
1620
}
1721

1822
connection = (config.useSshTunnel()) ? (RedisConnectionAbstract *) new RedisConnectionOverSsh(config)
19-
: (RedisConnectionAbstract *) new RedisConnection(config);
23+
: (RedisConnectionAbstract *) new RedisConnection(config);
2024

2125
if (!connection->connect())
2226
{
23-
consoleView.output("Invalid config. Can't create connection.");
27+
emit addOutput("Invalid config. Can't create connection.");
2428
return;
2529
}
2630

2731
connectionValid = true;
28-
consoleView.setPrompt(QString("%1:0>").arg(config.name));
29-
consoleView.output("Connected.");
32+
33+
emit changePrompt(QString("%1:0>").arg(config.name));
34+
emit addOutput("Connected.");
3035
}
3136

3237
void ConsoleConnectionWrapper::executeCommand(QString cmd)
3338
{
3439
if (!connectionValid)
3540
{
36-
consoleView.output("Invalid config. Can't create connection.");
41+
emit addOutput("Invalid config. Can't create connection.");
3742
return;
3843
}
3944

4045
if (!connection->isConnected() && !connection->connect())
4146
{
42-
consoleView.output("Connection error. Check network connection");
47+
emit addOutput("Connection error. Check network connection");
4348
return;
4449
}
4550

@@ -51,12 +56,12 @@ void ConsoleConnectionWrapper::executeCommand(QString cmd)
5156

5257
if (isSelectCommand)
5358
{
54-
consoleView.setPrompt(
59+
emit changePrompt(
5560
QString("%1:%2>")
5661
.arg(connection->config.name)
5762
.arg(selectDbRegex.cap(3))
5863
);
5964
}
6065

61-
consoleView.output(Response::valueToString(result));
66+
addOutput(Response::valueToString(result));
6267
}

redis-desktop-manager/source/redis/RedisConnectionOverSsh.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ void RedisConnectionOverSsh::OnSocketReadyRead()
112112
QString RedisConnectionOverSsh::getLastError()
113113
{
114114
if (socket == NULL) {
115-
return QString("Error with ssh connection");
115+
return QString("SSH connection error");
116116
}
117117

118118
return socket->errorString();

redis-desktop-manager/source/widgets/consoleTab.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
consoleTab::consoleTab(RedisConnectionConfig& config)
1010
{
1111
appendHtml("<span style='color: orange;'>List of unsupported commands: PTTL, DUMP, RESTORE, AUTH, QUIT, MONITOR</span>");
12+
appendHtml("Connecting ...");
1213

1314
QPalette p = palette();
1415
p.setColor(QPalette::Base, QColor(57, 57, 57));
@@ -20,16 +21,23 @@ consoleTab::consoleTab(RedisConnectionConfig& config)
2021
insertPrompt(false);
2122
isLocked = false;
2223

23-
connection = new ConsoleConnectionWrapper(config, *this);
24+
connection = new ConsoleConnectionWrapper(config);
25+
connection->moveToThread(&connectionThread);
2426

27+
connect(&connectionThread, &QThread::finished, connection, &QObject::deleteLater);
2528
connect(this, SIGNAL(onCommand(QString)), connection, SLOT(executeCommand(QString)));
29+
connect(connection, SIGNAL(changePrompt(QString)), this, SLOT(setPrompt(QString)));
30+
connect(connection, SIGNAL(addOutput(QString)), this, SLOT(output(QString)));
31+
connect(&connectionThread, SIGNAL(started()), connection, SLOT(init()));
32+
33+
connectionThread.start();
2634
}
2735

2836

2937
consoleTab::~consoleTab(void)
3038
{
31-
//connectionThread.quit();
32-
///connectionThread.wait();
39+
connectionThread.quit();
40+
connectionThread.wait();
3341
}
3442

3543
void consoleTab::setPrompt(QString str)

0 commit comments

Comments
 (0)