Skip to content

Commit 2bed502

Browse files
authored
0.9.0-alpha2
* Implement server info tab * Add basic translations support * Update translations and messages * Update qredisclient * Fix links in WelcomeTab * Use Helvetica Neue 12px as default font on OSX
1 parent 3b901e1 commit 2bed502

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+3560
-399
lines changed

.travis.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ script:
2626
- ./../bin/tests/tests -platform minimal -txt
2727
- ./../bin/tests/qml_tests -platform minimal -txt
2828
- cd ./../src
29-
- qmake && make -s -j 2
29+
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then
30+
qmake && make -s -j 2
31+
;
32+
fi
3033
after_success:
3134
- cd ./../tests
3235
- sudo pip install cpp-coveralls

src/app/app.cpp

Lines changed: 47 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#include "logger.h"
1414
#include "qmlutils.h"
15+
#include "common/tabviewmodel.h"
1516
#include "models/connectionconf.h"
1617
#include "models/configmanager.h"
1718
#include "models/connectionsmanager.h"
@@ -20,7 +21,8 @@
2021
#include "modules/value-editor/valueviewmodel.h"
2122
#include "modules/value-editor/viewmodel.h"
2223
#include "modules/value-editor/sortfilterproxymodel.h"
23-
#include "modules/console/consoleviewmodel.h"
24+
#include "modules/console/consolemodel.h"
25+
#include "modules/server-stats/serverstatsmodel.h"
2426
#include "modules/bulk-operations/bulkoperationsmanager.h"
2527

2628

@@ -47,16 +49,22 @@ Application::Application(int &argc, char **argv)
4749
initAppAnalytics();
4850
initRedisClient();
4951
initUpdater();
52+
installTranslator();
5053
}
5154

5255
void Application::initModels()
5356
{
5457
initConnectionsManager();
5558

56-
m_consoleModel = QSharedPointer<Console::ViewModel>(new Console::ViewModel());
59+
m_consoleModel = QSharedPointer<TabViewModel>(new TabViewModel(getTabModelFactory<Console::Model>()));
5760

5861
connect(m_connections.data(), &ConnectionsManager::openConsole,
59-
m_consoleModel.data(), &Console::ViewModel::openConsole);
62+
m_consoleModel.data(), &TabViewModel::openTab);
63+
64+
m_serverStatsModel = QSharedPointer<TabViewModel>(new TabViewModel(getTabModelFactory<ServerStats::Model>()));
65+
66+
connect(m_connections.data(), &ConnectionsManager::openServerStats,
67+
m_serverStatsModel.data(), &TabViewModel::openTab);
6068
}
6169

6270
void Application::initAppInfo()
@@ -70,8 +78,16 @@ void Application::initAppInfo()
7078
void Application::initAppFonts()
7179
{
7280
QSettings settings;
73-
QString appFont = settings.value("app/appFont", "Open Sans").toString();
74-
int appFontSize = settings.value("app/appFontSize", 11).toInt();
81+
#ifdef Q_OS_MAC
82+
QString defaultFontName("Helvetica Neue");
83+
int defaultFontSize = 12;
84+
#else
85+
QString defaultFontName("Open Sans");
86+
int defaultFontSize = 11;
87+
#endif
88+
89+
QString appFont = settings.value("app/appFont", defaultFontName).toString();
90+
int appFontSize = settings.value("app/appFontSize", defaultFontSize).toInt();
7591

7692
if (appFont == "Open Sans") {
7793
int result = QFontDatabase::addApplicationFont("://fonts/OpenSans.ttc");
@@ -109,6 +125,7 @@ void Application::registerQmlRootObjects()
109125
m_engine.rootContext()->setContextProperty("viewModel", m_keyValues.data()); // TODO: Remove legacy name usage in qml
110126
m_engine.rootContext()->setContextProperty("valuesModel", m_keyValues.data());
111127
m_engine.rootContext()->setContextProperty("consoleModel", m_consoleModel.data());
128+
m_engine.rootContext()->setContextProperty("serverStatsModel", m_serverStatsModel.data());
112129
m_engine.rootContext()->setContextProperty("appLogger", m_logger);
113130
m_engine.rootContext()->setContextProperty("bulkOperations", m_bulkOperations.data());
114131
}
@@ -151,10 +168,9 @@ void Application::initConnectionsManager()
151168

152169
if (config.isNull()) {
153170
QMessageBox::critical(nullptr,
154-
"Settings directory is not writable",
155-
QString("Program can't save connections file to settings dir."
156-
"Please change permissions or restart this program "
157-
" with administrative privileges")
171+
QObject::tr("Settings directory is not writable"),
172+
QString(QObject::tr("RDM can't save connections file to settings directory. "
173+
"Please change file permissions or restart RDM as administrator."))
158174
);
159175

160176
throw std::runtime_error("invalid connections config");
@@ -188,8 +204,29 @@ void Application::initUpdater()
188204
connect(m_updater.data(), SIGNAL(updateUrlRetrived(QString &)), this, SLOT(OnNewUpdateAvailable(QString &)));
189205
}
190206

207+
void Application::installTranslator()
208+
{
209+
QString locale = QLocale::system().uiLanguages().first().replace( "-", "_" );
210+
211+
qDebug() << QLocale::system().uiLanguages();
212+
213+
if (locale.isEmpty() || locale == "C")
214+
locale = "en_US";
215+
216+
qDebug() << "Detected locale:" << locale;
217+
218+
QTranslator* translator = new QTranslator((QObject *)this);
219+
if (translator->load( QString( ":/translations/rdm_" ) + locale ))
220+
{
221+
qDebug() << "Load translations file for locale:" << locale;
222+
QCoreApplication::installTranslator( translator );
223+
} else {
224+
delete translator;
225+
}
226+
}
227+
191228
void Application::OnNewUpdateAvailable(QString &url)
192229
{
193230
QMessageBox::information(nullptr, "New update available",
194-
QString("Please download new version of Redis Desktop Manager: %1").arg(url));
231+
QString(QObject::tr("Please download new version of Redis Desktop Manager: %1")).arg(url));
195232
}

