Skip to content

Commit

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

See merge request devel/studio!356
  • Loading branch information
MrMontag committed Oct 2, 2019
2 parents fdf7e9e + 10dfbd3 commit 9cadff0
Show file tree
Hide file tree
Showing 20 changed files with 186 additions and 63 deletions.
19 changes: 12 additions & 7 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
Version 0.12.7
Version 0.12.8
========================
- 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

# General
- fixed Studio not popping up for warning when drag'n'droping many files
- disabled GoTo dialog for all non-applicable widgets
- fixed crash when opening files with certain parenthesis constructs
- added fullscreen mode (win/linux: ALT+Return, macos: META+CMD+F)
- fixed accidental closing of log tab when closing results page

# Reference Viewer
- added auto resize when opening
- added context menu to let users auto resize after doing manual changes

1 change: 1 addition & 0 deletions platform/macos/macoscocoabridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class MacOSCocoaBridge
static void disableDictationMenuItem(bool flag);
static void disableCharacterPaletteMenuItem(bool flag);
static void setAllowsAutomaticWindowTabbing(bool flag);
static void setFullScreenMenuItemEverywhere(bool flag);
};

#endif // MACOSCOCOABRIDGE_H
5 changes: 5 additions & 0 deletions platform/macos/macoscocoabridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,8 @@
{
[NSWindow setAllowsAutomaticWindowTabbing: flag];
}

