Skip to content

Commit

Permalink
Merge branch '0.12.7-rc' into 'master'
Browse files Browse the repository at this point in the history
0.12.7

See merge request devel/studio!350
  • Loading branch information
MrMontag committed Sep 20, 2019
2 parents 5ef26ed + b27e712 commit fdf7e9e
Show file tree
Hide file tree
Showing 16 changed files with 168 additions and 61 deletions.
13 changes: 7 additions & 6 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
Version 0.12.6
Version 0.12.7
========================

## General
- fixed bookmarks sometimes not being able to be set
- improved add new/existing file dialog: now opens dialog in group folder if available
- fixed crash when GLB file does not contain any models, added proper warning/error instead
- added dialog to create license file (pops up when a license is in the user's clipboard and the "About GAMS" is opened)
- disabled top dockwidget area for all widgets as it should be used solely by the extended parameter editor
- fixed behavior of jumping to matching parenthesis ([Shift+]F8)
- fixed missing parenthesis highlighting for variables
- reduced flickering when minimizing/maximizing Studio
- removed online version check on Studio startup

4 changes: 2 additions & 2 deletions gams-studio.pro
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
TEMPLATE = subdirs

SUBDIRS += src \
tests \
uitests
# uitests \
tests

src.file = src/studio.pro
tests.depends = src
Expand Down
5 changes: 4 additions & 1 deletion jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,10 @@ pipeline {
STUDIO_PATCH_LEVEL=$(grep ^STUDIO_PATCH_LEVEL version | cut -f2 -d"=")
export VERSION=$STUDIO_MAJOR_VERSION.$STUDIO_MINOR_VERSION.$STUDIO_PATCH_LEVEL

linuxdeployqt-6-x86_64.AppImage appdir/usr/share/studio.desktop -bundle-non-qt-libs -no-translations -extra-plugins=iconengines -exclude-libs=libnss3,libnssutil3
linuxdeployqt-6-x86_64.AppImage appdir/usr/share/studio.desktop -bundle-non-qt-libs -no-translations -extra-plugins=iconengines

# Chromium crash workaround
cp /usr/lib/x86_64-linux-gnu/nss/* ./appdir/usr/lib

# Workaround to increase compatibility with older systems;
# see https://github.com/darealshinji/AppImageKit-checkrt amd
Expand Down
13 changes: 6 additions & 7 deletions src/editors/codeedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,10 +301,13 @@ void CodeEdit::keyPressEvent(QKeyEvent* e)
} else {
if (e == Hotkey::MatchParentheses || e == Hotkey::SelectParentheses) {
ParenthesesMatch pm = matchParentheses();
QTextCursor::MoveMode mm = (e == Hotkey::SelectParentheses) ? QTextCursor::KeepAnchor : QTextCursor::MoveAnchor;
if (pm.inOutMatch >= 0) {
bool sel = (e == Hotkey::SelectParentheses);
QTextCursor::MoveMode mm = sel ? QTextCursor::KeepAnchor : QTextCursor::MoveAnchor;
if (pm.match >= 0) {
QTextCursor cur = textCursor();
cur.setPosition(pm.inOutMatch, mm);
if (sel) cur.clearSelection();
if (cur.position() != pm.pos) cur.movePosition(QTextCursor::Left);
cur.setPosition(pm.match+1, mm);
setTextCursor(cur);
}
} else if (e == Hotkey::MoveCharGroupRight || e == Hotkey::SelectCharGroupRight) {
Expand Down Expand Up @@ -1101,15 +1104,13 @@ ParenthesesMatch CodeEdit::matchParentheses()
for (int i = parList.count()-1; i >= 0; --i) {
if (parList.at(i).relPos == pos || parList.at(i).relPos == pos-1) {
start = i;
break;
}
}
if (start < 0) return ParenthesesMatch();
// prepare matching search
int ci = parentheses.indexOf(parList.at(start).character);
bool back = ci >= pSplit;
ci = ci % pSplit;
bool inPar = back ^ (parList.at(start).relPos != pos);
ParenthesesMatch result(block.position() + parList.at(start).relPos);
QStringRef parEnter = parentheses.midRef(back ? pSplit : 0, pSplit);
QStringRef parLeave = parentheses.midRef(back ? 0 : pSplit, pSplit);
Expand Down Expand Up @@ -1141,14 +1142,12 @@ ParenthesesMatch CodeEdit::matchParentheses()
if (parentheses.at(ci) == 'E') return ParenthesesMatch(); // only mark embedded on mismatch
result.valid = true;
result.match = block.position() + parList.at(pi).relPos;
result.inOutMatch = result.match + (inPar^back ? 0 : 1);
return result;
}
} else {
// Mark bad parentheses
parStack.clear();
result.match = block.position() + parList.at(pi).relPos;
result.inOutMatch = result.match + (inPar^back ? 0 : 1);
return result;
}
} else {
Expand Down
5 changes: 2 additions & 3 deletions src/editors/codeedit.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,11 @@ class LineNumberArea;
class SearchWidget;

struct ParenthesesMatch {
ParenthesesMatch(int _pos = -1, int _match = -1, int _inOutMatch = -1, bool _valid = false)
: pos(_pos), match(_match), inOutMatch(_inOutMatch), valid(_valid) {}
ParenthesesMatch(int _pos = -1, int _match = -1, bool _valid = false)
: pos(_pos), match(_match), valid(_valid) {}
bool isValid() {return pos>=0;}
int pos;
int match;
int inOutMatch;
bool valid;
};

Expand Down
12 changes: 12 additions & 0 deletions src/help/helpdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,18 @@ class HelpData
}
return getChapterLocation(DocumentType::Solvers);
}

inline static int getURLIndexFrom(const QString &urlStr) {
int index = -1;
QStringList pathList;
pathList << "/docs" << "/modlib_ml" << "/testlib_ml" << "/datalib_ml" << "/emplib_ml" << "/apilib_ml" << "/finlib_ml" << "/noalib_ml" << "/psoptlib_ml";
for(QString path : pathList) {
index = urlStr.indexOf(path);
if (index > -1)
return index;
}
return -1;
}
};

}
Expand Down
2 changes: 1 addition & 1 deletion src/help/helppage.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class HelpPage : public QWebEnginePage
Q_OBJECT

public:
HelpPage(QWidget *parent = 0);
HelpPage(QWidget *parent = nullptr);

protected:
bool acceptNavigationRequest(const QUrl& url, QWebEnginePage::NavigationType type, bool isMainFrame);
Expand Down
55 changes: 33 additions & 22 deletions src/help/helpwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,8 @@ HelpWidget::HelpWidget(QWidget *parent) :
bookmarkToolButton->setMenu(mBookmarkMenu);

QMenu* helpMenu = new QMenu;
QString onlineStartPageUrl = getOnlineStartPageUrl().toString();
ui->actionOnlineHelp->setText("View This Page from "+onlineStartPageUrl);
ui->actionOnlineHelp->setStatusTip("View This Page from "+onlineStartPageUrl);
ui->actionOnlineHelp->setText("View This Page Online");
ui->actionOnlineHelp->setStatusTip("View This Page Online");
ui->actionOnlineHelp->setCheckable(true);
helpMenu->addAction(ui->actionOnlineHelp);
helpMenu->addSeparator();
Expand Down Expand Up @@ -304,13 +303,16 @@ void HelpWidget::on_loadFinished(bool ok)
ui->actionOnlineHelp->setChecked( false );
if (ok) {
if (ui->webEngineView->url().host().compare("www.gams.com", Qt::CaseInsensitive) == 0 ) {
if (ui->webEngineView->url().path().contains( getCurrentReleaseVersion()) )
ui->actionOnlineHelp->setChecked( true );
else if (ui->webEngineView->url().path().contains("latest") && isCurrentReleaseTheLatestVersion())
ui->actionOnlineHelp->setChecked( true );
else
if (onlineStartPageUrl.isValid()) {
if (ui->webEngineView->url().path().contains( onlineStartPageUrl.path()))
ui->actionOnlineHelp->setChecked( true );
else if (ui->webEngineView->url().path().contains("latest"))
ui->actionOnlineHelp->setChecked( true );
else
ui->actionOnlineHelp->setEnabled( false );
} else {
ui->actionOnlineHelp->setEnabled( false );

}
} else {
if (ui->webEngineView->url().scheme().compare("file", Qt::CaseSensitive) !=0 )
ui->actionOnlineHelp->setEnabled( false );
Expand Down Expand Up @@ -366,7 +368,7 @@ void HelpWidget::on_actionOnlineHelp_triggered(bool checked)
{
QUrl url = ui->webEngineView->url();
QString baseLocation = QDir(CommonPaths::systemDir()).absolutePath();
QUrl onlineStartPageUrl = getOnlineStartPageUrl();
onlineStartPageUrl = getOnlineStartPageUrl();
if (checked) {
QString urlStr = url.toDisplayString();
urlStr.replace( urlStr.indexOf("file://"), 7, "");
Expand All @@ -375,18 +377,27 @@ void HelpWidget::on_actionOnlineHelp_triggered(bool checked)
onlineStartPageUrl.toDisplayString() );
url = QUrl(urlStr);
} else {
if (isDocumentAvailable(CommonPaths::systemDir(), HelpData::getChapterLocation(DocumentType::Main))) {
QString urlStr = url.toDisplayString();
urlStr.replace( urlStr.indexOf( onlineStartPageUrl.toDisplayString() ),
onlineStartPageUrl.toDisplayString().size(),
baseLocation);
url.setUrl(urlStr);
url.setScheme("file");
} else {
QString htmlText;
getErrorHTMLText( htmlText, getStartPageUrl() );
ui->webEngineView->setHtml( htmlText );
}
if (url.host().compare("www.gams.com", Qt::CaseInsensitive) == 0 ) {
if (isDocumentAvailable(CommonPaths::systemDir(), HelpData::getChapterLocation(DocumentType::Main))) {
QString urlStr = url.toDisplayString();
int docsidx = HelpData::getURLIndexFrom(urlStr);
if (docsidx > -1) {
urlStr.replace( 0, docsidx, baseLocation );
url.setUrl(urlStr);
url.setScheme("file");
qDebug() << url.toString();
} else {
ui->webEngineView->load( getStartPageUrl() );
}
} else {
QString htmlText;
getErrorHTMLText( htmlText, getStartPageUrl() );
ui->webEngineView->setHtml( htmlText );
}

} else {
ui->webEngineView->load( getStartPageUrl() );
}
}
ui->actionOnlineHelp->setChecked( checked );
ui->webEngineView->load( url );
Expand Down
1 change: 1 addition & 0 deletions src/help/helpwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ public slots:
QMultiMap<QString, QString> mBookmarkMap;
QMenu* mBookmarkMenu;
QLabel mStatusBarLabel;
QUrl onlineStartPageUrl;

QUrl getStartPageUrl();
QUrl getOnlineStartPageUrl();
Expand Down
1 change: 1 addition & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ int main(int argc, char *argv[])
{
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication::setApplicationVersion(STUDIO_VERSION);
QCoreApplication::setAttribute(Qt::AA_UseOpenGLES);

// to temporarily add additional information enable the following line
// qSetMessagePattern("[%{function}:%{line}] %{message}");
Expand Down
9 changes: 9 additions & 0 deletions src/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,9 @@
<property name="accessibleName">
<string>Project Explorer</string>
</property>
<property name="allowedAreas">
<set>Qt::BottomDockWidgetArea|Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea</set>
</property>
<property name="windowTitle">
<string>Project Explorer</string>
</property>
Expand Down Expand Up @@ -346,6 +349,9 @@
<property name="floating">
<bool>false</bool>
</property>
<property name="allowedAreas">
<set>Qt::BottomDockWidgetArea|Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea</set>
</property>
<property name="windowTitle">
<string>Output</string>
</property>
Expand Down Expand Up @@ -398,6 +404,9 @@
</widget>
</widget>
<widget class="QDockWidget" name="dockHelpView">
<property name="allowedAreas">
<set>Qt::BottomDockWidgetArea|Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea</set>
</property>
<property name="windowTitle">
<string>Help</string>
</property>
Expand Down
68 changes: 67 additions & 1 deletion src/support/aboutgamsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@
#include "gamsprocess.h"
#include "checkforupdatewrapper.h"
#include "solvertablemodel.h"
#include "commonpaths.h"

#include <QClipboard>
#include <QFile>
#include <QMessageBox>
#include <QSortFilterProxyModel>

namespace gams {
Expand All @@ -36,6 +39,8 @@ AboutGAMSDialog::AboutGAMSDialog(const QString &title, QWidget *parent) :
{
ui->setupUi(this);

createLicenseFile(parent);

setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
this->setWindowTitle(title);
ui->label->setText(gamsLicense());
Expand Down Expand Up @@ -94,6 +99,67 @@ QString AboutGAMSDialog::gamsLicense()
return about.join("");
}

void AboutGAMSDialog::createLicenseFile(QWidget *parent)
{
auto clipboard = QGuiApplication::clipboard();
auto licenseLines = clipboard->text().split('\n', QString::SkipEmptyParts);
if (!isValidLicense(licenseLines))
return;

QFile licenseFile(CommonPaths::systemDir() + "/gamslice.txt");
if (licenseFile.exists()) {
auto result = QMessageBox::question(parent,
"Overwrite current GAMS license file?",
"It looks like there is a GAMS license on the clipboard. "
"Do you want to overwrite your current license file from this text? "
"Your current license location is: " + licenseFile.fileName());
if (result == QMessageBox::No)
return;
} else {
auto result = QMessageBox::question(parent,
"Create GAMS license file?",
"It looks like there is a GAMS license on the clipboard. "
"Do you want to create a license file from this text? "
"Your GAMS license location will be: " + licenseFile.fileName());
if (result == QMessageBox::No)
return;
}

if (licenseFile.open(QFile::WriteOnly)) {
QTextStream stream(&licenseFile);
stream << licenseLines.join("\n");
licenseFile.close();
}
}

bool AboutGAMSDialog::isValidLicense(QStringList &license)
{
if (license.count() < 5)
return false;

for (int i=0; i<license.size(); ++i) {
license[i] = license[i].trimmed();
if (license[i].count() == 65)
continue;
else
return false;
}

if (license[0].at(54) != ':' && license[0].at(54) != '/')
return false;

// Most of the platform keys listed below are relevant for Studio.
// WIN, WEX, LEX, DEX, SOX, AIX, SIS, BGP, LNX, SOL, DAR, DII, GEN, ALL
if (!license[0].endsWith("-WIN") && !license[0].endsWith("-LNX") &&
!license[0].endsWith("-DAR") && !license[0].endsWith("-GEN") &&
!license[0].endsWith("-ALL"))
return false;

if (!license[4].startsWith("DC"))
return false;
return true;
}

void AboutGAMSDialog::on_copylicense_clicked()
{
GamsProcess gproc;
Expand All @@ -103,7 +169,7 @@ void AboutGAMSDialog::on_copylicense_clicked()

QString AboutGAMSDialog::header()
{
return "<b><big>GAMS Studio " + QApplication::applicationVersion() + "</big></b>";//<br/><br/>";
return "<b><big>GAMS Studio " + QApplication::applicationVersion() + "</big></b>";
}

QString AboutGAMSDialog:: aboutStudio()
Expand Down
2 changes: 2 additions & 0 deletions src/support/aboutgamsdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ class AboutGAMSDialog : public QDialog

private:
QString gamsLicense();
void createLicenseFile(QWidget *parent);
bool isValidLicense(QStringList &license);

private slots:
void on_copylicense_clicked();
Expand Down
2 changes: 1 addition & 1 deletion src/support/checkforupdatewrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ void CheckForUpdateWrapper::getMessages(int &messageIndex, char *buffer)

int CheckForUpdateWrapper::errorCallback(int count, const char *message)
{
Q_UNUSED(count);
Q_UNUSED(count)
auto logger = SysLogLocator::systemLog();
logger->append(InvalidGAMS, LogMsgType::Error);
logger->append(message, LogMsgType::Error);
Expand Down
Loading

0 comments on commit fdf7e9e

Please sign in to comment.