Skip to content

Commit

Permalink
Check for empty process output && include view menu (fixes #150).
Browse files Browse the repository at this point in the history
  • Loading branch information
vaibhavpandeyvpz committed Apr 14, 2020
1 parent 8baa7d5 commit 7cb4ae6
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 22 deletions.
3 changes: 0 additions & 3 deletions sources/appearancesettingswidget.cpp
Expand Up @@ -21,9 +21,6 @@ QLayout *AppearanceSettingsWidget::buildForm()
QRadioButton *light = new QRadioButton(tr("Light"), this);
themes->addWidget(light);
themes->addWidget(m_RadioThemeDark = new QRadioButton(tr("Dark"), this));
auto spacer = new QWidget(this);
spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
themes->addWidget(spacer);
layout->addRow(tr("Theme"), themes);
layout->addRow(tr("Editor Font"), m_ComboEditorFont = new QFontComboBox(this));
layout->addRow(tr("Editor Font Size"), m_SpinEditorFontSize = new QSpinBox(this));
Expand Down
28 changes: 22 additions & 6 deletions sources/mainwindow.cpp
Expand Up @@ -46,15 +46,15 @@
#define URL_ISSUES "https://github.com/vaibhavpandeyvpz/apkstudio/issues"
#define URL_THANKS "https://forum.xda-developers.com/showthread.php?t=2493107"

#define WINDOW_WIDTH 640
#define WINDOW_HEIGHT 480
#define WINDOW_WIDTH 800
#define WINDOW_HEIGHT 600

MainWindow::MainWindow(const QMap<QString, QString> &versions, QWidget *parent)
: QMainWindow(parent), m_FindReplaceDialog(nullptr)
{
addDockWidget(Qt::LeftDockWidgetArea, buildProjectsDock());
addDockWidget(Qt::LeftDockWidgetArea, buildFilesDock());
addDockWidget(Qt::BottomDockWidgetArea, buildConsoleDock());
addDockWidget(Qt::LeftDockWidgetArea, m_DockProject = buildProjectsDock());
addDockWidget(Qt::LeftDockWidgetArea, m_DockFiles = buildFilesDock());
addDockWidget(Qt::BottomDockWidgetArea, m_DockConsole = buildConsoleDock());
addToolBar(Qt::LeftToolBarArea, buildMainToolBar());
setCentralWidget(buildCentralWidget());
setMenuBar(buildMenuBar());
Expand All @@ -78,6 +78,9 @@ MainWindow::MainWindow(const QMap<QString, QString> &versions, QWidget *parent)
if (state.isValid()) {
restoreState(state.toByteArray());
}
m_ActionViewProject->setChecked(m_DockProject->isVisible());
m_ActionViewFiles->setChecked(m_DockFiles->isVisible());
m_ActionViewConsole->setChecked(m_DockConsole->isVisible());
QTimer::singleShot(100, [=] {
QSettings settings;
const QStringList files = settings.value("open_files").toStringList();
Expand Down Expand Up @@ -241,6 +244,19 @@ QMenuBar *MainWindow::buildMenuBar()
m_ActionGoto->setEnabled(false);
edit->addSeparator();
edit->addAction(tr("Settings"), this, &MainWindow::handleActionSettings, QKeySequence::Preferences);
auto view = menubar->addMenu(tr("View"));
m_ActionViewProject = view->addAction(tr("Project"));
m_ActionViewProject->setCheckable(true);
connect(m_ActionViewProject, &QAction::toggled, m_DockProject, &QDockWidget::setVisible);
connect(m_DockProject, &QDockWidget::visibilityChanged, m_ActionViewProject, &QAction::setChecked);
m_ActionViewFiles = view->addAction(tr("Files"));
m_ActionViewFiles->setCheckable(true);
connect(m_ActionViewFiles, &QAction::toggled, m_DockFiles, &QDockWidget::setVisible);
connect(m_DockFiles, &QDockWidget::visibilityChanged, m_ActionViewFiles, &QAction::setChecked);
m_ActionViewConsole = view->addAction(tr("Console"));
m_ActionViewConsole->setCheckable(true);
connect(m_ActionViewConsole, &QAction::toggled, m_DockConsole, &QDockWidget::setVisible);
connect(m_DockConsole, &QDockWidget::visibilityChanged, m_ActionViewConsole, &QAction::setChecked);
auto project = menubar->addMenu(tr("Project"));
m_ActionBuild1 = project->addAction(tr("Build"), this, &MainWindow::handleActionBuild);
m_ActionBuild1->setEnabled(false);
Expand Down Expand Up @@ -781,7 +797,7 @@ void MainWindow::handleRecompileFinished(const QString &folder)
if (focus) {
auto parent = focus->parent();
while (parent) {
if (!m_ProjectsTree->isItemExpanded(parent)) {
if (!parent->isExpanded()) {
m_ProjectsTree->expandItem(parent);
}
parent = parent->parent();
Expand Down
7 changes: 7 additions & 0 deletions sources/mainwindow.h
@@ -1,6 +1,7 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QDockWidget>
#include <QFileIconProvider>
#include <QLabel>
#include <QListView>
Expand Down Expand Up @@ -45,7 +46,13 @@ class MainWindow : public QMainWindow
QAction *m_ActionSaveAll;
QAction *m_ActionSign;
QAction *m_ActionUndo;
QAction *m_ActionViewProject;
QAction *m_ActionViewFiles;
QAction *m_ActionViewConsole;
QStackedWidget *m_CentralStack;
QDockWidget *m_DockProject;
QDockWidget *m_DockFiles;
QDockWidget *m_DockConsole;
QTextEdit *m_EditConsole;
QList<QMetaObject::Connection> m_EditorConnections;
QFileIconProvider m_FileIconProvider;
Expand Down
2 changes: 1 addition & 1 deletion sources/signingconfigwidget.cpp
Expand Up @@ -32,7 +32,7 @@ QLayout *SigningConfigWidget::buildLayout()
child->addWidget(button = new QPushButton(tr("Browse"), this));
connect(button, &QPushButton::pressed, this, &SigningConfigWidget::handleBrowseKeystore);
auto empty = new QWidget(this);
empty->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
empty->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
child->addWidget(empty);
layout->addRow("", child);
layout->addRow(tr("Keystore Password"), m_EditKeystorePassword = new QLineEdit(this));
Expand Down
24 changes: 12 additions & 12 deletions sources/versionresolveworker.cpp
Expand Up @@ -53,11 +53,11 @@ void VersionResolveWorker::resolve()
#ifdef QT_DEBUG
qDebug() << "Apktool returned code" << result.code;
#endif
if (result.code == 0) {
if ((result.code == 0) && !result.output.isEmpty()) {
#ifdef QT_DEBUG
qDebug() << "Apktool returned" << result.output[0];
qDebug() << "Apktool returned" << result.output.first();
#endif
emit versionResolved("apktool", result.output[0].trimmed());
emit versionResolved("apktool", result.output.first().trimmed());
found = true;
}
}
Expand All @@ -74,11 +74,11 @@ void VersionResolveWorker::resolve()
#ifdef QT_DEBUG
qDebug() << "Jadx returned code" << result.code;
#endif
if (result.code == 0) {
if ((result.code == 0) && !result.output.isEmpty()) {
#ifdef QT_DEBUG
qDebug() << "Jadx returned" << result.output[0];
qDebug() << "Jadx returned" << result.output.first();
#endif
emit versionResolved("jadx", result.output[0].trimmed());
emit versionResolved("jadx", result.output.first().trimmed());
found = true;
}
}
Expand All @@ -95,12 +95,12 @@ void VersionResolveWorker::resolve()
#ifdef QT_DEBUG
qDebug() << "ADB returned code" << result.code;
#endif
if (result.code == 0) {
if ((result.code == 0) && !result.output.isEmpty()) {
#ifdef QT_DEBUG
qDebug() << "ADB returned" << result.output[0];
qDebug() << "ADB returned" << result.output.first();
#endif
QRegularExpression regexp(REGEXP_ADB_VERSION);
QRegularExpressionMatch match = regexp.match(result.output[0]);
QRegularExpressionMatch match = regexp.match(result.output.first());
if (match.hasMatch()) {
emit versionResolved("adb", match.captured(1));
found = true;
Expand All @@ -123,12 +123,12 @@ void VersionResolveWorker::resolve()
#ifdef QT_DEBUG
qDebug() << "Uber APK signer returned code" << result.code;
#endif
if (result.code == 0) {
if ((result.code == 0) && !result.output.isEmpty()) {
#ifdef QT_DEBUG
qDebug() << "Uber APK signer returned" << result.output[0];
qDebug() << "Uber APK signer returned" << result.output.first();
#endif
QRegularExpression regexp(REGEXP_UAS_VERSION);
QRegularExpressionMatch match = regexp.match(result.output[0]);
QRegularExpressionMatch match = regexp.match(result.output.first());
if (match.hasMatch()) {
emit versionResolved("uas", match.captured(1));
found = true;
Expand Down

0 comments on commit 7cb4ae6

Please sign in to comment.