void MacOSCocoaBridge::setFullScreenMenuItemEverywhere(bool flag)
{
[[NSUserDefaults standardUserDefaults] setBool:flag forKey:@"NSFullScreenMenuItemEverywhere"];
}
1 change: 1 addition & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ using gams::studio::Application;
int main(int argc, char *argv[])
{
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication::setAttribute(Qt::AA_UseOpenGLES);
QApplication::setApplicationVersion(STUDIO_VERSION);
QCoreApplication::setAttribute(Qt::AA_UseOpenGLES);

Expand Down
35 changes: 28 additions & 7 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ MainWindow::MainWindow(QWidget *parent)
{
mTextMarkRepo.init(&mFileMetaRepo, &mProjectRepo);
mSettings = SettingsLocator::settings();
mHistory = new HistoryData();
// QFile css(":/data/style.css");
// if (css.open(QFile::ReadOnly | QFile::Text)) {
// this->setStyleSheet(css.readAll());
Expand All @@ -98,6 +97,10 @@ MainWindow::MainWindow(QWidget *parent)
MacOSCocoaBridge::disableDictationMenuItem(true);
MacOSCocoaBridge::disableCharacterPaletteMenuItem(true);
MacOSCocoaBridge::setAllowsAutomaticWindowTabbing(false);
MacOSCocoaBridge::setFullScreenMenuItemEverywhere(false);
ui->actionFull_Screen->setShortcut(QKeySequence::FullScreen);
#else
ui->actionFull_Screen->setShortcuts({QKeySequence("Alt+Enter"), QKeySequence("Alt+Return")});
#endif

if (QOperatingSystemVersion::currentType() == QOperatingSystemVersion::MacOS) {
Expand Down Expand Up @@ -219,7 +222,6 @@ MainWindow::MainWindow(QWidget *parent)
SearchLocator::provide(mSearchDialog);
SettingsLocator::provide(mSettings);
SysLogLocator::provide(mSyslog);

QTimer::singleShot(0, this, &MainWindow::openInitialFiles);
}

Expand Down Expand Up @@ -1644,7 +1646,10 @@ int MainWindow::showSaveChangesMsgBox(const QString &text)
void MainWindow::on_logTabs_tabCloseRequested(int index)
{
bool isResults = ui->logTabs->widget(index) == mSearchDialog->resultsView();
if (isResults) mSearchDialog->clearResults();
if (isResults) {
mSearchDialog->clearResults();
return;
}

QWidget* edit = ui->logTabs->widget(index);
if (edit) {
Expand Down Expand Up @@ -1711,7 +1716,7 @@ void MainWindow::triggerGamsLibFileCreation(LibraryItem *item)

HistoryData *MainWindow::history()
{
return mHistory;
return &mHistory;
}

void MainWindow::addToOpenedFiles(QString filePath)
Expand Down Expand Up @@ -1932,6 +1937,8 @@ void MainWindow::dropEvent(QDropEvent* e)

int answer;
if(pathList.size() > 25) {
raise();
activateWindow();
QMessageBox msgBox;
msgBox.setText("You are trying to open " + QString::number(pathList.size()) +
" files at once. Depending on the file sizes this may take a long time.");
Expand Down Expand Up @@ -2016,7 +2023,7 @@ void MainWindow::mouseMoveEvent(QMouseEvent* event)
{
if (event->buttons()) {
QWidget* child = childAt(event->pos());
Q_UNUSED(child);
Q_UNUSED(child)
}
QMainWindow::mouseMoveEvent(event);
}
Expand Down Expand Up @@ -2832,10 +2839,11 @@ void MainWindow::writeTabs(QJsonObject &json) const

void MainWindow::on_actionGo_To_triggered()
{
if ((ui->mainTab->currentWidget() == mWp))
return;
if ((ui->mainTab->currentWidget() == mWp)) return;
CodeEdit *codeEdit = ViewHelper::toCodeEdit(mRecent.editor());
TextView *tv = ViewHelper::toTextView(mRecent.editor());
if (!codeEdit && !tv) return;

int maxLines = codeEdit ? codeEdit->blockCount() : tv ? tv->knownLines() : 1000000;
GoToDialog dialog(this, maxLines, bool(tv));
int result = dialog.exec();
Expand Down Expand Up @@ -3377,6 +3385,19 @@ void MainWindow::setSearchWidgetPos(const QPoint& searchWidgetPos)
mSearchWidgetPos = searchWidgetPos;
}

void MainWindow::on_actionFull_Screen_triggered()
{
if (isFullScreen()) {
if (mMaximizedBeforeFullScreen)
showMaximized();
else
showNormal();
} else {
mMaximizedBeforeFullScreen = isMaximized();
showFullScreen();
}
}

}
}

4 changes: 3 additions & 1 deletion src/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ private slots:
void on_actionHelp_View_triggered(bool checked);
void on_actionShow_System_Log_triggered();
void on_actionShow_Welcome_Page_triggered();
void on_actionFull_Screen_triggered();
// Other
void on_mainTab_tabCloseRequested(int index);
void on_logTabs_tabCloseRequested(int index);
Expand Down Expand Up @@ -351,7 +352,7 @@ private slots:
QActionGroup *mCodecGroupSwitch;
QActionGroup *mCodecGroupReload;
RecentData mRecent;
HistoryData *mHistory;
HistoryData mHistory;
StudioSettings* mSettings;
std::unique_ptr<AutosaveHandler> mAutosaveHandler;
ProjectContextMenu mProjectContextMenu;
Expand All @@ -369,6 +370,7 @@ private slots:
int mTimerID;
QStringList mOpenTabsList;
QVector<int> mClosedTabsIndexes;
bool mMaximizedBeforeFullScreen;
};

}
Expand Down
15 changes: 14 additions & 1 deletion src/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
<x>0</x>
<y>0</y>
<width>1024</width>
<height>22</height>
<height>23</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
Expand Down Expand Up @@ -208,6 +208,8 @@
<addaction name="separator"/>
<addaction name="menuBookmarks"/>
<addaction name="actionReset_Views"/>
<addaction name="separator"/>
<addaction name="actionFull_Screen"/>
</widget>
<widget class="QMenu" name="menuHelp">
<property name="title">
Expand Down Expand Up @@ -1127,6 +1129,17 @@
<string>Delete leftover scratch directories in current working directory</string>
</property>
</action>
<action name="actionFull_Screen">
<property name="checkable">
<bool>true</bool>
</property>
<property name="text">
<string>Full Screen</string>
</property>
<property name="shortcutContext">
<enum>Qt::WindowShortcut</enum>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>
Expand Down
43 changes: 37 additions & 6 deletions src/reference/symbolreferencewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ SymbolReferenceWidget::SymbolReferenceWidget(Reference* ref, SymbolDataType::Sym
mReferenceViewer(parent)
{
ui->setupUi(this);
ui->symbolReferenceSplitter->setSizes(QList<int>({2500,1500}));

mSymbolTableModel = new SymbolTableModel(mType, this);
ui->symbolView->setModel( mSymbolTableModel );
Expand All @@ -45,15 +46,23 @@ SymbolReferenceWidget::SymbolReferenceWidget(Reference* ref, SymbolDataType::Sym
ui->symbolView->sortByColumn(1, Qt::AscendingOrder);
ui->symbolView->setSortingEnabled(true);
ui->symbolView->setAlternatingRowColors(true);
ui->symbolView->setContextMenuPolicy(Qt::CustomContextMenu);

ui->symbolView->horizontalHeader()->setStretchLastSection(true);
ui->symbolView->verticalHeader()->setSectionResizeMode(QHeaderView::Fixed);
ui->symbolView->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);
ui->symbolView->horizontalHeader()->setSectionResizeMode( mSymbolTableModel->getLastSectionIndex(), QHeaderView::Stretch );
ui->symbolView->verticalHeader()->setMinimumSectionSize(1);
ui->symbolView->verticalHeader()->setDefaultSectionSize(int(fontMetrics().height()*TABLE_ROW_HEIGHT));

QAction* resizeColumn = mContextMenu.addAction("Auto Resize Columns", [this]() { resizeColumnToContents(); }, QKeySequence("Ctrl+R"));
resizeColumn->setShortcutContext(Qt::WidgetWithChildrenShortcut);
resizeColumn->setShortcutVisibleInContextMenu(true);
ui->symbolView->addAction(resizeColumn);

connect(mSymbolTableModel, &SymbolTableModel::symbolSelectionToBeUpdated, this, &SymbolReferenceWidget::updateSymbolSelection);
connect(ui->symbolView, &QAbstractItemView::doubleClicked, this, &SymbolReferenceWidget::jumpToFile);
connect(ui->symbolView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &SymbolReferenceWidget::updateSelectedSymbol);
connect(ui->symbolView, &QTableView::customContextMenuRequested, this, &SymbolReferenceWidget::showContextMenu);
connect(ui->symbolSearchLineEdit, &QLineEdit::textChanged, mSymbolTableModel, &SymbolTableModel::setFilterPattern);
connect(ui->allColumnToggleSearch, &QCheckBox::toggled, mSymbolTableModel, &SymbolTableModel::toggleSearchColumns);

Expand All @@ -63,11 +72,9 @@ SymbolReferenceWidget::SymbolReferenceWidget(Reference* ref, SymbolDataType::Sym
ui->referenceView->setSelectionBehavior(QAbstractItemView::SelectRows);
ui->referenceView->setSelectionMode(QAbstractItemView::SingleSelection);
ui->referenceView->setItemsExpandable(true);
ui->referenceView->expandAll();
ui->referenceView->resizeColumnToContents(0);
ui->referenceView->resizeColumnToContents(1);
ui->referenceView->setAlternatingRowColors(true);
ui->referenceView->setColumnHidden(3, true);
expandResetModel();

connect(ui->referenceView, &QAbstractItemView::doubleClicked, this, &SymbolReferenceWidget::jumpToReferenceItem);
connect( mReferenceTreeModel, &ReferenceTreeModel::modelReset, this, &SymbolReferenceWidget::expandResetModel);
Expand All @@ -92,7 +99,7 @@ bool SymbolReferenceWidget::isModelLoaded() const

void SymbolReferenceWidget::updateSelectedSymbol(QItemSelection selected, QItemSelection deselected)
{
Q_UNUSED(deselected);
Q_UNUSED(deselected)
if (selected.indexes().size() > 0) {
if (mType == SymbolDataType::FileUsed) {
mCurrentSymbolID = -1;
Expand Down Expand Up @@ -142,8 +149,10 @@ void SymbolReferenceWidget::resetModel()

void SymbolReferenceWidget::initModel()
{
if (!mSymbolTableModel->isModelLoaded())
if (!mSymbolTableModel->isModelLoaded()) {
mSymbolTableModel->initModel(mReference);
resizeColumnToContents();
}

mReferenceTreeModel->resetModel();
}
Expand Down Expand Up @@ -183,6 +192,28 @@ void SymbolReferenceWidget::updateSymbolSelection()
}
}

void SymbolReferenceWidget::resizeColumnToContents()
{
ui->symbolView->resizeColumnsToContents();
ui->symbolView->horizontalHeader()->setSectionResizeMode( mSymbolTableModel->getLastSectionIndex(), QHeaderView::Stretch );
}

void SymbolReferenceWidget::showContextMenu(QPoint p)
{
QModelIndexList indexSelection = ui->symbolView->selectionModel()->selectedIndexes();
if (indexSelection.size()<=0)
return;

if (mSymbolTableModel->rowCount()>0 && ui->symbolView->horizontalHeader()->logicalIndexAt(p)>=0) {
QMenu m(this);
for(QAction* action : ui->symbolView->actions()) {
action->setEnabled(true);
m.addAction(action);
}
m.exec(ui->symbolView->viewport()->mapToGlobal(p));
}
}

} // namespace reference
} // namespace studio
} // namespace gams
4 changes: 4 additions & 0 deletions src/reference/symbolreferencewidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#define SYMBOLREFERENCEWIDGET_H

#include <QWidget>
#include <QMenu>
#include <QSortFilterProxyModel>
#include <QItemSelection>

Expand Down Expand Up @@ -59,9 +60,12 @@ public slots:
void jumpToFile(const QModelIndex &index);
void jumpToReferenceItem(const QModelIndex &index);
void updateSymbolSelection();
void resizeColumnToContents();
void showContextMenu(QPoint p);

private:
Ui::SymbolReferenceWidget *ui;
QMenu mContextMenu;

SymbolTableModel* mSymbolTableModel;
ReferenceTreeModel* mReferenceTreeModel;
Expand Down
15 changes: 15 additions & 0 deletions src/reference/symbolreferencewidget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,21 @@
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>6</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QSplitter" name="symbolReferenceSplitter">
<property name="sizePolicy">
Expand Down
24 changes: 23 additions & 1 deletion src/reference/symboltablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ QVariant SymbolTableModel::data(const QModelIndex &index, int role) const
case SymbolDataType::Model :
switch(index.column()) {
case 0: return QString::number( refList.at(idx)->id() );
case 1: return refList.at(idx)->name();;
case 1: return refList.at(idx)->name();
case 2: return SymbolDataType::from( refList.at(idx)->type() ).name();
case 3: return refList.at(idx)->explanatoryText();
default: break;
Expand Down Expand Up @@ -375,6 +375,28 @@ void SymbolTableModel::setFilterPattern(const QString &pattern)
emit symbolSelectionToBeUpdated();
}

int SymbolTableModel::getLastSectionIndex()
{
switch(mType) {
case SymbolDataType::Set :
case SymbolDataType::Acronym :
case SymbolDataType::Parameter :
case SymbolDataType::Variable :
case SymbolDataType::Equation :
return 4;
case SymbolDataType::Model :
case SymbolDataType::Funct :
case SymbolDataType::File :
return 2;
case SymbolDataType::FileUsed :
return 0;
case SymbolDataType::Unknown :
case SymbolDataType::Unused :
return 5;
}
return 0;
}

SymbolTableModel::SortType SymbolTableModel::getSortTypeOf(int column) const
{
switch(mType) {
Expand Down
1 change: 1 addition & 0 deletions src/reference/symboltablemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class SymbolTableModel : public QAbstractTableModel
int getSortedIndexOf(const QString &name) const;
void toggleSearchColumns(bool checked);
void setFilterPattern(const QString& pattern);
int getLastSectionIndex();

static const int COLUMN_SYMBOL_ID = 0;
static const int COLUMN_SYMBOL_NAME = 1;
Expand Down
1 change: 1 addition & 0 deletions src/studio.pro
Original file line number Diff line number Diff line change
Expand Up @@ -363,4 +363,5 @@ OTHER_FILES += \
../jenkinsfile \
../jenkinsfile-ci \
../gamsstudio.desktop \
../CHANGELOG \
../version
Loading

0 comments on commit 9cadff0

Please sign in to comment.