src/app/app.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ class QmlUtils;
1414
class ConnectionsManager;
1515
class Updater;
1616
class LogHandler;
17+
class TabViewModel;
1718
namespace ValueEditor { class ViewModel; }
18-
namespace Console { class ViewModel; }
1919
namespace BulkOperations { class Manager; }
2020

2121

@@ -37,6 +37,7 @@ class Application : public QApplication
3737
void initLog();
3838
void initConnectionsManager();
3939
void initUpdater();
40+
void installTranslator();
4041

4142
private slots:
4243
void OnNewUpdateAvailable(QString &url);
@@ -48,6 +49,7 @@ private slots:
4849
QSharedPointer<Updater> m_updater;
4950
QSharedPointer<ValueEditor::ViewModel> m_keyValues;
5051
QSharedPointer<BulkOperations::Manager> m_bulkOperations;
51-
QSharedPointer<Console::ViewModel> m_consoleModel;
52+
QSharedPointer<TabViewModel> m_consoleModel;
53+
QSharedPointer<TabViewModel> m_serverStatsModel;
5254
LogHandler* m_logger;
5355
};

src/app/models/connectionsmanager.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class ConnectionsManager : public ConnectionsTree::Model, public BulkOperations:
4949

5050
void openConsole(QSharedPointer<RedisClient::Connection> connection);
5151

52+
void openServerStats(QSharedPointer<RedisClient::Connection> connection);
5253

