Skip to content

Commit

Permalink
support for older Qt5 library and GNU/Linux versions
Browse files Browse the repository at this point in the history
  • Loading branch information
mmozeiko committed Feb 1, 2017
1 parent b64837f commit 34ac37f
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 37 deletions.
13 changes: 6 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@ matrix:
- os: linux
language: cpp
dist: trusty
sudo: required
install:
- sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
- sudo add-apt-repository ppa:beineri/opt-qt58-trusty -y
- sudo apt-get update -q
- sudo apt-get install g++-6 qt58base -y
sudo: false
addons:
apt:
packages:
- qttools5-dev
script:
- mkdir build && cd build
- cmake -DCMAKE_C_COMPILER=gcc-6 -DCMAKE_CXX_COMPILER=g++-6 -DCMAKE_PREFIX_PATH=/opt/qt58/lib/cmake ..
- cmake ..
- cmake --build .

- os: osx
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
project(rclone-browser)

cmake_minimum_required(VERSION 3.2)
cmake_minimum_required(VERSION 2.8)

if(WIN32)
# link automatically to qtmain.lib on Windows
Expand Down
7 changes: 4 additions & 3 deletions src/item_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ namespace
{
static void advanceSpinner(QString& text)
{
QChar current = text[text.length() - 2];
int spinnerPos = (int)((size_t)text.length() - 2);
QChar current = text[spinnerPos];
static const QChar spinner[] = { '-', '\\', '|', '/' };
size_t spinnerCount = sizeof(spinner) / sizeof(*spinner);
const QChar* found = qFind(spinner, spinner + spinnerCount, current);
size_t idx = found - spinner;
size_t next = idx == spinnerCount - 1 ? 0 : idx + 1;
text[text.length() - 2] = spinner[next];
text[spinnerPos] = spinner[next];
}

QString getNiceSize(quint64 size)
Expand Down Expand Up @@ -549,7 +550,7 @@ void ItemModel::load(const QPersistentModelIndex& parentIndex, Item* parent)
{
modified = true;
emit beginInsertRows(parentIndex, parent->childs.count(), parent->childs.count() + todo.count() - 1);
parent->childs.append(todo);
parent->childs += todo;
emit endInsertRows();
}

Expand Down
45 changes: 21 additions & 24 deletions src/main_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,29 +112,6 @@ MainWindow::MainWindow()
ui.tabs->tabBar()->setTabButton(1, QTabBar::LeftSide, nullptr);
ui.tabs->setCurrentIndex(0);

QTimer::singleShot(0, ui.remotes, static_cast<void(QWidget::*)()>(&QWidget::setFocus));
QTimer::singleShot(0, this, [=]() { ui.remotes->currentItemChanged(nullptr, nullptr); });
QTimer::singleShot(0, this, [=]()
{
QString rclone = GetRclone();
if (rclone.isEmpty())
{
rclone = QStandardPaths::findExecutable("rclone");
QSettings settings;
settings.setValue("Settings/rclone", rclone);
SetRclone(rclone);
}
if (rclone.isEmpty())
{
QMessageBox::information(this, "Error", "Cannot check rclone verison!\nPlease verify rclone location.");
emit ui.preferences->trigger();
}
else
{
rcloneGetVersion();
}
});

QObject::connect(&mSystemTray, &QSystemTrayIcon::activated, this, [=](QSystemTrayIcon::ActivationReason reason)
{
if (reason == QSystemTrayIcon::DoubleClick || reason == QSystemTrayIcon::Trigger)
Expand Down Expand Up @@ -178,6 +155,26 @@ MainWindow::MainWindow()
mStatusMessage = new QLabel();
ui.statusBar->addWidget(mStatusMessage);
ui.statusBar->setStyleSheet("QStatusBar::item { border: 0; }");

QTimer::singleShot(0, ui.remotes, SLOT(setFocus()));

QString rclone = GetRclone();
if (rclone.isEmpty())
{
rclone = QStandardPaths::findExecutable("rclone");
QSettings settings;
settings.setValue("Settings/rclone", rclone);
SetRclone(rclone);
}
if (rclone.isEmpty())
{
QMessageBox::information(this, "Error", "Cannot check rclone verison!\nPlease verify rclone location.");
emit ui.preferences->trigger();
}
else
{
rcloneGetVersion();
}
}

MainWindow::~MainWindow()
Expand All @@ -199,7 +196,7 @@ void MainWindow::rcloneGetVersion()
{
QString version = p->readAllStandardOutput().trimmed();
mStatusMessage->setText(version + " in " + QDir::toNativeSeparators(GetRclone()));
QTimer::singleShot(0, this, &MainWindow::rcloneListRemotes);
rcloneListRemotes();
}
else
{
Expand Down
6 changes: 4 additions & 2 deletions src/remote_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ RemoteWidget::RemoteWidget(IconCache* iconCache, const QString& remote, bool isL

ItemModel* model = new ItemModel(iconCache, remote, this);
ui.tree->setModel(model);
QTimer::singleShot(0, ui.tree, static_cast<void(QWidget::*)()>(&QWidget::setFocus));
QTimer::singleShot(0, ui.tree, SLOT(setFocus()));

QObject::connect(model, &QAbstractItemModel::layoutChanged, this, [=]()
{
Expand Down Expand Up @@ -305,6 +305,7 @@ RemoteWidget::RemoteWidget(IconCache* iconCache, const QString& remote, bool isL
drives.insert(path, index);
}

#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
QThread* thread = new QThread(this);
thread->start();

Expand Down Expand Up @@ -334,7 +335,8 @@ RemoteWidget::RemoteWidget(IconCache* iconCache, const QString& remote, bool isL
thread->deleteLater();
worker->deleteLater();
});

#endif

ui.tree->selectionModel()->selectionChanged(QItemSelection(), QItemSelection());
}
else
Expand Down

0 comments on commit 34ac37f

Please sign in to comment.