Skip to content

Commit fc61a6d

Browse files
committed
linux build
1 parent d70435f commit fc61a6d

12 files changed

+109
-51
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ qtactiveqt-everywhere-src-6.7.1/
2424
mugi-query-0.0.1-win64_/
2525
qrc_icons.cpp
2626
CMakeLists.txt.user
27+
build/

CMakeLists.txt

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,18 @@ project(mugi-query VERSION 1.0 LANGUAGES CXX)
66
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
77
set(CMAKE_INCLUDE_CURRENT_DIR ON)
88

9+
if (WIN32)
910
find_package(Qt6 REQUIRED COMPONENTS Core Gui Sql Svg Widgets AxContainer Test)
10-
find_package(qwt REQUIRED)
11+
else()
12+
find_package(Qt6 REQUIRED COMPONENTS Core Gui Sql Svg Widgets Test)
13+
endif()
14+
15+
find_package(Qwt REQUIRED)
16+
17+
#qt_standard_project_setup()
18+
set(CMAKE_AUTOMOC TRUE)
19+
set(CMAKE_AUTOUIC TRUE)
1120

12-
qt_standard_project_setup()
1321

1422
# emmet
1523
add_library(emmet SHARED
@@ -268,13 +276,31 @@ qt6_add_resources(mugi-query "icons"
268276
${icons_resource_files}
269277
)
270278

271-
target_link_libraries(mugi-query PUBLIC
272-
Qt::AxContainer
273-
Qt::Core
274-
Qt::Gui
275-
Qt::Sql
276-
Qt::Svg
277-
qwt
278-
emmet
279-
sqlparse
280-
)
279+
if (WIN32)
280+
target_link_libraries(mugi-query PUBLIC
281+
Qt::AxContainer
282+
Qt::Core
283+
Qt::Gui
284+
Qt::Widgets
285+
Qt::Sql
286+
Qt::Svg
287+
Qwt
288+
emmet
289+
sqlparse
290+
)
291+
else()
292+
target_link_libraries(mugi-query PUBLIC
293+
Qt::Core
294+
Qt::Gui
295+
Qt::Widgets
296+
Qt::Sql
297+
Qt::Svg
298+
Qwt
299+
emmet
300+
sqlparse
301+
)
302+
endif()
303+
304+
# LD_LIBRARY_PATH="/usr/local/qwt-6.3.0-dev/lib:/usr/local/lib" /usr/local/bin/mugi-query
305+
install(TARGETS mugi-query emmet sqlparse)
306+
install(FILES emmet.json DESTINATION share)

README.md

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,24 +47,28 @@ Data import
4747

4848
### Linux (Ubuntu)
4949

50-
In terminal run
51-
5250
```bash
53-
# installs qt5 and build tools
54-
sudo apt install git build-essential qtbase5-dev qtchooser
51+
# install qt6 and build tools
52+
sudo apt install git build-essential cmake ninja-build qt6-base-dev libqt6svg6-dev libxkbcommon-dev
5553

56-
# installs qwt and dependencies
57-
sudo apt install libqwt-qt5-dev libqt5svg5-dev
54+
# build qwt
55+
git clone https://git.code.sf.net/p/qwt/git qwt-git
56+
cd qwt-git
57+
qmake6
58+
make
59+
sudo install
60+
cd ..
5861

59-
# installs sql plugins
60-
sudo apt install libqt5sql5-mysql libqt5sql5-odbc libqt5sql5-psql libqt5sql5-sqlite libqt5sql5-tds libqt5sql5-ibase
62+
# install sql plugins
63+
sudo apt install libqt6sql6-ibase libqt6sql6-mysql libqt6sql6-odbc libqt6sql6-psql libqt6sql6-sqlite
6164

6265
git clone https://github.com/mugiseyebrows/mugi-query.git
6366
cd mugi-query
64-
qmake -qt=5 'CONFIG+=release'
65-
make
66-
make clean
67-
strip mugi-query
68-
sudo make install # installs to /usr/local/bin
69-
python desktop.py # copies icons, creates desktop file
67+
mkdir build
68+
cd build
69+
cmake -G Ninja ..
70+
cmake --build .
71+
sudo cmake --install .
72+
cd ..
73+
python3 desktop.py
7074
```

cmake/FindQwt.cmake

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
find_library(QWT_LIBRARY NAMES qwt)
2+
find_library(QWT_LIBRARY NAMES Qwt)
33

44
find_path(QWT_INCLUDE_DIR NAMES qwt.h)
55

@@ -9,14 +9,14 @@ find_path(QWT_INCLUDE_DIR NAMES qwt.h)
99
include(FindPackageHandleStandardArgs)
1010

1111
find_package_handle_standard_args(
12-
qwt
12+
Qwt
1313
FOUND_VAR QWT_FOUND
1414
REQUIRED_VARS QWT_LIBRARY QWT_INCLUDE_DIR
1515
)
1616

1717
if (QWT_FOUND)
18-
add_library(qwt UNKNOWN IMPORTED)
19-
set_target_properties(qwt PROPERTIES
18+
add_library(Qwt UNKNOWN IMPORTED)
19+
set_target_properties(Qwt PROPERTIES
2020
IMPORTED_LOCATION ${QWT_LIBRARY}
2121
INTERFACE_INCLUDE_DIRECTORIES ${QWT_INCLUDE_DIR}
2222
)

desktop.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@
1414
os.makedirs(os.path.dirname(dst), exist_ok=True)
1515
shutil.copy(src,dst)
1616

17+
# /usr/bin/bash -c "LD_LIBRARY_PATH=/usr/local/lib:/usr/local/qwt-6.3.0-dev/lib /usr/local/bin/mugi-query"
18+
1719
icon = dst = os.path.join(icons,'256x256','apps','%s.png' % name)
18-
executable = '/usr/local/bin/%s' % name
20+
executable = '/usr/bin/bash -c "LD_LIBRARY_PATH=/usr/local/lib:/usr/local/qwt-6.3.0-dev/lib /usr/local/bin/mugi-query"'
1921
categories = ['Utility']
2022
with open(desktop,'w') as f:
2123
f.write('[Desktop Entry]\nName=%s\nExec=%s\nIcon=%s\nType=Application\nCategories=%s' % (name,executable,icon,';'.join(categories) + ';'))

src/copyeventfilter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ void CopyEventFilter::copyTsv(QTableView *view)
2626
{
2727
CopyEventFilter* filter = new CopyEventFilter(view);
2828
filter->setView(view);
29-
connect(filter,CopyEventFilter::copy,[=](){
29+
connect(filter,&CopyEventFilter::copy,[=](){
3030
ClipboardUtil::copyTsv(view);
3131
});
3232
}

src/emmet.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,33 +18,37 @@ static QStringList toStringList(const QJsonArray& arr) {
1818
return res;
1919
}
2020

21-
static QJsonDocument readJson(const QString& path) {
21+
static QJsonDocument readJson(const QString& path, QString& error) {
2222
QFile file(path);
2323
if (!file.open(QIODevice::ReadOnly)) {
24-
qDebug() << "cannot open" << path;
24+
error = QString("cannot open %1").arg(path);
2525
return QJsonDocument();
2626
}
2727
QByteArray data = file.readAll();
2828
QJsonParseError err;
2929
QJsonDocument doc = QJsonDocument::fromJson(data, &err);
3030
if (err.error != QJsonParseError::NoError) {
31-
qDebug() << err.errorString();
31+
error = err.errorString();
3232
}
3333
return doc;
3434
}
3535

36-
static QHash<QString, QString> loadEmmetDict() {
36+
static QHash<QString, QString> loadEmmetDict(QString& error) {
3737
QHash<QString, QString> dict;
3838
QDir dir(qApp->applicationDirPath());
39-
if (dir.dirName() == "debug") {
39+
if (dir.dirName() == "debug" || dir.dirName() == "release" || dir.dirName() == "build") {
4040
dir.cdUp();
4141
}
42+
if (dir.dirName() == "bin") {
43+
dir.cdUp();
44+
dir.cd("share");
45+
}
4246
/*if (dir.dirName() == "mugi-query") {
4347
dir.cd("lib");
4448
dir.cd("emmet");
4549
}*/
4650
QString path = dir.filePath("emmet.json");
47-
QJsonDocument doc = readJson(path);
51+
QJsonDocument doc = readJson(path, error);
4852
QJsonArray arr = doc.array();
4953
QStringList keys;
5054
for(QJsonArray::iterator it=arr.begin(); it!= arr.end(); it++) {
@@ -160,9 +164,9 @@ QString parseCw(const QString& text) {
160164
return QString();
161165
}
162166

163-
QString Emmet::parse(const QString& text) {
167+
QString Emmet::parse(const QString& text, QString& error) {
164168

165-
static QHash<QString, QString> dict = loadEmmetDict();
169+
static QHash<QString, QString> dict = loadEmmetDict(error);
166170

167171
QStringList res;
168172
QString tail = text;

src/emmet.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
class EMMET_EXPORT Emmet
99
{
1010
public:
11-
static QString parse(const QString &text);
11+
static QString parse(const QString &text, QString& error);
1212
};
1313

1414
#endif // EMMET_H

src/schema2/schema2data.cpp

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@
2121
#include <QSortFilterProxyModel>
2222
#include "checkablestringlistmodel.h"
2323

24-
#include <QAxObject>
24+
#ifdef Q_OS_WIN
25+
#include <QAxObject>
26+
#endif
27+
2528
#include <QStandardItemModel>
2629
#include "history.h"
2730
#include <QSqlError>
@@ -230,6 +233,7 @@ void Schema2Data::pullTablesOdbc() {
230233
if (filePath.isEmpty()) {
231234
return;
232235
}
236+
#ifdef Q_OS_WIN
233237

234238
QAxObject engine("DAO.DBEngine.120");
235239
QAxObject* database = engine.querySubObject("OpenDatabase(QString, bool)", filePath, false);
@@ -275,10 +279,9 @@ void Schema2Data::pullTablesOdbc() {
275279
mTables->updateColumns(tableName);
276280

277281
}
278-
279-
280-
281-
282+
#else
283+
// todo
284+
#endif
282285
}
283286

284287

@@ -454,6 +457,8 @@ void Schema2Data::pullIndexesOdbc() {
454457
return;
455458
}
456459

460+
#ifdef Q_OS_WIN
461+
457462
QAxObject engine("DAO.DBEngine.120");
458463

459464
QAxObject* database = engine.querySubObject("OpenDatabase(QString)", filePath);
@@ -513,6 +518,9 @@ void Schema2Data::pullIndexesOdbc() {
513518

514519
}
515520
}
521+
#else
522+
523+
#endif
516524

517525

518526
}
@@ -538,6 +546,8 @@ void Schema2Data::pullRelationsOdbc() {
538546
return;
539547
}
540548

549+
#ifdef Q_OS_WIN
550+
541551
QAxObject engine("DAO.DBEngine.120");
542552
QAxObject* database = engine.querySubObject("OpenDatabase(QString, bool)", filePath, false);
543553
QAxObject* relations = database->querySubObject("Relations");
@@ -568,7 +578,9 @@ void Schema2Data::pullRelationsOdbc() {
568578

569579

570580
}
571-
581+
#else
582+
// todo
583+
#endif
572584

573585
}
574586

src/tst_emmet.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ void tst_Emmet::testCw()
2828
{
2929
QFETCH(QString, in);
3030
QFETCH(QString, expected);
31-
QString parsed = Emmet::parse(in);
31+
QString error;
32+
QString parsed = Emmet::parse(in, error);
33+
if (!error.isEmpty()) {
34+
qDebug() << error;
35+
}
3236
//qDebug() << parsed;
3337
QCOMPARE(wssplit(parsed), wssplit(expected));
3438
}

src/widget/radiobuttons.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ void RadioButtons::init(const QStringList &items, int checkedIndex)
2525
button->setChecked(true);
2626
}
2727
mButtons.append(button);
28-
connect(button, qOverload<bool>(QRadioButton::clicked),[=](bool on){
28+
connect(button, qOverload<bool>(&QRadioButton::clicked),[=](bool on){
2929
if (on) {
3030
emit clicked(i);
3131
}

src/widget/textedit.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ static QTextCursor selectEmmetExpression(const QTextCursor& cursor) {
392392
return begin;
393393
}
394394

395-
395+
#include <QMessageBox>
396396

397397
bool TextEdit::tryEmmet() {
398398
if (!cursorAtEndOfWord()) {
@@ -404,7 +404,12 @@ bool TextEdit::tryEmmet() {
404404
qDebug() << "cursor.selectedText() is empty";
405405
return false;
406406
}
407-
QString e = Emmet::parse(text);
407+
QString error;
408+
QString e = Emmet::parse(text, error);
409+
if (!error.isEmpty()) {
410+
QMessageBox::critical(this, "Error", error);
411+
return false;
412+
}
408413
if (e.isEmpty()) {
409414
qDebug() << "cannot emmet text" << text;
410415
return false;

0 commit comments

Comments
 (0)