5354
// Proxy-signals from TreeOperationsModel
5455
void openValueTab(QSharedPointer<RedisClient::Connection> connection,

src/app/models/key-models/hashkey.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "hashkey.h"
22
#include <qredisclient/connection.h>
3+
#include <QObject>
34

45
HashKeyModel::HashKeyModel(QSharedPointer<RedisClient::Connection> connection,
56
QByteArray fullPath, int dbIndex, long long ttl)
@@ -47,7 +48,7 @@ QVariant HashKeyModel::getData(int rowIndex, int dataRole)
4748
void HashKeyModel::updateRow(int rowIndex, const QVariantMap &row)
4849
{
4950
if (!isRowLoaded(rowIndex) || !isRowValid(row))
50-
throw Exception("Invalid row");
51+
throw Exception(QObject::tr("Invalid row"));
5152

5253
QPair<QByteArray, QByteArray> cachedRow = m_rowsCache[rowIndex];
5354

@@ -70,7 +71,7 @@ void HashKeyModel::updateRow(int rowIndex, const QVariantMap &row)
7071
void HashKeyModel::addRow(const QVariantMap &row)
7172
{
7273
if (!isRowValid(row))
73-
throw Exception("Invalid row");
74+
throw Exception(QObject::tr("Invalid row"));
7475

7576
setHashRow(row["key"].toByteArray(), row["value"].toByteArray(), false);
7677
m_rowCount++;
@@ -101,20 +102,20 @@ void HashKeyModel::setHashRow(const QByteArray &hashKey, const QByteArray &hashV
101102
result = m_connection->commandSync({(updateIfNotExist)? "HSET" : "HSETNX",
102103
m_keyFullPath, hashKey, hashValue}, m_dbIndex);
103104
} catch (const RedisClient::Connection::Exception& e) {
104-
throw Exception("Connection error: " + QString(e.what()));
105+
throw Exception(QObject::tr("Connection error: ") + QString(e.what()));
105106
}
106107

107108
if (updateIfNotExist == false
108109
&& result.getValue().toInt() == 0)
109-
throw Exception("Value with same key already exist");
110+
throw Exception(QObject::tr("Value with the same key already exist"));
110111
}
111112

112113
void HashKeyModel::deleteHashRow(const QByteArray &hashKey)
113114
{
114115
try {
115116
m_connection->commandSync({"HDEL", m_keyFullPath, hashKey}, m_dbIndex);
116117
} catch (const RedisClient::Connection::Exception& e) {
117-
throw Exception("Connection error: " + QString(e.what()));
118+
throw Exception(QObject::tr("Connection error: ") + QString(e.what()));
118119
}
119120
}
120121

@@ -130,7 +131,7 @@ void HashKeyModel::addLoadedRowsToCache(const QVariantList &rows, int rowStart)
130131
++item;
131132

132133
if (item == rows.end())
133-
throw Exception("Partial data loaded from server");
134+
throw Exception(QObject::tr("Data was loaded from server partially."));
134135

135136
value.second = item->toByteArray();
136137
result.push_back(value);

src/app/models/key-models/keyfactory.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "sortedsetkey.h"
88
#include "hashkey.h"
99
#include "listkey.h"
10+
#include <QObject>
1011

1112
KeyFactory::KeyFactory()
1213
{}
@@ -23,16 +24,16 @@ void KeyFactory::loadKey(QSharedPointer<RedisClient::Connection> connection,
2324
QSharedPointer<ValueEditor::Model> result;
2425

2526
if (resp.isErrorMessage() || resp.getType() != RedisClient::Response::Type::Status) {
26-
QString msg("Cannot load key %1, connection error occurred: %2");
27+
QString msg(QObject::tr("Cannot load key %1, connection error occurred: %2"));
2728
callback(result, msg.arg(printableString(keyFullPath)).arg(resp.toRawString()));
2829
return;
2930
}
3031

3132
QString type = resp.getValue().toString();
3233

3334
if (type == "none") {
34-
QString msg("Cannot load key %1 because it doesn't exist in database."
35-
" Please reload connection tree and try again.");
35+
QString msg(QObject::tr("Cannot load key %1 because it doesn't exist in database."
36+
" Please reload connection tree and try again."));
3637
callback(result, msg.arg(printableString(keyFullPath)));
3738
return;
3839
}
@@ -42,7 +43,7 @@ void KeyFactory::loadKey(QSharedPointer<RedisClient::Connection> connection,
4243
try {
4344
ttlResult = connection->commandSync({"ttl", keyFullPath}, dbIndex);
4445
} catch (const RedisClient::Connection::Exception& e) {
45-
QString msg("Cannot load TTL for key %1, connection error occurred: %2");
46+
QString msg(QObject::tr("Cannot load TTL for key %1, connection error occurred: %2"));
4647
callback(result, msg.arg(printableString(keyFullPath)).arg(QString(e.what())));
4748
return;
4849
}
@@ -62,7 +63,7 @@ void KeyFactory::loadKey(QSharedPointer<RedisClient::Connection> connection,
6263
try {
6364
connection->runCommand(typeCmd);
6465
} catch (const RedisClient::Connection::Exception& e) {
65-
throw Exception("Cannot retrive type of the key: " + QString(e.what()));
66+
throw Exception(QObject::tr("Cannot retrive type of the key: ") + QString(e.what()));
6667
}
6768
}
6869

src/app/models/key-models/listkey.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,10 @@ QString ListKeyModel::getType()
1616
void ListKeyModel::updateRow(int rowIndex, const QVariantMap &row)
1717
{
1818
if (!isRowLoaded(rowIndex) || !isRowValid(row))
19-
throw Exception("Invalid row");
19+
throw Exception(QObject::tr("Invalid row"));
2020

2121
if (isActualPositionChanged(rowIndex))
22-
throw Exception("Can't delete row from list, because row already has changed."
23-
" Reload values and try again.");
22+
throw Exception(QObject::tr("The row has been changed and can't be updated now. Reload and try again."));
2423

2524
QByteArray newRow(row["value"].toByteArray());
2625
setListRow(rowIndex, newRow);
@@ -30,7 +29,7 @@ void ListKeyModel::updateRow(int rowIndex, const QVariantMap &row)
3029
void ListKeyModel::addRow(const QVariantMap &row)
3130
{
3231
if (!isRowValid(row))
33-
throw Exception("Invalid row");
32+
throw Exception(QObject::tr("Invalid row"));
3433

3534
addListRow(row["value"].toByteArray());
3635
m_rowCount++;
@@ -42,8 +41,7 @@ void ListKeyModel::removeRow(int i)
4241
return;
4342

4443
if (isActualPositionChanged(i))
45-
throw Exception("Can't delete row from list, because row already has changed."
46-
" Reload values and try again.");
44+
throw Exception(QObject::tr("The row has been changed and can't be deleted now. Reload and try again."));
4745

4846
// Replace value by system string
4947
QString customSystemValue("---VALUE_REMOVED_BY_RDM---");
@@ -74,7 +72,7 @@ bool ListKeyModel::isActualPositionChanged(int row)
7472
result = m_connection->commandSync({"LRANGE", m_keyFullPath, QString::number(row).toLatin1(),
7573
QString::number(row).toLatin1()}, m_dbIndex);
7674
} catch (const RedisClient::Connection::Exception& e) {
77-
throw Exception("Connection error: " + QString(e.what()));
75+
throw Exception(QObject::tr("Connection error: ") + QString(e.what()));
7876
}
7977

8078
QVariantList currentState = result.getValue().toList();
@@ -87,7 +85,7 @@ void ListKeyModel::addListRow(const QByteArray &value)
8785
try {
8886
m_connection->commandSync({"LPUSH", m_keyFullPath, value}, m_dbIndex);
8987
} catch (const RedisClient::Connection::Exception& e) {
90-
throw Exception("Connection error: " + QString(e.what()));
88+
throw Exception(QObject::tr("Connection error: ") + QString(e.what()));
9189
}
9290
}
9391

@@ -97,7 +95,7 @@ void ListKeyModel::setListRow(int pos, const QByteArray &value)
9795
m_connection->commandSync({"LSET", m_keyFullPath,
9896
QString::number(pos).toLatin1(), value}, m_dbIndex);
9997
} catch (const RedisClient::Connection::Exception& e) {
100-
throw Exception("Connection error: " + QString(e.what()));
98+
throw Exception(QObject::tr("Connection error: ") + QString(e.what()));
10199
}
102100
}
103101

@@ -107,6 +105,6 @@ void ListKeyModel::deleteListRow(int count, const QByteArray &value)
107105
m_connection->commandSync({"LREM", m_keyFullPath, QString::number(count).toLatin1(),
108106
value}, m_dbIndex);
109107
} catch (const RedisClient::Connection::Exception& e) {
110-
throw Exception("Connection error: " + QString(e.what()));
108+
throw Exception(QObject::tr("Connection error: ") + QString(e.what()));
111109
}
112110
}

src/app/models/key-models/setkey.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ QString SetKeyModel::getType()
1616
void SetKeyModel::updateRow(int rowIndex, const QVariantMap &row)
1717
{
1818
if (!isRowLoaded(rowIndex) || !isRowValid(row))
19-
throw Exception("Invalid row");
19+
throw Exception(QObject::tr("Invalid row"));
2020

2121
QByteArray cachedRow = m_rowsCache[rowIndex];
2222
QByteArray newRow(row["value"].toByteArray());
@@ -29,7 +29,7 @@ void SetKeyModel::updateRow(int rowIndex, const QVariantMap &row)
2929
void SetKeyModel::addRow(const QVariantMap &row)
3030
{
3131
if (!isRowValid(row))
32-
throw Exception("Invalid row");
32+
throw Exception(QObject::tr("Invalid row"));
3333

3434
addSetRow(row["value"].toByteArray());
3535
m_rowCount++;
@@ -54,7 +54,7 @@ void SetKeyModel::addSetRow(const QByteArray &value)
5454
try {
5555
m_connection->commandSync({"SADD", m_keyFullPath, value}, m_dbIndex);
5656
} catch (const RedisClient::Connection::Exception& e) {
57-
throw Exception("Connection error: " + QString(e.what()));
57+
throw Exception(QObject::tr("Connection error: ") + QString(e.what()));
5858
}
5959
}
6060

@@ -63,6 +63,6 @@ RedisClient::Response SetKeyModel::deleteSetRow(const QByteArray &value)
6363
try {
6464
return m_connection->commandSync({"SREM", m_keyFullPath, value}, m_dbIndex);
6565
} catch (const RedisClient::Connection::Exception& e) {
66-
throw Exception("Connection error: " + QString(e.what()));
66+
throw Exception(QObject::tr("Connection error: ") + QString(e.what()));
6767
}
6868
}

0 commit comments

Comments
 (0)